Inkscape
Vector Graphics Editor
|
SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMenu), and allows entry of both '. More...
#include <spinbutton.h>
Public Types | |
using | NumericMenuData = std::map< double, Glib::ustring > |
Public Member Functions | |
template<typename ... Args> | |
SpinButton (Args &&...args) | |
SpinButton (BaseObjectType *cobject, Glib::RefPtr< Gtk::Builder > const &) | |
~SpinButton () override | |
void | setUnitMenu (UnitMenu *unit_menu) |
void | addUnitTracker (UnitTracker *ut) |
void | set_zeroable (const bool zeroable=true) |
void | set_oneable (const bool oneable=true) |
bool | get_zeroable () const |
bool | get_oneable () const |
void | defocus () |
void | set_increment (double delta) |
void | setDefocusTarget (decltype(_defocus_target) target) |
void | set_dont_evaluate (bool flag) |
void | set_custom_numeric_menu_data (NumericMenuData &&custom_menu_data) |
Private Member Functions | |
void | _construct () |
int | on_input (double &newvalue) |
This callback function should try to convert the entered text to a number and write it to newvalue. | |
bool | on_key_pressed (Gtk::EventControllerKey const &controller, unsigned keyval, unsigned keycode, Gdk::ModifierType state) |
Handle specific keypress events, like Ctrl+Z. | |
bool | on_popup_menu (PopupMenuOptionalClick) |
void | create_popover_menu () |
void | on_numeric_menu_item_activate (double value) |
void | undo () |
Undo the editing, by resetting the value upon when the spinbutton got focus. | |
void | _unparentChildren () |
Private Attributes | |
UnitMenu * | _unit_menu = nullptr |
Linked unit menu for unit conversion in entered expressions. | |
UnitTracker * | _unit_tracker = nullptr |
Linked unit tracker for unit conversion in entered expressions. | |
double | _on_focus_in_value = 0. |
Inkscape::UI::DefocusTarget * | _defocus_target = nullptr |
Widget that should be informed when the spinbutton defocuses. | |
bool | _zeroable = false |
Reset-value should be zero. | |
bool | _oneable = false |
Reset-value should be one. | |
bool | _dont_evaluate = false |
Don't attempt to evaluate expressions. | |
NumericMenuData | _custom_menu_data |
bool | _custom_popup = false |
double | _increment = 0.0 |
std::unique_ptr< UI::Widget::PopoverMenu > | _popover_menu |
SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMenu), and allows entry of both '.
' and ',' for the decimal, even when in numeric mode.
Calling "set_numeric()" effectively disables the expression parsing. If no unit menu is linked, all unitlike characters are ignored.
Definition at line 51 of file spinbutton.h.
using Inkscape::UI::Widget::SpinButton::NumericMenuData = std::map<double, Glib::ustring> |
Definition at line 54 of file spinbutton.h.
|
inline |
Definition at line 57 of file spinbutton.h.
References _construct().
|
inline |
Definition at line 61 of file spinbutton.h.
References _construct().
|
override |
Definition at line 242 of file spinbutton.cpp.
References _unparentChildren().
|
private |
Definition at line 55 of file spinbutton.cpp.
References _on_focus_in_value, _unparentChildren(), key, on_input(), on_key_pressed(), Inkscape::UI::on_popup_menu(), and on_popup_menu().
Referenced by SpinButton(), and SpinButton().
|
private |
Definition at line 235 of file spinbutton.cpp.
References _popover_menu.
Referenced by _construct(), and ~SpinButton().
|
inline |
Definition at line 68 of file spinbutton.h.
References _unit_tracker.
Referenced by Inkscape::UI::Toolbar::ArcToolbar::_setupDerivedSpinButton(), Inkscape::UI::Toolbar::NodeToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::SelectToolbar::setup_derived_spin_button(), and Inkscape::UI::Toolbar::PaintbucketToolbar::setup_derived_spin_button().
|
private |
Definition at line 183 of file spinbutton.cpp.
References _custom_menu_data, _popover_menu, Inkscape::ustring::format_classic(), item, on_numeric_menu_item_activate(), and page.
Referenced by on_popup_menu().
void Inkscape::UI::Widget::SpinButton::defocus | ( | ) |
Definition at line 247 of file spinbutton.cpp.
References _defocus_target, Inkscape::UI::Widget::get_scrollable_ancestor(), and Inkscape::UI::DefocusTarget::onDefocus().
Referenced by on_key_pressed().
|
inline |
Definition at line 75 of file spinbutton.h.
References _oneable.
|
inline |
Definition at line 74 of file spinbutton.h.
References _zeroable.
|
private |
This callback function should try to convert the entered text to a number and write it to newvalue.
It calls a method to evaluate the (potential) mathematical expression.
false | No conversion done, continue with default handler. |
true | Conversion successful, don't call default handler. |
Definition at line 76 of file spinbutton.cpp.
References _dont_evaluate, _unit_menu, _unit_tracker, Inkscape::Util::ExpressionEvaluator::evaluate(), Inkscape::UI::Widget::get_text(), Inkscape::UI::Widget::UnitTracker::getActiveUnit(), Inkscape::UI::Widget::UnitMenu::getUnit(), result, Inkscape::Util::EvaluatorQuantity::value, and Inkscape::Util::EvaluatorException::what().
Referenced by _construct().
|
private |
Handle specific keypress events, like Ctrl+Z.
false | continue with default handler. |
true | don't call default handler. |
Definition at line 106 of file spinbutton.cpp.
References _increment, defocus(), Inkscape::UI::Tools::get_latin_keyval(), Inkscape::UI::Controller::has_flag(), and undo().
Referenced by _construct().
|
private |
Definition at line 168 of file spinbutton.cpp.
Referenced by create_popover_menu().
|
private |
Definition at line 173 of file spinbutton.cpp.
References _custom_popup, _popover_menu, and create_popover_menu().
Referenced by _construct().
void Inkscape::UI::Widget::SpinButton::set_custom_numeric_menu_data | ( | NumericMenuData && | custom_menu_data | ) |
Definition at line 260 of file spinbutton.cpp.
References _custom_menu_data, and _custom_popup.
Referenced by Inkscape::UI::Toolbar::ArcToolbar::ArcToolbar(), Inkscape::UI::Toolbar::Box3DToolbar::Box3DToolbar(), Inkscape::UI::Toolbar::CalligraphyToolbar::CalligraphyToolbar(), Inkscape::UI::Toolbar::ConnectorToolbar::ConnectorToolbar(), Inkscape::UI::Toolbar::EraserToolbar::EraserToolbar(), Inkscape::UI::Toolbar::GradientToolbar::GradientToolbar(), Inkscape::UI::Toolbar::MeasureToolbar::MeasureToolbar(), Inkscape::UI::Dialog::MeasureToolSettingsDialog::MeasureToolSettingsDialog(), Inkscape::UI::Toolbar::MeshToolbar::MeshToolbar(), Inkscape::UI::Toolbar::PaintbucketToolbar::PaintbucketToolbar(), Inkscape::UI::Toolbar::PencilToolbar::PencilToolbar(), Inkscape::UI::Toolbar::SpiralToolbar::SpiralToolbar(), Inkscape::UI::Toolbar::SprayToolbar::SprayToolbar(), Inkscape::UI::Toolbar::StarToolbar::StarToolbar(), Inkscape::UI::Toolbar::TextToolbar::TextToolbar(), and Inkscape::UI::Toolbar::TweakToolbar::TweakToolbar().
|
inline |
Definition at line 128 of file spinbutton.h.
References _dont_evaluate.
Referenced by Inkscape::UI::Widget::StatusBar::StatusBar().
void Inkscape::UI::Widget::SpinButton::set_increment | ( | double | delta | ) |
Definition at line 266 of file spinbutton.cpp.
References _increment, and delta.
Referenced by Inkscape::UI::Toolbar::SelectToolbar::setup_derived_spin_button().
|
inline |
Definition at line 72 of file spinbutton.h.
References _oneable.
|
inline |
Definition at line 71 of file spinbutton.h.
References _zeroable.
|
inline |
Definition at line 127 of file spinbutton.h.
References _defocus_target.
Referenced by Inkscape::UI::Toolbar::ArcToolbar::_setupDerivedSpinButton(), Inkscape::UI::Toolbar::SpiralToolbar::_setupDerivedSpinButton(), Inkscape::UI::Widget::SelectedStyle::SelectedStyle(), Inkscape::UI::Toolbar::NodeToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::SelectToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::GradientToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::MeasureToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::PaintbucketToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::CalligraphyToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::ConnectorToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::EraserToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::MeshToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::PencilToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::SprayToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::StarToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::TextToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::TweakToolbar::setup_derived_spin_button(), Inkscape::UI::Toolbar::Box3DToolbar::setup_derived_spin_button(), and Inkscape::UI::Widget::StatusBar::StatusBar().
|
inline |
Definition at line 67 of file spinbutton.h.
References _unit_menu.
Referenced by Inkscape::UI::Widget::ScalarUnit::ScalarUnit(), and Inkscape::UI::Widget::StrokeStyle::StrokeStyle().
|
private |
Undo the editing, by resetting the value upon when the spinbutton got focus.
Definition at line 230 of file spinbutton.cpp.
References _on_focus_in_value.
Referenced by on_key_pressed().
|
private |
Definition at line 90 of file spinbutton.h.
Referenced by create_popover_menu(), and set_custom_numeric_menu_data().
|
private |
Definition at line 91 of file spinbutton.h.
Referenced by on_popup_menu(), and set_custom_numeric_menu_data().
|
private |
Widget that should be informed when the spinbutton defocuses.
Definition at line 86 of file spinbutton.h.
Referenced by defocus(), and setDefocusTarget().
|
private |
Don't attempt to evaluate expressions.
Definition at line 89 of file spinbutton.h.
Referenced by on_input(), and set_dont_evaluate().
|
private |
Definition at line 92 of file spinbutton.h.
Referenced by on_key_pressed(), and set_increment().
|
private |
Definition at line 85 of file spinbutton.h.
Referenced by _construct(), and undo().
|
private |
Reset-value should be one.
Definition at line 88 of file spinbutton.h.
Referenced by get_oneable(), and set_oneable().
|
private |
Definition at line 93 of file spinbutton.h.
Referenced by _unparentChildren(), create_popover_menu(), and on_popup_menu().
|
private |
Linked unit menu for unit conversion in entered expressions.
Definition at line 83 of file spinbutton.h.
Referenced by on_input(), and setUnitMenu().
|
private |
Linked unit tracker for unit conversion in entered expressions.
Definition at line 84 of file spinbutton.h.
Referenced by addUnitTracker(), and on_input().
|
private |
Reset-value should be zero.
Definition at line 87 of file spinbutton.h.
Referenced by get_zeroable(), and set_zeroable().