mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use EnumBitSet for FrameFlags.
parent
d30e8dd1c1
commit
56b1e9df1f
|
@ -120,6 +120,6 @@ void DrawAircraftImage(const Vehicle *v, const Rect &r, VehicleID selection, Eng
|
|||
x += x_offs;
|
||||
y += UnScaleGUI(rect.top) - heli_offs;
|
||||
Rect hr = {x, y, x + width - 1, y + UnScaleGUI(rect.Height()) + heli_offs - 1};
|
||||
DrawFrameRect(hr.Expand(WidgetDimensions::scaled.bevel), COLOUR_WHITE, FR_BORDERONLY);
|
||||
DrawFrameRect(hr.Expand(WidgetDimensions::scaled.bevel), COLOUR_WHITE, FrameFlag::BorderOnly);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1427,9 +1427,9 @@ struct GenerateProgressWindow : public Window {
|
|||
switch (widget) {
|
||||
case WID_GP_PROGRESS_BAR: {
|
||||
/* Draw the % complete with a bar and a text */
|
||||
DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED);
|
||||
DrawFrameRect(r, COLOUR_GREY, {FrameFlag::BorderOnly, FrameFlag::Lowered});
|
||||
Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
|
||||
DrawFrameRect(br.WithWidth(br.Width() * _gws.percent / 100, _current_text_dir == TD_RTL), COLOUR_MAUVE, FR_NONE);
|
||||
DrawFrameRect(br.WithWidth(br.Width() * _gws.percent / 100, _current_text_dir == TD_RTL), COLOUR_MAUVE, {});
|
||||
SetDParam(0, _gws.percent);
|
||||
DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_NORMAL)), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
break;
|
||||
|
|
|
@ -611,7 +611,7 @@ public:
|
|||
bool lowered = !HasBit(this->excluded_range, index);
|
||||
|
||||
/* Redraw frame if lowered */
|
||||
if (lowered) DrawFrameRect(line, COLOUR_BROWN, FR_LOWERED);
|
||||
if (lowered) DrawFrameRect(line, COLOUR_BROWN, FrameFlag::Lowered);
|
||||
|
||||
const Rect text = line.Shrink(WidgetDimensions::scaled.framerect);
|
||||
DrawString(text, str, TC_BLACK, SA_CENTER, false, FS_SMALL);
|
||||
|
@ -1106,7 +1106,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
|||
bool lowered = !HasBit(_legend_excluded_cargo_payment_rates, cs->Index());
|
||||
|
||||
/* Redraw frame if lowered */
|
||||
if (lowered) DrawFrameRect(line, COLOUR_BROWN, FR_LOWERED);
|
||||
if (lowered) DrawFrameRect(line, COLOUR_BROWN, FrameFlag::Lowered);
|
||||
|
||||
const Rect text = line.Shrink(WidgetDimensions::scaled.framerect);
|
||||
|
||||
|
@ -1603,7 +1603,7 @@ struct IndustryProductionGraphWindow : BaseGraphWindow {
|
|||
bool lowered = !HasBit(_legend_excluded_cargo_production_history, p.cargo);
|
||||
|
||||
/* Redraw frame if lowered */
|
||||
if (lowered) DrawFrameRect(line, COLOUR_BROWN, FR_LOWERED);
|
||||
if (lowered) DrawFrameRect(line, COLOUR_BROWN, FrameFlag::Lowered);
|
||||
|
||||
const Rect text = line.Shrink(WidgetDimensions::scaled.framerect);
|
||||
|
||||
|
|
|
@ -794,11 +794,11 @@ void QueryString::DrawEditBox(const Window *w, WidgetID wid) const
|
|||
Rect cr = r.WithWidth(clearbtn_width, !rtl);
|
||||
Rect fr = r.Indent(clearbtn_width, !rtl);
|
||||
|
||||
DrawFrameRect(cr, wi->colour, wi->IsLowered() ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(cr, wi->colour, wi->IsLowered() ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawSpriteIgnorePadding(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT, PAL_NONE, cr, SA_CENTER);
|
||||
if (StrEmpty(this->text.GetText())) GfxFillRect(cr.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(wi->colour, SHADE_DARKER), FILLRECT_CHECKER);
|
||||
|
||||
DrawFrameRect(fr, wi->colour, FR_LOWERED | FR_DARKENED);
|
||||
DrawFrameRect(fr, wi->colour, {FrameFlag::Lowered, FrameFlag::Darkened});
|
||||
GfxFillRect(fr.Shrink(WidgetDimensions::scaled.bevel), PC_BLACK);
|
||||
|
||||
fr = fr.Shrink(WidgetDimensions::scaled.framerect);
|
||||
|
|
|
@ -140,9 +140,9 @@ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, WidgetID
|
|||
switch (widget) {
|
||||
case WID_NCDS_PROGRESS_BAR: {
|
||||
/* Draw the % complete with a bar and a text */
|
||||
DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED);
|
||||
DrawFrameRect(r, COLOUR_GREY, {FrameFlag::BorderOnly, FrameFlag::Lowered});
|
||||
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
|
||||
DrawFrameRect(ir.WithWidth((uint64_t)ir.Width() * this->downloaded_bytes / this->total_bytes, _current_text_dir == TD_RTL), COLOUR_MAUVE, FR_NONE);
|
||||
DrawFrameRect(ir.WithWidth((uint64_t)ir.Width() * this->downloaded_bytes / this->total_bytes, _current_text_dir == TD_RTL), COLOUR_MAUVE, {});
|
||||
SetDParam(0, this->downloaded_bytes);
|
||||
SetDParam(1, this->total_bytes);
|
||||
SetDParam(2, this->downloaded_bytes * 100LL / this->total_bytes);
|
||||
|
|
|
@ -1920,7 +1920,7 @@ public:
|
|||
r.top = y + offset;
|
||||
r.bottom = r.top + button->height - 1;
|
||||
|
||||
DrawFrameRect(r, button->colour, FR_NONE);
|
||||
DrawFrameRect(r, button->colour, {});
|
||||
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_DARKER), FILLRECT_CHECKER);
|
||||
|
@ -2094,7 +2094,7 @@ struct NetworkJoinStatusWindow : Window {
|
|||
switch (widget) {
|
||||
case WID_NJS_PROGRESS_BAR: {
|
||||
/* Draw the % complete with a bar and a text */
|
||||
DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED);
|
||||
DrawFrameRect(r, COLOUR_GREY, {FrameFlag::BorderOnly, FrameFlag::Lowered});
|
||||
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
|
||||
uint8_t progress; // used for progress bar
|
||||
switch (_network_join_status) {
|
||||
|
@ -2117,7 +2117,7 @@ struct NetworkJoinStatusWindow : Window {
|
|||
progress = 15 + _network_join_bytes * (100 - 15) / _network_join_bytes_total;
|
||||
break;
|
||||
}
|
||||
DrawFrameRect(ir.WithWidth(ir.Width() * progress / 100, _current_text_dir == TD_RTL), COLOUR_MAUVE, FR_NONE);
|
||||
DrawFrameRect(ir.WithWidth(ir.Width() * progress / 100, _current_text_dir == TD_RTL), COLOUR_MAUVE, {});
|
||||
DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)), STR_NETWORK_CONNECTING_1 + _network_join_status, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -425,9 +425,9 @@ struct NewGRFInspectWindow : Window {
|
|||
|
||||
/* Highlight the articulated part (this is different to the whole-vehicle highlighting of DrawVehicleImage */
|
||||
if (_current_text_dir == TD_RTL) {
|
||||
DrawFrameRect(r.right - sel_end + skip, y, r.right - sel_start + skip, y + h, COLOUR_WHITE, FR_BORDERONLY);
|
||||
DrawFrameRect(r.right - sel_end + skip, y, r.right - sel_start + skip, y + h, COLOUR_WHITE, FrameFlag::BorderOnly);
|
||||
} else {
|
||||
DrawFrameRect(r.left + sel_start - skip, y, r.left + sel_end - skip, y + h, COLOUR_WHITE, FR_BORDERONLY);
|
||||
DrawFrameRect(r.left + sel_start - skip, y, r.left + sel_end - skip, y + h, COLOUR_WHITE, FrameFlag::BorderOnly);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2237,10 +2237,10 @@ struct ScanProgressWindow : public Window {
|
|||
switch (widget) {
|
||||
case WID_SP_PROGRESS_BAR: {
|
||||
/* Draw the % complete with a bar and a text */
|
||||
DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED);
|
||||
DrawFrameRect(r, COLOUR_GREY, {FrameFlag::BorderOnly, FrameFlag::Lowered});
|
||||
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
|
||||
uint percent = scanned * 100 / std::max(1U, _settings_client.gui.last_newgrf_count);
|
||||
DrawFrameRect(ir.WithWidth(ir.Width() * percent / 100, _current_text_dir == TD_RTL), COLOUR_MAUVE, FR_NONE);
|
||||
DrawFrameRect(ir.WithWidth(ir.Width() * percent / 100, _current_text_dir == TD_RTL), COLOUR_MAUVE, {});
|
||||
SetDParam(0, percent);
|
||||
DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
break;
|
||||
|
|
|
@ -163,6 +163,6 @@ void DrawRoadVehImage(const Vehicle *v, const Rect &r, VehicleID selection, Engi
|
|||
if (v->index == selection) {
|
||||
int height = ScaleSpriteTrad(12);
|
||||
Rect hr = {(rtl ? px : 0), 0, (rtl ? max_width : px) - 1, height - 1};
|
||||
DrawFrameRect(hr.Translate(r.left, CenterBounds(r.top, r.bottom, height)).Expand(WidgetDimensions::scaled.bevel), COLOUR_WHITE, FR_BORDERONLY);
|
||||
DrawFrameRect(hr.Translate(r.left, CenterBounds(r.top, r.bottom, height)).Expand(WidgetDimensions::scaled.bevel), COLOUR_WHITE, FrameFlag::BorderOnly);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2931,8 +2931,8 @@ void DrawArrowButtons(int x, int y, Colours button_colour, uint8_t state, bool c
|
|||
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);
|
||||
DrawFrameRect(rr, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(lr, button_colour, (state == 1) ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawFrameRect(rr, button_colour, (state == 2) ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawSpriteIgnorePadding(SPR_ARROW_LEFT, PAL_NONE, lr, SA_CENTER);
|
||||
DrawSpriteIgnorePadding(SPR_ARROW_RIGHT, PAL_NONE, rr, SA_CENTER);
|
||||
|
||||
|
@ -2960,7 +2960,7 @@ void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool cl
|
|||
|
||||
Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
|
||||
|
||||
DrawFrameRect(r, button_colour, state ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(r, button_colour, state ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawSpriteIgnorePadding(SPR_ARROW_DOWN, PAL_NONE, r, SA_CENTER);
|
||||
|
||||
if (!clickable) {
|
||||
|
@ -2980,7 +2980,7 @@ void DrawBoolButton(int x, int y, bool state, bool clickable)
|
|||
static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
|
||||
|
||||
Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
|
||||
DrawFrameRect(r, _bool_ctabs[state][clickable], state ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(r, _bool_ctabs[state][clickable], state ? FrameFlag::Lowered : FrameFlags{});
|
||||
}
|
||||
|
||||
struct CustomCurrencyWindow : Window {
|
||||
|
|
|
@ -50,7 +50,7 @@ void DrawShipImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineI
|
|||
x += x_offs;
|
||||
y += UnScaleGUI(rect.top);
|
||||
Rect hr = {x, y, x + width - 1, y + UnScaleGUI(rect.Height()) - 1};
|
||||
DrawFrameRect(hr.Expand(WidgetDimensions::scaled.bevel), COLOUR_WHITE, FR_BORDERONLY);
|
||||
DrawFrameRect(hr.Expand(WidgetDimensions::scaled.bevel), COLOUR_WHITE, FrameFlag::BorderOnly);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ void DrawSliderWidget(Rect r, int min_value, int max_value, int nmarks, int valu
|
|||
value -= min_value;
|
||||
if (_current_text_dir == TD_RTL) value = max_value - value;
|
||||
x = r.left + (value * (r.right - r.left - sw) / max_value);
|
||||
DrawFrameRect(x, r.top, x + sw, r.bottom, COLOUR_GREY, FR_NONE);
|
||||
DrawFrameRect(x, r.top, x + sw, r.bottom, COLOUR_GREY, {});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -734,7 +734,7 @@ public:
|
|||
case SPET_BUTTON_TILE:
|
||||
case SPET_BUTTON_VEHICLE: {
|
||||
const int tmargin = WidgetDimensions::scaled.bevel.top + WidgetDimensions::scaled.frametext.top;
|
||||
const FrameFlags frame = this->active_button_id == ce.pe->index ? FR_LOWERED : FR_NONE;
|
||||
const FrameFlags frame = this->active_button_id == ce.pe->index ? FrameFlag::Lowered : FrameFlags{};
|
||||
const Colours bgcolour = StoryPageButtonData{ ce.pe->referenced_id }.GetColour();
|
||||
|
||||
DrawFrameRect(ce.bounds.left, ce.bounds.top - scrollpos, ce.bounds.right, ce.bounds.bottom - scrollpos - 1, bgcolour, frame);
|
||||
|
|
|
@ -167,7 +167,7 @@ void DrawTrainImage(const Train *v, const Rect &r, VehicleID selection, EngineIm
|
|||
* the next engine after the highlight could overlap it. */
|
||||
int height = ScaleSpriteTrad(12);
|
||||
Rect hr = {highlight_l, 0, highlight_r, height - 1};
|
||||
DrawFrameRect(hr.Translate(r.left, CenterBounds(r.top, r.bottom, height)).Expand(WidgetDimensions::scaled.bevel), COLOUR_WHITE, FR_BORDERONLY);
|
||||
DrawFrameRect(hr.Translate(r.left, CenterBounds(r.top, r.bottom, height)).Expand(WidgetDimensions::scaled.bevel), COLOUR_WHITE, FrameFlag::BorderOnly);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
|
||||
const Rect wr = this->GetWidget<NWidgetBase>(i)->GetCurrentRect().Shrink(WidgetDimensions::scaled.fullbevel);
|
||||
DrawFrameRect(wr.left, fr.top, wr.right, fr.bottom, COLOUR_PALE_GREEN,
|
||||
HasBit(_invisibility_opt, i - WID_TT_BEGIN) ? FR_LOWERED : FR_NONE);
|
||||
HasBit(_invisibility_opt, i - WID_TT_BEGIN) ? FrameFlag::Lowered : FrameFlags{});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1104,7 +1104,7 @@ struct RefitWindow : public Window {
|
|||
|
||||
if (left != right) {
|
||||
Rect hr = {left, highlight_top, right, highlight_bottom};
|
||||
DrawFrameRect(hr.Expand(WidgetDimensions::scaled.bevel), COLOUR_WHITE, FR_BORDERONLY);
|
||||
DrawFrameRect(hr.Expand(WidgetDimensions::scaled.bevel), COLOUR_WHITE, FrameFlag::BorderOnly);
|
||||
}
|
||||
|
||||
left = INT32_MIN;
|
||||
|
|
|
@ -1772,10 +1772,10 @@ static void ViewportDrawStrings(ZoomLevel zoom, const StringSpriteToDrawVector *
|
|||
|
||||
TextColour colour = TC_WHITE;
|
||||
if (ss.flags.Test(ViewportStringFlag::ColourRect)) {
|
||||
if (ss.colour != INVALID_COLOUR) DrawFrameRect(x, y, x + w - 1, y + h - 1, ss.colour, FR_NONE);
|
||||
if (ss.colour != INVALID_COLOUR) DrawFrameRect(x, y, x + w - 1, y + h - 1, ss.colour, {});
|
||||
colour = TC_BLACK;
|
||||
} else if (ss.flags.Test(ViewportStringFlag::TransparentRect)) {
|
||||
DrawFrameRect(x, y, x + w - 1, y + h - 1, ss.colour, FR_TRANSPARENT);
|
||||
DrawFrameRect(x, y, x + w - 1, y + h - 1, ss.colour, FrameFlag::Transparent);
|
||||
}
|
||||
|
||||
if (ss.flags.Test(ViewportStringFlag::TextColour)) {
|
||||
|
|
|
@ -282,7 +282,7 @@ WidgetID GetWidgetFromPos(const Window *w, int x, int y)
|
|||
*/
|
||||
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
|
||||
{
|
||||
if (flags & FR_TRANSPARENT) {
|
||||
if (flags.Test(FrameFlag::Transparent)) {
|
||||
GfxFillRect(left, top, right, bottom, PALETTE_TO_TRANSPARENT, FILLRECT_RECOLOUR);
|
||||
} else {
|
||||
assert(colour < COLOUR_END);
|
||||
|
@ -296,12 +296,12 @@ void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, Fra
|
|||
Rect outer = {left, top, right, bottom}; // Outside rectangle
|
||||
Rect inner = outer.Shrink(WidgetDimensions::scaled.bevel); // Inside rectangle
|
||||
|
||||
if (flags & FR_LOWERED) {
|
||||
if (flags.Test(FrameFlag::Lowered)) {
|
||||
GfxFillRect(outer.left, outer.top, inner.left - 1, outer.bottom, dark); // Left
|
||||
GfxFillRect(inner.left, outer.top, outer.right, inner.top - 1, dark); // Top
|
||||
GfxFillRect(inner.right + 1, inner.top, outer.right, inner.bottom, light); // Right
|
||||
GfxFillRect(inner.left, inner.bottom + 1, outer.right, outer.bottom, light); // Bottom
|
||||
interior = (flags & FR_DARKENED ? medium_dark : medium_light);
|
||||
interior = (flags.Test(FrameFlag::Darkened) ? medium_dark : medium_light);
|
||||
} else {
|
||||
GfxFillRect(outer.left, outer.top, inner.left - 1, inner.bottom, light); // Left
|
||||
GfxFillRect(inner.left, outer.top, inner.right, inner.top - 1, light); // Top
|
||||
|
@ -309,7 +309,7 @@ void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, Fra
|
|||
GfxFillRect(outer.left, inner.bottom + 1, outer.right, outer.bottom, dark); // Bottom
|
||||
interior = medium_dark;
|
||||
}
|
||||
if (!(flags & FR_BORDERONLY)) {
|
||||
if (!flags.Test(FrameFlag::BorderOnly)) {
|
||||
GfxFillRect(inner.left, inner.top, inner.right, inner.bottom, interior); // Inner
|
||||
}
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, StringA
|
|||
static inline void DrawImageButtons(const Rect &r, WidgetType type, Colours colour, bool clicked, SpriteID img, StringAlignment align)
|
||||
{
|
||||
assert(img != 0);
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FrameFlag::Lowered : FrameFlags{});
|
||||
|
||||
if ((type & WWT_MASK) == WWT_IMGBTN_2 && clicked) img++; // Show different image when clicked for #WWT_IMGBTN_2.
|
||||
DrawSpriteIgnorePadding(img, PAL_NONE, r, align);
|
||||
|
@ -389,7 +389,7 @@ static inline void DrawText(const Rect &r, TextColour colour, StringID str, Stri
|
|||
*/
|
||||
static inline void DrawInset(const Rect &r, Colours colour, TextColour text_colour, StringID str, StringAlignment align, FontSize fs)
|
||||
{
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, FR_LOWERED | FR_DARKENED);
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, {FrameFlag::Lowered, FrameFlag::Darkened});
|
||||
if (str != STR_NULL) DrawString(r.Shrink(WidgetDimensions::scaled.inset), str, text_colour, align, false, fs);
|
||||
}
|
||||
|
||||
|
@ -405,7 +405,7 @@ static inline void DrawInset(const Rect &r, Colours colour, TextColour text_colo
|
|||
*/
|
||||
static inline void DrawMatrix(const Rect &r, Colours colour, bool clicked, uint32_t num_columns, uint32_t num_rows, uint resize_x, uint resize_y)
|
||||
{
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FrameFlag::Lowered : FrameFlags{});
|
||||
|
||||
int column_width; // Width of a single column in the matrix.
|
||||
if (num_columns == 0) {
|
||||
|
@ -489,7 +489,7 @@ static inline void DrawVerticalScrollbar(const Rect &r, Colours colour, bool up_
|
|||
GfxFillRect(right, r.top + height, right + br - 1, r.bottom - height, c2);
|
||||
|
||||
Point pt = HandleScrollbarHittest(scrollbar, r.top, r.bottom, false);
|
||||
DrawFrameRect(r.left, pt.x, r.right, pt.y, colour, bar_dragged ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(r.left, pt.x, r.right, pt.y, colour, bar_dragged ? FrameFlag::Lowered : FrameFlags{});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -529,7 +529,7 @@ static inline void DrawHorizontalScrollbar(const Rect &r, Colours colour, bool l
|
|||
|
||||
/* draw actual scrollbar */
|
||||
Point pt = HandleScrollbarHittest(scrollbar, r.left, r.right, true);
|
||||
DrawFrameRect(pt.x, r.top, pt.y, r.bottom, colour, bar_dragged ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(pt.x, r.top, pt.y, r.bottom, colour, bar_dragged ? FrameFlag::Lowered : FrameFlags{});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -643,7 +643,7 @@ static inline void DrawDebugBox(const Rect &r, Colours colour, bool clicked)
|
|||
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);
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FrameFlag::Lowered : FrameFlags{});
|
||||
} else if (clicked) {
|
||||
GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(colour, SHADE_LIGHTER));
|
||||
}
|
||||
|
@ -657,7 +657,7 @@ static inline void DrawResizeBox(const Rect &r, Colours colour, bool at_left, bo
|
|||
*/
|
||||
static inline void DrawCloseBox(const Rect &r, Colours colour)
|
||||
{
|
||||
if (colour != COLOUR_WHITE) DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, FR_NONE);
|
||||
if (colour != COLOUR_WHITE) DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, {});
|
||||
Point offset;
|
||||
Dimension d = GetSpriteSize(SPR_CLOSEBOX, &offset);
|
||||
d.width -= offset.x;
|
||||
|
@ -680,9 +680,9 @@ void DrawCaption(const Rect &r, Colours colour, Owner owner, TextColour text_col
|
|||
{
|
||||
bool company_owned = owner < MAX_COMPANIES;
|
||||
|
||||
DrawFrameRect(r, colour, FR_BORDERONLY);
|
||||
DrawFrameRect(r, colour, FrameFlag::BorderOnly);
|
||||
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
|
||||
DrawFrameRect(ir, colour, company_owned ? FR_LOWERED | FR_DARKENED | FR_BORDERONLY : FR_LOWERED | FR_DARKENED);
|
||||
DrawFrameRect(ir, colour, company_owned ? FrameFlags{FrameFlag::Lowered, FrameFlag::Darkened, FrameFlag::BorderOnly} : FrameFlags{FrameFlag::Lowered, FrameFlag::Darkened});
|
||||
|
||||
if (company_owned) {
|
||||
GfxFillRect(ir.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(_company_colours[owner], SHADE_NORMAL));
|
||||
|
@ -711,13 +711,13 @@ static inline void DrawButtonDropdown(const Rect &r, Colours colour, bool clicke
|
|||
int dd_width = NWidgetLeaf::dropdown_dimension.width;
|
||||
|
||||
if (_current_text_dir == TD_LTR) {
|
||||
DrawFrameRect(r.left, r.top, r.right - dd_width, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(r.left, r.top, r.right - dd_width, r.bottom, colour, clicked_button ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawImageButtons(r.WithWidth(dd_width, true), WWT_DROPDOWN, colour, clicked_dropdown, SPR_ARROW_DOWN, SA_CENTER);
|
||||
if (str != STR_NULL) {
|
||||
DrawString(r.left + WidgetDimensions::scaled.dropdowntext.left, r.right - dd_width - WidgetDimensions::scaled.dropdowntext.right, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)), str, TC_BLACK, align);
|
||||
}
|
||||
} else {
|
||||
DrawFrameRect(r.left + dd_width, r.top, r.right, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(r.left + dd_width, r.top, r.right, r.bottom, colour, clicked_button ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawImageButtons(r.WithWidth(dd_width, false), WWT_DROPDOWN, colour, clicked_dropdown, SPR_ARROW_DOWN, SA_CENTER);
|
||||
if (str != STR_NULL) {
|
||||
DrawString(r.left + dd_width + WidgetDimensions::scaled.dropdowntext.left, r.right - WidgetDimensions::scaled.dropdowntext.right, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)), str, TC_BLACK, align);
|
||||
|
@ -733,7 +733,7 @@ void Window::DrawWidgets() const
|
|||
this->nested_root->Draw(this);
|
||||
|
||||
if (this->flags.Test(WindowFlag::WhiteBorder)) {
|
||||
DrawFrameRect(0, 0, this->width - 1, this->height - 1, COLOUR_WHITE, FR_BORDERONLY);
|
||||
DrawFrameRect(0, 0, this->width - 1, this->height - 1, COLOUR_WHITE, FrameFlag::BorderOnly);
|
||||
}
|
||||
|
||||
if (this->flags.Test(WindowFlag::Highlighted)) {
|
||||
|
@ -2341,7 +2341,7 @@ void NWidgetBackground::Draw(const Window *w)
|
|||
|
||||
switch (this->type) {
|
||||
case WWT_PANEL:
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, this->colour, this->IsLowered() ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, this->colour, this->IsLowered() ? FrameFlag::Lowered : FrameFlags{});
|
||||
break;
|
||||
|
||||
case WWT_FRAME:
|
||||
|
@ -3003,7 +3003,7 @@ void NWidgetLeaf::Draw(const Window *w)
|
|||
break;
|
||||
|
||||
case WWT_PUSHBTN:
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, this->colour, (clicked) ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, this->colour, (clicked) ? FrameFlag::Lowered : FrameFlags{});
|
||||
break;
|
||||
|
||||
case WWT_IMGBTN:
|
||||
|
@ -3016,7 +3016,7 @@ void NWidgetLeaf::Draw(const Window *w)
|
|||
case WWT_PUSHTXTBTN:
|
||||
case WWT_TEXTBTN_2:
|
||||
if (this->index >= 0) w->SetStringParameters(this->index);
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, this->colour, (clicked) ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, this->colour, (clicked) ? FrameFlag::Lowered : FrameFlags{});
|
||||
DrawLabel(r, this->type, clicked, this->text_colour, this->GetString(), this->align, this->text_size);
|
||||
break;
|
||||
|
||||
|
|
|
@ -21,15 +21,13 @@
|
|||
/**
|
||||
* Flags to describe the look of the frame
|
||||
*/
|
||||
enum FrameFlags : uint8_t {
|
||||
FR_NONE = 0,
|
||||
FR_TRANSPARENT = 1 << 0, ///< Makes the background transparent if set
|
||||
FR_BORDERONLY = 1 << 4, ///< Draw border only, no background
|
||||
FR_LOWERED = 1 << 5, ///< If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
|
||||
FR_DARKENED = 1 << 6, ///< If set the background is darker, allows for lowered frames with normal background colour when used with FR_LOWERED (ie. dropdown boxes)
|
||||
enum class FrameFlag : uint8_t {
|
||||
Transparent, ///< Makes the background transparent if set
|
||||
BorderOnly, ///< Draw border only, no background
|
||||
Lowered, ///< If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
|
||||
Darkened, ///< If set the background is darker, allows for lowered frames with normal background colour when used with FrameFlag::Lowered (ie. dropdown boxes)
|
||||
};
|
||||
|
||||
DECLARE_ENUM_AS_BIT_SET(FrameFlags)
|
||||
using FrameFlags = EnumBitSet<FrameFlag, uint8_t>;
|
||||
|
||||
class WidgetDimensions {
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue