Skip to content

Commit

Permalink
Move more toolbar-related stuff to SelectionSetToolmenu
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 18, 2020
1 parent bfae079 commit c70f664
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
26 changes: 2 additions & 24 deletions radiant/selection/selectionset/SelectionSetModule.cpp
Expand Up @@ -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 <sigc++/sigc++.h>
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)
Expand Down
23 changes: 22 additions & 1 deletion radiant/selection/selectionset/SelectionSetToolmenu.cpp
Expand Up @@ -6,6 +6,7 @@
#include "iuimanager.h"
#include "imap.h"
#include "iradiant.h"
#include "imainframe.h"
#include "itextstream.h"
#include "idialogmanager.h"

Expand All @@ -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
Expand All @@ -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)
);
Expand Down
2 changes: 1 addition & 1 deletion radiant/selection/selectionset/SelectionSetToolmenu.h
Expand Up @@ -23,7 +23,7 @@ class SelectionSetToolmenu
wxToolBarToolBase* _clearAllButton;

public:
SelectionSetToolmenu(wxToolBar* toolbar);
SelectionSetToolmenu();

private:
// Updates the available list items and widget sensitivity
Expand Down

0 comments on commit c70f664

Please sign in to comment.