mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-09 23:22:33 -04:00
Move widget tree painting to ui::Painter.
Still doesn't seem like the right place, but better than the event dispatcher!
This commit is contained in:
parent
a9bb7c96e5
commit
872c998ff1
3 changed files with 32 additions and 25 deletions
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "ui_painter.hpp"
|
||||
|
||||
#include "ui_widget.hpp"
|
||||
|
||||
#include "portapack.hpp"
|
||||
using namespace portapack;
|
||||
|
||||
|
@ -71,4 +73,29 @@ void Painter::fill_rectangle(const Rect r, const Color c) {
|
|||
display.fill_rectangle(r, c);
|
||||
}
|
||||
|
||||
void Painter::paint_widget(Widget* const w) {
|
||||
if( w->hidden() ) {
|
||||
// Mark widget (and all children) as invisible.
|
||||
w->visible(false);
|
||||
} else {
|
||||
// Mark this widget as visible and recurse.
|
||||
w->visible(true);
|
||||
|
||||
if( w->dirty() ) {
|
||||
w->paint(*this);
|
||||
// Force-paint all children.
|
||||
for(const auto child : w->children()) {
|
||||
child->set_dirty();
|
||||
paint_widget(child);
|
||||
}
|
||||
w->set_clean();
|
||||
} else {
|
||||
// Selectively paint all children.
|
||||
for(const auto child : w->children()) {
|
||||
paint_widget(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue