From f47466c701b2256b2ce232f6d311d2be47136eab Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 20 Mar 2017 21:12:31 +0100 Subject: Implement rotation via desktop to window affine. Remove rotation via viewbox. Still some work to do... (bzr r15603) --- src/verbs.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/verbs.cpp') diff --git a/src/verbs.cpp b/src/verbs.cpp index 8b3d7a5a2..55e332fe2 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -41,6 +41,7 @@ #include "desktop.h" #include "display/curve.h" +#include "display/sp-canvas.h" #include "document.h" #include "ui/tools/freehand-base.h" #include "extension/effect.h" -- cgit v1.2.3 From 79c31e9b54e6a47502edb61d590cd50ab0536269 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 21 Mar 2017 10:14:44 +0100 Subject: Add verbs for canvas rotation. (bzr r15604) --- src/verbs.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 22 deletions(-) (limited to 'src/verbs.cpp') diff --git a/src/verbs.cpp b/src/verbs.cpp index 55e332fe2..d0f2f2614 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1882,8 +1882,10 @@ void ZoomVerb::perform(SPAction *action, void *data) Inkscape::XML::Node *repr = dt->namedview->getRepr(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gdouble zoom_inc = - prefs->getDoubleLimited( "/options/zoomincrement/value", M_SQRT2, 1.01, 10 ); + gdouble zoom_inc = + prefs->getDoubleLimited( "/options/zoomincrement/value", M_SQRT2, 1.01, 10 ); + gdouble rotate_inc = + prefs->getDoubleLimited( "/options/rotateincrement/value", M_PI/90, M_PI/180, M_PI/4, "°" ); double zcorr = 1.0; Glib::ustring abbr = prefs->getString("/options/zoomcorrection/unit"); @@ -1958,6 +1960,41 @@ void ZoomVerb::perform(SPAction *action, void *data) case SP_VERB_ZOOM_PREV: dt->prev_transform(); break; + case SP_VERB_ROTATE_CW: + { + gint mul = 1 + Inkscape::UI::Tools::gobble_key_events( GDK_KEY_parenleft, 0); + // While drawing with the pen/pencil tool, rotate towards the end of the unfinished path + if (tools_isactive(dt, TOOLS_FREEHAND_PENCIL) || tools_isactive(dt, TOOLS_FREEHAND_PEN)) { + SPCurve *rc = SP_DRAW_CONTEXT(ec)->red_curve; + if (!rc->is_empty()) { + Geom::Point const rotate_to (*rc->last_point()); + dt->rotate_relative_keep_point(rotate_to, -mul*rotate_inc); + break; + } + } + + dt->rotate_relative_center_point( midpoint, -mul*rotate_inc); + break; + } + case SP_VERB_ROTATE_CCW: + { + gint mul = 1 + Inkscape::UI::Tools::gobble_key_events( GDK_KEY_parenright, 0); + // While drawing with the pen/pencil tool, rotate towards the end of the unfinished path + if (tools_isactive(dt, TOOLS_FREEHAND_PENCIL) || tools_isactive(dt, TOOLS_FREEHAND_PEN)) { + SPCurve *rc = SP_DRAW_CONTEXT(ec)->red_curve; + if (!rc->is_empty()) { + Geom::Point const rotate_to (*rc->last_point()); + dt->rotate_relative_keep_point(rotate_to, mul*rotate_inc); + break; + } + } + + dt->rotate_relative_center_point( midpoint, mul*rotate_inc); + break; + } + case SP_VERB_ROTATE_ZERO: + dt->rotate_absolute_center_point( midpoint, 0.0 ); + break; case SP_VERB_TOGGLE_RULERS: dt->toggleRulers(); break; @@ -2896,10 +2933,37 @@ Verb *Verb::_base_verbs[] = { N_("Open Preferences for the Eraser tool"), NULL), new ContextVerb(SP_VERB_CONTEXT_LPETOOL_PREFS, "LPEToolPrefs", N_("LPE Tool Preferences"), N_("Open Preferences for the LPETool tool"), NULL), - // Zoom/View + + // Zoom new ZoomVerb(SP_VERB_ZOOM_IN, "ZoomIn", N_("Zoom In"), N_("Zoom in"), INKSCAPE_ICON("zoom-in")), new ZoomVerb(SP_VERB_ZOOM_OUT, "ZoomOut", N_("Zoom Out"), N_("Zoom out"), INKSCAPE_ICON("zoom-out")), - // WHY ARE THE FOLLOWING ZoomVerbs??? + new ZoomVerb(SP_VERB_ZOOM_NEXT, "ZoomNext", N_("Nex_t Zoom"), N_("Next zoom (from the history of zooms)"), + INKSCAPE_ICON("zoom-next")), + new ZoomVerb(SP_VERB_ZOOM_PREV, "ZoomPrev", N_("Pre_vious Zoom"), N_("Previous zoom (from the history of zooms)"), + INKSCAPE_ICON("zoom-previous")), + new ZoomVerb(SP_VERB_ZOOM_1_1, "Zoom1:0", N_("Zoom 1:_1"), N_("Zoom to 1:1"), + INKSCAPE_ICON("zoom-original")), + new ZoomVerb(SP_VERB_ZOOM_1_2, "Zoom1:2", N_("Zoom 1:_2"), N_("Zoom to 1:2"), + INKSCAPE_ICON("zoom-half-size")), + new ZoomVerb(SP_VERB_ZOOM_2_1, "Zoom2:1", N_("_Zoom 2:1"), N_("Zoom to 2:1"), + INKSCAPE_ICON("zoom-double-size")), + new ZoomVerb(SP_VERB_ZOOM_PAGE, "ZoomPage", N_("_Page"), + N_("Zoom to fit page in window"), INKSCAPE_ICON("zoom-fit-page")), + new ZoomVerb(SP_VERB_ZOOM_PAGE_WIDTH, "ZoomPageWidth", N_("Page _Width"), + N_("Zoom to fit page width in window"), INKSCAPE_ICON("zoom-fit-width")), + new ZoomVerb(SP_VERB_ZOOM_DRAWING, "ZoomDrawing", N_("_Drawing"), + N_("Zoom to fit drawing in window"), INKSCAPE_ICON("zoom-fit-drawing")), + new ZoomVerb(SP_VERB_ZOOM_SELECTION, "ZoomSelection", N_("_Selection"), + N_("Zoom to fit selection in window"), INKSCAPE_ICON("zoom-fit-selection")), + + new ZoomVerb(SP_VERB_ROTATE_CW, "RotateClockwise", N_("Rotate Clockwise"), N_("Rotate canvas clockwise"), NULL), + new ZoomVerb(SP_VERB_ROTATE_CCW, "RotateCounterClockwise", N_("Rotate Counter-Clockwise"), N_("Rotate canvas counter-clockwise"), NULL), + new ZoomVerb(SP_VERB_ROTATE_ZERO, "RotateZero", N_("Rotate Zero"), N_("Reset canvas rotation to zero"), NULL), + + +// WHY ARE THE FOLLOWING ZoomVerbs??? + + // View new ZoomVerb(SP_VERB_TOGGLE_RULERS, "ToggleRulers", N_("_Rulers"), N_("Show or hide the canvas rulers"), NULL), new ZoomVerb(SP_VERB_TOGGLE_SCROLLBARS, "ToggleScrollbars", N_("Scroll_bars"), N_("Show or hide the canvas scrollbars"), NULL), new ZoomVerb(SP_VERB_TOGGLE_GRID, "ToggleGrid", N_("Page _Grid"), N_("Show or hide the page grid"), INKSCAPE_ICON("show-grid")), @@ -2911,16 +2975,7 @@ Verb *Verb::_base_verbs[] = { new ZoomVerb(SP_VERB_TOGGLE_TOOLBOX, "ToggleToolbox", N_("_Toolbox"), N_("Show or hide the main toolbox (on the left)"), NULL), new ZoomVerb(SP_VERB_TOGGLE_PALETTE, "TogglePalette", N_("_Palette"), N_("Show or hide the color palette"), NULL), new ZoomVerb(SP_VERB_TOGGLE_STATUSBAR, "ToggleStatusbar", N_("_Statusbar"), N_("Show or hide the statusbar (at the bottom of the window)"), NULL), - new ZoomVerb(SP_VERB_ZOOM_NEXT, "ZoomNext", N_("Nex_t Zoom"), N_("Next zoom (from the history of zooms)"), - INKSCAPE_ICON("zoom-next")), - new ZoomVerb(SP_VERB_ZOOM_PREV, "ZoomPrev", N_("Pre_vious Zoom"), N_("Previous zoom (from the history of zooms)"), - INKSCAPE_ICON("zoom-previous")), - new ZoomVerb(SP_VERB_ZOOM_1_1, "Zoom1:0", N_("Zoom 1:_1"), N_("Zoom to 1:1"), - INKSCAPE_ICON("zoom-original")), - new ZoomVerb(SP_VERB_ZOOM_1_2, "Zoom1:2", N_("Zoom 1:_2"), N_("Zoom to 1:2"), - INKSCAPE_ICON("zoom-half-size")), - new ZoomVerb(SP_VERB_ZOOM_2_1, "Zoom2:1", N_("_Zoom 2:1"), N_("Zoom to 2:1"), - INKSCAPE_ICON("zoom-double-size")), + new ZoomVerb(SP_VERB_FULLSCREEN, "FullScreen", N_("_Fullscreen"), N_("Stretch this document window to full screen"), INKSCAPE_ICON("view-fullscreen")), new ZoomVerb(SP_VERB_FULLSCREENFOCUS, "FullScreenFocus", N_("Fullscreen & Focus Mode"), N_("Stretch this document window to full screen"), @@ -2954,14 +3009,6 @@ Verb *Verb::_base_verbs[] = { new ZoomVerb(SP_VERB_VIEW_ICON_PREVIEW, "ViewIconPreview", N_("Ico_n Preview..."), N_("Open a window to preview objects at different icon resolutions"), INKSCAPE_ICON("dialog-icon-preview")), - new ZoomVerb(SP_VERB_ZOOM_PAGE, "ZoomPage", N_("_Page"), - N_("Zoom to fit page in window"), INKSCAPE_ICON("zoom-fit-page")), - new ZoomVerb(SP_VERB_ZOOM_PAGE_WIDTH, "ZoomPageWidth", N_("Page _Width"), - N_("Zoom to fit page width in window"), INKSCAPE_ICON("zoom-fit-width")), - new ZoomVerb(SP_VERB_ZOOM_DRAWING, "ZoomDrawing", N_("_Drawing"), - N_("Zoom to fit drawing in window"), INKSCAPE_ICON("zoom-fit-drawing")), - new ZoomVerb(SP_VERB_ZOOM_SELECTION, "ZoomSelection", N_("_Selection"), - N_("Zoom to fit selection in window"), INKSCAPE_ICON("zoom-fit-selection")), // Dialogs new DialogVerb(SP_VERB_DIALOG_PROTOTYPE, "DialogPrototype", N_("Prototype..."), -- cgit v1.2.3 From a6c82507f599a302e85f1a2faae0c6a27d672d9e Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 21 Mar 2017 21:41:59 +0100 Subject: Add entry for canvas rotate step in Inkscape Preferences dialog. Change default rotation step to 15 degrees. (bzr r15605) --- src/verbs.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/verbs.cpp') diff --git a/src/verbs.cpp b/src/verbs.cpp index d0f2f2614..78967e89b 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1885,7 +1885,8 @@ void ZoomVerb::perform(SPAction *action, void *data) gdouble zoom_inc = prefs->getDoubleLimited( "/options/zoomincrement/value", M_SQRT2, 1.01, 10 ); gdouble rotate_inc = - prefs->getDoubleLimited( "/options/rotateincrement/value", M_PI/90, M_PI/180, M_PI/4, "°" ); + prefs->getDoubleLimited( "/options/rotateincrement/value", 15, 1, 90, "°" ); + rotate_inc *= M_PI/180.0; double zcorr = 1.0; Glib::ustring abbr = prefs->getString("/options/zoomcorrection/unit"); -- cgit v1.2.3 From a184a53752fb8027c22e4a5d68819fd7b78a15d8 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 22 Mar 2017 20:03:41 +0100 Subject: Add canvas flip. No GUI. Can be bound to keys via preferences. (bzr r15606) --- src/verbs.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/verbs.cpp') diff --git a/src/verbs.cpp b/src/verbs.cpp index 78967e89b..b7b6da340 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1996,6 +1996,40 @@ void ZoomVerb::perform(SPAction *action, void *data) case SP_VERB_ROTATE_ZERO: dt->rotate_absolute_center_point( midpoint, 0.0 ); break; + case SP_VERB_FLIP_HORIZONTAL: + { + // While drawing with the pen/pencil tool, flip towards the end of the unfinished path + if (tools_isactive(dt, TOOLS_FREEHAND_PENCIL) || tools_isactive(dt, TOOLS_FREEHAND_PEN)) { + SPCurve *rc = SP_DRAW_CONTEXT(ec)->red_curve; + if (!rc->is_empty()) { + Geom::Point const flip_to (*rc->last_point()); + dt->flip_relative_keep_point(flip_to, SPDesktop::FLIP_HORIZONTAL); + break; + } + } + + dt->flip_relative_center_point( midpoint, SPDesktop::FLIP_HORIZONTAL); + break; + } + case SP_VERB_FLIP_VERTICAL: + { + gint mul = 1 + Inkscape::UI::Tools::gobble_key_events( GDK_KEY_parenright, 0); + // While drawing with the pen/pencil tool, flip towards the end of the unfinished path + if (tools_isactive(dt, TOOLS_FREEHAND_PENCIL) || tools_isactive(dt, TOOLS_FREEHAND_PEN)) { + SPCurve *rc = SP_DRAW_CONTEXT(ec)->red_curve; + if (!rc->is_empty()) { + Geom::Point const flip_to (*rc->last_point()); + dt->flip_relative_keep_point(flip_to, SPDesktop::FLIP_VERTICAL); + break; + } + } + + dt->flip_relative_center_point( midpoint, SPDesktop::FLIP_VERTICAL); + break; + } + case SP_VERB_FLIP_NONE: + dt->flip_absolute_center_point( midpoint, SPDesktop::FLIP_NONE); + break; case SP_VERB_TOGGLE_RULERS: dt->toggleRulers(); break; @@ -2961,6 +2995,10 @@ Verb *Verb::_base_verbs[] = { new ZoomVerb(SP_VERB_ROTATE_CCW, "RotateCounterClockwise", N_("Rotate Counter-Clockwise"), N_("Rotate canvas counter-clockwise"), NULL), new ZoomVerb(SP_VERB_ROTATE_ZERO, "RotateZero", N_("Rotate Zero"), N_("Reset canvas rotation to zero"), NULL), + new ZoomVerb(SP_VERB_FLIP_HORIZONTAL, "FlipHorizontal", N_("Flip Horizontal"), N_("Flip canvas horizontally"), INKSCAPE_ICON("object-flip-horizontal")), + new ZoomVerb(SP_VERB_FLIP_VERTICAL, "FlipVertical", N_("Flip Vertical"), N_("Flip canvas vertically"), INKSCAPE_ICON("object-flip-vertical")), + new ZoomVerb(SP_VERB_FLIP_NONE, "FlipNone", N_("Flip None"), N_("Undo any flip"), NULL), + // WHY ARE THE FOLLOWING ZoomVerbs??? -- cgit v1.2.3