Let the page buttons make way: a Page buttons setting that gives their room to the tiles, chevrons and dots instead of words, and a warning in the editor for pages nothing leads to (0.2.82)

GitHub issue #9 asked to drop the Previous/Next bar when Go to page tiles do the navigation and to give the tiles the whole screen. Page buttons is a setting the screen owns (on by default): a row in the Screen group of the settings page, switch.<screen>_page_buttons in Home Assistant, and a row in the editor's Screen settings. Without the bar, and on a screen with one page, place_page moves and sizes the three rows so they reach the bottom margin (Guition 108 -> 122 px, CYD 52 -> 61 px); a card keeps its circle, name and state in its middle and the single analog clock keeps its dial. With page buttons and swiping both off, the editor says where the Go to page tiles lead and which pages that leaves out of reach.

The bar itself: each half of the band under the tiles is one key with an MDI chevron and lights up under a finger, and a dot per page sits between them; the screen's settings page uses the same pager. App 0.2.82, firmware 0.2.69.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Max Gramser
2026-09-18 20:11:01 +02:00
parent b149428dcb
commit ffe639e23c
30 changed files with 566 additions and 165 deletions
+40 -22
View File
@@ -18,7 +18,7 @@
############################################################
substitutions:
SCREEN_FIRMWARE_VERSION: "0.2.68"
SCREEN_FIRMWARE_VERSION: "0.2.69"
# A tap survives a finger that drifts up to this far (320 px over 58 mm: 1 cm); further is a swipe.
TOUCH_MOVE_LIMIT_PX: "56"
# Shortest contact that counts as a tap; a resistive panel bounces, a capacitive one does not.
@@ -1458,6 +1458,18 @@ switch:
- lambda: 'settings_screen::set("swipe_pages", 1);'
turn_off_action:
- lambda: 'settings_screen::set("swipe_pages", 0);'
# Off, the Previous and Next bar under the tiles goes and the tiles take its room (firmware 0.2.69+).
- platform: template
id: setting_page_buttons
name: "Page buttons"
icon: "mdi:page-next-outline"
entity_category: config
restore_mode: DISABLED
lambda: return settings_screen::page_buttons != 0;
turn_on_action:
- lambda: 'settings_screen::set("page_buttons", 1);'
turn_off_action:
- lambda: 'settings_screen::set("page_buttons", 0);'
# Night hours as Home Assistant times (firmware 0.2.49+); the screen keeps minutes since midnight.
datetime:
@@ -2375,14 +2387,16 @@ lvgl:
clickable: false
# ---------- VALUE SLIDER OVERLAY ----------
# ---------- PAGE NAVIGATION: one full-width bar ----------
# ---------- PAGE NAVIGATION: the band under the tiles ----------
# Each half of the band is one key (firmware 0.2.69+): a chevron in its corner, lit up under a finger, and the
# page dots between them. The band reaches from the tile area's end (SCROLL_Y + SCROLL_H) to the bottom edge.
- obj:
id: page_prev
align: BOTTOM_LEFT
x: 0
y: 0
width: 130
height: 32
width: 160
height: 36
pad_all: 0
radius: 0
bg_opa: TRANSP
@@ -2403,29 +2417,29 @@ lvgl:
widgets:
- label:
align: LEFT_MID
x: 12
text: "< Previous"
text_font: label
x: 14
text: "\U000F0141" # chevron-left
text_font: materialdesign_icons_mini
styles: paint_ink
clickable: false
- label:
- obj:
id: page_number
align: BOTTOM_MID
y: 0
width: 60
height: 32
pad_top: 9
width: 104
height: 36
pad_all: 0
bg_opa: TRANSP
border_width: 0
text: "1 / 2"
text_align: CENTER
text_font: sublabel
clickable: false
scrollable: false
- obj:
id: page_next
align: BOTTOM_RIGHT
x: 0
y: 0
width: 130
height: 32
width: 160
height: 36
pad_all: 0
radius: 0
bg_opa: TRANSP
@@ -2444,9 +2458,9 @@ lvgl:
widgets:
- label:
align: RIGHT_MID
x: -12
text: "Next >"
text_font: label
x: -14
text: "\U000F0142" # chevron-right
text_font: materialdesign_icons_mini
styles: paint_ink
clickable: false
@@ -3717,12 +3731,14 @@ script:
bool visible = runtime_tiles::enabled ? i<6 && runtime_tiles::widgets[i].index<runtime_tiles::model.count : i < count && (paginated ? i >= 6 : i < 6);
ok = ok && (lv_obj_has_flag(tiles[i], LV_OBJ_FLAG_HIDDEN) != visible);
}
// The bar shows with more than one page, unless the Page buttons setting is off (firmware 0.2.69+).
const bool bar = paginated && (!runtime_tiles::enabled || settings_screen::page_buttons);
for (lv_obj_t* control : {id(page_prev), id(page_next), id(page_number)})
ok = ok && (lv_obj_has_flag(control, LV_OBJ_FLAG_HIDDEN) != paginated);
ok = ok && (lv_obj_has_flag(control, LV_OBJ_FLAG_HIDDEN) != bar);
lv_area_t nav, grid;
lv_obj_get_coords(id(page_next), &nav);
lv_obj_get_coords(id(tile_scroll), &grid);
ok = ok && (!paginated || grid.y2 < nav.y1);
ok = ok && (!bar || grid.y2 < nav.y1);
if(runtime_tiles::enabled)ok = runtime_tiles::check_tile_geometry() && ok;
ESP_LOGI("ui_test", "page_check=%s count=%d heap=%u frames=%u grid_bottom=%d nav_top=%d", ok ? "PASS" : "FAIL", count, (unsigned) esp_get_free_heap_size(), (unsigned) id(rendered_frames), grid.y2, nav.y1);
id(tile_page) = 0;
@@ -3772,7 +3788,7 @@ script:
lv_obj_add_flag(tiles[i], LV_OBJ_FLAG_HIDDEN);
}
}
lv_label_set_text(id(page_number), id(tile_page) == 0 ? "1 / 2" : "2 / 2");
settings_screen::page_dots(id(page_number), id(tile_page), 2, false);
if (id(tile_page) == 0) {
lv_obj_add_state(id(page_prev), LV_STATE_DISABLED);
lv_obj_clear_state(id(page_next), LV_STATE_DISABLED);
@@ -3813,6 +3829,8 @@ script:
for (auto [entity, minutes] : {std::make_pair(id(setting_night_start), settings.night_start), std::make_pair(id(setting_night_end), settings.night_end)}) {
if (!entity->has_state() || entity->hour * 60 + entity->minute != minutes) entity->update();
}
// The Page buttons setting moves the cards into the bar's room or back (firmware 0.2.69+).
if (runtime_tiles::enabled) runtime_tiles::page_buttons_changed();
settings_screen::refresh();
if (!id(ui_refresh).is_running()) id(ui_refresh).execute();