ESPHome 2026.5.0
Loading...
Searching...
No Matches
display_menu_base.h
Go to the documentation of this file.
1#pragma once
2
4
5#include "menu_item.h"
6
7#include <forward_list>
8
10
15
16class MenuItem;
17
22 public:
23 void set_root_item(MenuItemMenu *item) { this->displayed_item_ = this->root_item_ = item; }
24 void set_active(bool active) { this->active_ = active; }
25 void set_mode(MenuMode mode) { this->mode_ = mode; }
26 void set_rows(uint8_t rows) { this->rows_ = rows; }
27
28 float get_setup_priority() const override { return setup_priority::PROCESSOR; }
29
30 void up();
31 void down();
32 void left();
33 void right();
34 void enter();
35
36 void show_main();
37 void show();
38 void hide();
39
40 void draw();
41
42 bool is_active() const { return this->active_; }
43
44 protected:
45 void reset_();
46 void process_initial_();
49 bool cursor_up_();
50 bool cursor_down_();
51 bool enter_menu_();
52 bool leave_menu_();
53 void finish_editing_();
54 virtual void draw_menu();
55 virtual void draw_item(const MenuItem *item, uint8_t row, bool selected) = 0;
56 virtual void update() {}
57 virtual void draw_and_update() {
58 draw_menu();
59 update();
60 }
61
62 virtual void on_before_show(){};
63 virtual void on_after_show(){};
64 virtual void on_before_hide(){};
65 virtual void on_after_hide(){};
66
67 uint8_t rows_;
68 bool active_;
71
73 uint8_t top_index_{0};
74 uint8_t cursor_index_{0};
75 std::forward_list<std::pair<uint8_t, uint8_t>> selection_stack_{};
76 bool editing_{false};
78};
79
80} // namespace esphome::display_menu_base
BedjetMode mode
BedJet operating mode.
Class to display a hierarchical menu.
virtual void draw_item(const MenuItem *item, uint8_t row, bool selected)=0
std::forward_list< std::pair< uint8_t, uint8_t > > selection_stack_
constexpr float PROCESSOR
For components that use data from sensors like displays.
Definition component.h:45