summaryrefslogtreecommitdiffstats
path: root/src/desktop-style.cpp
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2015-05-22 07:02:44 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2015-05-22 07:02:44 +0000
commit35d94a8e1c01cd60e4fcf4c15f46fee38c765fca (patch)
treed8366acd729a6a9d4bdc1001f050a43f30d8b7ad /src/desktop-style.cpp
parentUndo changes to CMakeLists.txt in 2geom directory after syncs (diff)
parentminor tweaks to libUEMF and related code (diff)
downloadinkscape-35d94a8e1c01cd60e4fcf4c15f46fee38c765fca.tar.gz
inkscape-35d94a8e1c01cd60e4fcf4c15f46fee38c765fca.zip
Merge from trunk
(bzr r14059.2.15)
Diffstat (limited to 'src/desktop-style.cpp')
-rw-r--r--src/desktop-style.cpp95
1 files changed, 93 insertions, 2 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index afdc3064a..d2109c03c 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -576,8 +576,8 @@ objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_re
return QUERY_STYLE_MULTIPLE_DIFFERENT; // different kind of server
}
- SPPattern *pat = pattern_getroot (pattern);
- SPPattern *pat_res = pattern_getroot (pattern_res);
+ SPPattern *pat = SP_PATTERN (server)->rootPattern();
+ SPPattern *pat_res = SP_PATTERN (server_res)->rootPattern();
if (pat_res != pat) {
return QUERY_STYLE_MULTIPLE_DIFFERENT; // different pattern roots
}
@@ -1168,6 +1168,94 @@ objects_query_fontstyle (const std::vector<SPItem*> &objects, SPStyle *style_res
}
}
+int
+objects_query_fontvariants (const std::vector<SPItem*> &objects, SPStyle *style_res)
+{
+ bool set = false;
+
+ int texts = 0;
+
+ SPILigatures* ligatures_res = &(style_res->font_variant_ligatures);
+ SPIEnum* position_res = &(style_res->font_variant_position);
+ SPIEnum* caps_res = &(style_res->font_variant_caps);
+ SPINumeric* numeric_res = &(style_res->font_variant_numeric);
+
+ // Stores 'and' of all values
+ ligatures_res->computed = SP_CSS_FONT_VARIANT_LIGATURES_NORMAL;
+ position_res->computed = SP_CSS_FONT_VARIANT_POSITION_NORMAL;
+ caps_res->computed = SP_CSS_FONT_VARIANT_CAPS_NORMAL;
+ numeric_res->computed = SP_CSS_FONT_VARIANT_NUMERIC_NORMAL;
+
+ // Stores only differences
+ ligatures_res->value = 0;
+ position_res->value = 0;
+ caps_res->value = 0;
+ numeric_res->value = 0;
+
+ for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
+ SPObject *obj = *i;
+
+ if (!isTextualItem(obj)) {
+ continue;
+ }
+
+ SPStyle *style = obj->style;
+ if (!style) {
+ continue;
+ }
+
+ texts ++;
+
+ SPILigatures* ligatures_in = &(style->font_variant_ligatures);
+ SPIEnum* position_in = &(style->font_variant_position);
+ SPIEnum* caps_in = &(style->font_variant_caps);
+ SPINumeric* numeric_in = &(style->font_variant_numeric);
+ // computed stores which bits are on/off, only valid if same between all selected objects.
+ // value stores which bits are different between objects. This is a bit of an abuse of
+ // the values but then we don't need to add new variables to class.
+ if (set) {
+ ligatures_res->value |= (ligatures_res->computed ^ ligatures_in->computed );
+ ligatures_res->computed &= ligatures_in->computed;
+
+ position_res->value |= (position_res->computed ^ position_in->computed );
+ position_res->computed &= position_in->computed;
+
+ caps_res->value |= (caps_res->computed ^ caps_in->computed );
+ caps_res->computed &= caps_in->computed;
+
+ numeric_res->value |= (numeric_res->computed ^ numeric_in->computed );
+ numeric_res->computed &= numeric_in->computed;
+
+ } else {
+ ligatures_res->computed = ligatures_in->computed;
+ position_res->computed = position_in->computed;
+ caps_res->computed = caps_in->computed;
+ numeric_res->computed = numeric_in->computed;
+ }
+
+ set = true;
+ }
+
+ bool different = (style_res->font_variant_ligatures.value != 0 ||
+ style_res->font_variant_position.value != 0 ||
+ style_res->font_variant_caps.value != 0 ||
+ style_res->font_variant_numeric.value != 0 );
+
+ if (texts == 0 || !set)
+ return QUERY_STYLE_NOTHING;
+
+ if (texts > 1) {
+ if (different) {
+ return QUERY_STYLE_MULTIPLE_DIFFERENT;
+ } else {
+ return QUERY_STYLE_MULTIPLE_SAME;
+ }
+ } else {
+ return QUERY_STYLE_SINGLE;
+ }
+}
+
+
/**
* Write to style_res the baseline numbers.
*/
@@ -1577,6 +1665,8 @@ sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *sty
return objects_query_fontfamily (list, style);
} else if (property == QUERY_STYLE_PROPERTY_FONTSTYLE) {
return objects_query_fontstyle (list, style);
+ } else if (property == QUERY_STYLE_PROPERTY_FONTVARIANTS) {
+ return objects_query_fontvariants (list, style);
} else if (property == QUERY_STYLE_PROPERTY_FONTNUMBERS) {
return objects_query_fontnumbers (list, style);
} else if (property == QUERY_STYLE_PROPERTY_BASELINES) {
@@ -1598,6 +1688,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
int ret = desktop->_query_style_signal.emit(style, property);
if (ret != QUERY_STYLE_NOTHING)