RADLib
RADical C++ application framework
RADDesktopShell.h
Go to the documentation of this file.
1 #ifndef RADDESKTOPSHELL_H
2 #define RADDESKTOPSHELL_H
3 
9 #pragma once
10 
11 #include <cstdint>
12 #include <string>
13 #include <vector>
14 
15 namespace RADUi {
16 
17  enum class TerminalAppState {
18  Closed = 0,
19  Launching = 1,
20  Running = 2
21  };
22 
23  enum class DesktopWindowState {
24  Closed = 0,
25  Loading = 1,
26  Running = 2
27  };
28 
30  int32_t x = 118;
31  int32_t y = 96;
32  int32_t width = 368;
33  int32_t height = 200;
34  };
35 
37  std::string id;
38  std::string title;
39  };
40 
41  struct DesktopWindow {
42  uint32_t id = 0;
43  std::string appId;
44  std::string title;
47  uint32_t z = 0;
48  bool focused = false;
49  };
50 
52  public:
54 
55  bool applicationsMenuOpen() const;
56  bool terminalOpen() const;
57  bool terminalLaunching() const;
59  std::string statusText() const;
60 
61  const std::vector<DesktopAppDescriptor>& apps() const;
62  const std::vector<DesktopWindow>& windows() const;
63  const DesktopWindow *focusedWindow() const;
64  const DesktopWindow *terminalWindow() const;
65 
66  uint32_t registerApp(const DesktopAppDescriptor& app);
67  uint32_t launchApp(const std::string& appId);
68  bool focusWindow(uint32_t windowId);
69  bool closeWindow(uint32_t windowId);
70  bool moveWindow(uint32_t windowId, int32_t dx, int32_t dy);
71  bool resizeWindow(uint32_t windowId, int32_t dx, int32_t dy);
72  bool setWindowState(uint32_t windowId, DesktopWindowState state);
73 
76  void terminalReady();
78  bool handleEscape();
79 
80  private:
81  DesktopWindow *findWindow(uint32_t windowId);
82  const DesktopWindow *findWindow(uint32_t windowId) const;
83  DesktopWindow *findWindowByApp(const std::string& appId);
84  const DesktopWindow *findWindowByApp(const std::string& appId) const;
85  const DesktopAppDescriptor *findApp(const std::string& appId) const;
86  void focusWindowRecord(DesktopWindow& window);
87 
88  bool applicationsMenuOpen_ = false;
89  std::vector<DesktopAppDescriptor> apps_;
90  std::vector<DesktopWindow> windows_;
91  uint32_t nextWindowId_ = 1;
92  uint32_t nextZ_ = 1;
93  };
94 
95 } // namespace RADUi
96 
97 #endif
Definition: RADDesktopShell.h:51
bool terminalLaunching() const
uint32_t launchApp(const std::string &appId)
const DesktopWindow * focusedWindow() const
std::string statusText() const
bool closeWindow(uint32_t windowId)
TerminalAppState terminalState() const
const DesktopWindow * terminalWindow() const
uint32_t registerApp(const DesktopAppDescriptor &app)
const std::vector< DesktopWindow > & windows() const
bool focusWindow(uint32_t windowId)
bool applicationsMenuOpen() const
const std::vector< DesktopAppDescriptor > & apps() const
bool moveWindow(uint32_t windowId, int32_t dx, int32_t dy)
bool resizeWindow(uint32_t windowId, int32_t dx, int32_t dy)
bool setWindowState(uint32_t windowId, DesktopWindowState state)
Definition: RADAppKit.h:20
DesktopWindowState
Definition: RADDesktopShell.h:23
TerminalAppState
Definition: RADDesktopShell.h:17
Definition: RADDesktopShell.h:36
std::string id
Definition: RADDesktopShell.h:37
std::string title
Definition: RADDesktopShell.h:38
Definition: RADDesktopShell.h:29
int32_t x
Definition: RADDesktopShell.h:30
int32_t y
Definition: RADDesktopShell.h:31
int32_t width
Definition: RADDesktopShell.h:32
int32_t height
Definition: RADDesktopShell.h:33
Definition: RADDesktopShell.h:41
std::string appId
Definition: RADDesktopShell.h:43
uint32_t z
Definition: RADDesktopShell.h:47
std::string title
Definition: RADDesktopShell.h:44
DesktopWindowBounds bounds
Definition: RADDesktopShell.h:45
bool focused
Definition: RADDesktopShell.h:48
DesktopWindowState state
Definition: RADDesktopShell.h:46