X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fselect-context.cpp;h=c527471f5a22c093da8c24bce6f9cbb5b95a1a2c;hb=915f222e72a35382120e42ff1d204a99b16644b6;hp=bda4012c7b832aa956b121898c206f1967d8870d;hpb=6b15695578f07a3f72c4c9475c1a261a3021472a;p=inkscape.git diff --git a/src/select-context.cpp b/src/select-context.cpp index bda4012c7..c527471f5 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -22,8 +22,8 @@ #include "selection.h" #include "seltrans-handles.h" #include "sp-cursor.h" -#include "pixmaps/cursor-select-m.xpm" -#include "pixmaps/cursor-select-d.xpm" +//#include "pixmaps/cursor-select-m.xpm" // These aren't used +//#include "pixmaps/cursor-select-d.xpm" #include "pixmaps/handles.xpm" #include @@ -96,8 +96,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); @@ -191,7 +191,7 @@ sp_select_context_set(SPEventContext *ec, gchar const *key, gchar const *val) } else { sc->_seltrans->setShow(Inkscape::SelTrans::SHOW_CONTENT); } - } + } } static bool @@ -211,7 +211,7 @@ sp_select_context_abort(SPEventContext *event_context) if (sc->item) { // only undo if the item is still valid if (SP_OBJECT_DOCUMENT( SP_OBJECT(sc->item))) { - sp_document_undo(SP_DT_DOCUMENT(desktop)); + sp_document_undo(sp_desktop_document(desktop)); } sp_object_unref( SP_OBJECT(sc->item), NULL); @@ -219,7 +219,7 @@ sp_select_context_abort(SPEventContext *event_context) // NOTE: This is a workaround to a bug. // When the ctrl key is held, sc->item is not defined // so in this case (only), we skip the object doc check - sp_document_undo(SP_DT_DOCUMENT(desktop)); + sp_document_undo(sp_desktop_document(desktop)); } sc->item = NULL; @@ -233,12 +233,12 @@ sp_select_context_abort(SPEventContext *event_context) rb_escaped = 1; SP_EVENT_CONTEXT(sc)->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Selection canceled.")); return true; - } + } } return false; } -bool +bool key_is_a_modifier (guint key) { return (key == GDK_Alt_L || key == GDK_Alt_R || @@ -275,7 +275,7 @@ sp_select_context_up_one_layer(SPDesktop *desktop) { desktop->setCurrentLayer(parent); if (SP_IS_GROUP(current_layer) && SPGroup::LAYER != SP_GROUP(current_layer)->layerMode()) - SP_DT_SELECTION(desktop)->set(current_layer); + sp_desktop_selection(desktop)->set(current_layer); } } } @@ -318,8 +318,10 @@ 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, + sc->item = sp_event_context_find_item (desktop, NR::Point(event->button.x, event->button.y), event->button.state & GDK_MOD1_MASK, FALSE); sp_object_ref(sc->item, NULL); @@ -327,10 +329,12 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE 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 | GDK_POINTER_MOTION_HINT_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) { @@ -342,13 +346,13 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE case GDK_ENTER_NOTIFY: { GdkCursor *cursor = gdk_cursor_new(GDK_FLEUR); - gdk_window_set_cursor(GTK_WIDGET(SP_DT_CANVAS(desktop))->window, cursor); + gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, cursor); gdk_cursor_destroy(cursor); break; } case GDK_LEAVE_NOTIFY: - gdk_window_set_cursor(GTK_WIDGET(SP_DT_CANVAS(desktop))->window, event_context->cursor); + gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, event_context->cursor); break; case GDK_KEY_PRESS: @@ -383,7 +387,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) SPDesktop *desktop = event_context->desktop; SPSelectContext *sc = SP_SELECT_CONTEXT(event_context); Inkscape::SelTrans *seltrans = sc->_seltrans; - Inkscape::Selection *selection = SP_DT_SELECTION(desktop); + Inkscape::Selection *selection = sp_desktop_selection(desktop); 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); tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100); @@ -401,8 +405,10 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) SPItem *clicked_item = (SPItem *) selection->itemList()->data; if (SP_IS_GROUP (clicked_item)) { // enter group desktop->setCurrentLayer(reinterpret_cast(clicked_item)); - SP_DT_SELECTION(desktop)->clear(); + 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); } @@ -459,9 +465,13 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) // 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 @@ -470,7 +480,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) item_at_point = desktop->item_at_point(NR::Point(event->button.x, event->button.y), FALSE); if (!item_at_point) // if no item at this point, try at the click point (bug 1012200) item_at_point = desktop->item_at_point(NR::Point(xp, yp), FALSE); - if (item_at_point || sc->moved || sc->button_press_alt) { + if (item_at_point || sc->moved || sc->button_press_alt) { // drag only if starting from an item, or if something is already grabbed, or if alt-dragging if (!sc->moved) { item_in_group = desktop->item_at_point(NR::Point(event->button.x, event->button.y), TRUE); @@ -498,6 +508,8 @@ 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); @@ -535,6 +547,9 @@ 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); } @@ -546,7 +561,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) Inkscape::Rubberband::get()->stop(); seltrans->resetState(); // find out affected items: - GSList *items = sp_document_items_in_box(SP_DT_DOCUMENT(desktop), desktop->dkey, b.assume()); + GSList *items = sp_document_items_in_box(sp_desktop_document(desktop), desktop->dkey, b.assume()); if (event->button.state & GDK_SHIFT_MASK) { // with shift, add to selection selection->addList (items); @@ -564,12 +579,12 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (sc->button_press_ctrl) { // go into groups, honoring Alt - item = sp_event_context_find_item (desktop, + item = sp_event_context_find_item (desktop, NR::Point(event->button.x, event->button.y), event->button.state & GDK_MOD1_MASK, TRUE); sc->button_press_ctrl = FALSE; } else { // don't go into groups, honoring Alt - item = sp_event_context_find_item (desktop, + item = sp_event_context_find_item (desktop, NR::Point(event->button.x, event->button.y), event->button.state & GDK_MOD1_MASK, FALSE); } @@ -582,7 +597,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) sc->button_press_ctrl = FALSE; - item = sp_event_context_find_item (desktop, + item = sp_event_context_find_item (desktop, NR::Point(event->button.x, event->button.y), event->button.state & GDK_MOD1_MASK, TRUE); if (item) { @@ -610,6 +625,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) sp_canvas_item_ungrab(sc->grabbed, event->button.time); sc->grabbed = NULL; } + + desktop->updateNow(); } sc->button_press_shift = false; sc->button_press_ctrl = false; @@ -625,6 +642,19 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) _("Ctrl: select in groups, move hor/vert"), _("Shift: toggle select, force rubberband, disable snapping"), _("Alt: 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; } @@ -776,7 +806,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) SPItem *clicked_item = selection->singleItem(); if (SP_IS_GROUP (clicked_item)) { // enter group desktop->setCurrentLayer(reinterpret_cast(clicked_item)); - SP_DT_SELECTION(desktop)->clear(); + sp_desktop_selection(desktop)->clear(); } else { SP_EVENT_CONTEXT(sc)->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Selected object is not a group. Cannot enter.")); } @@ -797,6 +827,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) 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;