mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-01-07 22:47:40 +00: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
@ -240,30 +240,6 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
void paint_widget(ui::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(painter);
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static ui::Widget* touch_widget(ui::Widget* const w, ui::TouchEvent event) {
|
static ui::Widget* touch_widget(ui::Widget* const w, ui::TouchEvent event) {
|
||||||
if( !w->hidden() ) {
|
if( !w->hidden() ) {
|
||||||
@ -311,7 +287,7 @@ private:
|
|||||||
|
|
||||||
void handle_lcd_frame_sync() {
|
void handle_lcd_frame_sync() {
|
||||||
if( ui::is_dirty() ) {
|
if( ui::is_dirty() ) {
|
||||||
paint_widget(top_widget);
|
painter.paint_widget(top_widget);
|
||||||
ui::dirty_clear();
|
ui::dirty_clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "ui_painter.hpp"
|
#include "ui_painter.hpp"
|
||||||
|
|
||||||
|
#include "ui_widget.hpp"
|
||||||
|
|
||||||
#include "portapack.hpp"
|
#include "portapack.hpp"
|
||||||
using namespace portapack;
|
using namespace portapack;
|
||||||
|
|
||||||
@ -71,4 +73,29 @@ void Painter::fill_rectangle(const Rect r, const Color c) {
|
|||||||
display.fill_rectangle(r, 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 */
|
} /* namespace ui */
|
||||||
|
@ -37,6 +37,8 @@ struct Style {
|
|||||||
Style invert() const;
|
Style invert() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Widget;
|
||||||
|
|
||||||
class Painter {
|
class Painter {
|
||||||
public:
|
public:
|
||||||
Painter() { };
|
Painter() { };
|
||||||
@ -51,6 +53,8 @@ public:
|
|||||||
void draw_rectangle(const Rect r, const Color c);
|
void draw_rectangle(const Rect r, const Color c);
|
||||||
void fill_rectangle(const Rect r, const Color c);
|
void fill_rectangle(const Rect r, const Color c);
|
||||||
|
|
||||||
|
void paint_widget(Widget* const w);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void draw_hline(Point p, size_t width, const Color c);
|
void draw_hline(Point p, size_t width, const Color c);
|
||||||
void draw_vline(Point p, size_t height, const Color c);
|
void draw_vline(Point p, size_t height, const Color c);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user