summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2017-03-21 09:14:44 +0000
committertavmjong-free <tavmjong@free.fr>2017-03-21 09:14:44 +0000
commit79c31e9b54e6a47502edb61d590cd50ab0536269 (patch)
tree5873fc0c4fb39e51f225dbc2393b5c124f94111c /src
parentImplement rotation via desktop to window affine. (diff)
downloadinkscape-79c31e9b54e6a47502edb61d590cd50ab0536269.tar.gz
inkscape-79c31e9b54e6a47502edb61d590cd50ab0536269.zip
Add verbs for canvas rotation.
(bzr r15604)
Diffstat (limited to 'src')
-rw-r--r--src/ui/tools/tool-base.cpp14
-rw-r--r--src/verbs.cpp91
-rw-r--r--src/verbs.h30
3 files changed, 96 insertions, 39 deletions
diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp
index 83291fcfd..389056762 100644
--- a/src/ui/tools/tool-base.cpp
+++ b/src/ui/tools/tool-base.cpp
@@ -759,26 +759,26 @@ bool ToolBase::root_handler(GdkEvent* event) {
if (ctrl & shift) {
/* ctrl + shift, rotate */
- double rel_rotate;
- double rotate_inc = 2.0 * M_PI/180.0;
+ double rotate_inc = prefs->getDoubleLimited(
+ "/options/rotateincrement/value", M_PI/90, M_PI/180, M_PI/4, "°" );
switch (event->scroll.direction) {
case GDK_SCROLL_UP:
- rel_rotate = rotate_inc;
+ // Do nothing
break;
case GDK_SCROLL_DOWN:
- rel_rotate = -rotate_inc;
+ rotate_inc = -rotate_inc;
break;
default:
- rel_rotate = 0.0;
+ rotate_inc = 0.0;
break;
}
- if (rel_rotate != 0.0) {
+ if (rotate_inc != 0.0) {
Geom::Point const scroll_dt = desktop->point();
- desktop->rotate_relative_keep_point(scroll_dt, rel_rotate);
+ desktop->rotate_relative_keep_point(scroll_dt, rotate_inc);
}
} else if (event->scroll.state & GDK_SHIFT_MASK) {
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..."),
diff --git a/src/verbs.h b/src/verbs.h
index b6b7b54dc..d57988583 100644
--- a/src/verbs.h
+++ b/src/verbs.h
@@ -252,9 +252,26 @@ enum {
SP_VERB_CONTEXT_ERASER_PREFS,
SP_VERB_CONTEXT_LPETOOL_PREFS,
- /* Zooming and desktop settings */
+
+ /* Zooming */
SP_VERB_ZOOM_IN,
SP_VERB_ZOOM_OUT,
+ SP_VERB_ZOOM_NEXT,
+ SP_VERB_ZOOM_PREV,
+ SP_VERB_ZOOM_1_1,
+ SP_VERB_ZOOM_1_2,
+ SP_VERB_ZOOM_2_1,
+ SP_VERB_ZOOM_PAGE,
+ SP_VERB_ZOOM_PAGE_WIDTH,
+ SP_VERB_ZOOM_DRAWING,
+ SP_VERB_ZOOM_SELECTION,
+
+ /* Canvas Rotation */
+ SP_VERB_ROTATE_CW,
+ SP_VERB_ROTATE_CCW,
+ SP_VERB_ROTATE_ZERO,
+
+ /* Desktop settings */
SP_VERB_TOGGLE_RULERS,
SP_VERB_TOGGLE_SCROLLBARS,
SP_VERB_TOGGLE_GRID,
@@ -266,11 +283,6 @@ enum {
SP_VERB_TOGGLE_TOOLBOX,
SP_VERB_TOGGLE_PALETTE,
SP_VERB_TOGGLE_STATUSBAR,
- SP_VERB_ZOOM_NEXT,
- SP_VERB_ZOOM_PREV,
- SP_VERB_ZOOM_1_1,
- SP_VERB_ZOOM_1_2,
- SP_VERB_ZOOM_2_1,
SP_VERB_FULLSCREEN,
SP_VERB_FULLSCREENFOCUS,
SP_VERB_FOCUSTOGGLE,
@@ -282,14 +294,12 @@ enum {
SP_VERB_VIEW_MODE_TOGGLE,
SP_VERB_VIEW_COLOR_MODE_NORMAL,
SP_VERB_VIEW_COLOR_MODE_GRAYSCALE,
+
// SP_VERB_VIEW_COLOR_MODE_PRINT_COLORS_PREVIEW,
SP_VERB_VIEW_COLOR_MODE_TOGGLE,
SP_VERB_VIEW_CMS_TOGGLE,
SP_VERB_VIEW_ICON_PREVIEW,
- SP_VERB_ZOOM_PAGE,
- SP_VERB_ZOOM_PAGE_WIDTH,
- SP_VERB_ZOOM_DRAWING,
- SP_VERB_ZOOM_SELECTION,
+
/* Dialogs */
SP_VERB_DIALOG_PROTOTYPE,
SP_VERB_DIALOG_DISPLAY,