Code

Pot and Dutch translation update
[inkscape.git] / src / select-context.cpp
index fd4e132e1798cb054553f5e483a14b881916c90e..028c8634b62435475a926670ec97082a881c66f7 100644 (file)
@@ -98,6 +98,18 @@ sp_select_context_class_init(SPSelectContextClass *klass)
     event_context_class->set = sp_select_context_set;
     event_context_class->root_handler = sp_select_context_root_handler;
     event_context_class->item_handler = sp_select_context_item_handler;
+}
+
+static void
+sp_select_context_init(SPSelectContext *sc)
+{
+    sc->dragging = FALSE;
+    sc->moved = FALSE;
+    sc->button_press_shift = false;
+    sc->button_press_ctrl = false;
+    sc->button_press_alt = false;
+    sc->_seltrans = NULL;
+    sc->_describer = NULL;
 
     // cursors in select context
     CursorSelectMouseover = sp_cursor_new_from_xpm(cursor_select_m_xpm , 1, 1);
@@ -116,19 +128,6 @@ sp_select_context_class_init(SPSelectContextClass *klass)
     handles[10] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_sw_xpm);
     handles[11] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_w_xpm);
     handles[12] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_center_xpm);
-
-}
-
-static void
-sp_select_context_init(SPSelectContext *sc)
-{
-    sc->dragging = FALSE;
-    sc->moved = FALSE;
-    sc->button_press_shift = false;
-    sc->button_press_ctrl = false;
-    sc->button_press_alt = false;
-    sc->_seltrans = NULL;
-    sc->_describer = NULL;
 }
 
 static void
@@ -172,7 +171,12 @@ sp_select_context_setup(SPEventContext *ec)
 
     SPDesktop *desktop = ec->desktop;
 
-    select_context->_describer = new Inkscape::SelectionDescriber(desktop->selection, desktop->messageStack());
+    select_context->_describer = new Inkscape::SelectionDescriber(
+                desktop->selection, 
+                desktop->messageStack(),
+                _("Click selection to toggle scale/rotation handles"),
+                _("No objects selected. Click, Shift+click, or drag around objects to select.")
+        );
 
     select_context->_seltrans = new Inkscape::SelTrans(desktop);
 
@@ -212,6 +216,7 @@ sp_select_context_abort(SPEventContext *event_context)
             seltrans->ungrab();
             sc->moved = FALSE;
             sc->dragging = FALSE;
+            sp_event_context_discard_delayed_snap_event(event_context);
             drag_escaped = 1;
 
             if (sc->item) {
@@ -325,6 +330,8 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE
                     sc->dragging = TRUE;
                     sc->moved = FALSE;
 
+                    gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, CursorSelectDragging);
+
                     sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
 
                     // remember the clicked item in sc->item:
@@ -360,16 +367,14 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE
 
         case GDK_ENTER_NOTIFY:
         {
-            if (!desktop->isWaitingCursor()) {
-                GdkCursor *cursor = gdk_cursor_new(GDK_FLEUR);
-                gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, cursor);
-                gdk_cursor_destroy(cursor);
+            if (!desktop->isWaitingCursor() && !sc->dragging) {
+                gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, CursorSelectMouseover);
             }
             break;
         }
 
         case GDK_LEAVE_NOTIFY:
-            if (!desktop->isWaitingCursor())
+            if (!desktop->isWaitingCursor() && !sc->dragging)
                 gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, event_context->cursor);
             break;
 
