From ce697d7ebfb1e4affce10805c89445244d29388a Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 28 Oct 2015 14:40:01 +0100 Subject: Implement 'text-orientation' with user interface. Update 'writing-mode', adding 'vertical-lr'. Overhaul vertical text. Eliminate any use of "internal" leading in glyph metrics. Etc. (bzr r14430.1.1) --- src/desktop-style.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 5 deletions(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 02c18339b..2260d851f 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -500,7 +500,7 @@ objects_query_fillstroke (const std::vector &objects, SPStyle *style_re SPIPaint *paint_res = isfill? &style_res->fill : &style_res->stroke; bool paintImpossible = true; - paint_res->set = TRUE; + paint_res->set = true; SVGICCColor* iccColor = 0; @@ -1144,7 +1144,7 @@ objects_query_fontstyle (const std::vector &objects, SPStyle *style_res different = true; // different styles } - set = TRUE; + set = true; style_res->font_weight.value = style_res->font_weight.computed = style->font_weight.computed; style_res->font_style.value = style_res->font_style.computed = style->font_style.computed; style_res->font_stretch.value = style_res->font_stretch.computed = style->font_stretch.computed; @@ -1256,6 +1256,56 @@ objects_query_fontvariants (const std::vector &objects, SPStyle *style_ } +/** + * Write to style_res the average writing modes style of objects. + */ +int +objects_query_writing_modes (const std::vector &objects, SPStyle *style_res) +{ + bool different = false; + bool set = false; + + int texts = 0; + + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + SPObject *obj = *i; + + if (!isTextualItem(obj)) { + continue; + } + + SPStyle *style = obj->style; + if (!style) { + continue; + } + + texts ++; + + if (set && + ( ( style_res->writing_mode.computed != style->writing_mode.computed ) || + ( style_res->text_orientation.computed != style->text_orientation.computed ) ) ) { + different = true; // different styles + } + + set = true; + style_res->writing_mode.computed = style->writing_mode.computed; + style_res->text_orientation.computed = style->text_orientation.computed; + } + + 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; + } +} + int objects_query_fontfeaturesettings (const std::vector &objects, SPStyle *style_res) { @@ -1293,7 +1343,7 @@ objects_query_fontfeaturesettings (const std::vector &objects, SPStyle style_res->font_feature_settings.value = NULL; } - style_res->font_feature_settings.set = TRUE; + style_res->font_feature_settings.set = true; style_res->font_feature_settings.value = g_strdup(style->font_feature_settings.value); } @@ -1449,7 +1499,7 @@ objects_query_fontfamily (const std::vector &objects, SPStyle *style_re style_res->font_family.value = NULL; } - style_res->font_family.set = TRUE; + style_res->font_family.set = true; style_res->font_family.value = g_strdup(style->font_family.value); } @@ -1508,7 +1558,7 @@ objects_query_fontspecification (const std::vector &objects, SPStyle *s style_res->font_specification.value = NULL; } - style_res->font_specification.set = TRUE; + style_res->font_specification.set = true; style_res->font_specification.value = g_strdup(style->font_specification.value); } } @@ -1728,6 +1778,8 @@ sp_desktop_query_style_from_list (const std::vector &list, SPStyle *sty return objects_query_fontfeaturesettings (list, style); } else if (property == QUERY_STYLE_PROPERTY_FONTNUMBERS) { return objects_query_fontnumbers (list, style); + } else if (property == QUERY_STYLE_PROPERTY_WRITINGMODES) { + return objects_query_writing_modes (list, style); } else if (property == QUERY_STYLE_PROPERTY_BASELINES) { return objects_query_baselines (list, style); -- cgit v1.2.3 From 2e1f86061452fc6cad648a3370236bf2cb1f1a7d Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 28 Oct 2015 21:43:30 +0100 Subject: static code analysis (bzr r14432) --- src/desktop-style.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 02c18339b..e66da90fb 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -195,7 +195,7 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_css_attr_unset_uris(css_write); prefs->mergeStyle("/desktop/style", css_write); std::vector const itemlist = desktop->selection->itemList(); - for (std::vector::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) { + for (std::vector::const_iterator i = itemlist.begin(); i!= itemlist.end(); ++i) { /* last used styles for 3D box faces are stored separately */ SPObject *obj = *i; Box3DSide *side = dynamic_cast(obj); @@ -235,7 +235,7 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write css_no_text = sp_css_attr_unset_text(css_no_text); std::vector const itemlist = desktop->selection->itemList(); - for (std::vector::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) { + for (std::vector::const_iterator i = itemlist.begin(); i!= itemlist.end(); ++i) { SPItem *item = *i; // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME) @@ -447,7 +447,7 @@ stroke_average_width (const std::vector &objects) gdouble avgwidth = 0.0; bool notstroked = true; int n_notstroked = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPItem *item = *i; if (!item) { continue; @@ -513,7 +513,7 @@ objects_query_fillstroke (const std::vector &objects, SPStyle *style_re prev[0] = prev[1] = prev[2] = 0.0; bool same_color = true; - for (std::vector::const_iterator i = objects.begin(); i!= objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i!= objects.end(); ++i) { SPObject *obj = *i; if (!obj) { continue; @@ -697,7 +697,7 @@ objects_query_opacity (const std::vector &objects, SPStyle *style_res) guint opacity_items = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; if (!obj) { continue; @@ -753,7 +753,7 @@ objects_query_strokewidth (const std::vector &objects, SPStyle *style_r int n_stroked = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; if (!obj) { continue; @@ -827,7 +827,7 @@ objects_query_miterlimit (const std::vector &objects, SPStyle *style_re gdouble prev_ml = -1; bool same_ml = true; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; if (!dynamic_cast(obj)) { continue; @@ -886,7 +886,7 @@ objects_query_strokecap (const std::vector &objects, SPStyle *style_res bool same_cap = true; int n_stroked = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; if (!dynamic_cast(obj)) { continue; @@ -940,7 +940,7 @@ objects_query_strokejoin (const std::vector &objects, SPStyle *style_re bool same_join = true; int n_stroked = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; if (!dynamic_cast(obj)) { continue; @@ -1003,7 +1003,7 @@ objects_query_fontnumbers (const std::vector &objects, SPStyle *style_r int texts = 0; int no_size = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; if (!isTextualItem(obj)) { @@ -1122,7 +1122,7 @@ objects_query_fontstyle (const std::vector &objects, SPStyle *style_res int texts = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; if (!isTextualItem(obj)) { @@ -1192,7 +1192,7 @@ objects_query_fontvariants (const std::vector &objects, SPStyle *style_ caps_res->value = 0; numeric_res->value = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; if (!isTextualItem(obj)) { @@ -1268,7 +1268,7 @@ objects_query_fontfeaturesettings (const std::vector &objects, SPStyle } style_res->font_feature_settings.set = FALSE; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; @@ -1336,7 +1336,7 @@ objects_query_baselines (const std::vector &objects, SPStyle *style_res int texts = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; if (!isTextualItem(obj)) { @@ -1424,7 +1424,7 @@ objects_query_fontfamily (const std::vector &objects, SPStyle *style_re } style_res->font_family.set = FALSE; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; @@ -1480,7 +1480,7 @@ objects_query_fontspecification (const std::vector &objects, SPStyle *s } style_res->font_specification.set = FALSE; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; @@ -1538,7 +1538,7 @@ objects_query_blend (const std::vector &objects, SPStyle *style_res) bool same_blend = true; guint items = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; if (!obj) { continue; @@ -1628,7 +1628,7 @@ objects_query_blur (const std::vector &objects, SPStyle *style_res) guint blur_items = 0; guint items = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; if (!obj) { continue; -- cgit v1.2.3 From e16f1a053c67a8c42172f5186f247f11c3b6e777 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 22 Feb 2016 20:49:03 +0100 Subject: static code analysis (bzr r14664) --- src/desktop-style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 67c0687b7..a81cbdd1f 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1267,7 +1267,7 @@ objects_query_writing_modes (const std::vector &objects, SPStyle *style int texts = 0; - for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; if (!isTextualItem(obj)) { -- cgit v1.2.3 From a3f684fa5156f66fdcd3d15cc469d84258807201 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 7 Mar 2016 22:10:20 +0100 Subject: Add GUI for 'paint-order' property. (bzr r14693) --- src/desktop-style.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 10 deletions(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index a81cbdd1f..c36bcee44 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -881,8 +881,7 @@ objects_query_strokecap (const std::vector &objects, SPStyle *style_res return QUERY_STYLE_NOTHING; } - int cap = -1; - gdouble prev_cap = -1; + int prev_cap = -1; bool same_cap = true; int n_stroked = 0; @@ -905,11 +904,9 @@ objects_query_strokecap (const std::vector &objects, SPStyle *style_res if (prev_cap != -1 && style->stroke_linecap.value != prev_cap) same_cap = false; prev_cap = style->stroke_linecap.value; - - cap = style->stroke_linecap.value; } - style_res->stroke_linecap.value = cap; + style_res->stroke_linecap.value = prev_cap; style_res->stroke_linecap.set = true; if (n_stroked == 0) { @@ -935,8 +932,7 @@ objects_query_strokejoin (const std::vector &objects, SPStyle *style_re return QUERY_STYLE_NOTHING; } - int join = -1; - gdouble prev_join = -1; + int prev_join = -1; bool same_join = true; int n_stroked = 0; @@ -960,11 +956,9 @@ objects_query_strokejoin (const std::vector &objects, SPStyle *style_re same_join = false; } prev_join = style->stroke_linejoin.value; - - join = style->stroke_linejoin.value; } - style_res->stroke_linejoin.value = join; + style_res->stroke_linejoin.value = prev_join; style_res->stroke_linejoin.set = true; if (n_stroked == 0) { @@ -979,6 +973,62 @@ objects_query_strokejoin (const std::vector &objects, SPStyle *style_re } } +/** + * Write to style_res the paint order of a list of objects. + */ +int +objects_query_paintorder (const std::vector &objects, SPStyle *style_res) +{ + if (objects.empty()) { + /* No objects, set empty */ + return QUERY_STYLE_NOTHING; + } + + std::string prev_order; + bool same_order = true; + int n_order = 0; + + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { + SPObject *obj = *i; + if (!dynamic_cast(obj)) { + continue; + } + SPStyle *style = obj->style; + if (!style) { + continue; + } + + if ( style->stroke.isNone() ) { + continue; + } + + n_order ++; + + if (!prev_order.empty() && prev_order.compare( style->paint_order.value ) != 0) { + same_order = false; + } + if (style->paint_order.set) { + prev_order = style->paint_order.value; + } + } + + + g_free( style_res->paint_order.value ); + style_res->paint_order.value= g_strdup( prev_order.c_str() ); + style_res->paint_order.set = true; + + if (n_order == 0) { + return QUERY_STYLE_NOTHING; + } else if (n_order == 1) { + return QUERY_STYLE_SINGLE; + } else { + if (same_order) + return QUERY_STYLE_MULTIPLE_SAME; + else + return QUERY_STYLE_MULTIPLE_DIFFERENT; + } +} + /** * Write to style_res the average font size and spacing of objects. */ @@ -1763,6 +1813,8 @@ sp_desktop_query_style_from_list (const std::vector &list, SPStyle *sty } else if (property == QUERY_STYLE_PROPERTY_STROKEJOIN) { return objects_query_strokejoin (list, style); + } else if (property == QUERY_STYLE_PROPERTY_PAINTORDER) { + return objects_query_paintorder (list, style); } else if (property == QUERY_STYLE_PROPERTY_MASTEROPACITY) { return objects_query_opacity (list, style); @@ -1829,6 +1881,9 @@ sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query) int result_strokemiterlimit = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT); int result_strokecap = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKECAP); int result_strokejoin = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEJOIN); + + int result_paintorder = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_PAINTORDER); + int result_opacity = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY); int result_blur = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLUR); @@ -1842,6 +1897,7 @@ sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query) result_strokemiterlimit != QUERY_STYLE_NOTHING || result_strokecap != QUERY_STYLE_NOTHING || result_strokejoin != QUERY_STYLE_NOTHING || + result_paintorder != QUERY_STYLE_NOTHING || result_blur != QUERY_STYLE_NOTHING); } -- cgit v1.2.3 From 1c9e7ee09d40b8e06b80d0a09eca17d1b0fb8357 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sat, 12 Mar 2016 18:50:04 -0500 Subject: Add a units box to line height and wire in the style units, plus some cleanup (bzr r14701) --- src/desktop-style.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index c36bcee44..c28302d22 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1049,6 +1049,7 @@ objects_query_fontnumbers (const std::vector &objects, SPStyle *style_r double letterspacing_prev = 0; double wordspacing_prev = 0; double linespacing_prev = 0; + int linespacing_unit = 0; int texts = 0; int no_size = 0; @@ -1105,6 +1106,11 @@ objects_query_fontnumbers (const std::vector &objects, SPStyle *style_r linespacing_current = style->line_height.computed; linespacing_normal = false; } + if (linespacing_unit == 0) { + linespacing_unit = style->line_height.unit; + } else if (linespacing_unit != style->line_height.unit) { + linespacing_unit = SP_CSS_UNIT_PERCENT; + } linespacing += linespacing_current; if ((size_prev != 0 && style->font_size.computed != size_prev) || @@ -1148,7 +1154,7 @@ objects_query_fontnumbers (const std::vector &objects, SPStyle *style_r style_res->line_height.normal = linespacing_normal; style_res->line_height.computed = linespacing; style_res->line_height.value = linespacing; - style_res->line_height.unit = SP_CSS_UNIT_PERCENT; + style_res->line_height.unit = linespacing_unit; if (texts > 1) { if (different) { -- cgit v1.2.3