Mercurial > hg > openttd
changeset 13277:fe0462278733 draft
(svn r17786) -Fix [FS#3265]: graphical glitches (matrices/scrollbars with wrong 'size') upon reiniting windows
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sat, 17 Oct 2009 14:29:10 +0000 |
parents | 17f8561cd70b |
children | 9b5e7a9fc04b |
files | src/ai/ai_gui.cpp src/bridge_gui.cpp src/build_vehicle_gui.cpp src/depot_gui.cpp src/group_gui.cpp src/industry_gui.cpp src/misc_gui.cpp src/network/network_content_gui.cpp src/network/network_gui.cpp src/newgrf_gui.cpp src/news_gui.cpp src/order_gui.cpp src/settings_gui.cpp src/signs_gui.cpp src/station_gui.cpp src/subsidy_gui.cpp src/timetable_gui.cpp src/town_gui.cpp src/vehicle_gui.cpp src/window_gui.h |
diffstat | 20 files changed, 38 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -205,7 +205,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / this->line_height); + this->vscroll.SetCapacity(this->GetWidget<NWidgetCore>(AIL_WIDGET_LIST)->current_y / this->line_height); this->GetWidget<NWidgetCore>(AIL_WIDGET_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } }; @@ -401,7 +401,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / this->line_height); + this->vscroll.SetCapacity(this->GetWidget<NWidgetCore>(AIS_WIDGET_BACKGROUND)->current_y / this->line_height); this->GetWidget<NWidgetCore>(AIS_WIDGET_BACKGROUND)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } @@ -662,8 +662,6 @@ AIDebugWindow(const WindowDesc *desc, WindowNumber number) : Window() { - this->vscroll.SetCapacity(14); // Minimal number of lines in the log panel. - this->InitNested(desc, number); /* Disable the companies who are not active or not an AI */ for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) { @@ -671,6 +669,8 @@ } this->DisableWidget(AID_WIDGET_RELOAD_TOGGLE); + this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(AID_WIDGET_LOG_PANEL)->current_y / this->resize.step_height); + this->last_vscroll_pos = 0; this->autoscroll = true; @@ -681,7 +681,7 @@ { if (widget == AID_WIDGET_LOG_PANEL) { resize->height = FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL; - size->height = this->vscroll.GetCapacity() * resize->height + this->top_offset + this->bottom_offset; + size->height = 14 * resize->height + this->top_offset + this->bottom_offset; } } @@ -878,7 +878,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(AID_WIDGET_LOG_PANEL)->current_y / this->resize.step_height); } };
--- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -284,7 +284,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(BBSW_BRIDGE_LIST)->current_y / this->resize.step_height); this->GetWidget<NWidgetCore>(BBSW_BRIDGE_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); this->last_size = max(this->vscroll.GetCapacity(), this->last_size);
--- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1177,7 +1177,7 @@ } if (delta.y == 0) return; - this->vscroll.UpdateCapacity(delta.y / (int)GetVehicleListHeight(this->vehicle_type)); + this->vscroll.SetCapacity((this->widget[BUILD_VEHICLE_WIDGET_LIST].bottom - this->widget[BUILD_VEHICLE_WIDGET_LIST].top + 1) / GetVehicleListHeight(this->vehicle_type)); this->widget[BUILD_VEHICLE_WIDGET_LIST].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } };
--- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -906,8 +906,8 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); - this->hscroll.UpdateCapacity(delta.x / (int)this->resize.step_width); + this->vscroll.SetCapacity(this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->current_y / (int)this->resize.step_height); + this->hscroll.SetCapacity(this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->current_x / (int)this->resize.step_width); this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + ((this->type == VEH_TRAIN ? 1 : this->hscroll.GetCapacity()) << MAT_COL_START); }
--- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -614,10 +614,10 @@ virtual void OnResize(Point delta) { - this->vscroll2.UpdateCapacity(delta.y / PLY_WND_PRC__SIZE_OF_ROW_TINY); - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll2.SetCapacity((this->widget[GRP_WIDGET_LIST_GROUP].bottom - this->widget[GRP_WIDGET_LIST_GROUP].top + 1) / PLY_WND_PRC__SIZE_OF_ROW_TINY); + this->widget[GRP_WIDGET_LIST_GROUP].data = (this->vscroll2.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); - this->widget[GRP_WIDGET_LIST_GROUP].data = (this->vscroll2.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); + this->vscroll.SetCapacity((this->widget[GRP_WIDGET_LIST_VEHICLE].bottom - this->widget[GRP_WIDGET_LIST_VEHICLE].top + 1) / this->resize.step_height); this->widget[GRP_WIDGET_LIST_VEHICLE].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); }
--- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -361,7 +361,7 @@ virtual void OnResize(Point delta) { /* Adjust the number of items in the matrix depending of the rezise */ - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity((this->widget[DPIW_MATRIX_WIDGET].bottom - this->widget[DPIW_MATRIX_WIDGET].top + 1) / this->resize.step_height); this->widget[DPIW_MATRIX_WIDGET].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } @@ -1050,7 +1050,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(IDW_INDUSTRY_LIST)->current_y / this->resize.step_height); } virtual void OnHundredthTick()
--- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -1857,7 +1857,7 @@ case SLD_LOAD_SCENARIO: case SLD_LOAD_HEIGHTMAP: - this->vscroll.UpdateCapacity(-1); + this->vscroll.SetCapacity(this->vscroll.GetCapacity() - 1); case SLD_SAVE_GAME: this->GenerateFileName(); break; case SLD_SAVE_SCENARIO: strecpy(this->edit_str_buf, "UNNAMED", &this->edit_str_buf[edit_str_size - 1]); break; @@ -1974,7 +1974,7 @@ break; case SLWW_DRIVES_DIRECTORIES_LIST: { // Click the listbox - int y = (pt.y - this->widget[widget].top - 1) / 10; + int y = (pt.y - this->widget[SLWW_DRIVES_DIRECTORIES_LIST].top - 1) / 10; if (y < 0 || (y += this->vscroll.GetPosition()) >= this->vscroll.GetCount()) return; @@ -2092,7 +2092,7 @@ this->widget[SLWW_SAVE_GAME].left += diff; } - this->vscroll.UpdateCapacity(delta.y / 10); + this->vscroll.SetCapacity((this->widget[SLWW_DRIVES_DIRECTORIES_LIST].bottom - this->widget[SLWW_DRIVES_DIRECTORIES_LIST].top + 1) / 10); } virtual void OnInvalidateData(int data)
--- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -692,7 +692,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity((this->widget[NCLWW_MATRIX].bottom - this->widget[NCLWW_MATRIX].top + 1) / this->resize.step_height); this->widget[NCLWW_MATRIX].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); /* Make the matrix and details section grow both bigger (or smaller) */
--- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -714,7 +714,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity((this->widget[NGWW_MATRIX].bottom - this->widget[NGWW_MATRIX].top + 1) / this->resize.step_height); this->widget[NGWW_MATRIX].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); /* Additional colums in server list */
--- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -281,7 +281,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(ANGRFW_GRF_LIST)->current_y / this->resize.step_height); } virtual void OnPaint() @@ -610,7 +610,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity(this->GetWidget<NWidgetCore>(SNGRFS_FILE_LIST)->current_y / this->resize.step_height); this->GetWidget<NWidgetCore>(SNGRFS_FILE_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); }
--- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -993,7 +993,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / this->line_height); + this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(MHW_BACKGROUND)->current_y / this->line_height); } };
--- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -1268,8 +1268,8 @@ virtual void OnResize(Point delta) { - /* Update the scroll + matrix */ - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + /* Update the scroll bar */ + this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(ORDER_WIDGET_ORDER_LIST)->current_y / this->resize.step_height); } virtual void OnTimeout()
--- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1625,7 +1625,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / SETTING_HEIGHT); + this->vscroll.SetCapacity((this->widget[SETTINGSEL_OPTIONSPANEL].bottom - this->widget[SETTINGSEL_OPTIONSPANEL].top - 8) / SETTING_HEIGHT); } };
--- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -157,7 +157,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity((this->GetWidget<NWidgetBase>(SLW_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height); } virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize)
--- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -566,7 +566,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / 10); + this->vscroll.SetCapacity((this->widget[SLW_LIST].bottom - this->widget[SLW_LIST].top + 1) / 10); } virtual void OnInvalidateData(int data) @@ -1052,7 +1052,7 @@ virtual void OnResize(Point delta) { if (delta.x != 0) ResizeButtons(this, SVW_LOCATION, SVW_RENAME); - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity((this->widget[SVW_WAITING].bottom - this->widget[SVW_WAITING].top + 1) / this->resize.step_height); } }; @@ -1296,7 +1296,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity((this->GetWidget<NWidgetBase>(JSW_PANEL)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height); } virtual void OnInvalidateData(int data)
--- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -222,7 +222,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(SLW_PANEL)->current_y / this->resize.step_height); } virtual void OnInvalidateData(int data)
--- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -333,8 +333,8 @@ virtual void OnResize(Point delta) { - /* Update the scroll + matrix */ - this->vscroll.UpdateCapacity(delta.y / 10); + /* Update the scroll bar */ + this->vscroll.SetCapacity((this->widget[TTV_TIMETABLE_PANEL].bottom - this->widget[TTV_TIMETABLE_PANEL].top + 1) / this->resize.step_height); } };
--- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -659,7 +659,7 @@ this->BuildSortTownList(); this->InitNested(desc, 0); - this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(TDW_CENTERTOWN)->current_y / (int)this->resize.step_height); + this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(TDW_CENTERTOWN)->current_y / this->resize.step_height); } ~TownDirectoryWindow() @@ -803,7 +803,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(TDW_CENTERTOWN)->current_y / this->resize.step_height); } virtual void OnInvalidateData(int data)
--- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -389,7 +389,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity((this->widget[VRW_MATRIX].bottom - this->widget[VRW_MATRIX].top + 1) / this->resize.step_height); this->widget[VRW_MATRIX].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } }; @@ -1105,7 +1105,7 @@ virtual void OnResize(Point delta) { - this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height); + this->vscroll.SetCapacity((this->widget[VLW_WIDGET_LIST].bottom - this->widget[VLW_WIDGET_LIST].top + 1) / this->resize.step_height); this->widget[VLW_WIDGET_LIST].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } @@ -1501,7 +1501,7 @@ if (delta.x != 0) ResizeButtons(this, VLD_WIDGET_DETAILS_CARGO_CARRIED, VLD_WIDGET_DETAILS_TOTAL_CARGO); if (delta.y == 0) return; - this->vscroll.UpdateCapacity(delta.y / 14); + this->vscroll.SetCapacity((this->widget[VLD_WIDGET_MIDDLE_DETAILS].bottom - this->widget[VLD_WIDGET_MIDDLE_DETAILS].top + 1) / 14); this->widget[VLD_WIDGET_MIDDLE_DETAILS].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } };
--- a/src/window_gui.h +++ b/src/window_gui.h @@ -258,17 +258,6 @@ } /** - * Updates the capacity by adding/removing a number of (visible) elements. - * @param difference the difference in capacity - * @note updates the position if needed - */ - void UpdateCapacity(int difference) - { - if (difference == 0) return; - this->SetCapacity(this->cap + difference); - } - - /** * Sets the position of the first visible element * @param position the position of the element */