File diff r28811:c7d0936f4cf0 → r28812:d6d9465e39a0
src/widget.cpp
Show inline comments
 
@@ -275,17 +275,17 @@ WidgetID GetWidgetFromPos(const Window *
 
 * @param top    Top edge of the frame
 
 * @param right  Right edge of the frame
 
 * @param bottom Bottom edge of the frame
 
 * @param colour Colour table to use. @see _colour_gradient
 
 * @param colour Colour table to use. @see Colours
 
 * @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         = _colour_gradient[colour][3];
 
	uint medium_dark  = _colour_gradient[colour][5];
 
	uint medium_light = _colour_gradient[colour][6];
 
	uint light        = _colour_gradient[colour][7];
 
	uint dark         = GetColourGradient(colour, 3);
 
	uint medium_dark  = GetColourGradient(colour, 5);
 
	uint medium_light = GetColourGradient(colour, 6);
 
	uint light        = GetColourGradient(colour, 7);
 

	
 
	if (flags & FR_TRANSPARENT) {
 
		GfxFillRect(left, top, right, bottom, PALETTE_TO_TRANSPARENT, FILLRECT_RECOLOUR);
 
@@ -423,7 +423,7 @@ static inline void DrawMatrix(const Rect
 
		row_height = r.Height() / num_rows;
 
	}
 

	
 
	int col = _colour_gradient[colour & 0xF][6];
 
	int col = GetColourGradient(colour, 6);
 

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

	
 
	col = _colour_gradient[colour & 0xF][4];
 
	col = GetColourGradient(colour, 4);
 

	
 
	x = r.left - 1;
 
	for (int ctr = num_columns; ctr > 1; ctr--) {
 
@@ -469,8 +469,8 @@ static inline void DrawVerticalScrollbar
 
	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 = _colour_gradient[colour & 0xF][3];
 
	int c2 = _colour_gradient[colour & 0xF][7];
 
	int c1 = GetColourGradient(colour, 3);
 
	int c2 = GetColourGradient(colour, 7);
 

	
 
	/* draw "shaded" background */
 
	GfxFillRect(r.left, r.top + height, r.right, r.bottom - height, c2);
 
@@ -508,8 +508,8 @@ static inline void DrawHorizontalScrollb
 
	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 = _colour_gradient[colour & 0xF][3];
 
	int c2 = _colour_gradient[colour & 0xF][7];
 
	int c1 = GetColourGradient(colour, 3);
 
	int c2 = GetColourGradient(colour, 7);
 

	
 
	/* draw "shaded" background */
 
	GfxFillRect(r.left + width, r.top, r.right - width, r.bottom, c2);
 
@@ -547,8 +547,8 @@ static inline void DrawFrame(const Rect 
 

	
 
	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 = _colour_gradient[colour][3];
 
	int c2 = _colour_gradient[colour][7];
 
	int c1 = GetColourGradient(colour, 3);
 
	int c2 = GetColourGradient(colour, 7);
 

	
 
	/* If the frame has text, adjust the top bar to fit half-way through */
 
	Rect inner = r.Shrink(ScaleGUITrad(1));
 
@@ -645,7 +645,7 @@ static inline void DrawResizeBox(const R
 
	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), _colour_gradient[colour][6]);
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(colour, 6));
 
	}
 
	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));
 
}
 
@@ -685,7 +685,7 @@ void DrawCaption(const Rect &r, Colours 
 
	DrawFrameRect(ir, colour, company_owned ? FR_LOWERED | FR_DARKENED | FR_BORDERONLY : FR_LOWERED | FR_DARKENED);
 

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

	
 
	if (str != STR_NULL) {
 
@@ -1906,7 +1906,7 @@ NWidgetCore *NWidgetMatrix::GetWidgetFro
 
/* virtual */ void NWidgetMatrix::Draw(const Window *w)
 
{
 
	/* Fill the background. */
 
	GfxFillRect(this->GetCurrentRect(), _colour_gradient[this->colour & 0xF][5]);
 
	GfxFillRect(this->GetCurrentRect(), GetColourGradient(this->colour, 5));
 

	
 
	/* Set up a clipping area for the previews. */
 
	bool rtl = _current_text_dir == TD_RTL;
 
@@ -2171,7 +2171,7 @@ void NWidgetBackground::Draw(const Windo
 
	if (this->child != nullptr) this->child->Draw(w);
 

	
 
	if (this->IsDisabled()) {
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), _colour_gradient[this->colour & 0xF][2], FILLRECT_CHECKER);
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, 2), FILLRECT_CHECKER);
 
	}
 

	
 
	DrawOutline(w, this);
 
@@ -2416,7 +2416,7 @@ void NWidgetScrollbar::Draw(const Window
 
	}
 

	
 
	if (this->IsDisabled()) {
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), _colour_gradient[this->colour & 0xF][2], FILLRECT_CHECKER);
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, 2), FILLRECT_CHECKER);
 
	}
 

	
 
	DrawOutline(w, this);
 
@@ -2867,7 +2867,7 @@ void NWidgetLeaf::Draw(const Window *w)
 
	if (this->index >= 0) w->DrawWidget(r, this->index);
 

	
 
	if (this->IsDisabled()) {
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), _colour_gradient[this->colour & 0xF][2], FILLRECT_CHECKER);
 
		GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(this->colour, 2), FILLRECT_CHECKER);
 
	}
 

	
 
	DrawOutline(w, this);