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:
E.T.
2026-03-04 21:30:43 +01:00
committed by GitHub
parent 60ce89021a
commit 2b7302e659
11 changed files with 48 additions and 48 deletions
+1 -1
View File
@@ -171,7 +171,7 @@ void FocusManager::update(Widget* const top_widget, const KeyEvent event) {
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) {
+4 -4
View File
@@ -121,11 +121,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);
+11 -11
View File
@@ -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);
}
if (widget == nullptr)
@@ -209,9 +209,9 @@ const Style& Widget::style() const {
return style_ ? *style_ : parent()->style();
}
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
@@ -224,9 +224,9 @@ void Widget::visible(bool v) {
} else {
on_hide();
// Set all children invisible too.
// Set all children not drawn too.
for (const auto child : children()) {
child->visible(false);
child->drawn(false);
}
}
}
@@ -694,7 +694,7 @@ void Console::clear(bool clear_buffer = false) {
if (clear_buffer)
buffer.clear();
if (!hidden() && visible()) {
if (!hidden() && drawn()) {
display.fill_rectangle(
screen_rect(),
Theme::getInstance()->bg_darkest->background);
@@ -706,7 +706,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();
@@ -797,7 +797,7 @@ void Console::on_hide() {
}
void Console::crlf() {
if (hidden() || !visible()) return;
if (hidden() || !drawn()) return;
const auto& s = style();
auto sr = screen_rect();
@@ -3232,7 +3232,7 @@ void GraphEq::update_audio_spectrum(const AudioSpectrum& spectrum) {
}
void GraphEq::paint(Painter& painter) {
if (!visible()) return;
if (!drawn()) return;
if (!is_calculated) { // calc positions first
calculate_params();
is_calculated = true;
+4 -4
View File
@@ -126,8 +126,8 @@ class Widget {
bool dirty() const;
void set_clean();
void visible(bool v);
bool visible() { return flags.visible; };
void drawn(bool v);
bool drawn() { return flags.drawn; };
bool highlighted() const;
void set_highlighted(const bool value);
@@ -146,7 +146,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{
@@ -154,7 +154,7 @@ class Widget {
.hidden = false,
.focusable = false,
.highlighted = false,
.visible = false,
.drawn = false,
};
static const std::vector<Widget*> no_children;