diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2017-03-20 20:12:31 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2017-03-20 20:12:31 +0000 |
| commit | f47466c701b2256b2ce232f6d311d2be47136eab (patch) | |
| tree | 656e3f47c008066434975b3b0ed8c20832a83116 /src/ui | |
| parent | Modify CanvasXYGrid to work with rotated canvas. (diff) | |
| download | inkscape-f47466c701b2256b2ce232f6d311d2be47136eab.tar.gz inkscape-f47466c701b2256b2ce232f6d311d2be47136eab.zip | |
Implement rotation via desktop to window affine.
Remove rotation via viewbox.
Still some work to do...
(bzr r15603)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/dialog/export.cpp | 9 | ||||
| -rw-r--r-- | src/ui/tools/tool-base.cpp | 879 | ||||
| -rw-r--r-- | src/ui/view/edit-widget-interface.h | 3 |
3 files changed, 409 insertions, 482 deletions
diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index b7207fd50..1bb952de4 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -978,9 +978,7 @@ void Export::onExport () SPNamedView *nv = desktop->getNamedView(); SPDocument *doc = desktop->getDocument(); - Geom::Affine rot = doc->getRoot()->c2p; - doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; - doc->ensureUpToDate(); + bool exportSuccessful = false; bool hide = hide_export.get_active (); @@ -1005,7 +1003,6 @@ void Export::onExport () if (num < 1) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No items selected.")); - doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } @@ -1097,7 +1094,6 @@ void Export::onExport () if (filename.empty()) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("You have to enter a filename.")); sp_ui_error_dialog(_("You have to enter a filename")); - doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } @@ -1114,7 +1110,6 @@ void Export::onExport () if (!((x1 > x0) && (y1 > y0) && (width > 0) && (height > 0))) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The chosen area to be exported is invalid.")); sp_ui_error_dialog(_("The chosen area to be exported is invalid")); - doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } @@ -1137,7 +1132,6 @@ void Export::onExport () g_free(safeDir); g_free(error); - doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } @@ -1287,7 +1281,6 @@ void Export::onExport () } } } - doc->getRoot()->c2p *= doc->getRoot()->rotation; } // end of sp_export_export_clicked() /// Called when Browse button is clicked diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 8c7f54d14..83291fcfd 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -94,7 +94,6 @@ ToolBase::ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y, boo , _grdrag(NULL) , shape_editor(NULL) , space_panning(false) - , rotating_mode(false) , _delayed_snap_event(NULL) , _dse_callback_in_process(false) , desktop(NULL) @@ -328,130 +327,99 @@ bool ToolBase::root_handler(GdkEvent* event) { static unsigned int panning = 0; static unsigned int panning_cursor = 0; static unsigned int zoom_rb = 0; - static double angle = 0; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); /// @todo REmove redundant /value in preference keys tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); bool allow_panning = prefs->getBool("/options/spacebarpans/value"); - int rotation_snap = 180.0/prefs->getInt("/options/rotationsnapsperpi/value", 12); gint ret = FALSE; switch (event->type) { - case GDK_2BUTTON_PRESS: - if (panning) { - panning = 0; - sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); + case GDK_2BUTTON_PRESS: + if (panning) { + panning = 0; + sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); + ret = TRUE; + } else { + /* sp_desktop_dialog(); */ + } + break; + + case GDK_BUTTON_PRESS: + // save drag origin + xp = (gint) event->button.x; + yp = (gint) event->button.y; + within_tolerance = true; + + button_w = Geom::Point(event->button.x, event->button.y); + + switch (event->button.button) { + case 1: + if (this->space_panning) { + // When starting panning, make sure there are no snap events pending because these might disable the panning again + if (_uses_snap) { + sp_event_context_discard_delayed_snap_event(this); + } + panning = 1; + + sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), + GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK + | GDK_POINTER_MOTION_MASK + | GDK_POINTER_MOTION_HINT_MASK, NULL, + event->button.time - 1); + ret = TRUE; - } else { - /* sp_desktop_dialog(); */ } break; - case GDK_BUTTON_PRESS: - // save drag origin - xp = (gint) event->button.x; - yp = (gint) event->button.y; - within_tolerance = true; + case 2: + if (event->button.state & GDK_SHIFT_MASK) { + zoom_rb = 2; + } else { + // When starting panning, make sure there are no snap events pending because these might disable the panning again + if (_uses_snap) { + sp_event_context_discard_delayed_snap_event(this); + } + panning = 2; - button_w = Geom::Point(event->button.x, event->button.y); - switch (event->button.button) { - case 1: - if (this->space_panning) { - // When starting panning, make sure there are no snap events pending because these might disable the panning again - if (_uses_snap) { - sp_event_context_discard_delayed_snap_event(this); - } - panning = 1; + sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), + GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK + | GDK_POINTER_MOTION_HINT_MASK, NULL, + event->button.time - 1); - sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), - GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK - | GDK_POINTER_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK, NULL, - event->button.time - 1); + } - ret = TRUE; - } - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; - break; + ret = TRUE; + break; - case 2: - if (event->button.state & GDK_CONTROL_MASK) { - sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); - desktop->canvas->startRotateTo(desktop->namedview->document_rotation); - this->rotating_mode = true; - this->message_context->set(Inkscape::INFORMATION_MESSAGE, - _("<b>MMB + mouse move</b> to rotate canvas, use modifiers on screen to change snaps")); - } else { - if (event->button.state & GDK_SHIFT_MASK) { - zoom_rb = 2; - } else { - // When starting panning, make sure there are no snap events pending because these might disable the panning again - if (_uses_snap) { - sp_event_context_discard_delayed_snap_event(this); - } - panning = 2; - - sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), - GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK, NULL, - event->button.time - 1); - } - ret = TRUE; + case 3: + if ((event->button.state & GDK_SHIFT_MASK) || (event->button.state & GDK_CONTROL_MASK)) { + // When starting panning, make sure there are no snap events pending because these might disable the panning again + if (_uses_snap) { + sp_event_context_discard_delayed_snap_event(this); } - ret = TRUE; - break; - - case 3: - if ((event->button.state & GDK_SHIFT_MASK) || (event->button.state & GDK_CONTROL_MASK)) { - // When starting panning, make sure there are no snap events pending because these might disable the panning again - if (_uses_snap) { - sp_event_context_discard_delayed_snap_event(this); - } - panning = 3; + panning = 3; - sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), - GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK, NULL, - event->button.time); + sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), + GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK + | GDK_POINTER_MOTION_HINT_MASK, NULL, + event->button.time); - ret = TRUE; - } else if( !this->space_panning) { - sp_event_root_menu_popup(desktop, NULL, event); - } ret = TRUE; - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; - break; - - default: - break; + } else { + sp_event_root_menu_popup(desktop, NULL, event); } break; - case GDK_MOTION_NOTIFY: - if (this->rotating_mode) { - button_w = Geom::Point(event->motion.x, event->motion.y); - Geom::Point const motion_dt(desktop->doc2dt(desktop->w2d(button_w))); - Geom::Rect view = desktop->get_display_area(); - Geom::Point view_center = desktop->doc2dt(view.midpoint()); - Geom::Ray center_ray(motion_dt, view_center); - angle = Geom::deg_from_rad(center_ray.angle()) - 90; - if (event->motion.state & GDK_SHIFT_MASK && event->motion.state & GDK_CONTROL_MASK) { - angle = 0; - } else if(event->motion.state & GDK_CONTROL_MASK) { - angle = floor(angle/rotation_snap) * rotation_snap; - } else if (event->motion.state & GDK_SHIFT_MASK) { - angle = desktop->namedview->document_rotation; - } else if (event->motion.state & GDK_MOD1_MASK) { - //Decimal raw angle - } else { - angle = floor(angle); - } - desktop->canvas->rotateTo(angle); - } else if (panning == 4 && !xp && !yp ) { + default: + break; + } + break; + + case GDK_MOTION_NOTIFY: + if (panning) { + if (panning == 4 && !xp && !yp ) { // <Space> + mouse panning started, save location and grab canvas xp = event->motion.x; yp = event->motion.y; @@ -463,465 +431,428 @@ bool ToolBase::root_handler(GdkEvent* event) { | GDK_POINTER_MOTION_HINT_MASK, NULL, event->motion.time - 1); } - if (panning && !this->rotating_mode) { - if ((panning == 2 && !(event->motion.state & GDK_BUTTON2_MASK)) - || (panning == 1 && !(event->motion.state & GDK_BUTTON1_MASK)) - || (panning == 3 && !(event->motion.state & GDK_BUTTON3_MASK))) { - /* Gdk seems to lose button release for us sometimes :-( */ - panning = 0; - sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); - ret = TRUE; - } else { - if (within_tolerance && (abs((gint) event->motion.x - xp) - < tolerance) && (abs((gint) event->motion.y - yp) - < tolerance)) { - // do not drag if we're within tolerance from origin - break; - } - - // Once the user has moved farther than tolerance from - // the original location (indicating they intend to move - // the object, not click), then always process the motion - // notify coordinates as given (no snapping back to origin) - within_tolerance = false; - - // gobble subsequent motion events to prevent "sticking" - // when scrolling is slow - gobble_motion_events(panning == 2 ? GDK_BUTTON2_MASK : (panning - == 1 ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK)); - - if (panning_cursor == 0) { - panning_cursor = 1; - this->sp_event_context_set_cursor(GDK_FLEUR); - } - - Geom::Point const motion_w(event->motion.x, event->motion.y); - Geom::Point const moved_w(motion_w - button_w); - this->desktop->scroll_relative(moved_w, true); // we're still scrolling, do not redraw - ret = TRUE; - } - } else if (zoom_rb) { - Geom::Point const motion_w(event->motion.x, event->motion.y); - Geom::Point const motion_dt(desktop->w2d(motion_w)); + if ((panning == 2 && !(event->motion.state & GDK_BUTTON2_MASK)) + || (panning == 1 && !(event->motion.state & GDK_BUTTON1_MASK)) + || (panning == 3 && !(event->motion.state & GDK_BUTTON3_MASK))) { + /* Gdk seems to lose button release for us sometimes :-( */ + panning = 0; + sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); + ret = TRUE; + } else { if (within_tolerance && (abs((gint) event->motion.x - xp) < tolerance) && (abs((gint) event->motion.y - yp) < tolerance)) { - break; // do not drag if we're within tolerance from origin + // do not drag if we're within tolerance from origin + break; } - // Once the user has moved farther than tolerance from the original location - // (indicating they intend to move the object, not click), then always process the - // motion notify coordinates as given (no snapping back to origin) + // Once the user has moved farther than tolerance from + // the original location (indicating they intend to move + // the object, not click), then always process the motion + // notify coordinates as given (no snapping back to origin) within_tolerance = false; - if (Inkscape::Rubberband::get(desktop)->is_started()) { - Inkscape::Rubberband::get(desktop)->move(motion_dt); - } else { - Inkscape::Rubberband::get(desktop)->start(desktop, motion_dt); - } + // gobble subsequent motion events to prevent "sticking" + // when scrolling is slow + gobble_motion_events(panning == 2 ? GDK_BUTTON2_MASK : (panning + == 1 ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK)); - if (zoom_rb == 2) { - gobble_motion_events(GDK_BUTTON2_MASK); + if (panning_cursor == 0) { + panning_cursor = 1; + this->sp_event_context_set_cursor(GDK_FLEUR); } - } - break; - case GDK_BUTTON_RELEASE: - if (this->rotating_mode && event->button.button == 2) { - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; + Geom::Point const motion_w(event->motion.x, event->motion.y); + Geom::Point const moved_w(motion_w - button_w); + this->desktop->scroll_relative(moved_w, true); // we're still scrolling, do not redraw ret = TRUE; - if (desktop->canvas->endRotateTo()) { - sp_repr_set_svg_double(desktop->namedview->getRepr(), "inkscape:document-rotation", angle); - } + } + } else if (zoom_rb) { + Geom::Point const motion_w(event->motion.x, event->motion.y); + Geom::Point const motion_dt(desktop->w2d(motion_w)); + + if (within_tolerance && (abs((gint) event->motion.x - xp) + < tolerance) && (abs((gint) event->motion.y - yp) + < tolerance)) { + break; // do not drag if we're within tolerance from origin + } + + // Once the user has moved farther than tolerance from the original location + // (indicating they intend to move the object, not click), then always process the + // motion notify coordinates as given (no snapping back to origin) + within_tolerance = false; + + if (Inkscape::Rubberband::get(desktop)->is_started()) { + Inkscape::Rubberband::get(desktop)->move(motion_dt); } else { - xp = yp = 0; - if (panning_cursor == 1) { - panning_cursor = 0; - GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); - gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); - } + Inkscape::Rubberband::get(desktop)->start(desktop, motion_dt); + } - if (within_tolerance && (panning || zoom_rb)) { - zoom_rb = 0; + if (zoom_rb == 2) { + gobble_motion_events(GDK_BUTTON2_MASK); + } + } + break; - if (panning) { - panning = 0; - sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), - event->button.time); - } + case GDK_BUTTON_RELEASE: + xp = yp = 0; - Geom::Point const event_w(event->button.x, event->button.y); - Geom::Point const event_dt(desktop->w2d(event_w)); + if (panning_cursor == 1) { + panning_cursor = 0; + GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); + gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); + } - double const zoom_inc = prefs->getDoubleLimited( - "/options/zoomincrement/value", M_SQRT2, 1.01, 10); + if (within_tolerance && (panning || zoom_rb)) { + zoom_rb = 0; - desktop->zoom_relative_keep_point(event_dt, (event->button.state - & GDK_SHIFT_MASK) ? 1 / zoom_inc : zoom_inc); + if (panning) { + panning = 0; + sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), + event->button.time); + } - desktop->updateNow(); - ret = TRUE; - } else if (panning == event->button.button) { - panning = 0; - sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), - event->button.time); + Geom::Point const event_w(event->button.x, event->button.y); + Geom::Point const event_dt(desktop->w2d(event_w)); - // in slow complex drawings, some of the motion events are lost; - // to make up for this, we scroll it once again to the button-up event coordinates - // (i.e. canvas will always get scrolled all the way to the mouse release point, - // even if few intermediate steps were visible) - Geom::Point const motion_w(event->button.x, event->button.y); - Geom::Point const moved_w(motion_w - button_w); + double const zoom_inc = prefs->getDoubleLimited( + "/options/zoomincrement/value", M_SQRT2, 1.01, 10); - this->desktop->scroll_relative(moved_w); - desktop->updateNow(); - ret = TRUE; - } else if (zoom_rb == event->button.button) { - zoom_rb = 0; + desktop->zoom_relative_keep_point(event_dt, (event->button.state + & GDK_SHIFT_MASK) ? 1 / zoom_inc : zoom_inc); - Geom::OptRect const b = Inkscape::Rubberband::get(desktop)->getRectangle(); - Inkscape::Rubberband::get(desktop)->stop(); + desktop->updateNow(); + ret = TRUE; + } else if (panning == event->button.button) { + panning = 0; + sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), + event->button.time); + + // in slow complex drawings, some of the motion events are lost; + // to make up for this, we scroll it once again to the button-up event coordinates + // (i.e. canvas will always get scrolled all the way to the mouse release point, + // even if few intermediate steps were visible) + Geom::Point const motion_w(event->button.x, event->button.y); + Geom::Point const moved_w(motion_w - button_w); + + this->desktop->scroll_relative(moved_w); + desktop->updateNow(); + ret = TRUE; + } else if (zoom_rb == event->button.button) { + zoom_rb = 0; - if (b && !within_tolerance) { - desktop->set_display_area(*b, 10); - } + Geom::OptRect const b = Inkscape::Rubberband::get(desktop)->getRectangle(); + Inkscape::Rubberband::get(desktop)->stop(); - ret = TRUE; - } - if (this->rotating_mode && event->button.button != 3) { - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; - ret = TRUE; - desktop->canvas->endRotateTo(); - } + if (b && !within_tolerance) { + desktop->set_display_area(*b, 10); } - break; - case GDK_KEY_PRESS: { - double const acceleration = prefs->getDoubleLimited( - "/options/scrollingacceleration/value", 0, 0, 6); - int const key_scroll = prefs->getIntLimited("/options/keyscroll/value", - 10, 0, 1000); - - if (this->rotating_mode && - get_group0_keyval(&event->key) != GDK_KEY_space && - get_group0_keyval(&event->key) != GDK_KEY_Shift_L && - get_group0_keyval(&event->key) != GDK_KEY_Shift_R && - get_group0_keyval(&event->key) != GDK_KEY_Control_L && - get_group0_keyval(&event->key) != GDK_KEY_Control_R && - get_group0_keyval(&event->key) != GDK_KEY_Alt_L && - get_group0_keyval(&event->key) != GDK_KEY_Alt_R ) - { - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; - ret = TRUE; - desktop->canvas->endRotateTo(); - break; + ret = TRUE; + } + break; + + case GDK_KEY_PRESS: { + double const acceleration = prefs->getDoubleLimited( + "/options/scrollingacceleration/value", 0, 0, 6); + int const key_scroll = prefs->getIntLimited("/options/keyscroll/value", + 10, 0, 1000); + + switch (get_group0_keyval(&event->key)) { + // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets + // in the editing window). So we resteal them back and run our regular shortcut + // invoker on them. + unsigned int shortcut; + case GDK_KEY_Tab: + case GDK_KEY_ISO_Left_Tab: + case GDK_KEY_F1: + shortcut = get_group0_keyval(&event->key); + + if (event->key.state & GDK_SHIFT_MASK) { + shortcut |= SP_SHORTCUT_SHIFT_MASK; } - switch (get_group0_keyval(&event->key)) { - // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets - // in the editing window). So we resteal them back and run our regular shortcut - // invoker on them. - unsigned int shortcut; - case GDK_KEY_Tab: - case GDK_KEY_ISO_Left_Tab: - case GDK_KEY_F1: - shortcut = get_group0_keyval(&event->key); - - if (event->key.state & GDK_SHIFT_MASK) { - shortcut |= SP_SHORTCUT_SHIFT_MASK; - } + if (event->key.state & GDK_CONTROL_MASK) { + shortcut |= SP_SHORTCUT_CONTROL_MASK; + } - if (event->key.state & GDK_CONTROL_MASK) { - shortcut |= SP_SHORTCUT_CONTROL_MASK; - } + if (event->key.state & GDK_MOD1_MASK) { + shortcut |= SP_SHORTCUT_ALT_MASK; + } - if (event->key.state & GDK_MOD1_MASK) { - shortcut |= SP_SHORTCUT_ALT_MASK; - } + ret = sp_shortcut_invoke(shortcut, desktop); + break; - ret = sp_shortcut_invoke(shortcut, desktop); - break; + case GDK_KEY_Q: + case GDK_KEY_q: + if (desktop->quick_zoomed()) { + ret = TRUE; + } + if (!MOD__SHIFT(event) && !MOD__CTRL(event) && !MOD__ALT(event)) { + desktop->zoom_quick(true); + ret = TRUE; + } + break; - case GDK_KEY_Q: - case GDK_KEY_q: - if (desktop->quick_zoomed()) { - ret = TRUE; - } - if (!MOD__SHIFT(event) && !MOD__CTRL(event) && !MOD__ALT(event)) { - desktop->zoom_quick(true); - ret = TRUE; - } - break; + case GDK_KEY_W: + case GDK_KEY_w: + case GDK_KEY_F4: + /* Close view */ + if (MOD__CTRL_ONLY(event)) { + sp_ui_close_view(NULL); + ret = TRUE; + } + break; - case GDK_KEY_W: - case GDK_KEY_w: - case GDK_KEY_F4: - /* Close view */ - if (MOD__CTRL_ONLY(event)) { - sp_ui_close_view(NULL); - ret = TRUE; - } - break; + case GDK_KEY_Left: // Ctrl Left + case GDK_KEY_KP_Left: + case GDK_KEY_KP_4: + if (MOD__CTRL_ONLY(event)) { + int i = (int) floor(key_scroll * accelerate_scroll(event, + acceleration, desktop->getCanvas())); - case GDK_KEY_Left: // Ctrl Left - case GDK_KEY_KP_Left: - case GDK_KEY_KP_4: - if (MOD__CTRL_ONLY(event)) { - int i = (int) floor(key_scroll * accelerate_scroll(event, - acceleration, desktop->getCanvas())); + gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + this->desktop->scroll_relative(Geom::Point(i, 0)); + ret = TRUE; + } + break; - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); - this->desktop->scroll_relative(Geom::Point(i, 0)); - ret = TRUE; - } - break; + case GDK_KEY_Up: // Ctrl Up + case GDK_KEY_KP_Up: + case GDK_KEY_KP_8: + if (MOD__CTRL_ONLY(event)) { + int i = (int) floor(key_scroll * accelerate_scroll(event, + acceleration, desktop->getCanvas())); - case GDK_KEY_Up: // Ctrl Up - case GDK_KEY_KP_Up: - case GDK_KEY_KP_8: - if (MOD__CTRL_ONLY(event)) { - int i = (int) floor(key_scroll * accelerate_scroll(event, - acceleration, desktop->getCanvas())); + gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + this->desktop->scroll_relative(Geom::Point(0, i)); + ret = TRUE; + } + break; - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); - this->desktop->scroll_relative(Geom::Point(0, i)); - ret = TRUE; - } - break; + case GDK_KEY_Right: // Ctrl Right + case GDK_KEY_KP_Right: + case GDK_KEY_KP_6: + if (MOD__CTRL_ONLY(event)) { + int i = (int) floor(key_scroll * accelerate_scroll(event, + acceleration, desktop->getCanvas())); - case GDK_KEY_Right: // Ctrl Right - case GDK_KEY_KP_Right: - case GDK_KEY_KP_6: - if (MOD__CTRL_ONLY(event)) { - int i = (int) floor(key_scroll * accelerate_scroll(event, - acceleration, desktop->getCanvas())); + gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + this->desktop->scroll_relative(Geom::Point(-i, 0)); + ret = TRUE; + } + break; - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); - this->desktop->scroll_relative(Geom::Point(-i, 0)); - ret = TRUE; - } - break; + case GDK_KEY_Down: // Ctrl Down + case GDK_KEY_KP_Down: + case GDK_KEY_KP_2: + if (MOD__CTRL_ONLY(event)) { + int i = (int) floor(key_scroll * accelerate_scroll(event, + acceleration, desktop->getCanvas())); - case GDK_KEY_Down: // Ctrl Down - case GDK_KEY_KP_Down: - case GDK_KEY_KP_2: - if (MOD__CTRL_ONLY(event)) { - int i = (int) floor(key_scroll * accelerate_scroll(event, - acceleration, desktop->getCanvas())); + gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + this->desktop->scroll_relative(Geom::Point(0, -i)); + ret = TRUE; + } + break; - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); - this->desktop->scroll_relative(Geom::Point(0, -i)); - ret = TRUE; - } - break; + case GDK_KEY_Menu: + sp_event_root_menu_popup(desktop, NULL, event); + ret = TRUE; + break; - case GDK_KEY_Menu: + case GDK_KEY_F10: + if (MOD__SHIFT_ONLY(event)) { sp_event_root_menu_popup(desktop, NULL, event); ret = TRUE; - break; + } + break; - case GDK_KEY_F10: - if (MOD__SHIFT_ONLY(event)) { - sp_event_root_menu_popup(desktop, NULL, event); - ret = TRUE; - } - break; + case GDK_KEY_space: + within_tolerance = true; + xp = yp = 0; + if (!allow_panning) break; + panning = 4; + this->space_panning = true; + this->message_context->set(Inkscape::INFORMATION_MESSAGE, + _("<b>Space+mouse move</b> to pan canvas")); + + ret = TRUE; + break; - case GDK_KEY_space: -// if (event->key.state & GDK_CONTROL_MASK) { -// sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); -// desktop->canvas->startRotateTo(desktop->namedview->document_rotation); -// this->rotating_mode = true; -// this->message_context->set(Inkscape::INFORMATION_MESSAGE, -// _("<b>Space+mouse move</b> to rotate canvas, use modifiers on screen to change snaps")); -// } else { - within_tolerance = true; - xp = yp = 0; - if (!allow_panning) break; - panning = 4; - this->space_panning = true; - this->message_context->set(Inkscape::INFORMATION_MESSAGE, - _("<b>Space+mouse move</b> to pan canvas")); -// } + case GDK_KEY_z: + case GDK_KEY_Z: + if (MOD__ALT_ONLY(event)) { + desktop->zoom_grab_focus(); ret = TRUE; - break; + } + break; - case GDK_KEY_z: - case GDK_KEY_Z: - if (MOD__ALT_ONLY(event)) { - desktop->zoom_grab_focus(); - ret = TRUE; - } - break; + default: + break; + } + } + break; - default: - break; - } + case GDK_KEY_RELEASE: + // Stop panning on any key release + if (this->space_panning) { + this->space_panning = false; + this->message_context->clear(); + } + + if (panning) { + panning = 0; + xp = yp = 0; + + sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), + event->key.time); + + desktop->updateNow(); + } + + if (panning_cursor == 1) { + panning_cursor = 0; + GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); + gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); + } + + switch (get_group0_keyval(&event->key)) { + case GDK_KEY_space: + if (within_tolerance) { + // Space was pressed, but not panned + sp_toggle_selector(desktop); + + // Be careful, sp_toggle_selector will delete ourselves. + // Thus, make sure we return immediately. + return true; } + break; - case GDK_KEY_RELEASE: - if (this->rotating_mode && - get_group0_keyval(&event->key) != GDK_KEY_space && - get_group0_keyval(&event->key) != GDK_KEY_Shift_L && - get_group0_keyval(&event->key) != GDK_KEY_Shift_R && - get_group0_keyval(&event->key) != GDK_KEY_Control_L && - get_group0_keyval(&event->key) != GDK_KEY_Control_R && - get_group0_keyval(&event->key) != GDK_KEY_Alt_L && - get_group0_keyval(&event->key) != GDK_KEY_Alt_R ) - { - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; + case GDK_KEY_Q: + case GDK_KEY_q: + if (desktop->quick_zoomed()) { + desktop->zoom_quick(false); ret = TRUE; - desktop->canvas->endRotateTo(); - break; } + break; - // Stop panning on any key release - if (this->space_panning) { - this->space_panning = false; - this->message_context->clear(); - } + default: + break; + } + break; - if (panning) { - panning = 0; - xp = yp = 0; + case GDK_SCROLL: { + bool ctrl = (event->scroll.state & GDK_CONTROL_MASK); + bool shift = (event->scroll.state & GDK_SHIFT_MASK); + bool wheelzooms = prefs->getBool("/options/wheelzooms/value"); - sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), - event->key.time); + int const wheel_scroll = prefs->getIntLimited( + "/options/wheelscroll/value", 40, 0, 1000); - desktop->updateNow(); - } + // Size of smooth-scrolls (only used in GTK+ 3) + gdouble delta_x = 0; + gdouble delta_y = 0; - if (panning_cursor == 1) { - panning_cursor = 0; - GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); - gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); - } + if (ctrl & shift) { + /* ctrl + shift, rotate */ - switch (get_group0_keyval(&event->key)) { - case GDK_KEY_space: -// if (this->rotating_mode) { -// desktop->canvas->clearRotateTo(); -// this->rotating_mode = false; -// ret = TRUE; -// if (desktop->canvas->endRotateTo()) { -// sp_repr_set_svg_double(desktop->namedview->getRepr(), "inkscape:document-rotation", angle); -// } -// } - if (within_tolerance) { - // Space was pressed, but not panned - sp_toggle_selector(desktop); - - // Be careful, sp_toggle_selector will delete ourselves. - // Thus, make sure we return immediately. - return true; - } + double rel_rotate; + double rotate_inc = 2.0 * M_PI/180.0; + + switch (event->scroll.direction) { + case GDK_SCROLL_UP: + rel_rotate = rotate_inc; break; - case GDK_KEY_Q: - case GDK_KEY_q: - if (desktop->quick_zoomed()) { - desktop->zoom_quick(false); - ret = TRUE; - } + case GDK_SCROLL_DOWN: + rel_rotate = -rotate_inc; break; default: + rel_rotate = 0.0; break; } - break; - case GDK_SCROLL: { - if (this->rotating_mode) { - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; - desktop->canvas->endRotateTo(); + if (rel_rotate != 0.0) { + Geom::Point const scroll_dt = desktop->point(); + desktop->rotate_relative_keep_point(scroll_dt, rel_rotate); } - bool ctrl = (event->scroll.state & GDK_CONTROL_MASK); - bool wheelzooms = prefs->getBool("/options/wheelzooms/value"); - - int const wheel_scroll = prefs->getIntLimited( - "/options/wheelscroll/value", 40, 0, 1000); - // Size of smooth-scrolls (only used in GTK+ 3) - gdouble delta_x = 0; - gdouble delta_y = 0; + } else if (event->scroll.state & GDK_SHIFT_MASK) { + /* shift + wheel, pan left--right */ - /* shift + wheel, pan left--right */ - if (event->scroll.state & GDK_SHIFT_MASK) { - switch (event->scroll.direction) { - case GDK_SCROLL_UP: - desktop->scroll_relative(Geom::Point(wheel_scroll, 0)); - break; + switch (event->scroll.direction) { + case GDK_SCROLL_UP: + desktop->scroll_relative(Geom::Point(wheel_scroll, 0)); + break; - case GDK_SCROLL_DOWN: - desktop->scroll_relative(Geom::Point(-wheel_scroll, 0)); - break; + case GDK_SCROLL_DOWN: + desktop->scroll_relative(Geom::Point(-wheel_scroll, 0)); + break; - default: - break; - } + default: + break; + } - /* ctrl + wheel, zoom in--out */ - } else if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) { - double rel_zoom; - double const zoom_inc = prefs->getDoubleLimited( - "/options/zoomincrement/value", M_SQRT2, 1.01, 10); + } else if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) { + /* ctrl + wheel, zoom in--out */ + double rel_zoom; + double const zoom_inc = prefs->getDoubleLimited( + "/options/zoomincrement/value", M_SQRT2, 1.01, 10); - switch (event->scroll.direction) { - case GDK_SCROLL_UP: - rel_zoom = zoom_inc; - break; + switch (event->scroll.direction) { + case GDK_SCROLL_UP: + rel_zoom = zoom_inc; + break; - case GDK_SCROLL_DOWN: - rel_zoom = 1 / zoom_inc; - break; + case GDK_SCROLL_DOWN: + rel_zoom = 1 / zoom_inc; + break; - default: - rel_zoom = 0.0; - break; - } + default: + rel_zoom = 0.0; + break; + } - if (rel_zoom != 0.0) { - Geom::Point const scroll_dt = desktop->point(); - desktop->zoom_relative_keep_point(scroll_dt, rel_zoom); - } + if (rel_zoom != 0.0) { + Geom::Point const scroll_dt = desktop->point(); + desktop->zoom_relative_keep_point(scroll_dt, rel_zoom); + } - /* no modifier, pan up--down (left--right on multiwheel mice?) */ - } else { - switch (event->scroll.direction) { - case GDK_SCROLL_UP: - desktop->scroll_relative(Geom::Point(0, wheel_scroll)); - break; + /* no modifier, pan up--down (left--right on multiwheel mice?) */ + } else { + switch (event->scroll.direction) { + case GDK_SCROLL_UP: + desktop->scroll_relative(Geom::Point(0, wheel_scroll)); + break; - case GDK_SCROLL_DOWN: - desktop->scroll_relative(Geom::Point(0, -wheel_scroll)); - break; + case GDK_SCROLL_DOWN: + desktop->scroll_relative(Geom::Point(0, -wheel_scroll)); + break; - case GDK_SCROLL_LEFT: - desktop->scroll_relative(Geom::Point(wheel_scroll, 0)); - break; + case GDK_SCROLL_LEFT: + desktop->scroll_relative(Geom::Point(wheel_scroll, 0)); + break; - case GDK_SCROLL_RIGHT: - desktop->scroll_relative(Geom::Point(-wheel_scroll, 0)); - break; + case GDK_SCROLL_RIGHT: + desktop->scroll_relative(Geom::Point(-wheel_scroll, 0)); + break; - case GDK_SCROLL_SMOOTH: - gdk_event_get_scroll_deltas(event, &delta_x, &delta_y); - desktop->scroll_relative(Geom::Point(delta_x, delta_y)); - break; - } + case GDK_SCROLL_SMOOTH: + gdk_event_get_scroll_deltas(event, &delta_x, &delta_y); + desktop->scroll_relative(Geom::Point(delta_x, delta_y)); + break; } - break; } - default: - break; + break; } + default: + break; + } + return ret; } diff --git a/src/ui/view/edit-widget-interface.h b/src/ui/view/edit-widget-interface.h index fcba0c6da..c93b1f0ee 100644 --- a/src/ui/view/edit-widget-interface.h +++ b/src/ui/view/edit-widget-interface.h @@ -128,6 +128,9 @@ struct EditWidgetInterface /// The zoom display will get the keyboard focus. virtual void letZoomGrabFocus() = 0; + /// Temporarily block signals and update rotation display + virtual void updateRotation() = 0; + /// In auxiliary toolbox, set focus to widget having specific id virtual void setToolboxFocusTo (const gchar *) = 0; |
