aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform/native/ui_application.hpp
blob: c1f10d15ddafcc2fb25add3e51d763be0b3974be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#include "../resource.hpp"

#include <chrono>
#include <functional>
#include <vector>

namespace cru::platform::graph {
struct IGraphFactory;
}

namespace cru::platform::native {
struct INativeWindow;
struct ICursorManager;

// The entry point of a ui application.
struct IUiApplication : public virtual INativeResource {
 public:
  // 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;

  // 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 InvokeLater(const std::function<void()>& action) = 0;
  virtual unsigned long SetTimeout(std::chrono::milliseconds milliseconds,
                                   const std::function<void()>& action) = 0;
  virtual unsigned long SetInterval(std::chrono::milliseconds milliseconds,
                                    const std::function<void()>& action) = 0;
  virtual void CancelTimer(unsigned long id) = 0;

  virtual std::vector<INativeWindow*> GetAllWindow() = 0;
  virtual INativeWindow* CreateWindow(INativeWindow* parent) = 0;

  virtual cru::platform::graph::IGraphFactory* GetGraphFactory() = 0;

  virtual ICursorManager* GetCursorManager() = 0;
};
}  // namespace cru::platform::native