1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-22 19:20:59 +00:00

Made Type and ID private and added accessors for them.

This commit is contained in:
Martin 2024-07-18 11:45:29 -04:00
parent bddcde4e57
commit 83104e9e1e

View File

@ -1,11 +1,11 @@
#include "ESPUI.h" #include "ESPUI.h"
static uint16_t idCounter = 0;
static const String ControlError = "*** ESPUI ERROR: Could not transfer control ***"; static const String ControlError = "*** ESPUI ERROR: Could not transfer control ***";
Control::Control(Control::Type type, const char* label, std::function<void(Control*, int)> callback, Control::Control(Control::ControlId_t id, Control::Type type, const char* label, std::function<void(Control*, int)> callback,
const String& value, Control::Color color, bool visible, uint16_t parentControl) const String& value, Control::Color color, bool visible, ControlId_t parentControl)
: type(type), : id(id),
type(type),
label(label), label(label),
callback(callback), callback(callback),
value(value), value(value),
@ -14,23 +14,20 @@ Control::Control(Control::Type type, const char* label, std::function<void(Contr
wide(false), wide(false),
vertical(false), vertical(false),
enabled(true), enabled(true),
parentControl(parentControl), parentControl(parentControl)
next(nullptr)
{ {
id = ++idCounter;
ControlChangeID = 1; ControlChangeID = 1;
} }
Control::Control(const Control& Control) Control::Control(const Control& Control)
: type(Control.type), : type(Control.type),
id(Control.id), id(Control::noParent),
label(Control.label), label(Control.label),
callback(Control.callback), callback(Control.callback),
value(Control.value), value(Control.value),
color(Control.color), color(Control.color),
visible(Control.visible), visible(Control.visible),
parentControl(Control.parentControl), parentControl(Control.parentControl),
next(Control.next),
ControlChangeID(Control.ControlChangeID) ControlChangeID(Control.ControlChangeID)
{ } { }
@ -249,7 +246,6 @@ void Control::onWsEvent(String & cmd, String& data)
SendCallback(P_LEFT_DOWN); SendCallback(P_LEFT_DOWN);
break; break;
} }
else if (cmd.equals(F("plup"))) else if (cmd.equals(F("plup")))
{ {
SendCallback(P_LEFT_UP); SendCallback(P_LEFT_UP);