From f6c50e29d98c722789d53455e1af4b891a01d43f Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 27 Jun 2025 03:10:07 +0800 Subject: [PATCH] =?UTF-8?q?InputEvent=E6=94=B9=E5=90=8D=E4=B8=BAEventDispa?= =?UTF-8?q?tch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/io/event/EventDispatch.h | 24 ++++++++++++------------ inc/hgl/io/event/KeyboardEvent.h | 6 +++--- inc/hgl/io/event/MouseEvent.h | 6 +++--- inc/hgl/io/event/WindowEvent.h | 8 ++++---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/inc/hgl/io/event/EventDispatch.h b/inc/hgl/io/event/EventDispatch.h index df73bbc..519d34d 100644 --- a/inc/hgl/io/event/EventDispatch.h +++ b/inc/hgl/io/event/EventDispatch.h @@ -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 event_dispatch_subscribers; + SortedSet 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 diff --git a/inc/hgl/io/event/KeyboardEvent.h b/inc/hgl/io/event/KeyboardEvent.h index a68fbd2..21bc20f 100644 --- a/inc/hgl/io/event/KeyboardEvent.h +++ b/inc/hgl/io/event/KeyboardEvent.h @@ -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; diff --git a/inc/hgl/io/event/MouseEvent.h b/inc/hgl/io/event/MouseEvent.h index 463cd5e..5853cee 100644 --- a/inc/hgl/io/event/MouseEvent.h +++ b/inc/hgl/io/event/MouseEvent.h @@ -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; diff --git a/inc/hgl/io/event/WindowEvent.h b/inc/hgl/io/event/WindowEvent.h index 356ba33..702033a 100644 --- a/inc/hgl/io/event/WindowEvent.h +++ b/inc/hgl/io/event/WindowEvent.h @@ -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