Skip to content

Commit

Permalink
#6131: XYWnd is a DockablePanel
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 26, 2022
1 parent 1884104 commit 8a6ed8e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
50 changes: 27 additions & 23 deletions radiant/xyview/XYWnd.cpp
Expand Up @@ -68,10 +68,11 @@ namespace
int XYWnd::_nextId = 1;

XYWnd::XYWnd(wxWindow* parent, XYWndManager& owner) :
DockablePanel(parent),
MouseToolHandler(IMouseToolGroup::Type::OrthoView),
_owner(owner),
_id(_nextId++),
_wxGLWidget(new wxutil::GLWidget(parent, std::bind(&XYWnd::onRender, this), "XYWnd")),
_wxGLWidget(new wxutil::GLWidget(this, std::bind(&XYWnd::onRender, this), "XYWnd")),
_drawing(false),
_updateRequested(false),
_minWorldCoord(game::current::getValue<float>("/defaults/minWorldCoord")),
Expand All @@ -83,6 +84,9 @@ XYWnd::XYWnd(wxWindow* parent, XYWndManager& owner) :
{
_owner.registerXYWnd(this);

SetSizer(new wxBoxSizer(wxVERTICAL));
GetSizer()->Add(_wxGLWidget, 1, wxEXPAND);

_width = 0;
_height = 0;

Expand All @@ -107,28 +111,28 @@ XYWnd::XYWnd(wxWindow* parent, XYWndManager& owner) :
//_wxGLWidget->SetMinClientSize(wxSize(XYWND_MINSIZE_X, XYWND_MINSIZE_Y));

// wxGLWidget wireup
_wxGLWidget->Connect(wxEVT_SIZE, wxSizeEventHandler(XYWnd::onGLResize), NULL, this);

_wxGLWidget->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(XYWnd::onGLWindowScroll), NULL, this);
_wxGLWidget->Connect(wxEVT_MOTION, wxMouseEventHandler(XYWnd::onGLMouseMove), NULL, this);

_wxGLWidget->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(XYWnd::onGLMouseButtonPress), NULL, this);
_wxGLWidget->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(XYWnd::onGLMouseButtonPress), NULL, this);
_wxGLWidget->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(XYWnd::onGLMouseButtonRelease), NULL, this);
_wxGLWidget->Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(XYWnd::onGLMouseButtonPress), NULL, this);
_wxGLWidget->Connect(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(XYWnd::onGLMouseButtonPress), NULL, this);
_wxGLWidget->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XYWnd::onGLMouseButtonRelease), NULL, this);
_wxGLWidget->Connect(wxEVT_MIDDLE_DOWN, wxMouseEventHandler(XYWnd::onGLMouseButtonPress), NULL, this);
_wxGLWidget->Connect(wxEVT_MIDDLE_DCLICK, wxMouseEventHandler(XYWnd::onGLMouseButtonPress), NULL, this);
_wxGLWidget->Connect(wxEVT_MIDDLE_UP, wxMouseEventHandler(XYWnd::onGLMouseButtonRelease), NULL, this);
_wxGLWidget->Connect(wxEVT_AUX1_DOWN, wxMouseEventHandler(XYWnd::onGLMouseButtonPress), NULL, this);
_wxGLWidget->Connect(wxEVT_AUX1_DCLICK, wxMouseEventHandler(XYWnd::onGLMouseButtonPress), NULL, this);
_wxGLWidget->Connect(wxEVT_AUX1_UP, wxMouseEventHandler(XYWnd::onGLMouseButtonRelease), NULL, this);
_wxGLWidget->Connect(wxEVT_AUX2_DOWN, wxMouseEventHandler(XYWnd::onGLMouseButtonPress), NULL, this);
_wxGLWidget->Connect(wxEVT_AUX2_DCLICK, wxMouseEventHandler(XYWnd::onGLMouseButtonPress), NULL, this);
_wxGLWidget->Connect(wxEVT_AUX2_UP, wxMouseEventHandler(XYWnd::onGLMouseButtonRelease), NULL, this);

_wxGLWidget->Connect(wxEVT_IDLE, wxIdleEventHandler(XYWnd::onIdle), NULL, this);
_wxGLWidget->Bind(wxEVT_SIZE, &XYWnd::onGLResize, this);

_wxGLWidget->Bind(wxEVT_MOUSEWHEEL, &XYWnd::onGLWindowScroll, this);
_wxGLWidget->Bind(wxEVT_MOTION, &XYWnd::onGLMouseMove, this);

_wxGLWidget->Bind(wxEVT_LEFT_DOWN, &XYWnd::onGLMouseButtonPress, this);
_wxGLWidget->Bind(wxEVT_LEFT_DCLICK, &XYWnd::onGLMouseButtonPress, this);
_wxGLWidget->Bind(wxEVT_LEFT_UP, &XYWnd::onGLMouseButtonRelease, this);
_wxGLWidget->Bind(wxEVT_RIGHT_DOWN, &XYWnd::onGLMouseButtonPress, this);
_wxGLWidget->Bind(wxEVT_RIGHT_DCLICK, &XYWnd::onGLMouseButtonPress, this);
_wxGLWidget->Bind(wxEVT_RIGHT_UP, &XYWnd::onGLMouseButtonRelease, this);
_wxGLWidget->Bind(wxEVT_MIDDLE_DOWN, &XYWnd::onGLMouseButtonPress, this);
_wxGLWidget->Bind(wxEVT_MIDDLE_DCLICK, &XYWnd::onGLMouseButtonPress, this);
_wxGLWidget->Bind(wxEVT_MIDDLE_UP, &XYWnd::onGLMouseButtonRelease, this);
_wxGLWidget->Bind(wxEVT_AUX1_DOWN, &XYWnd::onGLMouseButtonPress, this);
_wxGLWidget->Bind(wxEVT_AUX1_DCLICK, &XYWnd::onGLMouseButtonPress, this);
_wxGLWidget->Bind(wxEVT_AUX1_UP, &XYWnd::onGLMouseButtonRelease, this);
_wxGLWidget->Bind(wxEVT_AUX2_DOWN, &XYWnd::onGLMouseButtonPress, this);
_wxGLWidget->Bind(wxEVT_AUX2_DCLICK, &XYWnd::onGLMouseButtonPress, this);
_wxGLWidget->Bind(wxEVT_AUX2_UP, &XYWnd::onGLMouseButtonRelease, this);

_wxGLWidget->Bind(wxEVT_IDLE, &XYWnd::onIdle, this);

_freezePointer.connectMouseEvents(
std::bind(&XYWnd::onGLMouseButtonPress, this, std::placeholders::_1),
Expand Down
3 changes: 2 additions & 1 deletion radiant/xyview/XYWnd.h
Expand Up @@ -20,6 +20,7 @@
#include "imousetool.h"
#include "tools/XYMouseToolEvent.h"
#include "wxutil/MouseToolHandler.h"
#include "wxutil/DockablePanel.h"
#include "XYRenderer.h"

namespace ui
Expand All @@ -28,7 +29,7 @@ namespace ui
class XYWndManager;

class XYWnd final :
public wxPanel,
public wxutil::DockablePanel,
public IOrthoView,
public scene::Graph::Observer,
protected wxutil::MouseToolHandler
Expand Down

0 comments on commit 8a6ed8e

Please sign in to comment.