diff --git a/src/select-context.cpp b/src/select-context.cpp
index 6cffdc076f7161c1f4fee26dfd86f4f5f82f0329..e1649e34f164b07d8bba7fb44bf8512ee8ec3378 100644 (file)
--- a/src/select-context.cpp
+++ b/src/select-context.cpp
/*
* Selection and transformation context
*
- * Author:
+ * Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
- *
- * Copyright (C) 1999-2005 authors
+ *
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
+ * Copyright (C) 1999-2005 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "selection.h"
#include "seltrans-handles.h"
#include "sp-cursor.h"
-//#include "pixmaps/cursor-select-m.xpm" // These aren't used
-//#include "pixmaps/cursor-select-d.xpm"
+#include "pixmaps/cursor-select-m.xpm"
+#include "pixmaps/cursor-select-d.xpm"
#include "pixmaps/handles.xpm"
#include <glibmm/i18n.h>
event_context_class->item_handler = sp_select_context_item_handler;
// 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_new_from_xpm(cursor_select_m_xpm , 1, 1);
+ CursorSelectDragging = sp_cursor_new_from_xpm(cursor_select_d_xpm , 1, 1);
// selection handles
handles[0] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_scale_nw_xpm);
handles[1] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_scale_ne_xpm);
}
} else {
NR::Maybe<NR::Rect> const b = Inkscape::Rubberband::get()->getRectangle();
- if (b != NR::Nothing()) {
+ if (b) {
Inkscape::Rubberband::get()->stop();
rb_escaped = 1;
SP_EVENT_CONTEXT(sc)->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Selection canceled."));
@@ -318,6 +319,8 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE
sc->dragging = TRUE;
sc->moved = FALSE;
+ sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
+
// remember the clicked item in sc->item:
sc->item = sp_event_context_find_item (desktop,
NR::Point(event->button.x, event->button.y), event->button.state & GDK_MOD1_MASK, FALSE);
@@ -325,12 +328,18 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE
rb_escaped = drag_escaped = 0;
+ if (sc->grabbed) {
+ sp_canvas_item_ungrab(sc->grabbed, event->button.time);
+ sc->grabbed = NULL;
+ }
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->drawing),
GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK |
GDK_POINTER_MOTION_MASK,
NULL, event->button.time);
sc->grabbed = SP_CANVAS_ITEM(desktop->drawing);
+ sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
+
ret = TRUE;
}
} else if (event->button.button == 3) {
desktop->setCurrentLayer(reinterpret_cast<SPObject *>(clicked_item));
sp_desktop_selection(desktop)->clear();
sc->dragging = false;
+
+ sp_canvas_end_forced_full_redraws(desktop->canvas);
} else { // switch tool
tools_switch_by_item (desktop, clicked_item);
}
NR::Point const button_pt(event->button.x, event->button.y);
NR::Point const p(desktop->w2d(button_pt));
Inkscape::Rubberband::get()->start(desktop, p);
+ if (sc->grabbed) {
+ sp_canvas_item_ungrab(sc->grabbed, event->button.time);
+ sc->grabbed = NULL;
+ }
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK,
NULL, event->button.time);
// motion notify coordinates as given (no snapping back to origin)
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 (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
sc->dragging = TRUE;
+ sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
+ }
+
if (sc->dragging) {
/* User has dragged fast, so we get events on root (lauris)*/
// not only that; we will end up here when ctrl-dragging as well
@@ -498,10 +517,14 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
ret = TRUE;
} else {
sc->dragging = FALSE;
+
+ sp_canvas_end_forced_full_redraws(desktop->canvas);
}
} else {
- Inkscape::Rubberband::get()->move(p);
- gobble_motion_events(GDK_BUTTON1_MASK);
+ if (Inkscape::Rubberband::get()->is_started()) {
+ Inkscape::Rubberband::get()->move(p);
+ gobble_motion_events(GDK_BUTTON1_MASK);
+ }
}
}
break;
@@ -535,18 +558,21 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
}
}
sc->dragging = FALSE;
+
+ sp_canvas_end_forced_full_redraws(desktop->canvas);
+
if (sc->item) {
sp_object_unref( SP_OBJECT(sc->item), NULL);
}
sc->item = NULL;
} else {
NR::Maybe<NR::Rect> const b = Inkscape::Rubberband::get()->getRectangle();
- if (b != NR::Nothing() && !within_tolerance) {
+ if (b && !within_tolerance) {
// this was a rubberband drag
Inkscape::Rubberband::get()->stop();
seltrans->resetState();
// find out affected items:
- GSList *items = sp_document_items_in_box(sp_desktop_document(desktop), desktop->dkey, b.assume());
+ GSList *items = sp_document_items_in_box(sp_desktop_document(desktop), desktop->dkey, *b);
if (event->button.state & GDK_SHIFT_MASK) {
// with shift, add to selection
selection->addList (items);
@@ -622,11 +648,28 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
if (!key_is_a_modifier (get_group0_keyval (&event->key))) {
event_context->defaultMessageContext()->clear();
+ } else if (sc->grabbed || seltrans->isGrabbed()) {
+ // do not change the statusbar text when mousekey is down to move or transform the object,
+ // because the statusbar text is already updated somewhere else.
+ break;
} else {
sp_event_show_modifier_tip (event_context->defaultMessageContext(), event,
_("<b>Ctrl</b>: select in groups, move hor/vert"),
_("<b>Shift</b>: toggle select, force rubberband, disable snapping"),
_("<b>Alt</b>: select under, move selected"));
+ // if Alt then change cursor to moving cursor:
+ guint keyval = get_group0_keyval(&event->key);
+ bool alt = ( MOD__ALT
+ || (keyval == GDK_Alt_L)
+ || (keyval == GDK_Alt_R)
+ || (keyval == GDK_Meta_L)
+ || (keyval == GDK_Meta_R));
+ if (alt) {
+ GdkCursor *cursor = gdk_cursor_new(GDK_FLEUR);
+ gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, cursor);
+ gdk_cursor_destroy(cursor);
+ }
+ //*/
break;
}
ret = TRUE;
}
break;
- case GDK_Tab: // Tab - cycle selection forward
- if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
- sp_selection_item_next();
- ret = TRUE;
- }
- break;
- case GDK_ISO_Left_Tab: // Shift Tab - cycle selection backward
- if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
- sp_selection_item_prev();
- ret = TRUE;
- }
- break;
case GDK_space:
/* stamping mode: show outline mode moving */
/* FIXME: Is next condition ok? (lauris) */
case GDK_KEY_RELEASE:
if (key_is_a_modifier (get_group0_keyval (&event->key)))
event_context->defaultMessageContext()->clear();
+ // set cursor to default.
+ gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, event_context->cursor);
break;
default:
break;