summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2016-12-11 14:33:49 +0000
committertavmjong-free <tavmjong@free.fr>2016-12-11 14:33:49 +0000
commit401349277d025fb736184e014b636027b412d29e (patch)
tree017d267e6dc49165119f9e9b4f60f532fa492ea9 /src
parentApply suv patch to handle containers https://bugs.launchpad.net/inkscape/+bug... (diff)
downloadinkscape-401349277d025fb736184e014b636027b412d29e.tar.gz
inkscape-401349277d025fb736184e014b636027b412d29e.zip
Add option to unset 'line-height' (as well as determine where it is set).
(bzr r15321)
Diffstat (limited to 'src')
-rw-r--r--src/desktop-style.cpp11
-rw-r--r--src/widgets/text-toolbar.cpp48
-rw-r--r--src/widgets/toolbox.cpp1
3 files changed, 55 insertions, 5 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index dee36d681..4c07c76ea 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -209,7 +209,7 @@ sp_desktop_set_style(Inkscape::ObjectSet *set, SPDesktop *desktop, SPCSSAttr *cs
if (!change)
return;
-// 2. Emit signal... See desktop->connectStyleSet in text-tool, tweak-tool, and gradient-drag.
+// 2. Emit signal... See desktop->connectSetStyle in text-tool, tweak-tool, and gradient-drag.
bool intercepted = desktop->_set_style_signal.emit(css);
/** \todo
@@ -1045,6 +1045,7 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
bool lineheight_normal = false;
bool lineheight_unit_proportional = false;
bool lineheight_unit_absolute = false;
+ bool lineheight_set = false; // Set true if any object has lineheight set.
double size_prev = 0;
double letterspacing_prev = 0;
@@ -1130,6 +1131,9 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
lineheight_normal = false;
lineheight += lineheight_current * doc_scale;
}
+ if (style->line_height.set) {
+ lineheight_set = true;
+ }
if ((size_prev != 0 && style->font_size.computed != size_prev) ||
(letterspacing_prev != 0 && style->letter_spacing.computed != letterspacing_prev) ||
@@ -1205,6 +1209,9 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
}
}
+ // Used by text toolbar unset 'line-height'
+ style_res->line_height.set = lineheight_set;
+
if (texts > 1) {
if (different || different_lineheight) {
return QUERY_STYLE_MULTIPLE_AVERAGED;
@@ -1907,7 +1914,7 @@ sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *sty
int
sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property)
{
- // Used by text tool and in gradient dragging
+ // Used by text tool and in gradient dragging. See connectQueryStyle.
int ret = desktop->_query_style_signal.emit(style, property);
if (ret != QUERY_STYLE_NOTHING)
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index 847ebd8c1..784c467f1 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -239,7 +239,7 @@ static void sp_text_fontsize_value_changed( Ink_ComboBoxEntry_Action *act, GObje
if (dynamic_cast<SPText *>(*i) || dynamic_cast<SPFlowtext *>(*i)) {
SPItem *item = *i;
- // Scale by inverse of accumulated paraent transform
+ // Scale by inverse of accumulated parent transform
SPCSSAttr *css_set = sp_repr_css_attr_new();
sp_repr_css_merge(css_set, css);
Geom::Affine const local(item->i2doc_affine());
@@ -321,6 +321,29 @@ static void sp_text_outer_style_changed( InkToggleAction*act, GObject *tbl )
sp_text_toolbox_selection_changed( NULL, tbl );
}
+// Unset line height on selection's inner text objects (tspan, etc.).
+static void sp_text_lineheight_unset_changed( InkToggleAction*act, GObject *tbl )
+{
+ // quit if run by the _changed callbacks
+ if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
+ return;
+ }
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+
+ SPCSSAttr *css = sp_repr_css_attr_new();
+ sp_repr_css_unset_property(css, "line-height");
+
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ sp_desktop_set_style (desktop, css);
+
+ sp_repr_css_attr_unref(css);
+
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
+ _("Text: Unset line height."));
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
+
// Handles both Superscripts and Subscripts
static void sp_text_script_changed( InkToggleAction* act, GObject *tbl )
{
@@ -599,7 +622,7 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl )
if (dynamic_cast<SPText *>(*i) || dynamic_cast<SPFlowtext *>(*i)) {
SPItem *item = *i;
- // Scale by inverse of accumulated paraent transform
+ // Scale by inverse of accumulated parent transform
SPCSSAttr *css_set = sp_repr_css_attr_new();
sp_repr_css_merge(css_set, css);
Geom::Affine const local(item->i2doc_affine());
@@ -1405,7 +1428,13 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
}
// Save unit so we can do convertions between new/old units.
g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(line_height_unit));
-
+
+ // Enable and turn on only if selection includes an object with line height set.
+ InkToggleAction* lineHeightUnset =
+ INK_TOGGLE_ACTION( g_object_get_data( tbl, "TextLineHeightUnsetAction"));
+ gtk_action_set_sensitive(GTK_ACTION(lineHeightUnset), query.line_height.set );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(lineHeightUnset), query.line_height.set );
+
// Word spacing
double wordSpacing;
if (query.word_spacing.normal) wordSpacing = 0.0;
@@ -2100,6 +2129,19 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
g_object_set( G_OBJECT(eact), "iconId", "text_rotation", NULL );
}
+ /* Text line height unset */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "TextLineHeightUnsetAction", // Name
+ _("Unset line height"), // Label
+ _("If enabled, line height is set on part of selection. Click to unset."),
+ INKSCAPE_ICON("paint-unknown"),
+ secondarySize ); // Icon size
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_text_lineheight_unset_changed), holder );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/text/line_height_unset", false) );
+ g_object_set_data( holder, "TextLineHeightUnsetAction", act );
+ }
+
/* Text outer style */
{
InkToggleAction* act = ink_toggle_action_new( "TextOuterStyleAction", // Name
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 1f6cb136c..a3db3c33d 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -514,6 +514,7 @@ static gchar const * ui_descr =
" <toolitem action='TextFontSizeAction' />"
" <toolitem action='TextLineHeightAction' />"
" <toolitem action='TextLineHeightUnitsAction' />"
+ " <toolitem action='TextLineHeightUnsetAction' />"
" <separator />"
" <toolitem action='TextAlignAction' />"
" <separator />"