diff options
Diffstat (limited to 'include/cru/platform/native')
-rw-r--r-- | include/cru/platform/native/basic_types.hpp | 11 | ||||
-rw-r--r-- | include/cru/platform/native/native_window.hpp | 50 | ||||
-rw-r--r-- | include/cru/platform/native/ui_applicaition.hpp | 31 |
3 files changed, 92 insertions, 0 deletions
diff --git a/include/cru/platform/native/basic_types.hpp b/include/cru/platform/native/basic_types.hpp new file mode 100644 index 00000000..573a9e76 --- /dev/null +++ b/include/cru/platform/native/basic_types.hpp @@ -0,0 +1,11 @@ +#pragma once +#include "cru/common/pre_config.hpp" + +namespace cru::platform::native { +struct Dpi { + float x; + float y; +}; + +enum class MouseButton { Left, Right, Middle }; +} // namespace cru::platform diff --git a/include/cru/platform/native/native_window.hpp b/include/cru/platform/native/native_window.hpp new file mode 100644 index 00000000..a82e7a23 --- /dev/null +++ b/include/cru/platform/native/native_window.hpp @@ -0,0 +1,50 @@ +#pragma once +#include "cru/common/base.hpp" + +#include "basic_types.hpp" +#include "cru/common/event.hpp" +#include "cru/common/ui_base.hpp" + +namespace cru::platform::graph { +struct Painter; +} + +namespace cru::platform::native { +struct NativeWindow : public virtual Interface { + // Return if the window is still valid, that is, hasn't been closed or + // destroyed. + virtual bool IsValid() = 0; + virtual void SetDeleteThisOnDestroy(bool value) = 0; + + virtual void Close() = 0; + + virtual NativeWindow* GetParent() = 0; + + virtual bool IsVisible() = 0; + virtual void SetVisible(bool is_visible) = 0; + + virtual ui::Size GetClientSize() = 0; + virtual void SetClientSize(const ui::Size& size) = 0; + + // Get the rect of the window containing frame. + // The lefttop of the rect is relative to screen lefttop. + virtual ui::Rect GetWindowRect() = 0; + + // Set the rect of the window containing frame. + // The lefttop of the rect is relative to screen lefttop. + virtual void SetWindowRect(const ui::Rect& rect) = 0; + + virtual graph::Painter* BeginPaint() = 0; + + virtual Event<>* DestroyEvent() = 0; + virtual Event<const ui::Size&>* ResizeEvent() = 0; + virtual Event<>* PaintEvent() = 0; + virtual Event<bool>* FocusEvent() = 0; + virtual Event<bool>* MouseEnterLeaveEvent() = 0; + virtual Event<const ui::Point&>* MouseMoveEvent() = 0; + virtual Event<MouseButton, const ui::Point&>* MouseDownEvent() = 0; + virtual Event<MouseButton, const ui::Point&>* MouseUpEvent() = 0; + virtual Event<int>* KeyDownEvent() = 0; + virtual Event<int>* KeyUpEvent() = 0; +}; +} // namespace cru::platform::ui diff --git a/include/cru/platform/native/ui_applicaition.hpp b/include/cru/platform/native/ui_applicaition.hpp new file mode 100644 index 00000000..8d42d813 --- /dev/null +++ b/include/cru/platform/native/ui_applicaition.hpp @@ -0,0 +1,31 @@ +#pragma once +#include "cru/common/base.hpp" + +#include <chrono> +#include <functional> +#include <vector> + +namespace cru::platform::graph { +struct GraphFactory; +} + +namespace cru::platform::native { +struct NativeWindow; + +struct UiApplication : public virtual Interface { + static UiApplication* GetInstance(); + + virtual int Run() = 0; + virtual void Quit(int quite_code) = 0; + + virtual void InvokeLater(const std::function<void()>& action) = 0; + virtual unsigned long SetTimeout(std::chrono::milliseconds milliseconds, + const std::function<void()>& action) = 0; + virtual unsigned long SetInterval(std::chrono::milliseconds milliseconds, + const std::function<void()>& action) = 0; + virtual void CancelTimer(unsigned long id) = 0; + + virtual std::vector<NativeWindow*> GetAllWindow() = 0; + virtual NativeWindow* CreateWindow(NativeWindow* parent) = 0; +}; +} // namespace cru::platform::ui |