diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2016-10-08 16:05:13 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marcjeanmougin@free.fr> | 2016-10-08 16:05:13 +0000 |
| commit | 6092d5422b03608db00f18e6ad8c87465b5dc3e8 (patch) | |
| tree | 2ae791c03acda4ca0bf1cc2fb309a94c39cbd058 /src/widgets | |
| parent | [Bug #770681] KEY MAPPING: Comma and period hijacked by scaling. (diff) | |
| parent | Made the style-utils.h license dual-with-GPLv2+. (diff) | |
| download | inkscape-6092d5422b03608db00f18e6ad8c87465b5dc3e8.tar.gz inkscape-6092d5422b03608db00f18e6ad8c87465b5dc3e8.zip | |
merge trunk-refactoring
(bzr r15156)
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/spray-toolbar.cpp | 4 | ||||
| -rw-r--r-- | src/widgets/stroke-style.cpp | 41 | ||||
| -rw-r--r-- | src/widgets/stroke-style.h | 1 | ||||
| -rw-r--r-- | src/widgets/style-utils.h | 45 | ||||
| -rw-r--r-- | src/widgets/text-toolbar.cpp | 3 |
5 files changed, 73 insertions, 21 deletions
diff --git a/src/widgets/spray-toolbar.cpp b/src/widgets/spray-toolbar.cpp index a724637e3..f456bc763 100644 --- a/src/widgets/spray-toolbar.cpp +++ b/src/widgets/spray-toolbar.cpp @@ -211,7 +211,7 @@ static void sp_toggle_pressure_scale( GtkToggleAction* act, gpointer data) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gboolean active = gtk_toggle_action_get_active(act); prefs->setBool("/tools/spray/usepressurescale", active); - if(active == true){ + if(active){ prefs->setDouble("/tools/spray/scale_variation", 0); } GObject *tbl = G_OBJECT(data); @@ -238,7 +238,7 @@ static void sp_toggle_picker( GtkToggleAction* act, gpointer data ) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gboolean active = gtk_toggle_action_get_active(act); prefs->setBool("/tools/spray/picker", active); - if(active == true){ + if(active){ prefs->setBool("/dialogs/clonetiler/dotrace", false); SPDesktop *dt = SP_ACTIVE_DESKTOP; if (Inkscape::UI::Dialog::CloneTiler *ct = get_clone_tiler_panel(dt)){ diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 4a658c5dc..81a8e8115 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -22,6 +22,7 @@ #include "svg/svg-color.h" #include "ui/widget/unit-menu.h" #include "desktop-widget.h" +#include "widgets/style-utils.h" using Inkscape::DocumentUndo; using Inkscape::Util::unit_table; @@ -437,6 +438,12 @@ StrokeStyle::makeRadioButton(Gtk::RadioButtonGroup &grp, return tb; } +bool StrokeStyle::shouldMarkersBeUpdated() +{ + return startMarkerCombo->update() || midMarkerCombo->update() || + endMarkerCombo->update(); +} + /** * Handles when user selects one of the markers from the marker combobox. * Gets the marker uri string and applies it to all selected @@ -444,11 +451,7 @@ StrokeStyle::makeRadioButton(Gtk::RadioButtonGroup &grp, */ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, SPMarkerLoc const /*which*/) { - bool markers_update = spw->startMarkerCombo->update() || - spw->midMarkerCombo->update() || - spw->endMarkerCombo->update(); - - if (spw->update || markers_update) { + if (spw->update || spw->shouldMarkersBeUpdated()) { return; } @@ -910,22 +913,20 @@ StrokeStyle::updateLine() if (result_ml != QUERY_STYLE_NOTHING) (*miterLimitAdj)->set_value(query.stroke_miterlimit.value); // TODO: reflect averagedness? - if (result_join != QUERY_STYLE_MULTIPLE_DIFFERENT && - result_join != QUERY_STYLE_NOTHING ) { + using Inkscape::is_query_style_updateable; + if (! is_query_style_updateable(result_join)) { setJoinType(query.stroke_linejoin.value); } else { setJoinButtons(NULL); } - if (result_cap != QUERY_STYLE_MULTIPLE_DIFFERENT && - result_cap != QUERY_STYLE_NOTHING ) { + if (! is_query_style_updateable(result_cap)) { setCapType (query.stroke_linecap.value); } else { setCapButtons(NULL); } - if (result_order != QUERY_STYLE_MULTIPLE_DIFFERENT && - result_order != QUERY_STYLE_NOTHING ) { + if (! is_query_style_updateable(result_order)) { setPaintOrder (query.paint_order.value); } else { setPaintOrder (NULL); @@ -976,6 +977,16 @@ StrokeStyle::setScaledDash(SPCSSAttr *css, } } +static inline double calcScaleLineWidth(const double width_typed, SPItem *const item, Inkscape::Util::Unit const *const unit) +{ + if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { + return Inkscape::Util::Quantity::convert(width_typed, unit, "px"); + } else { // percentage + const gdouble old_w = item->style->stroke_width.computed; + return old_w * width_typed / 100; + } +} + /** * Sets line properties like width, dashes, markers, etc. on all currently selected items. */ @@ -1007,13 +1018,7 @@ StrokeStyle::scaleLine() for(auto i=items.begin();i!=items.end();++i){ /* Set stroke width */ - double width; - if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { - width = Inkscape::Util::Quantity::convert(width_typed, unit, "px"); - } else { // percentage - gdouble old_w = (*i)->style->stroke_width.computed; - width = old_w * width_typed / 100; - } + const double width = calcScaleLineWidth(width_typed, (*i), unit); { Inkscape::CSSOStringStream os_width; diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h index 76582602d..2d7e187a1 100644 --- a/src/widgets/stroke-style.h +++ b/src/widgets/stroke-style.h @@ -177,6 +177,7 @@ private: void miterLimitChangedCB(); void lineDashChangedCB(); void unitChangedCB(); + bool shouldMarkersBeUpdated(); static void markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, SPMarkerLoc const which); static void buttonToggledCB(StrokeStyleButton *tb, StrokeStyle *spw); diff --git a/src/widgets/style-utils.h b/src/widgets/style-utils.h new file mode 100644 index 000000000..65b635f0c --- /dev/null +++ b/src/widgets/style-utils.h @@ -0,0 +1,45 @@ +/** + * @file + * Common utility functions for manipulating style. + */ +/* Author: + * Shlomi Fish <shlomif@cpan.org> + * + * Copyright (C) 2016 Shlomi Fish + * + * Dually-Licensed under: + * + * 1. The Expat license - https://www.gnu.org/licenses/license-list.html#Expat + * + * 2. The GNU General Public License, either version 2, or at your option, + * any later version of it. + * ( https://en.wikipedia.org/wiki/GNU_General_Public_License ) + */ + +#ifndef SEEN_DIALOGS_STYLE_UTILS_H +#define SEEN_DIALOGS_STYLE_UTILS_H + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "desktop-style.h" + +namespace Inkscape { + inline bool is_query_style_updateable(const int style) { + return (style == QUERY_STYLE_MULTIPLE_DIFFERENT || style == QUERY_STYLE_NOTHING); + } +} // namespace Inkscape + +#endif // SEEN_DIALOGS_STYLE_UTILS_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 4b22c8d7e..610d743a0 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -41,6 +41,7 @@ #include "ink-radio-action.h" #include "ink-toggle-action.h" #include "widgets/ink-comboboxentry-action.h" +#include "widgets/style-utils.h" #include "inkscape.h" #include "selection-chemistry.h" #include "sp-flowtext.h" @@ -304,7 +305,7 @@ static void sp_text_script_changed( InkToggleAction* act, GObject *tbl ) bool setSuper = false; bool setSub = false; - if(result_baseline == QUERY_STYLE_NOTHING || result_baseline == QUERY_STYLE_MULTIPLE_DIFFERENT ) { + if (Inkscape::is_query_style_updateable(result_baseline)) { // If not set or mixed, turn on superscript or subscript if( prop == 0 ) { setSuper = true; |
