From 6e8c27b8e5ad7db8961f1ebcd2b2592e02c05c36 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 10 Dec 2023 17:25:36 +0000 Subject: [PATCH] Change: Hide bevel for resizeable sparse layout windows. (#11572) When clicked, the button is still highlighted to show that it is active. The bevel is controlled with widget_data by RWV_SHOW_BEVEL or RWV_HIDE_BEVEL values. --- src/game/game_gui.cpp | 2 +- src/graph_gui.cpp | 12 ++++++------ src/network/network_content_gui.cpp | 2 +- src/network/network_gui.cpp | 2 +- src/newgrf_debug_gui.cpp | 2 +- src/newgrf_gui.cpp | 2 +- src/widget.cpp | 16 ++++++++++------ src/widget_type.h | 6 ++++++ 8 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index 037e6591e8..8dfd319407 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -67,7 +67,7 @@ static const NWidgetPart _nested_gs_config_widgets[] = { EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0), - NWidget(WWT_RESIZEBOX, COLOUR_MAUVE), + NWidget(WWT_RESIZEBOX, COLOUR_MAUVE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE), EndContainer(), EndContainer(), }; diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index bf56415ac4..25eee1d791 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -647,7 +647,7 @@ static const NWidgetPart _nested_operating_profit_widgets[] = { NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CV_GRAPH), SetMinimalSize(576, 160), SetFill(1, 1), SetResize(1, 1), NWidget(NWID_VERTICAL), NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1), - NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE), + NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE), EndContainer(), EndContainer(), EndContainer(), @@ -698,7 +698,7 @@ static const NWidgetPart _nested_income_graph_widgets[] = { NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CV_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1), NWidget(NWID_VERTICAL), NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1), - NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE), + NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE), EndContainer(), EndContainer(), EndContainer(), @@ -747,7 +747,7 @@ static const NWidgetPart _nested_delivered_cargo_graph_widgets[] = { NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CV_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1), NWidget(NWID_VERTICAL), NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1), - NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE), + NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE), EndContainer(), EndContainer(), EndContainer(), @@ -803,7 +803,7 @@ static const NWidgetPart _nested_performance_history_widgets[] = { NWidget(WWT_EMPTY, COLOUR_BROWN, WID_PHG_GRAPH), SetMinimalSize(576, 224), SetFill(1, 1), SetResize(1, 1), NWidget(NWID_VERTICAL), NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1), - NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_PHG_RESIZE), + NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_PHG_RESIZE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE), EndContainer(), EndContainer(), EndContainer(), @@ -852,7 +852,7 @@ static const NWidgetPart _nested_company_value_graph_widgets[] = { NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CV_GRAPH), SetMinimalSize(576, 224), SetFill(1, 1), SetResize(1, 1), NWidget(NWID_VERTICAL), NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1), - NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE), + NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE), EndContainer(), EndContainer(), EndContainer(), @@ -1089,7 +1089,7 @@ static const NWidgetPart _nested_cargo_payment_rates_widgets[] = { NWidget(NWID_SPACER), SetMinimalSize(12, 0), SetFill(1, 0), SetResize(1, 0), NWidget(WWT_TEXT, COLOUR_BROWN, WID_CPR_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL, STR_NULL), NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0), - NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CPR_RESIZE), + NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CPR_RESIZE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE), EndContainer(), EndContainer(), }; diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index d201e87338..cfbd160222 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -1105,7 +1105,7 @@ static const NWidgetPart _nested_network_content_list_widgets[] = { /* Resize button. */ NWidget(NWID_HORIZONTAL), NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0), - NWidget(WWT_RESIZEBOX, COLOUR_LIGHT_BLUE), + NWidget(WWT_RESIZEBOX, COLOUR_LIGHT_BLUE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE), EndContainer(), EndContainer(), }; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index da70a3cee6..ddd6f62985 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -936,7 +936,7 @@ static const NWidgetPart _nested_network_game_widgets[] = { /* Resize button. */ NWidget(NWID_HORIZONTAL), NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0), - NWidget(WWT_RESIZEBOX, COLOUR_LIGHT_BLUE), + NWidget(WWT_RESIZEBOX, COLOUR_LIGHT_BLUE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE), EndContainer(), EndContainer(), }; diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 8b8a1f5431..732c9d2aef 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -1152,7 +1152,7 @@ static const NWidgetPart _nested_sprite_aligner_widgets[] = { EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0), - NWidget(WWT_RESIZEBOX, COLOUR_GREY), + NWidget(WWT_RESIZEBOX, COLOUR_GREY), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE), EndContainer(), EndContainer(), }; diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 048ec5222e..f3f72fa80c 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -1963,7 +1963,7 @@ static const NWidgetPart _nested_newgrf_widgets[] = { /* Resize button. */ NWidget(NWID_HORIZONTAL), NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0), - NWidget(WWT_RESIZEBOX, COLOUR_MAUVE), + NWidget(WWT_RESIZEBOX, COLOUR_MAUVE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE), EndContainer(), EndContainer(), }; diff --git a/src/widget.cpp b/src/widget.cpp index 148bd8ddec..84176fa837 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -154,7 +154,7 @@ const WidgetDimensions WidgetDimensions::unscaled = { {20, 10, 20, 10}, ///< modalpopup {3, 3, 3, 3}, ///< picker {10, 8, 10, 8}, ///< sparse window padding - {10, 8, 10, 1}, ///< resizable sparse window padding + {10, 8, 10, 0}, ///< resizable sparse window padding 1, ///< vsep_picker WD_PAR_VSEP_NORMAL, ///< vsep_normal 4, ///< vsep_sparse @@ -777,10 +777,15 @@ static inline void DrawDebugBox(const Rect &r, Colours colour, bool clicked) * @param colour Colour of the resize box. * @param at_left Resize box is at left-side of the window, * @param clicked Box is lowered. + * @param bevel Draw bevel iff set. */ -static inline void DrawResizeBox(const Rect &r, Colours colour, bool at_left, bool clicked) +static inline void DrawResizeBox(const Rect &r, Colours colour, bool at_left, bool clicked, bool bevel) { - DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE); + 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]); + } 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)); } @@ -2774,7 +2779,7 @@ NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32_t data case WWT_RESIZEBOX: this->SetFill(0, 0); this->SetMinimalSize(WD_RESIZEBOX_WIDTH, 12); - this->SetDataTip(STR_NULL, STR_TOOLTIP_RESIZE); + this->SetDataTip(RWV_SHOW_BEVEL, STR_TOOLTIP_RESIZE); break; case WWT_CLOSEBOX: @@ -3072,8 +3077,7 @@ void NWidgetLeaf::Draw(const Window *w) break; case WWT_RESIZEBOX: - assert(this->widget_data == 0); - DrawResizeBox(r, this->colour, this->pos_x < (w->width / 2), !!(w->flags & WF_SIZING)); + DrawResizeBox(r, this->colour, this->pos_x < (w->width / 2), !!(w->flags & WF_SIZING), this->widget_data == 0); break; case WWT_CLOSEBOX: diff --git a/src/widget_type.h b/src/widget_type.h index 8ec91855c6..2280b09cbc 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -36,6 +36,12 @@ enum ArrowWidgetValues { AWV_RIGHT, ///< Force the arrow to the right }; +/** WidgetData values for a resize box widget. */ +enum ResizeWidgetValues { + RWV_SHOW_BEVEL, ///< Bevel of resize box is shown. + RWV_HIDE_BEVEL, ///< Bevel of resize box is hidden. +}; + /** * Window widget types, nested widget types, and nested widget part types. */