diff --git a/docs/source/embed_widgets/xleaflet_example.ipynb b/docs/source/embed_widgets/xleaflet_example.ipynb
index 32130c63..be220476 100644
--- a/docs/source/embed_widgets/xleaflet_example.ipynb
+++ b/docs/source/embed_widgets/xleaflet_example.ipynb
@@ -1,52 +1,52 @@
{
- "cells": [
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xhtml.hpp\"\n",
- "\n",
- "#include \"xleaflet/xmap.hpp\"\n",
- "#include \"xleaflet/xmarker.hpp\"\n",
- "\n",
- "auto html = xw::html::initialize()\n",
- " .value(\"Hello from an xwidget in an xmarker!\")\n",
- " .finalize();\n",
- "\n",
- "std::array center = {52.204793, 360.121558};\n",
- "\n",
- "auto map = xlf::map::initialize()\n",
- " .center(center)\n",
- " .zoom(15)\n",
- " .finalize();\n",
- "\n",
- "auto marker = xlf::marker::initialize()\n",
- " .location(center)\n",
- " .draggable(false)\n",
- " .popup(html)\n",
- " .finalize();\n",
- "map.add_layer(marker);\n",
- "\n",
- "map"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "C++14",
- "language": "C++14",
- "name": "xeus-cling-cpp14"
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xhtml.hpp\"\n",
+ "\n",
+ "#include \"xleaflet/xmap.hpp\"\n",
+ "#include \"xleaflet/xmarker.hpp\"\n",
+ "\n",
+ "auto html = xw::html::initialize()\n",
+ " .value(\"Hello from an xwidget in an xmarker!\")\n",
+ " .finalize();\n",
+ "\n",
+ "std::array center = {52.204793, 360.121558};\n",
+ "\n",
+ "auto map = xlf::map::initialize()\n",
+ " .center(center)\n",
+ " .zoom(15)\n",
+ " .finalize();\n",
+ "\n",
+ "auto marker = xlf::marker::initialize()\n",
+ " .location(center)\n",
+ " .draggable(false)\n",
+ " .popup(html)\n",
+ " .finalize();\n",
+ "map.add_layer(marker);\n",
+ "\n",
+ "map"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "C++14",
+ "language": "C++14",
+ "name": "xeus-cling-cpp14"
+ },
+ "language_info": {
+ "version": "14",
+ "codemirror_mode": "text/x-c++src",
+ "file_extension": ".cpp",
+ "mimetype": "text/x-c++src",
+ "name": "c++"
+ }
},
- "language_info": {
- "codemirror_mode": "text/x-c++src",
- "file_extension": ".cpp",
- "mimetype": "text/x-c++src",
- "name": "c++",
- "version": "14"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
+ "nbformat": 4,
+ "nbformat_minor": 2
}
diff --git a/docs/source/embed_widgets/xplot_example.ipynb b/docs/source/embed_widgets/xplot_example.ipynb
index 70577909..627b013d 100644
--- a/docs/source/embed_widgets/xplot_example.ipynb
+++ b/docs/source/embed_widgets/xplot_example.ipynb
@@ -1,79 +1,79 @@
{
- "cells": [
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \n",
- "#include \n",
- "#include \n",
- "\n",
- "#include \"xplot/xfigure.hpp\"\n",
- "#include \"xplot/xmarks.hpp\"\n",
- "#include \"xplot/xaxes.hpp\"\n",
- "\n",
- "auto randn(std::size_t n)\n",
- "{\n",
- " std::vector output(n);\n",
- " std::random_device rd;\n",
- " std::mt19937 gen(rd());\n",
- " std::normal_distribution<> dis(5, 2);\n",
- "\n",
- " std::for_each(output.begin(), output.end(), [&dis, &gen](auto& v){v = dis(gen);});\n",
- "\n",
- " return output;\n",
- "}\n",
- "\n",
- "std::size_t data_size = 200;\n",
- "std::vector data_x(data_size);\n",
- "std::iota(data_x.begin(), data_x.end(), 0);\n",
- "std::vector data_y = randn(data_size);\n",
- "std::vector data_c = randn(data_size);\n",
- "\n",
- "xpl::linear_scale scale_x, scale_y;\n",
- "xpl::linear_scale scale_size;\n",
- "\n",
- "auto scatter = xpl::scatter::initialize(scale_x, scale_y, scale_size)\n",
- " .x(data_x)\n",
- " .y(data_y)\n",
- " .size(data_c)\n",
- " .stroke(\"black\")\n",
- " .default_size(128)\n",
- " .enable_move(true)\n",
- " .colors(std::vector>{\"orangered\"})\n",
- " .finalize();\n",
- "\n",
- "xpl::axis axis_x(scale_x), axis_y(scale_y);\n",
- "axis_x.label = \"x\";\n",
- "axis_y.label = \"y\";\n",
- "axis_y.orientation = \"vertical\";\n",
- "axis_y.side = \"left\";\n",
- "\n",
- "xpl::figure fig;\n",
- "fig.padding_x = 0.025;\n",
- "fig.add_mark(scatter);\n",
- "fig.add_axis(axis_x);\n",
- "fig.add_axis(axis_y);\n",
- "fig"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "C++14",
- "language": "C++14",
- "name": "xeus-cling-cpp14"
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \n",
+ "#include \n",
+ "#include \n",
+ "\n",
+ "#include \"xplot/xfigure.hpp\"\n",
+ "#include \"xplot/xmarks.hpp\"\n",
+ "#include \"xplot/xaxes.hpp\"\n",
+ "\n",
+ "auto randn(std::size_t n)\n",
+ "{\n",
+ " std::vector output(n);\n",
+ " std::random_device rd;\n",
+ " std::mt19937 gen(rd());\n",
+ " std::normal_distribution<> dis(5, 2);\n",
+ "\n",
+ " std::for_each(output.begin(), output.end(), [&dis, &gen](auto& v){v = dis(gen);});\n",
+ "\n",
+ " return output;\n",
+ "}\n",
+ "\n",
+ "std::size_t data_size = 200;\n",
+ "std::vector data_x(data_size);\n",
+ "std::iota(data_x.begin(), data_x.end(), 0);\n",
+ "std::vector data_y = randn(data_size);\n",
+ "std::vector data_c = randn(data_size);\n",
+ "\n",
+ "xpl::linear_scale scale_x, scale_y;\n",
+ "xpl::linear_scale scale_size;\n",
+ "\n",
+ "auto scatter = xpl::scatter::initialize(scale_x, scale_y, scale_size)\n",
+ " .x(data_x)\n",
+ " .y(data_y)\n",
+ " .size(data_c)\n",
+ " .stroke(\"black\")\n",
+ " .default_size(128)\n",
+ " .enable_move(true)\n",
+ " .colors(std::vector>{\"orangered\"})\n",
+ " .finalize();\n",
+ "\n",
+ "xpl::axis axis_x(scale_x), axis_y(scale_y);\n",
+ "axis_x.label = \"x\";\n",
+ "axis_y.label = \"y\";\n",
+ "axis_y.orientation = \"vertical\";\n",
+ "axis_y.side = \"left\";\n",
+ "\n",
+ "xpl::figure fig;\n",
+ "fig.padding_x = 0.025;\n",
+ "fig.add_mark(scatter);\n",
+ "fig.add_axis(axis_x);\n",
+ "fig.add_axis(axis_y);\n",
+ "fig"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "C++14",
+ "language": "C++14",
+ "name": "xeus-cling-cpp14"
+ },
+ "language_info": {
+ "version": "14",
+ "codemirror_mode": "text/x-c++src",
+ "file_extension": ".cpp",
+ "mimetype": "text/x-c++src",
+ "name": "c++"
+ }
},
- "language_info": {
- "codemirror_mode": "text/x-c++src",
- "file_extension": ".cpp",
- "mimetype": "text/x-c++src",
- "name": "c++",
- "version": "14"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
+ "nbformat": 4,
+ "nbformat_minor": 2
}
diff --git a/environment-dev.yml b/environment-dev.yml
index 8a1219c2..786b0f86 100644
--- a/environment-dev.yml
+++ b/environment-dev.yml
@@ -10,7 +10,7 @@ dependencies:
- xeus=3.0.3
- cppzmq
- xproperty=0.11.0
-- nlohmann_json=3.9.1
+- nlohmann_json
# Test dependencies
- doctest >= 2.4.6
- json_schema_validator
diff --git a/notebooks/xwidgets.ipynb b/notebooks/xwidgets.ipynb
index 51849476..894c0952 100644
--- a/notebooks/xwidgets.ipynb
+++ b/notebooks/xwidgets.ipynb
@@ -1,1674 +1,1674 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Numerical widgets"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Defining a Slider Widget"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xslider.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::slider slider;\n",
- "\n",
- "slider // If the semicolon is ommitted in the last line, the return value is displayed."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "slider.value = 20; // Modifying properties of widgets triggers the update of the frontend."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "slider.value() // Reading the value requires using the call operator"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "// changine some more properties\n",
- "slider.max = 40;\n",
- "slider.style().handle_color = \"blue\";\n",
- "slider.orientation = \"vertical\";\n",
- "slider.description = \"A slider\";"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xcpp/xdisplay.hpp\"\n",
- "\n",
- "using xcpp::display;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "display(slider); // xcpp::display can be called to explicitely trigger a the display of an object."
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Using operator chaining to mimic keyword arguments"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "auto other_slider = xw::slider::initialize()\n",
- " .min(-1.0)\n",
- " .max(1.0)\n",
- " .description(\"Another slider\")\n",
- " .finalize();\n",
- "\n",
- "display(other_slider);"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Progress"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xprogress.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::progress progress;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "progress"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "progress.value = 60;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "progress.style().bar_color = \"red\";"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "progress.description = \"Completion\";"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "progress.style().description_width = \"30px\""
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Numerical input"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xnumber.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::number number;\n",
- "number"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "number.value = 4"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "number.value()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xnumber_bounded.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::number_bounded number_bounded;\n",
- "number_bounded"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "number_bounded.max = 10;\n",
- "number_bounded.value = 13"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "number_bounded.value()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Timer"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xplay.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::play play;\n",
- "play"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Boolean widgets"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Checkbox"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xcheckbox.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::checkbox checkbox;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "checkbox"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "checkbox.value = true;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "checkbox.indent = false;"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Toggle button"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xtogglebutton.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::togglebutton toggle;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "toggle"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "toggle.value = true;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "toggle.description = \"toggle\";"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Valid check"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xvalid.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::valid valid;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "valid"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "valid.value = true;"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# String widgets"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Label widget"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xlabel.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::label label;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "label"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "label.value = \"Some caption\";"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## HTML widget"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xhtml.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::html html;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "html.value = R\"xhtml(\n",
- " Some HTML\n",
- "
\n",
- ")xhtml\";\n",
- "html"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Text widget"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \n",
- "#include \"xwidgets/xtext.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::text text;\n",
- "text.value = \"Some text\";\n",
- "text"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "void submit_callback()\n",
- "{\n",
- " std::cout << \"submitted\" << std::endl;\n",
- "}"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "text.on_submit(submit_callback);"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Textarea widget"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xtextarea.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::textarea textarea;\n",
- "textarea.value = R\"textarea(Lorem ipsum dolor sit amet, consectetur \n",
- "adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore\n",
- "magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco\n",
- "laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor\n",
- "in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla \n",
- "pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa \n",
- "qui officia deserunt mollit anim id est laborum.\n",
- ")textarea\";\n",
- "textarea"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Password widget"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xpassword.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::password password;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "password"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Button widget"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \n",
- "#include \"xwidgets/xbutton.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::button bt;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "void foo()\n",
- "{\n",
- " std::cout << \"Clicked!\" << std::endl;\n",
- "}"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "bt.on_click(foo);\n",
- " \n",
- "bt"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "bt.description = \"button\";"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "bt.button_style = \"success\";"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "try {\n",
- " bt.button_style = \"some invalid value\"; // values are validated upon assignment\n",
- "}\n",
- "catch(std::exception const& btn_exception)\n",
- "{\n",
- " std::cerr << btn_exception.what();\n",
- "}"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "std::cout << bt.button_style();"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "collapsed": true
- },
- "source": [
- "# Widgets layout"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "bt.layout().width = \"50%\";\n",
- "bt.layout().height = \"200px\";"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "bt.style().button_color = \"#888\";"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Value semantics"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::button bt_copy = bt;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "bt_copy"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "bt.style().button_color = \"red\";\n",
- "bt_copy.style().button_color = \"green\";"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xslider.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::slider slide1;\n",
- "slide1.value = 4.0;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::slider slide2 = slide1;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "slide2"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "collapsed": true
- },
- "source": [
- "# Link widget"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xslider.hpp\"\n",
- "#include \"xwidgets/xlink.hpp\"\n",
- "#include \"xwidgets/xbox.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::slider s1, s2;\n",
- "\n",
- "s1.description = \"Slider 1\";\n",
- "s2.description = \"Slider 2\";"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "auto l = xw::link(s1, \"value\", s2, \"value\");"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "s1"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "s2"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::slider source, target;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "auto dl = xw::directional_link(source, \"value\", target, \"value\");"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "source"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "target"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Box widgets"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xbutton.hpp\"\n",
- "#include \"xwidgets/xslider.hpp\"\n",
- "#include \"xwidgets/xbox.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::vbox b;\n",
- "xw::slider slid1;\n",
- "slid1.description = \"Slider 1\";\n",
- "xw::slider slid2;\n",
- "slid2.description = \"Slider 2\";"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "b.add(xw::button());\n",
- "b.add(slid1);\n",
- "b.add(slid2);"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "b"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "b.remove(slid1)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "b.clear()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Controller"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xcontroller.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::controller c"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "c"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Selection widgets"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Toggle buttons"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xtogglebuttons.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::togglebuttons tb(std::vector({\"foo\", \"bar\"}), \"foo\");"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "tb"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "tb.value = \"bar\";"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "tb._options_labels = std::vector({\"baz\", \"taz\"});"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Dropdown"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xdropdown.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::dropdown dd(std::vector({\"foo\", \"bar\"}), \"foo\");"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "dd"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## RadioButtons"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xradiobuttons.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::radiobuttons rb(std::vector({\"foo\", \"bar\"}), \"foo\");"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "rb"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "collapsed": true
- },
- "source": [
- "## Select"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xselect.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::select sel(std::vector({\"foo\", \"bar\"}), \"foo\");"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "sel"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "sel.rows = 3"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Selection slider"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xselectionslider.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::selectionslider sslid(std::vector({\"foo\", \"bar\", \"baz\", \"taz\"}), \"foo\");"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "sslid"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "collapsed": true
- },
- "source": [
- "## Multiple Select"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xselect.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::select_multiple mul_sel(std::vector({\"foo\", \"bar\"}));"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "mul_sel"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "mul_sel.value()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "mul_sel.value = std::vector();"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Selection range slider"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xselectionslider.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::selection_rangeslider range_sslid(std::vector({\"foo\", \"bar\", \"baz\", \"taz\"}));"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "range_sslid"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "range_sslid.value()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "collapsed": true
- },
- "source": [
- "# Selection Containers"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Tabs"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xtab.hpp\"\n",
- "#include \"xwidgets/xbutton.hpp\"\n",
- "#include \"xwidgets/xslider.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::tab tabs;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::slider tab_slid;\n",
- "tabs.add(xw::button());\n",
- "tabs.add(tab_slid);"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "tabs"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "tabs.set_title(0, \"zero\");\n",
- "tabs.set_title(1, \"one\");"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Accordion"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xaccordion.hpp\"\n",
- "#include \"xwidgets/xbutton.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::accordion accord;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "accord.add(xw::button());\n",
- "accord.add(xw::button());\n",
- "accord.add(xw::button());"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "accord"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "accord.set_title(0, \"zero\");\n",
- "accord.set_title(1, \"one\");\n",
- "accord.set_title(2, \"two\");"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "collapsed": true
- },
- "source": [
- "# Color picker"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xcolor_picker.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::color_picker cpicker;"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "cpicker"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "cpicker.value = \"blue\";"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "cpicker.concise = true;"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Media"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/ximage.hpp\"\n",
- "#include \"xwidgets/xvideo.hpp\"\n",
- "#include \"xwidgets/xaudio.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "auto im = xw::image_from_file(\"marie.png\").finalize();\n",
- "im"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "auto vid1 = xw::video_from_file(\"Big.Buck.Bunny.mp4\").finalize();\n",
- "vid1"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "auto vid2 = xw::video_from_url(\"https://webrtc.github.io/samples/src/video/chrome.webm\").finalize();\n",
- "vid2"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "auto au = xw::audio_from_file(\"Big.Buck.Bunny.mp3\").finalize();\n",
- "au"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Output"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include \"xwidgets/xoutput.hpp\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "xw::output out;\n",
- "out"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include "
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "{\n",
- " // Using a scope guard to enable output capture\n",
- " auto g = out.guard();\n",
- " std::cout << \"This output is captured.\" << std::endl;\n",
- "}"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#include "
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "{\n",
- " // Using a scope guard to clear output widget\n",
- " auto g = out.guard();\n",
- " xcpp::clear_output();\n",
- "}"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "C++14",
- "language": "C++14",
- "name": "xcpp14"
- },
- "language_info": {
- "codemirror_mode": "text/x-c++src",
- "file_extension": ".cpp",
- "mimetype": "text/x-c++src",
- "name": "c++",
- "version": "14"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Numerical widgets"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Defining a Slider Widget"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xslider.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::slider slider;\n",
+ "\n",
+ "slider // If the semicolon is ommitted in the last line, the return value is displayed."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "slider.value = 20; // Modifying properties of widgets triggers the update of the frontend."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "slider.value() // Reading the value requires using the call operator"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "// changine some more properties\n",
+ "slider.max = 40;\n",
+ "slider.style().handle_color = \"blue\";\n",
+ "slider.orientation = \"vertical\";\n",
+ "slider.description = \"A slider\";"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xcpp/xdisplay.hpp\"\n",
+ "\n",
+ "using xcpp::display;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "display(slider); // xcpp::display can be called to explicitely trigger a the display of an object."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Using operator chaining to mimic keyword arguments"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "auto other_slider = xw::slider::initialize()\n",
+ " .min(-1.0)\n",
+ " .max(1.0)\n",
+ " .description(\"Another slider\")\n",
+ " .finalize();\n",
+ "\n",
+ "display(other_slider);"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Progress"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xprogress.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::progress progress;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "progress"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "progress.value = 60;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "progress.style().bar_color = \"red\";"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "progress.description = \"Completion\";"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "progress.style().description_width = \"30px\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Numerical input"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xnumber.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::number number;\n",
+ "number"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "number.value = 4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "number.value()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xnumber_bounded.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::number_bounded number_bounded;\n",
+ "number_bounded"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "number_bounded.max = 10;\n",
+ "number_bounded.value = 13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "number_bounded.value()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Timer"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xplay.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::play play;\n",
+ "play"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Boolean widgets"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Checkbox"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xcheckbox.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::checkbox checkbox;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "checkbox"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "checkbox.value = true;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "checkbox.indent = false;"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Toggle button"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xtogglebutton.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::togglebutton toggle;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "toggle"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "toggle.value = true;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "toggle.description = \"toggle\";"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Valid check"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xvalid.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::valid valid;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "valid"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "valid.value = true;"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# String widgets"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Label widget"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xlabel.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::label label;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "label"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "label.value = \"Some caption\";"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## HTML widget"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xhtml.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::html html;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "html.value = R\"xhtml(\n",
+ " Some HTML\n",
+ "
\n",
+ ")xhtml\";\n",
+ "html"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Text widget"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \n",
+ "#include \"xwidgets/xtext.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::text text;\n",
+ "text.value = \"Some text\";\n",
+ "text"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "void submit_callback()\n",
+ "{\n",
+ " std::cout << \"submitted\" << std::endl;\n",
+ "}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "text.on_submit(submit_callback);"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Textarea widget"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xtextarea.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::textarea textarea;\n",
+ "textarea.value = R\"textarea(Lorem ipsum dolor sit amet, consectetur \n",
+ "adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore\n",
+ "magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco\n",
+ "laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor\n",
+ "in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla \n",
+ "pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa \n",
+ "qui officia deserunt mollit anim id est laborum.\n",
+ ")textarea\";\n",
+ "textarea"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Password widget"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xpassword.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::password password;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "password"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Button widget"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \n",
+ "#include \"xwidgets/xbutton.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::button bt;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "void foo()\n",
+ "{\n",
+ " std::cout << \"Clicked!\" << std::endl;\n",
+ "}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "bt.on_click(foo);\n",
+ " \n",
+ "bt"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "bt.description = \"button\";"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "bt.button_style = \"success\";"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "try {\n",
+ " bt.button_style = \"some invalid value\"; // values are validated upon assignment\n",
+ "}\n",
+ "catch(std::exception const& btn_exception)\n",
+ "{\n",
+ " std::cerr << btn_exception.what();\n",
+ "}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "std::cout << bt.button_style();"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "# Widgets layout"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "bt.layout().width = \"50%\";\n",
+ "bt.layout().height = \"200px\";"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "bt.style().button_color = \"#888\";"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Value semantics"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::button bt_copy = bt;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "bt_copy"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "bt.style().button_color = \"red\";\n",
+ "bt_copy.style().button_color = \"green\";"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xslider.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::slider slide1;\n",
+ "slide1.value = 4.0;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::slider slide2 = slide1;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "slide2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "# Link widget"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xslider.hpp\"\n",
+ "#include \"xwidgets/xlink.hpp\"\n",
+ "#include \"xwidgets/xbox.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::slider s1, s2;\n",
+ "\n",
+ "s1.description = \"Slider 1\";\n",
+ "s2.description = \"Slider 2\";"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "auto l = xw::link(s1, \"value\", s2, \"value\");"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "s1"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "s2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::slider source, target;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "auto dl = xw::directional_link(source, \"value\", target, \"value\");"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "source"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "target"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Box widgets"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xbutton.hpp\"\n",
+ "#include \"xwidgets/xslider.hpp\"\n",
+ "#include \"xwidgets/xbox.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::vbox b;\n",
+ "xw::slider slid1;\n",
+ "slid1.description = \"Slider 1\";\n",
+ "xw::slider slid2;\n",
+ "slid2.description = \"Slider 2\";"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "b.add(xw::button());\n",
+ "b.add(slid1);\n",
+ "b.add(slid2);"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "b"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "b.remove(slid1)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "b.clear()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Controller"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xcontroller.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::controller c"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "c"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Selection widgets"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Toggle buttons"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xtogglebuttons.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::togglebuttons tb(std::vector({\"foo\", \"bar\"}), \"foo\");"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "tb"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "tb.value = \"bar\";"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "tb._options_labels = std::vector({\"baz\", \"taz\"});"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Dropdown"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xdropdown.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::dropdown dd(std::vector({\"foo\", \"bar\"}), \"foo\");"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "dd"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## RadioButtons"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xradiobuttons.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::radiobuttons rb(std::vector({\"foo\", \"bar\"}), \"foo\");"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "rb"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "## Select"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xselect.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::select sel(std::vector({\"foo\", \"bar\"}), \"foo\");"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "sel"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "sel.rows = 3"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Selection slider"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xselectionslider.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::selectionslider sslid(std::vector({\"foo\", \"bar\", \"baz\", \"taz\"}), \"foo\");"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "sslid"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "## Multiple Select"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xselect.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::select_multiple mul_sel(std::vector({\"foo\", \"bar\"}));"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "mul_sel"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "mul_sel.value()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "mul_sel.value = std::vector();"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Selection range slider"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xselectionslider.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::selection_rangeslider range_sslid(std::vector({\"foo\", \"bar\", \"baz\", \"taz\"}));"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "range_sslid"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "range_sslid.value()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "# Selection Containers"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Tabs"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xtab.hpp\"\n",
+ "#include \"xwidgets/xbutton.hpp\"\n",
+ "#include \"xwidgets/xslider.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::tab tabs;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::slider tab_slid;\n",
+ "tabs.add(xw::button());\n",
+ "tabs.add(tab_slid);"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "tabs"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "tabs.set_title(0, \"zero\");\n",
+ "tabs.set_title(1, \"one\");"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Accordion"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xaccordion.hpp\"\n",
+ "#include \"xwidgets/xbutton.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::accordion accord;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "accord.add(xw::button());\n",
+ "accord.add(xw::button());\n",
+ "accord.add(xw::button());"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "accord"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "accord.set_title(0, \"zero\");\n",
+ "accord.set_title(1, \"one\");\n",
+ "accord.set_title(2, \"two\");"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "# Color picker"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xcolor_picker.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::color_picker cpicker;"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "cpicker"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "cpicker.value = \"blue\";"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "cpicker.concise = true;"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Media"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/ximage.hpp\"\n",
+ "#include \"xwidgets/xvideo.hpp\"\n",
+ "#include \"xwidgets/xaudio.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "auto im = xw::image_from_file(\"marie.png\").finalize();\n",
+ "im"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "auto vid1 = xw::video_from_file(\"Big.Buck.Bunny.mp4\").finalize();\n",
+ "vid1"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "auto vid2 = xw::video_from_url(\"https://webrtc.github.io/samples/src/video/chrome.webm\").finalize();\n",
+ "vid2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "auto au = xw::audio_from_file(\"Big.Buck.Bunny.mp3\").finalize();\n",
+ "au"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Output"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include \"xwidgets/xoutput.hpp\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "xw::output out;\n",
+ "out"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "{\n",
+ " // Using a scope guard to enable output capture\n",
+ " auto g = out.guard();\n",
+ " std::cout << \"This output is captured.\" << std::endl;\n",
+ "}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#include "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "{\n",
+ " // Using a scope guard to clear output widget\n",
+ " auto g = out.guard();\n",
+ " xcpp::clear_output();\n",
+ "}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "C++14",
+ "language": "C++14",
+ "name": "xcpp14"
+ },
+ "language_info": {
+ "version": "14",
+ "codemirror_mode": "text/x-c++src",
+ "file_extension": ".cpp",
+ "mimetype": "text/x-c++src",
+ "name": "c++"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
}