diff options
author | crupest <crupest@outlook.com> | 2020-10-28 21:28:15 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-10-28 21:28:15 +0800 |
commit | df4df679e157f974773dad7776b204e9d4f3009e (patch) | |
tree | bbc1e939a6e7cf38c2b982ad071e145e3f583caa /include/cru/platform/native | |
parent | 6ce70ed4b08c7db20b6b384be26c7fc4e11c98de (diff) | |
download | cru-df4df679e157f974773dad7776b204e9d4f3009e.tar.gz cru-df4df679e157f974773dad7776b204e9d4f3009e.tar.bz2 cru-df4df679e157f974773dad7776b204e9d4f3009e.zip |
...
Diffstat (limited to 'include/cru/platform/native')
-rw-r--r-- | include/cru/platform/native/Base.hpp | 11 | ||||
-rw-r--r-- | include/cru/platform/native/Cursor.hpp | 1 | ||||
-rw-r--r-- | include/cru/platform/native/InputMethod.hpp | 6 | ||||
-rw-r--r-- | include/cru/platform/native/Keyboard.hpp | 4 | ||||
-rw-r--r-- | include/cru/platform/native/UiApplication.hpp | 6 | ||||
-rw-r--r-- | include/cru/platform/native/Window.hpp | 16 |
6 files changed, 10 insertions, 34 deletions
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 <memory> 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<std::u16string_view>* TextEvent() = 0; }; - -struct IInputMethodManager : virtual INativeResource { - virtual std::unique_ptr<IInputMethodContext> 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 <string_view> #include "cru/common/Bitmask.hpp" +#include <string> +#include <string_view> + 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 <chrono> #include <functional> @@ -45,13 +43,11 @@ struct IUiApplication : public virtual INativeResource { virtual void CancelTimer(long long id) = 0; virtual std::vector<INativeWindow*> GetAllWindow() = 0; - virtual std::shared_ptr<INativeWindowResolver> 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 <string_view> @@ -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<INativeWindowResolver> 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<graph::IPainter> BeginPaint() = 0; + // Don't use this instance after receive this event. virtual IEvent<std::nullptr_t>* DestroyEvent() = 0; virtual IEvent<std::nullptr_t>* PaintEvent() = 0; virtual IEvent<Size>* ResizeEvent() = 0; @@ -57,11 +51,7 @@ struct INativeWindow : virtual INativeResource { virtual IEvent<NativeMouseButtonEventArgs>* MouseUpEvent() = 0; virtual IEvent<NativeKeyEventArgs>* KeyDownEvent() = 0; virtual IEvent<NativeKeyEventArgs>* 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 |