HoverRace  2.0
UiScene.h
Go to the documentation of this file.
1 
2 // UiScene.h
3 //
4 // Copyright (c) 2013-2015 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #include "Scene.h"
25 
26 namespace HoverRace {
27  namespace Control {
28  class Nav;
29  }
30  namespace Display {
31  class UiViewModel;
32  }
33 }
34 
35 namespace HoverRace {
36 namespace Client {
37 
42 class UiScene : public Scene
43 {
44  using SUPER = Scene;
45 
46 public:
47  UiScene(const std::string &name = "") :
48  SUPER(name), needsLayout(true) { }
49  virtual ~UiScene() { }
50 
51 public:
52  bool IsMouseCursorEnabled() const override { return true; }
53 
54 public:
55  void AttachController(Control::InputEventController &controller,
56  ConnList &conns) override;
58  ConnList&) override { }
59 
60 private:
61  void OnAction();
62  void OnNav(Control::Nav &nav);
63 
64 protected:
65  void SetFocusRoot(std::shared_ptr<Display::UiViewModel> root);
66 
72  void RequestLayout() { needsLayout = true; }
73 
85  virtual void Layout() { }
86 
87 public:
88  void PrepareRender() override
89  {
90  if (needsLayout) {
91  Layout();
92  needsLayout = false;
93  }
94  }
95 
96  void Render() override { }
97 
98 private:
100 
101  std::shared_ptr<Display::UiViewModel> focusRoot;
102  boost::signals2::scoped_connection focusReqConn;
103  boost::signals2::scoped_connection focusRelConn;
104 };
105 
106 } // namespace Client
107 } // namespace HoverRace
void RequestLayout()
Indicate that the current layout is out-of-date and needs to be adjusted.
Definition: UiScene.h:72
bool needsLayout
Definition: UiScene.h:99
void DetachController(Control::InputEventController &, ConnList &) override
Remove the controller mappings.
Definition: UiScene.h:57
Base class for UI-centric scenes.
Definition: UiScene.h:42
std::shared_ptr< Display::UiViewModel > focusRoot
Definition: UiScene.h:101
boost::signals2::scoped_connection focusRelConn
Definition: UiScene.h:103
boost::signals2::scoped_connection focusReqConn
Definition: UiScene.h:102
std::array< boost::signals2::scoped_connection, 2 > conns
Definition: ProfileEditScene.cpp:152
void Render() override
Definition: UiScene.h:96
Scenes are analogous to fullscreen windows that are layered on top of each other. ...
Definition: Scene.h:43
A navigation direction.
Definition: Nav.h:45
virtual void Layout()
Adjust the size and position of any child elements.
Definition: UiScene.h:85
virtual ~UiScene()
Definition: UiScene.h:49
Tracks connections as a group.
Definition: Scene.h:69
void PrepareRender() override
Definition: UiScene.h:88
Definition: Announcement.h:24
bool IsMouseCursorEnabled() const override
Determine if the mouse cursor is enabled for this scene.
Definition: UiScene.h:52
Translates input events into actions.
Definition: Controller.h:106
UiScene(const std::string &name="")
Definition: UiScene.h:47