InputEvent改名为EventDispatch
This commit is contained in:
@@ -23,19 +23,19 @@ namespace hgl::io
|
||||
Break,
|
||||
};
|
||||
|
||||
class InputEvent
|
||||
class EventDispatch
|
||||
{
|
||||
protected:
|
||||
|
||||
InputEventSource source_type;
|
||||
InputEventSource source_type;
|
||||
|
||||
InputEvent * parent_input_event;
|
||||
EventDispatch * parent_input_event;
|
||||
|
||||
SortedSet<InputEvent *> event_dispatch_subscribers;
|
||||
SortedSet<EventDispatch *> event_dispatch_subscribers;
|
||||
|
||||
protected:
|
||||
|
||||
void SetParent(InputEvent *ie){parent_input_event=ie;}
|
||||
void SetParent(EventDispatch *ie){parent_input_event=ie;}
|
||||
|
||||
public:
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace hgl::io
|
||||
|
||||
if(!event_dispatch_subscribers.IsEmpty())
|
||||
{
|
||||
for(InputEvent *ie:event_dispatch_subscribers)
|
||||
for(EventDispatch *ie:event_dispatch_subscribers)
|
||||
if(ie->OnEvent(header,data)==EventProcResult::Break)
|
||||
return EventProcResult::Break;
|
||||
}
|
||||
@@ -58,25 +58,25 @@ namespace hgl::io
|
||||
|
||||
public:
|
||||
|
||||
InputEvent()
|
||||
EventDispatch()
|
||||
{
|
||||
source_type=InputEventSource::Root;
|
||||
parent_input_event=nullptr;
|
||||
}
|
||||
|
||||
InputEvent(InputEventSource ies)
|
||||
EventDispatch(InputEventSource ies)
|
||||
{
|
||||
source_type=ies;
|
||||
parent_input_event=nullptr;
|
||||
}
|
||||
|
||||
virtual ~InputEvent()
|
||||
virtual ~EventDispatch()
|
||||
{
|
||||
if(parent_input_event)
|
||||
parent_input_event->UnregistryEventDispatch(this);
|
||||
}
|
||||
|
||||
virtual bool RegistryEventDispatch(InputEvent *ie)
|
||||
virtual bool RegistryEventDispatch(EventDispatch *ie)
|
||||
{
|
||||
if(!ie)
|
||||
return(false);
|
||||
@@ -91,7 +91,7 @@ namespace hgl::io
|
||||
return(event_dispatch_subscribers.Add(ie)!=-1);
|
||||
}
|
||||
|
||||
bool UnregistryEventDispatch(InputEvent *ie)
|
||||
bool UnregistryEventDispatch(EventDispatch *ie)
|
||||
{
|
||||
if(!ie)return(false);
|
||||
|
||||
@@ -106,5 +106,5 @@ namespace hgl::io
|
||||
}
|
||||
|
||||
virtual bool Update(){return true;}
|
||||
};//class InputEvent
|
||||
};//class EventDispatch
|
||||
}//namespace hgl::io
|
||||
|
@@ -158,11 +158,11 @@ namespace hgl
|
||||
os_char ch;
|
||||
};
|
||||
|
||||
class KeyboardEvent:public InputEvent
|
||||
class KeyboardEvent:public EventDispatch
|
||||
{
|
||||
public:
|
||||
|
||||
KeyboardEvent():InputEvent(InputEventSource::Keyboard){}
|
||||
KeyboardEvent():EventDispatch(InputEventSource::Keyboard){}
|
||||
virtual ~KeyboardEvent()=default;
|
||||
|
||||
EventProcResult OnEvent(const EventHeader &header,const uint64 data) override
|
||||
@@ -177,7 +177,7 @@ namespace hgl
|
||||
}
|
||||
}
|
||||
|
||||
if(InputEvent::OnEvent(header,data)==EventProcResult::Break)
|
||||
if(EventDispatch::OnEvent(header,data)==EventProcResult::Break)
|
||||
return EventProcResult::Break;
|
||||
|
||||
return EventProcResult::Continue;
|
||||
|
@@ -42,7 +42,7 @@ namespace hgl::io
|
||||
|
||||
constexpr size_t MouseEventDataBytes=sizeof(MouseEventData);
|
||||
|
||||
class MouseEvent:public InputEvent
|
||||
class MouseEvent:public EventDispatch
|
||||
{
|
||||
MouseEventData *med;
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace hgl::io
|
||||
|
||||
public:
|
||||
|
||||
MouseEvent():InputEvent(InputEventSource::Mouse)
|
||||
MouseEvent():EventDispatch(InputEventSource::Mouse)
|
||||
{
|
||||
med=nullptr;
|
||||
position.x=0;
|
||||
@@ -88,7 +88,7 @@ namespace hgl::io
|
||||
}
|
||||
}
|
||||
|
||||
if(InputEvent::OnEvent(header,data)==EventProcResult::Break)
|
||||
if(EventDispatch::OnEvent(header,data)==EventProcResult::Break)
|
||||
return EventProcResult::Break;
|
||||
|
||||
return EventProcResult::Continue;
|
||||
|
@@ -27,13 +27,13 @@ namespace hgl
|
||||
|
||||
constexpr size_t WindowEventDataBytes=sizeof(WindowEventData);
|
||||
|
||||
class WindowEvent:public InputEvent
|
||||
class WindowEvent:public EventDispatch
|
||||
{
|
||||
WindowEventData *wed;
|
||||
|
||||
public:
|
||||
|
||||
WindowEvent():InputEvent(InputEventSource::Window){wed=nullptr;}
|
||||
WindowEvent():EventDispatch(InputEventSource::Window){wed=nullptr;}
|
||||
virtual ~WindowEvent()=default;
|
||||
|
||||
virtual EventProcResult OnEvent(const EventHeader &header,const uint64 data) override
|
||||
@@ -50,7 +50,7 @@ namespace hgl
|
||||
}
|
||||
}
|
||||
|
||||
if(InputEvent::OnEvent(header,data)==EventProcResult::Break)
|
||||
if(EventDispatch::OnEvent(header,data)==EventProcResult::Break)
|
||||
return EventProcResult::Break;
|
||||
|
||||
return EventProcResult::Continue;
|
||||
@@ -61,7 +61,7 @@ namespace hgl
|
||||
virtual void OnResize(uint w,uint h){}
|
||||
virtual void OnActive(bool){}
|
||||
virtual void OnClose (){}
|
||||
};//class WindowEvent:public InputEvent
|
||||
};//class WindowEvent:public EventDispatch
|
||||
}//namespace io
|
||||
}//namespace hgl
|
||||
#endif//HGL_IO_WINDOW_EVENT_INCLUDE
|
||||
|
Reference in New Issue
Block a user