mirror of https://github.com/OpenTTD/OpenTTD.git
Fix: Scale graph gridlines and axes with GUI scale
This commit is contained in:
parent
f1bf39f38b
commit
75774837f1
|
@ -347,18 +347,19 @@ protected:
|
|||
/* Draw the background of the graph itself. */
|
||||
GfxFillRect(r.left, r.top, r.right, r.bottom, GRAPH_BASE_COLOUR);
|
||||
|
||||
/* Draw the vertical grid lines. */
|
||||
/* Draw the grid lines. */
|
||||
int gridline_width = WidgetDimensions::scaled.bevel.top;
|
||||
int grid_colour = GRAPH_GRID_COLOUR;
|
||||
|
||||
/* Don't draw the first line, as that's where the axis will be. */
|
||||
/* Draw the vertical grid lines, skipping the first as that's where the axis will be. */
|
||||
x = r.left + x_sep;
|
||||
|
||||
int grid_colour = GRAPH_GRID_COLOUR;
|
||||
for (int i = 1; i < this->num_vert_lines + 1; i++) {
|
||||
/* If using wallclock units, we separate periods with a lighter line. */
|
||||
if (TimerGameEconomy::UsingWallclockUnits()) {
|
||||
grid_colour = (i % 4 == 0) ? GRAPH_YEAR_LINE_COLOUR : GRAPH_GRID_COLOUR;
|
||||
}
|
||||
GfxFillRect(x, r.top, x, r.bottom, grid_colour);
|
||||
GfxFillRect(x, r.top, x + gridline_width - 1, r.bottom, grid_colour);
|
||||
x += x_sep;
|
||||
}
|
||||
|
||||
|
@ -366,17 +367,17 @@ protected:
|
|||
y = r.bottom;
|
||||
|
||||
for (int i = 0; i < (num_hori_lines + 1); i++) {
|
||||
GfxFillRect(r.left - ScaleGUITrad(3), y, r.left - 1, y, GRAPH_AXIS_LINE_COLOUR);
|
||||
GfxFillRect(r.left, y, r.right, y, GRAPH_GRID_COLOUR);
|
||||
GfxFillRect(r.left - ScaleGUITrad(3), y, r.left - 1, y + gridline_width - 1, GRAPH_AXIS_LINE_COLOUR);
|
||||
GfxFillRect(r.left, y, r.right + gridline_width - 1, y + gridline_width - 1, GRAPH_GRID_COLOUR);
|
||||
y -= y_sep;
|
||||
}
|
||||
|
||||
/* Draw the y axis. */
|
||||
GfxFillRect(r.left, r.top, r.left, r.bottom, GRAPH_AXIS_LINE_COLOUR);
|
||||
GfxFillRect(r.left, r.top, r.left + gridline_width - 1, r.bottom + gridline_width - 1, GRAPH_AXIS_LINE_COLOUR);
|
||||
|
||||
/* Draw the x axis. */
|
||||
y = x_axis_offset + r.top;
|
||||
GfxFillRect(r.left, y, r.right, y, GRAPH_ZERO_LINE_COLOUR);
|
||||
GfxFillRect(r.left, y, r.right + gridline_width - 1, y + gridline_width - 1, GRAPH_ZERO_LINE_COLOUR);
|
||||
|
||||
/* Find the largest value that will be drawn. */
|
||||
if (this->num_on_x_axis == 0) return;
|
||||
|
@ -415,7 +416,7 @@ protected:
|
|||
year++;
|
||||
|
||||
/* Draw a lighter grid line between years. Top and bottom adjustments ensure we don't draw over top and bottom horizontal grid lines. */
|
||||
GfxFillRect(x + x_sep, r.top + 1, x + x_sep, r.bottom - 1, GRAPH_YEAR_LINE_COLOUR);
|
||||
GfxFillRect(x + x_sep, r.top + gridline_width, x + x_sep + gridline_width - 1, r.bottom - 1, GRAPH_YEAR_LINE_COLOUR);
|
||||
}
|
||||
x += x_sep;
|
||||
}
|
||||
|
@ -434,10 +435,11 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
/* draw lines and dots */
|
||||
uint linewidth = _settings_client.gui.graph_line_thickness;
|
||||
uint pointoffs1 = (linewidth + 1) / 2;
|
||||
uint pointoffs2 = linewidth + 1 - pointoffs1;
|
||||
/* Draw lines and dots. */
|
||||
uint linewidth = ScaleGUITrad(_settings_client.gui.graph_line_thickness);
|
||||
uint pointwidth = ScaleGUITrad(_settings_client.gui.graph_line_thickness + 1);
|
||||
uint pointoffs1 = pointwidth / 2;
|
||||
uint pointoffs2 = pointwidth - pointoffs1;
|
||||
for (int i = 0; i < this->num_dataset; i++) {
|
||||
if (!HasBit(this->excluded_data, i)) {
|
||||
/* Centre the dot between the grid lines. */
|
||||
|
|
Loading…
Reference in New Issue