select-context.cpp revision 6129af7cc5b723223e9617614c931936e5190421
1494N/A#define __SP_SELECT_CONTEXT_C__
1494N/A#ifdef HAVE_CONFIG_H
1494N/A#include "rubberband.h"
1494N/A#include "document.h"
1494N/A#include "selection.h"
1494N/A#include "seltrans-handles.h"
1494N/A#include "sp-cursor.h"
1494N/A#include "pixmaps/cursor-select-m.xpm"
1494N/A#include "pixmaps/cursor-select-d.xpm"
1494N/A#include "pixmaps/handles.xpm"
1494N/A#include "select-context.h"
1494N/A#include "selection-chemistry.h"
1494N/A#include "desktop-handles.h"
1494N/A#include "prefs-utils.h"
1494N/A#include "tools-switch.h"
1494N/A#include "message-stack.h"
1494N/A#include "selection-describer.h"
1494N/A#include "seltrans.h"
1637N/Astatic gint sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
1500N/Astatic gint rb_escaped = 0; // if non-zero, rubberband was canceled by esc, so the next button release should not deselect
1494N/Astatic bool within_tolerance = false;
1494N/A sizeof(SPSelectContextClass),
1494N/A sizeof(SPSelectContext),
1494N/A type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPSelectContext", &info, (GTypeFlags)0);
if (CursorSelectDragging) {
if (CursorSelectMouseover) {
select_context->_describer = new Inkscape::SelectionDescriber(desktop->selection, desktop->messageStack());
SP_EVENT_CONTEXT(sc)->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Move canceled."));
SP_EVENT_CONTEXT(sc)->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Selection canceled."));
if (current_layer) {
if ( parent
static gint
case GDK_BUTTON_PRESS:
within_tolerance = true;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
case GDK_KEY_PRESS:
if (!ret) {
return ret;
static gint
gdouble const nudge = prefs_get_double_attribute_limited("options.nudgedistance", "value", 2, 0, 1000); // in px
gdouble const offset = prefs_get_double_attribute_limited("options.defaultscale", "value", 2, 0, 1000);
case GDK_2BUTTON_PRESS:
case GDK_BUTTON_PRESS:
within_tolerance = true;
case GDK_MOTION_NOTIFY:
if ( within_tolerance
within_tolerance = false;
if (sc->button_press_ctrl || sc->button_press_alt) // if ctrl or alt was pressed and it's not click, we want to drag rather than rubberband
// if neither a group nor an item (possibly in a group) at point are selected, set selection to the item at point
} // otherwise, do not change selection so that dragging selected-within-group items, as well as alt-dragging, is possible
// unfortunately in complex drawings, gobbling results in losing grab of the object, for some mysterious reason
case GDK_BUTTON_RELEASE:
if (item) {
if (item) {
rb_escaped = 0;
case GDK_KP_Left:
case GDK_KP_4:
case GDK_KP_Up:
case GDK_KP_8:
case GDK_KP_Right:
case GDK_KP_6:
case GDK_KP_Down:
case GDK_KP_2:
case GDK_Escape:
case GDK_a:
case GDK_A:
if (MOD__CTRL_ONLY) {
case GDK_space:
case GDK_x:
case GDK_X:
if (MOD__ALT_ONLY) {
case GDK_bracketleft:
if (MOD__ALT) {
} else if (MOD__CTRL) {
} else if (snaps) {
case GDK_bracketright:
if (MOD__ALT) {
} else if (MOD__CTRL) {
} else if (snaps) {
case GDK_less:
case GDK_comma:
if (MOD__ALT) {
} else if (MOD__CTRL) {
case GDK_greater:
case GDK_period:
if (MOD__ALT) {
} else if (MOD__CTRL) {
case GDK_Return:
if (MOD__CTRL_ONLY) {
SP_EVENT_CONTEXT(sc)->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Selected object is not a group. Cannot enter."));
case GDK_BackSpace:
if (MOD__CTRL_ONLY) {
case GDK_KEY_RELEASE:
if (!ret) {
return ret;