1
0
mirror of https://github.com/s00500/ESPUI.git synced 2025-07-04 11:20:19 +00:00

Added Tabbed View

* new member of Control: parentControl
* changed addControl() to add children of elements
* added some styles in the css
* two new divs in index.html
* added frontend code to controls.js
* added new demo to demonstrate the tabbed view
This commit is contained in:
Christian Riggenbach
2019-03-03 23:22:01 +01:00
parent 50de3dad87
commit 4ea7928fd5
16 changed files with 428 additions and 67 deletions

View File

@ -361,9 +361,11 @@ void onWsEvent( AsyncWebSocket* server, AsyncWebSocketClient* client,
}
}
int ESPUIClass::addControl( ControlType type, const char* label,
String value, ControlColor color,
void ( *callback )( Control, int ) ) {
uint16_t ESPUIClass::addControl( ControlType type, const char* label,
String value, ControlColor color,
void ( *callback )( Control, int ),
uint16_t parentControl
) {
if ( this->getControl( label ) != nullptr ) {
if ( this->verbosity ) {
Serial.println( "UI ERROR: Element " + String( label ) +
@ -373,7 +375,7 @@ int ESPUIClass::addControl( ControlType type, const char* label,
return -1;
}
Control* control = new Control( type, label, callback, value, color );
Control* control = new Control( type, label, callback, value, color, parentControl );
if ( this->controls == nullptr ) {
this->controls = control;
@ -417,7 +419,7 @@ int ESPUIClass::switcher( const char* label, bool startState,
int ESPUIClass::pad( const char* label, bool center,
void ( *callback )( Control, int ), ControlColor color ) {
if ( center ) {
return addControl( ControlType::Cpad, label, "", color, callback );
return addControl( ControlType::PadWithCenter, label, "", color, callback );
} else {
return addControl( ControlType::Pad, label, "", color, callback );
}
@ -608,6 +610,10 @@ void ESPUIClass::jsonDom( AsyncWebSocketClient* client ) {
item["value"] = String( control->value );
item["color"] = ( int )control->color;
if ( control->parentControl != 0xffff ) {
item["parentControl"] = String( control->parentControl );
}
items.add( item );
control = control->next;