165 if(widget_state == enable) {
182 const std::string&
id()
const
243 template <
class T,
class W,
class CT>
264 const bool mandatory,
265 const std::function<T()>& callback_load_value,
266 const std::function<
void(CT)>& callback_save_value)
273 static_assert(!std::is_same_v<styled_widget, W>,
"Second template argument cannot be styled_widget");
290 field(
const std::string&
id,
const bool mandatory, T& linked_variable)
293 ,
link_(linked_variable)
297 static_assert(!std::is_same_v<styled_widget, W>,
"Second template argument cannot be styled_widget");
317 field(
const std::string&
id,
const bool mandatory,
const T& value)
324 static_assert(std::is_same_v<styled_widget, W>,
"Second template argument must be styled_widget");
446 throw std::runtime_error(
"Mandatory field widget is null");
455 void save(
const bool must_be_active)
459 if(!must_be_active ||
get_widget()->get_active()) {
460 if constexpr(std::is_same_v<W, styled_widget>) {
462 }
else if constexpr(std::is_same_v<W, selectable_item>) {
477 if constexpr(std::is_same_v<W, styled_widget>) {
491 const bool mandatory,
492 const std::function<
bool()>& callback_load_value,
493 const std::function<
void(
const bool)>& callback_save_value,
494 const std::function<
void(
widget&)>& callback_change,
495 const bool initial_fire)
497 id, mandatory, callback_load_value, callback_save_value)
504 const bool mandatory,
505 bool& linked_variable,
506 const std::function<
void(
widget&)>& callback_change,
507 const bool initial_fire)
539 const bool mandatory,
540 const std::function<std::string()>& callback_load_value,
541 const std::function<
void(
const std::string&)>&
544 id, mandatory, callback_load_value, callback_save_value)
549 const bool mandatory,
550 std::string& linked_variable)
552 id, mandatory, linked_variable)
561 widget->save_to_history();
571 const bool mandatory,
572 const std::string& text,
573 const bool use_markup)
Abstract base class for the fields.
void widget_finalize()
Finalizes the widget.
void widget_init()
Initializes the widget.
styled_widget * get_widget()
virtual void init_specialized()
See widget_init.
const std::string id_
The id field of the widget, should be unique in a window.
field_base(const std::string &id, const bool mandatory)
Constructor.
virtual void init_generic()=0
See widget_init.
const std::string & id() const
virtual void finalize_specialized()
See widget_finalize.
const styled_widget * get_widget() const
const bool mandatory_
Is the widget optional or mandatory in this window.
void detach_from_window()
Detaches the field from a window.
virtual void widget_restore()=0
Restores a widget.
void widget_set_enabled(const bool enable, const bool sync)
Enables a widget.
void attach_to_window(window &window)
Attaches the field to a window.
styled_widget * widget_
The widget attached to the field.
virtual void widget_save()=0
Saves a widget.
virtual void finalize_generic()=0
See widget_finalize.
bool is_mandatory() const
Specialized field class for boolean.
field_bool(const std::string &id, const bool mandatory, const std::function< bool()> &callback_load_value, const std::function< void(const bool)> &callback_save_value, const std::function< void(widget &)> &callback_change, const bool initial_fire)
field_bool(const std::string &id, const bool mandatory, bool &linked_variable, const std::function< void(widget &)> &callback_change, const bool initial_fire)
std::function< void(widget &)> callback_change_
void init_specialized()
Overridden from field_base.
Specialized field class for a styled_widget, used for labels and images.
bool use_markup_
Whether or not the label uses markup.
void init_specialized()
Overridden from field_base.
field_label(const std::string &id, const bool mandatory, const std::string &text, const bool use_markup)
Specialized field class for text.
field_text(const std::string &id, const bool mandatory, std::string &linked_variable)
field_text(const std::string &id, const bool mandatory, const std::function< std::string()> &callback_load_value, const std::function< void(const std::string &)> &callback_save_value)
void finalize_specialized()
Overridden from field_base.
Template class to implement the generic field implementation.
void widget_save()
Inherited from field_base.
void widget_restore()
Inherited from field_base.
void init_generic()
Inherited from field_base.
void set_widget_value(CT value)
Sets the value of the field.
void save(const bool must_be_active)
Stores the value in the widget in the interval value_.
field(const std::string &id, const bool mandatory, const T &value)
Constructor.
T & link_
The variable linked to the field.
T value_
The value_ of the widget, this value is also available once the widget is destroyed.
field(const std::string &id, const bool mandatory, const std::function< T()> &callback_load_value, const std::function< void(CT)> &callback_save_value)
Constructor.
void validate_widget()
Test whether the widget exists if the widget is mandatory.
void set_cache_value(CT value)
Sets the value of the field.
std::function< void(CT)> callback_save_value_
The callback function to save the value.
void finalize_generic()
Inherited from field_base.
field(const std::string &id, const bool mandatory, T &linked_variable)
Constructor.
T get_widget_value()
Gets the value of the field.
void restore()
Stores the internal value_ in the widget.
std::function< T()> callback_load_value_
The callback function to load the value.
Small abstract helper class.
Abstract base class for text items.
A widget that allows the user to input text in single line.
base class of top level items, the only item which needs to store the final canvases to draw on.
Contains all forward declarations for field.hpp.
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.