Code

Use correct text anchor for vertical text and when aligning or distributing
[inkscape.git] / src / ui / dialog / align-and-distribute.cpp
index 09fe89cff22b209d7b94c66d7551c38adc7710f5..2bba0a0f8e22d6c85cd3c401828d861d69c3a5ef 100644 (file)
@@ -464,7 +464,9 @@ public:
         removeOverlapXGap.set_value(0);
         dialog.tooltips().set_tip(removeOverlapXGap,
                                   _("Minimum horizontal gap (in px units) between bounding boxes"));
-        /* TRANSLATORS: Horizontal gap. Only put "H:" equivalent in the translation */
+        //TRANSLATORS: only translate "string" in "context|string".
+        // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
+        // "H:" stands for horizontal gap
         removeOverlapXGapLabel.set_label(Q_("gap|H:"));
 
         removeOverlapYGap.set_digits(1);
@@ -703,14 +705,16 @@ private :
         {
             if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) {
                 Inkscape::Text::Layout const *layout = te_get_layout(*it);
-                Geom::Point base = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(*it);
-                if (base[Geom::X] < b_min[Geom::X]) b_min[Geom::X] = base[Geom::X];
-                if (base[Geom::Y] < b_min[Geom::Y]) b_min[Geom::Y] = base[Geom::Y];
-                if (base[Geom::X] > b_max[Geom::X]) b_max[Geom::X] = base[Geom::X];
-                if (base[Geom::Y] > b_max[Geom::Y]) b_max[Geom::Y] = base[Geom::Y];
-
-                Baselines b (*it, base, _orientation);
-                sorted.push_back(b);
+                boost::optional<Geom::Point> pt = layout->baselineAnchorPoint();
+                if (pt) {
+                    Geom::Point base = *pt * sp_item_i2d_affine(*it);
+                    if (base[Geom::X] < b_min[Geom::X]) b_min[Geom::X] = base[Geom::X];
+                    if (base[Geom::Y] < b_min[Geom::Y]) b_min[Geom::Y] = base[Geom::Y];
+                    if (base[Geom::X] > b_max[Geom::X]) b_max[Geom::X] = base[Geom::X];
+                    if (base[Geom::Y] > b_max[Geom::Y]) b_max[Geom::Y] = base[Geom::Y];
+                    Baselines b (*it, base, _orientation);
+                    sorted.push_back(b);
+                }
             }
         }
 
@@ -744,11 +748,14 @@ private :
             {
                 if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) {
                     Inkscape::Text::Layout const *layout = te_get_layout(*it);
-                    Geom::Point base = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(*it);
-                    Geom::Point t(0.0, 0.0);
-                    t[_orientation] = b_min[_orientation] - base[_orientation];
-                    sp_item_move_rel(*it, Geom::Translate(t));
-                    changed = true;
+                    boost::optional<Geom::Point> pt = layout->baselineAnchorPoint();
+                    if (pt) {
+                        Geom::Point base = *pt * sp_item_i2d_affine(*it);
+                        Geom::Point t(0.0, 0.0);
+                        t[_orientation] = b_min[_orientation] - base[_orientation];
+                        sp_item_move_rel(*it, Geom::Translate(t));
+                        changed = true;
+                    }
                 }
             }
 
@@ -805,7 +812,7 @@ AlignAndDistribute::AlignAndDistribute()
                    _("Align left edges"),
                    0, 1);
     addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_CENTER,
-                   _("Center objects horizontally"),
+                   _("Center on vertical axis"),
                    0, 2);
     addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_RIGHT,
                    _("Align right sides"),
@@ -892,11 +899,14 @@ AlignAndDistribute::AlignAndDistribute()
                             0, 0);
 
     //Node Mode buttons
-    addNodeButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_NODES,
-                  _("Align selected nodes horizontally"),
-                  0, Geom::X, false);
+    // NOTE: "align nodes vertically" means "move nodes vertically until they align on a common
+    // _horizontal_ line". This is analogous to what the "align-vertical-center" icon means.
+    // There is no doubt some ambiguity. For this reason the descriptions are different.
     addNodeButton(INKSCAPE_ICON_ALIGN_VERTICAL_NODES,
-                  _("Align selected nodes vertically"),
+                  _("Align selected nodes to a common horizontal line"),
+                  0, Geom::X, false);
+    addNodeButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_NODES,
+                  _("Align selected nodes to a common vertical line"),
                   1, Geom::Y, false);
     addNodeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_NODE,
                   _("Distribute selected nodes horizontally"),