Esp32-RBGridUI
Library for creating UIs for the RBController app
Loading...
Searching...
No Matches
widget.cpp
Go to the documentation of this file.
1#include <esp_log.h>
2#include <stdio.h>
3
4#include "widget.h"
5
6#define TAG "UiBuilderWidget"
7
8namespace gridui {
9namespace builder {
10
11Widget::Widget(const char* type, WidgetState& state)
12 : m_state(state)
13 , m_type(type)
14 , m_style(nullptr) {
15}
16
19
20rbjson::Object& Widget::extra() {
21 return m_state.data();
22}
23
24rbjson::Object& Widget::style() {
25 auto* res = extra().getObject("css");
26 if (res == nullptr) {
27 res = new rbjson::Object;
28 extra().set("css", res);
29 }
30 return *res;
31}
32
33void Widget::serialize(std::stringstream& ss) {
34 ss << "{";
35 {
36 ss << "\"uuid\":" << m_state.uuid() << ",";
37 ss << "\"type\":\"" << m_type << "\",";
38 ss << "\"state\":";
39 extra().serialize(ss);
40 }
41 ss << "}";
42}
43};
44
45};
uint16_t uuid() const
Definition widget.h:78
const rbjson::Object & data() const
Definition widget.h:79
rbjson::Object & extra()
Definition widget.cpp:20
WidgetState & m_state
Definition widget.h:90
virtual void serialize(std::stringstream &ss)
Definition widget.cpp:33
rbjson::Object & style()
Definition widget.cpp:24
Definition arm.h:8