From cf859ad7a718dfe7ee8af17c139f1bb2e9243db2 Mon Sep 17 00:00:00 2001 From: Matthew Mott Date: Tue, 25 Jan 2022 19:49:44 +0000 Subject: [PATCH] #5872: show skins button is pressed by default The ModelSelector always starts off showing skins in the tree, so this change makes the initial button state correspond to the visible behaviour. --- radiant/ui/modelselector/ModelSelector.cpp | 32 +++++++++++++--------- radiant/ui/modelselector/ModelSelector.h | 6 ++-- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/radiant/ui/modelselector/ModelSelector.cpp b/radiant/ui/modelselector/ModelSelector.cpp index f337cd558c..933b39354d 100644 --- a/radiant/ui/modelselector/ModelSelector.cpp +++ b/radiant/ui/modelselector/ModelSelector.cpp @@ -258,31 +258,37 @@ void ModelSelector::onModelLoaded(const model::ModelNodePtr& modelNode) _materialsList->updateFromModel(model); } -// Helper function to create the TreeView -void ModelSelector::setupTreeView(wxWindow* parent) +wxWindow* ModelSelector::setupTreeViewToolbar(wxWindow* parent) { - _treeView = new ModelTreeView(parent); - _treeView->SetMinSize(wxSize(200, 200)); - - // Get selection and connect the changed callback - _treeView->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &ModelSelector::onSelectionChanged, this); - _treeView->Bind(wxutil::EV_TREEVIEW_POPULATION_FINISHED, - &ModelSelector::onTreeViewPopulationFinished, this); - // Set up the top treeview toolbar, including a custom button to enable/disable the showing of // skins in the tree. auto* toolbar = new wxutil::ResourceTreeViewToolbar(parent, _treeView); auto* showSkinsBtn = new wxutil::BitmapToggleButton(toolbar, wxutil::GetLocalBitmap("skin16.png"), wxutil::GetLocalBitmap("skin16.png")); - showSkinsBtn->SetToolTip(_("Show skins in the tree as children of their associated models")); + showSkinsBtn->SetValue(true); + showSkinsBtn->SetToolTip(_("List model skins in the tree underneath their associated models")); showSkinsBtn->Bind(wxEVT_TOGGLEBUTTON, [this](auto& ev) { _treeView->SetShowSkins(ev.IsChecked()); }); toolbar->GetRightSizer()->Add(showSkinsBtn, wxSizerFlags().Border(wxLEFT, 6)); + return toolbar; +} + +void ModelSelector::setupTreeView(wxWindow* parent) +{ + _treeView = new ModelTreeView(parent); + _treeView->SetMinSize(wxSize(200, 200)); + + // Get selection and connect the changed callback + _treeView->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &ModelSelector::onSelectionChanged, this); + _treeView->Bind(wxutil::EV_TREEVIEW_POPULATION_FINISHED, + &ModelSelector::onTreeViewPopulationFinished, this); + + // Pack in tree view and its toolbar parent->GetSizer()->Prepend(_treeView, 1, wxEXPAND); - parent->GetSizer()->Prepend(toolbar, 0, wxEXPAND | wxALIGN_LEFT | wxBOTTOM | wxLEFT | wxRIGHT, - 6); + parent->GetSizer()->Prepend(setupTreeViewToolbar(parent), 0, + wxEXPAND | wxALIGN_LEFT | wxBOTTOM | wxLEFT | wxRIGHT, 6); parent->GetSizer()->Layout(); // Accept the dialog on double-clicking on a model in the list diff --git a/radiant/ui/modelselector/ModelSelector.h b/radiant/ui/modelselector/ModelSelector.h index 152103c1ce..55a48d52e6 100644 --- a/radiant/ui/modelselector/ModelSelector.h +++ b/radiant/ui/modelselector/ModelSelector.h @@ -42,11 +42,8 @@ class ModelSelector; typedef std::shared_ptr ModelSelectorPtr; /// Dialog for browsing and selecting a model and/or skin -class ModelSelector : - public wxutil::DialogBase, - private wxutil::XmlResourceBasedWidget +class ModelSelector: public wxutil::DialogBase, private wxutil::XmlResourceBasedWidget { -private: wxPanel* _dialogPanel; // Model preview widget @@ -94,6 +91,7 @@ class ModelSelector : // Helper functions to configure GUI components void setupAdvancedPanel(wxWindow* parent); void setupTreeView(wxWindow* parent); + wxWindow* setupTreeViewToolbar(wxWindow* parent); // Populate the tree view with models void populateModels();