#include "xwidgets/xslider.hpp"
xw::slider<double> slider;
slider // If the semicolon is ommitted in the last line, the return value is displayed.
slider.value = 20; // Modifying properties of widgets triggers the update of the frontend.
slider.value() // Reading the value requires using the call operator
// changine some more properties
slider.max = 40;
slider.style().handle_color = "blue";
slider.orientation = "vertical";
slider.description = "A slider";
#include "xcpp/xdisplay.hpp"
using xcpp::display;
display(slider); // xcpp::display can be called to explicitely trigger a the display of an object.
auto other_slider = xw::slider<double>::initialize()
.min(-1.0)
.max(1.0)
.description("Another slider")
.finalize();
display(other_slider);
#include "xwidgets/xprogress.hpp"
xw::progress<double> progress;
progress
progress.value = 60;
progress.style().bar_color = "red";
progress.description = "Completion";
progress.style().description_width = "30px"
#include "xwidgets/xnumeral.hpp"
xw::numeral<double> numeral;
numeral
numeral.value = 4
numeral.value()
#include "xwidgets/xplay.hpp"
xw::play play;
play
#include "xwidgets/xcheckbox.hpp"
xw::checkbox checkbox;
checkbox
checkbox.value = true;
checkbox.indent = false;
#include "xwidgets/xtogglebutton.hpp"
xw::togglebutton toggle;
toggle
toggle.value = true;
toggle.description = "toggle";
#include "xwidgets/xvalid.hpp"
xw::valid valid;
valid
valid.value = true;
#include "xwidgets/xlabel.hpp"
xw::label label;
label
label.value = "Some caption";
#include "xwidgets/xhtml.hpp"
xw::html html;
html.value = R"xhtml(
<div style="
width: 50%;
height: 100px;
background: #323;
color: white;
text-align: center;"
>Some HTML
</div>
)xhtml";
html
#include <iostream>
#include "xwidgets/xtext.hpp"
xw::text text;
text.value = "Some text";
text
void submit_callback()
{
std::cout << "submitted" << std::endl;
}
text.on_submit(submit_callback);
#include "xwidgets/xtextarea.hpp"
xw::textarea textarea;
textarea.value = R"textarea(Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est laborum.
)textarea";
textarea
#include "xwidgets/xpassword.hpp"
xw::password password;
password
#include <iostream>
#include "xwidgets/xbutton.hpp"
xw::button bt;
void foo()
{
std::cout << "Clicked!" << std::endl;
}
bt.on_click(foo);
bt
bt.description = "button";
bt.button_style = "success";
bt.button_style = "some invalid value"; // values are validated upon assignment
std::cout << bt.button_style();
bt.layout().width = "50%";
bt.layout().height = "200px";
bt.style().button_color = "#888";
xw::button bt_copy = bt;
bt_copy
bt.style().button_color = "red";
bt_copy.style().button_color = "green";
#include "xwidgets/xslider.hpp"
xw::slider<double> slide1;
slide1.value = 4.0;
xw::slider<double> slide2 = slide1;
slide2
#include "xwidgets/xslider.hpp"
#include "xwidgets/xlink.hpp"
#include "xwidgets/xbox.hpp"
xw::slider<double> s1, s2;
s1.description = "Slider 1";
s2.description = "Slider 2";
auto l = xw::link(s1, "value", s2, "value");
s1
s2
xw::slider<double> source, target;
auto dl = xw::directional_link(source, "value", target, "value");
source
target
#include "xwidgets/xbutton.hpp"
#include "xwidgets/xslider.hpp"
#include "xwidgets/xbox.hpp"
xw::vbox b;
xw::slider<double> slid1;
slid1.description = "Slider 1";
xw::slider<double> slid2;
slid2.description = "Slider 2";
b.add(xw::button());
b.add(slid1);
b.add(slid2);
b
b.remove(slid1)
b.clear()
#include "xwidgets/xcontroller.hpp"
xw::controller c
c
#include "xwidgets/xtogglebuttons.hpp"
xw::togglebuttons tb(std::vector<std::string>({"foo", "bar"}), "foo");
tb
tb.value = "bar";
tb._options_labels = std::vector<std::string>({"baz", "taz"});
#include "xwidgets/xdropdown.hpp"
xw::dropdown dd(std::vector<std::string>({"foo", "bar"}), "foo");
dd
#include "xwidgets/xradiobuttons.hpp"
xw::radiobuttons rb(std::vector<std::string>({"foo", "bar"}), "foo");
rb
#include "xwidgets/xselect.hpp"
xw::select sel(std::vector<std::string>({"foo", "bar"}), "foo");
sel
sel.rows = 3
#include "xwidgets/xselectionslider.hpp"
xw::selectionslider sslid(std::vector<std::string>({"foo", "bar", "baz", "taz"}), "foo");
sslid
#include "xwidgets/xselect.hpp"
xw::select_multiple mul_sel(std::vector<std::string>({"foo", "bar"}));
mul_sel
mul_sel.value()
mul_sel.value = std::vector<std::string>();
#include "xwidgets/xselectionslider.hpp"
xw::selection_rangeslider range_sslid(std::vector<std::string>({"foo", "bar", "baz", "taz"}));
range_sslid
range_sslid.value()
#include "xwidgets/xtab.hpp"
#include "xwidgets/xbutton.hpp"
#include "xwidgets/xslider.hpp"
xw::tab tabs;
xw::slider<double> tab_slid;
tabs.add(xw::button());
tabs.add(tab_slid);
tabs
tabs.set_title(0, "zero");
tabs.set_title(1, "one");
#include "xwidgets/xaccordion.hpp"
#include "xwidgets/xbutton.hpp"
xw::accordion accord;
accord.add(xw::button());
accord.add(xw::button());
accord.add(xw::button());
accord
accord.set_title(0, "zero");
accord.set_title(1, "one");
accord.set_title(2, "two");
#include "xwidgets/xcolor_picker.hpp"
xw::color_picker cpicker;
cpicker
cpicker.value = "blue";
cpicker.concise = true;
#include "xwidgets/ximage.hpp"
#include "xwidgets/xvideo.hpp"
#include "xwidgets/xaudio.hpp"
auto im = xw::image_from_file("marie.png").finalize();
im
auto vid1 = xw::video_from_file("Big.Buck.Bunny.mp4").finalize();
vid1
auto vid2 = xw::video_from_url("https://webrtc.github.io/samples/src/video/chrome.webm").finalize();
vid2
auto au = xw::audio_from_file("Big.Buck.Bunny.mp3").finalize();
au
#include "xwidgets/xoutput.hpp"
xw::output out;
out
#include <iostream>
{
// Using a scope guard to enable output capture
auto g = out.guard();
std::cout << "This output is captured." << std::endl;
}
#include <xcpp/xdisplay.hpp>
{
// Using a scope guard to clear output widget
auto g = out.guard();
xcpp::clear_output();
}