mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-10 16:49:36 +00:00
rename Widget::visible to Widget::drawn (#3066)
* rename Widget::visible to Widget::drawn * Update firmware/standalone/common/ui/ui_widget.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update firmware/standalone/common/ui/ui_widget.hpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix fm_radio usage of drawn() --------- Co-authored-by: gullradriel <3157857+gullradriel@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -160,7 +160,7 @@ void FocusManager::update(
|
||||
const auto focus_screen_rect = focus_widget()->screen_rect();
|
||||
|
||||
const auto test_fn = [&focus_screen_rect, event](ui::Widget* const w) -> test_result_t {
|
||||
// if( w->visible() && w->focusable() ) {
|
||||
// if( w->drawn() && w->focusable() ) {
|
||||
if (w->focusable()) {
|
||||
const auto distance = rect_distances(event, focus_screen_rect, w->screen_rect());
|
||||
if (distance >= 0) {
|
||||
|
||||
@@ -118,11 +118,11 @@ void Painter::paint_widget_tree(Widget* w) {
|
||||
|
||||
void Painter::paint_widget(Widget* w) {
|
||||
if (w->hidden()) {
|
||||
// Mark widget (and all children) as invisible.
|
||||
w->visible(false);
|
||||
// Mark widget (and all children) as not drawn.
|
||||
w->drawn(false);
|
||||
} else {
|
||||
// Mark this widget as visible and recurse.
|
||||
w->visible(true);
|
||||
// Mark this widget as drawn and recurse.
|
||||
w->drawn(true);
|
||||
|
||||
if (w->dirty()) {
|
||||
w->paint(*this);
|
||||
|
||||
@@ -91,9 +91,9 @@ void Widget::set_parent(Widget* const widget) {
|
||||
}
|
||||
|
||||
if (parent_ && !widget) {
|
||||
// We have a parent, but are losing it. Update visible status.
|
||||
// We have a parent, but are losing it. Update drawn status.
|
||||
dirty_overlapping_children_in_rect(screen_rect());
|
||||
visible(false);
|
||||
drawn(false);
|
||||
}
|
||||
|
||||
parent_ = widget;
|
||||
@@ -212,9 +212,9 @@ const Style& Widget::style() const {
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::visible(bool v) {
|
||||
if (v != flags.visible) {
|
||||
flags.visible = v;
|
||||
void Widget::drawn(bool v) {
|
||||
if (v != flags.drawn) {
|
||||
flags.drawn = v;
|
||||
|
||||
/* TODO: This on_show/on_hide implementation seems inelegant.
|
||||
* But I need *some* way to take/configure resources when
|
||||
@@ -227,9 +227,9 @@ void Widget::visible(bool v) {
|
||||
} else {
|
||||
on_hide();
|
||||
|
||||
// Set all children invisible too.
|
||||
// Mark all children as not drawn too.
|
||||
for (const auto child : children()) {
|
||||
child->visible(false);
|
||||
child->drawn(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -701,7 +701,7 @@ void Console::clear(bool clear_buffer = false) {
|
||||
if (clear_buffer)
|
||||
buffer.clear();
|
||||
|
||||
if (!hidden() && visible()) {
|
||||
if (!hidden() && drawn()) {
|
||||
_api->fill_rectangle(screen_rect().left(), screen_rect().top(), screen_rect().width(), screen_rect().height(), Theme::getInstance()->bg_darkest->background.v);
|
||||
}
|
||||
|
||||
@@ -711,7 +711,7 @@ void Console::clear(bool clear_buffer = false) {
|
||||
void Console::write(std::string message) {
|
||||
bool escape = false;
|
||||
|
||||
if (!hidden() && visible()) {
|
||||
if (!hidden() && drawn()) {
|
||||
const Style& s = style();
|
||||
const Font& font = s.font;
|
||||
auto rect = screen_rect();
|
||||
@@ -803,7 +803,7 @@ void Console::on_hide() {
|
||||
}
|
||||
|
||||
void Console::crlf() {
|
||||
if (hidden() || !visible())
|
||||
if (hidden() || !drawn())
|
||||
return;
|
||||
|
||||
const auto& s = style();
|
||||
|
||||
@@ -127,8 +127,8 @@ class Widget {
|
||||
bool dirty() const;
|
||||
void set_clean();
|
||||
|
||||
void visible(bool v);
|
||||
bool visible() { return flags.visible; };
|
||||
void drawn(bool v);
|
||||
bool drawn() const { return flags.drawn; };
|
||||
|
||||
bool highlighted() const;
|
||||
void set_highlighted(const bool value);
|
||||
@@ -147,7 +147,7 @@ class Widget {
|
||||
bool hidden : 1; // Hide widget and children.
|
||||
bool focusable : 1; // Widget can receive focus.
|
||||
bool highlighted : 1; // Show in a highlighted style.
|
||||
bool visible : 1; // Object was visible during last paint.
|
||||
bool drawn : 1; // Object was drawn during last paint.
|
||||
};
|
||||
|
||||
flags_t flags{
|
||||
@@ -155,7 +155,7 @@ class Widget {
|
||||
.hidden = false,
|
||||
.focusable = false,
|
||||
.highlighted = false,
|
||||
.visible = false,
|
||||
.drawn = false,
|
||||
};
|
||||
|
||||
static const std::vector<Widget*> no_children;
|
||||
|
||||
Reference in New Issue
Block a user