18 ComboBoxItem() =
default;
19 ComboBoxItem(
const std::string &
id,
const std::string &
name) : fId(
id), fName(
name) {}
23struct TestPanelModel {
24 std::string fSampleText;
25 std::vector<ComboBoxItem> fComboItems;
26 std::string fSelectId;
27 std::string fButtonText;
30std::shared_ptr<ROOT::Experimental::RWebWindow> window;
31std::unique_ptr<TestPanelModel> model;
34void ProcessConnection(
unsigned connid)
36 printf(
"connection established %u\n", connid);
38 window->Send(connid, std::string(
"MODEL:") +
json.Data());
41void ProcessCloseConnection(
unsigned connid)
43 printf(
"connection closed %u\n", connid);
46void ProcessData(
unsigned connid,
const std::string &arg)
48 if (arg ==
"REFRESH") {
50 printf(
"Send model again\n");
51 model->fButtonText =
Form(
"Custom button %d", ++sendcnt);
53 window->Send(connid, std::string(
"MODEL:") +
json.Data());
54 }
else if (arg.find(
"MODEL:") == 0) {
56 auto m = TBufferJSON::FromJSON<TestPanelModel>(arg.substr(6));
58 printf(
"New model, selected: %s\n",
m->fSelectId.c_str());
61 printf(
"Fail to decode model: %s\n", arg.c_str());
69 model = std::make_unique<TestPanelModel>();
70 model->fSampleText =
"This is openui5 widget";
71 model->fComboItems = {{
"item1",
"Text 1"}, {
"item2",
"Text 2"}, {
"item3",
"Text 3"}, {
"item4",
"Text 4"}};
72 model->fSelectId =
"item2";
73 model->fButtonText =
"Custom button";
81 window->SetPanelName(
"localapp.view.TestPanel");
89 window->SetCallBacks(ProcessConnection, ProcessData, ProcessCloseConnection);
91 window->SetGeometry(400, 500);
char * Form(const char *fmt,...)
static std::shared_ptr< RWebWindow > Create()
Create new RWebWindow Using default RWebWindowsManager.
static TString ToJSON(const T *obj, Int_t compact=0, const char *member_name=nullptr)
basic_json< std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, double, std::allocator, adl_serializer, std::vector< std::uint8_t > > json