1#ifdef NANOGUI_PYTHON
2
3#include "python.h"
4
5typedef IntBox<int64_t> Int64Box;
6
7void register_formhelper(py::module &m) {
8 enum DummyEnum { };
9
10 py::class_<FormHelper>(m, "FormHelper", D(FormHelper))
11 .def(py::init<Screen *>(), D(FormHelper, FormHelper))
12 .def("addWindow", &FormHelper::addWindow, py::arg("pos"),
13 py::arg("title") = std::string("Untitled"),
14 D(FormHelper, addWindow))
15 .def("addGroup", &FormHelper::addGroup, D(FormHelper, addGroup))
16 .def("addButton", &FormHelper::addButton, py::arg("label"),
17 py::arg("cb"), D(FormHelper, addGroup))
18 .def("addBoolVariable",
19 [](FormHelper &h, const std::string &label,
20 const std::function<void(const bool &) > &setter,
21 const std::function<bool(void) > &getter, bool editable) -> CheckBox* {
22 return h.addVariable(label, setter, getter, editable);
23 },
24 py::arg("label"), py::arg("setter"), py::arg("getter"),
25 py::arg("editable") = true)
26 .def("addIntVariable",
27 [](FormHelper &h, const std::string &label,
28 const std::function<void(const int64_t &) > &setter,
29 const std::function<int64_t(void) > &getter, bool editable) -> Int64Box* {
30 return h.addVariable(label, setter, getter, editable);
31 },
32 py::arg("label"), py::arg("setter"), py::arg("getter"),
33 py::arg("editable") = true)
34 .def("addDoubleVariable",
35 [](FormHelper &h, const std::string &label,
36 const std::function<void(const double &) > &setter,
37 const std::function<double(void) > &getter, bool editable) -> FloatBox<double>* {
38 return h.addVariable(label, setter, getter, editable);
39 },
40 py::arg("label"), py::arg("setter"), py::arg("getter"),
41 py::arg("editable") = true)
42 .def("addStringVariable",
43 [](FormHelper &h, const std::string &label,
44 const std::function<void(const std::string &) > &setter,
45 const std::function<std::string(void) > &getter, bool editable) -> TextBox* {
46 return h.addVariable(label, setter, getter, editable);
47 },
48 py::arg("label"), py::arg("setter"), py::arg("getter"),
49 py::arg("editable") = true)
50 .def("addColorVariable",
51 [](FormHelper &h, const std::string &label,
52 const std::function<void(const Color &) > &setter,
53 const std::function<Color(void) > &getter, bool editable) -> ColorPicker* {
54 return h.addVariable(label, setter, getter, editable);
55 },
56 py::arg("label"), py::arg("setter"), py::arg("getter"),
57 py::arg("editable") = true)
58 .def("addEnumVariable",
59 [](FormHelper &h, const std::string &label,
60 const std::function<void(const int &) > &setter,
61 const std::function<int(void) > &getter, bool editable) -> ComboBox* {
62 return h.addVariable(label,
63 reinterpret_cast<const std::function<void(const DummyEnum &)>&>(setter),
64 reinterpret_cast<const std::function<DummyEnum(void)>&>(getter),
65 editable);
66 },
67 py::arg("label"), py::arg("setter"), py::arg("getter"),
68 py::arg("editable") = true)
69 .def("addWidget", &FormHelper::addWidget, D(FormHelper, addWidget))
70 .def("refresh", &FormHelper::refresh, D(FormHelper, refresh))
71 .def("window", &FormHelper::window, D(FormHelper, window))
72 .def("setWindow", &FormHelper::setWindow, D(FormHelper, setWindow))
73 .def("fixedSize", &FormHelper::fixedSize, D(FormHelper, fixedSize))
74 .def("setFixedSize", &FormHelper::setFixedSize, D(FormHelper, setFixedSize))
75 .def("groupFontName", &FormHelper::groupFontName, D(FormHelper, groupFontName))
76 .def("setGroupFontName", &FormHelper::setGroupFontName, D(FormHelper, setGroupFontName))
77 .def("labelFontName", &FormHelper::labelFontName, D(FormHelper, labelFontName))
78 .def("setLabelFontName", &FormHelper::setLabelFontName, D(FormHelper, setLabelFontName))
79 .def("groupFontSize", &FormHelper::groupFontSize, D(FormHelper, groupFontSize))
80 .def("setGroupFontSize", &FormHelper::setGroupFontSize, D(FormHelper, setGroupFontSize))
81 .def("labelFontSize", &FormHelper::labelFontSize, D(FormHelper, labelFontSize))
82 .def("setLabelFontSize", &FormHelper::setLabelFontSize, D(FormHelper, setLabelFontSize))
83 .def("widgetFontSize", &FormHelper::widgetFontSize, D(FormHelper, widgetFontSize))
84 .def("setWidgetFontSize", &FormHelper::setWidgetFontSize, D(FormHelper, setWidgetFontSize));
85}
86#endif
87