Skip to content

Commit

Permalink
#5872: show skins button is pressed by default
Browse files Browse the repository at this point in the history
The ModelSelector always starts off showing skins in the tree, so this change
makes the initial button state correspond to the visible behaviour.
  • Loading branch information
Matthew Mott committed Jan 25, 2022
1 parent 30caee2 commit cf859ad
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
32 changes: 19 additions & 13 deletions radiant/ui/modelselector/ModelSelector.cpp
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions radiant/ui/modelselector/ModelSelector.h
Expand Up @@ -42,11 +42,8 @@ class ModelSelector;
typedef std::shared_ptr<ModelSelector> 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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit cf859ad

Please sign in to comment.