easy_gui::Tabs tabs;
easy_gui::CheckboxGroup flags;
easy_gui::HsvPicker picker;
easy_gui::Theme theme;
easy_gui::BoxLayout layout;
uint binding=0,themeIndex=0;
easy_gui::ScrollPanel scroll;
array<string> pages={"General","Color","Theme"};
array<string> themes={"Dark","Light","Minimal"};
array<string> labels={"Show labels","Show counters","Compact view"};
void on_load(){
tabs.index=easy_gui::load_uint("tab",0);
flags.values.resize(3);
for(uint i=0;i<3;i++)flags.values[i]=easy_gui::load_uint("flag-"+i,0)!=0;
picker.hue=easy_ui::bounded(float(easy_gui::load_uint("hue",28)),0,360,28);
picker.saturation=easy_ui::bounded(float(easy_gui::load_uint("saturation",70)),0,100,70)/100;
picker.value=easy_ui::bounded(float(easy_gui::load_uint("brightness",100)),0,100,100)/100;
picker.alpha=easy_ui::bounded(float(easy_gui::load_uint("alpha",255)),0,255,255);
binding=easy_gui::load_uint("binding",0);if(binding>254)binding=0;
themeIndex=easy_gui::load_uint("theme-index",0);if(themeIndex>2)themeIndex=0;
theme.preset(themeIndex);theme.load("theme");
}
void on_frame(){
theme.apply();
render::text(24,18,"Easy / GUI panel",theme.accent);
tabs.draw("tabs",pages,24,48,360);
if(tabs.index==0){
flags.draw("flags",labels,24,92,360);
layout.begin(16,208,376,2);
vec2 p=layout.place(1,32);binding=ui::keybind("binding","Key",binding,p.x,p.y,layout.placedWidth,layout.placedHeight);
p=layout.place(1,32);if(ui::button("clear-binding","Clear key",p.x,p.y,layout.placedWidth,layout.placedHeight))binding=0;
}else if(tabs.index==1)picker.draw("picker",24,92,360);
else {
scroll.begin("theme-scroll",300,24,92,360,240);
float top=92-scroll.offset;
uint next=ui::cycle("theme-preset",themes[themeIndex],themeIndex,3,24,top,360,32);
if(next!=themeIndex){themeIndex=next;theme.preset(themeIndex);}
if(ui::button("theme-accent","Use HSV color as accent",24,top+44,360,32))theme.accent=picker.color();
render::text(24,top+100,"Custom theme / five RGBA colors",theme.text);
if(ui::button("reset-theme","Reset selected preset",24,top+264,360,32))theme.preset(themeIndex);
scroll.end();
}
if(gui::enabled()){
gui::set("tab",""+tabs.index);gui::set("hue",""+uint(picker.hue));
gui::set("saturation",""+uint(picker.saturation*100+0.5f));
gui::set("brightness",""+uint(picker.value*100+0.5f));gui::set("alpha",""+uint(picker.alpha));
gui::set("binding",""+binding);gui::set("theme-index",""+themeIndex);theme.save("theme");
for(uint i=0;i<3;i++)gui::set("flag-"+i,flags.values[i]?"1":"0");
}
render::text(24,354,gui::enabled()?"GUI state saves automatically":"Temporary state / storage not granted",theme.text);
}
Easy Universal / Примеры и шаблоны