SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
ui_button.h
Go to the documentation of this file.
1#ifndef SENSESP_UI_UI_BUTTON_H
2#define SENSESP_UI_UI_BUTTON_H
3
4#include <map>
5#include <memory>
6
7#include "Arduino.h"
9
10namespace sensesp {
11
18class UIButton : public Observable {
19 public:
20 UIButton(String title, String name, bool must_confirm)
21 : title_(title), name_(name), must_confirm_(must_confirm) {}
22
23 const bool get_must_confirm() { return must_confirm_; }
24 const String get_title() { return title_; }
25 const String get_name() { return name_; }
26
27 static const std::map<String, std::shared_ptr<UIButton>>& get_ui_buttons() {
28 return ui_buttons_;
29 }
30
31 static UIButton* add(String name, String title, bool must_confirm = true) {
32 auto new_cmd = std::make_shared<UIButton>(title, name, must_confirm);
33 ui_buttons_[name] = new_cmd;
34
35 return new_cmd.get();
36 }
37
38 protected:
39 String title_;
40 String name_;
42
43 static std::map<String, std::shared_ptr<UIButton>> ui_buttons_;
44};
45
46} // namespace sensesp
47
48#endif
A base class which allow observers to attach callbacks to themselves. The callbacks will be called wh...
Definition observable.h:16
UIButton implements a button interface on the web UI.
Definition ui_button.h:18
static const std::map< String, std::shared_ptr< UIButton > > & get_ui_buttons()
Definition ui_button.h:27
UIButton(String title, String name, bool must_confirm)
Definition ui_button.h:20
const bool get_must_confirm()
Definition ui_button.h:23
const String get_name()
Definition ui_button.h:25
const String get_title()
Definition ui_button.h:24
static UIButton * add(String name, String title, bool must_confirm=true)
Definition ui_button.h:31
static std::map< String, std::shared_ptr< UIButton > > ui_buttons_
Definition ui_button.h:43