diff options
author | crupest <crupest@outlook.com> | 2020-03-18 21:16:25 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-03-18 21:16:25 +0800 |
commit | b129c5a144dfb116082689ffaaa9ac78e2403656 (patch) | |
tree | 08c3540569260c4231996f769040beb3737e5b4b /include | |
parent | abf604f8c6ec89c8d7df7062fe10fd17c60d5719 (diff) | |
download | cru-b129c5a144dfb116082689ffaaa9ac78e2403656.tar.gz cru-b129c5a144dfb116082689ffaaa9ac78e2403656.tar.bz2 cru-b129c5a144dfb116082689ffaaa9ac78e2403656.zip |
...
Diffstat (limited to 'include')
-rw-r--r-- | include/cru/platform/graph/base.hpp | 12 | ||||
-rw-r--r-- | include/cru/platform/graph/factory.hpp | 4 | ||||
-rw-r--r-- | include/cru/platform/graph/fwd.hpp | 12 | ||||
-rw-r--r-- | include/cru/platform/graph/geometry.hpp | 2 | ||||
-rw-r--r-- | include/cru/platform/graph/painter.hpp | 5 | ||||
-rw-r--r-- | include/cru/platform/graph/text_layout.hpp | 9 | ||||
-rw-r--r-- | include/cru/platform/native/ui_application.hpp | 15 | ||||
-rw-r--r-- | include/cru/ui/render/border_render_object.hpp | 5 | ||||
-rw-r--r-- | include/cru/ui/render/render_object.hpp | 5 | ||||
-rw-r--r-- | include/cru/ui/render/text_render_object.hpp | 8 | ||||
-rw-r--r-- | include/cru/win/native/ui_application.hpp | 11 |
11 files changed, 43 insertions, 45 deletions
diff --git a/include/cru/platform/graph/base.hpp b/include/cru/platform/graph/base.hpp index 8c2a2d2f..0b011262 100644 --- a/include/cru/platform/graph/base.hpp +++ b/include/cru/platform/graph/base.hpp @@ -2,3 +2,15 @@ #include "../graph_base.hpp" #include "../matrix.hpp" #include "../resource.hpp" + +#include "fwd.hpp" + +#include <memory> + +namespace cru::platform::graph { +struct TextHitTestResult { + int position; + bool trailing; + bool insideText; +}; +} // namespace cru::platform::graph diff --git a/include/cru/platform/graph/factory.hpp b/include/cru/platform/graph/factory.hpp index 2c52cbb8..0ed45161 100644 --- a/include/cru/platform/graph/factory.hpp +++ b/include/cru/platform/graph/factory.hpp @@ -1,15 +1,13 @@ #pragma once -#include "base.hpp" +#include "resource.hpp" #include "brush.hpp" #include "font.hpp" #include "geometry.hpp" #include "text_layout.hpp" -#include <memory> #include <string> #include <string_view> -#include <utility> namespace cru::platform::graph { // Entry point of the graph module. diff --git a/include/cru/platform/graph/fwd.hpp b/include/cru/platform/graph/fwd.hpp new file mode 100644 index 00000000..508a49fa --- /dev/null +++ b/include/cru/platform/graph/fwd.hpp @@ -0,0 +1,12 @@ +#pragma once + +namespace cru::platform::graph { +struct IGraphFactory; +struct IBrush; +struct ISolidColorBrush; +struct IFont; +struct IGeometry; +struct IGeometryBuilder; +struct IPainter; +struct ITextLayout; +} // namespace cru::platform::graph diff --git a/include/cru/platform/graph/geometry.hpp b/include/cru/platform/graph/geometry.hpp index a49453dd..85ffd3f6 100644 --- a/include/cru/platform/graph/geometry.hpp +++ b/include/cru/platform/graph/geometry.hpp @@ -1,8 +1,6 @@ #pragma once #include "resource.hpp" -#include <memory> - namespace cru::platform::graph { struct IGeometry : virtual IGraphResource { virtual bool FillContains(const Point& point) = 0; diff --git a/include/cru/platform/graph/painter.hpp b/include/cru/platform/graph/painter.hpp index 3ae9cf1c..1f4ab7cb 100644 --- a/include/cru/platform/graph/painter.hpp +++ b/include/cru/platform/graph/painter.hpp @@ -1,10 +1,7 @@ #pragma once -#include "base.hpp" +#include "resource.hpp" namespace cru::platform::graph { -struct IBrush; -struct IGeometry; -struct ITextLayout; struct IPainter : virtual INativeResource { virtual Matrix GetTransform() = 0; diff --git a/include/cru/platform/graph/text_layout.hpp b/include/cru/platform/graph/text_layout.hpp index d1cfb44b..20009c0d 100644 --- a/include/cru/platform/graph/text_layout.hpp +++ b/include/cru/platform/graph/text_layout.hpp @@ -1,19 +1,10 @@ #pragma once #include "resource.hpp" -#include <memory> #include <string> #include <vector> namespace cru::platform::graph { -struct IFont; - -struct TextHitTestResult { - int position; - bool trailing; - bool insideText; -}; - struct ITextLayout : virtual IGraphResource { virtual std::string GetText() = 0; virtual void SetText(std::string new_text) = 0; diff --git a/include/cru/platform/native/ui_application.hpp b/include/cru/platform/native/ui_application.hpp index edbcc578..e02904bb 100644 --- a/include/cru/platform/native/ui_application.hpp +++ b/include/cru/platform/native/ui_application.hpp @@ -20,10 +20,15 @@ struct IUiApplication : public virtual INativeResource { public: static IUiApplication* GetInstance() { return instance; } - protected: + private: static IUiApplication* instance; + protected: + IUiApplication(); + public: + ~IUiApplication() override; + // Block current thread and run the message loop. Return the exit code when // message loop gets a quit message (possibly posted by method RequestQuit). virtual int Run() = 0; @@ -31,13 +36,13 @@ struct IUiApplication : public virtual INativeResource { // Post a quit message with given quit code. virtual void RequestQuit(int quit_code) = 0; - virtual void AddOnQuitHandler(const std::function<void()>& handler) = 0; + virtual void AddOnQuitHandler(std::function<void()> handler) = 0; - virtual void InvokeLater(const std::function<void()>& action) = 0; + virtual void InvokeLater(std::function<void()> action) = 0; virtual unsigned long SetTimeout(std::chrono::milliseconds milliseconds, - const std::function<void()>& action) = 0; + std::function<void()> action) = 0; virtual unsigned long SetInterval(std::chrono::milliseconds milliseconds, - const std::function<void()>& action) = 0; + std::function<void()> action) = 0; virtual void CancelTimer(unsigned long id) = 0; virtual std::vector<INativeWindow*> GetAllWindow() = 0; diff --git a/include/cru/ui/render/border_render_object.hpp b/include/cru/ui/render/border_render_object.hpp index 726510a8..b9af71c0 100644 --- a/include/cru/ui/render/border_render_object.hpp +++ b/include/cru/ui/render/border_render_object.hpp @@ -3,11 +3,6 @@ #include <memory> -namespace cru::platform::graph { -struct IBrush; -struct IGeometry; -} // namespace cru::platform::graph - namespace cru::ui::render { struct CornerRadius { constexpr CornerRadius() diff --git a/include/cru/ui/render/render_object.hpp b/include/cru/ui/render/render_object.hpp index d9851757..8db1a20f 100644 --- a/include/cru/ui/render/render_object.hpp +++ b/include/cru/ui/render/render_object.hpp @@ -2,6 +2,7 @@ #include "../base.hpp" #include "cru/common/event.hpp" +#include "cru/platform/graph/base.hpp" #include <vector> @@ -10,10 +11,6 @@ namespace cru::ui { class Control; } -namespace cru::platform::graph { -struct IPainter; -} - namespace cru::ui::render { struct AfterLayoutEventArgs {}; diff --git a/include/cru/ui/render/text_render_object.hpp b/include/cru/ui/render/text_render_object.hpp index 33d34f78..62313cd3 100644 --- a/include/cru/ui/render/text_render_object.hpp +++ b/include/cru/ui/render/text_render_object.hpp @@ -1,17 +1,9 @@ #pragma once #include "render_object.hpp" -#include "cru/platform/graph/text_layout.hpp" - #include <memory> #include <string> -// forward declarations -namespace cru::platform::graph { -struct IBrush; -struct IFont; -} // namespace cru::platform::graph - namespace cru::ui::render { class TextRenderObject : public RenderObject { public: diff --git a/include/cru/win/native/ui_application.hpp b/include/cru/win/native/ui_application.hpp index 73f67abe..8de9d1b5 100644 --- a/include/cru/win/native/ui_application.hpp +++ b/include/cru/win/native/ui_application.hpp @@ -35,17 +35,18 @@ class WinUiApplication : public WinNativeResource, int Run() override; void RequestQuit(int quit_code) override; - void AddOnQuitHandler(const std::function<void()>& handler) override; + void AddOnQuitHandler(std::function<void()> handler) override; - void InvokeLater(const std::function<void()>& action) override; + void InvokeLater(std::function<void()> action) override; unsigned long SetTimeout(std::chrono::milliseconds milliseconds, - const std::function<void()>& action) override; + std::function<void()> action) override; unsigned long SetInterval(std::chrono::milliseconds milliseconds, - const std::function<void()>& action) override; + std::function<void()> action) override; void CancelTimer(unsigned long id) override; std::vector<INativeWindow*> GetAllWindow() override; - std::shared_ptr<INativeWindowResolver> CreateWindow(INativeWindow* parent) override; + std::shared_ptr<INativeWindowResolver> CreateWindow( + INativeWindow* parent) override; cru::platform::graph::IGraphFactory* GetGraphFactory() override; |