Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI] Configurable Allocator for modm::ViewStack #1184

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/modm/ui/display/color_graphic_display.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include "graphic_display.hpp"

using namespace modm::platform;

namespace modm
{

Expand Down
2 changes: 1 addition & 1 deletion src/modm/ui/display/graphic_display.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class GraphicDisplay : public IOStream
inline void
clearPixel(glcd::Point p)
{
this->setPixel(p.x, p.y);
this->clearPixel(p.x, p.y);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/modm/ui/gui/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def prepare(module, options):
":container",
":debug",
":processing:timer",
":ui:display",
":ui:gui",
":ui:menu")
":ui:display")
return True

def build(env):
Expand Down
11 changes: 9 additions & 2 deletions src/modm/ui/gui/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

// ----------------------------------------------------------------------------
modm::gui::View::View(modm::gui::GuiViewStack* stack, uint8_t identifier, modm::gui::Dimension dimension) :
AbstractView(stack, identifier),
stack(stack),
dimension(dimension)
dimension(dimension),
identifier(identifier),
alive(true)
{
this->display().clear();
}
Expand Down Expand Up @@ -161,3 +162,9 @@ void modm::gui::View::markDrawn()
(*iter)->markDrawn();
}
}

modm::ColorGraphicDisplay&
modm::gui::View::display()
{
return stack->getDisplay();
}
45 changes: 42 additions & 3 deletions src/modm/ui/gui/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include "widgets/widget.hpp"
#include "colorpalette.hpp"

#include <modm/ui/menu/abstract_view.hpp>

namespace modm
{

Expand All @@ -41,7 +39,7 @@ class GuiViewStack;
* @ingroup modm_ui_gui
* @author Thorsten Lajewski
*/
class View : public modm::AbstractView
class View
{
friend class GuiViewStack;

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

/**
* @brief hasChanged indicates the current displayed view has changed.
* This function prevents unnecessary drawing of the display
* @return if true the display has to be redrawn.
*/
virtual bool
hasChanged() = 0;

virtual void
preUpdate()
{
Expand All @@ -79,10 +85,30 @@ class View : public modm::AbstractView
bool
pack(Widget *w, const modm::glcd::Point &coord);

/**
* @brief isAlive tells the ViewStack if it should remove this screen.
* @return
*/
bool
isAlive() const
{
return this->alive;
}

/// Remove the view from the screen. The viewStack handles the deletion.
void
remove();

/**
* @brief onRemove will be called right before the view gets deleted,
* can be reimplemented to reset external data.
*/
virtual void
onRemove()
{
// nothing to be done here
}

/// Set color palette for every contained widget
void
setColorPalette(ColorPalette& cp);
Expand All @@ -105,12 +131,25 @@ class View : public modm::AbstractView
return stack;
}

modm::ColorGraphicDisplay&
display();

/**
* @brief getIdentifier of the view.
*/
inline uint8_t getIdentifier(){
return this->identifier;
}

protected:
modm::gui::GuiViewStack* stack;
Dimension dimension;
WidgetContainer widgets;

modm::gui::ColorPalette colorpalette;

const uint8_t identifier;
bool alive;
};

} // namespace gui
Expand Down
2 changes: 1 addition & 1 deletion src/modm/ui/gui/view_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// ----------------------------------------------------------------------------
modm::gui::GuiViewStack::GuiViewStack(modm::ColorGraphicDisplay* display, modm::gui::inputQueue* queue) :
ViewStack(display),
display(display),
input_queue(queue)
{
}
Expand Down
13 changes: 11 additions & 2 deletions src/modm/ui/gui/view_stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <modm/ui/display/color_graphic_display.hpp>
#include <modm/container/stack.hpp>
#include <modm/container/linked_list.hpp>
#include <modm/ui/menu/menu_buttons.hpp>
#include "view.hpp"
#include "types.hpp"

Expand All @@ -41,7 +40,7 @@ namespace gui
* @ingroup modm_ui_gui
* @author Thorsten Lajewski
*/
class GuiViewStack : public modm::ViewStack
class GuiViewStack
{
public:
GuiViewStack(modm::ColorGraphicDisplay* display, modm::gui::inputQueue* queue);
Expand Down Expand Up @@ -84,7 +83,17 @@ class GuiViewStack : public modm::ViewStack
virtual void
update();

/**
* @brief getDisplay access underlying GraphicDisplay
*/
inline modm::ColorGraphicDisplay&
getDisplay()
{
return *this->display;
}

private:
modm::ColorGraphicDisplay *display;
modm::Stack< modm::gui::View* , modm::LinkedList< modm::gui::View* > > stack;
modm::gui::inputQueue *input_queue;
};
Expand Down
21 changes: 0 additions & 21 deletions src/modm/ui/menu/abstract_menu.cpp

This file was deleted.

9 changes: 7 additions & 2 deletions src/modm/ui/menu/abstract_menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ namespace modm{
* \author Thorsten Lajewski
* \ingroup modm_ui_menu
*/
class AbstractMenu: public AbstractView
template<typename Allocator = std::allocator<IAbstractView> >
class AbstractMenu : public AbstractView<Allocator>
{
public:

AbstractMenu(modm::ViewStack* stack, uint8_t identifier);
AbstractMenu(modm::ViewStack<Allocator>* stack, uint8_t identifier) :
modm::AbstractView<Allocator>(stack, identifier)
{
}

virtual ~AbstractMenu() {}

virtual void
shortButtonPress(modm::MenuButtons::Button button) = 0;
Expand Down
68 changes: 0 additions & 68 deletions src/modm/ui/menu/abstract_view.cpp

This file was deleted.

Loading
Loading