Esp32-RBGridUI
Library for creating UIs for the RBController app
Loading...
Searching...
No Matches
select.h
Go to the documentation of this file.
1#pragma once
2
3#include "../widgets/select.h"
4#include "widget.h"
5
6namespace gridui {
7namespace builder {
8
11class Select : public Widget, public BuilderMixin<Select, gridui::Select> {
12 static const char* name() { return "Select"; }
13
14 friend class gridui::_GridUi;
15 using Widget::Widget;
16
17public:
18 Select& color(const std::string& color) {
19 extra().set("color", color);
20 return *this;
21 }
22
23 Select& background(const std::string& background) {
24 extra().set("background", background);
25 return *this;
26 }
27
29 extra().set("disabled", new rbjson::Bool(disabled));
30 return *this;
31 }
32
33 Select& options(const std::vector<std::string>& options) {
34 std::string out = "";
35 for (auto& option : options) {
36 out.append(option);
37 out.push_back(',');
38 }
39 if (out.size() > 0)
40 out.pop_back();
41 extra().set("options", new rbjson::String(out));
42 return *this;
43 }
44
45 Select& options(const std::string& options) {
46 extra().set("options", new rbjson::String(options));
47 return *this;
48 }
49
50 Select& selectedIndex(int index) {
51 extra().set("selectedIndex", new rbjson::Number(index));
52 return *this;
53 }
54
58 addCallback("changed", cb);
59 return *this;
60 }
61};
62
63};
64};
std::function< void(gridui::Select &)> callback_t
Definition widget.h:41
void addCallback(const std::string &name, const callback_t &cb)
Definition widget.h:54
Select & options(const std::vector< std::string > &options)
Definition select.h:33
Select & disabled(bool disabled)
Definition select.h:28
Select & color(const std::string &color)
Definition select.h:18
Select & background(const std::string &background)
Definition select.h:23
Select & options(const std::string &options)
Definition select.h:45
Select & selectedIndex(int index)
Definition select.h:50
rbjson::Object & extra()
Definition widget.cpp:16
Select & onChanged(callback_t cb)
Definition select.h:57
Definition arm.h:8