summaryrefslogtreecommitdiffstats
path: root/src/ui/tools
diff options
context:
space:
mode:
authorEduard Braun <eduard.braun2@gmx.de>2017-07-09 12:42:10 +0000
committerEduard Braun <eduard.braun2@gmx.de>2017-07-09 12:42:10 +0000
commit241554b7ad311b5868ba284c7a4e6a410432b9bd (patch)
tree8bf6fed572d27e9b97ca60b90ae1684ba4856eeb /src/ui/tools
parentUse .xml when exporting shortcuts by default (diff)
parentShortcuts: Fix for 7d248fbba5b0c24d9a24cda8c3f2e79f96395553 (is_user_set was ... (diff)
downloadinkscape-241554b7ad311b5868ba284c7a4e6a410432b9bd.tar.gz
inkscape-241554b7ad311b5868ba284c7a4e6a410432b9bd.zip
Merge branch 'master' into shortcuts
Diffstat (limited to 'src/ui/tools')
-rw-r--r--src/ui/tools/arc-tool.cpp11
-rw-r--r--src/ui/tools/box3d-tool.cpp2
-rw-r--r--src/ui/tools/calligraphic-tool.cpp2
-rw-r--r--src/ui/tools/connector-tool.cpp15
-rw-r--r--src/ui/tools/dropper-tool.cpp265
-rw-r--r--src/ui/tools/dropper-tool.h11
-rw-r--r--src/ui/tools/dynamic-base.cpp4
-rw-r--r--src/ui/tools/dynamic-base.h2
-rw-r--r--src/ui/tools/eraser-tool.cpp2
-rw-r--r--src/ui/tools/flood-tool.cpp2
-rw-r--r--src/ui/tools/freehand-base.cpp4
-rw-r--r--src/ui/tools/freehand-base.h2
-rw-r--r--src/ui/tools/gradient-tool.cpp2
-rw-r--r--src/ui/tools/lpe-tool.cpp2
-rw-r--r--src/ui/tools/measure-tool.cpp10
-rw-r--r--src/ui/tools/mesh-tool.cpp2
-rw-r--r--src/ui/tools/node-tool.cpp6
-rw-r--r--src/ui/tools/node-tool.h2
-rw-r--r--src/ui/tools/pen-tool.cpp6
-rw-r--r--src/ui/tools/pen-tool.h2
-rw-r--r--src/ui/tools/pencil-tool.cpp2
-rw-r--r--src/ui/tools/rect-tool.cpp11
-rw-r--r--src/ui/tools/select-tool.cpp10
-rw-r--r--src/ui/tools/spiral-tool.cpp10
-rw-r--r--src/ui/tools/spray-tool.cpp2
-rw-r--r--src/ui/tools/star-tool.cpp11
-rw-r--r--src/ui/tools/text-tool.cpp6
-rw-r--r--src/ui/tools/tool-base.cpp107
-rw-r--r--src/ui/tools/tool-base.h15
-rw-r--r--src/ui/tools/tweak-tool.cpp16
-rw-r--r--src/ui/tools/zoom-tool.cpp2
31 files changed, 278 insertions, 268 deletions
diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp
index 6652f7ab5..b501962fb 100644
--- a/src/ui/tools/arc-tool.cpp
+++ b/src/ui/tools/arc-tool.cpp
@@ -59,7 +59,7 @@ const std::string ArcTool::prefsPath = "/tools/shapes/arc";
ArcTool::ArcTool()
- : ToolBase(cursor_ellipse_xpm, 4, 4)
+ : ToolBase(cursor_ellipse_xpm)
, arc(NULL)
{
}
@@ -244,15 +244,6 @@ bool ArcTool::root_handler(GdkEvent* event) {
}
break;
- case GDK_KEY_Up:
- case GDK_KEY_Down:
- case GDK_KEY_KP_Up:
- case GDK_KEY_KP_Down:
- // prevent the zoom field from activation
- if (!MOD__CTRL_ONLY(event))
- handled = true;
- break;
-
case GDK_KEY_x:
case GDK_KEY_X:
if (MOD__ALT_ONLY(event)) {
diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp
index 425695a2c..276385335 100644
--- a/src/ui/tools/box3d-tool.cpp
+++ b/src/ui/tools/box3d-tool.cpp
@@ -54,7 +54,7 @@ const std::string& Box3dTool::getPrefsPath() {
const std::string Box3dTool::prefsPath = "/tools/shapes/3dbox";
Box3dTool::Box3dTool()
- : ToolBase(cursor_3dbox_xpm, 4, 4)
+ : ToolBase(cursor_3dbox_xpm)
, _vpdrag(NULL)
, box3d(NULL)
, ctrl_dragged(false)
diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp
index 7228a52bc..266375caa 100644
--- a/src/ui/tools/calligraphic-tool.cpp
+++ b/src/ui/tools/calligraphic-tool.cpp
@@ -88,7 +88,7 @@ const std::string& CalligraphicTool::getPrefsPath() {
const std::string CalligraphicTool::prefsPath = "/tools/calligraphic";
CalligraphicTool::CalligraphicTool()
- : DynamicBase(cursor_calligraphy_xpm, 4, 4)
+ : DynamicBase(cursor_calligraphy_xpm)
, keep_selected(true)
, hatch_spacing(0)
, hatch_spacing_step(0)
diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp
index 7e6fb4b72..6d2682089 100644
--- a/src/ui/tools/connector-tool.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -145,7 +145,7 @@ const std::string& ConnectorTool::getPrefsPath() {
const std::string ConnectorTool::prefsPath = "/tools/connector";
ConnectorTool::ConnectorTool()
- : ToolBase(cursor_connector_xpm, 1, 1)
+ : ToolBase(cursor_connector_xpm)
, selection(NULL)
, npoints(0)
, state(SP_CONNECTOR_CONTEXT_IDLE)
@@ -348,7 +348,7 @@ cc_select_handle(SPKnot* knot)
knot->setShape(SP_KNOT_SHAPE_SQUARE);
knot->setSize(10);
knot->setAnchor(SP_ANCHOR_CENTER);
- knot->setFill(0x0000ffff, 0x0000ffff, 0x0000ffff);
+ knot->setFill(0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff);
knot->updateCtrl();
}
@@ -358,7 +358,7 @@ cc_deselect_handle(SPKnot* knot)
knot->setShape(SP_KNOT_SHAPE_SQUARE);
knot->setSize(8);
knot->setAnchor(SP_ANCHOR_CENTER);
- knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff);
+ knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff, 0xff0000ff);
knot->updateCtrl();
}
@@ -941,8 +941,7 @@ void ConnectorTool::_finish() {
this->npoints = 0;
if (this->newConnRef) {
- this->newConnRef->removeFromGraph();
- delete this->newConnRef;
+ this->newConnRef->router()->deleteConnector(this->newConnRef);
this->newConnRef = NULL;
}
}
@@ -1058,7 +1057,7 @@ void ConnectorTool::_activeShapeAddKnot(SPItem* item) {
knot->setShape(SP_KNOT_SHAPE_SQUARE);
knot->setSize(8);
knot->setAnchor(SP_ANCHOR_CENTER);
- knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff);
+ knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff, 0xff0000ff);
knot->updateCtrl();
// We don't want to use the standard knot handler.
@@ -1176,8 +1175,8 @@ void ConnectorTool::cc_set_active_conn(SPItem *item) {
knot->setShape(SP_KNOT_SHAPE_SQUARE);
knot->setSize(7);
knot->setAnchor(SP_ANCHOR_CENTER);
- knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff);
- knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff);
+ knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff, 0xff0000ff);
+ knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff);
knot->updateCtrl();
// We don't want to use the standard knot handler,
diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp
index 99177dc75..53a99e481 100644
--- a/src/ui/tools/dropper-tool.cpp
+++ b/src/ui/tools/dropper-tool.cpp
@@ -39,6 +39,8 @@
#include "pixmaps/cursor-dropper-f.xpm"
#include "pixmaps/cursor-dropper-s.xpm"
+#include "pixmaps/cursor-dropping-f.xpm"
+#include "pixmaps/cursor-dropping-s.xpm"
#include "ui/tools/dropper-tool.h"
#include "message-context.h"
@@ -46,9 +48,6 @@
using Inkscape::DocumentUndo;
-static GdkCursor *cursor_dropper_fill = NULL;
-static GdkCursor *cursor_dropper_stroke = NULL;
-
namespace Inkscape {
namespace UI {
namespace Tools {
@@ -60,18 +59,20 @@ const std::string& DropperTool::getPrefsPath() {
const std::string DropperTool::prefsPath = "/tools/dropper";
DropperTool::DropperTool()
- : ToolBase(cursor_dropper_f_xpm, 5, 5)
+ : ToolBase(cursor_dropper_f_xpm)
, R(0)
, G(0)
, B(0)
, alpha(0)
+ , radius(0)
+ , invert(false)
+ , stroke(false)
+ , dropping(false)
, dragging(false)
, grabbed(NULL)
, area(NULL)
, centre(0, 0)
{
- cursor_dropper_fill = sp_cursor_new_from_xpm(cursor_dropper_f_xpm , 5, 5);
- cursor_dropper_stroke = sp_cursor_new_from_xpm(cursor_dropper_s_xpm , 5, 5);
}
DropperTool::~DropperTool() {
@@ -117,41 +118,84 @@ void DropperTool::finish() {
this->area = NULL;
}
- if (cursor_dropper_fill) {
- g_object_unref(cursor_dropper_fill);
- cursor_dropper_fill = NULL;
- }
-
- if (cursor_dropper_stroke) {
- g_object_unref(cursor_dropper_stroke);
- cursor_dropper_fill = NULL;
- }
-
ToolBase::finish();
}
/**
* Returns the current dropper context color.
*/
-guint32 DropperTool::get_color() {
+guint32 DropperTool::get_color(bool invert) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int pick = prefs->getInt("/tools/dropper/pick", SP_DROPPER_PICK_VISIBLE);
bool setalpha = prefs->getBool("/tools/dropper/setalpha", true);
- return SP_RGBA32_F_COMPOSE(this->R,
- this->G,
- this->B,
- (pick == SP_DROPPER_PICK_ACTUAL && setalpha) ? this->alpha : 1.0);
+ return SP_RGBA32_F_COMPOSE(
+ fabs(invert - this->R),
+ fabs(invert - this->G),
+ fabs(invert - this->B),
+ (pick == SP_DROPPER_PICK_ACTUAL && setalpha) ? this->alpha : 1.0);
}
bool DropperTool::root_handler(GdkEvent* event) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int ret = FALSE;
-
int pick = prefs->getInt("/tools/dropper/pick", SP_DROPPER_PICK_VISIBLE);
- bool setalpha = prefs->getBool("/tools/dropper/setalpha", true);
+
+ // Decide first what kind of 'mode' we're in.
+ if (event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE) {
+ switch (event->key.keyval) {
+ case GDK_KEY_Shift_L:
+ case GDK_KEY_Shift_R:
+ this->stroke = event->type == GDK_KEY_PRESS;
+ break;
+ case GDK_KEY_Control_L:
+ case GDK_KEY_Control_R:
+ this->dropping = event->type == GDK_KEY_PRESS;
+ break;
+ case GDK_KEY_Alt_L:
+ case GDK_KEY_Alt_R:
+ this->invert = event->type == GDK_KEY_PRESS;
+ break;
+ }
+ }
+
+ // Get color from selected object instead.
+ if(this->dropping) {
+ Inkscape::Selection *selection = desktop->getSelection();
+ g_assert(selection);
+ guint32 apply_color;
+ bool apply_set = false;
+ for (auto& obj: selection->objects()) {
+ if(obj->style) {
+ double opacity = 1.0;
+ if(!this->stroke && obj->style->fill.set) {
+ if(obj->style->fill_opacity.set) {
+ opacity = obj->style->fill_opacity.value;
+ }
+ apply_color = obj->style->fill.value.color.toRGBA32(opacity);
+ apply_set = true;
+ } else if(this->stroke && obj->style->stroke.set) {
+ if(obj->style->stroke_opacity.set) {
+ opacity = obj->style->stroke_opacity.value;
+ }
+ apply_color = obj->style->stroke.value.color.toRGBA32(opacity);
+ apply_set = true;
+ }
+ }
+ }
+ if(apply_set) {
+ this->R = SP_RGBA32_R_F(apply_color);
+ this->G = SP_RGBA32_G_F(apply_color);
+ this->B = SP_RGBA32_B_F(apply_color);
+ this->alpha = SP_RGBA32_A_F(apply_color);
+ } else {
+ // This means that having no selection or some other error
+ // we will default back to normal dropper mode.
+ this->dropping = false;
+ }
+ }
switch (event->type) {
case GDK_BUTTON_PRESS:
@@ -160,11 +204,12 @@ bool DropperTool::root_handler(GdkEvent* event) {
this->dragging = true;
ret = TRUE;
}
-
- sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
- GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
- NULL, event->button.time);
- this->grabbed = SP_CANVAS_ITEM(desktop->acetate);
+
+ sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
+ GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
+ NULL, event->button.time);
+ this->grabbed = SP_CANVAS_ITEM(desktop->acetate);
break;
case GDK_MOTION_NOTIFY:
@@ -174,14 +219,6 @@ bool DropperTool::root_handler(GdkEvent* event) {
break;
} else if (!this->space_panning) {
// otherwise, constantly calculate color no matter is any button pressed or not
-
- // If one time pick with stroke set the pixmap
- if (prefs->getBool("/tools/dropper/onetimepick", false) && prefs->getInt("/dialogs/fillstroke/page", 0) == 1) {
- //TODO Only set when not set already
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
- gdk_window_set_cursor(window, cursor_dropper_stroke);
- }
-
double rw = 0.0;
double R(0), G(0), B(0), A(0);
@@ -190,10 +227,10 @@ bool DropperTool::root_handler(GdkEvent* event) {
// radius
rw = std::min(Geom::L2(Geom::Point(event->button.x, event->button.y) - this->centre), 400.0);
-
if (rw == 0) { // happens sometimes, little idea why...
break;
}
+ this->radius = rw;
Geom::Point const cd = desktop->w2d(this->centre);
Geom::Affine const w2dt = desktop->w2d();
@@ -242,74 +279,57 @@ bool DropperTool::root_handler(GdkEvent* event) {
}
// remember color
- this->R = R;
- this->G = G;
- this->B = B;
- this->alpha = A;
-
- // status message
- double alpha_to_set = setalpha? this->alpha : 1.0;
- guint32 c32 = SP_RGBA32_F_COMPOSE(R, G, B, alpha_to_set);
-
- gchar c[64];
- sp_svg_write_color(c, sizeof(c), c32);
-
- // alpha of color under cursor, to show in the statusbar
- // locale-sensitive printf is OK, since this goes to the UI, not into SVG
- gchar *alpha = g_strdup_printf(_(" alpha %.3g"), alpha_to_set);
- // where the color is picked, to show in the statusbar
- gchar *where = this->dragging ? g_strdup_printf(_(", averaged with radius %d"), (int) rw) : g_strdup_printf("%s", _(" under cursor"));
- // message, to show in the statusbar
- const gchar *message = this->dragging ? _("<b>Release mouse</b> to set color.") : _("<b>Click</b> to set fill, <b>Shift+click</b> to set stroke; <b>drag</b> to average color in area; with <b>Alt</b> to pick inverse color; <b>Ctrl+C</b> to copy the color under mouse to clipboard");
-
- this->defaultMessageContext()->setF(
- Inkscape::NORMAL_MESSAGE,
- "<b>%s%s</b>%s. %s", c,
- (pick == SP_DROPPER_PICK_VISIBLE) ? "" : alpha, where, message);
-
- g_free(where);
- g_free(alpha);
-
+ if(!this->dropping && (R != this->R || G != this->G || B != this->B || A != this->alpha)) {
+ this->R = R;
+ this->G = G;
+ this->B = B;
+ this->alpha = A;
+ }
ret = TRUE;
}
break;
case GDK_BUTTON_RELEASE:
if (event->button.button == 1 && !this->space_panning) {
- sp_canvas_item_hide(this->area);
- this->dragging = false;
-
- if (this->grabbed) {
- sp_canvas_item_ungrab(this->grabbed, event->button.time);
- this->grabbed = NULL;
- }
-
- double alpha_to_set = setalpha? this->alpha : 1.0;
-
- bool fill = !(event->button.state & GDK_SHIFT_MASK); // Stroke if Shift key held
-
- if (prefs->getBool("/tools/dropper/onetimepick", false)) {
- // "One time" pick from Fill/Stroke dialog stroke page, always apply fill or stroke (ignore <Shift> key)
- fill = (prefs->getInt("/dialogs/fillstroke/page", 0) == 0) ? true : false;
+ sp_canvas_item_hide(this->area);
+ this->dragging = false;
+
+ if (this->grabbed) {
+ sp_canvas_item_ungrab(this->grabbed, event->button.time);
+ this->grabbed = NULL;
+ }
+
+ Inkscape::Selection *selection = desktop->getSelection();
+ g_assert(selection);
+ std::vector<SPItem *> old_selection(selection->items().begin(), selection->items().end());
+ if(this->dropping) {
+ Geom::Point const button_w(event->button.x, event->button.y);
+ // remember clicked item, disregarding groups, honoring Alt
+ this->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, TRUE);
+
+ // Change selected object to object under cursor
+ if (this->item_to_select) {
+ std::vector<SPItem *> vec(selection->items().begin(), selection->items().end());
+ selection->set(this->item_to_select);
+ }
+ } else {
+ if (prefs->getBool("/tools/dropper/onetimepick", false)) {
+ // "One time" pick from Fill/Stroke dialog stroke page, always apply fill or stroke (ignore <Shift> key)
+ //fill = (prefs->getInt("/dialogs/fillstroke/page", 0) == 0) ? true : false;
+ }
}
// do the actual color setting
- sp_desktop_set_color(desktop,
- (event->button.state & GDK_MOD1_MASK)?
- ColorRGBA(1 - this->R, 1 - this->G, 1 - this->B, alpha_to_set) : ColorRGBA(this->R, this->G, this->B, alpha_to_set),
- false, fill);
+ sp_desktop_set_color(desktop, ColorRGBA(this->get_color(this->invert)), false, !this->stroke);
// REJON: set aux. toolbar input to hex color!
-
- if (event->button.state & GDK_SHIFT_MASK) {
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
- gdk_window_set_cursor(window, cursor_dropper_stroke);
- }
-
if (!(desktop->getSelection()->isEmpty())) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_DROPPER,
_("Set picked color"));
}
+ if(this->dropping) {
+ selection->setList(old_selection);
+ }
if (prefs->getBool("/tools/dropper/onetimepick", false)) {
prefs->setBool("/tools/dropper/onetimepick", false);
@@ -326,50 +346,49 @@ bool DropperTool::root_handler(GdkEvent* event) {
case GDK_KEY_PRESS:
switch (get_group0_keyval(&event->key)) {
- case GDK_KEY_Up:
- case GDK_KEY_Down:
- case GDK_KEY_KP_Up:
- case GDK_KEY_KP_Down:
+ case GDK_KEY_Up:
+ case GDK_KEY_Down:
+ case GDK_KEY_KP_Up:
+ case GDK_KEY_KP_Down:
// prevent the zoom field from activation
if (!MOD__CTRL_ONLY(event)) {
ret = TRUE;
}
break;
-
- case GDK_KEY_Escape:
+ case GDK_KEY_Escape:
desktop->getSelection()->clear();
- case GDK_KEY_Shift_L:
- case GDK_KEY_Shift_R:
- if (!desktop->isWaitingCursor() && !prefs->getBool("/tools/dropper/onetimepick", false)) {
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
- gdk_window_set_cursor(window, cursor_dropper_stroke);
- }
-
- break;
- default:
break;
}
break;
-
- case GDK_KEY_RELEASE:
- switch (get_group0_keyval(&event->key)) {
- case GDK_KEY_Shift_L:
- case GDK_KEY_Shift_R:
- if (!desktop->isWaitingCursor() && !prefs->getBool("/tools/dropper/onetimepick", false)) {
- GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
- gdk_window_set_cursor(window, cursor_dropper_fill);
- }
- break;
-
- default:
- break;
- }
- break;
-
- default:
- break;
}
+ // set the status message to the right text.
+ gchar c[64];
+ sp_svg_write_color(c, sizeof(c), this->get_color(this->invert));
+
+ // alpha of color under cursor, to show in the statusbar
+ // locale-sensitive printf is OK, since this goes to the UI, not into SVG
+ gchar *alpha = g_strdup_printf(_(" alpha %.3g"), this->alpha);
+ // where the color is picked, to show in the statusbar
+ gchar *where = this->dragging ? g_strdup_printf(_(", averaged with radius %d"), (int) this->radius) : g_strdup_printf("%s", _(" under cursor"));
+ // message, to show in the statusbar
+ const gchar *message = this->dragging ? _("<b>Release mouse</b> to set color.") : _("<b>Click</b> to set fill, <b>Shift+click</b> to set stroke; <b>drag</b> to average color in area; with <b>Alt</b> to pick inverse color; <b>Ctrl+C</b> to copy the color under mouse to clipboard");
+
+ this->defaultMessageContext()->setF(
+ Inkscape::NORMAL_MESSAGE,
+ "<b>%s%s</b>%s. %s", c,
+ (pick == SP_DROPPER_PICK_VISIBLE) ? "" : alpha, where, message);
+
+ g_free(where);
+ g_free(alpha);
+
+ // Set the right cursor for the mode and apply the special Fill color
+ auto xpm = (this->dropping ? (this->stroke ? cursor_dropping_s_xpm : cursor_dropping_f_xpm) :
+ (this->stroke ? cursor_dropper_s_xpm : cursor_dropper_f_xpm));
+ GdkCursor *cursor = sp_cursor_from_xpm(xpm, this->get_color(this->invert));
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(desktop->getCanvas()));
+ gdk_window_set_cursor(window, cursor);
+
if (!ret) {
ret = ToolBase::root_handler(event);
}
diff --git a/src/ui/tools/dropper-tool.h b/src/ui/tools/dropper-tool.h
index cfeb91dab..813f68296 100644
--- a/src/ui/tools/dropper-tool.h
+++ b/src/ui/tools/dropper-tool.h
@@ -25,6 +25,11 @@ enum {
SP_DROPPER_PICK_VISIBLE,
SP_DROPPER_PICK_ACTUAL
};
+enum {
+ DONT_REDRAW_CURSOR,
+ DRAW_FILL_CURSOR,
+ DRAW_STROKE_CURSOR
+};
namespace Inkscape {
namespace UI {
@@ -39,7 +44,7 @@ public:
virtual const std::string& getPrefsPath();
- guint32 get_color();
+ guint32 get_color(bool invert=false);
protected:
virtual void setup();
@@ -52,6 +57,10 @@ private:
double B;
double alpha;
+ double radius;
+ bool invert;
+ bool stroke;
+ bool dropping;
bool dragging;
SPCanvasItem* grabbed;
diff --git a/src/ui/tools/dynamic-base.cpp b/src/ui/tools/dynamic-base.cpp
index 6627a470e..bb4989333 100644
--- a/src/ui/tools/dynamic-base.cpp
+++ b/src/ui/tools/dynamic-base.cpp
@@ -18,8 +18,8 @@ namespace Inkscape {
namespace UI {
namespace Tools {
-DynamicBase::DynamicBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y)
- : ToolBase(cursor_shape, hot_x, hot_y)
+DynamicBase::DynamicBase(gchar const *const *cursor_shape)
+ : ToolBase(cursor_shape)
, accumulated(NULL)
, segments(NULL)
, currentshape(NULL)
diff --git a/src/ui/tools/dynamic-base.h b/src/ui/tools/dynamic-base.h
index 095af8f88..e270052f3 100644
--- a/src/ui/tools/dynamic-base.h
+++ b/src/ui/tools/dynamic-base.h
@@ -38,7 +38,7 @@ namespace Tools {
class DynamicBase : public ToolBase {
public:
- DynamicBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y);
+ DynamicBase(gchar const *const *cursor_shape);
virtual ~DynamicBase();
virtual void set(const Inkscape::Preferences::Entry& val);
diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp
index ae312e054..b4246b9cc 100644
--- a/src/ui/tools/eraser-tool.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -93,7 +93,7 @@ const std::string& EraserTool::getPrefsPath() {
const std::string EraserTool::prefsPath = "/tools/eraser";
EraserTool::EraserTool()
- : DynamicBase(cursor_eraser_xpm, 4, 4)
+ : DynamicBase(cursor_eraser_xpm)
, nowidth(false)
{
}
diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp
index 6e1d085aa..f6f9b4355 100644
--- a/src/ui/tools/flood-tool.cpp
+++ b/src/ui/tools/flood-tool.cpp
@@ -98,7 +98,7 @@ Glib::ustring gap_init[4] = {
const std::vector<Glib::ustring> FloodTool::gap_list( gap_init, gap_init+4 );
FloodTool::FloodTool()
- : ToolBase(cursor_paintbucket_xpm, 11, 30)
+ : ToolBase(cursor_paintbucket_xpm)
, item(NULL)
{
// TODO: Why does the flood tool use a hardcoded tolerance instead of a pref?
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 4af70a816..8a5ef0aad 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -63,8 +63,8 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc);
static void spdc_reset_white(FreehandBase *dc);
static void spdc_free_colors(FreehandBase *dc);
-FreehandBase::FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y)
- : ToolBase(cursor_shape, hot_x, hot_y)
+FreehandBase::FreehandBase(gchar const *const *cursor_shape)
+ : ToolBase(cursor_shape)
, selection(NULL)
, grab(NULL)
, attach(false)
diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h
index 3ee4cd7d0..a3069aa09 100644
--- a/src/ui/tools/freehand-base.h
+++ b/src/ui/tools/freehand-base.h
@@ -44,7 +44,7 @@ namespace Tools {
class FreehandBase : public ToolBase {
public:
- FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y);
+ FreehandBase(gchar const *const *cursor_shape);
virtual ~FreehandBase();
Inkscape::Selection *selection;
diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp
index 750596808..95d940bd6 100644
--- a/src/ui/tools/gradient-tool.cpp
+++ b/src/ui/tools/gradient-tool.cpp
@@ -58,7 +58,7 @@ const std::string GradientTool::prefsPath = "/tools/gradient";
GradientTool::GradientTool()
- : ToolBase(cursor_gradient_xpm, 4, 4)
+ : ToolBase(cursor_gradient_xpm)
, cursor_addnode(false)
, node_added(false)
// TODO: Why are these connections stored as pointers?
diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp
index 29e4c9e74..35e6d14a0 100644
--- a/src/ui/tools/lpe-tool.cpp
+++ b/src/ui/tools/lpe-tool.cpp
@@ -68,7 +68,7 @@ const std::string& LpeTool::getPrefsPath() {
const std::string LpeTool::prefsPath = "/tools/lpetool";
LpeTool::LpeTool()
- : PenTool(cursor_crosshairs_xpm, 7, 7)
+ : PenTool(cursor_crosshairs_xpm)
, shape_editor(NULL)
, canvas_bbox(NULL)
, mode(Inkscape::LivePathEffect::BEND_PATH)
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index 98b2c7d03..0da883891 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -322,7 +322,7 @@ void createAngleDisplayCurve(SPDesktop *desktop, Geom::Point const &center, Geom
boost::optional<Geom::Point> explicit_base_tmp = boost::none;
MeasureTool::MeasureTool()
- : ToolBase(cursor_measure_xpm, 4, 4)
+ : ToolBase(cursor_measure_xpm)
, grabbed(NULL)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
@@ -332,14 +332,14 @@ MeasureTool::MeasureTool()
// create the knots
this->knot_start = new SPKnot(desktop, _("Measure start, <b>Shift+Click</b> for position dialog"));
this->knot_start->setMode(SP_KNOT_MODE_XOR);
- this->knot_start->setFill(MT_KNOT_COLOR_NORMAL, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER);
- this->knot_start->setStroke(0x0000007f, 0x0000007f, 0x0000007f);
+ this->knot_start->setFill(MT_KNOT_COLOR_NORMAL, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER);
+ this->knot_start->setStroke(0x0000007f, 0x0000007f, 0x0000007f, 0x0000007f);
this->knot_start->setShape(SP_KNOT_SHAPE_CIRCLE);
this->knot_start->updateCtrl();
this->knot_end = new SPKnot(desktop, _("Measure end, <b>Shift+Click</b> for position dialog"));
this->knot_end->setMode(SP_KNOT_MODE_XOR);
- this->knot_end->setFill(MT_KNOT_COLOR_NORMAL, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER);
- this->knot_end->setStroke(0x0000007f, 0x0000007f, 0x0000007f);
+ this->knot_end->setFill(MT_KNOT_COLOR_NORMAL, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER, MT_KNOT_COLOR_MOUSEOVER);
+ this->knot_end->setStroke(0x0000007f, 0x0000007f, 0x0000007f, 0x0000007f);
this->knot_end->setShape(SP_KNOT_SHAPE_CIRCLE);
this->knot_end->updateCtrl();
Geom::Rect display_area = desktop->get_display_area();
diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp
index ac43b6c9d..d79741270 100644
--- a/src/ui/tools/mesh-tool.cpp
+++ b/src/ui/tools/mesh-tool.cpp
@@ -72,7 +72,7 @@ const std::string MeshTool::prefsPath = "/tools/mesh";
// TODO: The gradient tool class looks like a 1:1 copy.
MeshTool::MeshTool()
- : ToolBase(cursor_gradient_xpm, 4, 4)
+ : ToolBase(cursor_gradient_xpm)
, cursor_addnode(false)
, node_added(false)
, show_handles(true)
diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp
index 0c948c91c..08aacf805 100644
--- a/src/ui/tools/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -118,7 +118,7 @@ const std::string NodeTool::prefsPath = "/tools/nodes";
SPCanvasGroup *create_control_group(SPDesktop *d);
NodeTool::NodeTool()
- : ToolBase(cursor_node_xpm, 1, 1)
+ : ToolBase(cursor_node_xpm)
, _selected_nodes(NULL)
, _multipath(NULL)
, edit_clipping_paths(false)
@@ -773,14 +773,10 @@ void NodeTool::mouseover_changed(Inkscape::UI::ControlPoint *p) {
if (cdp && !this->cursor_drag) {
this->cursor_shape = cursor_node_d_xpm;
- this->hot_x = 1;
- this->hot_y = 1;
this->sp_event_context_update_cursor();
this->cursor_drag = true;
} else if (!cdp && this->cursor_drag) {
this->cursor_shape = cursor_node_xpm;
- this->hot_x = 1;
- this->hot_y = 1;
this->sp_event_context_update_cursor();
this->cursor_drag = false;
}
diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h
index 983ba6cee..dded2d9bd 100644
--- a/src/ui/tools/node-tool.h
+++ b/src/ui/tools/node-tool.h
@@ -61,6 +61,7 @@ public:
virtual bool root_handler(GdkEvent* event);
virtual const std::string& getPrefsPath();
+ boost::ptr_map<SPItem*, ShapeEditor> _shape_editors;
private:
sigc::connection _selection_changed_connection;
@@ -74,7 +75,6 @@ private:
Inkscape::UI::PathSharedData* _path_data;
SPCanvasGroup *_transform_handle_group;
SPItem *_last_over;
- boost::ptr_map<SPItem*, ShapeEditor> _shape_editors;
bool cursor_drag;
bool show_handles;
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index 0422dc9cd..4f19b25c6 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -81,7 +81,7 @@ const std::string& PenTool::getPrefsPath() {
const std::string PenTool::prefsPath = "/tools/freehand/pen";
PenTool::PenTool()
- : FreehandBase(cursor_pen_xpm, 4, 4)
+ : FreehandBase(cursor_pen_xpm)
, p()
, npoints(0)
, mode(MODE_CLICK)
@@ -100,8 +100,8 @@ PenTool::PenTool()
{
}
-PenTool::PenTool(gchar const *const *cursor_shape, gint hot_x, gint hot_y)
- : FreehandBase(cursor_shape, hot_x, hot_y)
+PenTool::PenTool(gchar const *const *cursor_shape)
+ : FreehandBase(cursor_shape)
, p()
, npoints(0)
, mode(MODE_CLICK)
diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h
index 5a21e3bac..7e5483358 100644
--- a/src/ui/tools/pen-tool.h
+++ b/src/ui/tools/pen-tool.h
@@ -23,7 +23,7 @@ namespace Tools {
class PenTool : public FreehandBase {
public:
PenTool();
- PenTool(gchar const *const *cursor_shape, gint hot_x, gint hot_y);
+ PenTool(gchar const *const *cursor_shape);
virtual ~PenTool();
enum Mode {
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index ec2874823..99b8103c3 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -57,7 +57,7 @@ const std::string& PencilTool::getPrefsPath() {
const std::string PencilTool::prefsPath = "/tools/freehand/pencil";
PencilTool::PencilTool()
- : FreehandBase(cursor_pencil_xpm, 4, 4)
+ : FreehandBase(cursor_pencil_xpm)
, p()
, npoints(0)
, state(SP_PENCIL_CONTEXT_IDLE)
diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp
index 272531945..9ebf51e76 100644
--- a/src/ui/tools/rect-tool.cpp
+++ b/src/ui/tools/rect-tool.cpp
@@ -52,7 +52,7 @@ const std::string& RectTool::getPrefsPath() {
const std::string RectTool::prefsPath = "/tools/shapes/rect";
RectTool::RectTool()
- : ToolBase(cursor_rect_xpm, 4, 4)
+ : ToolBase(cursor_rect_xpm)
, rect(NULL)
, rx(0)
, ry(0)
@@ -274,15 +274,6 @@ bool RectTool::root_handler(GdkEvent* event) {
NULL);
}
break;
- case GDK_KEY_Up:
- case GDK_KEY_Down:
- case GDK_KEY_KP_Up:
- case GDK_KEY_KP_Down:
- // prevent the zoom field from activation
- if (!MOD__CTRL_ONLY(event))
- ret = TRUE;
- break;
-
case GDK_KEY_x:
case GDK_KEY_X:
if (MOD__ALT_ONLY(event)) {
diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp
index bae1793ed..fca2173ca 100644
--- a/src/ui/tools/select-tool.cpp
+++ b/src/ui/tools/select-tool.cpp
@@ -81,7 +81,7 @@ sp_load_handles(int start, int count, char const **xpm) {
SelectTool::SelectTool()
// Don't load a default cursor
- : ToolBase(NULL, 0, 0)
+ : ToolBase(NULL)
, dragging(false)
, moved(false)
, button_press_shift(false)
@@ -94,8 +94,8 @@ SelectTool::SelectTool()
, _describer(NULL)
{
// cursors in select context
- CursorSelectMouseover = sp_cursor_new_from_xpm(cursor_select_m_xpm , 1, 1);
- CursorSelectDragging = sp_cursor_new_from_xpm(cursor_select_d_xpm , 1, 1);
+ CursorSelectMouseover = sp_cursor_from_xpm(cursor_select_m_xpm);
+ CursorSelectDragging = sp_cursor_from_xpm(cursor_select_d_xpm);
// selection handles
sp_load_handles(0, 2, handle_scale_xpm);
@@ -566,7 +566,9 @@ bool SelectTool::root_handler(GdkEvent* event) {
/* User has dragged fast, so we get events on root (lauris)*/
// not only that; we will end up here when ctrl-dragging as well
// and also when we started within tolerance, but trespassed tolerance outside of item
- Inkscape::Rubberband::get(desktop)->stop();
+ if (Inkscape::Rubberband::get(desktop)->is_started()) {
+ Inkscape::Rubberband::get(desktop)->stop();
+ }
this->defaultMessageContext()->clear();
item_at_point = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), FALSE);
diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp
index 0ba08853e..b681aec38 100644
--- a/src/ui/tools/spiral-tool.cpp
+++ b/src/ui/tools/spiral-tool.cpp
@@ -51,7 +51,7 @@ const std::string& SpiralTool::getPrefsPath() {
const std::string SpiralTool::prefsPath = "/tools/shapes/spiral";
SpiralTool::SpiralTool()
- : ToolBase(cursor_spiral_xpm, 4, 4)
+ : ToolBase(cursor_spiral_xpm)
, spiral(NULL)
, revo(3)
, exp(1)
@@ -245,14 +245,6 @@ bool SpiralTool::root_handler(GdkEvent* event) {
NULL,
_("<b>Alt</b>: lock spiral radius"));
break;
- case GDK_KEY_Up:
- case GDK_KEY_Down:
- case GDK_KEY_KP_Up:
- case GDK_KEY_KP_Down:
- // prevent the zoom field from activation
- if (!MOD__CTRL_ONLY(event))
- ret = TRUE;
- break;
case GDK_KEY_x:
case GDK_KEY_X:
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index ad006627c..f3e7e6d3c 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -137,7 +137,7 @@ static void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *it
}
SprayTool::SprayTool()
- : ToolBase(cursor_spray_xpm, 4, 4, false)
+ : ToolBase(cursor_spray_xpm, false)
, pressure(TC_DEFAULT_PRESSURE)
, dragging(false)
, usepressurewidth(false)
diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp
index ddee08189..32f0e6d92 100644
--- a/src/ui/tools/star-tool.cpp
+++ b/src/ui/tools/star-tool.cpp
@@ -57,7 +57,7 @@ const std::string& StarTool::getPrefsPath() {
const std::string StarTool::prefsPath = "/tools/shapes/star";
StarTool::StarTool()
- : ToolBase(cursor_star_xpm, 4, 4)
+ : ToolBase(cursor_star_xpm)
, star(NULL)
, magnitude(5)
, proportion(0.5)
@@ -260,15 +260,6 @@ bool StarTool::root_handler(GdkEvent* event) {
NULL);
break;
- case GDK_KEY_Up:
- case GDK_KEY_Down:
- case GDK_KEY_KP_Up:
- case GDK_KEY_KP_Down:
- // prevent the zoom field from activation
- if (!MOD__CTRL_ONLY(event))
- ret = TRUE;
- break;
-
case GDK_KEY_x:
case GDK_KEY_X:
if (MOD__ALT_ONLY(event)) {
diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp
index 649bbb045..9091b455e 100644
--- a/src/ui/tools/text-tool.cpp
+++ b/src/ui/tools/text-tool.cpp
@@ -76,7 +76,7 @@ const std::string TextTool::prefsPath = "/tools/text";
TextTool::TextTool()
- : ToolBase(cursor_text_xpm, 7, 7)
+ : ToolBase(cursor_text_xpm)
, imc(NULL)
, text(NULL)
, pdoc(0, 0)
@@ -359,8 +359,6 @@ bool TextTool::item_handler(SPItem* item, GdkEvent* event) {
sp_canvas_item_show(this->indicator);
this->cursor_shape = cursor_text_insert_xpm;
- this->hot_x = 7;
- this->hot_y = 10;
this->sp_event_context_update_cursor();
sp_text_context_update_text_selection(this);
@@ -548,8 +546,6 @@ bool TextTool::root_handler(GdkEvent* event) {
this->over_text = 0;
// update cursor and statusbar: we are not over a text object now
this->cursor_shape = cursor_text_xpm;
- this->hot_x = 7;
- this->hot_y = 7;
this->sp_event_context_update_cursor();
desktop->event_context->defaultMessageContext()->clear();
}
diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp
index 490d0fb26..12c3a3675 100644
--- a/src/ui/tools/tool-base.cpp
+++ b/src/ui/tools/tool-base.cpp
@@ -23,6 +23,7 @@
#include "shortcuts.h"
#include "file.h"
+#include "ui/contextmenu.h"
#include "ui/interface.h"
#include "ui/event-debug.h"
#include "ui/tool/control-point.h"
@@ -30,6 +31,10 @@
#include "ui/tools/tool-base.h"
#include "ui/tools-switch.h"
#include "ui/tools/lpe-tool.h"
+#include "ui/tool/commit-events.h"
+#include "ui/tool/event-utils.h"
+#include "ui/tools/node-tool.h"
+#include "ui/tool/shape-record.h"
#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
@@ -85,7 +90,7 @@ SPDesktop const& ToolBase::getDesktop() const {
return *desktop;
}
-ToolBase::ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y, bool uses_snap)
+ToolBase::ToolBase(gchar const *const *cursor_shape, bool uses_snap)
: pref_observer(NULL)
, cursor(NULL)
, xp(0)
@@ -103,8 +108,6 @@ ToolBase::ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y, boo
, desktop(NULL)
, _uses_snap(uses_snap)
, cursor_shape(cursor_shape)
- , hot_x(hot_x)
- , hot_y(hot_y)
{
}
@@ -153,44 +156,22 @@ void ToolBase::sp_event_context_set_cursor(GdkCursorType cursor_type) {
void ToolBase::sp_event_context_update_cursor() {
GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas());
if (gtk_widget_get_window (w)) {
-
- GtkStyle *style = gtk_widget_get_style(w);
-
- /* fixme: */
if (this->cursor_shape) {
- GdkDisplay *display = gdk_display_get_default();
- if (gdk_display_supports_cursor_alpha(display) && gdk_display_supports_cursor_color(display)) {
- bool fillHasColor=false, strokeHasColor=false;
- guint32 fillColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), true, &fillHasColor);
- guint32 strokeColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), false, &strokeHasColor);
- double fillOpacity = fillHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), true) : 0;
- double strokeOpacity = strokeHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), false) : 0;
-
- GdkPixbuf *pixbuf = sp_cursor_pixbuf_from_xpm(
- this->cursor_shape,
- style->black, style->white,
- SP_RGBA32_U_COMPOSE(SP_RGBA32_R_U(fillColor),SP_RGBA32_G_U(fillColor),SP_RGBA32_B_U(fillColor),SP_COLOR_F_TO_U(fillOpacity)),
- SP_RGBA32_U_COMPOSE(SP_RGBA32_R_U(strokeColor),SP_RGBA32_G_U(strokeColor),SP_RGBA32_B_U(strokeColor),SP_COLOR_F_TO_U(strokeOpacity))
- );
- if (pixbuf != NULL) {
- if (this->cursor) {
- g_object_unref(this->cursor);
- }
- this->cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, this->hot_x, this->hot_y);
- g_object_unref(pixbuf);
- }
- } else {
- GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)this->cursor_shape);
-
- if (pixbuf) {
- if (this->cursor) {
- g_object_unref(this->cursor);
- }
- this->cursor = gdk_cursor_new_from_pixbuf(display,
- pixbuf, this->hot_x, this->hot_y);
- g_object_unref(pixbuf);
- }
+ if(this->cursor) {
+ g_object_unref(this->cursor);
}
+
+ bool fillHasColor=false, strokeHasColor=false;
+ guint32 fillColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), true, &fillHasColor);
+ guint32 strokeColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), false, &strokeHasColor);
+ double fillOpacity = fillHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), true) : 0;
+ double strokeOpacity = strokeHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), false) : 0;
+
+ this->cursor = sp_cursor_from_xpm(
+ this->cursor_shape,
+ SP_RGBA32_C_COMPOSE(fillColor, fillOpacity),
+ SP_RGBA32_C_COMPOSE(strokeColor, strokeOpacity)
+ );
}
gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor);
gdk_flush();
@@ -207,8 +188,7 @@ void ToolBase::sp_event_context_update_cursor() {
void ToolBase::setup() {
this->pref_observer = new ToolPrefObserver(this->getPrefsPath(), this);
Inkscape::Preferences::get()->addObserver(*(this->pref_observer));
-
- this->sp_event_context_update_cursor();
+ this->sp_event_context_update_cursor();
}
/**
@@ -326,6 +306,43 @@ static gdouble accelerate_scroll(GdkEvent *event, gdouble acceleration,
return scroll_multiply;
}
+/** Moves the selected points along the supplied unit vector according to
+ * the modifier state of the supplied event. */
+bool ToolBase::_keyboardMove(GdkEventKey const &event, Geom::Point const &dir)
+{
+ if (held_control(event)) return false;
+ unsigned num = 1 + combine_key_events(shortcut_key(event), 0);
+ Geom::Point delta = dir * num;
+ if (held_shift(event)) delta *= 10;
+ if (held_alt(event)) {
+ delta /= desktop->current_zoom();
+ } else {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000, "px");
+ delta *= nudge;
+ }
+ if (shape_editor && shape_editor->has_knotholder()) {
+ KnotHolder * knotholder = shape_editor->knotholder;
+ if (knotholder) {
+ knotholder->transform_selected(Geom::Translate(delta));
+ }
+ } else if (tools_isactive(desktop, TOOLS_NODES)) {
+ Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context);
+ if (nt) {
+ for(auto i=nt->_shape_editors.begin();i!=nt->_shape_editors.end();++i){
+ ShapeEditor * shape_editor = i->second;
+ if (shape_editor && shape_editor->has_knotholder()) {
+ KnotHolder * knotholder = shape_editor->knotholder;
+ if (knotholder) {
+ knotholder->transform_selected(Geom::Translate(delta));
+ }
+ }
+ }
+ }
+ }
+ return true;
+}
+
bool ToolBase::root_handler(GdkEvent* event) {
// ui_dump_event (event, "ToolBase::root_handler");
@@ -624,6 +641,8 @@ bool ToolBase::root_handler(GdkEvent* event) {
gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
this->desktop->scroll_relative(Geom::Point(i, 0));
ret = TRUE;
+ } else {
+ ret = _keyboardMove(event->key, Geom::Point(-1, 0));
}
break;
@@ -637,6 +656,8 @@ bool ToolBase::root_handler(GdkEvent* event) {
gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
this->desktop->scroll_relative(Geom::Point(0, i));
ret = TRUE;
+ } else {
+ ret = _keyboardMove(event->key, Geom::Point(0, 1));
}
break;
@@ -650,6 +671,8 @@ bool ToolBase::root_handler(GdkEvent* event) {
gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
this->desktop->scroll_relative(Geom::Point(-i, 0));
ret = TRUE;
+ } else {
+ ret = _keyboardMove(event->key, Geom::Point(1, 0));
}
break;
@@ -663,6 +686,8 @@ bool ToolBase::root_handler(GdkEvent* event) {
gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
this->desktop->scroll_relative(Geom::Point(0, -i));
ret = TRUE;
+ } else {
+ ret = _keyboardMove(event->key, Geom::Point(0, -1));
}
break;
diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h
index 69533e417..09a9db660 100644
--- a/src/ui/tools/tool-base.h
+++ b/src/ui/tools/tool-base.h
@@ -14,12 +14,12 @@
#include <stddef.h>
#include <string>
-
+#include "knot.h"
+#include "knotholder.h"
#include <2geom/point.h>
#include <gdk/gdk.h>
#include <glib-object.h>
#include <sigc++/trackable.h>
-#include "knot.h"
#include "preferences.h"
@@ -30,7 +30,7 @@ namespace Glib {
class GrDrag;
class SPDesktop;
class SPItem;
-
+class KnotHolder;
namespace Inkscape {
class MessageContext;
class SelCue;
@@ -42,6 +42,7 @@ namespace Inkscape {
namespace Inkscape {
namespace UI {
+
class ShapeEditor;
namespace Tools {
@@ -144,7 +145,7 @@ public:
void enableGrDrag (bool enable=true);
bool deleteSelectedDrag(bool just_one);
- ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y, bool uses_snap = true);
+ ToolBase(gchar const *const *cursor_shape, bool uses_snap=true);
virtual ~ToolBase();
@@ -219,20 +220,18 @@ public:
SPDesktop *desktop;
bool _uses_snap; // TODO: make protected or private
-
protected:
/// An xpm containing the shape of the tool's cursor.
gchar const *const *cursor_shape;
- /// The cursor's hot spot
- gint hot_x, hot_y;
-
bool sp_event_context_knot_mouseover() const;
private:
ToolBase(const ToolBase&);
ToolBase& operator=(const ToolBase&);
+ bool _keyboardMove(GdkEventKey const &event, Geom::Point const &dir);
+
void sp_event_context_set_cursor(GdkCursorType cursor_type);
};
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index ff5d623c2..dcd9413fb 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -38,13 +38,13 @@
#include "pixmaps/cursor-tweak-rotate-counterclockwise.xpm"
#include "pixmaps/cursor-tweak-more.xpm"
#include "pixmaps/cursor-tweak-less.xpm"
-#include "pixmaps/cursor-thin.xpm"
-#include "pixmaps/cursor-thicken.xpm"
-#include "pixmaps/cursor-attract.xpm"
-#include "pixmaps/cursor-repel.xpm"
-#include "pixmaps/cursor-push.xpm"
-#include "pixmaps/cursor-roughen.xpm"
-#include "pixmaps/cursor-color.xpm"
+#include "pixmaps/cursor-tweak-thin.xpm"
+#include "pixmaps/cursor-tweak-thicken.xpm"
+#include "pixmaps/cursor-tweak-attract.xpm"
+#include "pixmaps/cursor-tweak-repel.xpm"
+#include "pixmaps/cursor-tweak-push.xpm"
+#include "pixmaps/cursor-tweak-roughen.xpm"
+#include "pixmaps/cursor-tweak-color.xpm"
#include "context-fns.h"
#include "inkscape.h"
#include "splivarot.h"
@@ -92,7 +92,7 @@ const std::string& TweakTool::getPrefsPath() {
const std::string TweakTool::prefsPath = "/tools/tweak";
TweakTool::TweakTool()
- : ToolBase(cursor_push_xpm, 4, 4)
+ : ToolBase(cursor_push_xpm)
, pressure(TC_DEFAULT_PRESSURE)
, dragging(false)
, usepressure(false)
diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp
index d40d2e969..8ba0c17b3 100644
--- a/src/ui/tools/zoom-tool.cpp
+++ b/src/ui/tools/zoom-tool.cpp
@@ -36,7 +36,7 @@ const std::string& ZoomTool::getPrefsPath() {
const std::string ZoomTool::prefsPath = "/tools/zoom";
ZoomTool::ZoomTool()
- : ToolBase(cursor_zoom_xpm, 6, 6)
+ : ToolBase(cursor_zoom_xpm)
, grabbed(NULL)
, escaped(false)
{