ViewManager.h
1 /*
2 
3 Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu)
4 All rights reserved.
5 
6 This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe)
7 Dynacoe was released under the MIT License, as detailed below.
8 
9 
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is furnished
16 to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall
19 be included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 
29 
30 
31 */
32 
33 
34 
35 #ifndef DYNACOEVIEWMANAGER_H_INCLUDED
36 #define DYNACOEVIEWMANAGER_H_INCLUDED
37 
38 
39 #include <Dynacoe/Util/Table.h>
40 #include <Dynacoe/Modules/Module.h>
41 #include <Dynacoe/Backends/Display/Display.h>
42 #include <string>
43 #include <vector>
44 #include <map>
45 
46 
47 
48 
49 
50 namespace Dynacoe {
51 
52 using ViewID = LookupID;
53 
54 class Graphics;
55 class Color;
56 
57 
58 
59 
60 
61 
66  // name change: ViewManager
67 class ViewManager : public Module {
68 public:
69  friend class Engine;
70  /* Display management */
71 
72 
73 
77  static ViewID New(const std::string & name, int w, int h);
78 
79 
83  static void NewMain(const std::string & name = "", int w = 640, int h = 480);
84 
85 
91  static void Destroy(ViewID);
92 
95  static Display * Get(ViewID);
96 
97 
100  static void SetMain(ViewID);
101 
102 
105  static ViewID GetCurrent();
106 
110  static int GetViewHeight();
111 
114  static int GetViewWidth();
115 
116 
119  static std::vector<ViewID> ListViews();
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134  private:
135  static void init();
136  static void initBase();
137 
138  static std::string origCWD;
139 
140  struct LogicalDisplay {
141  Display * display;
142  };
143 
144  static Dynacoe::Table<LogicalDisplay> displays;
145  static ViewID currentDisplay;
146 
147  public:
148  std::string GetName() { return "ViewManager"; }
149  void Init(); void InitAfter(); void RunBefore(); void RunAfter(); void DrawBefore(); void DrawAfter();
150  Backend * GetBackend();
151 } ;
152 }
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 #endif // DYNACOESYS_H_INCLUDED
169 
static void Destroy(ViewID)
Destroys the specified display.
Backend.
Definition: Backend.h:56
static int GetViewWidth()
Gets the width of the currently set Display.
Definition: AssetID.h:37
static std::vector< ViewID > ListViews()
Returns a list of all currently created Displays.
static void NewMain(const std::string &name="", int w=640, int h=480)
Convenience function for creating and immediately setting the new display as the current display to u...
static ViewID New(const std::string &name, int w, int h)
Creates a new Display with the given w and h in pixels. Its ID is returned.
The module that manages all Displays.
Definition: ViewManager.h:67
Backend that controls how data is displayed to the user.
Definition: Display.h:53
static void SetMain(ViewID)
Sets the given Display as the one to update and draw to.
static ViewID GetCurrent()
Returns a pointer to the currently set Display.
Main class that handles automated updates of Dynacoe.
Definition: Dynacoe.h:55
static Display * Get(ViewID)
Returns the Display corresponding to the given ID.
static int GetViewHeight()
Gets the dimensions of the currently set Display. If no valid display is set, 0 is returned...