Inkscape
Vector Graphics Editor
|
A drop down menu for choosing unit types. More...
#include <unit-menu.h>
Public Member Functions | |
UnitMenu () | |
Construct a UnitMenu. | |
UnitMenu (DropDown::BaseObjectType *cobject, Glib::RefPtr< Gtk::Builder > const &) | |
~UnitMenu () override | |
bool | setUnitType (UnitType unit_type, bool svg_length=false) |
Adds the unit type to the widget. | |
bool | resetUnitType (UnitType unit_type, bool svg_length=false) |
Removes all unit entries, then adds the unit type to the widget. | |
void | addUnit (Unit const &u) |
Adds a unit, possibly user-defined, to the menu. | |
bool | setUnit (Glib::ustring const &unit) |
Sets the dropdown widget to the given unit abbreviation. | |
Unit const * | getUnit () const |
Returns the Unit object corresponding to the current selection in the dropdown widget. | |
Glib::ustring | getUnitAbbr () const |
Returns the abbreviated unit name of the selected unit. | |
UnitType | getUnitType () const |
Returns the UnitType of the selected unit. | |
double | getUnitFactor () const |
Returns the unit factor for the selected unit. | |
int | getDefaultDigits () const |
Returns the recommended number of digits for displaying numbers of this unit type. | |
double | getDefaultStep () const |
Returns the recommended step size in spin buttons displaying units of this type. | |
double | getDefaultPage () const |
Returns the recommended page size (when hitting pgup/pgdn) in spin buttons displaying units of this type. | |
double | getConversion (Glib::ustring const &new_unit_abbr, Glib::ustring const &old_unit_abbr="no_unit") const |
Returns the conversion factor required to convert values of the currently selected unit into units of type new_unit_abbr. | |
bool | isAbsolute () const |
Returns true if the selected unit is not dimensionless (false for %, true for px, pt, cm, etc). | |
bool | isRadial () const |
Returns true if the selected unit is radial (deg or rad). | |
Glib::SignalProxyProperty | signal_changed () |
virtual void | on_changed () |
![]() | |
DropDownList () | |
DropDownList (BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &builder) | |
unsigned int | append (const Glib::ustring &item) |
Glib::ustring | get_string (unsigned int position) const |
unsigned int | get_item_count () const |
void | remove_all () |
Glib::SignalProxyProperty | signal_changed () |
void | enable_search (bool enable=true) |
void | set_row_separator_func (std::function< bool(unsigned int)> callback) |
Private Member Functions | |
Glib::ustring | get_selected_string () const |
Private Attributes | |
UnitType | _type |
A drop down menu for choosing unit types.
Definition at line 30 of file unit-menu.h.
Inkscape::UI::Widget::UnitMenu::UnitMenu | ( | ) |
Inkscape::UI::Widget::UnitMenu::UnitMenu | ( | DropDown::BaseObjectType * | cobject, |
Glib::RefPtr< Gtk::Builder > const & | |||
) |
|
overridedefault |
void Inkscape::UI::Widget::UnitMenu::addUnit | ( | Unit const & | u | ) |
Adds a unit, possibly user-defined, to the menu.
Definition at line 58 of file unit-menu.cpp.
References Inkscape::Util::UnitTable::addUnit(), Inkscape::UI::Widget::DropDownList::append(), and Inkscape::Util::UnitTable::get().
Referenced by Inkscape::UI::Widget::StrokeStyle::StrokeStyle().
|
private |
Definition at line 164 of file unit-menu.cpp.
References Inkscape::UI::Widget::DropDownList::get_string().
Referenced by getUnit(), and getUnitAbbr().
double Inkscape::UI::Widget::UnitMenu::getConversion | ( | Glib::ustring const & | new_unit_abbr, |
Glib::ustring const & | old_unit_abbr = "no_unit" |
||
) | const |
Returns the conversion factor required to convert values of the currently selected unit into units of type new_unit_abbr.
Definition at line 126 of file unit-menu.cpp.
References Inkscape::Util::UnitTable::get(), and getUnit().
Referenced by Inkscape::UI::Widget::ScalarUnit::AbsoluteToPercentage(), Inkscape::UI::Widget::ScalarUnit::getValue(), Inkscape::UI::Widget::ZoomCorrRulerSlider::on_unit_changed(), Inkscape::UI::Widget::ScalarUnit::on_unit_changed(), Inkscape::UI::Dialog::Transformation::onMoveRelativeToggled(), Inkscape::UI::Widget::ScalarUnit::PercentageToAbsolute(), Inkscape::UI::Widget::ScalarUnit::setValueKeepUnit(), and Inkscape::UI::Dialog::Transformation::updatePageMove().
int Inkscape::UI::Widget::UnitMenu::getDefaultDigits | ( | ) | const |
Returns the recommended number of digits for displaying numbers of this unit type.
Definition at line 110 of file unit-menu.cpp.
References getUnit().
Referenced by Inkscape::UI::Widget::ScalarUnit::initScalar().
double Inkscape::UI::Widget::UnitMenu::getDefaultPage | ( | ) | const |
Returns the recommended page size (when hitting pgup/pgdn) in spin buttons displaying units of this type.
Definition at line 121 of file unit-menu.cpp.
References getDefaultStep().
Referenced by Inkscape::UI::Widget::ScalarUnit::initScalar().
double Inkscape::UI::Widget::UnitMenu::getDefaultStep | ( | ) | const |
Returns the recommended step size in spin buttons displaying units of this type.
Definition at line 115 of file unit-menu.cpp.
References getUnit().
Referenced by getDefaultPage(), and Inkscape::UI::Widget::ScalarUnit::initScalar().
Unit const * Inkscape::UI::Widget::UnitMenu::getUnit | ( | ) | const |
Returns the Unit object corresponding to the current selection in the dropdown widget.
Definition at line 64 of file unit-menu.cpp.
References _type, current, Inkscape::Util::UnitTable::get(), and get_selected_string().
Referenced by Inkscape::UI::Dialog::SingleExport::areaXChange(), Inkscape::UI::Dialog::SingleExport::areaYChange(), Inkscape::UI::Dialog::CloneTiler::CloneTiler(), Inkscape::UI::Dialog::SingleExport::dpiChange(), Inkscape::UI::Dialog::CloneTiler::fill_height_changed(), Inkscape::UI::Dialog::CloneTiler::fill_width_changed(), getConversion(), getDefaultDigits(), getDefaultStep(), Inkscape::UI::Widget::ScalarUnit::getUnit(), getUnitAbbr(), getUnitFactor(), getUnitType(), Inkscape::UI::Widget::SpinButton::on_input(), Inkscape::UI::Dialog::SingleExport::onExport(), Inkscape::UI::Dialog::SingleExport::refreshPreview(), Inkscape::UI::Dialog::SingleExport::setArea(), Inkscape::UI::Widget::StrokeStyle::setStrokeWidth(), Inkscape::UI::Widget::StrokeStyle::StrokeStyle(), Inkscape::UI::Dialog::CloneTiler::unit_changed(), Inkscape::UI::Widget::StrokeStyle::unitChangedCB(), and Inkscape::UI::Widget::StrokeStyle::updateLine().
Glib::ustring Inkscape::UI::Widget::UnitMenu::getUnitAbbr | ( | ) | const |
Returns the abbreviated unit name of the selected unit.
Definition at line 92 of file unit-menu.cpp.
References get_selected_string(), and getUnit().
Referenced by Inkscape::UI::Widget::RegisteredUnitMenu::on_changed(), Inkscape::UI::Widget::PrefUnit::on_changed(), Inkscape::UI::Widget::ZoomCorrRulerSlider::on_unit_changed(), Inkscape::UI::Widget::ScalarUnit::on_unit_changed(), Inkscape::UI::Widget::RegisteredScalarUnit::on_value_changed(), Inkscape::UI::Widget::RegisteredScalarUnit::RegisteredScalarUnit(), Inkscape::UI::Widget::ScalarUnit::resetUnitType(), Inkscape::UI::Widget::ScalarUnit::ScalarUnit(), and Inkscape::UI::Widget::ScalarUnit::setUnitType().
double Inkscape::UI::Widget::UnitMenu::getUnitFactor | ( | ) | const |
Returns the unit factor for the selected unit.
Definition at line 105 of file unit-menu.cpp.
References getUnit().
UnitType Inkscape::UI::Widget::UnitMenu::getUnitType | ( | ) | const |
Returns the UnitType of the selected unit.
Definition at line 100 of file unit-menu.cpp.
References getUnit().
Referenced by Inkscape::UI::Widget::ScalarUnit::getUnitType(), isAbsolute(), and isRadial().
bool Inkscape::UI::Widget::UnitMenu::isAbsolute | ( | ) | const |
Returns true if the selected unit is not dimensionless (false for %, true for px, pt, cm, etc).
Definition at line 146 of file unit-menu.cpp.
References getUnitType().
Referenced by Inkscape::UI::Dialog::Transformation::applyPageScale(), Inkscape::UI::Dialog::Transformation::applyPageSkew(), Inkscape::UI::Dialog::Transformation::onScaleXValueChanged(), and Inkscape::UI::Dialog::Transformation::onScaleYValueChanged().
bool Inkscape::UI::Widget::UnitMenu::isRadial | ( | ) | const |
Returns true if the selected unit is radial (deg or rad).
Definition at line 151 of file unit-menu.cpp.
References getUnitType().
Referenced by Inkscape::UI::Dialog::Transformation::applyPageSkew().
|
virtual |
Reimplemented in Inkscape::UI::Widget::PrefUnit.
Definition at line 160 of file unit-menu.cpp.
Referenced by UnitMenu().
bool Inkscape::UI::Widget::UnitMenu::resetUnitType | ( | UnitType | unit_type, |
bool | svg_length = false |
||
) |
Removes all unit entries, then adds the unit type to the widget.
This extracts the corresponding units from the unit map matching the given type, and appends them to the dropdown widget. It causes the primary unit for the given unit_type to be selected.
Definition at line 51 of file unit-menu.cpp.
References Inkscape::UI::Widget::DropDownList::remove_all(), and setUnitType().
Referenced by Inkscape::UI::Widget::ScalarUnit::resetUnitType().
bool Inkscape::UI::Widget::UnitMenu::setUnit | ( | Glib::ustring const & | unit | ) |
Sets the dropdown widget to the given unit abbreviation.
Returns true if the unit was selectable, false if not (i.e., if the unit was not present in the widget).
Definition at line 75 of file unit-menu.cpp.
References Inkscape::UI::Widget::DropDownList::get_item_count(), and Inkscape::UI::Widget::DropDownList::get_string().
Referenced by Inkscape::UI::Dialog::GuidelinePropertiesDialog::_setup(), Inkscape::UI::Dialog::CloneTiler::CloneTiler(), Inkscape::UI::Dialog::Transformation::desktopReplaced(), Inkscape::UI::Dialog::GridArrangeTab::GridArrangeTab(), Inkscape::UI::Widget::PrefUnit::init(), Inkscape::UI::Widget::ZoomCorrRulerSlider::init(), Inkscape::UI::Widget::RegisteredUnitMenu::setUnit(), Inkscape::UI::Widget::ScalarUnit::setUnit(), setUnitType(), Inkscape::UI::Dialog::SingleExport::setupUnits(), Inkscape::UI::Widget::ScalarUnit::setValue(), Inkscape::UI::Widget::StrokeStyle::StrokeStyle(), and Inkscape::UI::Widget::StrokeStyle::updateLine().
bool Inkscape::UI::Widget::UnitMenu::setUnitType | ( | UnitType | unit_type, |
bool | svg_length = false |
||
) |
Adds the unit type to the widget.
This extracts the corresponding units from the unit map matching the given type, and appends them to the dropdown widget. It causes the primary unit for the given unit_type to be selected.
svg_length | - If set to true will limit the drop down to only units available in SVGLength. i.e. the ones we ship and are valid in the SVG specification. |
Definition at line 33 of file unit-menu.cpp.
References _type, Inkscape::UI::Widget::DropDownList::append(), Inkscape::Util::UnitTable::get(), and setUnit().
Referenced by Inkscape::UI::Dialog::GuidelinePropertiesDialog::_setup(), Inkscape::UI::Dialog::CloneTiler::CloneTiler(), Inkscape::UI::Dialog::GridArrangeTab::GridArrangeTab(), Inkscape::UI::Widget::PrefUnit::init(), Inkscape::UI::Widget::ZoomCorrRulerSlider::init(), Inkscape::UI::Dialog::Transformation::layoutPageMove(), Inkscape::UI::Dialog::Transformation::layoutPageRotate(), Inkscape::UI::Dialog::Transformation::layoutPageScale(), Inkscape::UI::Dialog::Transformation::layoutPageSkew(), Inkscape::UI::Dialog::Transformation::layoutPageTransform(), resetUnitType(), Inkscape::UI::Widget::ScalarUnit::ScalarUnit(), Inkscape::UI::Widget::ScalarUnit::setUnitType(), Inkscape::UI::Dialog::SingleExport::setupUnits(), and Inkscape::UI::Widget::StrokeStyle::StrokeStyle().
Glib::SignalProxyProperty Inkscape::UI::Widget::UnitMenu::signal_changed | ( | ) |
Definition at line 156 of file unit-menu.cpp.
Referenced by Inkscape::UI::Dialog::CloneTiler::CloneTiler(), Inkscape::UI::Widget::ZoomCorrRulerSlider::init(), Inkscape::UI::Widget::ScalarUnit::ScalarUnit(), Inkscape::UI::Dialog::SingleExport::setup(), and Inkscape::UI::Widget::StrokeStyle::StrokeStyle().
|
private |
Definition at line 140 of file unit-menu.h.
Referenced by getUnit(), and setUnitType().