summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicolas Dufour <nicoduf@yahoo.fr>2011-03-29 17:30:25 +0000
committerJazzyNico <nicoduf@yahoo.fr>2011-03-29 17:30:25 +0000
commit4e9fcca4f83f765ab147790d04e251a2bdbd9879 (patch)
treee5d5c5dadbed7c41be2510ee60e7f4ccd80198cc /src
parentdxf input. modify stop command (Bug 739803) (diff)
downloadinkscape-4e9fcca4f83f765ab147790d04e251a2bdbd9879.tar.gz
inkscape-4e9fcca4f83f765ab147790d04e251a2bdbd9879.zip
Spray:
* Spray context code clean-up (coding style and unused code removal). * Shift+k and Shift+l shortcuts inverted to reflect the mode order on azerty and qwerty keyboards. * Up and down keys now modify the population parameter. * Tooltips and status messages consistency fixes. * Old Q_() context replaced with C_() context macro. * Fix default values error in the parameters sliders. * Initial fix for duplicate window parameters update (the pressure button now updates as expected). * Fix a bug when spraying with GDK_SCROLL_DOWN (population value was reset to 100). * Default selcue set to 1, default gradient drag set to 0. Eraser: * Reodering the eraser tool parameters for UI consistency. * Default mode set to Cut out a path, default width set to 10. (bzr r10132)
Diffstat (limited to 'src')
-rw-r--r--src/preferences-skeleton.h6
-rw-r--r--src/spray-context.cpp693
-rw-r--r--src/spray-context.h5
-rw-r--r--src/widgets/toolbox.cpp87
4 files changed, 332 insertions, 459 deletions
diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h
index 0acb3c9e2..124a2ae51 100644
--- a/src/preferences-skeleton.h
+++ b/src/preferences-skeleton.h
@@ -106,8 +106,8 @@ static char const preferences_skeleton[] =
" <group id=\"cp5\" name=\"" N_("Tracing") "\" width=\"50\" mass=\"0\" wiggle=\"0.0\" angle=\"0.0\" thinning=\"0.0\" tremor=\"0.0\" flatness=\"0\" cap_rounding=\"0.0\" tracebackground=\"1\" usepressure=\"1\" usetilt=\"1\"/>\n"
" </group>\n"
" </eventcontext>\n"
-" <eventcontext id=\"eraser\" mode=\"0\" style=\"fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;\"\n"
-" mass=\"0.02\" drag=\"1\" angle=\"30\" width=\"0.15\" thinning=\"0.1\" flatness=\"0.0\" cap_rounding=\"1.4\" usecurrent=\"0\"\n"
+" <eventcontext id=\"eraser\" mode=\"1\" style=\"fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;\"\n"
+" mass=\"0.02\" drag=\"1\" angle=\"30\" width=\"10\" thinning=\"0.1\" flatness=\"0.0\" cap_rounding=\"1.4\" usecurrent=\"0\"\n"
" tracebackground=\"0\" usepressure=\"1\" usetilt=\"0\" selcue=\"1\">\n"
" </eventcontext>\n"
" <eventcontext id=\"lpetool\" mode=\"drag\" style=\"fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;\">\n"
@@ -118,7 +118,7 @@ static char const preferences_skeleton[] =
" style=\"fill:black;fill-opacity:1;stroke:none;font-family:Sans;font-style:normal;font-weight:normal;font-size:40px;\" selcue=\"1\"/>\n"
" <eventcontext id=\"nodes\" selcue=\"1\" gradientdrag=\"1\" highlight_color=\"4278190335\" pathflash_enabled=\"1\" pathflash_unselected=\"0\" pathflash_timeout=\"500\" show_handles=\"1\" show_outline=\"0\" sculpting_profile=\"1\" single_node_transform_handles=\"0\" show_transform_handles=\"0\" live_outline=\"1\" live_objects=\"1\" show_helperpath=\"0\" x=\"0\" y=\"0\" edit_clipping_paths=\"0\" edit_masks=\"0\" />\n"
" <eventcontext id=\"tweak\" selcue=\"0\" gradientdrag=\"0\" show_handles=\"0\" width=\"0.2\" force=\"0.2\" fidelity=\"0.5\" usepressure=\"1\" style=\"fill:red;stroke:none;\" usecurrent=\"0\"/>\n"
-" <eventcontext id=\"spray\" usepressure=\"1\" width=\"15\" population=\"70\" mode=\"1\" rotation_variation=\"0\" scale_variation=\"0\" standard_deviation=\"70\" mean=\"0\"/>\n"
+" <eventcontext id=\"spray\" selcue=\"1\" gradientdrag=\"0\" usepressure=\"1\" width=\"15\" population=\"70\" mode=\"1\" rotation_variation=\"0\" scale_variation=\"0\" standard_deviation=\"70\" mean=\"0\"/>\n"
" <eventcontext id=\"gradient\" selcue=\"1\"/>\n"
" <eventcontext id=\"zoom\" selcue=\"1\" gradientdrag=\"0\"/>\n"
" <eventcontext id=\"dropper\" selcue=\"1\" gradientdrag=\"1\" pick=\"1\" setalpha=\"1\"/>\n"
diff --git a/src/spray-context.cpp b/src/spray-context.cpp
index e7ef9d317..ae74b09da 100644
--- a/src/spray-context.cpp
+++ b/src/spray-context.cpp
@@ -36,7 +36,6 @@
#include "desktop-events.h"
#include "desktop-handles.h"
#include "unistd.h"
-#include "desktop-style.h"
#include "message-context.h"
#include "pixmaps/cursor-spray.xpm"
#include <boost/optional.hpp>
@@ -46,19 +45,13 @@
#include "context-fns.h"
#include "sp-item.h"
#include "inkscape.h"
-#include "color.h"
-#include "svg/svg-color.h"
+
#include "splivarot.h"
#include "sp-item-group.h"
#include "sp-shape.h"
#include "sp-path.h"
#include "path-chemistry.h"
-#include "sp-gradient.h"
-#include "sp-stop.h"
-#include "sp-gradient-reference.h"
-#include "sp-linear-gradient.h"
-#include "sp-radial-gradient.h"
-#include "gradient-chemistry.h"
+
#include "sp-text.h"
#include "sp-flowtext.h"
#include "display/sp-canvas.h"
@@ -73,8 +66,6 @@
#include "box3d.h"
#include "sp-item-transform.h"
#include "filter-chemistry.h"
-#include "sp-gaussian-blur-fns.h"
-#include "sp-gaussian-blur.h"
#include "spray-context.h"
#include "ui/dialog/dialog-manager.h"
@@ -85,9 +76,7 @@
using Inkscape::DocumentUndo;
using namespace std;
-
#define DDC_RED_RGBA 0xff0000ff
-
#define DYNA_MIN_WIDTH 1.0e-6
static void sp_spray_context_class_init(SPSprayContextClass *klass);
@@ -106,13 +95,12 @@ static SPEventContextClass *parent_class = 0;
* @param mu : mean
* @param sigma : standard deviation ( > 0 )
*/
-inline double NormalDistribution(double mu,double sigma)
+inline double NormalDistribution(double mu, double sigma)
{
// use Box Muller's algorithm
return mu + sigma * sqrt( -2.0 * log(g_random_double_range(0, 1)) ) * cos( 2.0*M_PI*g_random_double_range(0, 1) );
}
-
GtkType sp_spray_context_get_type(void)
{
static GType type = 0;
@@ -147,7 +135,7 @@ static void sp_spray_context_class_init(SPSprayContextClass *klass)
}
/* Method to rotate items */
-void sp_spray_rotate_rel(Geom::Point c,SPDesktop */*desktop*/,SPItem *item, Geom::Rotate const &rotation)
+void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Rotate const &rotation)
{
Geom::Point center = c;
Geom::Translate const s(c);
@@ -164,10 +152,10 @@ void sp_spray_rotate_rel(Geom::Point c,SPDesktop */*desktop*/,SPItem *item, Geom
}
/* Method to scale items */
-void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale const &scale)
+void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale const &scale)
{
Geom::Translate const s(c);
- item->set_i2d_affine(item->i2d_affine() * s.inverse() * scale * s );
+ item->set_i2d_affine(item->i2d_affine() * s.inverse() * scale * s);
item->doWriteTransform(item->getRepr(), item->transform);
}
@@ -185,22 +173,17 @@ static void sp_spray_context_init(SPSprayContext *tc)
tc->width = 0.2;
tc->force = 0.2;
tc->ratio = 0;
- tc->tilt=0;
+ tc->tilt = 0;
tc->mean = 0.2;
- tc->rotation_variation=0;
- tc->standard_deviation=0.2;
- tc->scale=1;
+ tc->rotation_variation = 0;
+ tc->standard_deviation = 0.2;
+ tc->scale = 1;
tc->scale_variation = 1;
tc->pressure = TC_DEFAULT_PRESSURE;
tc->is_dilating = false;
tc->has_dilated = false;
- tc->do_h = true;
- tc->do_s = true;
- tc->do_l = true;
- tc->do_o = false;
-
new (&tc->style_set_connection) sigc::connection();
}
@@ -233,8 +216,8 @@ bool is_transform_modes(gint mode)
void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/)
{
- SPEventContext *event_context = SP_EVENT_CONTEXT(tc);
- SPDesktop *desktop = event_context->desktop;
+ SPEventContext *event_context = SP_EVENT_CONTEXT(tc);
+ SPDesktop *desktop = event_context->desktop;
guint num = 0;
gchar *sel_message = NULL;
@@ -248,13 +231,13 @@ void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/)
switch (tc->mode) {
case SPRAY_MODE_COPY:
- tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray <b>copies</b> of the initial selection"), sel_message);
+ tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray <b>copies</b> of the initial selection."), sel_message);
break;
case SPRAY_MODE_CLONE:
- tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray <b>clones</b> of the initial selection"), sel_message);
+ tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray <b>clones</b> of the initial selection."), sel_message);
break;
case SPRAY_MODE_SINGLE_PATH:
- tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray in a <b>single path</b> of the initial selection"), sel_message);
+ tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or scroll to spray in a <b>single path</b> of the initial selection."), sel_message);
break;
default:
break;
@@ -267,8 +250,9 @@ static void sp_spray_context_setup(SPEventContext *ec)
{
SPSprayContext *tc = SP_SPRAY_CONTEXT(ec);
- if (((SPEventContextClass *) parent_class)->setup)
+ if (((SPEventContextClass *) parent_class)->setup) {
((SPEventContextClass *) parent_class)->setup(ec);
+ }
{
/* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */
@@ -304,18 +288,11 @@ static void sp_spray_context_setup(SPEventContext *ec)
sp_event_context_read(ec, "standard_deviation");
sp_event_context_read(ec, "usepressure");
sp_event_context_read(ec, "Scale");
- sp_event_context_read(ec, "doh");
- sp_event_context_read(ec, "dol");
- sp_event_context_read(ec, "dos");
- sp_event_context_read(ec, "doo");
-
- ;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/spray/selcue")) {
ec->enableSelectionCue();
}
-
if (prefs->getBool("/tools/spray/gradientdrag")) {
ec->enableGrDrag();
}
@@ -326,56 +303,47 @@ static void sp_spray_context_set(SPEventContext *ec, Inkscape::Preferences::Entr
SPSprayContext *tc = SP_SPRAY_CONTEXT(ec);
Glib::ustring path = val->getEntryName();
- if (path == "width") {
- tc->width = 0.01 * CLAMP(val->getInt(10), 1, 100);
- } else if (path == "mode") {
+ if (path == "mode") {
tc->mode = val->getInt();
sp_spray_update_cursor(tc, false);
- } else if (path == "distribution") {
- tc->distrib = val->getInt(1);
+ } else if (path == "width") {
+ tc->width = 0.01 * CLAMP(val->getInt(10), 1, 100);
+ } else if (path == "usepressure") {
+ tc->usepressure = val->getBool();
} else if (path == "population") {
tc->population = 0.01 * CLAMP(val->getInt(10), 1, 100);
- } else if (path == "tilt") {
- tc->tilt = CLAMP(val->getDouble(0.1), 0, 1000.0);
- } else if (path == "ratio") {
- tc->ratio = CLAMP(val->getDouble(), 0.0, 0.9);
- } else if (path == "force") {
- tc->force = CLAMP(val->getDouble(1.0), 0, 1.0);
} else if (path == "rotation_variation") {
tc->rotation_variation = CLAMP(val->getDouble(0.0), 0, 100.0);
} else if (path == "scale_variation") {
tc->scale_variation = CLAMP(val->getDouble(1.0), 0, 100.0);
- } else if (path == "mean") {
- tc->mean = 0.01 * CLAMP(val->getInt(10), 1, 100);
} else if (path == "standard_deviation") {
tc->standard_deviation = 0.01 * CLAMP(val->getInt(10), 1, 100);
- } else if (path == "usepressure") {
- tc->usepressure = val->getBool();
- } else if (path == "doh") {
- tc->do_h = val->getBool();
- } else if (path == "dos") {
- tc->do_s = val->getBool();
- } else if (path == "dol") {
- tc->do_l = val->getBool();
- } else if (path == "doo") {
- tc->do_o = val->getBool();
- }
+ } else if (path == "mean") {
+ tc->mean = 0.01 * CLAMP(val->getInt(10), 1, 100);
+// Not implemented in the toolbar and preferences yet
+ } else if (path == "distribution") {
+ tc->distrib = val->getInt(1);
+ } else if (path == "tilt") {
+ tc->tilt = CLAMP(val->getDouble(0.1), 0, 1000.0);
+ } else if (path == "ratio") {
+ tc->ratio = CLAMP(val->getDouble(), 0.0, 0.9);
+ } else if (path == "force") {
+ tc->force = CLAMP(val->getDouble(1.0), 0, 1.0);
+ }
}
static void sp_spray_extinput(SPSprayContext *tc, GdkEvent *event)
{
- if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &tc->pressure))
- tc->pressure = CLAMP (tc->pressure, TC_MIN_PRESSURE, TC_MAX_PRESSURE);
- else
+ if (gdk_event_get_axis(event, GDK_AXIS_PRESSURE, &tc->pressure)) {
+ tc->pressure = CLAMP(tc->pressure, TC_MIN_PRESSURE, TC_MAX_PRESSURE);
+ } else {
tc->pressure = TC_DEFAULT_PRESSURE;
+ }
}
double get_dilate_radius(SPSprayContext *tc)
{
-
return 250 * tc->width/SP_EVENT_CONTEXT(tc)->desktop->current_zoom();
-
-
}
double get_path_force(SPSprayContext *tc)
@@ -423,29 +391,25 @@ double get_move_standard_deviation(SPSprayContext *tc)
* @param[in] choice :
*/
-void random_position( double &radius, double &angle, double &a, double &s, int /*choice*/)
+void random_position(double &radius, double &angle, double &a, double &s, int /*choice*/)
{
// angle is taken from an uniform distribution
angle = g_random_double_range(0, M_PI*2.0);
// radius is taken from a Normal Distribution
double radius_temp =-1;
- while(!((radius_temp>=0)&&(radius_temp<=1)))
+ while(!((radius_temp >= 0) && (radius_temp <=1 )))
{
- radius_temp = NormalDistribution( a, s );
+ radius_temp = NormalDistribution(a, s);
}
// Because we are in polar coordinates, a special treatment has to be done to the radius.
// Otherwise, positions taken from an uniform repartition on radius and angle will not seam to
// be uniformily distributed on the disk (more at the center and less at the boundary).
// We counter this effect with a 0.5 exponent. This is empiric.
- radius = pow( radius_temp, 0.5);
+ radius = pow(radius_temp, 0.5);
}
-
-
-
-
bool sp_spray_recursive(SPDesktop *desktop,
Inkscape::Selection *selection,
SPItem *item,
@@ -463,7 +427,7 @@ bool sp_spray_recursive(SPDesktop *desktop,
double ratio,
double tilt,
double rotation_variation,
- gint _distrib )
+ gint _distrib)
{
bool did = false;
@@ -473,7 +437,7 @@ bool sp_spray_recursive(SPDesktop *desktop,
selection->add(item);
}
- double _fid = g_random_double_range(0,1);
+ double _fid = g_random_double_range(0, 1);
double angle = g_random_double_range( - rotation_variation / 100.0 * M_PI , rotation_variation / 100.0 * M_PI );
double _scale = g_random_double_range( 1.0 - scale_variation / 100.0, 1.0 + scale_variation / 100.0 );
double dr; double dp;
@@ -484,7 +448,7 @@ bool sp_spray_recursive(SPDesktop *desktop,
Geom::OptRect a = item->getBounds(item->i2doc_affine());
if (a) {
SPItem *item_copied;
- if(_fid<=population)
+ if(_fid <= population)
{
// duplicate
SPDocument *doc = item->document;
@@ -497,12 +461,12 @@ bool sp_spray_recursive(SPDesktop *desktop,
SPObject *new_obj = doc->getObjectByRepr(copy);
item_copied = (SPItem *) new_obj; //convertion object->item
Geom::Point center=item->getCenter();
- sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale));
- sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale));
+ sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(_scale,_scale));
+ sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(scale,scale));
sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle));
//Move the cursor p
- 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());
+ 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());
sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
did = true;
}
@@ -520,11 +484,11 @@ bool sp_spray_recursive(SPDesktop *desktop,
items = items->next) {
SPItem *item1 = (SPItem *) items->data;
- if (i==1) {
- father=item1;
+ if (i == 1) {
+ father = item1;
}
- if (i==2) {
- unionResult=item1;
+ if (i == 2) {
+ unionResult = item1;
}
i++;
}
@@ -535,16 +499,16 @@ bool sp_spray_recursive(SPDesktop *desktop,
Geom::OptRect a = father->getBounds(father->i2doc_affine());
if (a) {
- if (i==2) {
+ if (i == 2) {
Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc);
parent->appendChild(copy1);
SPObject *new_obj1 = doc->getObjectByRepr(copy1);
son = (SPItem *) new_obj1; // conversion object->item
- unionResult=son;
+ unionResult = son;
Inkscape::GC::release(copy1);
- }
+ }
- if (_fid<=population) { // Rules the population of objects sprayed
+ if (_fid <= population) { // Rules the population of objects sprayed
// duplicates the father
Inkscape::XML::Node *copy2 = old_repr->duplicate(xml_doc);
parent->appendChild(copy2);
@@ -552,12 +516,12 @@ bool sp_spray_recursive(SPDesktop *desktop,
item_copied = (SPItem *) new_obj2;
// Move around the cursor
- 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());
+ 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());
Geom::Point center=father->getCenter();
- sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale));
- sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale));
- sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle));
+ sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale));
+ sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale));
+ sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle));
sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
// union and duplication
@@ -573,7 +537,7 @@ bool sp_spray_recursive(SPDesktop *desktop,
} else if (mode == SPRAY_MODE_CLONE) {
Geom::OptRect a = item->getBounds(item->i2doc_affine());
if (a) {
- if(_fid<=population) {
+ if(_fid <= population) {
SPItem *item_copied;
SPDocument *doc = item->document;
Inkscape::XML::Document* xml_doc = doc->getReprDoc();
@@ -590,11 +554,11 @@ bool sp_spray_recursive(SPDesktop *desktop,
SPObject *clone_object = doc->getObjectByRepr(clone);
// conversion object->item
item_copied = (SPItem *) clone_object;
- Geom::Point center=item->getCenter();
- sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale));
- sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale));
- sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle));
- 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());
+ Geom::Point center = item->getCenter();
+ sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale));
+ sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale));
+ sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle));
+ 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());
sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
Inkscape::GC::release(clone);
@@ -612,35 +576,12 @@ bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p,
Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(tc)->desktop);
SPDesktop *desktop = SP_EVENT_CONTEXT(tc)->desktop;
-
if (selection->isEmpty()) {
return false;
}
bool did = false;
double radius = get_dilate_radius(tc);
-
-
-
- bool do_fill = false, do_stroke = false, do_opacity = false;
- guint32 fill_goal = sp_desktop_get_color_tool(desktop, "/tools/spray", true, &do_fill);
- guint32 stroke_goal = sp_desktop_get_color_tool(desktop, "/tools/spray", false, &do_stroke);
- double opacity_goal = sp_desktop_get_master_opacity_tool(desktop, "/tools/spray", &do_opacity);
- if (reverse) {
- // RGB inversion
- fill_goal = SP_RGBA32_U_COMPOSE(
- (255 - SP_RGBA32_R_U(fill_goal)),
- (255 - SP_RGBA32_G_U(fill_goal)),
- (255 - SP_RGBA32_B_U(fill_goal)),
- (255 - SP_RGBA32_A_U(fill_goal)));
- stroke_goal = SP_RGBA32_U_COMPOSE(
- (255 - SP_RGBA32_R_U(stroke_goal)),
- (255 - SP_RGBA32_G_U(stroke_goal)),
- (255 - SP_RGBA32_B_U(stroke_goal)),
- (255 - SP_RGBA32_A_U(stroke_goal)));
- opacity_goal = 1 - opacity_goal;
- }
-
double path_force = get_path_force(tc);
if (radius == 0 || path_force == 0) {
return false;
@@ -657,7 +598,6 @@ bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p,
double move_mean = get_move_mean(tc);
double move_standard_deviation = get_move_standard_deviation(tc);
-
for (GSList *items = g_slist_copy((GSList *) selection->itemList());
items != NULL;
items = items->next) {
@@ -665,10 +605,10 @@ bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p,
SPItem *item = (SPItem *) items->data;
if (is_transform_modes(tc->mode)) {
- if (sp_spray_recursive (desktop,selection, item, p, vector, tc->mode, radius, move_force, tc->population,tc->scale, tc->scale_variation, reverse, move_mean, move_standard_deviation,tc->ratio,tc->tilt, tc->rotation_variation, tc->distrib))
+ if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, move_force, tc->population, tc->scale, tc->scale_variation, reverse, move_mean, move_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib))
did = true;
} else {
- if (sp_spray_recursive (desktop,selection, item, p, vector, tc->mode, radius, path_force, tc->population,tc->scale, tc->scale_variation, reverse, path_mean, path_standard_deviation,tc->ratio,tc->tilt, tc->rotation_variation, tc->distrib))
+ if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, path_force, tc->population, tc->scale, tc->scale_variation, reverse, path_mean, path_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib))
did = true;
}
}
@@ -678,36 +618,35 @@ bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p,
void sp_spray_update_area(SPSprayContext *tc)
{
- double radius = get_dilate_radius(tc);
- Geom::Affine const sm ( Geom::Scale(radius/(1-tc->ratio), radius/(1+tc->ratio)) );
- sp_canvas_item_affine_absolute(tc->dilate_area, (sm* Geom::Rotate(tc->tilt))* Geom::Translate(SP_EVENT_CONTEXT(tc)->desktop->point()));
- sp_canvas_item_show(tc->dilate_area);
+ double radius = get_dilate_radius(tc);
+ Geom::Affine const sm ( Geom::Scale(radius/(1-tc->ratio), radius/(1+tc->ratio)) );
+ sp_canvas_item_affine_absolute(tc->dilate_area, (sm* Geom::Rotate(tc->tilt))* Geom::Translate(SP_EVENT_CONTEXT(tc)->desktop->point()));
+ sp_canvas_item_show(tc->dilate_area);
}
void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift)
{
// select the button mode
- SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("spray_tool_mode", mode);
+ SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue("spray_tool_mode", mode);
// need to set explicitly, because the prefs may not have changed by the previous
tc->mode = mode;
- sp_spray_update_cursor (tc, with_shift);
+ sp_spray_update_cursor(tc, with_shift);
}
void sp_spray_switch_mode_temporarily(SPSprayContext *tc, gint mode, bool with_shift)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- // Juggling about so that prefs have the old value but tc->mode and the button show new mode:
- gint now_mode = prefs->getInt("/tools/spray/mode", 0);
- SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("spray_tool_mode", mode);
- // button has changed prefs, restore
- prefs->setInt("/tools/spray/mode", now_mode);
- // changing prefs changed tc->mode, restore back :)
- tc->mode = mode;
- sp_spray_update_cursor (tc, with_shift);
+ // Juggling about so that prefs have the old value but tc->mode and the button show new mode:
+ gint now_mode = prefs->getInt("/tools/spray/mode", 0);
+ SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue("spray_tool_mode", mode);
+ // button has changed prefs, restore
+ prefs->setInt("/tools/spray/mode", now_mode);
+ // changing prefs changed tc->mode, restore back :)
+ tc->mode = mode;
+ sp_spray_update_cursor(tc, with_shift);
}
-gint sp_spray_context_root_handler(SPEventContext *event_context,
- GdkEvent *event)
+gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *event)
{
SPSprayContext *tc = SP_SPRAY_CONTEXT(event_context);
SPDesktop *desktop = event_context->desktop;
@@ -723,13 +662,11 @@ gint sp_spray_context_root_handler(SPEventContext *event_context,
break;
case GDK_BUTTON_PRESS:
if (event->button.button == 1 && !event_context->space_panning) {
-
if (Inkscape::have_viable_layer(desktop, tc->_message_context) == false) {
return TRUE;
}
- Geom::Point const motion_w(event->button.x,
- event->button.y);
+ Geom::Point const motion_w(event->button.x, event->button.y);
Geom::Point const motion_dt(desktop->w2d(motion_w));
tc->last_push = desktop->dt2doc(motion_dt);
@@ -738,23 +675,17 @@ gint sp_spray_context_root_handler(SPEventContext *event_context,
sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3);
tc->is_drawing = true;
tc->is_dilating = true;
- tc->has_dilated = false;
-
-
-
- if(tc->is_dilating && event->button.button == 1 && !event_context->space_panning)
-
- sp_spray_dilate (tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT);
+ tc->has_dilated = false;
+ if(tc->is_dilating && event->button.button == 1 && !event_context->space_panning) {
+ sp_spray_dilate(tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT);
+ }
-
- tc->has_dilated=true;
-
+ tc->has_dilated = true;
ret = TRUE;
}
break;
- case GDK_MOTION_NOTIFY:
- {
+ case GDK_MOTION_NOTIFY: {
Geom::Point const motion_w(event->motion.x,
event->motion.y);
Geom::Point motion_dt(desktop->w2d(motion_w));
@@ -762,22 +693,22 @@ gint sp_spray_context_root_handler(SPEventContext *event_context,
sp_spray_extinput(tc, event);
// draw the dilating cursor
- double radius = get_dilate_radius(tc);
- Geom::Affine const sm (Geom::Scale(radius/(1-tc->ratio), radius/(1+tc->ratio)) );
- sp_canvas_item_affine_absolute(tc->dilate_area, (sm*Geom::Rotate(tc->tilt))*Geom::Translate(desktop->w2d(motion_w)));
- sp_canvas_item_show(tc->dilate_area);
-
- guint num = 0;
- if (!desktop->selection->isEmpty()) {
- num = g_slist_length((GSList *) desktop->selection->itemList());
- }
- if (num == 0) {
- tc->_message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to spray."));
- }
+ double radius = get_dilate_radius(tc);
+ Geom::Affine const sm (Geom::Scale(radius/(1-tc->ratio), radius/(1+tc->ratio)) );
+ sp_canvas_item_affine_absolute(tc->dilate_area, (sm*Geom::Rotate(tc->tilt))*Geom::Translate(desktop->w2d(motion_w)));
+ sp_canvas_item_show(tc->dilate_area);
+
+ guint num = 0;
+ if (!desktop->selection->isEmpty()) {
+ num = g_slist_length((GSList *) desktop->selection->itemList());
+ }
+ if (num == 0) {
+ tc->_message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to spray."));
+ }
// dilating:
if (tc->is_drawing && ( event->motion.state & GDK_BUTTON1_MASK )) {
- sp_spray_dilate (tc, motion_w, motion_doc, motion_doc - tc->last_push, event->button.state & GDK_SHIFT_MASK? true : false);
+ sp_spray_dilate(tc, motion_w, motion_doc, motion_doc - tc->last_push, event->button.state & GDK_SHIFT_MASK? true : false);
//tc->last_push = motion_doc;
tc->has_dilated = true;
@@ -785,254 +716,206 @@ gint sp_spray_context_root_handler(SPEventContext *event_context,
gobble_motion_events(GDK_BUTTON1_MASK);
return TRUE;
}
-
}
break;
-/*Spray with the scroll*/
- case GDK_SCROLL:
- {
- if (event->scroll.state & GDK_BUTTON1_MASK)
- {
- double temp ;
- temp=tc->population;
- tc->population=1.0;
- desktop->setToolboxAdjustmentValue ("population", tc->population * 100);
- Geom::Point const scroll_w(event->button.x,event->button.y);
- Geom::Point const scroll_dt = desktop->point();;
- Geom::Point motion_doc(desktop->dt2doc(scroll_dt));
- switch (event->scroll.direction)
- {
- case GDK_SCROLL_UP:
- {
- if (Inkscape::have_viable_layer(desktop, tc->_message_context) == false)
- {
- return TRUE;
- }
- tc->last_push = desktop->dt2doc(scroll_dt);
- sp_spray_extinput(tc, event);
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3);
- tc->is_drawing = true;
- tc->is_dilating = true;
- tc->has_dilated = false;
- if(tc->is_dilating && !event_context->space_panning)
-
- sp_spray_dilate (tc, scroll_w, desktop->dt2doc(scroll_dt), Geom::Point(0,0),false);
-
-
-
- tc->has_dilated=true;
- tc->population=temp;
-
- desktop->setToolboxAdjustmentValue ("population", tc->population * 100);
-
- ret = TRUE;
- }
- break;
- case GDK_SCROLL_DOWN:
- {
- if (Inkscape::have_viable_layer(desktop, tc->_message_context) == false)
- {
- return TRUE;
- }
- tc->last_push = desktop->dt2doc(scroll_dt);
- sp_spray_extinput(tc, event);
- sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3);
- tc->is_drawing = true;
- tc->is_dilating = true;
- tc->has_dilated = false;
- if(tc->is_dilating && !event_context->space_panning)
- sp_spray_dilate (tc, scroll_w, desktop->dt2doc(scroll_dt), Geom::Point(0,0), false);
-
- tc->has_dilated=true;
-
- ret = TRUE;
-
-
- }
- break;
-case GDK_SCROLL_RIGHT:
- {} break;
-case GDK_SCROLL_LEFT:
- {} break;
- }
- }
-
-
- break;
-
- }
- case GDK_BUTTON_RELEASE:
- {
- Geom::Point const motion_w(event->button.x, event->button.y);
- Geom::Point const motion_dt(desktop->w2d(motion_w));
-
- sp_canvas_end_forced_full_redraws(desktop->canvas);
- tc->is_drawing = false;
-
- if (tc->is_dilating && event->button.button == 1 && !event_context->space_panning) {
- if (!tc->has_dilated) {
- // if we did not rub, do a light tap
- tc->pressure = 0.03;
- sp_spray_dilate (tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT);
- }
- tc->is_dilating = false;
- tc->has_dilated = false;
- switch (tc->mode) {
- case SPRAY_MODE_COPY:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
- SP_VERB_CONTEXT_SPRAY, _("Spray with copies"));
- break;
- case SPRAY_MODE_CLONE:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
- SP_VERB_CONTEXT_SPRAY, _("Spray with clones"));
+ /*Spray with the scroll*/
+ case GDK_SCROLL: {
+ if (event->scroll.state & GDK_BUTTON1_MASK) {
+ double temp ;
+ temp = tc->population;
+ tc->population = 1.0;
+ desktop->setToolboxAdjustmentValue("population", tc->population * 100);
+ Geom::Point const scroll_w(event->button.x, event->button.y);
+ Geom::Point const scroll_dt = desktop->point();;
+ Geom::Point motion_doc(desktop->dt2doc(scroll_dt));
+ switch (event->scroll.direction) {
+ case GDK_SCROLL_DOWN:
+ case GDK_SCROLL_UP: {
+ if (Inkscape::have_viable_layer(desktop, tc->_message_context) == false) {
+ return TRUE;
+ }
+ tc->last_push = desktop->dt2doc(scroll_dt);
+ sp_spray_extinput(tc, event);
+ sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3);
+ tc->is_drawing = true;
+ tc->is_dilating = true;
+ tc->has_dilated = false;
+ if(tc->is_dilating && !event_context->space_panning) {
+ sp_spray_dilate(tc, scroll_w, desktop->dt2doc(scroll_dt), Geom::Point(0,0), false);
+ }
+ tc->has_dilated = true;
+
+ tc->population = temp;
+ desktop->setToolboxAdjustmentValue("population", tc->population * 100);
+
+ ret = TRUE;
+ }
break;
- case SPRAY_MODE_SINGLE_PATH:
- DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
- SP_VERB_CONTEXT_SPRAY, _("Spray in single path"));
- break;
- }
- }
- break;
- }
-
- case GDK_KEY_PRESS:
- switch (get_group0_keyval (&event->key)) {
-case GDK_j: if (MOD__SHIFT_ONLY) {
- sp_spray_switch_mode(tc, SPRAY_MODE_COPY, MOD__SHIFT);
- ret = TRUE;
- }
-case GDK_J: if (MOD__SHIFT_ONLY) {
- sp_spray_switch_mode(tc, SPRAY_MODE_COPY, MOD__SHIFT);
- ret = TRUE;
- }
-
-break;
- case GDK_m:
- case GDK_M:
- case GDK_0:
-
- break;
- case GDK_i:
- case GDK_I:
- case GDK_k: if (MOD__SHIFT_ONLY) {
- sp_spray_switch_mode(tc, SPRAY_MODE_SINGLE_PATH, MOD__SHIFT);
- ret = TRUE;
- }
- case GDK_K:if (MOD__SHIFT_ONLY) {
- sp_spray_switch_mode(tc, SPRAY_MODE_SINGLE_PATH, MOD__SHIFT);
- ret = TRUE;
- }
-break;
-
- case GDK_l: if (MOD__SHIFT_ONLY) {
- sp_spray_switch_mode(tc, SPRAY_MODE_CLONE, MOD__SHIFT);
- ret = TRUE;
- }
-
- case GDK_L:
- if (MOD__SHIFT_ONLY) {
- sp_spray_switch_mode(tc, SPRAY_MODE_CLONE, MOD__SHIFT);
- ret = TRUE;
+ case GDK_SCROLL_RIGHT:
+ {} break;
+ case GDK_SCROLL_LEFT:
+ {} break;
+ }
}
break;
- case GDK_Up:
- case GDK_KP_Up:
- if (!MOD__CTRL_ONLY) {
- tc->scale += 0.05;
-
- //desktop->setToolboxAdjustmentValue ("spray-force", tc->force * 100);
- ret = TRUE;
+ }
+
+ case GDK_BUTTON_RELEASE: {
+ Geom::Point const motion_w(event->button.x, event->button.y);
+ Geom::Point const motion_dt(desktop->w2d(motion_w));
+
+ sp_canvas_end_forced_full_redraws(desktop->canvas);
+ tc->is_drawing = false;
+
+ if (tc->is_dilating && event->button.button == 1 && !event_context->space_panning) {
+ if (!tc->has_dilated) {
+ // if we did not rub, do a light tap
+ tc->pressure = 0.03;
+ sp_spray_dilate(tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT);
+ }
+ tc->is_dilating = false;
+ tc->has_dilated = false;
+ switch (tc->mode) {
+ case SPRAY_MODE_COPY:
+ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+ SP_VERB_CONTEXT_SPRAY, _("Spray with copies"));
+ break;
+ case SPRAY_MODE_CLONE:
+ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+ SP_VERB_CONTEXT_SPRAY, _("Spray with clones"));
+ break;
+ case SPRAY_MODE_SINGLE_PATH:
+ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+ SP_VERB_CONTEXT_SPRAY, _("Spray in single path"));
+ break;
+ }
}
break;
- case GDK_Down:
- case GDK_KP_Down:
- if (!MOD__CTRL_ONLY) {
-
- tc->scale -= 0.05;
- if (tc->scale < 0.0)
- tc->scale = 0.0;
- //desktop->setToolboxAdjustmentValue ("spray-force", tc->force * 100);
-
- ret = TRUE;
+ }
- }
- break;
- case GDK_Right:
- case GDK_KP_Right:
- if (!MOD__CTRL_ONLY) {
- tc->width += 0.01;
- if (tc->width > 1.0)
- tc->width = 1.0;
- desktop->setToolboxAdjustmentValue ("altx-spray", tc->width * 100); // the same spinbutton is for alt+x
- sp_spray_update_area(tc);
- ret = TRUE;
- }
- break;
- case GDK_Left:
- case GDK_KP_Left:
- if (!MOD__CTRL_ONLY) {
- tc->width -= 0.01;
- if (tc->width < 0.01)
+ case GDK_KEY_PRESS:
+ switch (get_group0_keyval (&event->key)) {
+ case GDK_j:
+ case GDK_J:
+ if (MOD__SHIFT_ONLY) {
+ sp_spray_switch_mode(tc, SPRAY_MODE_COPY, MOD__SHIFT);
+ ret = TRUE;
+ }
+ break;
+ case GDK_k:
+ case GDK_K:
+ if (MOD__SHIFT_ONLY) {
+ sp_spray_switch_mode(tc, SPRAY_MODE_CLONE, MOD__SHIFT);
+ ret = TRUE;
+ }
+ break;
+ case GDK_l:
+ case GDK_L:
+ if (MOD__SHIFT_ONLY) {
+ sp_spray_switch_mode(tc, SPRAY_MODE_SINGLE_PATH, MOD__SHIFT);
+ ret = TRUE;
+ }
+ break;
+ case GDK_Up:
+ case GDK_KP_Up:
+ if (!MOD__CTRL_ONLY) {
+ tc->population += 0.01;
+ if (tc->population > 1.0) {
+ tc->population = 1.0;
+ }
+ desktop->setToolboxAdjustmentValue("spray-population", tc->population * 100);
+ ret = TRUE;
+ }
+ break;
+ case GDK_Down:
+ case GDK_KP_Down:
+ if (!MOD__CTRL_ONLY) {
+ tc->population -= 0.01;
+ if (tc->population < 0.0) {
+ tc->population = 0.0;
+ }
+ desktop->setToolboxAdjustmentValue("spray-population", tc->population * 100);
+ ret = TRUE;
+ }
+ break;
+ case GDK_Right:
+ case GDK_KP_Right:
+ if (!MOD__CTRL_ONLY) {
+ tc->width += 0.01;
+ if (tc->width > 1.0) {
+ tc->width = 1.0;
+ }
+ // the same spinbutton is for alt+x
+ desktop->setToolboxAdjustmentValue("altx-spray", tc->width * 100);
+ sp_spray_update_area(tc);
+ ret = TRUE;
+ }
+ break;
+ case GDK_Left:
+ case GDK_KP_Left:
+ if (!MOD__CTRL_ONLY) {
+ tc->width -= 0.01;
+ if (tc->width < 0.01) {
+ tc->width = 0.01;
+ }
+ desktop->setToolboxAdjustmentValue("altx-spray", tc->width * 100);
+ sp_spray_update_area(tc);
+ ret = TRUE;
+ }
+ break;
+ case GDK_Home:
+ case GDK_KP_Home:
tc->width = 0.01;
- desktop->setToolboxAdjustmentValue ("altx-spray", tc->width * 100);
- sp_spray_update_area(tc);
- ret = TRUE;
+ desktop->setToolboxAdjustmentValue("altx-spray", tc->width * 100);
+ sp_spray_update_area(tc);
+ ret = TRUE;
+ break;
+ case GDK_End:
+ case GDK_KP_End:
+ tc->width = 1.0;
+ desktop->setToolboxAdjustmentValue("altx-spray", tc->width * 100);
+ sp_spray_update_area(tc);
+ ret = TRUE;
+ break;
+ case GDK_x:
+ case GDK_X:
+ if (MOD__ALT_ONLY) {
+ desktop->setToolboxFocusTo("altx-spray");
+ ret = TRUE;
+ }
+ break;
+ case GDK_Shift_L:
+ case GDK_Shift_R:
+ sp_spray_update_cursor(tc, true);
+ break;
+ case GDK_Control_L:
+ case GDK_Control_R:
+ break;
+ default:
+ break;
}
break;
- case GDK_Home:
- case GDK_KP_Home:
- tc->width = 0.01;
- desktop->setToolboxAdjustmentValue ("altx-spray", tc->width * 100);
- sp_spray_update_area(tc);
- ret = TRUE;
- break;
- case GDK_End:
- case GDK_KP_End:
- tc->width = 1.0;
- desktop->setToolboxAdjustmentValue ("altx-spray", tc->width * 100);
- sp_spray_update_area(tc);
- ret = TRUE;
- break;
- case GDK_x:
- case GDK_X:
- if (MOD__ALT_ONLY) {
- desktop->setToolboxFocusTo ("altx-spray");
- ret = TRUE;
+
+ case GDK_KEY_RELEASE: {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ switch (get_group0_keyval(&event->key)) {
+ case GDK_Shift_L:
+ case GDK_Shift_R:
+ sp_spray_update_cursor(tc, false);
+ break;
+ case GDK_Control_L:
+ case GDK_Control_R:
+ sp_spray_switch_mode (tc, prefs->getInt("/tools/spray/mode"), MOD__SHIFT);
+ tc->_message_context->clear();
+ break;
+ default:
+ sp_spray_switch_mode (tc, prefs->getInt("/tools/spray/mode"), MOD__SHIFT);
+ break;
}
- break;
+ }
- case GDK_Shift_L:
- case GDK_Shift_R:
- sp_spray_update_cursor(tc, true);
- break;
-/*Set the scale to 1*/
- case GDK_Control_L:
- tc->scale=1;
default:
break;
- }
- break;
-
- case GDK_KEY_RELEASE: {
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- switch (get_group0_keyval(&event->key)) {
- case GDK_Shift_L:
- case GDK_Shift_R:
- sp_spray_update_cursor(tc, false);
- break;
- case GDK_Control_L:
- case GDK_Control_R:
- sp_spray_switch_mode (tc, prefs->getInt("/tools/spray/mode"), MOD__SHIFT);
- tc->_message_context->clear();
- break;
- default:
- sp_spray_switch_mode (tc, prefs->getInt("/tools/spray/mode"), MOD__SHIFT);
- break;
- }
- }
-
- default:
- break;
}
if (!ret) {
diff --git a/src/spray-context.h b/src/spray-context.h
index edb872117..c485a6a96 100644
--- a/src/spray-context.h
+++ b/src/spray-context.h
@@ -91,11 +91,6 @@ struct SPSprayContext
Geom::Point last_push;
SPCanvasItem *dilate_area;
- bool do_h;
- bool do_s;
- bool do_l;
- bool do_o;
-
sigc::connection style_set_connection;
};
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 7ef864383..fe87bc4e2 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -332,7 +332,6 @@ static gchar const * ui_descr =
" <toolbar name='SprayToolbar'>"
" <toolitem action='SprayModeAction' />"
" <separator />"
- " <separator />"
" <toolitem action='SprayWidthAction' />"
" <toolitem action='SprayPressureAction' />"
" <toolitem action='SprayPopulationAction' />"
@@ -469,9 +468,9 @@ static gchar const * ui_descr =
" </toolbar>"
" <toolbar name='EraserToolbar'>"
- " <toolitem action='EraserWidthAction' />"
- " <separator />"
" <toolitem action='EraserModeAction' />"
+ " <separator />"
+ " <toolitem action='EraserWidthAction' />"
" </toolbar>"
" <toolbar name='TextToolbar'>"
@@ -4609,10 +4608,10 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
{
/* Mean */
- gchar const* labels[] = {_("(minimum mean)"), 0, 0, _("(default)"), 0, 0, 0, _("(maximum mean)")};
- gdouble values[] = {1, 5, 10, 20, 30, 50, 70, 100};
+ gchar const* labels[] = {_("(default)"), 0, 0, 0, 0, 0, 0, _("(maximum mean)")};
+ gdouble values[] = {0, 5, 10, 20, 30, 50, 70, 100};
EgeAdjustmentAction *eact = create_adjustment_action( "SprayMeanAction",
- _("Focus"), _("Focus:"), _("0 to spray a spot. Increase to enlarge the ring radius."),
+ _("Focus"), _("Focus:"), _("0 to spray a spot; increase to enlarge the ring radius"),
"/tools/spray/mean", 0,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-mean",
0, 100, 1.0, 10.0,
@@ -4625,13 +4624,10 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
{
/* Standard_deviation */
- gchar const* labels[] = {_("(minimum scatter)"), 0, 0, _("(default)"), 0, 0, 0, _("(maximum scatter)")};
+ gchar const* labels[] = {_("(minimum scatter)"), 0, 0, 0, 0, 0, _("(default)"), _("(maximum scatter)")};
gdouble values[] = {1, 5, 10, 20, 30, 50, 70, 100};
-
- //TRANSLATORS: only translate "string" in "context|string".
- // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
EgeAdjustmentAction *eact = create_adjustment_action( "SprayStandard_deviationAction",
- Q_("Toolbox|Scatter"), Q_("Toolbox|Scatter:"), _("Increase to scatter sprayed objects."),
+ C_("Spray tool", "Scatter"), C_("Spray tool", "Scatter:"), _("Increase to scatter sprayed objects"),
"/tools/spray/standard_deviation", 70,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-standard_deviation",
1, 100, 1.0, 10.0,
@@ -4688,11 +4684,11 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
}
{ /* Population */
- gchar const* labels[] = {_("(low population)"), 0, 0, _("(default)"), 0, 0, _("(high population)")};
- gdouble values[] = {10, 25, 35, 50, 60, 80, 100};
+ gchar const* labels[] = {_("(low population)"), 0, 0, 0, _("(default)"), 0, _("(high population)")};
+ gdouble values[] = {5, 20, 35, 50, 70, 85, 100};
EgeAdjustmentAction *eact = create_adjustment_action( "SprayPopulationAction",
_("Amount"), _("Amount:"),
- _("Adjusts the number of items sprayed per clic."),
+ _("Adjusts the number of items sprayed per clic"),
"/tools/spray/population", 70,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-population",
1, 100, 1.0, 10.0,
@@ -4708,21 +4704,22 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
{
InkToggleAction* act = ink_toggle_action_new( "SprayPressureAction",
_("Pressure"),
- _("Use the pressure of the input device to alter the amount of sprayed objects."),
+ _("Use the pressure of the input device to alter the amount of sprayed objects"),
"use_pressure",
Inkscape::ICON_SIZE_DECORATION );
- gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
- g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_spray_pressure_state_changed), NULL);
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/usepressure", true) );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressure");
+ g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher);
+
}
{ /* Rotation */
- gchar const* labels[] = {_("(low rotation variation)"), 0, 0, _("(default)"), 0, 0, _("(high rotation variation)")};
- gdouble values[] = {10, 25, 35, 50, 60, 80, 100};
+ gchar const* labels[] = {_("(default)"), 0, 0, 0, 0, 0, 0, _("(high rotation variation)")};
+ gdouble values[] = {0, 10, 25, 35, 50, 60, 80, 100};
EgeAdjustmentAction *eact = create_adjustment_action( "SprayRotationAction",
_("Rotation"), _("Rotation:"),
// xgettext:no-c-format
- _("Variation of the rotation of the sprayed objects. 0% for the same rotation than the original object."),
+ _("Variation of the rotation of the sprayed objects; 0% for the same rotation than the original object"),
"/tools/spray/rotation_variation", 0,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-rotation",
0, 100, 1.0, 10.0,
@@ -4735,15 +4732,12 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
}
{ /* Scale */
- gchar const* labels[] = {_("(low scale variation)"), 0, 0, _("(default)"), 0, 0, _("(high scale variation)")};
- gdouble values[] = {10, 25, 35, 50, 60, 80, 100};
-
- //TRANSLATORS: only translate "string" in "context|string".
- // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
+ gchar const* labels[] = {_("(default)"), 0, 0, 0, 0, 0, 0, _("(high scale variation)")};
+ gdouble values[] = {0, 10, 25, 35, 50, 60, 80, 100};
EgeAdjustmentAction *eact = create_adjustment_action( "SprayScaleAction",
- Q_("Toolbox|Scale"), Q_("Toolbox|Scale:"),
+ C_("Spray tool", "Scale"), C_("Spray tool", "Scale:"),
// xgettext:no-c-format
- _("Variation in the scale of the sprayed objects. 0% for the same scale than the original object."),
+ _("Variation in the scale of the sprayed objects; 0% for the same scale than the original object"),
"/tools/spray/scale_variation", 0,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-scale",
0, 100, 1.0, 10.0,
@@ -6118,23 +6112,6 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
{
- /* Width */
- gchar const* labels[] = {_("(hairline)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad stroke)")};
- gdouble values[] = {1, 3, 5, 10, 15, 20, 30, 50, 75, 100};
- EgeAdjustmentAction *eact = create_adjustment_action( "EraserWidthAction",
- _("Pen Width"), _("Width:"),
- _("The width of the eraser pen (relative to the visible canvas area)"),
- "/tools/eraser/width", 15,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-eraser",
- 1, 100, 1.0, 10.0,
- labels, values, G_N_ELEMENTS(labels),
- sp_erc_width_value_changed, 1, 0);
- ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
- gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
- gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
- }
-
- {
GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
GtkTreeIter iter;
@@ -6153,9 +6130,10 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
-1 );
EgeSelectOneAction* act = ege_select_one_action_new( "EraserModeAction", (""), (""), NULL, GTK_TREE_MODEL(model) );
+ g_object_set( act, "short_label", _("Mode:"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
g_object_set_data( holder, "eraser_mode_action", act );
-
+
ege_select_one_action_set_appearance( act, "full" );
ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL );
@@ -6169,6 +6147,23 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_erasertb_mode_changed), holder );
}
+ {
+ /* Width */
+ gchar const* labels[] = {_("(hairline)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad stroke)")};
+ gdouble values[] = {1, 3, 5, 10, 15, 20, 30, 50, 75, 100};
+ EgeAdjustmentAction *eact = create_adjustment_action( "EraserWidthAction",
+ _("Pen Width"), _("Width:"),
+ _("The width of the eraser pen (relative to the visible canvas area)"),
+ "/tools/eraser/width", 15,
+ GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-eraser",
+ 1, 100, 1.0, 10.0,
+ labels, values, G_N_ELEMENTS(labels),
+ sp_erc_width_value_changed, 1, 0);
+ ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ }
+
}
//########################