aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/platform')
-rw-r--r--include/cru/platform/graph/graph_factory.hpp6
-rw-r--r--include/cru/platform/native/native_window.hpp4
-rw-r--r--include/cru/platform/native/ui_applicaition.hpp24
3 files changed, 25 insertions, 9 deletions
diff --git a/include/cru/platform/graph/graph_factory.hpp b/include/cru/platform/graph/graph_factory.hpp
index b2619e8d..60d4ed8a 100644
--- a/include/cru/platform/graph/graph_factory.hpp
+++ b/include/cru/platform/graph/graph_factory.hpp
@@ -15,10 +15,14 @@
namespace cru::platform::graph {
// Entry point of the graph module.
+// If you create a IUiApplication instance, then you should not create
+// IGraphFactory manually. IUiApplication will call
+// IGraphFactory::CreateInstance and set auto-delete to true.
+// The manual creation method of IGraphFactory provides a you a way to use graph
+// related tools without interact with actual ui like window system.
struct IGraphFactory : virtual Interface, virtual IAutoDelete {
// Create a platform-specific instance and save it as the global instance.
// Do not create the instance twice. Implements should assert for that.
- // After the
// After creating, get the instance by GetInstance.
static IGraphFactory* CreateInstance();
diff --git a/include/cru/platform/native/native_window.hpp b/include/cru/platform/native/native_window.hpp
index 0e076348..3a0fd3e1 100644
--- a/include/cru/platform/native/native_window.hpp
+++ b/include/cru/platform/native/native_window.hpp
@@ -10,7 +10,7 @@ struct IPainter;
}
namespace cru::platform::native {
-struct NativeWindow : public virtual Interface {
+struct INativeWindow : public virtual Interface {
// Return if the window is still valid, that is, hasn't been closed or
// destroyed.
virtual bool IsValid() = 0;
@@ -18,7 +18,7 @@ struct NativeWindow : public virtual Interface {
virtual void Close() = 0;
- virtual NativeWindow* GetParent() = 0;
+ virtual INativeWindow* GetParent() = 0;
virtual bool IsVisible() = 0;
virtual void SetVisible(bool is_visible) = 0;
diff --git a/include/cru/platform/native/ui_applicaition.hpp b/include/cru/platform/native/ui_applicaition.hpp
index 0188393e..655b8ea0 100644
--- a/include/cru/platform/native/ui_applicaition.hpp
+++ b/include/cru/platform/native/ui_applicaition.hpp
@@ -1,16 +1,28 @@
#pragma once
#include "cru/common/base.hpp"
+#include "cru/common/auto_delete.hpp"
+
#include <chrono>
#include <functional>
#include <vector>
namespace cru::platform::native {
-struct NativeWindow;
+struct INativeWindow;
+
+// The entry point of a ui application.
+// It will call IGraphFactory::CreateInstance during its creation
+// and set graph factory to be auto deleted. If you want to keep
+// the graph factory then you should manually set it to false after
+// creating the ui application.
+struct IUiApplication : virtual Interface, virtual IAutoDelete {
+ // Create a platform-specific instance and save it as the global instance.
+ // Do not create the instance twice. Implements should assert for that.
+ // After creating, get the instance by GetInstance.
+ static IUiApplication* CreateInstance();
-struct UiApplication : public virtual Interface {
- static UiApplication* CreateInstance();
- static UiApplication* GetInstance();
+ // Get the global instance. If it is not created, then return nullptr.
+ static IUiApplication* GetInstance();
virtual int Run() = 0;
virtual void Quit(int quite_code) = 0;
@@ -24,7 +36,7 @@ struct UiApplication : public virtual Interface {
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;
+ virtual std::vector<INativeWindow*> GetAllWindow() = 0;
+ virtual INativeWindow* CreateWindow(INativeWindow* parent) = 0;
};
} // namespace cru::platform::ui