@@ -408,11 +413,6 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
-    gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); // in px
-    gdouble const offset = prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000);
-    tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
-    int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
-
     // make sure we still have valid objects to move around
     if (sc->item && SP_OBJECT_DOCUMENT( SP_OBJECT(sc->item))==NULL) {
         sp_select_context_abort(event_context);
@@ -427,10 +427,13 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         desktop->setCurrentLayer(reinterpret_cast<SPObject *>(clicked_item));
                         sp_desktop_selection(desktop)->clear();
                         sc->dragging = false;
+                        sp_event_context_discard_delayed_snap_event(event_context);
 
                         sp_canvas_end_forced_full_redraws(desktop->canvas);
                     } else { // switch tool
-                        tools_switch_by_item (desktop, clicked_item);
+                        Geom::Point const button_pt(event->button.x, event->button.y);
+                        Geom::Point const p(desktop->w2d(button_pt));
+                        tools_switch_by_item (desktop, clicked_item, p);
                     }
                 } else {
                     sp_select_context_up_one_layer(desktop);
@@ -477,7 +480,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
             break;
 
         case GDK_MOTION_NOTIFY:
-            if (event->motion.state & GDK_BUTTON1_MASK && !event_context->space_panning) {
+               tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
+               if (event->motion.state & GDK_BUTTON1_MASK && !event_context->space_panning) {
                 Geom::Point const motion_pt(event->motion.x, event->motion.y);
                 Geom::Point const p(desktop->w2d(motion_pt));
 
@@ -494,7 +498,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 if (sc->button_press_ctrl || (sc->button_press_alt && !sc->button_press_shift && !selection->isEmpty())) {
                     // if it's not click and ctrl or alt was pressed (the latter with some selection
                     // but not with shift) we want to drag rather than rubberband
-                    sc->dragging = TRUE;
+                       sc->dragging = TRUE;
+                    gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, CursorSelectDragging);
 
                     sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
                 }
@@ -513,6 +518,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         if (!sc->moved) {
                             item_in_group = desktop->item_at_point(Geom::Point(event->button.x, event->button.y), TRUE);
                             group_at_point = desktop->group_at_point(Geom::Point(event->button.x, event->button.y));
+                            if (SP_IS_LAYER(selection->single()))
+                                group_at_point = SP_GROUP(selection->single());
 
                             // group-at-point is meant to be topmost item if it's a group,
                             // not topmost group of all items at point
@@ -533,7 +540,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                                 if (item_at_point && !selection->includes(item_at_point))
                                     selection->set(item_at_point);
                             } // otherwise, do not change selection so that dragging selected-within-group items, as well as alt-dragging, is possible
-                            seltrans->grab(p, -1, -1, FALSE);
+                            seltrans->grab(p, -1, -1, FALSE, TRUE);
                             sc->moved = TRUE;
                         }
                         if (!seltrans->isEmpty())
@@ -543,7 +550,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         ret = TRUE;
                     } else {
                         sc->dragging = FALSE;
-
+                        sp_event_context_discard_delayed_snap_event(event_context);
                         sp_canvas_end_forced_full_redraws(desktop->canvas);
                     }
                 } else {
@@ -575,9 +582,12 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                                 seltrans->resetState();
                                 selection->toggle(sc->item);
                             } else {
+                                SPObject* single = selection->single();
                                 // without shift, increase state (i.e. toggle scale/rotation handles)
                                 if (selection->includes(sc->item)) {
                                     seltrans->increaseState();
+                                } else if (SP_IS_LAYER(single) && single->isAncestorOf(sc->item)) {
+                                    seltrans->increaseState();
                                 } else {
                                     seltrans->resetState();
                                     selection->set(sc->item);
@@ -589,7 +599,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         }
                     }
                     sc->dragging = FALSE;
-
+                    gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, CursorSelectMouseover);
+                    sp_event_context_discard_delayed_snap_event(event_context);
                     sp_canvas_end_forced_full_redraws(desktop->canvas);
 
                     if (sc->item) {
@@ -597,7 +608,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                     }
                     sc->item = NULL;
                 } else {
-                    Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop);
+                    Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
                     if (r->is_started() && !within_tolerance) {
                         // this was a rubberband drag
                         GSList *items = NULL;
@@ -689,8 +700,9 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
 
         case GDK_KEY_PRESS: // keybindings for select context
 
-            {
-            guint keyval = get_group0_keyval(&event->key);
+                       {
+                       {
+               guint keyval = get_group0_keyval(&event->key);
             bool alt = ( MOD__ALT
                                     || (keyval == GDK_Alt_L)
                                     || (keyval == GDK_Alt_R)
@@ -717,16 +729,18 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                                                 _("<b>Alt</b>: click to select under; drag to move selected or select by touch"));
                     // if Alt and nonempty selection, show moving cursor ("move selected"):
                     if (alt && !selection->isEmpty() && !desktop->isWaitingCursor()) {
-                        GdkCursor *cursor = gdk_cursor_new(GDK_FLEUR);
-                        gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, cursor);
-                        gdk_cursor_destroy(cursor);
+                        gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, CursorSelectDragging);
                     }
                     //*/
                     break;
             }
-            }
+                       }
+
+            gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); // in px
+                       gdouble const offset = prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000);
+                       int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
 
-            switch (get_group0_keyval (&event->key)) {
+                       switch (get_group0_keyval (&event->key)) {
                 case GDK_Left: // move selection left
                 case GDK_KP_Left:
                 case GDK_KP_4:
@@ -917,7 +931,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                     break;
             }
             break;
-
+                       }
         case GDK_KEY_RELEASE:
             {
             guint keyval = get_group0_keyval(&event->key);
@@ -938,8 +952,9 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
             }
             }
             // set cursor to default.
-            if (!desktop->isWaitingCursor())
+            if (!desktop->isWaitingCursor()) {
                 gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, event_context->cursor);
+            }
             break;
         default:
             break;