desktop-events.cpp revision a3cc2f41c8cd1301dccc4d27ccabc34db9c375bb
2521N/A#ifdef HAVE_CONFIG_H
2521N/A#include "desktop-events.h"
2521N/A#include "desktop-handles.h"
2521N/A#include "dialogs/dialog-events.h"
2521N/A#include "display/canvas-axonomgrid.h"
2521N/A#include "display/canvas-grid.h"
2521N/A#include "display/guideline.h"
2521N/A#include "display/snap-indicator.h"
2521N/A#include "document.h"
2521N/A#include "document-undo.h"
2521N/A#include "event-context.h"
2521N/A#include "helper/unit-menu.h"
2521N/A#include "message-context.h"
2521N/A#include "preferences.h"
2521N/A#include "display/sp-canvas.h"
2521N/A#include "sp-guide.h"
2521N/A#include "sp-metrics.h"
2521N/A#include "sp-namedview.h"
2521N/A#include "tools-switch.h"
2521N/A#include "widgets/desktop-widget.h"
2521N/Astatic void init_extended();
2521N/Avoid sp_dt_ruler_snap_new_guide(SPDesktop *desktop, SPCanvasItem *guide, Geom::Point &event_dt, Geom::Point &normal);
2521N/Astatic gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dtw, bool horiz)
2521N/A case GDK_BUTTON_PRESS:
clicked = true;
dragged = false;
if (grid){
if (horiz) {
NULL,
case GDK_MOTION_NOTIFY:
if (clicked) {
dragged = true;
case GDK_BUTTON_RELEASE:
if (!dragged) {
clicked = false;
dragged = false;
return FALSE;
sp_event_context_snap_delay_handler(dtw->desktop->event_context, (gpointer) widget, (gpointer) dtw, (GdkEventMotion *)event, DelayedSnapEvent::GUIDE_HRULER);
sp_event_context_snap_delay_handler(dtw->desktop->event_context, (gpointer) widget, (gpointer) dtw, (GdkEventMotion *)event, DelayedSnapEvent::GUIDE_VRULER);
//static bool reset_drag_origin = false; // when Ctrl is pressed while dragging, this is used to trigger resetting of the
static bool moved = false;
SPDesktop *desktop = static_cast<SPDesktop*>(g_object_get_data(G_OBJECT(item->canvas), "SPDesktop"));
case GDK_2BUTTON_PRESS:
case GDK_BUTTON_PRESS:
NULL,
case GDK_MOTION_NOTIFY:
sp_event_context_snap_delay_handler(desktop->event_context, (gpointer) item, data, (GdkEventMotion *)event, DelayedSnapEvent::GUIDE_HANDLER);
m.unSetup();
switch (drag_type) {
case SP_DRAG_TRANSLATE:
case SP_DRAG_ROTATE:
if (snaps) {
if (relative_snaps) {
case SP_DRAG_MOVE_ORIGIN:
case SP_DRAG_NONE:
moved = true;
case GDK_BUTTON_RELEASE:
if (moved) {
m.unSetup();
switch (drag_type) {
case SP_DRAG_TRANSLATE:
case SP_DRAG_ROTATE:
if (snaps) {
if (relative_snaps) {
case SP_DRAG_MOVE_ORIGIN:
case SP_DRAG_NONE:
moved = false;
case GDK_ENTER_NOTIFY:
gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), guide_cursor);
gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), guide_cursor);
desktop->guidesMessageContext()->setF(Inkscape::NORMAL_MESSAGE, _("<b>Guideline</b>: %s"), guide_description);
case GDK_LEAVE_NOTIFY:
gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), desktop->event_context->cursor);
case GDK_KEY_PRESS:
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
case GDK_KEY_BackSpace:
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), guide_cursor);
case GDK_KEY_RELEASE:
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), guide_cursor);
return ret;
static void init_extended()
if ( devices ) {
if ( devName
switch ( devSrc ) {
case GDK_SOURCE_PEN:
case GDK_SOURCE_ERASER:
case GDK_SOURCE_CURSOR:
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
case GDK_SCROLL:
case GDK_PROXIMITY_IN:
case GDK_PROXIMITY_OUT:
//g_message("Changed device %s -> %s", lastName.c_str(), name.c_str());
void sp_dt_ruler_snap_new_guide(SPDesktop *desktop, SPCanvasItem * /*guide*/, Geom::Point &event_dt, Geom::Point &normal)
// path this guide will change it slope to become either tangential or perpendicular to that path. It's
// therefore not useful to try tangential or perpendicular snapping, so this will be disabled temporarily
// After snapping, both event_dt and normal have been modified accordingly; we'll take the normal (of the
if (!(pref_tang || pref_perp)) { // if we don't want to snap either perpendicularly or tangentially, then
m.unSetup();