Skip to content

Commit 31bbf48

Browse files
MatthewMArnoldsalkinium
authored andcommitted
[ui] Remove dependency of :ui:gui on :ui:menu
1 parent 73464ae commit 31bbf48

File tree

5 files changed

+64
-11
lines changed

5 files changed

+64
-11
lines changed

src/modm/ui/gui/module.lb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ def prepare(module, options):
2323
":container",
2424
":debug",
2525
":processing:timer",
26-
":ui:display",
27-
":ui:gui",
28-
":ui:menu")
26+
":ui:display")
2927
return True
3028

3129
def build(env):

src/modm/ui/gui/view.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919
// ----------------------------------------------------------------------------
2020
modm::gui::View::View(modm::gui::GuiViewStack* stack, uint8_t identifier, modm::gui::Dimension dimension) :
21-
AbstractView(stack, identifier),
2221
stack(stack),
23-
dimension(dimension)
22+
dimension(dimension),
23+
identifier(identifier),
24+
alive(true)
2425
{
2526
this->display().clear();
2627
}
@@ -161,3 +162,9 @@ void modm::gui::View::markDrawn()
161162
(*iter)->markDrawn();
162163
}
163164
}
165+
166+
modm::ColorGraphicDisplay&
167+
modm::gui::View::display()
168+
{
169+
return stack->getDisplay();
170+
}

src/modm/ui/gui/view.hpp

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#include "widgets/widget.hpp"
2525
#include "colorpalette.hpp"
2626

27-
#include <modm/ui/menu/abstract_view.hpp>
28-
2927
namespace modm
3028
{
3129

@@ -41,7 +39,7 @@ class GuiViewStack;
4139
* @ingroup modm_ui_gui
4240
* @author Thorsten Lajewski
4341
*/
44-
class View : public modm::AbstractView
42+
class View
4543
{
4644
friend class GuiViewStack;
4745

@@ -61,6 +59,14 @@ class View : public modm::AbstractView
6159
virtual void
6260
update();
6361

62+
/**
63+
* @brief hasChanged indicates the current displayed view has changed.
64+
* This function prevents unnecessary drawing of the display
65+
* @return if true the display has to be redrawn.
66+
*/
67+
virtual bool
68+
hasChanged() = 0;
69+
6470
virtual void
6571
preUpdate()
6672
{
@@ -79,10 +85,30 @@ class View : public modm::AbstractView
7985
bool
8086
pack(Widget *w, const modm::glcd::Point &coord);
8187

88+
/**
89+
* @brief isAlive tells the ViewStack if it should remove this screen.
90+
* @return
91+
*/
92+
bool
93+
isAlive() const
94+
{
95+
return this->alive;
96+
}
97+
8298
/// Remove the view from the screen. The viewStack handles the deletion.
8399
void
84100
remove();
85101

102+
/**
103+
* @brief onRemove will be called right before the view gets deleted,
104+
* can be reimplemented to reset external data.
105+
*/
106+
virtual void
107+
onRemove()
108+
{
109+
// nothing to be done here
110+
}
111+
86112
/// Set color palette for every contained widget
87113
void
88114
setColorPalette(ColorPalette& cp);
@@ -105,12 +131,25 @@ class View : public modm::AbstractView
105131
return stack;
106132
}
107133

134+
modm::ColorGraphicDisplay&
135+
display();
136+
137+
/**
138+
* @brief getIdentifier of the view.
139+
*/
140+
inline uint8_t getIdentifier(){
141+
return this->identifier;
142+
}
143+
108144
protected:
109145
modm::gui::GuiViewStack* stack;
110146
Dimension dimension;
111147
WidgetContainer widgets;
112148

113149
modm::gui::ColorPalette colorpalette;
150+
151+
const uint8_t identifier;
152+
bool alive;
114153
};
115154

116155
} // namespace gui

src/modm/ui/gui/view_stack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// ----------------------------------------------------------------------------
2222
modm::gui::GuiViewStack::GuiViewStack(modm::ColorGraphicDisplay* display, modm::gui::inputQueue* queue) :
23-
ViewStack(display),
23+
display(display),
2424
input_queue(queue)
2525
{
2626
}

src/modm/ui/gui/view_stack.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <modm/ui/display/color_graphic_display.hpp>
2222
#include <modm/container/stack.hpp>
2323
#include <modm/container/linked_list.hpp>
24-
#include <modm/ui/menu/menu_buttons.hpp>
2524
#include "view.hpp"
2625
#include "types.hpp"
2726

@@ -41,7 +40,7 @@ namespace gui
4140
* @ingroup modm_ui_gui
4241
* @author Thorsten Lajewski
4342
*/
44-
class GuiViewStack : public modm::ViewStack
43+
class GuiViewStack
4544
{
4645
public:
4746
GuiViewStack(modm::ColorGraphicDisplay* display, modm::gui::inputQueue* queue);
@@ -84,7 +83,17 @@ class GuiViewStack : public modm::ViewStack
8483
virtual void
8584
update();
8685

86+
/**
87+
* @brief getDisplay access underlying GraphicDisplay
88+
*/
89+
inline modm::ColorGraphicDisplay&
90+
getDisplay()
91+
{
92+
return *this->display;
93+
}
94+
8795
private:
96+
modm::ColorGraphicDisplay *display;
8897
modm::Stack< modm::gui::View* , modm::LinkedList< modm::gui::View* > > stack;
8998
modm::gui::inputQueue *input_queue;
9099
};

0 commit comments

Comments
 (0)