added files of io/event
This commit is contained in:
64
inc/hgl/io/event/WindowEvent.h
Normal file
64
inc/hgl/io/event/WindowEvent.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef HGL_IO_WINDOW_EVENT_INCLUDE
|
||||
#define HGL_IO_WINDOW_EVENT_INCLUDE
|
||||
|
||||
#include<hgl/io/event/InputEvent.h>
|
||||
namespace hgl
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
enum class WindowEventID
|
||||
{
|
||||
Active,
|
||||
Resize,
|
||||
Close
|
||||
};//enum class WindowEventID
|
||||
|
||||
union WindowEventData
|
||||
{
|
||||
uint64 data;
|
||||
|
||||
struct
|
||||
{
|
||||
int16 width,height;
|
||||
};
|
||||
|
||||
bool active;
|
||||
};
|
||||
|
||||
constexpr size_t WindowEventDataBytes=sizeof(WindowEventData);
|
||||
|
||||
class WindowEvent:public InputEvent
|
||||
{
|
||||
WindowEventData *wed;
|
||||
|
||||
public:
|
||||
|
||||
WindowEvent():InputEvent(InputEventSource::Window){}
|
||||
virtual ~WindowEvent()=default;
|
||||
|
||||
EventProcResult OnEvent(const EventHeader &header,const uint64 data) override
|
||||
{
|
||||
wed=(WindowEventData *)&data;
|
||||
|
||||
switch(WindowEventID(header.id))
|
||||
{
|
||||
case WindowEventID::Active:OnActive (wed->active) ;break;
|
||||
case WindowEventID::Resize:OnResize (wed->width,wed->height);break;
|
||||
case WindowEventID::Close: OnClose () ;break;
|
||||
}
|
||||
|
||||
if(InputEvent::OnEvent(header,data)==EventProcResult::Break)
|
||||
return EventProcResult::Break;
|
||||
|
||||
return EventProcResult::Continue;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void OnResize(uint,uint){}
|
||||
virtual void OnActive(bool){}
|
||||
virtual void OnClose (){}
|
||||
};//class WindowEvent:public InputEvent
|
||||
}//namespace io
|
||||
}//namespace hgl
|
||||
#endif//HGL_IO_WINDOW_EVENT_INCLUDE
|
Reference in New Issue
Block a user