From a62468bed666efa2cdae8e2a34f31c760ddaa40a Mon Sep 17 00:00:00 2001 From: alberth Date: Tue, 28 Jul 2015 18:18:59 +0000 Subject: (svn r27345) -Fix-ish: Hide selected view if no object selected. --- src/object_gui.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 25856c172..c31915d57 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -337,10 +337,7 @@ public: _selected_object_view = 0; } - this->GetWidget(WID_BO_OBJECT_MATRIX)->SetClicked(_selected_object_view); - this->GetWidget(WID_BO_SELECT_MATRIX)->SetClicked(_selected_object_index != -1 ? ObjectClass::Get(_selected_object_class)->GetUIFromIndex(_selected_object_index) : -1); - this->UpdateSelectSize(); - this->SetDirty(); + this->UpdateButtons(_selected_object_class, _selected_object_index, _selected_object_view); } void UpdateSelectSize() @@ -355,6 +352,29 @@ public: } } + /** + * Update buttons to show the selection to the user. + * @param sel_class The class of the selected object. + * @param sel_index Index of the object to select, or \c -1 . + * @param sel_view View of the object to select. + */ + void UpdateButtons(ObjectClassID sel_class, int sel_index, uint sel_view) + { + int view_number, object_number; + if (sel_index == -1) { + view_number = -1; // If no object selected, also hide the selected view. + object_number = -1; + } else { + view_number = sel_view; + object_number = ObjectClass::Get(sel_class)->GetUIFromIndex(sel_index); + } + + this->GetWidget(WID_BO_OBJECT_MATRIX)->SetClicked(view_number); + this->GetWidget(WID_BO_SELECT_MATRIX)->SetClicked(object_number); + this->UpdateSelectSize(); + this->SetDirty(); + } + virtual void OnResize() { this->vscroll->SetCapacityFromWidget(this, WID_BO_CLASS_LIST); -- cgit v1.2.3-70-g09d2