Skip to content

Commit

Permalink
#2132: Add tool item to camera toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Feb 5, 2021
1 parent 26a2adb commit 55fa827
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
14 changes: 14 additions & 0 deletions install/ui/camwnd.fbp
Expand Up @@ -228,6 +228,20 @@
<property name="statusbar"></property>
<property name="tooltip">Clip plane out</property>
</object>
<object class="toolSeparator" expanded="1">
<property name="permission">protected</property>
</object>
<object class="tool" expanded="1">
<property name="bitmap">Load From Art Provider; darkradiant:grid_toggle.png; wxART_TOOLBAR</property>
<property name="context_menu">0</property>
<property name="id">wxID_ANY</property>
<property name="kind">wxITEM_CHECK</property>
<property name="label">drawGridButton</property>
<property name="name">drawGridButton</property>
<property name="permission">protected</property>
<property name="statusbar"></property>
<property name="tooltip">Draw 3D Grid</property>
</object>
</object>
</object>
</object>
Expand Down
8 changes: 8 additions & 0 deletions install/ui/camwnd.xrc
Expand Up @@ -82,6 +82,14 @@
<longhelp></longhelp>
<bitmap stock_id="darkradiant:farClipOut.png" stock_client="wxART_TOOLBAR">undefined.png</bitmap>
</object>
<object class="separator" />
<object class="tool" name="drawGridButton">
<label>drawGridButton</label>
<tooltip>Draw 3D Grid</tooltip>
<longhelp></longhelp>
<bitmap stock_id="darkradiant:grid_toggle.png" stock_client="wxART_TOOLBAR">undefined.png</bitmap>
<toggle>1</toggle>
</object>
</object>
</object>
</object>
Expand Down
8 changes: 8 additions & 0 deletions radiant/camera/CamWnd.cpp
Expand Up @@ -137,6 +137,7 @@ void CamWnd::constructToolbar()
const wxToolBarToolBase* flatShadeBtn = getToolBarToolByLabel(_camToolbar, "flatShadeBtn");
const wxToolBarToolBase* texturedBtn = getToolBarToolByLabel(_camToolbar, "texturedBtn");
const wxToolBarToolBase* lightingBtn = getToolBarToolByLabel(_camToolbar, "lightingBtn");
const wxToolBarToolBase* gridButton = getToolBarToolByLabel(_camToolbar, "drawGridButton");

if (!GlobalRenderSystem().shaderProgramsAvailable())
{
Expand All @@ -156,6 +157,9 @@ void CamWnd::constructToolbar()
_mainWxWidget->GetParent()->Bind(wxEVT_COMMAND_TOOL_CLICKED,&CamWnd::onRenderModeButtonsChanged, this, flatShadeBtn->GetId());
_mainWxWidget->GetParent()->Bind(wxEVT_COMMAND_TOOL_CLICKED, &CamWnd::onRenderModeButtonsChanged, this, texturedBtn->GetId());
_mainWxWidget->GetParent()->Bind(wxEVT_COMMAND_TOOL_CLICKED, &CamWnd::onRenderModeButtonsChanged, this, lightingBtn->GetId());

auto toggleCameraGridEvent = GlobalEventManager().findEvent("ToggleCameraGrid");
toggleCameraGridEvent->connectToolItem(gridButton);

// Far clip buttons.
_farClipInID = getToolID(_camToolbar, "clipPlaneInButton");
Expand Down Expand Up @@ -236,6 +240,10 @@ void CamWnd::constructGUIComponents()

CamWnd::~CamWnd()
{
const wxToolBarToolBase* gridButton = getToolBarToolByLabel(_camToolbar, "drawGridButton");
auto toggleCameraGridEvent = GlobalEventManager().findEvent("ToggleCameraGrid");
toggleCameraGridEvent->disconnectToolItem(gridButton);

// Stop the timer, it might still fire even during shutdown
_timer.Stop();

Expand Down
2 changes: 2 additions & 0 deletions radiant/camera/CameraWndManager.cpp
Expand Up @@ -69,6 +69,8 @@ void CameraWndManager::registerCommands()
GlobalEventManager().addWidgetToggle("ToggleCamera");
GlobalEventManager().setToggled("ToggleCamera", true);

GlobalEventManager().addRegistryToggle("ToggleCameraGrid", RKEY_CAMERA_GRID_ENABLED);

GlobalEventManager().addKeyEvent("CameraMoveForward", std::bind(&CameraWndManager::onMoveForwardKey, this, std::placeholders::_1));
GlobalEventManager().addKeyEvent("CameraMoveBack", std::bind(&CameraWndManager::onMoveBackKey, this, std::placeholders::_1));
GlobalEventManager().addKeyEvent("CameraMoveLeft", std::bind(&CameraWndManager::onMoveLeftKey, this, std::placeholders::_1));
Expand Down

0 comments on commit 55fa827

Please sign in to comment.