diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-11-10 17:23:11 +0000 |
|---|---|---|
| committer | jabiertxof <jabier.arraiza@marker.es> | 2015-11-10 17:23:11 +0000 |
| commit | 31aa6219ac721c59cb1a98788dbca7b7a58c5000 (patch) | |
| tree | dbc4a7d53b85eebecc9b76f3e47fb47f65ebf64e | |
| parent | merge of branch lp:~inkscape.dev/inkscape/spraytool-no-overlap (diff) | |
| download | inkscape-31aa6219ac721c59cb1a98788dbca7b7a58c5000.tar.gz inkscape-31aa6219ac721c59cb1a98788dbca7b7a58c5000.zip | |
Spray Tool: Change hide invisibe by over visible and over invisible, sugested by Ivan Louette
(bzr r14453)
| -rw-r--r-- | src/ui/tools/spray-tool.cpp | 47 | ||||
| -rw-r--r-- | src/ui/tools/spray-tool.h | 3 | ||||
| -rw-r--r-- | src/widgets/spray-toolbar.cpp | 41 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 3 |
4 files changed, 65 insertions, 29 deletions
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 17b82fe1d..99cb78936 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -178,7 +178,8 @@ SprayTool::SprayTool() , pickinversevalue(false) , pickfill(false) , pickstroke(false) - , visible(false) + , overtransparent(true) + , overnotransparent(true) , offset(0) { } @@ -259,7 +260,8 @@ void SprayTool::setup() { sp_event_context_read(this, "pickinversevalue"); sp_event_context_read(this, "pickfill"); sp_event_context_read(this, "pickstroke"); - sp_event_context_read(this, "visible"); + sp_event_context_read(this, "overnotransparent"); + sp_event_context_read(this, "overtransparent"); sp_event_context_read(this, "nooverlap"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -312,8 +314,10 @@ void SprayTool::set(const Inkscape::Preferences::Entry& val) { this->pickfill = val.getBool(); } else if (path == "pickstroke") { this->pickstroke = val.getBool(); - } else if (path == "visible") { - this->visible = val.getBool(); + } else if (path == "overnotransparent") { + this->overnotransparent = val.getBool(); + } else if (path == "overtransparent") { + this->overtransparent = val.getBool(); } else if (path == "nooverlap") { this->nooverlap = val.getBool(); } @@ -440,7 +444,8 @@ static bool fit_item(SPDesktop *desktop, bool pickinversevalue, bool pickfill, bool pickstroke, - bool visible, + bool overnotransparent, + bool overtransparent, bool nooverlap, double offset, SPCSSAttr *css, @@ -485,7 +490,10 @@ static bool fit_item(SPDesktop *desktop, ink_cairo_surface_average_color(s, R, G, B, A); cairo_surface_destroy(s); guint32 rgba = SP_RGBA32_F_COMPOSE(R, G, B, A); - if(nooverlap && visible && (A==0 || A < 1e-6)){ + if(nooverlap && !overtransparent && (A==0 || A < 1e-6)){ + return false; + } + if(nooverlap && !overnotransparent && A>0){ return false; } size = std::min(width_transformed,height_transformed); @@ -525,14 +533,14 @@ static bool fit_item(SPDesktop *desktop, std::abs(bbox_top - bbox_top_main) > std::abs(offset_min))){ return false; } - } else if(picker || visible){ + } else if(picker || !overtransparent || !overnotransparent){ item_down->setHidden(true); item_down->updateRepr(); } } } } - if(picker || visible){ + if(picker || !overtransparent || !overnotransparent){ if(!nooverlap){ doc->ensureUpToDate(); } @@ -555,7 +563,10 @@ static bool fit_item(SPDesktop *desktop, g = 1; b = 1; } - if(visible && (a == 0 || a < 1e-6)){ + if(!overtransparent && (a == 0 || a < 1e-6)){ + return false; + } + if(!overnotransparent && a >0){ return false; } @@ -649,7 +660,8 @@ static bool fit_item(SPDesktop *desktop, pickinversevalue, pickfill, pickstroke, - visible, + overnotransparent, + overtransparent, nooverlap, offset, css, @@ -699,7 +711,7 @@ static bool fit_item(SPDesktop *desktop, sp_repr_css_set_property(css, "stroke", color_string); } } - if(!nooverlap && (picker || visible)){ + if(!nooverlap && (picker || !overtransparent || !overnotransparent)){ for (std::vector<SPItem *>::const_iterator k=items_down.begin(); k!=items_down.end(); k++) { SPItem *item_hidden = *k; item_hidden->setHidden(false); @@ -732,7 +744,8 @@ static bool sp_spray_recursive(SPDesktop *desktop, bool pickinversevalue, bool pickfill, bool pickstroke, - bool visible, + bool overnotransparent, + bool overtransparent, double offset, bool usepressurescale, double pressure) @@ -773,8 +786,8 @@ static bool sp_spray_recursive(SPDesktop *desktop, Geom::Point center = item->getCenter(); Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); SPCSSAttr *css = sp_repr_css_attr_new(); - if(nooverlap || picker || visible){ - if(!fit_item(desktop, item, a, move, center, angle, _scale, scale, picker, pickinversevalue, pickfill, pickstroke, visible, nooverlap, offset, css, false)){ + if(nooverlap || picker || !overtransparent || !overnotransparent){ + if(!fit_item(desktop, item, a, move, center, angle, _scale, scale, picker, pickinversevalue, pickfill, pickstroke, overnotransparent, overtransparent, nooverlap, offset, css, false)){ return false; } } @@ -880,8 +893,8 @@ static bool sp_spray_recursive(SPDesktop *desktop, Geom::Point center=item->getCenter(); Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); SPCSSAttr *css = sp_repr_css_attr_new(); - if(nooverlap || picker || visible){ - if(!fit_item(desktop, item, a, move, center, angle, _scale, scale, picker, pickinversevalue, pickfill, pickstroke, visible, nooverlap, offset, css, false)){ + if(nooverlap || picker || !overtransparent || !overnotransparent){ + if(!fit_item(desktop, item, a, move, center, angle, _scale, scale, picker, pickinversevalue, pickfill, pickstroke, overnotransparent, overtransparent, nooverlap, offset, css, false)){ return false; } } @@ -959,7 +972,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = *i; g_assert(item != NULL); - if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, population, tc->scale, tc->scale_variation, reverse, move_mean, move_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib, tc->nooverlap, tc->picker, tc->pickinversevalue, tc->pickfill, tc->pickstroke, tc->visible, tc->offset, tc->usepressurescale, get_pressure(tc))) { + if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, population, tc->scale, tc->scale_variation, reverse, move_mean, move_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib, tc->nooverlap, tc->picker, tc->pickinversevalue, tc->pickfill, tc->pickstroke, tc->overnotransparent, tc->overtransparent, tc->offset, tc->usepressurescale, get_pressure(tc))) { did = true; } } diff --git a/src/ui/tools/spray-tool.h b/src/ui/tools/spray-tool.h index ca0c20375..ba4e75f70 100644 --- a/src/ui/tools/spray-tool.h +++ b/src/ui/tools/spray-tool.h @@ -94,7 +94,8 @@ public: bool pickinversevalue; bool pickfill; bool pickstroke; - bool visible; + bool overtransparent; + bool overnotransparent; double offset; sigc::connection style_set_connection; diff --git a/src/widgets/spray-toolbar.cpp b/src/widgets/spray-toolbar.cpp index 5e0d81964..fe69b5050 100644 --- a/src/widgets/spray-toolbar.cpp +++ b/src/widgets/spray-toolbar.cpp @@ -186,13 +186,21 @@ static void sp_toggle_pressure_scale( GtkToggleAction* act, gpointer data) sp_stb_sensitivize( tbl ); } -static void sp_toggle_visible( GtkToggleAction* act, gpointer data) +static void sp_toggle_over_no_transparent( GtkToggleAction* act, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gboolean active = gtk_toggle_action_get_active(act); - prefs->setBool("/tools/spray/visible", active); + prefs->setBool("/tools/spray/overnotransparent", active); } +static void sp_toggle_over_transparent( GtkToggleAction* act, gpointer data) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + gboolean active = gtk_toggle_action_get_active(act); + prefs->setBool("/tools/spray/overtransparent", active); +} + + static void sp_toggle_picker( GtkToggleAction* act, gpointer data ) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -472,17 +480,30 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pick_stroke), holder) ; gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); } - - /* Visible */ + + /* Over Transparent */ + { + InkToggleAction* act = ink_toggle_action_new( "SprayOverTransparentAction", + _("Apply over transparent areas"), + _("Apply over transparent areas"), + INKSCAPE_ICON("object-hidden"), + secondarySize ); + gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/overtransparent", true) ); + g_object_set_data( holder, "overtransparent", act ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_over_transparent), holder) ; + gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + } + + /* Over No Transparent */ { - InkToggleAction* act = ink_toggle_action_new( "SprayOverVisibleAction", - _("Apply only over non transparent areas"), - _("Apply only over non transparent areas"), + InkToggleAction* act = ink_toggle_action_new( "SprayOverNoTransparentAction", + _("Apply over no transparent areas"), + _("Apply over no transparent areas"), INKSCAPE_ICON("object-visible"), secondarySize ); - gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/visible", false) ); - g_object_set_data( holder, "visible", act ); - g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_visible), holder) ; + gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/overnotransparent", true) ); + g_object_set_data( holder, "overnotransparent", act ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_over_no_transparent), holder) ; gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); } diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index cdb9e0d20..b9051dd50 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -321,7 +321,8 @@ static gchar const * ui_descr = " <toolitem action='SprayStandard_deviationAction' />" " <toolitem action='SprayMeanAction' />" " <separator />" - " <toolitem action='SprayOverVisibleAction' />" + " <toolitem action='SprayOverNoTransparentAction' />" + " <toolitem action='SprayOverTransparentAction' />" " <toolitem action='SprayNoOverlapAction' />" " <toolitem action='SprayToolOffsetAction' />" " <separator />" |
