diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-11-27 17:39:31 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-11-27 17:39:31 +0800 |
| commit | 97ca464fc9e9da4e20e3320559a6f4ac3203fe84 (patch) | |
| tree | fa23dd3d31fd6c86814ef4505ae2f7966b840ed2 /include | |
| parent | 6e8d570e3d63b5bc4e24d258d2dd383530ace2a3 (diff) | |
| download | cru-97ca464fc9e9da4e20e3320559a6f4ac3203fe84.tar.gz cru-97ca464fc9e9da4e20e3320559a6f4ac3203fe84.tar.bz2 cru-97ca464fc9e9da4e20e3320559a6f4ac3203fe84.zip | |
Clean code. Use event define macro of native window on linux.
Diffstat (limited to 'include')
| -rw-r--r-- | include/cru/platform/gui/sdl/UiApplication.h | 3 | ||||
| -rw-r--r-- | include/cru/platform/gui/sdl/Window.h | 34 | ||||
| -rw-r--r-- | include/cru/platform/gui/xcb/Window.h | 32 |
3 files changed, 6 insertions, 63 deletions
diff --git a/include/cru/platform/gui/sdl/UiApplication.h b/include/cru/platform/gui/sdl/UiApplication.h index c300568c..be5ae102 100644 --- a/include/cru/platform/gui/sdl/UiApplication.h +++ b/include/cru/platform/gui/sdl/UiApplication.h @@ -38,6 +38,8 @@ class SdlUiApplication : public SdlResource, public virtual IUiApplication { std::function<void()> action) override; void CancelTimer(long long id) override; + void DeleteLater(Object* object) override; + std::vector<INativeWindow*> GetAllWindow() override; INativeWindow* CreateWindow() override; @@ -64,6 +66,7 @@ class SdlUiApplication : public SdlResource, public virtual IUiApplication { bool release_graphics_factory_; std::uint32_t empty_event_type_; + DeleteLaterPool delete_later_pool_; TimerRegistry<std::function<void()>> timers_; std::atomic_int quit_code_; std::vector<std::function<void()>> quit_handlers_; diff --git a/include/cru/platform/gui/sdl/Window.h b/include/cru/platform/gui/sdl/Window.h index 8ffadd02..78fbaa93 100644 --- a/include/cru/platform/gui/sdl/Window.h +++ b/include/cru/platform/gui/sdl/Window.h @@ -1,11 +1,9 @@ #pragma once -#include <cru/base/Base.h> #include "../../GraphicsBase.h" #include "../Window.h" #include "Base.h" #include <SDL3/SDL_video.h> -#include <cstddef> #include <optional> namespace cru::platform::gui::sdl { @@ -59,21 +57,7 @@ class SdlWindow : public SdlResource, public virtual INativeWindow { std::unique_ptr<graphics::IPainter> BeginPaint() override; - IEvent<std::nullptr_t>* CreateEvent() override; - IEvent<std::nullptr_t>* DestroyEvent() override; - IEvent<std::nullptr_t>* PaintEvent() override; - - IEvent<WindowVisibilityType>* VisibilityChangeEvent() override; - IEvent<const Size&>* ResizeEvent() override; - IEvent<FocusChangeType>* FocusEvent() override; - - IEvent<MouseEnterLeaveType>* MouseEnterLeaveEvent() override; - IEvent<const Point&>* MouseMoveEvent() override; - IEvent<const NativeMouseButtonEventArgs&>* MouseDownEvent() override; - IEvent<const NativeMouseButtonEventArgs&>* MouseUpEvent() override; - IEvent<const NativeMouseWheelEventArgs&>* MouseWheelEvent() override; - IEvent<const NativeKeyEventArgs&>* KeyDownEvent() override; - IEvent<const NativeKeyEventArgs&>* KeyUpEvent() override; + CRU_DEFINE_CRU_PLATFORM_GUI_I_NATIVE_WINDOW_OVERRIDE_EVENTS() IInputMethodContext* GetInputMethodContext() override; @@ -86,19 +70,5 @@ class SdlWindow : public SdlResource, public virtual INativeWindow { std::optional<SDL_Window*> sdl_window_; SdlWindow* parent_; WindowStyleFlag style_; - - Event<std::nullptr_t> create_event_; - Event<std::nullptr_t> destroy_event_; - Event<std::nullptr_t> paint_event_; - Event<WindowVisibilityType> visibility_change_event_; - Event<const Size&> resize_event_; - Event<FocusChangeType> focus_event_; - Event<MouseEnterLeaveType> mouse_enter_leave_event_; - Event<const Point&> mouse_move_event_; - Event<const NativeMouseButtonEventArgs&> mouse_down_event_; - Event<const NativeMouseButtonEventArgs&> mouse_up_event_; - Event<const NativeMouseWheelEventArgs&> mouse_wheel_event_; - Event<const NativeKeyEventArgs&> key_down_event_; - Event<const NativeKeyEventArgs&> key_up_event_; }; -} // namespace cru::platform::gui::xcb +} // namespace cru::platform::gui::sdl diff --git a/include/cru/platform/gui/xcb/Window.h b/include/cru/platform/gui/xcb/Window.h index 293732c5..6820e7a9 100644 --- a/include/cru/platform/gui/xcb/Window.h +++ b/include/cru/platform/gui/xcb/Window.h @@ -7,7 +7,6 @@ #include <cairo.h> #include <xcb/xcb.h> -#include <cstddef> #include <optional> namespace cru::platform::gui::xcb { @@ -63,21 +62,7 @@ class XcbWindow : public XcbResource, public virtual INativeWindow { std::unique_ptr<graphics::IPainter> BeginPaint() override; - IEvent<std::nullptr_t>* CreateEvent() override; - IEvent<std::nullptr_t>* DestroyEvent() override; - IEvent<std::nullptr_t>* PaintEvent() override; - - IEvent<WindowVisibilityType>* VisibilityChangeEvent() override; - IEvent<const Size&>* ResizeEvent() override; - IEvent<FocusChangeType>* FocusEvent() override; - - IEvent<MouseEnterLeaveType>* MouseEnterLeaveEvent() override; - IEvent<const Point&>* MouseMoveEvent() override; - IEvent<const NativeMouseButtonEventArgs&>* MouseDownEvent() override; - IEvent<const NativeMouseButtonEventArgs&>* MouseUpEvent() override; - IEvent<const NativeMouseWheelEventArgs&>* MouseWheelEvent() override; - IEvent<const NativeKeyEventArgs&>* KeyDownEvent() override; - IEvent<const NativeKeyEventArgs&>* KeyUpEvent() override; + CRU_DEFINE_CRU_PLATFORM_GUI_I_NATIVE_WINDOW_OVERRIDE_EVENTS() IInputMethodContext* GetInputMethodContext() override; @@ -121,20 +106,5 @@ class XcbWindow : public XcbResource, public virtual INativeWindow { XcbXimInputMethodContext* input_method_; TimerAutoCanceler repaint_canceler_; - - Event<std::nullptr_t> create_event_; - Event<std::nullptr_t> destroy_event_; - Event<std::nullptr_t> paint_event_; - - Event<WindowVisibilityType> visibility_change_event_; - Event<const Size&> resize_event_; - Event<FocusChangeType> focus_event_; - Event<MouseEnterLeaveType> mouse_enter_leave_event_; - Event<const Point&> mouse_move_event_; - Event<const NativeMouseButtonEventArgs&> mouse_down_event_; - Event<const NativeMouseButtonEventArgs&> mouse_up_event_; - Event<const NativeMouseWheelEventArgs&> mouse_wheel_event_; - Event<const NativeKeyEventArgs&> key_down_event_; - Event<const NativeKeyEventArgs&> key_up_event_; }; } // namespace cru::platform::gui::xcb |
