Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix build error under msys2 with wxWidgets option enabled #211

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 26 additions & 21 deletions src/gui/vlWX/WXGLCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ wxGLCanvas(parent, id, attribList, pos, size, style, name, palette)
{
// let wxWidgets manage the deletion of this object
setAutomaticDelete(false);
mMouseCount = 0;
DragAcceptFiles(true);

mWXGLContext = new wxGLContext(this);
}
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -125,27 +124,37 @@ void WXGLCanvas::OnMouseWheel( wxMouseEvent& ev )
//-----------------------------------------------------------------------------
void WXGLCanvas::OnMouseUp( wxMouseEvent& ev )
{
if (ev.GetButton() == wxMOUSE_BTN_NONE)
return;
switch(ev.GetButton())
if (HasCapture())
{
case wxMOUSE_BTN_LEFT: dispatchMouseUpEvent(LeftButton, ev.GetX(), ev.GetY()); break;
case wxMOUSE_BTN_MIDDLE: dispatchMouseUpEvent(MiddleButton, ev.GetX(), ev.GetY()); break;
case wxMOUSE_BTN_RIGHT: dispatchMouseUpEvent(RightButton, ev.GetX(), ev.GetY()); break;
default:
case wxMOUSE_BTN_ANY: dispatchMouseUpEvent(UnknownButton, ev.GetX(), ev.GetY()); break;
}
mMouseCount--;
// release only once
if (!mMouseCount)
// Release the mouse capture
ReleaseMouse();
VL_CHECK(mMouseCount>=0)

if (ev.GetButton() == wxMOUSE_BTN_NONE)
{
ev.Skip();
return;
}
switch(ev.GetButton())
{
case wxMOUSE_BTN_LEFT: dispatchMouseUpEvent(LeftButton, ev.GetX(), ev.GetY()); break;
case wxMOUSE_BTN_MIDDLE: dispatchMouseUpEvent(MiddleButton, ev.GetX(), ev.GetY()); break;
case wxMOUSE_BTN_RIGHT: dispatchMouseUpEvent(RightButton, ev.GetX(), ev.GetY()); break;
default:
case wxMOUSE_BTN_ANY: dispatchMouseUpEvent(UnknownButton, ev.GetX(), ev.GetY()); break;
}
ev.Skip();
}
}
//-----------------------------------------------------------------------------
void WXGLCanvas::OnMouseDown( wxMouseEvent& ev )
{
CaptureMouse();

if (ev.GetButton() == wxMOUSE_BTN_NONE)
{
ev.Skip();
return;
}
switch(ev.GetButton())
{
case wxMOUSE_BTN_LEFT: dispatchMouseDownEvent(LeftButton, ev.GetX(), ev.GetY()); break;
Expand All @@ -154,11 +163,7 @@ void WXGLCanvas::OnMouseDown( wxMouseEvent& ev )
default:
case wxMOUSE_BTN_ANY: dispatchMouseDownEvent(UnknownButton, ev.GetX(), ev.GetY()); break;
}
// capture only once
VL_CHECK(mMouseCount>=0)
if (!mMouseCount)
CaptureMouse();
mMouseCount++;
ev.Skip();
}
//-----------------------------------------------------------------------------
void WXGLCanvas::OnSize(wxSizeEvent& ev)
Expand Down Expand Up @@ -365,7 +370,7 @@ bool WXGLCanvas::setFullscreen(bool fullscreen)
void WXGLCanvas::quitApplication()
{
wxApp* app = dynamic_cast<wxApp*>(wxApp::GetInstance());
if ( app )
if ( app )
{
app->ExitMainLoop();
}
Expand Down
10 changes: 5 additions & 5 deletions src/gui/vlWX/WXGLCanvas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@
#ifndef vlWXGLCanvas_INCLUDE_ONCE
#define vlWXGLCanvas_INCLUDE_ONCE

#include <vlWX/link_config.hpp>
#include <vlGraphics/OpenGLContext.hpp>
#include <vlCore/Time.hpp>
#include <wx/frame.h>
#include <wx/glcanvas.h>
#include <wx/timer.h>
#include <wx/dcclient.h>
#include <wx/image.h>
#include <wx/app.h>
#include <vlWX/link_config.hpp>
#include <vlGraphics/OpenGLContext.hpp>
#include <vlCore/Time.hpp>


#if !wxUSE_GLCANVAS
#error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"
Expand All @@ -52,7 +53,7 @@ namespace vlWX
class VLWX_EXPORT WXGLCanvas: public wxGLCanvas, public vl::OpenGLContext
{
public:
WXGLCanvas(
WXGLCanvas(
wxWindow* parent,
wxWindowID id = wxID_ANY,
const int *attribList = NULL,
Expand Down Expand Up @@ -101,7 +102,6 @@ namespace vlWX

private:
wxCursor mCursor;
int mMouseCount;
wxGLContext* mWXGLContext;
DECLARE_EVENT_TABLE()
};
Expand Down