summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNathan Lee <2431820-nathanal@users.noreply.gitlab.com>2019-04-26 04:10:54 +0000
committerNathan Lee <2431820-nathanal@users.noreply.gitlab.com>2019-04-30 12:01:19 +0000
commit9db06f0ff1f297754e328eb5909e98792091b6ec (patch)
tree5e66aba0e03b3c6677f0220f30ff7a1f9cf217f9 /src
parentSimplify UI for LPE add (diff)
downloadinkscape-9db06f0ff1f297754e328eb5909e98792091b6ec.tar.gz
inkscape-9db06f0ff1f297754e328eb5909e98792091b6ec.zip
Make display unit change roll out to toolbars
Add exception for measure tool, which uses preferences Fixes https://gitlab.com/inkscape/inbox/issues/393 Partial fix: https://gitlab.com/inkscape/inkscape/issues/208
Diffstat (limited to 'src')
-rw-r--r--src/ui/toolbar/arc-toolbar.cpp3
-rw-r--r--src/ui/toolbar/rect-toolbar.cpp2
-rw-r--r--src/ui/toolbar/text-toolbar.cpp2
-rw-r--r--src/ui/tools/measure-tool.cpp6
-rw-r--r--src/ui/widget/unit-tracker.cpp2
-rw-r--r--src/util/units.h2
-rw-r--r--src/widgets/desktop-widget.cpp4
-rw-r--r--src/widgets/toolbox.cpp2
8 files changed, 15 insertions, 8 deletions
diff --git a/src/ui/toolbar/arc-toolbar.cpp b/src/ui/toolbar/arc-toolbar.cpp
index e9e25b7df..751efaa80 100644
--- a/src/ui/toolbar/arc-toolbar.cpp
+++ b/src/ui/toolbar/arc-toolbar.cpp
@@ -39,6 +39,7 @@
#include "verbs.h"
#include "object/sp-ellipse.h"
+#include "object/sp-namedview.h"
#include "ui/icon-names.h"
#include "ui/pref-pusher.h"
@@ -78,7 +79,7 @@ ArcToolbar::ArcToolbar(SPDesktop *desktop) :
_freeze(false),
_repr(nullptr)
{
- _tracker->setActiveUnit(unit_table.getUnit("px"));
+ _tracker->setActiveUnit(desktop->getNamedView()->display_units);
auto prefs = Inkscape::Preferences::get();
{
diff --git a/src/ui/toolbar/rect-toolbar.cpp b/src/ui/toolbar/rect-toolbar.cpp
index 960ddaac9..a8b49e62d 100644
--- a/src/ui/toolbar/rect-toolbar.cpp
+++ b/src/ui/toolbar/rect-toolbar.cpp
@@ -84,7 +84,7 @@ RectToolbar::RectToolbar(SPDesktop *desktop)
// rx/ry units menu: create
//tracker->addUnit( SP_UNIT_PERCENT, 0 );
// fixme: add % meaning per cent of the width/height
- _tracker->setActiveUnit(unit_table.getUnit("px"));
+ _tracker->setActiveUnit(desktop->getNamedView()->display_units);
_mode_item->set_use_markup(true);
/* W */
diff --git a/src/ui/toolbar/text-toolbar.cpp b/src/ui/toolbar/text-toolbar.cpp
index bd73fe584..3b55f8b08 100644
--- a/src/ui/toolbar/text-toolbar.cpp
+++ b/src/ui/toolbar/text-toolbar.cpp
@@ -265,7 +265,7 @@ TextToolbar::TextToolbar(SPDesktop *desktop)
_tracker(new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR))
{
/* Line height unit tracker */
- _tracker->prependUnit(unit_table.getUnit("")); // No unit
+ _tracker->prependUnit(unit_table.getUnit("")); // Ratio
_tracker->addUnit(unit_table.getUnit("%"));
_tracker->addUnit(unit_table.getUnit("em"));
_tracker->addUnit(unit_table.getUnit("ex"));
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index f8c8517c9..64824514e 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -810,7 +810,7 @@ void MeasureTool::toMarkDimension()
setLine(start, end, true, color);
Glib::ustring unit_name = prefs->getString("/tools/measure/unit");
if (!unit_name.compare("")) {
- unit_name = "px";
+ unit_name = DEFAULT_UNIT_NAME;
}
double fontsize = prefs->getDouble("/tools/measure/fontsize", 10.0);
int precision = prefs->getInt("/tools/measure/precision", 2);
@@ -1162,7 +1162,7 @@ void MeasureTool::showInfoBox(Geom::Point cursor, bool into_groups)
Glib::ustring unit_name = prefs->getString("/tools/measure/unit");
bool only_selected = prefs->getBool("/tools/measure/only_selected", false);
if (!unit_name.compare("")) {
- unit_name = "px";
+ unit_name = DEFAULT_UNIT_NAME;
}
Geom::Scale zoom = Geom::Scale(Inkscape::Util::Quantity::convert(desktop->current_zoom(), "px", unit->abbr)).inverse();
if(newover != over){
@@ -1324,7 +1324,7 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom,
}
Glib::ustring unit_name = prefs->getString("/tools/measure/unit");
if (!unit_name.compare("")) {
- unit_name = "px";
+ unit_name = DEFAULT_UNIT_NAME;
}
double scale = prefs->getDouble("/tools/measure/scale", 100.0) / 100.0;
double fontsize = prefs->getDouble("/tools/measure/fontsize", 10.0);
diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp
index 665bb7497..4abfaa9c8 100644
--- a/src/ui/widget/unit-tracker.cpp
+++ b/src/ui/widget/unit-tracker.cpp
@@ -180,7 +180,9 @@ UnitTracker::create_tool_item(Glib::ustring const &label,
Glib::ustring const &tooltip)
{
auto combo = ComboToolItem::create(label, tooltip, "NotUsed", _store);
+ combo->set_active(_active);
combo->signal_changed().connect(sigc::mem_fun(*this, &UnitTracker::_unitChangedCB));
+ combo->set_data("unit-tracker", this);
_combo_list.push_back(combo);
return combo;
}
diff --git a/src/util/units.h b/src/util/units.h
index 2b7f8674c..48478c77c 100644
--- a/src/util/units.h
+++ b/src/util/units.h
@@ -22,6 +22,8 @@
#ifndef DOXYGEN_SHOULD_SKIP_THIS
+#define DEFAULT_UNIT_NAME "mm";
+
namespace std {
template <>
struct hash<Glib::ustring> : public std::unary_function<Glib::ustring, std::size_t> {
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 7386f2fa5..a50427c09 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -1769,10 +1769,10 @@ void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags)
// Don't apply to text toolbar. We want to be able to
// use different units for text. (Bug 1562217)
const Glib::ustring name = j->get_name();
- if ( name == "TextToolbar")
+ if ( name == "TextToolbar" || name == "MeasureToolbar")
continue;
- gpointer t = sp_search_by_data_recursive(GTK_WIDGET(j->gobj()), (gpointer) "tracker");
+ gpointer t = sp_search_by_data_recursive(GTK_WIDGET(j->gobj()), (gpointer) "unit-tracker");
if (t == nullptr) // didn't find any tracker data
continue;
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index d3daa892f..e3b95fa2b 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -198,6 +198,7 @@ static struct {
SP_VERB_INVALID, nullptr, nullptr},
{ "/tools/zoom", "zoom_toolbox", Inkscape::UI::Toolbar::ZoomToolbar::create, nullptr, "ZoomToolbar",
SP_VERB_INVALID, nullptr, nullptr},
+ // If you change MeasureToolbar here, change it also in desktop-widget.cpp
{ "/tools/measure", "measure_toolbox", Inkscape::UI::Toolbar::MeasureToolbar::create, nullptr, "MeasureToolbar",
SP_VERB_INVALID, nullptr, nullptr},
{ "/tools/shapes/star", "star_toolbox", Inkscape::UI::Toolbar::StarToolbar::create, nullptr, "StarToolbar",
@@ -819,6 +820,7 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
gtk_container_add(GTK_CONTAINER(toolbox), holder);
gtk_size_group_add_widget(grouper, holder);
sp_set_font_size_smaller( holder );
+ gtk_widget_set_name( holder, aux_toolboxes[i].ui_name );
// TODO: We could make the toolbox a custom subclass of GtkEventBox
// so that we can store a list of toolbars, rather than using