Changeset - r28814:02b90af3b0cc
[Not reviewed]
master
0 19 0
Peter Nelson - 4 months ago 2023-12-28 10:04:55
peter1138@openttd.org
Codechange: Give ColourShade values names instead of numbers.
19 files changed with 55 insertions and 55 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1014,13 +1014,13 @@ void DrawEngineList(VehicleType type, co
 
	bool rtl = _current_text_dir == TD_RTL;
 
	int step_size = GetEngineListHeight(type);
 
	int sprite_left  = GetVehicleImageCellSize(type, EIT_PURCHASE).extend_left;
 
	int sprite_right = GetVehicleImageCellSize(type, EIT_PURCHASE).extend_right;
 
	int sprite_width = sprite_left + sprite_right;
 
	int circle_width = std::max(GetScaledSpriteSize(SPR_CIRCLE_FOLDED).width, GetScaledSpriteSize(SPR_CIRCLE_UNFOLDED).width);
 
	int linecolour = GetColourGradient(COLOUR_ORANGE, SHADE_4);
 
	int linecolour = GetColourGradient(COLOUR_ORANGE, SHADE_NORMAL);
 

	
 
	Rect ir      = r.WithHeight(step_size).Shrink(WidgetDimensions::scaled.matrix);
 
	int sprite_y_offset = ScaleSpriteTrad(sprite_y_offsets[type]) + ir.Height() / 2;
 

	
 
	Dimension replace_icon = {0, 0};
 
	int count_width = 0;
src/company_cmd.cpp
Show inline comments
 
@@ -143,14 +143,14 @@ void SetLocalCompany(CompanyID new_compa
 
 * Get the colour for DrawString-subroutines which matches the colour of the company.
 
 * @param company Company to get the colour of.
 
 * @return Colour of \a company.
 
 */
 
TextColour GetDrawStringCompanyColour(CompanyID company)
 
{
 
	if (!Company::IsValidID(company)) return (TextColour)GetColourGradient(COLOUR_WHITE, SHADE_4) | TC_IS_PALETTE_COLOUR;
 
	return (TextColour)GetColourGradient(_company_colours[company], SHADE_4) | TC_IS_PALETTE_COLOUR;
 
	if (!Company::IsValidID(company)) return (TextColour)GetColourGradient(COLOUR_WHITE, SHADE_NORMAL) | TC_IS_PALETTE_COLOUR;
 
	return (TextColour)GetColourGradient(_company_colours[company], SHADE_NORMAL) | TC_IS_PALETTE_COLOUR;
 
}
 

	
 
/**
 
 * Draw the icon of a company.
 
 * @param c Company that needs its icon drawn.
 
 * @param x Horizontal coordinate of the icon.
src/console_gui.cpp
Show inline comments
 
@@ -491,11 +491,11 @@ bool IsValidConsoleColour(TextColour c)
 
	if (!(c & TC_IS_PALETTE_COLOUR)) return TC_BEGIN <= c && c < TC_END;
 

	
 
	/* A text colour from the palette is used; must be the company
 
	 * colour gradient, so it must be one of those. */
 
	c &= ~TC_IS_PALETTE_COLOUR;
 
	for (Colours i = COLOUR_BEGIN; i < COLOUR_END; i++) {
 
		if (GetColourGradient(i, SHADE_4) == c) return true;
 
		if (GetColourGradient(i, SHADE_NORMAL) == c) return true;
 
	}
 

	
 
	return false;
 
}
src/depot_gui.cpp
Show inline comments
 
@@ -381,13 +381,13 @@ struct DepotWindow : Window {
 
		 * This only works in two cases:
 
		 *  - All vehicles use VEHICLEINFO_FULL_VEHICLE_WIDTH as reference width.
 
		 *  - All vehicles are 8/8. This cannot be checked for NewGRF, so instead we check for "all vehicles are original vehicles".
 
		 */
 
		if (this->type == VEH_TRAIN && _consistent_train_width != 0) {
 
			int w = ScaleSpriteTrad(2 * _consistent_train_width);
 
			int col = GetColourGradient(wid->colour, SHADE_4);
 
			int col = GetColourGradient(wid->colour, SHADE_NORMAL);
 
			Rect image = ir.Indent(this->header_width, rtl).Indent(this->count_width, !rtl);
 
			int first_line = w + (-this->hscroll->GetPosition()) % w;
 
			if (rtl) {
 
				for (int x = image.right - first_line; x >= image.left; x -= w) {
 
					GfxDrawLine(x, r.top, x, r.bottom, col, ScaleGUITrad(1), ScaleGUITrad(3));
 
				}
src/graph_gui.cpp
Show inline comments
 
@@ -624,13 +624,13 @@ public:
 
		this->month = mo;
 

	
 
		int numd = 0;
 
		for (CompanyID k = COMPANY_FIRST; k < MAX_COMPANIES; k++) {
 
			const Company *c = Company::GetIfValid(k);
 
			if (c != nullptr) {
 
				this->colours[numd] = GetColourGradient(c->colour, SHADE_6);
 
				this->colours[numd] = GetColourGradient(c->colour, SHADE_LIGHTER);
 
				for (int j = this->num_on_x_axis, i = 0; --j >= 0;) {
 
					if (j >= c->num_valid_stat_ent) {
 
						this->cost[numd][i] = INVALID_DATAPOINT;
 
					} else {
 
						/* Ensure we never assign INVALID_DATAPOINT, as that has another meaning.
 
						 * Instead, use the value just under it. Hopefully nobody will notice. */
 
@@ -1291,14 +1291,14 @@ struct PerformanceRatingDetailWindow : W
 

	
 
		if (!IsInsideMM(widget, WID_PRD_SCORE_FIRST, WID_PRD_SCORE_LAST + 1)) return;
 

	
 
		ScoreID score_type = (ScoreID)(widget - WID_PRD_SCORE_FIRST);
 

	
 
		/* The colours used to show how the progress is going */
 
		int colour_done = GetColourGradient(COLOUR_GREEN, SHADE_4);
 
		int colour_notdone = GetColourGradient(COLOUR_RED, SHADE_4);
 
		int colour_done = GetColourGradient(COLOUR_GREEN, SHADE_NORMAL);
 
		int colour_notdone = GetColourGradient(COLOUR_RED, SHADE_NORMAL);
 

	
 
		/* Draw all the score parts */
 
		int64_t val    = _score_part[company][score_type];
 
		int64_t needed = _score_info[score_type].needed;
 
		int   score  = _score_info[score_type].score;
 

	
src/group_gui.cpp
Show inline comments
 
@@ -259,13 +259,13 @@ private:
 
	 * @param has_children Whether the group has children and should have a fold / unfold button.
 
	 */
 
	void DrawGroupInfo(int y, int left, int right, GroupID g_id, int indent = 0, bool protection = false, bool has_children = false) const
 
	{
 
		/* Highlight the group if a vehicle is dragged over it */
 
		if (g_id == this->group_over) {
 
			GfxFillRect(left + WidgetDimensions::scaled.bevel.left, y + WidgetDimensions::scaled.framerect.top, right - WidgetDimensions::scaled.bevel.right, y + this->tiny_step_height - 1 - WidgetDimensions::scaled.framerect.bottom, GetColourGradient(COLOUR_GREY, SHADE_7));
 
			GfxFillRect(left + WidgetDimensions::scaled.bevel.left, y + WidgetDimensions::scaled.framerect.top, right - WidgetDimensions::scaled.bevel.right, y + this->tiny_step_height - 1 - WidgetDimensions::scaled.framerect.bottom, GetColourGradient(COLOUR_GREY, SHADE_LIGHTEST));
 
		}
 

	
 
		if (g_id == NEW_GROUP) return;
 

	
 
		/* draw the selected group in white, else we draw it in black */
 
		TextColour colour = g_id == this->vli.index ? TC_WHITE : TC_BLACK;
 
@@ -627,13 +627,13 @@ public:
 
					/* Mark vehicles which are in sub-groups (only if we are not using shared order coalescing) */
 
					Rect mr = r.WithHeight(this->resize.step_height);
 
					size_t max = std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehgroups.size());
 
					for (size_t i = this->vscroll->GetPosition(); i < max; ++i) {
 
						const Vehicle *v = this->vehgroups[i].GetSingleVehicle();
 
						if (v->group_id != this->vli.index) {
 
							GfxFillRect(mr.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(COLOUR_GREY, SHADE_3), FILLRECT_CHECKER);
 
							GfxFillRect(mr.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(COLOUR_GREY, SHADE_DARK), FILLRECT_CHECKER);
 
						}
 
						mr = mr.Translate(0, this->resize.step_height);
 
					}
 
				}
 

	
 
				this->DrawVehicleListItems(this->vehicle_sel, this->resize.step_height, r);
src/linkgraph/linkgraph_gui.cpp
Show inline comments
 
@@ -309,13 +309,13 @@ void LinkGraphOverlay::DrawContent(Point
 
		GfxDrawLine(pta.x + offset_x, pta.y, ptb.x + offset_x, ptb.y, colour, width, dash);
 
	} else {
 
		int offset_y = (pta.x < ptb.x ? 1 : -1) * side * width;
 
		GfxDrawLine(pta.x, pta.y + offset_y, ptb.x, ptb.y + offset_y, colour, width, dash);
 
	}
 

	
 
	GfxDrawLine(pta.x, pta.y, ptb.x, ptb.y, GetColourGradient(COLOUR_GREY, SHADE_1), width);
 
	GfxDrawLine(pta.x, pta.y, ptb.x, ptb.y, GetColourGradient(COLOUR_GREY, SHADE_DARKEST), width);
 
}
 

	
 
/**
 
 * Draw dots for stations into the smallmap. The dots' sizes are determined by the amount of
 
 * cargo produced there, their colours by the type of cargo produced.
 
 */
 
@@ -329,14 +329,14 @@ void LinkGraphOverlay::DrawStationDots(c
 
		if (!this->IsPointVisible(pt, dpi, 3 * width)) continue;
 

	
 
		uint r = width * 2 + width * 2 * std::min(200U, i.second) / 200;
 

	
 
		LinkGraphOverlay::DrawVertex(pt.x, pt.y, r,
 
				GetColourGradient(st->owner != OWNER_NONE ?
 
						Company::Get(st->owner)->colour : COLOUR_GREY, SHADE_5),
 
				GetColourGradient(COLOUR_GREY, SHADE_1));
 
						Company::Get(st->owner)->colour : COLOUR_GREY, SHADE_LIGHT),
 
				GetColourGradient(COLOUR_GREY, SHADE_DARKEST));
 
	}
 
}
 

	
 
/**
 
 * Draw a square symbolizing a producer of cargo.
 
 * @param x X coordinate of the middle of the vertex.
src/misc_gui.cpp
Show inline comments
 
@@ -791,13 +791,13 @@ void QueryString::DrawEditBox(const Wind
 
	Rect r = wi->GetCurrentRect();
 
	Rect cr = r.WithWidth(clearbtn_width, !rtl);
 
	Rect fr = r.Indent(clearbtn_width, !rtl);
 

	
 
	DrawFrameRect(cr, wi->colour, wi->IsLowered() ? FR_LOWERED : FR_NONE);
 
	DrawSpriteIgnorePadding(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT, PAL_NONE, cr, SA_CENTER);
 
	if (this->text.bytes == 1) GfxFillRect(cr.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(wi->colour, SHADE_2), FILLRECT_CHECKER);
 
	if (this->text.bytes == 1) GfxFillRect(cr.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(wi->colour, SHADE_DARKER), FILLRECT_CHECKER);
 

	
 
	DrawFrameRect(fr, wi->colour, FR_LOWERED | FR_DARKENED);
 
	GfxFillRect(fr.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK);
 

	
 
	fr = fr.Shrink(WidgetDimensions::scaled.framerect);
 
	/* Limit the drawing of the string inside the widget boundaries */
src/network/network_gui.cpp
Show inline comments
 
@@ -1943,13 +1943,13 @@ public:
 
			r.top = y + offset;
 
			r.bottom = r.top + button->height - 1;
 

	
 
			DrawFrameRect(r, button->colour, FR_NONE);
 
			DrawSprite(button->sprite, PAL_NONE, r.left + WidgetDimensions::scaled.framerect.left, r.top + WidgetDimensions::scaled.framerect.top);
 
			if (button->disabled) {
 
				GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(button->colour, SHADE_2), FILLRECT_CHECKER);
 
				GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(button->colour, SHADE_DARKER), FILLRECT_CHECKER);
 
			}
 

	
 
			int width = button->width + WidgetDimensions::scaled.hsep_normal;
 
			x += rtl ? width : -width;
 
		}
 
	}
