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}
15
16rbjson::Object& Widget::extra() {
17 return m_state.data();
18}
19
20rbjson::Object& Widget::style() {
21 auto* res = extra().getObject("css");
22 if (res == nullptr) {
23 res = new rbjson::Object;
24 extra().set("css", res);
25 }
26 return *res;
27}
28
29void Widget::serialize(std::ostream& ss) {
30 extra().shrink_to_fit();
31
32 ss << "{";
33 {
34 ss << "\"uuid\":" << m_state.uuid() << ",";
35 ss << "\"type\":\"" << m_type << "\",";
36 ss << "\"state\":";
37 extra().serialize(ss);
38 }
39 ss << "}";
40}
41};
42
43};
uint16_t uuid() const
Definition widget.h:109
const rbjson::Object & data() const
Definition widget.h:110
rbjson::Object & extra()
Definition widget.cpp:16
WidgetState & m_state
Definition widget.h:93
void serialize(std::ostream &ss)
Definition widget.cpp:29
rbjson::Object & style()
Definition widget.cpp:20
Definition arm.h:8