diff options
author | frosch <frosch@openttd.org> | 2013-06-30 14:36:31 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2013-06-30 14:36:31 +0000 |
commit | 43ec0bf0c118b5228a9c50a2ba1650d021dc5c44 (patch) | |
tree | 5aef49476d90a8b682f809125c8c37d035a1c9fa | |
parent | 8116aeff218fe55c98c0dcd2a62390fe7e7d9c6e (diff) | |
download | openttd-43ec0bf0c118b5228a9c50a2ba1650d021dc5c44.tar.xz |
(svn r25537) -Codechange: Optionally make WWT_MATRIX compute the number of rows and columns from the resize step size.
-rw-r--r-- | src/ai/ai_gui.cpp | 9 | ||||
-rw-r--r-- | src/autoreplace_gui.cpp | 3 | ||||
-rw-r--r-- | src/bridge_gui.cpp | 4 | ||||
-rw-r--r-- | src/build_vehicle_gui.cpp | 3 | ||||
-rw-r--r-- | src/depot_gui.cpp | 13 | ||||
-rw-r--r-- | src/group_gui.cpp | 9 | ||||
-rw-r--r-- | src/industry_gui.cpp | 3 | ||||
-rw-r--r-- | src/network/network_content_gui.cpp | 3 | ||||
-rw-r--r-- | src/network/network_gui.cpp | 6 | ||||
-rw-r--r-- | src/newgrf_debug_gui.cpp | 3 | ||||
-rw-r--r-- | src/newgrf_gui.cpp | 4 | ||||
-rw-r--r-- | src/object_gui.cpp | 3 | ||||
-rw-r--r-- | src/rail_gui.cpp | 3 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 9 | ||||
-rw-r--r-- | src/widget.cpp | 22 | ||||
-rw-r--r-- | src/widget_type.h | 4 |
16 files changed, 42 insertions, 59 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 0736e9ba9..676774f15 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -210,9 +210,7 @@ struct AIListWindow : public Window { virtual void OnResize() { - NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_AIL_LIST); this->vscroll->SetCapacityFromWidget(this, WID_AIL_LIST); - nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } /** @@ -244,7 +242,7 @@ static const NWidgetPart _nested_ai_list_widgets[] = { NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE), EndContainer(), NWidget(NWID_HORIZONTAL), - NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_AIL_LIST), SetMinimalSize(188, 112), SetFill(1, 1), SetResize(1, 1), SetMatrixDataTip(1, 5, STR_AI_LIST_TOOLTIP), SetScrollbar(WID_AIL_SCROLLBAR), + NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_AIL_LIST), SetMinimalSize(188, 112), SetFill(1, 1), SetResize(1, 1), SetMatrixDataTip(1, 0, STR_AI_LIST_TOOLTIP), SetScrollbar(WID_AIL_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_AIL_SCROLLBAR), EndContainer(), NWidget(WWT_PANEL, COLOUR_MAUVE, WID_AIL_INFO_BG), SetMinimalTextLines(8, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM), SetResize(1, 0), @@ -561,9 +559,7 @@ struct AISettingsWindow : public Window { virtual void OnResize() { - NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_AIS_BACKGROUND); this->vscroll->SetCapacityFromWidget(this, WID_AIS_BACKGROUND); - nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } virtual void OnTick() @@ -593,7 +589,7 @@ static const NWidgetPart _nested_ai_settings_widgets[] = { NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE), EndContainer(), NWidget(NWID_HORIZONTAL), - NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_AIS_BACKGROUND), SetMinimalSize(188, 182), SetResize(1, 1), SetFill(1, 0), SetMatrixDataTip(1, 5, STR_NULL), SetScrollbar(WID_AIS_SCROLLBAR), + NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_AIS_BACKGROUND), SetMinimalSize(188, 182), SetResize(1, 1), SetFill(1, 0), SetMatrixDataTip(1, 0, STR_NULL), SetScrollbar(WID_AIS_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_AIS_SCROLLBAR), EndContainer(), NWidget(NWID_HORIZONTAL), @@ -723,7 +719,6 @@ struct AIConfigWindow : public Window { NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_AIC_LIST); this->vscroll->SetCapacity(nwi->current_y / this->line_height); this->vscroll->SetCount(MAX_COMPANIES); - nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); this->OnInvalidateData(0); } diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 7cfb5844b..b159376a0 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -509,9 +509,6 @@ public: { this->vscroll[0]->SetCapacityFromWidget(this, WID_RV_LEFT_MATRIX); this->vscroll[1]->SetCapacityFromWidget(this, WID_RV_RIGHT_MATRIX); - - this->GetWidget<NWidgetCore>(WID_RV_LEFT_MATRIX)->widget_data = - this->GetWidget<NWidgetCore>(WID_RV_RIGHT_MATRIX)->widget_data = (this->vscroll[0]->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } /** diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index e6f9ab4b7..234102931 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -159,7 +159,6 @@ public: if (this->last_size > this->vscroll->GetCapacity()) { ResizeWindow(this, 0, (this->last_size - this->vscroll->GetCapacity()) * this->resize.step_height); } - this->GetWidget<NWidgetCore>(WID_BBS_BRIDGE_LIST)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } ~BuildBridgeWindow() @@ -297,7 +296,6 @@ public: virtual void OnResize() { this->vscroll->SetCapacityFromWidget(this, WID_BBS_BRIDGE_LIST); - this->GetWidget<NWidgetCore>(WID_BBS_BRIDGE_LIST)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); this->last_size = max(this->vscroll->GetCapacity(), this->last_size); } @@ -340,7 +338,7 @@ static const NWidgetPart _nested_build_bridge_widgets[] = { NWidget(WWT_DROPDOWN, COLOUR_DARK_GREEN, WID_BBS_DROPDOWN_CRITERIA), SetFill(1, 0), SetDataTip(0x0, STR_TOOLTIP_SORT_CRITERIA), EndContainer(), /* Matrix. */ - NWidget(WWT_MATRIX, COLOUR_DARK_GREEN, WID_BBS_BRIDGE_LIST), SetFill(1, 0), SetResize(0, 22), SetMatrixDataTip(1, 4, STR_SELECT_BRIDGE_SELECTION_TOOLTIP), SetScrollbar(WID_BBS_SCROLLBAR), + NWidget(WWT_MATRIX, COLOUR_DARK_GREEN, WID_BBS_BRIDGE_LIST), SetFill(1, 0), SetResize(0, 22), SetMatrixDataTip(1, 0, STR_SELECT_BRIDGE_SELECTION_TOOLTIP), SetScrollbar(WID_BBS_SCROLLBAR), EndContainer(), /* scrollbar + resize button */ diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 6b4c25c09..45a95e379 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -69,7 +69,7 @@ static const NWidgetPart _nested_build_vehicle_widgets[] = { EndContainer(), /* Vehicle list. */ NWidget(NWID_HORIZONTAL), - NWidget(WWT_MATRIX, COLOUR_GREY, WID_BV_LIST), SetResize(1, 1), SetFill(1, 0), SetMatrixDataTip(1, 1, STR_NULL), SetScrollbar(WID_BV_SCROLLBAR), + NWidget(WWT_MATRIX, COLOUR_GREY, WID_BV_LIST), SetResize(1, 1), SetFill(1, 0), SetMatrixDataTip(1, 0, STR_NULL), SetScrollbar(WID_BV_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_BV_SCROLLBAR), EndContainer(), /* Panel with details. */ @@ -1405,7 +1405,6 @@ struct BuildVehicleWindow : Window { virtual void OnResize() { this->vscroll->SetCapacityFromWidget(this, WID_BV_LIST); - this->GetWidget<NWidgetCore>(WID_BV_LIST)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } }; diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 132d0de66..3f5cfb532 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -246,6 +246,7 @@ struct DepotWindow : Window { /* Don't show 'rename button' of aircraft hangar */ this->GetWidget<NWidgetStacked>(WID_D_SHOW_RENAME)->SetDisplayedPlane(type == VEH_AIRCRAFT ? SZSP_NONE : 0); /* Only train depots have a horizontal scrollbar and a 'sell chain' button */ + if (type == VEH_TRAIN) this->GetWidget<NWidgetCore>(WID_D_MATRIX)->widget_data = 1 << MAT_COL_START; this->GetWidget<NWidgetStacked>(WID_D_SHOW_H_SCROLL)->SetDisplayedPlane(type == VEH_TRAIN ? 0 : SZSP_HORIZONTAL); this->GetWidget<NWidgetStacked>(WID_D_SHOW_SELL_CHAIN)->SetDisplayedPlane(type == VEH_TRAIN ? 0 : SZSP_NONE); this->SetupWidgetData(type); @@ -335,9 +336,9 @@ struct DepotWindow : Window { bool rtl = _current_text_dir == TD_RTL; /* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */ - uint16 mat_data = this->GetWidget<NWidgetCore>(WID_D_MATRIX)->widget_data; - uint16 rows_in_display = GB(mat_data, MAT_ROW_START, MAT_ROW_BITS); - uint16 boxes_in_each_row = GB(mat_data, MAT_COL_START, MAT_COL_BITS); + const NWidgetCore *wid = this->GetWidget<NWidgetCore>(WID_D_MATRIX); + uint16 boxes_in_each_row = this->type == VEH_TRAIN ? 1 : wid->current_x / wid->resize_x; + uint16 rows_in_display = wid->current_y / wid->resize_y; uint16 num = this->vscroll->GetPosition() * boxes_in_each_row; int maxval = min(this->vehicle_list.Length(), num + (rows_in_display * boxes_in_each_row)); @@ -968,14 +969,10 @@ struct DepotWindow : Window { virtual void OnResize() { - NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_D_MATRIX); this->vscroll->SetCapacityFromWidget(this, WID_D_MATRIX); if (this->type == VEH_TRAIN) { + NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_D_MATRIX); this->hscroll->SetCapacity(nwi->current_x - this->header_width - this->count_width); - nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); - } else { - this->num_columns = nwi->current_x / nwi->resize_x; - nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (this->num_columns << MAT_COL_START); } } diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 8c1859764..ed3176e27 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -47,7 +47,7 @@ static const NWidgetPart _nested_group_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_ALL_VEHICLES), SetFill(1, 0), EndContainer(), NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_DEFAULT_VEHICLES), SetFill(1, 0), EndContainer(), NWidget(NWID_HORIZONTAL), - NWidget(WWT_MATRIX, COLOUR_GREY, WID_GL_LIST_GROUP), SetMatrixDataTip(1, 7, STR_GROUPS_CLICK_ON_GROUP_FOR_TOOLTIP), + NWidget(WWT_MATRIX, COLOUR_GREY, WID_GL_LIST_GROUP), SetMatrixDataTip(1, 0, STR_GROUPS_CLICK_ON_GROUP_FOR_TOOLTIP), SetFill(1, 0), SetResize(0, 1), SetScrollbar(WID_GL_LIST_GROUP_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_GL_LIST_GROUP_SCROLLBAR), EndContainer(), @@ -71,7 +71,7 @@ static const NWidgetPart _nested_group_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(12, 12), SetResize(1, 0), EndContainer(), EndContainer(), NWidget(NWID_HORIZONTAL), - NWidget(WWT_MATRIX, COLOUR_GREY, WID_GL_LIST_VEHICLE), SetMinimalSize(248, 0), SetMatrixDataTip(1, 7, STR_NULL), SetResize(1, 1), SetFill(1, 0), SetScrollbar(WID_GL_LIST_VEHICLE_SCROLLBAR), + NWidget(WWT_MATRIX, COLOUR_GREY, WID_GL_LIST_VEHICLE), SetMinimalSize(248, 0), SetMatrixDataTip(1, 0, STR_NULL), SetResize(1, 1), SetFill(1, 0), SetScrollbar(WID_GL_LIST_VEHICLE_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_GL_LIST_VEHICLE_SCROLLBAR), EndContainer(), NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(1, 0), SetFill(1, 1), SetResize(1, 0), EndContainer(), @@ -679,13 +679,8 @@ public: virtual void OnResize() { - NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_GL_LIST_GROUP); this->group_sb->SetCapacityFromWidget(this, WID_GL_LIST_GROUP); - nwi->widget_data = (this->group_sb->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); - - nwi = this->GetWidget<NWidgetCore>(WID_GL_LIST_VEHICLE); this->vscroll->SetCapacityFromWidget(this, WID_GL_LIST_VEHICLE); - nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } virtual void OnDropdownSelect(int widget, int index) diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 9e03f613b..4b5412d81 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -174,7 +174,7 @@ static const NWidgetPart _nested_build_industry_widgets[] = { NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN), EndContainer(), NWidget(NWID_HORIZONTAL), - NWidget(WWT_MATRIX, COLOUR_DARK_GREEN, WID_DPI_MATRIX_WIDGET), SetMatrixDataTip(1, 8, STR_FUND_INDUSTRY_SELECTION_TOOLTIP), SetFill(1, 0), SetResize(1, 1), SetScrollbar(WID_DPI_SCROLLBAR), + NWidget(WWT_MATRIX, COLOUR_DARK_GREEN, WID_DPI_MATRIX_WIDGET), SetMatrixDataTip(1, 0, STR_FUND_INDUSTRY_SELECTION_TOOLTIP), SetFill(1, 0), SetResize(1, 1), SetScrollbar(WID_DPI_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_DPI_SCROLLBAR), EndContainer(), NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_DPI_INFOPANEL), SetResize(1, 0), @@ -528,7 +528,6 @@ public: { /* Adjust the number of items in the matrix depending of the resize */ this->vscroll->SetCapacityFromWidget(this, WID_DPI_MATRIX_WIDGET); - this->GetWidget<NWidgetCore>(WID_DPI_MATRIX_WIDGET)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } virtual void OnPlaceObject(Point pt, TileIndex tile) diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index fe0668f05..358187cc2 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -869,7 +869,6 @@ public: virtual void OnResize() { this->vscroll->SetCapacityFromWidget(this, WID_NCL_MATRIX); - this->GetWidget<NWidgetCore>(WID_NCL_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } virtual void OnReceiveContentInfo(const ContentInfo *rci) @@ -983,7 +982,7 @@ static const NWidgetPart _nested_network_content_list_widgets[] = { NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_NAME), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_CONTENT_NAME_CAPTION, STR_CONTENT_NAME_CAPTION_TOOLTIP), EndContainer(), - NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, WID_NCL_MATRIX), SetResize(1, 14), SetFill(1, 1), SetScrollbar(WID_NCL_SCROLLBAR), SetMatrixDataTip(0, 0, STR_CONTENT_MATRIX_TOOLTIP), + NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, WID_NCL_MATRIX), SetResize(1, 14), SetFill(1, 1), SetScrollbar(WID_NCL_SCROLLBAR), SetMatrixDataTip(1, 0, STR_CONTENT_MATRIX_TOOLTIP), EndContainer(), NWidget(NWID_VSCROLLBAR, COLOUR_LIGHT_BLUE, WID_NCL_SCROLLBAR), EndContainer(), diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index e4af9d5b9..be028355e 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -890,7 +890,6 @@ public: virtual void OnResize() { this->vscroll->SetCapacityFromWidget(this, WID_NG_MATRIX); - this->GetWidget<NWidgetCore>(WID_NG_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } virtual void OnTick() @@ -946,7 +945,7 @@ static const NWidgetPart _nested_network_game_widgets[] = { NWidget(NWID_VERTICAL), NWidgetFunction(MakeResizableHeader), NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, WID_NG_MATRIX), SetResize(1, 1), SetFill(1, 0), - SetMatrixDataTip(0, 0, STR_NETWORK_SERVER_LIST_CLICK_GAME_TO_SELECT), SetScrollbar(WID_NG_SCROLLBAR), + SetMatrixDataTip(1, 0, STR_NETWORK_SERVER_LIST_CLICK_GAME_TO_SELECT), SetScrollbar(WID_NG_SCROLLBAR), EndContainer(), NWidget(NWID_VSCROLLBAR, COLOUR_LIGHT_BLUE, WID_NG_SCROLLBAR), EndContainer(), @@ -1572,7 +1571,6 @@ struct NetworkLobbyWindow : public Window { virtual void OnResize() { this->vscroll->SetCapacityFromWidget(this, WID_NL_MATRIX); - this->GetWidget<NWidgetCore>(WID_NL_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } }; @@ -1588,7 +1586,7 @@ static const NWidgetPart _nested_network_lobby_window_widgets[] = { /* Company list. */ NWidget(NWID_VERTICAL), NWidget(WWT_PANEL, COLOUR_WHITE, WID_NL_HEADER), SetMinimalSize(146, 0), SetResize(1, 0), SetFill(1, 0), EndContainer(), - NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, WID_NL_MATRIX), SetMinimalSize(146, 0), SetResize(1, 1), SetFill(1, 1), SetMatrixDataTip(0, 0, STR_NETWORK_GAME_LOBBY_COMPANY_LIST_TOOLTIP), SetScrollbar(WID_NL_SCROLLBAR), + NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, WID_NL_MATRIX), SetMinimalSize(146, 0), SetResize(1, 1), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_NETWORK_GAME_LOBBY_COMPANY_LIST_TOOLTIP), SetScrollbar(WID_NL_SCROLLBAR), EndContainer(), NWidget(NWID_VSCROLLBAR, COLOUR_LIGHT_BLUE, WID_NL_SCROLLBAR), NWidget(NWID_SPACER), SetMinimalSize(5, 0), SetResize(0, 1), diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 95837753a..b2c82e5b3 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -815,7 +815,6 @@ struct SpriteAlignerWindow : Window { virtual void OnResize() { this->vscroll->SetCapacityFromWidget(this, WID_SA_LIST); - this->GetWidget<NWidgetCore>(WID_SA_LIST)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } }; @@ -865,7 +864,7 @@ static const NWidgetPart _nested_sprite_aligner_widgets[] = { NWidget(NWID_VERTICAL), SetPIP(10, 5, 10), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SA_PICKER), SetDataTip(STR_SPRITE_ALIGNER_PICKER_BUTTON, STR_SPRITE_ALIGNER_PICKER_TOOLTIP), SetFill(1, 0), NWidget(NWID_HORIZONTAL), - NWidget(WWT_MATRIX, COLOUR_GREY, WID_SA_LIST), SetResize(1, 1), SetMatrixDataTip(1, 1, STR_NULL), SetFill(1, 1), SetScrollbar(WID_SA_SCROLLBAR), + NWidget(WWT_MATRIX, COLOUR_GREY, WID_SA_LIST), SetResize(1, 1), SetMatrixDataTip(1, 0, STR_NULL), SetFill(1, 1), SetScrollbar(WID_SA_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SA_SCROLLBAR), EndContainer(), EndContainer(), diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 837b37de8..6ba2ade70 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -460,9 +460,7 @@ struct NewGRFParametersWindow : public Window { virtual void OnResize() { - NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_NP_BACKGROUND); this->vscroll->SetCapacityFromWidget(this, WID_NP_BACKGROUND); - nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } /** @@ -512,7 +510,7 @@ static const NWidgetPart _nested_newgrf_parameter_widgets[] = { EndContainer(), EndContainer(), NWidget(NWID_HORIZONTAL), - NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_NP_BACKGROUND), SetMinimalSize(188, 182), SetResize(1, 1), SetFill(1, 0), SetMatrixDataTip(1, 5, STR_NULL), SetScrollbar(WID_NP_SCROLLBAR), + NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_NP_BACKGROUND), SetMinimalSize(188, 182), SetResize(1, 1), SetFill(1, 0), SetMatrixDataTip(1, 0, STR_NULL), SetScrollbar(WID_NP_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_NP_SCROLLBAR), EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NP_SHOW_DESCRIPTION), diff --git a/src/object_gui.cpp b/src/object_gui.cpp index e4287c7ac..c295abcf0 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -366,7 +366,6 @@ public: virtual void OnResize() { this->vscroll->SetCapacityFromWidget(this, WID_BO_CLASS_LIST); - this->GetWidget<NWidgetCore>(WID_BO_CLASS_LIST)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } virtual void OnClick(Point pt, int widget, int click_count) @@ -455,7 +454,7 @@ static const NWidgetPart _nested_build_object_widgets[] = { NWidget(NWID_HORIZONTAL), SetPadding(2, 0, 0, 0), NWidget(NWID_VERTICAL), NWidget(NWID_HORIZONTAL), SetPadding(0, 5, 2, 5), - NWidget(WWT_MATRIX, COLOUR_GREY, WID_BO_CLASS_LIST), SetFill(1, 0), SetMatrixDataTip(1, 5, STR_OBJECT_BUILD_CLASS_TOOLTIP), SetScrollbar(WID_BO_SCROLLBAR), + NWidget(WWT_MATRIX, COLOUR_GREY, WID_BO_CLASS_LIST), SetFill(1, 0), SetMatrixDataTip(1, 0, STR_OBJECT_BUILD_CLASS_TOOLTIP), SetScrollbar(WID_BO_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_BO_SCROLLBAR), EndContainer(), NWidget(NWID_HORIZONTAL), SetPadding(0, 5, 0, 5), diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 37c076f21..61c29e1e1 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1149,7 +1149,6 @@ public: { if (this->vscroll != NULL) { // New stations available. this->vscroll->SetCapacityFromWidget(this, WID_BRAS_NEWST_LIST); - this->GetWidget<NWidgetCore>(WID_BRAS_NEWST_LIST)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } } @@ -1357,7 +1356,7 @@ static const NWidgetPart _nested_station_builder_widgets[] = { NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BRAS_SHOW_NEWST_ADDITIONS), NWidget(NWID_HORIZONTAL), SetPIP(7, 0, 7), SetPadding(2, 0, 1, 0), NWidget(WWT_MATRIX, COLOUR_GREY, WID_BRAS_NEWST_LIST), SetMinimalSize(122, 71), SetFill(1, 0), - SetMatrixDataTip(1, 5, STR_STATION_BUILD_STATION_CLASS_TOOLTIP), SetScrollbar(WID_BRAS_NEWST_SCROLL), + SetMatrixDataTip(1, 0, STR_STATION_BUILD_STATION_CLASS_TOOLTIP), SetScrollbar(WID_BRAS_NEWST_SCROLL), NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_BRAS_NEWST_SCROLL), EndContainer(), EndContainer(), diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 0d65cd0f1..cb61a5fd3 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -970,7 +970,6 @@ struct RefitWindow : public Window { this->vehicle_width = GetVehicleWidth(Vehicle::Get(this->window_number), EIT_IN_DETAILS); this->vscroll->SetCapacityFromWidget(this, WID_VR_MATRIX); if (this->hscroll != NULL) this->hscroll->SetCapacityFromWidget(this, WID_VR_VEHICLE_PANEL_DISPLAY); - this->GetWidget<NWidgetCore>(WID_VR_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } }; @@ -990,7 +989,7 @@ static const NWidgetPart _nested_vehicle_refit_widgets[] = { NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_VR_SELECT_HEADER), SetDataTip(STR_REFIT_TITLE, STR_NULL), SetResize(1, 0), /* Matrix + scrollbar. */ NWidget(NWID_HORIZONTAL), - NWidget(WWT_MATRIX, COLOUR_GREY, WID_VR_MATRIX), SetMinimalSize(228, 112), SetResize(1, 14), SetFill(1, 1), SetMatrixDataTip(1, 8, STR_NULL), SetScrollbar(WID_VR_SCROLLBAR), + NWidget(WWT_MATRIX, COLOUR_GREY, WID_VR_MATRIX), SetMinimalSize(228, 112), SetResize(1, 14), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_NULL), SetScrollbar(WID_VR_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_VR_SCROLLBAR), EndContainer(), NWidget(WWT_PANEL, COLOUR_GREY, WID_VR_INFO), SetMinimalTextLines(2, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM), SetResize(1, 0), EndContainer(), @@ -1248,7 +1247,7 @@ static const NWidgetPart _nested_vehicle_list[] = { EndContainer(), NWidget(NWID_HORIZONTAL), - NWidget(WWT_MATRIX, COLOUR_GREY, WID_VL_LIST), SetMinimalSize(248, 0), SetFill(1, 0), SetResize(1, 1), SetScrollbar(WID_VL_SCROLLBAR), + NWidget(WWT_MATRIX, COLOUR_GREY, WID_VL_LIST), SetMinimalSize(248, 0), SetFill(1, 0), SetResize(1, 1), SetMatrixDataTip(1, 0, STR_NULL), SetScrollbar(WID_VL_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_VL_SCROLLBAR), EndContainer(), @@ -1671,7 +1670,6 @@ public: virtual void OnResize() { this->vscroll->SetCapacityFromWidget(this, WID_VL_LIST); - this->GetWidget<NWidgetCore>(WID_VL_LIST)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } /** @@ -1794,7 +1792,7 @@ static const NWidgetPart _nested_train_vehicle_details_widgets[] = { EndContainer(), NWidget(WWT_PANEL, COLOUR_GREY, WID_VD_TOP_DETAILS), SetResize(1, 0), SetMinimalSize(405, 42), EndContainer(), NWidget(NWID_HORIZONTAL), - NWidget(WWT_MATRIX, COLOUR_GREY, WID_VD_MATRIX), SetResize(1, 1), SetMinimalSize(393, 45), SetMatrixDataTip(1, 7, STR_NULL), SetFill(1, 0), SetScrollbar(WID_VD_SCROLLBAR), + NWidget(WWT_MATRIX, COLOUR_GREY, WID_VD_MATRIX), SetResize(1, 1), SetMinimalSize(393, 45), SetMatrixDataTip(1, 0, STR_NULL), SetFill(1, 0), SetScrollbar(WID_VD_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_VD_SCROLLBAR), EndContainer(), NWidget(NWID_HORIZONTAL), @@ -2199,7 +2197,6 @@ struct VehicleDetailsWindow : Window { NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_VD_MATRIX); if (nwi != NULL) { this->vscroll->SetCapacityFromWidget(this, WID_VD_MATRIX); - nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } } }; diff --git a/src/widget.cpp b/src/widget.cpp index beaa808ed..6eaaef998 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -270,16 +270,30 @@ static inline void DrawInset(const Rect &r, Colours colour, StringID str) * @param colour Colour of the background. * @param clicked Matrix is rendered lowered. * @param data Data of the widget, number of rows and columns of the widget. + * @param resize_x Matrix resize unit size. + * @param resize_y Matrix resize unit size. */ -static inline void DrawMatrix(const Rect &r, Colours colour, bool clicked, uint16 data) +static inline void DrawMatrix(const Rect &r, Colours colour, bool clicked, uint16 data, uint resize_x, uint resize_y) { DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE); int num_columns = GB(data, MAT_COL_START, MAT_COL_BITS); // Lower 8 bits of the widget data: Number of columns in the matrix. - int column_width = (r.right - r.left + 1) / num_columns; // Width of a single column in the matrix. + int column_width; // Width of a single column in the matrix. + if (num_columns == 0) { + column_width = resize_x; + num_columns = (r.right - r.left + 1) / column_width; + } else { + column_width = (r.right - r.left + 1) / num_columns; + } int num_rows = GB(data, MAT_ROW_START, MAT_ROW_BITS); // Upper 8 bits of the widget data: Number of rows in the matrix. - int row_height = (r.bottom - r.top + 1) / num_rows; // Height of a single row in the matrix. + int row_height; // Height of a single row in the matrix. + if (num_rows == 0) { + row_height = resize_y; + num_rows = (r.bottom - r.top + 1) / row_height; + } else { + row_height = (r.bottom - r.top + 1) / num_rows; + } int col = _colour_gradient[colour & 0xF][6]; @@ -2401,7 +2415,7 @@ void NWidgetLeaf::Draw(const Window *w) break; case WWT_MATRIX: - DrawMatrix(r, this->colour, clicked, this->widget_data); + DrawMatrix(r, this->colour, clicked, this->widget_data, this->resize_x, this->resize_y); break; case WWT_EDITBOX: { diff --git a/src/widget_type.h b/src/widget_type.h index 14b555315..793f93b71 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -1022,8 +1022,8 @@ static inline NWidgetPart SetDataTip(uint16 data, StringID tip) /** * Widget part function for setting the data and tooltip of WWT_MATRIX widgets - * @param cols Number of columns. - * @param rows Number of rows. + * @param cols Number of columns. \c 0 means to use draw columns with width according to the resize step size. + * @param rows Number of rows. \c 0 means to use draw rows with height according to the resize step size. * @param tip Tooltip of the widget. * @ingroup NestedWidgetParts */ |