src/order_gui.cpp
Show inline comments
 
@@ -1121,13 +1121,13 @@ public:
 

	
 
				if (i != this->selected_order && i == this->order_over) {
 
					/* Highlight dragged order destination. */
 
					int top = (this->order_over < this->selected_order ? y : y + line_height) - WidgetDimensions::scaled.framerect.top;
 
					int bottom = std::min(top + 2, ir.bottom);
 
					top = std::max(top - 3, ir.top);
 
					GfxFillRect(ir.left, top, ir.right, bottom, GetColourGradient(COLOUR_GREY, SHADE_7));
 
					GfxFillRect(ir.left, top, ir.right, bottom, GetColourGradient(COLOUR_GREY, SHADE_LIGHTEST));
 
					break;
 
				}
 
				y += line_height;
 

	
 
				i++;
 
				order = order->next;
src/palette_func.h
Show inline comments
 
@@ -39,19 +39,19 @@ inline bool IsValidColours(Colours colou
 
}
 

	
 
TextColour GetContrastColour(uint8_t background, uint8_t threshold = 128);
 

	
 
enum ColourShade : uint8_t {
 
	SHADE_BEGIN = 0,
 
	SHADE_1,
 
	SHADE_2,
 
	SHADE_3,
 
	SHADE_4,
 
