summaryrefslogtreecommitdiffstats
path: root/src/knot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/knot.cpp')
-rw-r--r--src/knot.cpp68
1 files changed, 14 insertions, 54 deletions
diff --git a/src/knot.cpp b/src/knot.cpp
index bfc0c4f0b..50fa73391 100644
--- a/src/knot.cpp
+++ b/src/knot.cpp
@@ -13,7 +13,6 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
#endif
#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
@@ -24,11 +23,8 @@
#include "knot-ptr.h"
#include "document.h"
#include "document-undo.h"
-#include "preferences.h"
#include "message-stack.h"
#include "message-context.h"
-#include "ui/tools-switch.h"
-#include "ui/tools/tool-base.h"
#include "ui/tools/node-tool.h"
#include <gtk/gtk.h>
@@ -73,6 +69,7 @@ SPKnot::SPKnot(SPDesktop *desktop, gchar const *tip)
this->flags = 0;
this->size = 8;
+ this->angle = 0;
this->pos = Geom::Point(0, 0);
this->grabbed_rel_pos = Geom::Point(0, 0);
this->anchor = SP_ANCHOR_CENTER;
@@ -113,6 +110,7 @@ SPKnot::SPKnot(SPDesktop *desktop, gchar const *tip)
SP_TYPE_CTRL,
"anchor", SP_ANCHOR_CENTER,
"size", 8.0,
+ "angle", 0.0,
"filled", TRUE,
"fill_color", 0xffffff00,
"stroked", TRUE,
@@ -126,21 +124,14 @@ SPKnot::SPKnot(SPDesktop *desktop, gchar const *tip)
}
SPKnot::~SPKnot() {
-#if GTK_CHECK_VERSION(3,0,0)
- GdkDisplay *display = gdk_display_get_default();
- GdkDeviceManager *dm = gdk_display_get_device_manager(display);
- GdkDevice *device = gdk_device_manager_get_client_pointer(dm);
+ auto display = gdk_display_get_default();
+ auto dm = gdk_display_get_device_manager(display);
+ auto device = gdk_device_manager_get_client_pointer(dm);
if ((this->flags & SP_KNOT_GRABBED) && gdk_display_device_is_grabbed(display, device)) {
// This happens e.g. when deleting a node in node tool while dragging it
gdk_device_ungrab(device, GDK_CURRENT_TIME);
}
-#else
- if ((this->flags & SP_KNOT_GRABBED) && gdk_pointer_is_grabbed ()) {
- // This happens e.g. when deleting a node in node tool while dragging it
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- }
-#endif
if (this->_event_handler_id > 0) {
g_signal_handler_disconnect(G_OBJECT (this->item), this->_event_handler_id);
@@ -154,11 +145,7 @@ SPKnot::~SPKnot() {
for (gint i = 0; i < SP_KNOT_VISIBLE_STATES; i++) {
if (this->cursor[i]) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(this->cursor[i]);
-#else
- gdk_cursor_unref(this->cursor[i]);
-#endif
this->cursor[i] = NULL;
}
}
@@ -227,7 +214,7 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot
if ((event->button.button == 1) && knot->desktop && knot->desktop->event_context && !knot->desktop->event_context->space_panning) {
Geom::Point const p = knot->desktop->w2d(Geom::Point(event->button.x, event->button.y));
knot->startDragging(p, (gint) event->button.x, (gint) event->button.y, event->button.time);
-
+ knot->mousedown_signal.emit(knot, event->button.state);
consumed = TRUE;
}
break;
@@ -254,7 +241,6 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot
if (moved) {
knot->setFlag(SP_KNOT_DRAGGING, FALSE);
-
knot->ungrabbed_signal.emit(knot, event->button.state);
} else {
knot->click_signal.emit(knot, event->button.state);
@@ -265,10 +251,7 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot
consumed = TRUE;
}
}
- if (tools_isactive(knot->desktop, TOOLS_NODES)) {
- Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(knot->desktop->event_context);
- nt->update_helperpath();
- }
+ Inkscape::UI::Tools::sp_update_helperpath();
break;
case GDK_MOTION_NOTIFY:
if (grabbed && knot->desktop && knot->desktop->event_context && !knot->desktop->event_context->space_panning) {
@@ -292,19 +275,15 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot
}
if (!moved) {
- knot->grabbed_signal.emit(knot, event->motion.state);
-
knot->setFlag(SP_KNOT_DRAGGING, TRUE);
+ knot->grabbed_signal.emit(knot, event->button.state);
}
sp_event_context_snap_delay_handler(knot->desktop->event_context, NULL, knot, (GdkEventMotion *)event, Inkscape::UI::Tools::DelayedSnapEvent::KNOT_HANDLER);
sp_knot_handler_request_position(event, knot);
moved = TRUE;
}
- if (tools_isactive(knot->desktop, TOOLS_NODES)) {
- Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(knot->desktop->event_context);
- nt->update_helperpath();
- }
+ Inkscape::UI::Tools::sp_update_helperpath();
break;
case GDK_ENTER_NOTIFY:
knot->setFlag(SP_KNOT_MOUSEOVER, TRUE);
@@ -462,6 +441,7 @@ void SPKnot::updateCtrl() {
g_object_set(this->item, "shape", this->shape, NULL);
g_object_set(this->item, "mode", this->mode, NULL);
g_object_set(this->item, "size", (gdouble) this->size, NULL);
+ g_object_set(this->item, "angle", this->angle, NULL);
g_object_set(this->item, "anchor", this->anchor, NULL);
if (this->pixbuf) {
@@ -505,6 +485,10 @@ void SPKnot::setPixbuf(gpointer p) {
pixbuf = p;
}
+void SPKnot::setAngle(double i) {
+ angle = i;
+}
+
void SPKnot::setFill(guint32 normal, guint32 mouseover, guint32 dragging) {
fill[SP_KNOT_STATE_NORMAL] = normal;
fill[SP_KNOT_STATE_MOUSEOVER] = mouseover;
@@ -525,57 +509,33 @@ void SPKnot::setImage(guchar* normal, guchar* mouseover, guchar* dragging) {
void SPKnot::setCursor(GdkCursor* normal, GdkCursor* mouseover, GdkCursor* dragging) {
if (cursor[SP_KNOT_STATE_NORMAL]) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(cursor[SP_KNOT_STATE_NORMAL]);
-#else
- gdk_cursor_unref(cursor[SP_KNOT_STATE_NORMAL]);
-#endif
}
cursor[SP_KNOT_STATE_NORMAL] = normal;
if (normal) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_ref(normal);
-#else
- gdk_cursor_ref(normal);
-#endif
}
if (cursor[SP_KNOT_STATE_MOUSEOVER]) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(cursor[SP_KNOT_STATE_MOUSEOVER]);
-#else
- gdk_cursor_unref(cursor[SP_KNOT_STATE_MOUSEOVER]);
-#endif
}
cursor[SP_KNOT_STATE_MOUSEOVER] = mouseover;
if (mouseover) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_ref(mouseover);
-#else
- gdk_cursor_ref(mouseover);
-#endif
}
if (cursor[SP_KNOT_STATE_DRAGGING]) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(cursor[SP_KNOT_STATE_DRAGGING]);
-#else
- gdk_cursor_unref(cursor[SP_KNOT_STATE_DRAGGING]);
-#endif
}
cursor[SP_KNOT_STATE_DRAGGING] = dragging;
if (dragging) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_ref(dragging);
-#else
- gdk_cursor_ref(dragging);
-#endif
}
}