aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-03-18 21:16:25 +0800
committercrupest <crupest@outlook.com>2020-03-18 21:16:25 +0800
commitb129c5a144dfb116082689ffaaa9ac78e2403656 (patch)
tree08c3540569260c4231996f769040beb3737e5b4b /include/cru/platform
parentabf604f8c6ec89c8d7df7062fe10fd17c60d5719 (diff)
downloadcru-b129c5a144dfb116082689ffaaa9ac78e2403656.tar.gz
cru-b129c5a144dfb116082689ffaaa9ac78e2403656.tar.bz2
cru-b129c5a144dfb116082689ffaaa9ac78e2403656.zip
...
Diffstat (limited to 'include/cru/platform')
-rw-r--r--include/cru/platform/graph/base.hpp12
-rw-r--r--include/cru/platform/graph/factory.hpp4
-rw-r--r--include/cru/platform/graph/fwd.hpp12
-rw-r--r--include/cru/platform/graph/geometry.hpp2
-rw-r--r--include/cru/platform/graph/painter.hpp5
-rw-r--r--include/cru/platform/graph/text_layout.hpp9
-rw-r--r--include/cru/platform/native/ui_application.hpp15
7 files changed, 36 insertions, 23 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;