	SHADE_5,
 
	SHADE_6,
 
	SHADE_7,
 
	SHADE_DARKEST,
 
	SHADE_DARKER,
 
	SHADE_DARK,
 
	SHADE_NORMAL,
 
	SHADE_LIGHT,
 
	SHADE_LIGHTER,
 
	SHADE_LIGHTEST,
 
	SHADE_END,
 
};
 
DECLARE_POSTFIX_INCREMENT(ColourShade)
 

	
 
byte GetColourGradient(Colours colour, ColourShade shade);
 
void SetColourGradient(Colours colour, ColourShade shade, byte palette_colour);
src/settings_gui.cpp
Show inline comments
 
@@ -1411,13 +1411,13 @@ uint BaseSettingEntry::Draw(GameSettings
 
	bool rtl = _current_text_dir == TD_RTL;
 
	int offset = (rtl ? -(int)_circle_size.width : (int)_circle_size.width) / 2;
 
	int level_width = rtl ? -WidgetDimensions::scaled.hsep_indent : WidgetDimensions::scaled.hsep_indent;
 

	
 
	int x = rtl ? right : left;
 
	if (cur_row >= first_row) {
 
		int colour = GetColourGradient(COLOUR_ORANGE, SHADE_4);
 
		int colour = GetColourGradient(COLOUR_ORANGE, SHADE_NORMAL);
 
		y += (cur_row - first_row) * SETTING_HEIGHT; // Compute correct y start position
 

	
 
		/* Draw vertical for parent nesting levels */
 
		for (uint lvl = 0; lvl < this->level; lvl++) {
 
			if (!HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y + SETTING_HEIGHT - 1, colour);
 
			x += level_width;
 
@@ -2906,13 +2906,13 @@ void ShowGameSettings()
 
 * @param state 0 = none clicked, 1 = first clicked, 2 = second clicked
 
 * @param clickable_left is the left button clickable?
 
 * @param clickable_right is the right button clickable?
 
 */
 
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
 
{
 
	int colour = GetColourGradient(button_colour, SHADE_2);
 
	int colour = GetColourGradient(button_colour, SHADE_DARKER);
 
	Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
 

	
 
	Rect lr = {x,                  y, x + (int)dim.width     - 1, y + (int)dim.height - 1};
 
	Rect rr = {x + (int)dim.width, y, x + (int)dim.width * 2 - 1, y + (int)dim.height - 1};
 

	
 
	DrawFrameRect(lr, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
 
@@ -2937,13 +2937,13 @@ void DrawArrowButtons(int x, int y, Colo
 
 * @param button_colour the colour of the button
 
 * @param state true = lowered
 
 * @param clickable is the button clickable?
 
 */
 
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
 
{
 
	int colour = GetColourGradient(button_colour, SHADE_2);
 
	int colour = GetColourGradient(button_colour, SHADE_DARKER);
 

	
 
	Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
 

	
 
	DrawFrameRect(r, button_colour, state ? FR_LOWERED : FR_NONE);
 
	DrawSpriteIgnorePadding(SPR_ARROW_DOWN, PAL_NONE, r, SA_CENTER);
 

	
src/smallmap_gui.cpp
Show inline comments
 
@@ -343,13 +343,13 @@ void BuildLandLegend()
 
void BuildOwnerLegend()
 
{
 
	_legend_land_owners[1].colour = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].default_colour;
 

	
 
	int i = NUM_NO_COMPANY_ENTRIES;
 
	for (const Company *c : Company::Iterate()) {
 
		_legend_land_owners[i].colour = GetColourGradient(c->colour, SHADE_5);
 
		_legend_land_owners[i].colour = GetColourGradient(c->colour, SHADE_LIGHT);
 
		_legend_land_owners[i].company = c->index;
 
		_legend_land_owners[i].show_on_map = true;
 
		_legend_land_owners[i].col_break = false;
 
		_legend_land_owners[i].end = false;
 
		_company_to_list_pos[c->index] = i;
 
		i++;
src/train_gui.cpp
Show inline comments
 
@@ -73,13 +73,13 @@ static int HighlightDragPosition(int px,
 

	
 
	if (drag_hlight_width > 0) {
 
		int height = ScaleSpriteTrad(12);
 
		int top = y - height / 2;
 
		Rect r = {drag_hlight_left, top, drag_hlight_right, top + height - 1};
 
		/* Sprite-scaling is used here as the area is from sprite size */
 
		GfxFillRect(r.Shrink(ScaleSpriteTrad(1)), GetColourGradient(COLOUR_GREY, SHADE_7));
 
		GfxFillRect(r.Shrink(ScaleSpriteTrad(1)), GetColourGradient(COLOUR_GREY, SHADE_LIGHTEST));
 
	}
 

	
 
	return drag_hlight_width;
 
}
 

	
 
/**
 
@@ -396,13 +396,13 @@ void DrawTrainDetails(const Train *v, co
 
			Rect dr = r.Indent(sprite_width, rtl);
 
			uint num_lines = std::max(1u, (unsigned)_cargo_summary.size());
 
			for (uint i = 0; i < num_lines; i++) {
 
				if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
 
					int py = r.top - line_height * vscroll_pos + text_y_offset;
 
					if (i > 0 || separate_sprite_row) {
 
						if (vscroll_pos != 0) GfxFillRect(r.left, py - WidgetDimensions::scaled.matrix.top - 1, r.right, py - WidgetDimensions::scaled.matrix.top, GetColourGradient(COLOUR_GREY, SHADE_5));
 
						if (vscroll_pos != 0) GfxFillRect(r.left, py - WidgetDimensions::scaled.matrix.top - 1, r.right, py - WidgetDimensions::scaled.matrix.top, GetColourGradient(COLOUR_GREY, SHADE_LIGHT));
 
					}
 
					switch (det_tab) {
 
						case TDW_TAB_CARGO:
 
							if (i < _cargo_summary.size()) {
 
								TrainDetailsCargoTab(&_cargo_summary[i], dr.left, dr.right, py);
 
							} else {
src/vehicle_gui.cpp
Show inline comments
 
@@ -621,13 +621,13 @@ static void DrawVehicleRefitWindow(const
 
	Rect ir = r.Shrink(WidgetDimensions::scaled.matrix);
 
	uint current = 0;
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
	uint iconwidth = std::max(GetSpriteSize(SPR_CIRCLE_FOLDED).width, GetSpriteSize(SPR_CIRCLE_UNFOLDED).width);
 
	uint iconheight = GetSpriteSize(SPR_CIRCLE_FOLDED).height;
 
	int linecolour = GetColourGradient(COLOUR_ORANGE, SHADE_4);
 
	int linecolour = GetColourGradient(COLOUR_ORANGE, SHADE_NORMAL);
 

	
 
	int iconleft   = rtl ? ir.right - iconwidth     : ir.left;
 
	int iconcenter = rtl ? ir.right - iconwidth / 2 : ir.left + iconwidth / 2;
 
	int iconinner  = rtl ? ir.right - iconwidth     : ir.left + iconwidth;
 

	
 
	Rect tr = ir.Indent(iconwidth + WidgetDimensions::scaled.hsep_wide, rtl);
src/viewport.cpp
Show inline comments
 
@@ -1713,13 +1713,13 @@ static void ViewportDrawStrings(ZoomLeve
 

	
 
		if (ss.colour != INVALID_COLOUR) {
 
			if (IsTransparencySet(TO_SIGNS) && ss.string_id != STR_WHITE_SIGN) {
 
				/* Don't draw the rectangle.
 
				 * Real colours need the TC_IS_PALETTE_COLOUR flag.
 
				 * Otherwise colours from _string_colourmap are assumed. */
 
				colour = (TextColour)GetColourGradient(ss.colour, SHADE_6) | TC_IS_PALETTE_COLOUR;
 
				colour = (TextColour)GetColourGradient(ss.colour, SHADE_LIGHTER) | TC_IS_PALETTE_COLOUR;
 
			} else {
 
				/* Draw the rectangle if 'transparent station signs' is off,
 
				 * or if we are drawing a general text sign (STR_WHITE_SIGN). */
 
				DrawFrameRect(
 
					x, y, x + w - 1, y + h - 1, ss.colour,
 
					IsTransparencySet(TO_SIGNS) ? FR_TRANSPARENT : FR_NONE
src/widget.cpp
Show inline comments
 
@@ -279,16 +279,16 @@ WidgetID GetWidgetFromPos(const Window *
 
 * @param flags  Flags controlling how to draw the frame. @see FrameFlags
 
 */
 
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
 
{
 
	assert(colour < COLOUR_END);
 

	
 
	uint dark         = GetColourGradient(colour, SHADE_3);
 
	uint medium_dark  = GetColourGradient(colour, SHADE_5);
 
	uint medium_light = GetColourGradient(colour, SHADE_6);
 
	uint light        = GetColourGradient(colour, SHADE_7);
 
	uint dark         = GetColourGradient(colour, SHADE_DARK);
 
	uint medium_dark  = GetColourGradient(colour, SHADE_LIGHT);
 
	uint medium_light = GetColourGradient(colour, SHADE_LIGHTER);
 
	uint light        = GetColourGradient(colour, SHADE_LIGHTEST);
 

	
 
	if (flags & FR_TRANSPARENT) {
 
		GfxFillRect(left, top, right, bottom, PALETTE_TO_TRANSPARENT, FILLRECT_RECOLOUR);
 
	} else {
 
		uint interior;
 

	
 
@@ -420,13 +420,13 @@ static inline void DrawMatrix(const Rect
 
		row_height = resize_y;
 
		num_rows = r.Height() / row_height;
 
	} else {
 
		row_height = r.Height() / num_rows;
 
	}
 

	
 
	int col = GetColourGradient(colour, SHADE_6);
 
	int col = GetColourGradient(colour, SHADE_LIGHTER);
 

	
 
	int x = r.left;
 
	for (int ctr = num_columns; ctr > 1; ctr--) {
 
		x += column_width;
 
		GfxFillRect(x, r.top + WidgetDimensions::scaled.bevel.top, x + WidgetDimensions::scaled.bevel.left - 1, r.bottom - WidgetDimensions::scaled.bevel.bottom, col);
 
	}
 
@@ -434,13 +434,13 @@ static inline void DrawMatrix(const Rect
 
	x = r.top;
 
	for (int ctr = num_rows; ctr > 1; ctr--) {
 
		x += row_height;
 
		GfxFillRect(r.left + WidgetDimensions::scaled.bevel.left, x, r.right - WidgetDimensions::scaled.bevel.right, x + WidgetDimensions::scaled.bevel.top - 1, col);
 
	}
 

	
 
	col = GetColourGradient(colour, SHADE_4);
 
	col = GetColourGradient(colour, SHADE_NORMAL);
 

	
 
	x = r.left - 1;
 
	for (int ctr = num_columns; ctr > 1; ctr--) {
 
		x += column_width;
 
		GfxFillRect(x - WidgetDimensions::scaled.bevel.right + 1, r.top + WidgetDimensions::scaled.bevel.top, x, r.bottom - WidgetDimensions::scaled.bevel.bottom, col);
 
	}
 
@@ -466,14 +466,14 @@ static inline void DrawVerticalScrollbar
 
	int height = NWidgetScrollbar::GetVerticalDimension().height;
 

	
 
	/* draw up/down buttons */
 
	DrawImageButtons(r.WithHeight(height, false),  NWID_VSCROLLBAR, colour, up_clicked,   SPR_ARROW_UP,   SA_CENTER);
 
	DrawImageButtons(r.WithHeight(height, true),   NWID_VSCROLLBAR, colour, down_clicked, SPR_ARROW_DOWN, SA_CENTER);
 

	
 
	int c1 = GetColourGradient(colour, SHADE_3);
 
	int c2 = GetColourGradient(colour, SHADE_7);
 
	int c1 = GetColourGradient(colour, SHADE_DARK);
 
	int c2 = GetColourGradient(colour, SHADE_LIGHTEST);
 

	
 
	/* draw "shaded" background */
 
	GfxFillRect(r.left, r.top + height, r.right, r.bottom - height, c2);
 
	GfxFillRect(r.left, r.top + height, r.right, r.bottom - height, c1, FILLRECT_CHECKER);
 

	
 
	/* track positions. These fractions are based on original 1x dimensions, but scale better. */
 
@@ -505,14 +505,14 @@ static inline void DrawHorizontalScrollb
 
{
 
	int width = NWidgetScrollbar::GetHorizontalDimension().width;
 

	
 
	DrawImageButtons(r.WithWidth(width, false), NWID_HSCROLLBAR, colour, left_clicked,  SPR_ARROW_LEFT,  SA_CENTER);
 
	DrawImageButtons(r.WithWidth(width, true),  NWID_HSCROLLBAR, colour, right_clicked, SPR_ARROW_RIGHT, SA_CENTER);
 

	
 
	int c1 = GetColourGradient(colour, SHADE_3);
 
	int c2 = GetColourGradient(colour, SHADE_7);
 
	int c1 = GetColourGradient(colour, SHADE_DARK);
 
	int c2 = GetColourGradient(colour, SHADE_LIGHTEST);
 

	
 
	/* draw "shaded" background */
 
	GfxFillRect(r.left + width, r.top, r.right - width, r.bottom, c2);
 
	GfxFillRect(r.left + width, r.top, r.right - width, r.bottom, c1, FILLRECT_CHECKER);
 

	
 
	/* track positions. These fractions are based on original 1x dimensions, but scale better. */
 
@@ -544,14 +544,14 @@ static inline void DrawHorizontalScrollb
 
static inline void DrawFrame(const Rect &r, Colours colour, TextColour text_colour, StringID str, StringAlignment align, FontSize fs)
 
{
 
	int x2 = r.left; // by default the left side is the left side of the widget
 

	
 
	if (str != STR_NULL) x2 = DrawString(r.left + WidgetDimensions::scaled.frametext.left, r.right - WidgetDimensions::scaled.frametext.right, r.top, str, text_colour, align, false, fs);
 

	
 
	int c1 = GetColourGradient(colour, SHADE_3);
 
	int c2 = GetColourGradient(colour, SHADE_7);
 
	int c1 = GetColourGradient(colour, SHADE_DARK);
 
	int c2 = GetColourGradient(colour, SHADE_LIGHTEST);
 

	
 
	/* If the frame has text, adjust the top bar to fit half-way through */
 
	Rect inner = r.Shrink(ScaleGUITrad(1));
 
	if (str != STR_NULL) inner.top = r.top + GetCharacterHeight(FS_NORMAL) / 2;
 

	
 
	Rect outer  = inner.Expand(WidgetDimensions::scaled.bevel);
 
@@ -642,13 +642,13 @@ static inline void DrawDebugBox(const Re
 
 */
 
static inline void DrawResizeBox(const Rect &r, Colours colour, bool at_left, bool clicked, bool bevel)
 
{
 
	if (bevel) {
 
		DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE);
 
	} else if (clicked) {
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(colour, SHADE_6));
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(colour, SHADE_LIGHTER));
 
	}
 
	DrawSpriteIgnorePadding(at_left ? SPR_WINDOW_RESIZE_LEFT : SPR_WINDOW_RESIZE_RIGHT, PAL_NONE, r.Shrink(ScaleGUITrad(2)), at_left ? (SA_LEFT | SA_BOTTOM | SA_FORCE) : (SA_RIGHT | SA_BOTTOM | SA_FORCE));
 
}
 

	
 
/**
 
 * Draw a close box.
 
@@ -682,13 +682,13 @@ void DrawCaption(const Rect &r, Colours 
 

	
 
	DrawFrameRect(r, colour, FR_BORDERONLY);
 
	Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
 
	DrawFrameRect(ir, colour, company_owned ? FR_LOWERED | FR_DARKENED | FR_BORDERONLY : FR_LOWERED | FR_DARKENED);
 

	
 
	if (company_owned) {
 
		GfxFillRect(ir.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(_company_colours[owner], SHADE_4));
 
		GfxFillRect(ir.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(_company_colours[owner], SHADE_NORMAL));
 
	}
 

	
 
	if (str != STR_NULL) {
 
		Dimension d = GetStringBoundingBox(str);
 
		Point p = GetAlignedPosition(r, d, align);
 
		DrawString(r.left + WidgetDimensions::scaled.captiontext.left, r.right - WidgetDimensions::scaled.captiontext.left, p.y, str, text_colour, align, false, fs);
 
@@ -1903,13 +1903,13 @@ NWidgetCore *NWidgetMatrix::GetWidgetFro
 
	return child->GetWidgetFromPos(x, y);
 
}
 

	
 
/* virtual */ void NWidgetMatrix::Draw(const Window *w)
 
{
 
	/* Fill the background. */
 
	GfxFillRect(this->GetCurrentRect(), GetColourGradient(this->colour, SHADE_5));
 
	GfxFillRect(this->GetCurrentRect(), GetColourGradient(this->colour, SHADE_LIGHT));
 

	
 
	/* Set up a clipping area for the previews. */
 
	bool rtl = _current_text_dir == TD_RTL;
 
	DrawPixelInfo tmp_dpi;
 
	if (!FillDrawPixelInfo(&tmp_dpi, this->pos_x + (rtl ? this->pip_post : this->pip_pre), this->pos_y + this->pip_pre, this->current_x - this->pip_pre - this->pip_post, this->current_y - this->pip_pre - this->pip_post)) return;
 

	
 
@@ -2168,13 +2168,13 @@ void NWidgetBackground::Draw(const Windo
 
	}
 

	
 
	if (this->index >= 0) w->DrawWidget(r, this->index);
 
	if (this->child != nullptr) this->child->Draw(w);
 

	
 
	if (this->IsDisabled()) {
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, SHADE_2), FILLRECT_CHECKER);
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, SHADE_DARKER), FILLRECT_CHECKER);
 
	}
 

	
 
	DrawOutline(w, this);
 
}
 

	
 
NWidgetCore *NWidgetBackground::GetWidgetFromPos(int x, int y)
 
@@ -2413,13 +2413,13 @@ void NWidgetScrollbar::Draw(const Window
 
		DrawHorizontalScrollbar(r, this->colour, up_lowered, middle_lowered, down_lowered, this);
 
	} else {
 
		DrawVerticalScrollbar(r, this->colour, up_lowered, middle_lowered, down_lowered, this);
 
	}
 

	
 
	if (this->IsDisabled()) {
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, SHADE_2), FILLRECT_CHECKER);
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, SHADE_DARKER), FILLRECT_CHECKER);
 
	}
 

	
 
	DrawOutline(w, this);
 
}
 

	
 
/* static */ void NWidgetScrollbar::InvalidateDimensionCache()
 
@@ -2864,13 +2864,13 @@ void NWidgetLeaf::Draw(const Window *w)
 
		default:
 
			NOT_REACHED();
 
	}
 
	if (this->index >= 0) w->DrawWidget(r, this->index);
 

	
 
	if (this->IsDisabled()) {
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, SHADE_2), FILLRECT_CHECKER);
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, SHADE_DARKER), FILLRECT_CHECKER);
 
	}
 

	
 
	DrawOutline(w, this);
 
}
 

	
 
