PrusaSlicer-NonPlainar/src/slic3r/GUI/Event.hpp
bubnikv b3b800de65 Refactoring of RemovableDriveManager:
1) On Windows and Linux, the device enumeration now runs at a background
   thread, while it ran on the UI thread on idle, which may have been
   blocking on some rare Windows setups, see GH #3515 #3733 #3746 #3766
2) On OSX, the device enumeration now relies on OS callback, no
   polling is required.
3) Refactored for cleaner interface.
2020-03-06 15:10:58 +01:00

72 lines
1.5 KiB
C++

#ifndef slic3r_Events_hpp_
#define slic3r_Events_hpp_
#include <array>
#include <wx/event.h>
namespace Slic3r {
namespace GUI {
struct SimpleEvent : public wxEvent
{
SimpleEvent(wxEventType type, wxObject* origin = nullptr) : wxEvent(0, type)
{
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
SetEventObject(origin);
}
virtual wxEvent* Clone() const
{
return new SimpleEvent(GetEventType(), GetEventObject());
}
};
template<class T, size_t N> struct ArrayEvent : public wxEvent
{
std::array<T, N> data;
ArrayEvent(wxEventType type, std::array<T, N> data, wxObject* origin = nullptr)
: wxEvent(0, type), data(std::move(data))
{
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
SetEventObject(origin);
}
virtual wxEvent* Clone() const
{
return new ArrayEvent<T, N>(GetEventType(), data, GetEventObject());
}
};
template<class T> struct Event : public wxEvent
{
T data;
Event(wxEventType type, const T &data, wxObject* origin = nullptr)
: wxEvent(0, type), data(std::move(data))
{
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
SetEventObject(origin);
}
Event(wxEventType type, T&& data, wxObject* origin = nullptr)
: wxEvent(0, type), data(std::move(data))
{
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
SetEventObject(origin);
}
virtual wxEvent* Clone() const
{
return new Event<T>(GetEventType(), data, GetEventObject());
}
};
}
}
#endif // slic3r_Events_hpp_