diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:29:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:29:01 +0000 |
commit | 35a96bde514a8897f6f0fcc41c5833bf63df2e2a (patch) | |
tree | 657d15a03cc46bd099fc2c6546a7a4ad43815d9f /src/live_effects/parameter/unit.cpp | |
parent | Initial commit. (diff) | |
download | inkscape-35a96bde514a8897f6f0fcc41c5833bf63df2e2a.tar.xz inkscape-35a96bde514a8897f6f0fcc41c5833bf63df2e2a.zip |
Adding upstream version 1.0.2.upstream/1.0.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/live_effects/parameter/unit.cpp')
-rw-r--r-- | src/live_effects/parameter/unit.cpp | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp new file mode 100644 index 0000000..65a939b --- /dev/null +++ b/src/live_effects/parameter/unit.cpp @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com> + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "ui/widget/registered-widget.h" +#include <glibmm/i18n.h> + +#include "live_effects/parameter/unit.h" +#include "live_effects/effect.h" +#include "verbs.h" +#include "util/units.h" + +using Inkscape::Util::unit_table; + +namespace Inkscape { + +namespace LivePathEffect { + + +UnitParam::UnitParam( const Glib::ustring& label, const Glib::ustring& tip, + const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, + Effect* effect, Glib::ustring default_unit) + : Parameter(label, tip, key, wr, effect) +{ + defunit = unit_table.getUnit(default_unit); + unit = defunit; +} + +UnitParam::~UnitParam() += default; + +bool +UnitParam::param_readSVGValue(const gchar * strvalue) +{ + if (strvalue) { + param_set_value(*unit_table.getUnit(strvalue)); + return true; + } + return false; +} + +Glib::ustring +UnitParam::param_getSVGValue() const +{ + return unit->abbr; +} + +Glib::ustring +UnitParam::param_getDefaultSVGValue() const +{ + return defunit->abbr; +} + +void +UnitParam::param_set_default() +{ + param_set_value(*defunit); +} + +void +UnitParam::param_update_default(const gchar * default_unit) +{ + defunit = unit_table.getUnit((Glib::ustring)default_unit); +} + +void +UnitParam::param_set_value(Inkscape::Util::Unit const &val) +{ + param_effect->refresh_widgets = true; + unit = new Inkscape::Util::Unit(val); +} + +const gchar * +UnitParam::get_abbreviation() const +{ + return unit->abbr.c_str(); +} + +Gtk::Widget * +UnitParam::param_newWidget() +{ + Inkscape::UI::Widget::RegisteredUnitMenu* unit_menu = Gtk::manage( + new Inkscape::UI::Widget::RegisteredUnitMenu(param_label, + param_key, + *param_wr, + param_effect->getRepr(), + param_effect->getSPDoc())); + + unit_menu->setUnit(unit->abbr); + unit_menu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change unit parameter")); + + return dynamic_cast<Gtk::Widget *> (unit_menu); +} + +} /* namespace LivePathEffect */ +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : |