Debian Codegraph @

plugins/dm.gui/gui/Gui.h

raw
1 #pragma once
2
3 #include "igui.h"
4
5 #include <map>
6 #include <unordered_map>
7 #include <memory>
8 #include "parser/DefTokeniser.h"
9 #include "GuiWindowDef.h"
10
11 namespace gui
12 {
13
14 class Gui;
15 typedef std::shared_ptr<Gui> GuiPtr;
16
17 class GuiWindowDef;
18 typedef std::shared_ptr<GuiWindowDef> GuiWindowDefPtr;
19
20 /**
21 * greebo: This class represents a single D3 GUI. It holds all
22 * the windowDefs and the source code behind.
23 */
24 class Gui :
25 public IGui
26 {
27 private:
28 // The desktop window
29 IGuiWindowDefPtr _desktop;
30
31 // The global GUI state variables
32 typedef std::unordered_map<std::string, std::string> GuiState;
33 GuiState _state;
34
35 typedef std::unordered_map<std::string, sigc::signal<void>> GuiStateChangedSignals;
36 GuiStateChangedSignals _stateSignals;
37
38 public:
39 const IGuiWindowDefPtr& getDesktop() const override;
40 void setDesktop(const IGuiWindowDefPtr& newDesktop) override;
41
42 // Sets the given state variable (gui::<key> = <value>)
43 void setStateString(const std::string& key, const std::string& value) override;
44
45 // Allocate and/or return the changed signal for the given key
46 sigc::signal<void>& getChangedSignalForState(const std::string& key) override;
47
48 // Returns the state string "gui::<key>" or an empty string if non-existent
49 std::string getStateString(const std::string& key) override;
50
51 // Sets up the time of the entire GUI (all windowDefs)
52 void initTime(const std::size_t time) override;
53
54 // "Think" routine, advances all active windowDefs (where notime == false)
55 void update(const std::size_t timestep) override;
56
57 // Returns a reference to the named windowDef, returns NULL if not found
58 IGuiWindowDefPtr findWindowDef(const std::string& name) override;
59
60 // Called by the GuiRenderer to re-compile text VBOs, etc.
61 void pepareRendering() override;
62
63 // Takes the given token stream and attempts to construct a GUI object from it
64 // Returns NULL on failure
65 static GuiPtr createFromTokens(parser::DefTokeniser& tokeniser);
66 };
67
68 } // namespace