/**
src/widgets/dropdown_type.h
Show inline comments
 
@@ -34,13 +34,13 @@ public:
 
	virtual bool Selectable() const { return true; }
 
	virtual uint Height() const { return 0; }
 
	virtual uint Width() const { return 0; }
 

	
 
	virtual void Draw(const Rect &full, const Rect &, bool, Colours bg_colour) const
 
	{
 
		if (this->masked) GfxFillRect(full, GetColourGradient(bg_colour, SHADE_5), FILLRECT_CHECKER);
 
		if (this->masked) GfxFillRect(full, GetColourGradient(bg_colour, SHADE_LIGHT), FILLRECT_CHECKER);
 
	}
 

	
 
	TextColour GetColour(bool sel) const
 
	{
 
		if (this->shaded) return (sel ? TC_SILVER : TC_GREY) | TC_NO_SHADE;
 
		return sel ? TC_WHITE : TC_BLACK;
 
@@ -60,14 +60,14 @@ public:
 

	
 
	bool Selectable() const override { return false; }
 
	uint Height() const override { return std::max<uint>(GetCharacterHeight(TFs), this->TBase::Height()); }
 

	
 
	void Draw(const Rect &full, const Rect &, bool, Colours bg_colour) const override
 
	{
 
		uint8_t c1 = GetColourGradient(bg_colour, SHADE_3);
 
		uint8_t c2 = GetColourGradient(bg_colour, SHADE_7);
 
		uint8_t c1 = GetColourGradient(bg_colour, SHADE_DARK);
 
		uint8_t c2 = GetColourGradient(bg_colour, SHADE_LIGHTEST);
 

	
 
		int mid = CenterBounds(full.top, full.bottom, 0);
 
		GfxFillRect(full.left, mid - WidgetDimensions::scaled.bevel.bottom, full.right, mid - 1, c1);
 
		GfxFillRect(full.left, mid, full.right, mid + WidgetDimensions::scaled.bevel.top - 1, c2);
 
	}
 
};
src/widgets/slider.cpp
Show inline comments
 
@@ -38,15 +38,15 @@ void DrawSliderWidget(Rect r, int min_va
 
	const int ha = (r.bottom - r.top) / 5;
 
	const int sw = ScaleGUITrad(SLIDER_WIDTH);
 
	const int t = WidgetDimensions::scaled.bevel.top; /* Thickness of lines */
 
	int wx1 = r.left  + sw / 2;
 
	int wx2 = r.right - sw / 2;
 
	if (_current_text_dir == TD_RTL) std::swap(wx1, wx2);
 
	const uint shadow = GetColourGradient(COLOUR_GREY, SHADE_3);
 
	const uint fill = GetColourGradient(COLOUR_GREY, SHADE_6);
 
	const uint light = GetColourGradient(COLOUR_GREY, SHADE_7);
 
	const uint shadow = GetColourGradient(COLOUR_GREY, SHADE_DARK);
 
	const uint fill = GetColourGradient(COLOUR_GREY, SHADE_LIGHTER);
 
	const uint light = GetColourGradient(COLOUR_GREY, SHADE_LIGHTEST);
 
	const std::vector<Point> wedge{ Point{wx1, r.bottom - ha}, Point{wx2, r.top + ha}, Point{wx2, r.bottom - ha} };
 
	GfxFillPolygon(wedge, fill);
 
	GfxDrawLine(wedge[0].x, wedge[0].y, wedge[2].x, wedge[2].y, light, t);
 
	GfxDrawLine(wedge[1].x, wedge[1].y, wedge[2].x, wedge[2].y, _current_text_dir == TD_RTL ? shadow : light, t);
 
	GfxDrawLine(wedge[0].x, wedge[0].y, wedge[1].x, wedge[1].y, shadow, t);
 

	
0 comments (0 inline, 0 general)