Skip to content

Commit

Permalink
#5532: Switch off the favourite controls, add the section label to th…
Browse files Browse the repository at this point in the history
…e toolbar instead.
  • Loading branch information
codereader committed Mar 22, 2021
1 parent 1c7d0ce commit 0a59f33
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
36 changes: 26 additions & 10 deletions libs/wxutil/dataview/ResourceTreeViewToolbar.cpp
Expand Up @@ -23,18 +23,18 @@ ResourceTreeViewToolbar::ResourceTreeViewToolbar(wxWindow* parent, ResourceTreeV
SetSizer(grid);

// Hbox for the favourites selection widgets
auto* favourites = new wxBoxSizer(wxHORIZONTAL);
_leftSizer = new wxBoxSizer(wxHORIZONTAL);
_showAll = new wxRadioButton(this, wxID_ANY, _("Show All"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
_showFavourites = new wxRadioButton(this, wxID_ANY, _("Show Favourites"));

_showAll->Bind(wxEVT_RADIOBUTTON, &ResourceTreeViewToolbar::_onFilterButtonToggled, this);
_showFavourites->Bind(wxEVT_RADIOBUTTON, &ResourceTreeViewToolbar::_onFilterButtonToggled, this);

favourites->Add(_showAll, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0);
favourites->Add(_showFavourites, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 6);
_leftSizer->Add(_showAll, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0);
_leftSizer->Add(_showFavourites, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 6);

// Filter text entry box
auto* filterBox = new wxBoxSizer(wxHORIZONTAL);
_rightSizer = new wxBoxSizer(wxHORIZONTAL);

auto* filterImage = new wxStaticBitmap(this, wxID_ANY, wxArtProvider::GetBitmap(wxART_FIND, wxART_TOOLBAR, wxSize(16, 16)));

Expand Down Expand Up @@ -65,17 +65,33 @@ ResourceTreeViewToolbar::ResourceTreeViewToolbar(wxWindow* parent, ResourceTreeV
JumpToPrevFilterMatch();
});

filterBox->Add(filterImage, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 6);
filterBox->Add(_filterEntry, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 6);
filterBox->Add(_findPrevButton, 0, wxEXPAND | wxRIGHT, 3);
filterBox->Add(_findNextButton, 0, wxEXPAND, 6);
_rightSizer->Add(filterImage, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 6);
_rightSizer->Add(_filterEntry, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 6);
_rightSizer->Add(_findPrevButton, 0, wxEXPAND | wxRIGHT, 3);
_rightSizer->Add(_findNextButton, 0, wxEXPAND, 6);

grid->Add(favourites, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxRIGHT, 6);
grid->Add(filterBox, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 6);
grid->Add(_leftSizer, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxRIGHT, 6);
grid->Add(_rightSizer, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT, 6);

AssociateToTreeView(treeView);
}

wxSizer* ResourceTreeViewToolbar::GetLeftSizer()
{
return _leftSizer;
}

wxSizer* ResourceTreeViewToolbar::GetRightSizer()
{
return _rightSizer;
}

void ResourceTreeViewToolbar::EnableFavouriteManagement(bool enable)
{
_showAll->Show(enable);
_showFavourites->Show(enable);
}

void ResourceTreeViewToolbar::AssociateToTreeView(ResourceTreeView* treeView)
{
_treeView = treeView;
Expand Down
11 changes: 11 additions & 0 deletions libs/wxutil/dataview/ResourceTreeViewToolbar.h
Expand Up @@ -26,9 +26,20 @@ class ResourceTreeViewToolbar :
wxBitmapButton* _findPrevButton;
wxBitmapButton* _findNextButton;

wxSizer* _leftSizer;
wxSizer* _rightSizer;

public:
ResourceTreeViewToolbar(wxWindow* parent, ResourceTreeView* treeView = nullptr);

// Return the sizer for packing items in the left half of the toolbar
wxSizer* GetLeftSizer();

// Return the sizer for packing items in the right half of the toolbar
wxSizer* GetRightSizer();

void EnableFavouriteManagement(bool enable);

void AssociateToTreeView(ResourceTreeView* treeView);

void ClearFilter();
Expand Down
6 changes: 6 additions & 0 deletions radiant/ui/materials/MaterialEditor.cpp
Expand Up @@ -128,6 +128,12 @@ MaterialEditor::MaterialEditor() :
_treeView->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &MaterialEditor::_onTreeViewSelectionChanged, this);

auto* treeToolbar = new wxutil::ResourceTreeViewToolbar(panel, _treeView);
treeToolbar->EnableFavouriteManagement(false);

auto definitionLabel = getControl<wxStaticText>("MaterialEditorDefinitionLabel");
definitionLabel->GetContainingSizer()->Detach(definitionLabel);
definitionLabel->Reparent(treeToolbar);
treeToolbar->GetLeftSizer()->Add(definitionLabel, 0, wxALIGN_LEFT);

panel->GetSizer()->Add(treeToolbar, 0, wxEXPAND | wxBOTTOM, 6);
panel->GetSizer()->Add(_treeView, 1, wxEXPAND);
Expand Down

0 comments on commit 0a59f33

Please sign in to comment.