Code

Removed use of union in paint type/struct
[inkscape.git] / src / select-context.cpp
index 8f971149e079588efabf006d3760075f6232f900..e1649e34f164b07d8bba7fb44bf8512ee8ec3378 100644 (file)
@@ -3,11 +3,12 @@
 /*
  * 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
  */
@@ -22,8 +23,8 @@
 #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>
 
@@ -96,8 +97,8 @@ sp_select_context_class_init(SPSelectContextClass *klass)
     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);
@@ -228,7 +229,7 @@ sp_select_context_abort(SPEventContext *event_context)
         }
     } 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."));
@@ -327,6 +328,10 @@ 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,
@@ -429,6 +434,10 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 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);
@@ -512,8 +521,10 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         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;
@@ -556,12 +567,12 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                     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);
@@ -735,18 +746,6 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         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) */