From 923bb00c0952c0bb848f6edc917c00a591732e39 Mon Sep 17 00:00:00 2001 From: Juanjo Date: Fri, 9 Aug 2013 09:32:52 +0000 Subject: [PATCH] Add a min sizing for viewports. --- src/news_gui.cpp | 4 ++-- src/viewport_gui.cpp | 2 +- src/widget.cpp | 3 +++ src/widget_type.h | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/news_gui.cpp b/src/news_gui.cpp index ba4b557db3..9760ac8021 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -166,7 +166,7 @@ static const NWidgetPart _nested_thin_news_widgets[] = { EndContainer(), EndContainer(), NWidget(WWT_EMPTY, COLOUR_WHITE, WID_N_MESSAGE), SetMinimalSize(428, 48), SetFill(1, 0), SetPadding(0, 5, 0, 5), - NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_N_VIEWPORT), SetMinimalSize(426, 70), SetPadding(1, 2, 2, 2), + NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_N_VIEWPORT), SetSizingType(NWST_VIEWPORT), SetMinimalSize(426, 70), SetPadding(1, 2, 2, 2), EndContainer(), }; @@ -188,7 +188,7 @@ static const NWidgetPart _nested_small_news_widgets[] = { /* Main part */ NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_N_HEADLINE), NWidget(WWT_INSET, COLOUR_LIGHT_BLUE, WID_N_INSET), SetPadding(2, 2, 2, 2), - NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_N_VIEWPORT), SetPadding(1, 1, 1, 1), SetMinimalSize(274, 47), SetFill(1, 0), + NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_N_VIEWPORT), SetSizingType(NWST_VIEWPORT), SetPadding(1, 1, 1, 1), SetMinimalSize(274, 47), SetFill(1, 0), EndContainer(), NWidget(WWT_EMPTY, COLOUR_WHITE, WID_N_MESSAGE), SetMinimalSize(275, 20), SetFill(1, 0), SetPadding(0, 5, 0, 5), EndContainer(), diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index ab8125fa1f..7e9b3b3cc0 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -32,7 +32,7 @@ static const NWidgetPart _nested_extra_view_port_widgets[] = { NWidget(WWT_STICKYBOX, COLOUR_GREY), EndContainer(), NWidget(WWT_PANEL, COLOUR_GREY), - NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_EV_VIEWPORT), SetPadding(2, 2, 2, 2), SetResize(1, 1), SetFill(1, 1), + NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_EV_VIEWPORT), SetSizingType(NWST_VIEWPORT), SetPadding(2, 2, 2, 2), SetResize(1, 1), SetFill(1, 1), EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_EV_ZOOM_IN), SetDataTip(SPR_IMG_ZOOMIN, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_IN), diff --git a/src/widget.cpp b/src/widget.cpp index 437d2fdf3f..9217de0053 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -770,6 +770,9 @@ void NWidgetResizeBase::SetMinimalSize(uint min_x, uint min_y) case NWST_STEP: min_size = _settings_client.gui.min_step; break; + case NWST_VIEWPORT: + min_size = 3 * _settings_client.gui.min_button; + break; default: NOT_REACHED(); } diff --git a/src/widget_type.h b/src/widget_type.h index 6d95a2ce27..43ec2e4b69 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -49,6 +49,7 @@ enum NWidSizingType { NWST_STEP, ///< Size will be set at least _settings_client.gui.min_step (scrollbars and dropdowns). NWST_KEYBOARD, ///< Size for keyboard keys. NWST_WINDOW_LENGTH, ///< Width for command errors, message windows and statusbar middle part. + NWST_VIEWPORT, ///< Sizing type for viewports. NWST_OVERRIDE, ///< Avoid widgets to use automatic minimal sizing. NWST_END };