# HG changeset patch # User sbr # Date 1370378933 -7200 # Branch fs5567_02 # Node ID 746f9822492e3c0a3d4e4e1b3300036ff7b507c3 # Parent 2b13bc4f7b4cc549b467051740ee7eb57bbd05bb # Parent fae04a0a58690d473bdefc0a25c007c7ba520c9a -Change: Restore the window size before setting up the object matrix. The visibility of an object depends of the size of the matrix. The window size should then be resized before SelectOtherObject() call SetClicked() on the matrix. diff --git a/src/object_gui.cpp b/src/object_gui.cpp --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -83,6 +83,19 @@ this->FinishInitNested(0); + /* If needed restore the window previous size with the stored values.*/ + uint default_num_cols = this->GetMatrixColumnCount(); + uint default_num_rows = this->vscroll->GetCapacity(); + int delta_x = (_matrix_col_count > default_num_cols) ? (_matrix_col_count - default_num_cols) * this->resize.step_width : 0; + int delta_y = (_list_row_count > default_num_rows) ? (_list_row_count - default_num_rows) * this->resize.step_height : 0; + if (delta_x > 0 || delta_y > 0) { + ResizeWindow(this, delta_x, delta_y, false); + /* The window may be linked to the toolbars, thus positioned at the left-bottom of the toolbars. + * If the resized window is wider than the toolbars, its position need te be adjusted to ensure all + * matrix columns are visible. */ + this->FindWindowPlacementAndResize(this->width, this->height); + } + NWidgetMatrix *matrix = this->GetWidget(WID_BO_SELECT_MATRIX); matrix->SetScrollbar(this->GetScrollbar(WID_BO_SELECT_SCROLL)); @@ -95,19 +108,6 @@ assert(ObjectClass::Get(_selected_object_class)->GetUISpecCount() > 0); // object GUI should be disables elsewise this->EnsureSelectedObjectClassIsVisible(); this->GetWidget(WID_BO_OBJECT_MATRIX)->SetCount(4); - - /* If needed restore the window previous size with the stored values.*/ - uint default_num_cols = this->GetMatrixColumnCount(); - uint default_num_rows = this->vscroll->GetCapacity(); - int delta_x = (_matrix_col_count > default_num_cols) ? (_matrix_col_count - default_num_cols) * this->resize.step_width : 0; - int delta_y = (_list_row_count > default_num_rows) ? (_list_row_count - default_num_rows) * this->resize.step_height : 0; - if (delta_x > 0 || delta_y > 0) { - ResizeWindow(this, delta_x, delta_y, false); - /* The window may be linked to the toolbars, thus positioned at the left-bottom of the toolbars. - * If the resized window is wider than the toolbars, its position need te be adjusted to ensure all - * matrix columns are visible. */ - this->FindWindowPlacementAndResize(this->width, this->height); - } } virtual ~BuildObjectWindow()