Skip to content

Commit

Permalink
Implement connect header icon logic
Browse files Browse the repository at this point in the history
Connect icon is shown if connect is/was succesfully registered (states Connecting, Ok, Error)
If connect was registered and printer is set ready, icon switches from connect_16x16.png to set_ready_16x16.png
  • Loading branch information
michalrudolf committed Sep 20, 2024
1 parent 77bad65 commit 7e50194
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/gui/window_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ void window_header_t::updateNetwork() {

// Not fully connected -> make the icon gray
icon_network.set_shadow(interface_status != NETDEV_NETIF_UP);

#if BUDDY_ENABLE_CONNECT()
icon_connect.set_shadow(interface_status != NETDEV_NETIF_UP);
#endif // BUDDY_ENABLE_CONNECT()
}

void window_header_t::updateTransfer() {
Expand Down Expand Up @@ -176,7 +180,7 @@ void window_header_t::updateAllRects() {
maybe_update(bed_text, bed_text_width);
maybe_update(bed_icon, bed_icon.resource()->w);
#if BUDDY_ENABLE_CONNECT()
maybe_update(icon_ready_for_connect, icon_ready_for_connect.resource()->w);
maybe_update(icon_connect, icon_connect.resource()->w);
#endif // BUDDY_ENABLE_CONNECT()

auto label_width = current_offset - GuiDefaults::HeaderPadding.left;
Expand All @@ -201,7 +205,8 @@ void window_header_t::updateIcons() {
update_bed_info();

#if BUDDY_ENABLE_CONNECT()
icon_ready_for_connect.set_visible(connect_client::is_connect_registered() && connect_client::MarlinPrinter::is_printer_ready());
icon_connect.SetRes(connect_client::MarlinPrinter::is_printer_ready() ? &img::set_ready_16x16 : &img::connect_16x16);
icon_connect.set_visible(connect_client::is_connect_registered());
#endif // BUDDY_ENABLE_CONNECT()

#if !HAS_MINI_DISPLAY()
Expand All @@ -227,7 +232,7 @@ window_header_t::window_header_t(window_t *parent, const string_view_utf8 &txt)
, icon_transfer(this, first_rect_doesnt_matter, &img::transfer_icon_16x16)
, icon_stealth(this, first_rect_doesnt_matter, &img::stealth_20x16)
#if BUDDY_ENABLE_CONNECT()
, icon_ready_for_connect(this, first_rect_doesnt_matter, &img::set_ready_16x16)
, icon_connect(this, first_rect_doesnt_matter, &img::connect_16x16)
#endif // BUDDY_ENABLE_CONNECT()
, bed_text(this, first_rect_doesnt_matter, is_multiline::no)
, bed_icon(this, first_rect_doesnt_matter, &img::heatbed_16x16)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/window_header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct window_header_t : public window_frame_t {
window_icon_t icon_transfer;
window_icon_t icon_stealth;
#if BUDDY_ENABLE_CONNECT()
window_icon_t icon_ready_for_connect;
window_icon_t icon_connect; /// Icon switches between connect_16x16 and set_ready_16x16
#endif // BUDDY_ENABLE_CONNECT()
window_text_t bed_text;
window_icon_t bed_icon;
Expand Down

0 comments on commit 7e50194

Please sign in to comment.