Merge branch 'dev_native' of https://github.com/prusa3d/Slic3r into dev_native

This commit is contained in:
Enrico Turri 2018-10-03 14:08:44 +02:00
commit 46efaf6791
3 changed files with 23 additions and 14 deletions

View File

@ -1,6 +1,7 @@
#ifndef slic3r_Events_hpp_
#define slic3r_Events_hpp_
#include <wx/event.h>
@ -11,11 +12,14 @@ namespace GUI {
struct SimpleEvent : public wxEvent
{
SimpleEvent(wxEventType type, int id = 0) : wxEvent(id, type) {}
SimpleEvent(wxEventType type, wxObject* origin = nullptr) : wxEvent(0, type)
{
SetEventObject(origin);
}
virtual wxEvent* Clone() const
{
return new SimpleEvent(GetEventType(), GetId());
return new SimpleEvent(GetEventType(), GetEventObject());
}
};
@ -23,26 +27,30 @@ template<class T, size_t N> struct ArrayEvent : public wxEvent
{
std::array<T, N> data;
ArrayEvent(wxEventType type, std::array<T, N> data, int id = 0)
: wxEvent(id, type), data(std::move(data))
{}
ArrayEvent(wxEventType type, std::array<T, N> data, wxObject* origin = nullptr)
: wxEvent(0, type), data(std::move(data))
{
SetEventObject(origin);
}
virtual wxEvent* Clone() const
{
return new ArrayEvent<T, N>(GetEventType(), data, GetId());
return new ArrayEvent<T, N>(GetEventType(), data, GetEventObject());
}
};
template<class T> struct ArrayEvent<T, 1> : public wxEvent
{
T data;
ArrayEvent(wxEventType type, T data, int id = 0)
: wxEvent(id, type), data(std::move(data))
{}
ArrayEvent(wxEventType type, T data, wxObject* origin = nullptr)
: wxEvent(0, type), data(std::move(data))
{
SetEventObject(origin);
}
virtual wxEvent* Clone() const
{
return new ArrayEvent<T, 1>(GetEventType(), data, GetId());
return new ArrayEvent<T, 1>(GetEventType(), data, GetEventObject());
}
};

View File

@ -2007,8 +2007,9 @@ GLCanvas3D::~GLCanvas3D()
}
}
void GLCanvas3D::post_event(const wxEvent &event)
void GLCanvas3D::post_event(wxEvent &&event)
{
event.SetEventObject(m_canvas);
wxPostEvent(m_canvas, event);
}

View File

@ -86,8 +86,8 @@ struct ObjectSelectEvent;
wxDECLARE_EVENT(EVT_GLCANVAS_OBJECT_SELECT, ObjectSelectEvent);
struct ObjectSelectEvent : public ArrayEvent<ptrdiff_t, 2>
{
ObjectSelectEvent(ptrdiff_t object_id, ptrdiff_t volume_id, int id = 0)
: ArrayEvent(EVT_GLCANVAS_OBJECT_SELECT, {object_id, volume_id}, id)
ObjectSelectEvent(ptrdiff_t object_id, ptrdiff_t volume_id, wxObject *origin = nullptr)
: ArrayEvent(EVT_GLCANVAS_OBJECT_SELECT, {object_id, volume_id}, origin)
{}
ptrdiff_t object_id() const { return data[0]; }
@ -546,7 +546,7 @@ class GLCanvas3D
GCodePreviewVolumeIndex m_gcode_preview_volume_index;
void post_event(const wxEvent &event);
void post_event(wxEvent &&event);
void viewport_changed();
public:
GLCanvas3D(wxGLCanvas* canvas);