From c70f664e168fa06ce3eccad40587beb0e5f0faea Mon Sep 17 00:00:00 2001 From: codereader Date: Wed, 18 Mar 2020 18:01:56 +0100 Subject: [PATCH] Move more toolbar-related stuff to SelectionSetToolmenu --- .../selectionset/SelectionSetModule.cpp | 26 ++----------------- .../selectionset/SelectionSetToolmenu.cpp | 23 +++++++++++++++- .../selectionset/SelectionSetToolmenu.h | 2 +- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/radiant/selection/selectionset/SelectionSetModule.cpp b/radiant/selection/selectionset/SelectionSetModule.cpp index 90f3af449e..5ec6bddd78 100644 --- a/radiant/selection/selectionset/SelectionSetModule.cpp +++ b/radiant/selection/selectionset/SelectionSetModule.cpp @@ -4,8 +4,8 @@ #include "ieventmanager.h" #include "iselection.h" #include "icommandsystem.h" -#include "i18n.h" #include "imap.h" +#include "i18n.h" #include "iradiant.h" #include @@ -42,11 +42,9 @@ class SelectionSetModule : if (_dependencies.empty()) { - _dependencies.insert(MODULE_SELECTIONSYSTEM); _dependencies.insert(MODULE_EVENTMANAGER); _dependencies.insert(MODULE_COMMANDSYSTEM); _dependencies.insert(MODULE_RADIANT); - _dependencies.insert(MODULE_MAP); _dependencies.insert(MODULE_MAPINFOFILEMANAGER); } @@ -75,28 +73,8 @@ class SelectionSetModule : private: void onRadiantStartup() { - // Get the horizontal toolbar and add a custom widget - wxToolBar* toolbar = GlobalMainFrame().getToolbar(IMainFrame::TOOLBAR_HORIZONTAL); - - // Insert a separator at the end of the toolbar - toolbar->AddSeparator(); - - wxStaticText* label = new wxStaticText(toolbar, wxID_ANY, _("Selection Set: ")); - toolbar->AddControl(label); - // Construct a new tool menu object - _toolMenu.reset(new SelectionSetToolmenu(toolbar)); - - toolbar->Realize(); - -#ifdef __WXOSX__ - // Weird workaround to stop an empty area from being drawn - // where the label and combobox are supposed to be - label->Hide(); - label->Show(); - _toolMenu->Hide(); - _toolMenu->Show(); -#endif + _toolMenu.reset(new SelectionSetToolmenu); } void deleteAllSelectionSetsCmd(const cmd::ArgumentList& args) diff --git a/radiant/selection/selectionset/SelectionSetToolmenu.cpp b/radiant/selection/selectionset/SelectionSetToolmenu.cpp index 11d43ba72d..f3f5420cd1 100644 --- a/radiant/selection/selectionset/SelectionSetToolmenu.cpp +++ b/radiant/selection/selectionset/SelectionSetToolmenu.cpp @@ -6,6 +6,7 @@ #include "iuimanager.h" #include "imap.h" #include "iradiant.h" +#include "imainframe.h" #include "itextstream.h" #include "idialogmanager.h" @@ -26,9 +27,18 @@ namespace const int CLEAR_TOOL_ID = 1; } -SelectionSetToolmenu::SelectionSetToolmenu(wxToolBar* toolbar) : +SelectionSetToolmenu::SelectionSetToolmenu() : _dropdownToolId(wxID_NONE) { + // Get the horizontal toolbar and add a custom widget + wxToolBar* toolbar = GlobalMainFrame().getToolbar(IMainFrame::TOOLBAR_HORIZONTAL); + + // Insert a separator at the end of the toolbar + toolbar->AddSeparator(); + + wxStaticText* label = new wxStaticText(toolbar, wxID_ANY, _("Selection Set: ")); + toolbar->AddControl(label); + _dropdown = new wxComboBox(toolbar, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER); // Add tooltip @@ -46,6 +56,17 @@ SelectionSetToolmenu::SelectionSetToolmenu(wxToolBar* toolbar) : toolbar->Bind(wxEVT_TOOL, &SelectionSetToolmenu::onDeleteAllSetsClicked, this, _clearAllButton->GetId()); + toolbar->Realize(); + +#ifdef __WXOSX__ + // Weird workaround to stop an empty area from being drawn + // where the label and combobox are supposed to be + label->Hide(); + label->Show(); + _toolMenu->Hide(); + _toolMenu->Show(); +#endif + _mapEventHandler = GlobalMapModule().signal_mapEvent().connect( sigc::mem_fun(*this, &SelectionSetToolmenu::onMapEvent) ); diff --git a/radiant/selection/selectionset/SelectionSetToolmenu.h b/radiant/selection/selectionset/SelectionSetToolmenu.h index 042bdc40ce..70e5c7ece4 100644 --- a/radiant/selection/selectionset/SelectionSetToolmenu.h +++ b/radiant/selection/selectionset/SelectionSetToolmenu.h @@ -23,7 +23,7 @@ class SelectionSetToolmenu wxToolBarToolBase* _clearAllButton; public: - SelectionSetToolmenu(wxToolBar* toolbar); + SelectionSetToolmenu(); private: // Updates the available list items and widget sensitivity