SensESP 3.5.1-alpha
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
sensesp::UIButton Class Reference

UIButton implements a button interface on the web UI. More...

#include <sensesp/ui/ui_button.h>

Inheritance diagram for sensesp::UIButton:
[legend]

Public Member Functions

 UIButton (String title, String name, bool must_confirm)
 
const bool get_must_confirm ()
 
const String get_title ()
 
const String get_name ()
 
- Public Member Functions inherited from sensesp::Observable
 Observable ()
 
 Observable (Observable &&other)
 Move constructor.
 
void notify ()
 
int attach (std::function< void()> observer)
 Attach an observer callback.
 
void detach (int id)
 Remove a previously attached observer by its ID.
 

Static Public Member Functions

static const std::map< String, std::shared_ptr< UIButton > > & get_ui_buttons ()
 
static UIButtonadd (String name, String title, bool must_confirm=true)
 Create a button and register it for the web UI.
 
static void clear_registry ()
 Empty the button registry.
 

Static Public Attributes

static constexpr size_t kMaxNameLength = 64
 Longest button name the web UI click endpoint resolves.
 

Protected Attributes

String title_
 
String name_
 
bool must_confirm_
 

Static Protected Attributes

static std::map< String, std::shared_ptr< UIButton > > ui_buttons_
 

Detailed Description

UIButton implements a button interface on the web UI.

Each UIButton object creates a button in the "Control" tab of the web UI. When the button is clicked, the object's observers are notified.

Definition at line 18 of file ui_button.h.

Constructor & Destructor Documentation

◆ UIButton()

sensesp::UIButton::UIButton ( String  title,
String  name,
bool  must_confirm 
)
inline

Definition at line 23 of file ui_button.h.

Member Function Documentation

◆ add()

static UIButton * sensesp::UIButton::add ( String  name,
String  title,
bool  must_confirm = true 
)
inlinestatic

Create a button and register it for the web UI.

Call during setup, before the HTTP server starts serving: the registry is read by the web UI handlers without locking. A duplicate name replaces the previously registered button.

Names up to kMaxNameLength characters appear in the web UI; a longer name is registered but hidden, since the click endpoint cannot resolve it.

Definition at line 45 of file ui_button.h.

◆ clear_registry()

void sensesp::UIButton::clear_registry ( )
static

Empty the button registry.

Releases the registry's shared_ptr references. Intended for clean app restart and test isolation; not for normal runtime use.

Like ConfigItemBase and unlike the raw-pointer registries, this registry owns its entries via shared_ptr, so there is no unregister-on-destruction: clearing the map releases the objects.

Definition at line 7 of file ui_button.cpp.

Here is the caller graph for this function:

◆ get_must_confirm()

const bool sensesp::UIButton::get_must_confirm ( )
inline

Definition at line 26 of file ui_button.h.

◆ get_name()

const String sensesp::UIButton::get_name ( )
inline

Definition at line 28 of file ui_button.h.

◆ get_title()

const String sensesp::UIButton::get_title ( )
inline

Definition at line 27 of file ui_button.h.

◆ get_ui_buttons()

static const std::map< String, std::shared_ptr< UIButton > > & sensesp::UIButton::get_ui_buttons ( )
inlinestatic

Definition at line 30 of file ui_button.h.

Member Data Documentation

◆ kMaxNameLength

constexpr size_t sensesp::UIButton::kMaxNameLength = 64
staticconstexpr

Longest button name the web UI click endpoint resolves.

Definition at line 21 of file ui_button.h.

◆ must_confirm_

bool sensesp::UIButton::must_confirm_
protected

Definition at line 78 of file ui_button.h.

◆ name_

String sensesp::UIButton::name_
protected

Definition at line 77 of file ui_button.h.

◆ title_

String sensesp::UIButton::title_
protected

Definition at line 76 of file ui_button.h.

◆ ui_buttons_

std::map< String, std::shared_ptr< UIButton > > sensesp::UIButton::ui_buttons_
staticprotected

Definition at line 80 of file ui_button.h.


The documentation for this class was generated from the following files: