From df4df679e157f974773dad7776b204e9d4f3009e Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 28 Oct 2020 21:28:15 +0800 Subject: ... --- include/cru/platform/native/Base.hpp | 11 +++-------- include/cru/platform/native/Cursor.hpp | 1 - include/cru/platform/native/InputMethod.hpp | 6 ------ include/cru/platform/native/Keyboard.hpp | 4 +++- include/cru/platform/native/UiApplication.hpp | 6 +----- include/cru/platform/native/Window.hpp | 16 +++------------- 6 files changed, 10 insertions(+), 34 deletions(-) (limited to 'include/cru/platform/native') diff --git a/include/cru/platform/native/Base.hpp b/include/cru/platform/native/Base.hpp index bba7b960..c3e87439 100644 --- a/include/cru/platform/native/Base.hpp +++ b/include/cru/platform/native/Base.hpp @@ -1,23 +1,18 @@ #pragma once +#include "Keyboard.hpp" #include "cru/common/Base.hpp" #include "cru/common/Bitmask.hpp" #include "cru/platform/graph/Base.hpp" -#include "Keyboard.hpp" + +#include "../Resource.hpp" namespace cru::platform::native { struct ICursor; struct ICursorManager; struct IUiApplication; struct INativeWindow; -struct INativeWindowResolver; -struct IInputMethodManager; struct IInputMethodContext; -struct Dpi { - float x; - float y; -}; - namespace details { struct TagMouseButton {}; } // namespace details diff --git a/include/cru/platform/native/Cursor.hpp b/include/cru/platform/native/Cursor.hpp index 6c8f8068..447cd694 100644 --- a/include/cru/platform/native/Cursor.hpp +++ b/include/cru/platform/native/Cursor.hpp @@ -1,5 +1,4 @@ #pragma once -#include "../Resource.hpp" #include "Base.hpp" #include diff --git a/include/cru/platform/native/InputMethod.hpp b/include/cru/platform/native/InputMethod.hpp index 6f222a43..de752417 100644 --- a/include/cru/platform/native/InputMethod.hpp +++ b/include/cru/platform/native/InputMethod.hpp @@ -1,5 +1,4 @@ #pragma once -#include "../Resource.hpp" #include "Base.hpp" #include "cru/common/Event.hpp" @@ -52,11 +51,6 @@ struct IInputMethodContext : virtual INativeResource { virtual IEvent* TextEvent() = 0; }; - -struct IInputMethodManager : virtual INativeResource { - virtual std::unique_ptr GetContext( - INativeWindow* window) = 0; -}; } // namespace cru::platform::native template <> diff --git a/include/cru/platform/native/Keyboard.hpp b/include/cru/platform/native/Keyboard.hpp index 8f53c5d6..67a35c8a 100644 --- a/include/cru/platform/native/Keyboard.hpp +++ b/include/cru/platform/native/Keyboard.hpp @@ -1,7 +1,9 @@ #pragma once -#include #include "cru/common/Bitmask.hpp" +#include +#include + namespace cru::platform::native { // Because of the complexity of keyboard layout, I only add code in US keyboard // layout, the most widely used layout in China. We should try to make it easy diff --git a/include/cru/platform/native/UiApplication.hpp b/include/cru/platform/native/UiApplication.hpp index 4c1b3456..2b1b047a 100644 --- a/include/cru/platform/native/UiApplication.hpp +++ b/include/cru/platform/native/UiApplication.hpp @@ -1,7 +1,5 @@ #pragma once -#include "../Resource.hpp" #include "Base.hpp" -#include "cru/common/Base.hpp" #include #include @@ -45,13 +43,11 @@ struct IUiApplication : public virtual INativeResource { virtual void CancelTimer(long long id) = 0; virtual std::vector GetAllWindow() = 0; - virtual std::shared_ptr CreateWindow( - INativeWindow* parent) = 0; + virtual INativeWindow* CreateWindow(INativeWindow* parent) = 0; virtual cru::platform::graph::IGraphFactory* GetGraphFactory() = 0; virtual ICursorManager* GetCursorManager() = 0; - virtual IInputMethodManager* GetInputMethodManager() = 0; }; class TimerAutoCanceler { diff --git a/include/cru/platform/native/Window.hpp b/include/cru/platform/native/Window.hpp index 1fcac1fc..c8abdeac 100644 --- a/include/cru/platform/native/Window.hpp +++ b/include/cru/platform/native/Window.hpp @@ -1,6 +1,6 @@ #pragma once -#include "../Resource.hpp" #include "Base.hpp" + #include "cru/common/Event.hpp" #include @@ -8,14 +8,7 @@ namespace cru::platform::native { // Represents a native window, which exposes some low-level events and // operations. -// -// Usually you save an INativeWindowResolver after creating a window. Because -// window may be destroyed when user do certain actions like click the close -// button. Then the INativeWindow instance is destroyed and -// INativeWindowResolver::Resolve return nullptr to indicate the fact. struct INativeWindow : virtual INativeResource { - virtual std::shared_ptr GetResolver() = 0; - virtual void Close() = 0; virtual INativeWindow* GetParent() = 0; @@ -47,6 +40,7 @@ struct INativeWindow : virtual INativeResource { // Remember to call EndDraw on return value and destroy it. virtual std::unique_ptr BeginPaint() = 0; + // Don't use this instance after receive this event. virtual IEvent* DestroyEvent() = 0; virtual IEvent* PaintEvent() = 0; virtual IEvent* ResizeEvent() = 0; @@ -57,11 +51,7 @@ struct INativeWindow : virtual INativeResource { virtual IEvent* MouseUpEvent() = 0; virtual IEvent* KeyDownEvent() = 0; virtual IEvent* KeyUpEvent() = 0; -}; -// See INativeWindow for more info. -struct INativeWindowResolver : virtual INativeResource { - // Think twice before you save the return value. - virtual INativeWindow* Resolve() = 0; + virtual IInputMethodContext* GetInputMethodContext() = 0; }; } // namespace cru::platform::native -- cgit v1.2.3