Gamedev Framework (gf)  0.10.0
A C++14 framework for 2D games
WidgetContainer.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2018 Lilian Franchi
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #ifndef GF_WIDGET_CONTAINER_H
22 #define GF_WIDGET_CONTAINER_H
23 
24 #include <vector>
25 
26 #include "RenderStates.h"
27 
28 namespace gf {
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 inline namespace v1 {
31 #endif
32 
33  class Widget;
34  class RenderTarget;
35 
42  class GF_API WidgetContainer {
43  public:
48 
58  void render(RenderTarget &target, const RenderStates &states = RenderStates());
59 
65  void pointTo(Vector2f coords);
66 
72  void addWidget(Widget& widget);
73 
81  Widget *removeWidget(Widget *widget);
82 
86  void triggerAction();
87 
91  void selectNextWidget();
92 
96  void selectPreviousWidget();
97 
98  private:
99  void unselectCurrentlySelected();
100 
101  void computePreviousIndex();
102  void computeNextIndex();
103 
104  Widget& getCurrent();
105 
106  private:
107  std::vector<Widget*> m_widgets;
108  std::size_t m_selectedWidgetIndex;
109  bool m_widgetIsSelected;
110  };
111 
112 #ifndef DOXYGEN_SHOULD_SKIP_THIS
113 }
114 #endif
115 }
116 
117 #endif // WIDGETS_WIDGET_CONTAINER_H
Base class for all render targets (window, texture, ...)
Definition: RenderTarget.h:66
Define the states used for drawing to a RenderTarget.
Definition: RenderStates.h:82
The widgets abstract class.
Definition: Widget.h:53
The namespace for gf classes.
Definition: Action.h:34
A collection of widgets.
Definition: WidgetContainer.h:42