Merge lp:~inkscape.dev/inkscape/doc_rotate into lp:~inkscape.dev/inkscape/trunk
- doc_rotate
- Merge into trunk
Proposed by
Jabiertxof
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 15444 | ||||
Proposed branch: | lp:~inkscape.dev/inkscape/doc_rotate | ||||
Merge into: | lp:~inkscape.dev/inkscape/trunk | ||||
Diff against target: |
2821 lines (+1359/-546) 31 files modified
share/extensions/hpgl_output.py (+15/-0) share/extensions/synfig_output.py (+9/-0) src/attributes.cpp (+1/-0) src/attributes.h (+1/-0) src/desktop-events.cpp (+4/-0) src/display/canvas-temporary-item-list.h (+1/-0) src/display/sp-canvas.cpp (+292/-3) src/display/sp-canvas.h (+4/-1) src/document-undo.cpp (+37/-34) src/document.cpp (+6/-0) src/extension/internal/cairo-png-out.cpp (+2/-2) src/extension/internal/cairo-ps-out.cpp (+5/-2) src/extension/internal/cairo-renderer-pdf-out.cpp (+3/-1) src/extension/internal/emf-inout.cpp (+3/-2) src/extension/internal/javafx-out.cpp (+7/-2) src/extension/internal/latex-pstricks-out.cpp (+2/-0) src/extension/internal/odf.cpp (+8/-1) src/extension/internal/pov-out.cpp (+10/-3) src/extension/internal/wmf-inout.cpp (+5/-2) src/file.cpp (+4/-2) src/print.cpp (+2/-0) src/sp-namedview.cpp (+97/-1) src/sp-namedview.h (+8/-3) src/ui/dialog/export.cpp (+8/-1) src/ui/tools/tool-base.cpp (+562/-466) src/ui/tools/tool-base.h (+1/-0) src/viewbox.cpp (+49/-13) src/viewbox.h (+7/-0) src/widgets/desktop-widget.cpp (+202/-6) src/widgets/desktop-widget.h (+3/-1) src/widgets/widget-sizes.h (+1/-0) |
||||
To merge this branch: | bzr merge lp:~inkscape.dev/inkscape/doc_rotate | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Owens | Approve | ||
Inkscape Developers | Pending | ||
Review via email: mp+310123@code.launchpad.net |
Commit message
Description of the change
Add rotate canvas feature to Inkscape.
It add the option to rotate in 2 ways:
1. from botton left widget
2. with control+middle button or spacebar
To post a comment you must log in.
- 15175. By Jabiertxof
-
Fix a bug that allow to enter rotate mode with right click
- 15176. By Jabiertxof
-
Update to trunk
- 15177. By Jabiertxof
-
Fix some bugs pointed by vlada
- 15178. By Jabiertxof
-
Update to trunk
- 15179. By Jabiertxof
-
Fix some bugs
- 15180. By Jabiertxof <jtx@jtx>
-
fixing to new trunk
- 15181. By Jabiertxof <jtx@jtx>
-
Update to trunk
- 15182. By Jabiertxof
-
Put namespace as constant
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'share/extensions/hpgl_output.py' | |||
2 | --- share/extensions/hpgl_output.py 2016-05-26 09:28:23 +0000 | |||
3 | +++ share/extensions/hpgl_output.py 2017-01-24 17:53:20 +0000 | |||
4 | @@ -20,6 +20,7 @@ | |||
5 | 20 | 20 | ||
6 | 21 | # standard library | 21 | # standard library |
7 | 22 | import sys | 22 | import sys |
8 | 23 | from inkex import NSS | ||
9 | 23 | # local libraries | 24 | # local libraries |
10 | 24 | import hpgl_encoder | 25 | import hpgl_encoder |
11 | 25 | import inkex | 26 | import inkex |
12 | @@ -44,10 +45,18 @@ | |||
13 | 44 | self.OptionParser.add_option('--precut', action='store', type='inkbool', dest='precut', default='TRUE', help='Use precut') | 45 | self.OptionParser.add_option('--precut', action='store', type='inkbool', dest='precut', default='TRUE', help='Use precut') |
14 | 45 | self.OptionParser.add_option('--flat', action='store', type='float', dest='flat', default=1.2, help='Curve flatness') | 46 | self.OptionParser.add_option('--flat', action='store', type='float', dest='flat', default=1.2, help='Curve flatness') |
15 | 46 | self.OptionParser.add_option('--autoAlign', action='store', type='inkbool', dest='autoAlign', default='TRUE', help='Auto align') | 47 | self.OptionParser.add_option('--autoAlign', action='store', type='inkbool', dest='autoAlign', default='TRUE', help='Auto align') |
16 | 48 | self.DOCROTATE = "{http://www.inkscape.org/namespaces/inkscape}document_rotation" | ||
17 | 47 | 49 | ||
18 | 48 | def effect(self): | 50 | def effect(self): |
19 | 49 | self.options.debug = False | 51 | self.options.debug = False |
20 | 50 | # get hpgl data | 52 | # get hpgl data |
21 | 53 | svg = self.document.getroot() | ||
22 | 54 | xpathStr = '//sodipodi:namedview' | ||
23 | 55 | nv = svg.xpath(xpathStr, namespaces=NSS) | ||
24 | 56 | document_rotate = "0" | ||
25 | 57 | if nv != []: | ||
26 | 58 | document_rotate = nv[0].get(self.DOCROTATE) | ||
27 | 59 | nv[0].set(self.DOCROTATE,"0") | ||
28 | 51 | myHpglEncoder = hpgl_encoder.hpglEncoder(self) | 60 | myHpglEncoder = hpgl_encoder.hpglEncoder(self) |
29 | 52 | try: | 61 | try: |
30 | 53 | self.hpgl, debugObject = myHpglEncoder.getHpgl() | 62 | self.hpgl, debugObject = myHpglEncoder.getHpgl() |
31 | @@ -56,9 +65,13 @@ | |||
32 | 56 | # issue error if no paths found | 65 | # issue error if no paths found |
33 | 57 | inkex.errormsg(_("No paths where found. Please convert all objects you want to save into paths.")) | 66 | inkex.errormsg(_("No paths where found. Please convert all objects you want to save into paths.")) |
34 | 58 | self.hpgl = '' | 67 | self.hpgl = '' |
35 | 68 | if nv != [] and document_rotate: | ||
36 | 69 | nv[0].set("inkscape:document_rotation",document_rotate) | ||
37 | 59 | return | 70 | return |
38 | 60 | else: | 71 | else: |
39 | 61 | type, value, traceback = sys.exc_info() | 72 | type, value, traceback = sys.exc_info() |
40 | 73 | if nv != [] and document_rotate: | ||
41 | 74 | nv[0].set("inkscape:document_rotation",document_rotate) | ||
42 | 62 | raise ValueError, ("", type, value), traceback | 75 | raise ValueError, ("", type, value), traceback |
43 | 63 | # convert raw HPGL to HPGL | 76 | # convert raw HPGL to HPGL |
44 | 64 | hpglInit = 'IN' | 77 | hpglInit = 'IN' |
45 | @@ -67,6 +80,8 @@ | |||
46 | 67 | if self.options.speed > 0: | 80 | if self.options.speed > 0: |
47 | 68 | hpglInit += ';VS%d' % self.options.speed | 81 | hpglInit += ';VS%d' % self.options.speed |
48 | 69 | self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; ' | 82 | self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; ' |
49 | 83 | if nv != [] and document_rotate: | ||
50 | 84 | nv[0].set("inkscape:document_rotation",document_rotate) | ||
51 | 70 | 85 | ||
52 | 71 | def output(self): | 86 | def output(self): |
53 | 72 | # print to file | 87 | # print to file |
54 | 73 | 88 | ||
55 | === modified file 'share/extensions/synfig_output.py' | |||
56 | --- share/extensions/synfig_output.py 2011-11-25 19:00:24 +0000 | |||
57 | +++ share/extensions/synfig_output.py 2017-01-24 17:53:20 +0000 | |||
58 | @@ -1046,6 +1046,11 @@ | |||
59 | 1046 | ###### Main Class ######################################### | 1046 | ###### Main Class ######################################### |
60 | 1047 | class SynfigExport(SynfigPrep): | 1047 | class SynfigExport(SynfigPrep): |
61 | 1048 | def __init__(self): | 1048 | def __init__(self): |
62 | 1049 | svg = self.document.getroot() | ||
63 | 1050 | xpathStr = '//http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}:namedview' | ||
64 | 1051 | res = svg.xpath(xpathStr, namespaces=inkex.NSS) | ||
65 | 1052 | self.document_rotate = res[0].get("inkscape:document_rotation") | ||
66 | 1053 | res[0].set("inkscape:document_rotation","0") | ||
67 | 1049 | SynfigPrep.__init__(self) | 1054 | SynfigPrep.__init__(self) |
68 | 1050 | 1055 | ||
69 | 1051 | def effect(self): | 1056 | def effect(self): |
70 | @@ -1073,6 +1078,10 @@ | |||
71 | 1073 | root_canvas.append(layer) | 1078 | root_canvas.append(layer) |
72 | 1074 | 1079 | ||
73 | 1075 | d.get_root_tree().write(sys.stdout) | 1080 | d.get_root_tree().write(sys.stdout) |
74 | 1081 | svg = self.document.getroot() | ||
75 | 1082 | xpathStr = '//http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}:namedview' | ||
76 | 1083 | res = svg.xpath(xpathStr, namespaces=inkex.NSS) | ||
77 | 1084 | res[0].set("inkscape:document_rotation",self.document_rotate) | ||
78 | 1076 | 1085 | ||
79 | 1077 | def convert_node(self, node, d): | 1086 | def convert_node(self, node, d): |
80 | 1078 | """Convert an SVG node to a list of Synfig layers""" | 1087 | """Convert an SVG node to a list of Synfig layers""" |
81 | 1079 | 1088 | ||
82 | === modified file 'src/attributes.cpp' | |||
83 | --- src/attributes.cpp 2016-10-19 11:11:05 +0000 | |||
84 | +++ src/attributes.cpp 2017-01-24 17:53:20 +0000 | |||
85 | @@ -89,6 +89,7 @@ | |||
86 | 89 | {SP_ATTR_INKSCAPE_ZOOM, "inkscape:zoom"}, | 89 | {SP_ATTR_INKSCAPE_ZOOM, "inkscape:zoom"}, |
87 | 90 | {SP_ATTR_INKSCAPE_CX, "inkscape:cx"}, | 90 | {SP_ATTR_INKSCAPE_CX, "inkscape:cx"}, |
88 | 91 | {SP_ATTR_INKSCAPE_CY, "inkscape:cy"}, | 91 | {SP_ATTR_INKSCAPE_CY, "inkscape:cy"}, |
89 | 92 | {SP_ATTR_INKSCAPE_DOCUMENT_ROTATION, "inkscape:document-rotation"}, | ||
90 | 92 | {SP_ATTR_INKSCAPE_WINDOW_WIDTH, "inkscape:window-width"}, | 93 | {SP_ATTR_INKSCAPE_WINDOW_WIDTH, "inkscape:window-width"}, |
91 | 93 | {SP_ATTR_INKSCAPE_WINDOW_HEIGHT, "inkscape:window-height"}, | 94 | {SP_ATTR_INKSCAPE_WINDOW_HEIGHT, "inkscape:window-height"}, |
92 | 94 | {SP_ATTR_INKSCAPE_WINDOW_X, "inkscape:window-x"}, | 95 | {SP_ATTR_INKSCAPE_WINDOW_X, "inkscape:window-x"}, |
93 | 95 | 96 | ||
94 | === modified file 'src/attributes.h' | |||
95 | --- src/attributes.h 2016-10-19 11:11:05 +0000 | |||
96 | +++ src/attributes.h 2017-01-24 17:53:20 +0000 | |||
97 | @@ -97,6 +97,7 @@ | |||
98 | 97 | SP_ATTR_INKSCAPE_ZOOM, | 97 | SP_ATTR_INKSCAPE_ZOOM, |
99 | 98 | SP_ATTR_INKSCAPE_CX, | 98 | SP_ATTR_INKSCAPE_CX, |
100 | 99 | SP_ATTR_INKSCAPE_CY, | 99 | SP_ATTR_INKSCAPE_CY, |
101 | 100 | SP_ATTR_INKSCAPE_DOCUMENT_ROTATION, | ||
102 | 100 | SP_ATTR_INKSCAPE_WINDOW_WIDTH, | 101 | SP_ATTR_INKSCAPE_WINDOW_WIDTH, |
103 | 101 | SP_ATTR_INKSCAPE_WINDOW_HEIGHT, | 102 | SP_ATTR_INKSCAPE_WINDOW_HEIGHT, |
104 | 102 | SP_ATTR_INKSCAPE_WINDOW_X, | 103 | SP_ATTR_INKSCAPE_WINDOW_X, |
105 | 103 | 104 | ||
106 | === modified file 'src/desktop-events.cpp' | |||
107 | --- src/desktop-events.cpp 2016-08-08 23:57:01 +0000 | |||
108 | +++ src/desktop-events.cpp 2017-01-24 17:53:20 +0000 | |||
109 | @@ -155,6 +155,10 @@ | |||
110 | 155 | } | 155 | } |
111 | 156 | } | 156 | } |
112 | 157 | 157 | ||
113 | 158 | SPNamedView *namedview = desktop->namedview; | ||
114 | 159 | if (namedview && namedview->document_rotation) { | ||
115 | 160 | normal *= Geom::Rotate(Geom::rad_from_deg(namedview->document_rotation * -1)); | ||
116 | 161 | } | ||
117 | 158 | guide = sp_guideline_new(desktop->guides, NULL, event_dt, normal); | 162 | guide = sp_guideline_new(desktop->guides, NULL, event_dt, normal); |
118 | 159 | sp_guideline_set_color(SP_GUIDELINE(guide), desktop->namedview->guidehicolor); | 163 | sp_guideline_set_color(SP_GUIDELINE(guide), desktop->namedview->guidehicolor); |
119 | 160 | 164 | ||
120 | 161 | 165 | ||
121 | === modified file 'src/display/canvas-temporary-item-list.h' | |||
122 | --- src/display/canvas-temporary-item-list.h 2014-10-08 02:22:03 +0000 | |||
123 | +++ src/display/canvas-temporary-item-list.h 2017-01-24 17:53:20 +0000 | |||
124 | @@ -14,6 +14,7 @@ | |||
125 | 14 | 14 | ||
126 | 15 | struct SPCanvasItem; | 15 | struct SPCanvasItem; |
127 | 16 | class SPDesktop; | 16 | class SPDesktop; |
128 | 17 | class SPViewBox; | ||
129 | 17 | 18 | ||
130 | 18 | namespace Inkscape { | 19 | namespace Inkscape { |
131 | 19 | namespace Display { | 20 | namespace Display { |
132 | 20 | 21 | ||
133 | === modified file 'src/display/sp-canvas.cpp' | |||
134 | --- src/display/sp-canvas.cpp 2016-12-25 19:26:50 +0000 | |||
135 | +++ src/display/sp-canvas.cpp 2017-01-24 17:53:20 +0000 | |||
136 | @@ -29,18 +29,24 @@ | |||
137 | 29 | #include "helper/sp-marshal.h" | 29 | #include "helper/sp-marshal.h" |
138 | 30 | #include <2geom/rect.h> | 30 | #include <2geom/rect.h> |
139 | 31 | #include <2geom/affine.h> | 31 | #include <2geom/affine.h> |
140 | 32 | #include "display/cairo-utils.h" | ||
141 | 33 | #include "display/sp-canvas.h" | 32 | #include "display/sp-canvas.h" |
142 | 34 | #include "display/sp-canvas-group.h" | 33 | #include "display/sp-canvas-group.h" |
143 | 34 | #include "display/rendermode.h" | ||
144 | 35 | #include "display/cairo-utils.h" | ||
145 | 36 | #include "display/cairo-templates.h" | ||
146 | 37 | #include "display/drawing-context.h" | ||
147 | 38 | #include "display/drawing-item.h" | ||
148 | 39 | #include "display/nr-filter-colormatrix.h" | ||
149 | 40 | #include "display/canvas-arena.h" | ||
150 | 35 | #include "preferences.h" | 41 | #include "preferences.h" |
151 | 36 | #include "inkscape.h" | 42 | #include "inkscape.h" |
152 | 37 | #include "sodipodi-ctrlrect.h" | 43 | #include "sodipodi-ctrlrect.h" |
153 | 38 | #include "cms-system.h" | 44 | #include "cms-system.h" |
154 | 39 | #include "display/rendermode.h" | ||
155 | 40 | #include "display/cairo-utils.h" | ||
156 | 41 | #include "debug/gdk-event-latency-tracker.h" | 45 | #include "debug/gdk-event-latency-tracker.h" |
157 | 42 | #include "desktop.h" | 46 | #include "desktop.h" |
158 | 43 | #include "color.h" | 47 | #include "color.h" |
159 | 48 | #include <iomanip> | ||
160 | 49 | #include <glibmm/i18n.h> | ||
161 | 44 | 50 | ||
162 | 45 | using Inkscape::Debug::GdkEventLatencyTracker; | 51 | using Inkscape::Debug::GdkEventLatencyTracker; |
163 | 46 | 52 | ||
164 | @@ -1888,6 +1894,19 @@ | |||
165 | 1888 | return SP_CANVAS_GROUP(_root); | 1894 | return SP_CANVAS_GROUP(_root); |
166 | 1889 | } | 1895 | } |
167 | 1890 | 1896 | ||
168 | 1897 | gdouble grayscale_value_matrix[20] = { | ||
169 | 1898 | 0.21, 0.72, 0.072, 0, 0, | ||
170 | 1899 | 0.21, 0.72, 0.072, 0, 0, | ||
171 | 1900 | 0.21, 0.72, 0.072, 0, 0, | ||
172 | 1901 | 0 , 0 , 0 , 1, 0 | ||
173 | 1902 | }; | ||
174 | 1903 | cairo_surface_t *surface_rotated; | ||
175 | 1904 | cairo_surface_t *surface_origin; | ||
176 | 1905 | cairo_surface_t *surface_measure; | ||
177 | 1906 | double start_angle = 0; | ||
178 | 1907 | bool started = false; | ||
179 | 1908 | bool rotated = false; | ||
180 | 1909 | |||
181 | 1891 | void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling) | 1910 | void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling) |
182 | 1892 | { | 1911 | { |
183 | 1893 | GtkAllocation allocation; | 1912 | GtkAllocation allocation; |
184 | @@ -1910,9 +1929,14 @@ | |||
185 | 1910 | cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | 1929 | cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
186 | 1911 | // Paint the background | 1930 | // Paint the background |
187 | 1912 | cairo_translate(cr, -ix, -iy); | 1931 | cairo_translate(cr, -ix, -iy); |
188 | 1932 | if (rotated) { | ||
189 | 1933 | cairo_translate(cr, dx, dy); | ||
190 | 1934 | rotated = false; | ||
191 | 1935 | } | ||
192 | 1913 | cairo_set_source(cr, _background); | 1936 | cairo_set_source(cr, _background); |
193 | 1914 | cairo_paint(cr); | 1937 | cairo_paint(cr); |
194 | 1915 | // Copy the old backing store contents | 1938 | // Copy the old backing store contents |
195 | 1939 | |||
196 | 1916 | cairo_set_source_surface(cr, _backing_store, _x0, _y0); | 1940 | cairo_set_source_surface(cr, _backing_store, _x0, _y0); |
197 | 1917 | cairo_rectangle(cr, _x0, _y0, allocation.width, allocation.height); | 1941 | cairo_rectangle(cr, _x0, _y0, allocation.width, allocation.height); |
198 | 1918 | cairo_clip(cr); | 1942 | cairo_clip(cr); |
199 | @@ -1949,6 +1973,271 @@ | |||
200 | 1949 | addIdle(); | 1973 | addIdle(); |
201 | 1950 | } | 1974 | } |
202 | 1951 | 1975 | ||
203 | 1976 | void SPCanvas::startRotateTo(double angle) | ||
204 | 1977 | { | ||
205 | 1978 | if (!_backing_store || started) { | ||
206 | 1979 | return; | ||
207 | 1980 | } | ||
208 | 1981 | start_angle = angle; | ||
209 | 1982 | started = true; | ||
210 | 1983 | GtkAllocation allocation; | ||
211 | 1984 | gtk_widget_get_allocation(&_widget, &allocation); | ||
212 | 1985 | int half_w = allocation.width/2; | ||
213 | 1986 | int half_h = allocation.height/2; | ||
214 | 1987 | int half_min = std::min(half_w,half_h); | ||
215 | 1988 | |||
216 | 1989 | cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); | ||
217 | 1990 | cairo_t *cr = cairo_create(new_backing_store); | ||
218 | 1991 | cairo_arc(cr, half_w, half_h, half_min-15, 0, 2*M_PI); | ||
219 | 1992 | cairo_fill(cr); | ||
220 | 1993 | cairo_set_operator(cr, CAIRO_OPERATOR_IN); | ||
221 | 1994 | cairo_set_source_surface(cr, _backing_store, 0, 0); | ||
222 | 1995 | cairo_paint(cr); | ||
223 | 1996 | cairo_set_operator(cr, CAIRO_OPERATOR_OVER); | ||
224 | 1997 | cairo_arc(cr, half_w, half_h, half_min-16, 0, 2*M_PI); | ||
225 | 1998 | cairo_set_source_rgba (cr, 1, 1, 1, 0.5); | ||
226 | 1999 | cairo_stroke(cr); | ||
227 | 2000 | cairo_destroy(cr); | ||
228 | 2001 | surface_rotated = new_backing_store; | ||
229 | 2002 | |||
230 | 2003 | cairo_surface_t *new_backing_store_measure = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); | ||
231 | 2004 | cr = cairo_create(new_backing_store_measure); | ||
232 | 2005 | cairo_arc(cr, half_w, half_h, half_min-15, 0, 2*M_PI); | ||
233 | 2006 | cairo_set_source_rgba (cr, 1, 1, 1, 0.2); | ||
234 | 2007 | cairo_fill(cr); | ||
235 | 2008 | cairo_translate(cr, half_w, half_h); | ||
236 | 2009 | cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); | ||
237 | 2010 | cairo_set_font_size(cr, 10.0); | ||
238 | 2011 | for (gint x = 0; x < 360 ; x++){ | ||
239 | 2012 | gint ang = 360 - x ;//+ 90; | ||
240 | 2013 | if (ang > 180) { | ||
241 | 2014 | ang -= 360; | ||
242 | 2015 | } | ||
243 | 2016 | double rot = (-180.0 + x)*(M_PI/180.); | ||
244 | 2017 | double dist = half_min-9; | ||
245 | 2018 | gint inverse = 1; | ||
246 | 2019 | if((x) < 91 || (x) > 270) { | ||
247 | 2020 | inverse = -1; | ||
248 | 2021 | } | ||
249 | 2022 | if(x%10 == 0) { | ||
250 | 2023 | cairo_rotate(cr, -rot); | ||
251 | 2024 | cairo_text_extents_t extents; | ||
252 | 2025 | std::string s = std::to_string(ang) + "º"; | ||
253 | 2026 | cairo_text_extents(cr, s.c_str(), &extents); | ||
254 | 2027 | //std::cout << extents.width/2 << "extents.x_bearing\n"; | ||
255 | 2028 | cairo_translate(cr, (extents.width/2) * inverse * -1, (dist + ((extents.height/2)* inverse))); | ||
256 | 2029 | if((x) < 91 || (x) > 270) { | ||
257 | 2030 | cairo_rotate(cr, 180*(M_PI/180.0)); | ||
258 | 2031 | } | ||
259 | 2032 | cairo_text_path(cr, s.c_str()); | ||
260 | 2033 | if((x) < 91 || (x) > 270) { | ||
261 | 2034 | cairo_rotate(cr, -180*(M_PI/180.0)); | ||
262 | 2035 | } | ||
263 | 2036 | cairo_translate(cr, (extents.width/2) * inverse , (dist + ((extents.height/2)* inverse)) * -1); | ||
264 | 2037 | cairo_set_source_rgba (cr, 1, 1, 1, 1); | ||
265 | 2038 | cairo_fill(cr); | ||
266 | 2039 | cairo_rotate(cr, rot); | ||
267 | 2040 | } | ||
268 | 2041 | cairo_rotate(cr, x*(M_PI/180.)); | ||
269 | 2042 | if(x%5 == 0) { | ||
270 | 2043 | cairo_move_to(cr, 0, half_min-30); | ||
271 | 2044 | cairo_line_to(cr, 0, half_min-17); | ||
272 | 2045 | } else { | ||
273 | 2046 | cairo_move_to(cr, 0, half_min-20); | ||
274 | 2047 | cairo_line_to(cr, 0, half_min-15); | ||
275 | 2048 | } | ||
276 | 2049 | cairo_line_to(cr, 0, half_min-15); | ||
277 | 2050 | cairo_set_source_rgba (cr, 0, 0, 0, 0.4); | ||
278 | 2051 | cairo_set_line_width (cr,1); | ||
279 | 2052 | cairo_stroke(cr); | ||
280 | 2053 | cairo_rotate(cr, -x*(M_PI/180.)); | ||
281 | 2054 | } | ||
282 | 2055 | cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); | ||
283 | 2056 | cairo_translate(cr, -half_w, -half_h); | ||
284 | 2057 | cairo_arc(cr, half_w, half_h, half_min-30, 0, 2*M_PI); | ||
285 | 2058 | cairo_set_source_rgba (cr, 1, 1, 1, 1); | ||
286 | 2059 | cairo_fill(cr); | ||
287 | 2060 | cairo_translate(cr, half_w, half_h); | ||
288 | 2061 | cairo_set_operator(cr, CAIRO_OPERATOR_OVER); | ||
289 | 2062 | cairo_rotate(cr, start_angle*(M_PI/180.)); | ||
290 | 2063 | cairo_move_to(cr, 0, 0); | ||
291 | 2064 | cairo_line_to(cr, 0, (half_min-17) * -1); | ||
292 | 2065 | cairo_set_source_rgba (cr, 1, 1, 1, 0.25); | ||
293 | 2066 | cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); | ||
294 | 2067 | cairo_set_line_width (cr,5); | ||
295 | 2068 | cairo_stroke(cr); | ||
296 | 2069 | cairo_move_to(cr, 0, 0); | ||
297 | 2070 | cairo_line_to(cr, 0, (half_min-17) * -1); | ||
298 | 2071 | cairo_set_source_rgba (cr, 1, 0, 0, 0.9); | ||
299 | 2072 | cairo_set_line_width (cr,1); | ||
300 | 2073 | cairo_stroke(cr); | ||
301 | 2074 | cairo_rotate(cr, -start_angle*(M_PI/180.)); | ||
302 | 2075 | cairo_destroy(cr); | ||
303 | 2076 | surface_measure = new_backing_store_measure; | ||
304 | 2077 | |||
305 | 2078 | cairo_surface_t *new_backing_store_grey = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); | ||
306 | 2079 | cr = cairo_create(new_backing_store_grey); | ||
307 | 2080 | cairo_set_operator(cr, CAIRO_OPERATOR_OVER); | ||
308 | 2081 | cairo_set_source_surface(cr, _backing_store, 0, 0); | ||
309 | 2082 | cairo_paint(cr); | ||
310 | 2083 | Inkscape::Filters::FilterColorMatrix::ColorMatrixMatrix _grayscale_colormatrix = std::vector<gdouble> (grayscale_value_matrix, grayscale_value_matrix + 20); | ||
311 | 2084 | cairo_surface_t *out = ink_cairo_surface_create_identical(new_backing_store_grey); | ||
312 | 2085 | ink_cairo_surface_filter(new_backing_store_grey, out, _grayscale_colormatrix); | ||
313 | 2086 | cairo_set_source_surface(cr, out, 0, 0); | ||
314 | 2087 | cairo_surface_destroy(out); | ||
315 | 2088 | cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | ||
316 | 2089 | cairo_paint(cr); | ||
317 | 2090 | cairo_destroy(cr); | ||
318 | 2091 | surface_origin = new_backing_store_grey; | ||
319 | 2092 | } | ||
320 | 2093 | |||
321 | 2094 | bool SPCanvas::endRotateTo() | ||
322 | 2095 | { | ||
323 | 2096 | if (!_backing_store || !started) { | ||
324 | 2097 | return false; | ||
325 | 2098 | } | ||
326 | 2099 | started = false; | ||
327 | 2100 | surface_rotated = NULL; | ||
328 | 2101 | surface_origin = NULL; | ||
329 | 2102 | gtk_widget_queue_draw(GTK_WIDGET(this)); | ||
330 | 2103 | dirtyAll(); | ||
331 | 2104 | addIdle(); | ||
332 | 2105 | rotated = true; | ||
333 | 2106 | return true; | ||
334 | 2107 | } | ||
335 | 2108 | |||
336 | 2109 | void SPCanvas::clearRotateTo() | ||
337 | 2110 | { | ||
338 | 2111 | if (!started) { | ||
339 | 2112 | return; | ||
340 | 2113 | } | ||
341 | 2114 | gtk_widget_queue_draw(GTK_WIDGET(this)); | ||
342 | 2115 | dirtyAll(); | ||
343 | 2116 | addIdle(); | ||
344 | 2117 | } | ||
345 | 2118 | |||
346 | 2119 | void SPCanvas::rotateTo(double angle) | ||
347 | 2120 | { | ||
348 | 2121 | if (!_backing_store || !started) { | ||
349 | 2122 | return; | ||
350 | 2123 | } | ||
351 | 2124 | GtkAllocation allocation; | ||
352 | 2125 | gtk_widget_get_allocation(&_widget, &allocation); | ||
353 | 2126 | int half_w = allocation.width/2; | ||
354 | 2127 | int half_h = allocation.height/2; | ||
355 | 2128 | int half_min = std::min(half_w,half_h); | ||
356 | 2129 | cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); | ||
357 | 2130 | cairo_t *cr = cairo_create(new_backing_store); | ||
358 | 2131 | cairo_set_source_surface(cr, surface_origin, 0, 0); | ||
359 | 2132 | cairo_paint(cr); | ||
360 | 2133 | cairo_set_source_rgba (cr, 0, 0, 0, 0.5); | ||
361 | 2134 | cairo_paint(cr); | ||
362 | 2135 | cairo_pattern_t *source_pattern; | ||
363 | 2136 | cairo_matrix_t matrix; | ||
364 | 2137 | source_pattern = cairo_pattern_create_for_surface (surface_rotated); | ||
365 | 2138 | cairo_matrix_init_identity (&matrix); | ||
366 | 2139 | cairo_matrix_translate (&matrix, allocation.width/2.0, allocation.height/2.0); | ||
367 | 2140 | cairo_matrix_rotate (&matrix, Geom::rad_from_deg(angle - start_angle) * -1); | ||
368 | 2141 | cairo_matrix_translate (&matrix, -allocation.width/2.0, -allocation.height/2.0); | ||
369 | 2142 | cairo_pattern_set_matrix (source_pattern, &matrix); | ||
370 | 2143 | cairo_set_source(cr, source_pattern); | ||
371 | 2144 | cairo_paint(cr); | ||
372 | 2145 | cairo_set_source_surface(cr, surface_measure, 0, 0); | ||
373 | 2146 | cairo_paint(cr); | ||
374 | 2147 | cairo_translate(cr, half_w, half_h); | ||
375 | 2148 | cairo_rotate(cr, angle*(M_PI/180.)); | ||
376 | 2149 | cairo_move_to(cr, 0, 0); | ||
377 | 2150 | cairo_line_to(cr, 0, (half_min-17) * -1); | ||
378 | 2151 | cairo_set_source_rgba (cr, 1, 1, 1, 0.25); | ||
379 | 2152 | cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); | ||
380 | 2153 | cairo_set_line_width (cr,5); | ||
381 | 2154 | cairo_stroke(cr); | ||
382 | 2155 | cairo_move_to(cr, 0, 0); | ||
383 | 2156 | cairo_line_to(cr, 0, (half_min-17) * -1); | ||
384 | 2157 | cairo_set_source_rgba (cr, 1, 1, 1, 0.9); | ||
385 | 2158 | cairo_set_line_width (cr,1); | ||
386 | 2159 | cairo_stroke(cr); | ||
387 | 2160 | cairo_move_to(cr, 0, 0); | ||
388 | 2161 | cairo_line_to(cr, 0, (half_min-17) * -1); | ||
389 | 2162 | cairo_set_source_rgba (cr, 1, 0, 0, 0.9); | ||
390 | 2163 | const double dashed[] = {6.0, 3.0}; | ||
391 | 2164 | int len = sizeof(dashed) / sizeof(dashed[0]); | ||
392 | 2165 | cairo_set_dash(cr, dashed, len, 1); | ||
393 | 2166 | cairo_stroke(cr); | ||
394 | 2167 | cairo_translate(cr, -half_w, -half_h); | ||
395 | 2168 | cairo_set_source_rgba (cr, 1, 1, 1, 0.25); | ||
396 | 2169 | cairo_arc(cr, half_w, half_h, 7, 0, 2*M_PI); | ||
397 | 2170 | cairo_fill(cr); | ||
398 | 2171 | cairo_set_source_rgba (cr, 1, 0, 0, 0.7); | ||
399 | 2172 | cairo_arc(cr, half_w, half_h, 5, 0, 2*M_PI); | ||
400 | 2173 | cairo_fill(cr); | ||
401 | 2174 | cairo_translate(cr, half_w, half_h); | ||
402 | 2175 | cairo_rotate(cr, -angle*(M_PI/180.)); | ||
403 | 2176 | cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); | ||
404 | 2177 | cairo_set_font_size(cr, 15.0); | ||
405 | 2178 | cairo_text_extents_t extents; | ||
406 | 2179 | std::ostringstream s; | ||
407 | 2180 | s << _("Original angle ") << std::fixed << std::setprecision(2) << start_angle << "º"; | ||
408 | 2181 | cairo_text_extents(cr, s.str().c_str(), &extents); | ||
409 | 2182 | cairo_translate(cr, half_w - extents.width -15 ,-half_h + 25); | ||
410 | 2183 | cairo_set_source_rgba (cr, 1, 1, 1, 1); | ||
411 | 2184 | cairo_text_path(cr, s.str().c_str()); | ||
412 | 2185 | cairo_fill(cr); | ||
413 | 2186 | cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 25) *-1); | ||
414 | 2187 | s.str(""); | ||
415 | 2188 | s << _("New angle ") << std::fixed << std::setprecision(2) << angle << "º"; | ||
416 | 2189 | cairo_text_extents(cr, s.str().c_str(), &extents); | ||
417 | 2190 | cairo_translate(cr, half_w - extents.width -15 ,-half_h + 45); | ||
418 | 2191 | cairo_text_path(cr, s.str().c_str()); | ||
419 | 2192 | cairo_fill(cr); | ||
420 | 2193 | cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 45) *-1); | ||
421 | 2194 | s.str(""); | ||
422 | 2195 | s << _("Gap ") << std::fixed << std::setprecision(2) << std::abs(start_angle-angle) << "º"; | ||
423 | 2196 | cairo_text_extents(cr, s.str().c_str(), &extents); | ||
424 | 2197 | cairo_translate(cr, half_w - extents.width -15 ,-half_h + 65); | ||
425 | 2198 | cairo_text_path(cr, s.str().c_str()); | ||
426 | 2199 | cairo_fill(cr); | ||
427 | 2200 | cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 65) *-1); | ||
428 | 2201 | cairo_translate(cr, -half_w + 10 ,-half_h + 25); | ||
429 | 2202 | s.str(""); | ||
430 | 2203 | cairo_set_font_size(cr, 12.0); | ||
431 | 2204 | s << _("Normal mode, 1º round step"); | ||
432 | 2205 | cairo_text_path(cr, s.str().c_str()); | ||
433 | 2206 | cairo_fill(cr); | ||
434 | 2207 | cairo_translate(cr, (-half_w +10) * -1 ,(-half_h + 25) * -1); | ||
435 | 2208 | cairo_translate(cr, -half_w + 10 ,-half_h + 40); | ||
436 | 2209 | s.str(""); | ||
437 | 2210 | s << _("+ALT, Fractional degrees"); | ||
438 | 2211 | cairo_text_path(cr, s.str().c_str()); | ||
439 | 2212 | cairo_fill(cr); | ||
440 | 2213 | cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 40) * -1); | ||
441 | 2214 | cairo_translate(cr, -half_w + 10 ,-half_h + 55); | ||
442 | 2215 | s.str(""); | ||
443 | 2216 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | ||
444 | 2217 | s << _("+CTRL, ") << 180.0/prefs->getInt("/options/rotationsnapsperpi/value", 12) << _("º round step"); | ||
445 | 2218 | cairo_text_path(cr, s.str().c_str()); | ||
446 | 2219 | cairo_fill(cr); | ||
447 | 2220 | cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 55) * -1); | ||
448 | 2221 | cairo_translate(cr, -half_w + 10 ,-half_h + 70); | ||
449 | 2222 | s.str(""); | ||
450 | 2223 | s << _("+SHIFT, Reset"); | ||
451 | 2224 | cairo_text_path(cr, s.str().c_str()); | ||
452 | 2225 | cairo_fill(cr); | ||
453 | 2226 | cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 70) * -1); | ||
454 | 2227 | cairo_translate(cr, -half_w + 10 ,-half_h + 85); | ||
455 | 2228 | s.str(""); | ||
456 | 2229 | s << _("+CTRL+SHIFT, 0º"); | ||
457 | 2230 | cairo_text_path(cr, s.str().c_str()); | ||
458 | 2231 | cairo_fill(cr); | ||
459 | 2232 | //cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 60) * -1); | ||
460 | 2233 | cairo_destroy(cr); | ||
461 | 2234 | cairo_surface_destroy(_backing_store); | ||
462 | 2235 | _backing_store = new_backing_store; | ||
463 | 2236 | cairo_pattern_destroy (source_pattern); | ||
464 | 2237 | gtk_widget_queue_draw(GTK_WIDGET(this)); | ||
465 | 2238 | addIdle(); | ||
466 | 2239 | } | ||
467 | 2240 | |||
468 | 1952 | void SPCanvas::updateNow() | 2241 | void SPCanvas::updateNow() |
469 | 1953 | { | 2242 | { |
470 | 1954 | if (_need_update) { | 2243 | if (_need_update) { |
471 | 1955 | 2244 | ||
472 | === modified file 'src/display/sp-canvas.h' | |||
473 | --- src/display/sp-canvas.h 2016-08-12 04:11:03 +0000 | |||
474 | +++ src/display/sp-canvas.h 2017-01-24 17:53:20 +0000 | |||
475 | @@ -72,7 +72,10 @@ | |||
476 | 72 | struct SPCanvas { | 72 | struct SPCanvas { |
477 | 73 | /// Scrolls canvas to specific position (cx and cy are measured in screen pixels). | 73 | /// Scrolls canvas to specific position (cx and cy are measured in screen pixels). |
478 | 74 | void scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling = false); | 74 | void scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling = false); |
480 | 75 | 75 | void startRotateTo(double angle); | |
481 | 76 | void rotateTo(double angle); | ||
482 | 77 | bool endRotateTo(); | ||
483 | 78 | void clearRotateTo(); | ||
484 | 76 | /// Synchronously updates the canvas if necessary. | 79 | /// Synchronously updates the canvas if necessary. |
485 | 77 | void updateNow(); | 80 | void updateNow(); |
486 | 78 | 81 | ||
487 | 79 | 82 | ||
488 | === modified file 'src/document-undo.cpp' | |||
489 | --- src/document-undo.cpp 2017-01-24 00:02:46 +0000 | |||
490 | +++ src/document-undo.cpp 2017-01-24 17:53:20 +0000 | |||
491 | @@ -240,49 +240,52 @@ | |||
492 | 240 | 240 | ||
493 | 241 | gboolean Inkscape::DocumentUndo::undo(SPDocument *doc) | 241 | gboolean Inkscape::DocumentUndo::undo(SPDocument *doc) |
494 | 242 | { | 242 | { |
507 | 243 | using Inkscape::Debug::EventTracker; | 243 | using Inkscape::Debug::EventTracker; |
508 | 244 | using Inkscape::Debug::SimpleEvent; | 244 | using Inkscape::Debug::SimpleEvent; |
509 | 245 | 245 | ||
510 | 246 | gboolean ret; | 246 | gboolean ret; |
511 | 247 | 247 | ||
512 | 248 | EventTracker<SimpleEvent<Inkscape::Debug::Event::DOCUMENT> > tracker("undo"); | 248 | EventTracker<SimpleEvent<Inkscape::Debug::Event::DOCUMENT> > tracker("undo"); |
513 | 249 | 249 | ||
514 | 250 | g_assert (doc != NULL); | 250 | g_assert (doc != NULL); |
515 | 251 | g_assert (doc->priv != NULL); | 251 | g_assert (doc->priv != NULL); |
516 | 252 | g_assert (doc->priv->sensitive); | 252 | g_assert (doc->priv->sensitive); |
517 | 253 | 253 | ||
518 | 254 | doc->priv->sensitive = FALSE; | 254 | doc->priv->sensitive = FALSE; |
519 | 255 | doc->priv->seeking = true; | 255 | doc->priv->seeking = true; |
520 | 256 | 256 | ||
532 | 257 | doc->actionkey.clear(); | 257 | doc->actionkey.clear(); |
533 | 258 | 258 | ||
534 | 259 | finish_incomplete_transaction(*doc); | 259 | finish_incomplete_transaction(*doc); |
535 | 260 | 260 | ||
536 | 261 | if (! doc->priv->undo.empty()) { | 261 | if (! doc->priv->undo.empty()) { |
537 | 262 | Inkscape::Event *log = doc->priv->undo.back(); | 262 | Inkscape::Event *log = doc->priv->undo.back(); |
538 | 263 | doc->priv->undo.pop_back(); | 263 | doc->priv->undo.pop_back(); |
539 | 264 | sp_repr_undo_log (log->event); | 264 | sp_repr_undo_log (log->event); |
540 | 265 | perform_document_update(*doc); | 265 | perform_document_update(*doc); |
541 | 266 | 266 | ||
542 | 267 | doc->priv->redo.push_back(log); | 267 | doc->priv->redo.push_back(log); |
543 | 268 | 268 | ||
544 | 269 | doc->setModifiedSinceSave(); | 269 | doc->setModifiedSinceSave(); |
545 | 270 | doc->priv->undoStackObservers.notifyUndoEvent(log); | 270 | doc->priv->undoStackObservers.notifyUndoEvent(log); |
546 | 271 | 271 | ||
555 | 272 | ret = TRUE; | 272 | ret = TRUE; |
556 | 273 | } else { | 273 | } else { |
557 | 274 | ret = FALSE; | 274 | ret = FALSE; |
558 | 275 | } | 275 | } |
559 | 276 | 276 | ||
560 | 277 | sp_repr_begin_transaction (doc->rdoc); | 277 | sp_repr_begin_transaction (doc->rdoc); |
561 | 278 | 278 | ||
562 | 279 | doc->priv->sensitive = TRUE; | 279 | doc->priv->sensitive = TRUE; |
563 | 280 | doc->priv->seeking = false; | 280 | doc->priv->seeking = false; |
564 | 281 | 281 | ||
567 | 282 | if (ret) | 282 | if (ret) INKSCAPE.external_change(); |
566 | 283 | INKSCAPE.external_change(); | ||
568 | 284 | 283 | ||
570 | 285 | return ret; | 284 | SPObject *updated = doc->getRoot(); |
571 | 285 | if (updated) { | ||
572 | 286 | updated->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); | ||
573 | 287 | } | ||
574 | 288 | return ret; | ||
575 | 286 | } | 289 | } |
576 | 287 | 290 | ||
577 | 288 | gboolean Inkscape::DocumentUndo::redo(SPDocument *doc) | 291 | gboolean Inkscape::DocumentUndo::redo(SPDocument *doc) |
578 | 289 | 292 | ||
579 | === modified file 'src/document.cpp' | |||
580 | --- src/document.cpp 2016-11-28 22:07:00 +0000 | |||
581 | +++ src/document.cpp 2017-01-24 17:53:20 +0000 | |||
582 | @@ -386,6 +386,7 @@ | |||
583 | 386 | if (!bordercolor.empty()) { | 386 | if (!bordercolor.empty()) { |
584 | 387 | rnew->setAttribute("bordercolor", bordercolor.data()); | 387 | rnew->setAttribute("bordercolor", bordercolor.data()); |
585 | 388 | } | 388 | } |
586 | 389 | sp_repr_set_svg_double(rnew, "inkscape:document-rotation", 0.); | ||
587 | 389 | sp_repr_set_svg_double(rnew, "borderopacity", | 390 | sp_repr_set_svg_double(rnew, "borderopacity", |
588 | 390 | prefs->getDouble("/template/base/borderopacity", 1.0)); | 391 | prefs->getDouble("/template/base/borderopacity", 1.0)); |
589 | 391 | sp_repr_set_svg_double(rnew, "objecttolerance", | 392 | sp_repr_set_svg_double(rnew, "objecttolerance", |
590 | @@ -407,6 +408,11 @@ | |||
591 | 407 | rroot->addChild(rnew, NULL); | 408 | rroot->addChild(rnew, NULL); |
592 | 408 | // clean up | 409 | // clean up |
593 | 409 | Inkscape::GC::release(rnew); | 410 | Inkscape::GC::release(rnew); |
594 | 411 | } else { | ||
595 | 412 | Inkscape::XML::Node *nv_repr = sp_item_group_get_child_by_name(document->root, NULL, "sodipodi:namedview")->getRepr(); | ||
596 | 413 | if (!nv_repr->attribute("inkscape:document-rotation")) { | ||
597 | 414 | sp_repr_set_svg_double(nv_repr, "inkscape:document-rotation", 0.); | ||
598 | 415 | } | ||
599 | 410 | } | 416 | } |
600 | 411 | 417 | ||
601 | 412 | // Defs | 418 | // Defs |
602 | 413 | 419 | ||
603 | === modified file 'src/extension/internal/cairo-png-out.cpp' | |||
604 | --- src/extension/internal/cairo-png-out.cpp 2014-03-27 01:33:44 +0000 | |||
605 | +++ src/extension/internal/cairo-png-out.cpp 2017-01-24 17:53:20 +0000 | |||
606 | @@ -53,11 +53,10 @@ | |||
607 | 53 | { | 53 | { |
608 | 54 | CairoRenderer *renderer; | 54 | CairoRenderer *renderer; |
609 | 55 | CairoRenderContext *ctx; | 55 | CairoRenderContext *ctx; |
611 | 56 | 56 | doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; | |
612 | 57 | doc->ensureUpToDate(); | 57 | doc->ensureUpToDate(); |
613 | 58 | 58 | ||
614 | 59 | /* Start */ | 59 | /* Start */ |
615 | 60 | |||
616 | 61 | SPItem *base = doc->getRoot(); | 60 | SPItem *base = doc->getRoot(); |
617 | 62 | Inkscape::Drawing drawing; | 61 | Inkscape::Drawing drawing; |
618 | 63 | unsigned dkey = SPItem::display_key_new(1); | 62 | unsigned dkey = SPItem::display_key_new(1); |
619 | @@ -77,6 +76,7 @@ | |||
620 | 77 | renderer->destroyContext(ctx); | 76 | renderer->destroyContext(ctx); |
621 | 78 | 77 | ||
622 | 79 | base->invoke_hide(dkey); | 78 | base->invoke_hide(dkey); |
623 | 79 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
624 | 80 | /* end */ | 80 | /* end */ |
625 | 81 | delete renderer; | 81 | delete renderer; |
626 | 82 | 82 | ||
627 | 83 | 83 | ||
628 | === modified file 'src/extension/internal/cairo-ps-out.cpp' | |||
629 | --- src/extension/internal/cairo-ps-out.cpp 2016-06-11 17:25:23 +0000 | |||
630 | +++ src/extension/internal/cairo-ps-out.cpp 2017-01-24 17:53:20 +0000 | |||
631 | @@ -68,6 +68,7 @@ | |||
632 | 68 | ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool omittext, | 68 | ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool omittext, |
633 | 69 | bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px, bool eps = false) | 69 | bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px, bool eps = false) |
634 | 70 | { | 70 | { |
635 | 71 | doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; | ||
636 | 71 | doc->ensureUpToDate(); | 72 | doc->ensureUpToDate(); |
637 | 72 | 73 | ||
638 | 73 | SPItem *base = NULL; | 74 | SPItem *base = NULL; |
639 | @@ -84,9 +85,10 @@ | |||
640 | 84 | pageBoundingBox = !exportDrawing; | 85 | pageBoundingBox = !exportDrawing; |
641 | 85 | } | 86 | } |
642 | 86 | 87 | ||
644 | 87 | if (!base) | 88 | if (!base) { |
645 | 89 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
646 | 88 | return false; | 90 | return false; |
648 | 89 | 91 | } | |
649 | 90 | Inkscape::Drawing drawing; | 92 | Inkscape::Drawing drawing; |
650 | 91 | unsigned dkey = SPItem::display_key_new(1); | 93 | unsigned dkey = SPItem::display_key_new(1); |
651 | 92 | base->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); | 94 | base->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); |
652 | @@ -115,6 +117,7 @@ | |||
653 | 115 | 117 | ||
654 | 116 | renderer->destroyContext(ctx); | 118 | renderer->destroyContext(ctx); |
655 | 117 | delete renderer; | 119 | delete renderer; |
656 | 120 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
657 | 118 | 121 | ||
658 | 119 | return ret; | 122 | return ret; |
659 | 120 | } | 123 | } |
660 | 121 | 124 | ||
661 | === modified file 'src/extension/internal/cairo-renderer-pdf-out.cpp' | |||
662 | --- src/extension/internal/cairo-renderer-pdf-out.cpp 2016-06-11 17:25:23 +0000 | |||
663 | +++ src/extension/internal/cairo-renderer-pdf-out.cpp 2017-01-24 17:53:20 +0000 | |||
664 | @@ -61,6 +61,7 @@ | |||
665 | 61 | bool texttopath, bool omittext, bool filtertobitmap, int resolution, | 61 | bool texttopath, bool omittext, bool filtertobitmap, int resolution, |
666 | 62 | const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px) | 62 | const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px) |
667 | 63 | { | 63 | { |
668 | 64 | doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; | ||
669 | 64 | doc->ensureUpToDate(); | 65 | doc->ensureUpToDate(); |
670 | 65 | 66 | ||
671 | 66 | /* Start */ | 67 | /* Start */ |
672 | @@ -80,6 +81,7 @@ | |||
673 | 80 | } | 81 | } |
674 | 81 | 82 | ||
675 | 82 | if (!base) { | 83 | if (!base) { |
676 | 84 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
677 | 83 | return false; | 85 | return false; |
678 | 84 | } | 86 | } |
679 | 85 | 87 | ||
680 | @@ -112,7 +114,7 @@ | |||
681 | 112 | 114 | ||
682 | 113 | renderer->destroyContext(ctx); | 115 | renderer->destroyContext(ctx); |
683 | 114 | delete renderer; | 116 | delete renderer; |
685 | 115 | 117 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | |
686 | 116 | return ret; | 118 | return ret; |
687 | 117 | } | 119 | } |
688 | 118 | 120 | ||
689 | 119 | 121 | ||
690 | === modified file 'src/extension/internal/emf-inout.cpp' | |||
691 | --- src/extension/internal/emf-inout.cpp 2016-06-11 17:25:23 +0000 | |||
692 | +++ src/extension/internal/emf-inout.cpp 2017-01-24 17:53:20 +0000 | |||
693 | @@ -94,7 +94,7 @@ | |||
694 | 94 | const gchar *oldconst; | 94 | const gchar *oldconst; |
695 | 95 | gchar *oldoutput; | 95 | gchar *oldoutput; |
696 | 96 | unsigned int ret; | 96 | unsigned int ret; |
698 | 97 | 97 | doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; | |
699 | 98 | doc->ensureUpToDate(); | 98 | doc->ensureUpToDate(); |
700 | 99 | 99 | ||
701 | 100 | mod = Inkscape::Extension::get_print(PRINT_EMF); | 100 | mod = Inkscape::Extension::get_print(PRINT_EMF); |
702 | @@ -114,6 +114,7 @@ | |||
703 | 114 | /* Print document */ | 114 | /* Print document */ |
704 | 115 | ret = mod->begin(doc); | 115 | ret = mod->begin(doc); |
705 | 116 | if (ret) { | 116 | if (ret) { |
706 | 117 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
707 | 117 | g_free(oldoutput); | 118 | g_free(oldoutput); |
708 | 118 | throw Inkscape::Extension::Output::save_failed(); | 119 | throw Inkscape::Extension::Output::save_failed(); |
709 | 119 | } | 120 | } |
710 | @@ -127,7 +128,7 @@ | |||
711 | 127 | 128 | ||
712 | 128 | mod->set_param_string("destination", oldoutput); | 129 | mod->set_param_string("destination", oldoutput); |
713 | 129 | g_free(oldoutput); | 130 | g_free(oldoutput); |
715 | 130 | 131 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | |
716 | 131 | return; | 132 | return; |
717 | 132 | } | 133 | } |
718 | 133 | 134 | ||
719 | 134 | 135 | ||
720 | === modified file 'src/extension/internal/javafx-out.cpp' | |||
721 | --- src/extension/internal/javafx-out.cpp 2016-07-14 11:17:21 +0000 | |||
722 | +++ src/extension/internal/javafx-out.cpp 2017-01-24 17:53:20 +0000 | |||
723 | @@ -843,7 +843,8 @@ | |||
724 | 843 | bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) | 843 | bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) |
725 | 844 | { | 844 | { |
726 | 845 | reset(); | 845 | reset(); |
728 | 846 | 846 | doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; | |
729 | 847 | doc->ensureUpToDate(); | ||
730 | 847 | 848 | ||
731 | 848 | name = Glib::path_get_basename(filename_utf8); | 849 | name = Glib::path_get_basename(filename_utf8); |
732 | 849 | int pos = name.find('.'); | 850 | int pos = name.find('.'); |
733 | @@ -856,12 +857,14 @@ | |||
734 | 856 | //# Lets do the curves first, to get the stats | 857 | //# Lets do the curves first, to get the stats |
735 | 857 | 858 | ||
736 | 858 | if (!doTree(doc)) { | 859 | if (!doTree(doc)) { |
737 | 860 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
738 | 859 | return false; | 861 | return false; |
739 | 860 | } | 862 | } |
740 | 861 | String curveBuf = outbuf; | 863 | String curveBuf = outbuf; |
741 | 862 | outbuf.clear(); | 864 | outbuf.clear(); |
742 | 863 | 865 | ||
743 | 864 | if (!doHeader()) { | 866 | if (!doHeader()) { |
744 | 867 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
745 | 865 | return false; | 868 | return false; |
746 | 866 | } | 869 | } |
747 | 867 | 870 | ||
748 | @@ -875,6 +878,7 @@ | |||
749 | 875 | doBody(doc, doc->getRoot()); | 878 | doBody(doc, doc->getRoot()); |
750 | 876 | 879 | ||
751 | 877 | if (!doTail()) { | 880 | if (!doTail()) { |
752 | 881 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
753 | 878 | return false; | 882 | return false; |
754 | 879 | } | 883 | } |
755 | 880 | 884 | ||
756 | @@ -884,6 +888,7 @@ | |||
757 | 884 | FILE *f = Inkscape::IO::fopen_utf8name(filename_utf8, "w"); | 888 | FILE *f = Inkscape::IO::fopen_utf8name(filename_utf8, "w"); |
758 | 885 | if (!f) | 889 | if (!f) |
759 | 886 | { | 890 | { |
760 | 891 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
761 | 887 | err("Could open JavaFX file '%s' for writing", filename_utf8); | 892 | err("Could open JavaFX file '%s' for writing", filename_utf8); |
762 | 888 | return false; | 893 | return false; |
763 | 889 | } | 894 | } |
764 | @@ -894,7 +899,7 @@ | |||
765 | 894 | } | 899 | } |
766 | 895 | 900 | ||
767 | 896 | fclose(f); | 901 | fclose(f); |
769 | 897 | 902 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | |
770 | 898 | return true; | 903 | return true; |
771 | 899 | } | 904 | } |
772 | 900 | 905 | ||
773 | 901 | 906 | ||
774 | === modified file 'src/extension/internal/latex-pstricks-out.cpp' | |||
775 | --- src/extension/internal/latex-pstricks-out.cpp 2012-04-18 07:02:24 +0000 | |||
776 | +++ src/extension/internal/latex-pstricks-out.cpp 2017-01-24 17:53:20 +0000 | |||
777 | @@ -49,6 +49,7 @@ | |||
778 | 49 | void LatexOutput::save(Inkscape::Extension::Output * /*mod2*/, SPDocument *doc, gchar const *filename) | 49 | void LatexOutput::save(Inkscape::Extension::Output * /*mod2*/, SPDocument *doc, gchar const *filename) |
779 | 50 | { | 50 | { |
780 | 51 | SPPrintContext context; | 51 | SPPrintContext context; |
781 | 52 | doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; | ||
782 | 52 | doc->ensureUpToDate(); | 53 | doc->ensureUpToDate(); |
783 | 53 | 54 | ||
784 | 54 | Inkscape::Extension::Print *mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX); | 55 | Inkscape::Extension::Print *mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX); |
785 | @@ -76,6 +77,7 @@ | |||
786 | 76 | 77 | ||
787 | 77 | mod->set_param_string("destination", oldoutput); | 78 | mod->set_param_string("destination", oldoutput); |
788 | 78 | g_free(oldoutput); | 79 | g_free(oldoutput); |
789 | 80 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
790 | 79 | } | 81 | } |
791 | 80 | 82 | ||
792 | 81 | #include "clear-n_.h" | 83 | #include "clear-n_.h" |
793 | 82 | 84 | ||
794 | === modified file 'src/extension/internal/odf.cpp' | |||
795 | --- src/extension/internal/odf.cpp 2016-08-17 07:39:43 +0000 | |||
796 | +++ src/extension/internal/odf.cpp 2017-01-24 17:53:20 +0000 | |||
797 | @@ -72,6 +72,7 @@ | |||
798 | 72 | #include "sp-path.h" | 72 | #include "sp-path.h" |
799 | 73 | #include "sp-text.h" | 73 | #include "sp-text.h" |
800 | 74 | #include "sp-flowtext.h" | 74 | #include "sp-flowtext.h" |
801 | 75 | #include "sp-root.h" | ||
802 | 75 | #include "svg/svg.h" | 76 | #include "svg/svg.h" |
803 | 76 | #include "text-editing.h" | 77 | #include "text-editing.h" |
804 | 77 | #include "util/units.h" | 78 | #include "util/units.h" |
805 | @@ -2095,7 +2096,8 @@ | |||
806 | 2095 | void OdfOutput::save(Inkscape::Extension::Output */*mod*/, SPDocument *doc, gchar const *filename) | 2096 | void OdfOutput::save(Inkscape::Extension::Output */*mod*/, SPDocument *doc, gchar const *filename) |
807 | 2096 | { | 2097 | { |
808 | 2097 | reset(); | 2098 | reset(); |
810 | 2098 | 2099 | doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; | |
811 | 2100 | doc->ensureUpToDate(); | ||
812 | 2099 | documentUri = Inkscape::URI(filename); | 2101 | documentUri = Inkscape::URI(filename); |
813 | 2100 | 2102 | ||
814 | 2101 | ZipFile zf; | 2103 | ZipFile zf; |
815 | @@ -2104,25 +2106,30 @@ | |||
816 | 2104 | if (!writeManifest(zf)) | 2106 | if (!writeManifest(zf)) |
817 | 2105 | { | 2107 | { |
818 | 2106 | g_warning("Failed to write manifest"); | 2108 | g_warning("Failed to write manifest"); |
819 | 2109 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
820 | 2107 | return; | 2110 | return; |
821 | 2108 | } | 2111 | } |
822 | 2109 | 2112 | ||
823 | 2110 | if (!writeContent(zf, doc->rroot)) | 2113 | if (!writeContent(zf, doc->rroot)) |
824 | 2111 | { | 2114 | { |
825 | 2112 | g_warning("Failed to write content"); | 2115 | g_warning("Failed to write content"); |
826 | 2116 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
827 | 2113 | return; | 2117 | return; |
828 | 2114 | } | 2118 | } |
829 | 2115 | 2119 | ||
830 | 2116 | if (!writeMeta(zf)) | 2120 | if (!writeMeta(zf)) |
831 | 2117 | { | 2121 | { |
832 | 2118 | g_warning("Failed to write metafile"); | 2122 | g_warning("Failed to write metafile"); |
833 | 2123 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
834 | 2119 | return; | 2124 | return; |
835 | 2120 | } | 2125 | } |
836 | 2121 | 2126 | ||
837 | 2122 | if (!zf.writeFile(filename)) | 2127 | if (!zf.writeFile(filename)) |
838 | 2123 | { | 2128 | { |
839 | 2129 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
840 | 2124 | return; | 2130 | return; |
841 | 2125 | } | 2131 | } |
842 | 2132 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
843 | 2126 | } | 2133 | } |
844 | 2127 | 2134 | ||
845 | 2128 | 2135 | ||
846 | 2129 | 2136 | ||
847 | === modified file 'src/extension/internal/pov-out.cpp' | |||
848 | --- src/extension/internal/pov-out.cpp 2016-07-14 11:17:21 +0000 | |||
849 | +++ src/extension/internal/pov-out.cpp 2017-01-24 17:53:20 +0000 | |||
850 | @@ -616,11 +616,13 @@ | |||
851 | 616 | void PovOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) | 616 | void PovOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) |
852 | 617 | { | 617 | { |
853 | 618 | reset(); | 618 | reset(); |
855 | 619 | 619 | doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; | |
856 | 620 | doc->ensureUpToDate(); | ||
857 | 620 | //###### SAVE IN POV FORMAT TO BUFFER | 621 | //###### SAVE IN POV FORMAT TO BUFFER |
858 | 621 | //# Lets do the curves first, to get the stats | 622 | //# Lets do the curves first, to get the stats |
859 | 622 | if (!doTree(doc)) | 623 | if (!doTree(doc)) |
860 | 623 | { | 624 | { |
861 | 625 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
862 | 624 | err("Could not output curves for %s", filename_utf8); | 626 | err("Could not output curves for %s", filename_utf8); |
863 | 625 | return; | 627 | return; |
864 | 626 | } | 628 | } |
865 | @@ -630,6 +632,7 @@ | |||
866 | 630 | 632 | ||
867 | 631 | if (!doHeader()) | 633 | if (!doHeader()) |
868 | 632 | { | 634 | { |
869 | 635 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
870 | 633 | err("Could not write header for %s", filename_utf8); | 636 | err("Could not write header for %s", filename_utf8); |
871 | 634 | return; | 637 | return; |
872 | 635 | } | 638 | } |
873 | @@ -638,6 +641,7 @@ | |||
874 | 638 | 641 | ||
875 | 639 | if (!doTail()) | 642 | if (!doTail()) |
876 | 640 | { | 643 | { |
877 | 644 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
878 | 641 | err("Could not write footer for %s", filename_utf8); | 645 | err("Could not write footer for %s", filename_utf8); |
879 | 642 | return; | 646 | return; |
880 | 643 | } | 647 | } |
881 | @@ -648,9 +652,11 @@ | |||
882 | 648 | //###### WRITE TO FILE | 652 | //###### WRITE TO FILE |
883 | 649 | Inkscape::IO::dump_fopen_call(filename_utf8, "L"); | 653 | Inkscape::IO::dump_fopen_call(filename_utf8, "L"); |
884 | 650 | FILE *f = Inkscape::IO::fopen_utf8name(filename_utf8, "w"); | 654 | FILE *f = Inkscape::IO::fopen_utf8name(filename_utf8, "w"); |
886 | 651 | if (!f) | 655 | if (!f){ |
887 | 656 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
888 | 652 | return; | 657 | return; |
890 | 653 | 658 | } | |
891 | 659 | |||
892 | 654 | for (String::iterator iter = outbuf.begin() ; iter!=outbuf.end(); ++iter) | 660 | for (String::iterator iter = outbuf.begin() ; iter!=outbuf.end(); ++iter) |
893 | 655 | { | 661 | { |
894 | 656 | int ch = *iter; | 662 | int ch = *iter; |
895 | @@ -658,6 +664,7 @@ | |||
896 | 658 | } | 664 | } |
897 | 659 | 665 | ||
898 | 660 | fclose(f); | 666 | fclose(f); |
899 | 667 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
900 | 661 | } | 668 | } |
901 | 662 | 669 | ||
902 | 663 | 670 | ||
903 | 664 | 671 | ||
904 | === modified file 'src/extension/internal/wmf-inout.cpp' | |||
905 | --- src/extension/internal/wmf-inout.cpp 2016-06-11 17:25:23 +0000 | |||
906 | +++ src/extension/internal/wmf-inout.cpp 2017-01-24 17:53:20 +0000 | |||
907 | @@ -95,7 +95,7 @@ | |||
908 | 95 | SPPrintContext context; | 95 | SPPrintContext context; |
909 | 96 | const gchar *oldconst; | 96 | const gchar *oldconst; |
910 | 97 | gchar *oldoutput; | 97 | gchar *oldoutput; |
912 | 98 | 98 | doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; | |
913 | 99 | doc->ensureUpToDate(); | 99 | doc->ensureUpToDate(); |
914 | 100 | 100 | ||
915 | 101 | mod = Inkscape::Extension::get_print(PRINT_WMF); | 101 | mod = Inkscape::Extension::get_print(PRINT_WMF); |
916 | @@ -115,6 +115,7 @@ | |||
917 | 115 | /* Print document */ | 115 | /* Print document */ |
918 | 116 | if (mod->begin(doc)) { | 116 | if (mod->begin(doc)) { |
919 | 117 | g_free(oldoutput); | 117 | g_free(oldoutput); |
920 | 118 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
921 | 118 | throw Inkscape::Extension::Output::save_failed(); | 119 | throw Inkscape::Extension::Output::save_failed(); |
922 | 119 | } | 120 | } |
923 | 120 | mod->base->invoke_print(&context); | 121 | mod->base->invoke_print(&context); |
924 | @@ -127,7 +128,7 @@ | |||
925 | 127 | 128 | ||
926 | 128 | mod->set_param_string("destination", oldoutput); | 129 | mod->set_param_string("destination", oldoutput); |
927 | 129 | g_free(oldoutput); | 130 | g_free(oldoutput); |
929 | 130 | 131 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | |
930 | 131 | return; | 132 | return; |
931 | 132 | } | 133 | } |
932 | 133 | 134 | ||
933 | @@ -135,6 +136,8 @@ | |||
934 | 135 | void | 136 | void |
935 | 136 | Wmf::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filename) | 137 | Wmf::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filename) |
936 | 137 | { | 138 | { |
937 | 139 | doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; | ||
938 | 140 | doc->ensureUpToDate(); | ||
939 | 138 | Inkscape::Extension::Extension * ext; | 141 | Inkscape::Extension::Extension * ext; |
940 | 139 | 142 | ||
941 | 140 | ext = Inkscape::Extension::db.get(PRINT_WMF); | 143 | ext = Inkscape::Extension::db.get(PRINT_WMF); |
942 | 141 | 144 | ||
943 | === modified file 'src/file.cpp' | |||
944 | --- src/file.cpp 2017-01-24 00:39:06 +0000 | |||
945 | +++ src/file.cpp 2017-01-24 17:53:20 +0000 | |||
946 | @@ -293,10 +293,12 @@ | |||
947 | 293 | bool replace_empty) | 293 | bool replace_empty) |
948 | 294 | { | 294 | { |
949 | 295 | SPDesktop *desktop = SP_ACTIVE_DESKTOP; | 295 | SPDesktop *desktop = SP_ACTIVE_DESKTOP; |
950 | 296 | Inkscape::Display::TemporaryItem *page_border_rotated = NULL; | ||
951 | 296 | if (desktop) { | 297 | if (desktop) { |
952 | 297 | desktop->setWaitingCursor(); | 298 | desktop->setWaitingCursor(); |
953 | 299 | page_border_rotated = sp_document_namedview(desktop->getDocument(), NULL)->page_border_rotated; | ||
954 | 298 | } | 300 | } |
956 | 299 | 301 | ||
957 | 300 | SPDocument *doc = NULL; | 302 | SPDocument *doc = NULL; |
958 | 301 | bool cancelled = false; | 303 | bool cancelled = false; |
959 | 302 | try { | 304 | try { |
960 | @@ -315,7 +317,6 @@ | |||
961 | 315 | } | 317 | } |
962 | 316 | 318 | ||
963 | 317 | if (doc) { | 319 | if (doc) { |
964 | 318 | |||
965 | 319 | SPDocument *existing = desktop ? desktop->getDocument() : NULL; | 320 | SPDocument *existing = desktop ? desktop->getDocument() : NULL; |
966 | 320 | 321 | ||
967 | 321 | if (existing && existing->virgin && replace_empty) { | 322 | if (existing && existing->virgin && replace_empty) { |
968 | @@ -323,6 +324,7 @@ | |||
969 | 323 | doc->ensureUpToDate(); // TODO this will trigger broken link warnings, etc. | 324 | doc->ensureUpToDate(); // TODO this will trigger broken link warnings, etc. |
970 | 324 | desktop->change_document(doc); | 325 | desktop->change_document(doc); |
971 | 325 | doc->emitResizedSignal(doc->getWidth().value("px"), doc->getHeight().value("px")); | 326 | doc->emitResizedSignal(doc->getWidth().value("px"), doc->getHeight().value("px")); |
972 | 327 | desktop->remove_temporary_canvasitem(page_border_rotated); | ||
973 | 326 | } else { | 328 | } else { |
974 | 327 | // create a whole new desktop and window | 329 | // create a whole new desktop and window |
975 | 328 | SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); // TODO this will trigger broken link warnings, etc. | 330 | SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); // TODO this will trigger broken link warnings, etc. |
976 | 329 | 331 | ||
977 | === modified file 'src/print.cpp' | |||
978 | --- src/print.cpp 2012-02-27 23:49:20 +0000 | |||
979 | +++ src/print.cpp 2017-01-24 17:53:20 +0000 | |||
980 | @@ -79,6 +79,7 @@ | |||
981 | 79 | void | 79 | void |
982 | 80 | sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) | 80 | sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) |
983 | 81 | { | 81 | { |
984 | 82 | doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; | ||
985 | 82 | doc->ensureUpToDate(); | 83 | doc->ensureUpToDate(); |
986 | 83 | 84 | ||
987 | 84 | // Build arena | 85 | // Build arena |
988 | @@ -88,6 +89,7 @@ | |||
989 | 88 | Inkscape::UI::Dialog::Print printop(doc,base); | 89 | Inkscape::UI::Dialog::Print printop(doc,base); |
990 | 89 | Gtk::PrintOperationResult res = printop.run(Gtk::PRINT_OPERATION_ACTION_PRINT_DIALOG, parentWindow); | 90 | Gtk::PrintOperationResult res = printop.run(Gtk::PRINT_OPERATION_ACTION_PRINT_DIALOG, parentWindow); |
991 | 90 | (void)res; // TODO handle this | 91 | (void)res; // TODO handle this |
992 | 92 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
993 | 91 | } | 93 | } |
994 | 92 | 94 | ||
995 | 93 | void sp_print_document_to_file(SPDocument *doc, gchar const *filename) | 95 | void sp_print_document_to_file(SPDocument *doc, gchar const *filename) |
996 | 94 | 96 | ||
997 | === modified file 'src/sp-namedview.cpp' | |||
998 | --- src/sp-namedview.cpp 2016-08-03 14:56:48 +0000 | |||
999 | +++ src/sp-namedview.cpp 2017-01-24 17:53:20 +0000 | |||
1000 | @@ -19,7 +19,12 @@ | |||
1001 | 19 | #include "event-log.h" | 19 | #include "event-log.h" |
1002 | 20 | #include <2geom/transforms.h> | 20 | #include <2geom/transforms.h> |
1003 | 21 | 21 | ||
1004 | 22 | #include "display/sp-canvas-group.h" | ||
1005 | 23 | #include "display/canvas-bpath.h" | ||
1006 | 24 | #include "display/canvas-temporary-item.h" | ||
1007 | 25 | #include "display/canvas-temporary-item-list.h" | ||
1008 | 22 | #include "display/canvas-grid.h" | 26 | #include "display/canvas-grid.h" |
1009 | 27 | #include "display/curve.h" | ||
1010 | 23 | #include "util/units.h" | 28 | #include "util/units.h" |
1011 | 24 | #include "svg/svg-color.h" | 29 | #include "svg/svg-color.h" |
1012 | 25 | #include "xml/repr.h" | 30 | #include "xml/repr.h" |
1013 | @@ -29,12 +34,15 @@ | |||
1014 | 29 | #include "desktop-events.h" | 34 | #include "desktop-events.h" |
1015 | 30 | 35 | ||
1016 | 31 | #include "sp-guide.h" | 36 | #include "sp-guide.h" |
1017 | 37 | #include "sp-root.h" | ||
1018 | 32 | #include "sp-item-group.h" | 38 | #include "sp-item-group.h" |
1019 | 33 | #include "sp-namedview.h" | 39 | #include "sp-namedview.h" |
1020 | 34 | #include "preferences.h" | 40 | #include "preferences.h" |
1021 | 35 | #include "desktop.h" | 41 | #include "desktop.h" |
1022 | 42 | #include "selection.h" | ||
1023 | 43 | #include "object-set.h" | ||
1024 | 44 | #include "inkscape.h" | ||
1025 | 36 | #include "conn-avoid-ref.h" // for defaultConnSpacing. | 45 | #include "conn-avoid-ref.h" // for defaultConnSpacing. |
1026 | 37 | #include "sp-root.h" | ||
1027 | 38 | #include <gtkmm/window.h> | 46 | #include <gtkmm/window.h> |
1028 | 39 | 47 | ||
1029 | 40 | using Inkscape::DocumentUndo; | 48 | using Inkscape::DocumentUndo; |
1030 | @@ -72,6 +80,7 @@ | |||
1031 | 72 | this->pagecolor = 0; | 80 | this->pagecolor = 0; |
1032 | 73 | this->cx = 0; | 81 | this->cx = 0; |
1033 | 74 | this->pageshadow = 0; | 82 | this->pageshadow = 0; |
1034 | 83 | this->document_rotation = 0; | ||
1035 | 75 | this->window_width = 0; | 84 | this->window_width = 0; |
1036 | 76 | this->window_height = 0; | 85 | this->window_height = 0; |
1037 | 77 | this->window_maximized = 0; | 86 | this->window_maximized = 0; |
1038 | @@ -92,9 +101,13 @@ | |||
1039 | 92 | this->default_layer_id = 0; | 101 | this->default_layer_id = 0; |
1040 | 93 | 102 | ||
1041 | 94 | this->connector_spacing = defaultConnSpacing; | 103 | this->connector_spacing = defaultConnSpacing; |
1042 | 104 | this->page_border_rotated = NULL; | ||
1043 | 95 | } | 105 | } |
1044 | 96 | 106 | ||
1045 | 97 | SPNamedView::~SPNamedView() { | 107 | SPNamedView::~SPNamedView() { |
1046 | 108 | if(!this->getViewList().empty()) { // >0 Desktops | ||
1047 | 109 | this->getViewList()[0]->remove_temporary_canvasitem(this->page_border_rotated); | ||
1048 | 110 | } | ||
1049 | 98 | } | 111 | } |
1050 | 99 | 112 | ||
1051 | 100 | static void sp_namedview_generate_old_grid(SPNamedView * /*nv*/, SPDocument *document, Inkscape::XML::Node *repr) { | 113 | static void sp_namedview_generate_old_grid(SPNamedView * /*nv*/, SPDocument *document, Inkscape::XML::Node *repr) { |
1052 | @@ -212,6 +225,7 @@ | |||
1053 | 212 | this->readAttr( "inkscape:zoom" ); | 225 | this->readAttr( "inkscape:zoom" ); |
1054 | 213 | this->readAttr( "inkscape:cx" ); | 226 | this->readAttr( "inkscape:cx" ); |
1055 | 214 | this->readAttr( "inkscape:cy" ); | 227 | this->readAttr( "inkscape:cy" ); |
1056 | 228 | this->readAttr( "inkscape:document-rotation" ); | ||
1057 | 215 | this->readAttr( "inkscape:window-width" ); | 229 | this->readAttr( "inkscape:window-width" ); |
1058 | 216 | this->readAttr( "inkscape:window-height" ); | 230 | this->readAttr( "inkscape:window-height" ); |
1059 | 217 | this->readAttr( "inkscape:window-x" ); | 231 | this->readAttr( "inkscape:window-x" ); |
1060 | @@ -409,6 +423,11 @@ | |||
1061 | 409 | this->cy = value ? g_ascii_strtod(value, NULL) : HUGE_VAL; // HUGE_VAL means not set | 423 | this->cy = value ? g_ascii_strtod(value, NULL) : HUGE_VAL; // HUGE_VAL means not set |
1062 | 410 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); | 424 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); |
1063 | 411 | break; | 425 | break; |
1064 | 426 | case SP_ATTR_INKSCAPE_DOCUMENT_ROTATION: | ||
1065 | 427 | this->document_rotation = value ? g_ascii_strtod(value, NULL) : 0; | ||
1066 | 428 | sp_namedview_set_document_rotation(this); | ||
1067 | 429 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); | ||
1068 | 430 | break; | ||
1069 | 412 | case SP_ATTR_INKSCAPE_WINDOW_WIDTH: | 431 | case SP_ATTR_INKSCAPE_WINDOW_WIDTH: |
1070 | 413 | this->window_width = value? atoi(value) : -1; // -1 means not set | 432 | this->window_width = value? atoi(value) : -1; // -1 means not set |
1071 | 414 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); | 433 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); |
1072 | @@ -939,6 +958,81 @@ | |||
1073 | 939 | } | 958 | } |
1074 | 940 | } | 959 | } |
1075 | 941 | 960 | ||
1076 | 961 | void sp_namedview_doc_rotate_guides(SPNamedView *nv) | ||
1077 | 962 | { | ||
1078 | 963 | bool saved = DocumentUndo::getUndoSensitive(nv->document); | ||
1079 | 964 | DocumentUndo::setUndoSensitive(nv->document, false); | ||
1080 | 965 | SPRoot * root = nv->document->getRoot(); | ||
1081 | 966 | Geom::Point page_center = root->viewBox.midpoint() * root->vbt; | ||
1082 | 967 | Geom::Affine rot = Geom::identity(); | ||
1083 | 968 | rot *= Geom::Translate(page_center).inverse(); | ||
1084 | 969 | rot *= Geom::Rotate(Geom::rad_from_deg((nv->document_rotation - root->get_rotation()) * -1)); | ||
1085 | 970 | rot *= Geom::Translate(page_center); | ||
1086 | 971 | for(std::vector<SPGuide *>::iterator it=nv->guides.begin();it!=nv->guides.end();++it ) { | ||
1087 | 972 | Geom::Point const on_line = (*it)->getPoint() * rot ; | ||
1088 | 973 | (*it)->moveto(on_line, true); | ||
1089 | 974 | Geom::Affine rot_normal_affine = Geom::Rotate(Geom::rad_from_deg((nv->document_rotation - root->get_rotation()) * -1)); | ||
1090 | 975 | Geom::Point const rot_normal = (*it)->getNormal() * rot_normal_affine; | ||
1091 | 976 | (*it)->set_normal(rot_normal, true); | ||
1092 | 977 | } | ||
1093 | 978 | DocumentUndo::setUndoSensitive(nv->document, saved); | ||
1094 | 979 | nv->document->setModifiedSinceSave(); | ||
1095 | 980 | } | ||
1096 | 981 | |||
1097 | 982 | void sp_namedview_set_document_rotation(SPNamedView *nv) | ||
1098 | 983 | { | ||
1099 | 984 | if ( nv->document->getRoot()->get_rotation() == nv->document_rotation) return; | ||
1100 | 985 | if(!nv->getViewList().empty()) { // >0 Desktops | ||
1101 | 986 | SPDesktop *desktop = nv->getViewList()[0]; | ||
1102 | 987 | desktop->remove_temporary_canvasitem(nv->page_border_rotated); | ||
1103 | 988 | SPRoot * root = nv->document->getRoot(); | ||
1104 | 989 | SPCurve *c = new SPCurve(); | ||
1105 | 990 | c->moveto(root->viewBox.min()); | ||
1106 | 991 | c->lineto(Geom::Point(root->viewBox.max()[Geom::X],root->viewBox.min()[Geom::Y])); | ||
1107 | 992 | c->lineto(Geom::Point(root->viewBox.max()[Geom::X],root->viewBox.max()[Geom::Y])); | ||
1108 | 993 | c->lineto(Geom::Point(root->viewBox.min()[Geom::X],root->viewBox.max()[Geom::Y])); | ||
1109 | 994 | c->closepath(); | ||
1110 | 995 | Geom::Point page_center = root->viewBox.midpoint(); | ||
1111 | 996 | Geom::PathVector const box = c->get_pathvector(); | ||
1112 | 997 | Geom::Affine rot = Geom::identity(); | ||
1113 | 998 | rot *= Geom::Translate(page_center).inverse(); | ||
1114 | 999 | rot *= Geom::Rotate(Geom::rad_from_deg(nv->document_rotation * -1)); | ||
1115 | 1000 | rot *= Geom::Translate(page_center); | ||
1116 | 1001 | if (nv->document_rotation) { | ||
1117 | 1002 | SPCanvasItem *canvas_border = sp_canvas_bpath_new(desktop->getTempGroup(), c, true); | ||
1118 | 1003 | sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_border), 0xFF00009A, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); | ||
1119 | 1004 | sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_border), 0, SP_WIND_RULE_NONZERO); | ||
1120 | 1005 | sp_canvas_item_affine_absolute(canvas_border, rot * root->vbt); | ||
1121 | 1006 | nv->page_border_rotated = desktop->add_temporary_canvasitem(canvas_border, 0); | ||
1122 | 1007 | } | ||
1123 | 1008 | sp_namedview_doc_rotate_guides(nv); | ||
1124 | 1009 | nv->document->getRoot()->set_rotation(nv->document_rotation); | ||
1125 | 1010 | c->unref(); | ||
1126 | 1011 | } | ||
1127 | 1012 | if (nv->document_rotation) { | ||
1128 | 1013 | nv->showborder = FALSE; | ||
1129 | 1014 | } else { | ||
1130 | 1015 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | ||
1131 | 1016 | nv->showborder = prefs->getBool("/template/base/showborder", 1.0); | ||
1132 | 1017 | } | ||
1133 | 1018 | |||
1134 | 1019 | SPDesktop * desktop = SP_ACTIVE_DESKTOP; | ||
1135 | 1020 | if (desktop) { | ||
1136 | 1021 | //TODO: Remove knots of shapes on selected items | ||
1137 | 1022 | // Inkscape::Selection * sel = desktop->getSelection(); | ||
1138 | 1023 | // std::vector<SPItem*> il(sel->items().begin(), sel->items().end()); | ||
1139 | 1024 | // for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ | ||
1140 | 1025 | // SPItem *item = *l; | ||
1141 | 1026 | // sel->remove(item->getRepr()); | ||
1142 | 1027 | // sel->add(item->getRepr()); | ||
1143 | 1028 | // } | ||
1144 | 1029 | SPObject *updated = desktop->getDocument()->getRoot(); | ||
1145 | 1030 | if (updated) { | ||
1146 | 1031 | updated->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); | ||
1147 | 1032 | } | ||
1148 | 1033 | } | ||
1149 | 1034 | } | ||
1150 | 1035 | |||
1151 | 942 | static void sp_namedview_show_single_guide(SPGuide* guide, bool show) | 1036 | static void sp_namedview_show_single_guide(SPGuide* guide, bool show) |
1152 | 943 | { | 1037 | { |
1153 | 944 | if (show) { | 1038 | if (show) { |
1154 | @@ -953,6 +1047,8 @@ | |||
1155 | 953 | guide->set_locked(locked, true); | 1047 | guide->set_locked(locked, true); |
1156 | 954 | } | 1048 | } |
1157 | 955 | 1049 | ||
1158 | 1050 | |||
1159 | 1051 | |||
1160 | 956 | void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr) | 1052 | void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr) |
1161 | 957 | { | 1053 | { |
1162 | 958 | unsigned int v; | 1054 | unsigned int v; |
1163 | 959 | 1055 | ||
1164 | === modified file 'src/sp-namedview.h' | |||
1165 | --- src/sp-namedview.h 2016-06-08 08:35:36 +0000 | |||
1166 | +++ src/sp-namedview.h 2017-01-24 17:53:20 +0000 | |||
1167 | @@ -21,6 +21,7 @@ | |||
1168 | 21 | #include "snap.h" | 21 | #include "snap.h" |
1169 | 22 | #include "document.h" | 22 | #include "document.h" |
1170 | 23 | #include "util/units.h" | 23 | #include "util/units.h" |
1171 | 24 | #include "display/sp-canvas.h" | ||
1172 | 24 | #include <vector> | 25 | #include <vector> |
1173 | 25 | 26 | ||
1174 | 26 | namespace Inkscape { | 27 | namespace Inkscape { |
1175 | @@ -28,6 +29,9 @@ | |||
1176 | 28 | namespace Util { | 29 | namespace Util { |
1177 | 29 | class Unit; | 30 | class Unit; |
1178 | 30 | } | 31 | } |
1179 | 32 | namespace Display { | ||
1180 | 33 | class TemporaryItem; | ||
1181 | 34 | } | ||
1182 | 31 | } | 35 | } |
1183 | 32 | 36 | ||
1184 | 33 | typedef unsigned int guint32; | 37 | typedef unsigned int guint32; |
1185 | @@ -38,7 +42,7 @@ | |||
1186 | 38 | SP_BORDER_LAYER_TOP | 42 | SP_BORDER_LAYER_TOP |
1187 | 39 | }; | 43 | }; |
1188 | 40 | 44 | ||
1190 | 41 | class SPNamedView : public SPObjectGroup { | 45 | class SPNamedView : public SPObjectGroup{ |
1191 | 42 | public: | 46 | public: |
1192 | 43 | SPNamedView(); | 47 | SPNamedView(); |
1193 | 44 | virtual ~SPNamedView(); | 48 | virtual ~SPNamedView(); |
1194 | @@ -54,6 +58,7 @@ | |||
1195 | 54 | double zoom; | 58 | double zoom; |
1196 | 55 | double cx; | 59 | double cx; |
1197 | 56 | double cy; | 60 | double cy; |
1198 | 61 | double document_rotation; | ||
1199 | 57 | int window_width; | 62 | int window_width; |
1200 | 58 | int window_height; | 63 | int window_height; |
1201 | 59 | int window_x; | 64 | int window_x; |
1202 | @@ -66,7 +71,7 @@ | |||
1203 | 66 | 71 | ||
1204 | 67 | Inkscape::Util::Unit const *display_units; // Units used for the UI (*not* the same as units of SVG coordinates) | 72 | Inkscape::Util::Unit const *display_units; // Units used for the UI (*not* the same as units of SVG coordinates) |
1205 | 68 | Inkscape::Util::Unit const *page_size_units; // Only used in "Custom size" part of Document Properties dialog | 73 | Inkscape::Util::Unit const *page_size_units; // Only used in "Custom size" part of Document Properties dialog |
1207 | 69 | 74 | Inkscape::Display::TemporaryItem *page_border_rotated; | |
1208 | 70 | GQuark default_layer_id; | 75 | GQuark default_layer_id; |
1209 | 71 | 76 | ||
1210 | 72 | double connector_spacing; | 77 | double connector_spacing; |
1211 | @@ -121,7 +126,7 @@ | |||
1212 | 121 | void sp_namedview_window_from_document(SPDesktop *desktop); | 126 | void sp_namedview_window_from_document(SPDesktop *desktop); |
1213 | 122 | void sp_namedview_document_from_window(SPDesktop *desktop); | 127 | void sp_namedview_document_from_window(SPDesktop *desktop); |
1214 | 123 | void sp_namedview_update_layers_from_document (SPDesktop *desktop); | 128 | void sp_namedview_update_layers_from_document (SPDesktop *desktop); |
1216 | 124 | 129 | void sp_namedview_set_document_rotation(SPNamedView *nv); | |
1217 | 125 | void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr); | 130 | void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr); |
1218 | 126 | void sp_namedview_guides_toggle_lock(SPDocument *doc, Inkscape::XML::Node *repr); | 131 | void sp_namedview_guides_toggle_lock(SPDocument *doc, Inkscape::XML::Node *repr); |
1219 | 127 | void sp_namedview_show_grids(SPNamedView *namedview, bool show, bool dirty_document); | 132 | void sp_namedview_show_grids(SPNamedView *namedview, bool show, bool dirty_document); |
1220 | 128 | 133 | ||
1221 | === modified file 'src/ui/dialog/export.cpp' | |||
1222 | --- src/ui/dialog/export.cpp 2017-01-04 23:08:02 +0000 | |||
1223 | +++ src/ui/dialog/export.cpp 2017-01-24 17:53:20 +0000 | |||
1224 | @@ -978,7 +978,9 @@ | |||
1225 | 978 | 978 | ||
1226 | 979 | SPNamedView *nv = desktop->getNamedView(); | 979 | SPNamedView *nv = desktop->getNamedView(); |
1227 | 980 | SPDocument *doc = desktop->getDocument(); | 980 | SPDocument *doc = desktop->getDocument(); |
1229 | 981 | 981 | Geom::Affine rot = doc->getRoot()->c2p; | |
1230 | 982 | doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; | ||
1231 | 983 | doc->ensureUpToDate(); | ||
1232 | 982 | bool exportSuccessful = false; | 984 | bool exportSuccessful = false; |
1233 | 983 | 985 | ||
1234 | 984 | bool hide = hide_export.get_active (); | 986 | bool hide = hide_export.get_active (); |
1235 | @@ -1003,6 +1005,7 @@ | |||
1236 | 1003 | 1005 | ||
1237 | 1004 | if (num < 1) { | 1006 | if (num < 1) { |
1238 | 1005 | desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No items selected.")); | 1007 | desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No items selected.")); |
1239 | 1008 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
1240 | 1006 | return; | 1009 | return; |
1241 | 1007 | } | 1010 | } |
1242 | 1008 | 1011 | ||
1243 | @@ -1094,6 +1097,7 @@ | |||
1244 | 1094 | if (filename.empty()) { | 1097 | if (filename.empty()) { |
1245 | 1095 | desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("You have to enter a filename.")); | 1098 | desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("You have to enter a filename.")); |
1246 | 1096 | sp_ui_error_dialog(_("You have to enter a filename")); | 1099 | sp_ui_error_dialog(_("You have to enter a filename")); |
1247 | 1100 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
1248 | 1097 | return; | 1101 | return; |
1249 | 1098 | } | 1102 | } |
1250 | 1099 | 1103 | ||
1251 | @@ -1110,6 +1114,7 @@ | |||
1252 | 1110 | if (!((x1 > x0) && (y1 > y0) && (width > 0) && (height > 0))) { | 1114 | if (!((x1 > x0) && (y1 > y0) && (width > 0) && (height > 0))) { |
1253 | 1111 | desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The chosen area to be exported is invalid.")); | 1115 | desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The chosen area to be exported is invalid.")); |
1254 | 1112 | sp_ui_error_dialog(_("The chosen area to be exported is invalid")); | 1116 | sp_ui_error_dialog(_("The chosen area to be exported is invalid")); |
1255 | 1117 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
1256 | 1113 | return; | 1118 | return; |
1257 | 1114 | } | 1119 | } |
1258 | 1115 | 1120 | ||
1259 | @@ -1132,6 +1137,7 @@ | |||
1260 | 1132 | 1137 | ||
1261 | 1133 | g_free(safeDir); | 1138 | g_free(safeDir); |
1262 | 1134 | g_free(error); | 1139 | g_free(error); |
1263 | 1140 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
1264 | 1135 | return; | 1141 | return; |
1265 | 1136 | } | 1142 | } |
1266 | 1137 | 1143 | ||
1267 | @@ -1281,6 +1287,7 @@ | |||
1268 | 1281 | } | 1287 | } |
1269 | 1282 | } | 1288 | } |
1270 | 1283 | } | 1289 | } |
1271 | 1290 | doc->getRoot()->c2p *= doc->getRoot()->rotation; | ||
1272 | 1284 | } // end of sp_export_export_clicked() | 1291 | } // end of sp_export_export_clicked() |
1273 | 1285 | 1292 | ||
1274 | 1286 | /// Called when Browse button is clicked | 1293 | /// Called when Browse button is clicked |
1275 | 1287 | 1294 | ||
1276 | === modified file 'src/ui/tools/tool-base.cpp' | |||
1277 | --- src/ui/tools/tool-base.cpp 2016-08-09 09:33:34 +0000 | |||
1278 | +++ src/ui/tools/tool-base.cpp 2017-01-24 17:53:20 +0000 | |||
1279 | @@ -94,6 +94,7 @@ | |||
1280 | 94 | , _grdrag(NULL) | 94 | , _grdrag(NULL) |
1281 | 95 | , shape_editor(NULL) | 95 | , shape_editor(NULL) |
1282 | 96 | , space_panning(false) | 96 | , space_panning(false) |
1283 | 97 | , rotating_mode(false) | ||
1284 | 97 | , _delayed_snap_event(NULL) | 98 | , _delayed_snap_event(NULL) |
1285 | 98 | , _dse_callback_in_process(false) | 99 | , _dse_callback_in_process(false) |
1286 | 99 | , desktop(NULL) | 100 | , desktop(NULL) |
1287 | @@ -327,99 +328,130 @@ | |||
1288 | 327 | static unsigned int panning = 0; | 328 | static unsigned int panning = 0; |
1289 | 328 | static unsigned int panning_cursor = 0; | 329 | static unsigned int panning_cursor = 0; |
1290 | 329 | static unsigned int zoom_rb = 0; | 330 | static unsigned int zoom_rb = 0; |
1291 | 331 | static double angle = 0; | ||
1292 | 330 | 332 | ||
1293 | 331 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 333 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
1294 | 332 | 334 | ||
1295 | 333 | /// @todo REmove redundant /value in preference keys | 335 | /// @todo REmove redundant /value in preference keys |
1296 | 334 | tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); | 336 | tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); |
1297 | 335 | bool allow_panning = prefs->getBool("/options/spacebarpans/value"); | 337 | bool allow_panning = prefs->getBool("/options/spacebarpans/value"); |
1298 | 338 | int rotation_snap = 180.0/prefs->getInt("/options/rotationsnapsperpi/value", 12); | ||
1299 | 336 | gint ret = FALSE; | 339 | gint ret = FALSE; |
1300 | 337 | 340 | ||
1301 | 338 | switch (event->type) { | 341 | switch (event->type) { |
1386 | 339 | case GDK_2BUTTON_PRESS: | 342 | case GDK_2BUTTON_PRESS: |
1387 | 340 | if (panning) { | 343 | if (panning) { |
1388 | 341 | panning = 0; | 344 | panning = 0; |
1389 | 342 | sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); | 345 | sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); |
1390 | 343 | ret = TRUE; | 346 | ret = TRUE; |
1391 | 344 | } else { | 347 | } else { |
1392 | 345 | /* sp_desktop_dialog(); */ | 348 | /* sp_desktop_dialog(); */ |
1393 | 346 | } | 349 | } |
1394 | 347 | break; | 350 | break; |
1395 | 348 | 351 | ||
1396 | 349 | case GDK_BUTTON_PRESS: | 352 | case GDK_BUTTON_PRESS: |
1397 | 350 | // save drag origin | 353 | // save drag origin |
1398 | 351 | xp = (gint) event->button.x; | 354 | xp = (gint) event->button.x; |
1399 | 352 | yp = (gint) event->button.y; | 355 | yp = (gint) event->button.y; |
1400 | 353 | within_tolerance = true; | 356 | within_tolerance = true; |
1401 | 354 | 357 | ||
1402 | 355 | button_w = Geom::Point(event->button.x, event->button.y); | 358 | button_w = Geom::Point(event->button.x, event->button.y); |
1403 | 356 | 359 | switch (event->button.button) { | |
1404 | 357 | switch (event->button.button) { | 360 | case 1: |
1405 | 358 | case 1: | 361 | if (this->space_panning) { |
1406 | 359 | if (this->space_panning) { | 362 | // When starting panning, make sure there are no snap events pending because these might disable the panning again |
1407 | 360 | // When starting panning, make sure there are no snap events pending because these might disable the panning again | 363 | if (_uses_snap) { |
1408 | 361 | if (_uses_snap) { | 364 | sp_event_context_discard_delayed_snap_event(this); |
1409 | 362 | sp_event_context_discard_delayed_snap_event(this); | 365 | } |
1410 | 363 | } | 366 | panning = 1; |
1411 | 364 | panning = 1; | 367 | |
1412 | 365 | 368 | sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), | |
1413 | 366 | sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), | 369 | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK |
1414 | 367 | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | 370 | | GDK_POINTER_MOTION_MASK |
1415 | 368 | | GDK_POINTER_MOTION_MASK | 371 | | GDK_POINTER_MOTION_HINT_MASK, NULL, |
1416 | 369 | | GDK_POINTER_MOTION_HINT_MASK, NULL, | 372 | event->button.time - 1); |
1417 | 370 | event->button.time - 1); | 373 | |
1418 | 371 | 374 | ret = TRUE; | |
1419 | 372 | ret = TRUE; | 375 | } |
1420 | 373 | } | 376 | desktop->canvas->clearRotateTo(); |
1421 | 374 | break; | 377 | this->rotating_mode = false; |
1422 | 375 | 378 | break; | |
1423 | 376 | case 2: | 379 | |
1424 | 377 | if (event->button.state & GDK_SHIFT_MASK) { | 380 | case 2: |
1425 | 378 | zoom_rb = 2; | 381 | if (event->button.state & GDK_CONTROL_MASK) { |
1426 | 379 | } else { | 382 | sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); |
1427 | 380 | // When starting panning, make sure there are no snap events pending because these might disable the panning again | 383 | desktop->canvas->startRotateTo(desktop->namedview->document_rotation); |
1428 | 381 | if (_uses_snap) { | 384 | this->rotating_mode = true; |
1429 | 382 | sp_event_context_discard_delayed_snap_event(this); | 385 | this->message_context->set(Inkscape::INFORMATION_MESSAGE, |
1430 | 383 | } | 386 | _("<b>MMB + mouse move</b> to rotate canvas, use modifiers on screen to change snaps")); |
1431 | 384 | panning = 2; | 387 | } else { |
1432 | 385 | 388 | if (event->button.state & GDK_SHIFT_MASK) { | |
1433 | 386 | sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), | 389 | zoom_rb = 2; |
1434 | 387 | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | 390 | } else { |
1435 | 388 | | GDK_POINTER_MOTION_HINT_MASK, NULL, | 391 | // When starting panning, make sure there are no snap events pending because these might disable the panning again |
1436 | 389 | event->button.time - 1); | 392 | if (_uses_snap) { |
1437 | 390 | 393 | sp_event_context_discard_delayed_snap_event(this); | |
1438 | 391 | } | 394 | } |
1439 | 392 | 395 | panning = 2; | |
1440 | 393 | ret = TRUE; | 396 | |
1441 | 394 | break; | 397 | sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), |
1442 | 395 | 398 | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | |
1443 | 396 | case 3: | 399 | | GDK_POINTER_MOTION_HINT_MASK, NULL, |
1444 | 397 | if ((event->button.state & GDK_SHIFT_MASK) || (event->button.state & GDK_CONTROL_MASK)) { | 400 | event->button.time - 1); |
1445 | 398 | // When starting panning, make sure there are no snap events pending because these might disable the panning again | 401 | } |
1446 | 399 | if (_uses_snap) { | 402 | ret = TRUE; |
1447 | 400 | sp_event_context_discard_delayed_snap_event(this); | 403 | } |
1448 | 401 | } | 404 | ret = TRUE; |
1449 | 402 | panning = 3; | 405 | break; |
1450 | 403 | 406 | ||
1451 | 404 | sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), | 407 | case 3: |
1452 | 405 | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | 408 | if ((event->button.state & GDK_SHIFT_MASK) || (event->button.state & GDK_CONTROL_MASK)) { |
1453 | 406 | | GDK_POINTER_MOTION_HINT_MASK, NULL, | 409 | // When starting panning, make sure there are no snap events pending because these might disable the panning again |
1454 | 407 | event->button.time); | 410 | if (_uses_snap) { |
1455 | 408 | 411 | sp_event_context_discard_delayed_snap_event(this); | |
1456 | 409 | ret = TRUE; | 412 | } |
1457 | 410 | } else { | 413 | panning = 3; |
1458 | 411 | sp_event_root_menu_popup(desktop, NULL, event); | 414 | |
1459 | 412 | } | 415 | sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), |
1460 | 413 | break; | 416 | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK |
1461 | 414 | 417 | | GDK_POINTER_MOTION_HINT_MASK, NULL, | |
1462 | 415 | default: | 418 | event->button.time); |
1463 | 416 | break; | 419 | |
1464 | 417 | } | 420 | ret = TRUE; |
1465 | 418 | break; | 421 | } else if( !this->space_panning) { |
1466 | 419 | 422 | sp_event_root_menu_popup(desktop, NULL, event); | |
1467 | 420 | case GDK_MOTION_NOTIFY: | 423 | } |
1468 | 421 | if (panning) { | 424 | ret = TRUE; |
1469 | 422 | if (panning == 4 && !xp && !yp ) { | 425 | desktop->canvas->clearRotateTo(); |
1470 | 426 | this->rotating_mode = false; | ||
1471 | 427 | break; | ||
1472 | 428 | |||
1473 | 429 | default: | ||
1474 | 430 | break; | ||
1475 | 431 | } | ||
1476 | 432 | break; | ||
1477 | 433 | |||
1478 | 434 | case GDK_MOTION_NOTIFY: | ||
1479 | 435 | if (this->rotating_mode) { | ||
1480 | 436 | button_w = Geom::Point(event->motion.x, event->motion.y); | ||
1481 | 437 | Geom::Point const motion_dt(desktop->doc2dt(desktop->w2d(button_w))); | ||
1482 | 438 | Geom::Rect view = desktop->get_display_area(); | ||
1483 | 439 | Geom::Point view_center = desktop->doc2dt(view.midpoint()); | ||
1484 | 440 | Geom::Ray center_ray(motion_dt, view_center); | ||
1485 | 441 | angle = Geom::deg_from_rad(center_ray.angle()) - 90; | ||
1486 | 442 | if (event->motion.state & GDK_SHIFT_MASK && event->motion.state & GDK_CONTROL_MASK) { | ||
1487 | 443 | angle = 0; | ||
1488 | 444 | } else if(event->motion.state & GDK_CONTROL_MASK) { | ||
1489 | 445 | angle = floor(angle/rotation_snap) * rotation_snap; | ||
1490 | 446 | } else if (event->motion.state & GDK_SHIFT_MASK) { | ||
1491 | 447 | angle = desktop->namedview->document_rotation; | ||
1492 | 448 | } else if (event->motion.state & GDK_MOD1_MASK) { | ||
1493 | 449 | //Decimal raw angle | ||
1494 | 450 | } else { | ||
1495 | 451 | angle = floor(angle); | ||
1496 | 452 | } | ||
1497 | 453 | desktop->canvas->rotateTo(angle); | ||
1498 | 454 | } else if (panning == 4 && !xp && !yp ) { | ||
1499 | 423 | // <Space> + mouse panning started, save location and grab canvas | 455 | // <Space> + mouse panning started, save location and grab canvas |
1500 | 424 | xp = event->motion.x; | 456 | xp = event->motion.x; |
1501 | 425 | yp = event->motion.y; | 457 | yp = event->motion.y; |
1502 | @@ -431,401 +463,465 @@ | |||
1503 | 431 | | GDK_POINTER_MOTION_HINT_MASK, NULL, | 463 | | GDK_POINTER_MOTION_HINT_MASK, NULL, |
1504 | 432 | event->motion.time - 1); | 464 | event->motion.time - 1); |
1505 | 433 | } | 465 | } |
1515 | 434 | 466 | if (panning && !this->rotating_mode) { | |
1516 | 435 | if ((panning == 2 && !(event->motion.state & GDK_BUTTON2_MASK)) | 467 | if ((panning == 2 && !(event->motion.state & GDK_BUTTON2_MASK)) |
1517 | 436 | || (panning == 1 && !(event->motion.state & GDK_BUTTON1_MASK)) | 468 | || (panning == 1 && !(event->motion.state & GDK_BUTTON1_MASK)) |
1518 | 437 | || (panning == 3 && !(event->motion.state & GDK_BUTTON3_MASK))) { | 469 | || (panning == 3 && !(event->motion.state & GDK_BUTTON3_MASK))) { |
1519 | 438 | /* Gdk seems to lose button release for us sometimes :-( */ | 470 | /* Gdk seems to lose button release for us sometimes :-( */ |
1520 | 439 | panning = 0; | 471 | panning = 0; |
1521 | 440 | sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); | 472 | sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); |
1522 | 441 | ret = TRUE; | 473 | ret = TRUE; |
1523 | 442 | } else { | 474 | } else { |
1524 | 475 | if (within_tolerance && (abs((gint) event->motion.x - xp) | ||
1525 | 476 | < tolerance) && (abs((gint) event->motion.y - yp) | ||
1526 | 477 | < tolerance)) { | ||
1527 | 478 | // do not drag if we're within tolerance from origin | ||
1528 | 479 | break; | ||
1529 | 480 | } | ||
1530 | 481 | |||
1531 | 482 | // Once the user has moved farther than tolerance from | ||
1532 | 483 | // the original location (indicating they intend to move | ||
1533 | 484 | // the object, not click), then always process the motion | ||
1534 | 485 | // notify coordinates as given (no snapping back to origin) | ||
1535 | 486 | within_tolerance = false; | ||
1536 | 487 | |||
1537 | 488 | // gobble subsequent motion events to prevent "sticking" | ||
1538 | 489 | // when scrolling is slow | ||
1539 | 490 | gobble_motion_events(panning == 2 ? GDK_BUTTON2_MASK : (panning | ||
1540 | 491 | == 1 ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK)); | ||
1541 | 492 | |||
1542 | 493 | if (panning_cursor == 0) { | ||
1543 | 494 | panning_cursor = 1; | ||
1544 | 495 | this->sp_event_context_set_cursor(GDK_FLEUR); | ||
1545 | 496 | } | ||
1546 | 497 | |||
1547 | 498 | Geom::Point const motion_w(event->motion.x, event->motion.y); | ||
1548 | 499 | Geom::Point const moved_w(motion_w - button_w); | ||
1549 | 500 | this->desktop->scroll_world(moved_w, true); // we're still scrolling, do not redraw | ||
1550 | 501 | ret = TRUE; | ||
1551 | 502 | } | ||
1552 | 503 | } else if (zoom_rb) { | ||
1553 | 504 | Geom::Point const motion_w(event->motion.x, event->motion.y); | ||
1554 | 505 | Geom::Point const motion_dt(desktop->w2d(motion_w)); | ||
1555 | 506 | |||
1556 | 443 | if (within_tolerance && (abs((gint) event->motion.x - xp) | 507 | if (within_tolerance && (abs((gint) event->motion.x - xp) |
1557 | 444 | < tolerance) && (abs((gint) event->motion.y - yp) | 508 | < tolerance) && (abs((gint) event->motion.y - yp) |
1558 | 445 | < tolerance)) { | 509 | < tolerance)) { |
1561 | 446 | // do not drag if we're within tolerance from origin | 510 | break; // do not drag if we're within tolerance from origin |
1560 | 447 | break; | ||
1562 | 448 | } | 511 | } |
1563 | 449 | 512 | ||
1568 | 450 | // Once the user has moved farther than tolerance from | 513 | // Once the user has moved farther than tolerance from the original location |
1569 | 451 | // the original location (indicating they intend to move | 514 | // (indicating they intend to move the object, not click), then always process the |
1570 | 452 | // the object, not click), then always process the motion | 515 | // motion notify coordinates as given (no snapping back to origin) |
1567 | 453 | // notify coordinates as given (no snapping back to origin) | ||
1571 | 454 | within_tolerance = false; | 516 | within_tolerance = false; |
1572 | 455 | 517 | ||
1586 | 456 | // gobble subsequent motion events to prevent "sticking" | 518 | if (Inkscape::Rubberband::get(desktop)->is_started()) { |
1587 | 457 | // when scrolling is slow | 519 | Inkscape::Rubberband::get(desktop)->move(motion_dt); |
1588 | 458 | gobble_motion_events(panning == 2 ? GDK_BUTTON2_MASK : (panning | 520 | } else { |
1589 | 459 | == 1 ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK)); | 521 | Inkscape::Rubberband::get(desktop)->start(desktop, motion_dt); |
1590 | 460 | 522 | } | |
1591 | 461 | if (panning_cursor == 0) { | 523 | |
1592 | 462 | panning_cursor = 1; | 524 | if (zoom_rb == 2) { |
1593 | 463 | this->sp_event_context_set_cursor(GDK_FLEUR); | 525 | gobble_motion_events(GDK_BUTTON2_MASK); |
1594 | 464 | } | 526 | } |
1595 | 465 | 527 | } | |
1596 | 466 | Geom::Point const motion_w(event->motion.x, event->motion.y); | 528 | break; |
1597 | 467 | Geom::Point const moved_w(motion_w - button_w); | 529 | |
1598 | 468 | this->desktop->scroll_world(moved_w, true); // we're still scrolling, do not redraw | 530 | case GDK_BUTTON_RELEASE: |
1599 | 531 | if (this->rotating_mode && event->button.button == 2) { | ||
1600 | 532 | desktop->canvas->clearRotateTo(); | ||
1601 | 533 | this->rotating_mode = false; | ||
1602 | 469 | ret = TRUE; | 534 | ret = TRUE; |
1621 | 470 | } | 535 | if (desktop->canvas->endRotateTo()) { |
1622 | 471 | } else if (zoom_rb) { | 536 | sp_repr_set_svg_double(desktop->namedview->getRepr(), "inkscape:document-rotation", angle); |
1623 | 472 | Geom::Point const motion_w(event->motion.x, event->motion.y); | 537 | } |
1606 | 473 | Geom::Point const motion_dt(desktop->w2d(motion_w)); | ||
1607 | 474 | |||
1608 | 475 | if (within_tolerance && (abs((gint) event->motion.x - xp) | ||
1609 | 476 | < tolerance) && (abs((gint) event->motion.y - yp) | ||
1610 | 477 | < tolerance)) { | ||
1611 | 478 | break; // do not drag if we're within tolerance from origin | ||
1612 | 479 | } | ||
1613 | 480 | |||
1614 | 481 | // Once the user has moved farther than tolerance from the original location | ||
1615 | 482 | // (indicating they intend to move the object, not click), then always process the | ||
1616 | 483 | // motion notify coordinates as given (no snapping back to origin) | ||
1617 | 484 | within_tolerance = false; | ||
1618 | 485 | |||
1619 | 486 | if (Inkscape::Rubberband::get(desktop)->is_started()) { | ||
1620 | 487 | Inkscape::Rubberband::get(desktop)->move(motion_dt); | ||
1624 | 488 | } else { | 538 | } else { |
1645 | 489 | Inkscape::Rubberband::get(desktop)->start(desktop, motion_dt); | 539 | xp = yp = 0; |
1646 | 490 | } | 540 | if (panning_cursor == 1) { |
1647 | 491 | 541 | panning_cursor = 0; | |
1648 | 492 | if (zoom_rb == 2) { | 542 | GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); |
1649 | 493 | gobble_motion_events(GDK_BUTTON2_MASK); | 543 | gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); |
1650 | 494 | } | 544 | } |
1651 | 495 | } | 545 | |
1652 | 496 | break; | 546 | if (within_tolerance && (panning || zoom_rb)) { |
1653 | 497 | 547 | zoom_rb = 0; | |
1654 | 498 | case GDK_BUTTON_RELEASE: | 548 | |
1655 | 499 | xp = yp = 0; | 549 | if (panning) { |
1656 | 500 | 550 | panning = 0; | |
1657 | 501 | if (panning_cursor == 1) { | 551 | sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), |
1658 | 502 | panning_cursor = 0; | 552 | event->button.time); |
1659 | 503 | GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); | 553 | } |
1660 | 504 | gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); | 554 | |
1661 | 505 | } | 555 | Geom::Point const event_w(event->button.x, event->button.y); |
1662 | 506 | 556 | Geom::Point const event_dt(desktop->w2d(event_w)); | |
1663 | 507 | if (within_tolerance && (panning || zoom_rb)) { | 557 | |
1664 | 508 | zoom_rb = 0; | 558 | double const zoom_inc = prefs->getDoubleLimited( |
1665 | 559 | "/options/zoomincrement/value", M_SQRT2, 1.01, 10); | ||
1666 | 560 | |||
1667 | 561 | desktop->zoom_relative_keep_point(event_dt, (event->button.state | ||
1668 | 562 | & GDK_SHIFT_MASK) ? 1 / zoom_inc : zoom_inc); | ||
1669 | 563 | |||
1670 | 564 | desktop->updateNow(); | ||
1671 | 565 | ret = TRUE; | ||
1672 | 566 | } else if (panning == event->button.button) { | ||
1673 | 567 | panning = 0; | ||
1674 | 568 | sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), | ||
1675 | 569 | event->button.time); | ||
1676 | 570 | |||
1677 | 571 | // in slow complex drawings, some of the motion events are lost; | ||
1678 | 572 | // to make up for this, we scroll it once again to the button-up event coordinates | ||
1679 | 573 | // (i.e. canvas will always get scrolled all the way to the mouse release point, | ||
1680 | 574 | // even if few intermediate steps were visible) | ||
1681 | 575 | Geom::Point const motion_w(event->button.x, event->button.y); | ||
1682 | 576 | Geom::Point const moved_w(motion_w - button_w); | ||
1683 | 577 | |||
1684 | 578 | this->desktop->scroll_world(moved_w); | ||
1685 | 579 | desktop->updateNow(); | ||
1686 | 580 | ret = TRUE; | ||
1687 | 581 | } else if (zoom_rb == event->button.button) { | ||
1688 | 582 | zoom_rb = 0; | ||
1689 | 583 | |||
1690 | 584 | Geom::OptRect const b = Inkscape::Rubberband::get(desktop)->getRectangle(); | ||
1691 | 585 | Inkscape::Rubberband::get(desktop)->stop(); | ||
1692 | 586 | |||
1693 | 587 | if (b && !within_tolerance) { | ||
1694 | 588 | desktop->set_display_area(*b, 10); | ||
1695 | 589 | } | ||
1696 | 590 | |||
1697 | 591 | ret = TRUE; | ||
1698 | 592 | } | ||
1699 | 593 | if (this->rotating_mode && event->button.button != 3) { | ||
1700 | 594 | desktop->canvas->clearRotateTo(); | ||
1701 | 595 | this->rotating_mode = false; | ||
1702 | 596 | ret = TRUE; | ||
1703 | 597 | desktop->canvas->endRotateTo(); | ||
1704 | 598 | } | ||
1705 | 599 | } | ||
1706 | 600 | break; | ||
1707 | 601 | |||
1708 | 602 | case GDK_KEY_PRESS: { | ||
1709 | 603 | double const acceleration = prefs->getDoubleLimited( | ||
1710 | 604 | "/options/scrollingacceleration/value", 0, 0, 6); | ||
1711 | 605 | int const key_scroll = prefs->getIntLimited("/options/keyscroll/value", | ||
1712 | 606 | 10, 0, 1000); | ||
1713 | 607 | |||
1714 | 608 | if (this->rotating_mode && | ||
1715 | 609 | get_group0_keyval(&event->key) != GDK_KEY_space && | ||
1716 | 610 | get_group0_keyval(&event->key) != GDK_KEY_Shift_L && | ||
1717 | 611 | get_group0_keyval(&event->key) != GDK_KEY_Shift_R && | ||
1718 | 612 | get_group0_keyval(&event->key) != GDK_KEY_Control_L && | ||
1719 | 613 | get_group0_keyval(&event->key) != GDK_KEY_Control_R && | ||
1720 | 614 | get_group0_keyval(&event->key) != GDK_KEY_Alt_L && | ||
1721 | 615 | get_group0_keyval(&event->key) != GDK_KEY_Alt_R ) | ||
1722 | 616 | { | ||
1723 | 617 | desktop->canvas->clearRotateTo(); | ||
1724 | 618 | this->rotating_mode = false; | ||
1725 | 619 | ret = TRUE; | ||
1726 | 620 | desktop->canvas->endRotateTo(); | ||
1727 | 621 | break; | ||
1728 | 622 | } | ||
1729 | 623 | |||
1730 | 624 | switch (get_group0_keyval(&event->key)) { | ||
1731 | 625 | // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets | ||
1732 | 626 | // in the editing window). So we resteal them back and run our regular shortcut | ||
1733 | 627 | // invoker on them. | ||
1734 | 628 | unsigned int shortcut; | ||
1735 | 629 | case GDK_KEY_Tab: | ||
1736 | 630 | case GDK_KEY_ISO_Left_Tab: | ||
1737 | 631 | case GDK_KEY_F1: | ||
1738 | 632 | shortcut = get_group0_keyval(&event->key); | ||
1739 | 633 | |||
1740 | 634 | if (event->key.state & GDK_SHIFT_MASK) { | ||
1741 | 635 | shortcut |= SP_SHORTCUT_SHIFT_MASK; | ||
1742 | 636 | } | ||
1743 | 637 | |||
1744 | 638 | if (event->key.state & GDK_CONTROL_MASK) { | ||
1745 | 639 | shortcut |= SP_SHORTCUT_CONTROL_MASK; | ||
1746 | 640 | } | ||
1747 | 641 | |||
1748 | 642 | if (event->key.state & GDK_MOD1_MASK) { | ||
1749 | 643 | shortcut |= SP_SHORTCUT_ALT_MASK; | ||
1750 | 644 | } | ||
1751 | 645 | |||
1752 | 646 | ret = sp_shortcut_invoke(shortcut, desktop); | ||
1753 | 647 | break; | ||
1754 | 648 | |||
1755 | 649 | case GDK_KEY_Q: | ||
1756 | 650 | case GDK_KEY_q: | ||
1757 | 651 | if (desktop->quick_zoomed()) { | ||
1758 | 652 | ret = TRUE; | ||
1759 | 653 | } | ||
1760 | 654 | if (!MOD__SHIFT(event) && !MOD__CTRL(event) && !MOD__ALT(event)) { | ||
1761 | 655 | desktop->zoom_quick(true); | ||
1762 | 656 | ret = TRUE; | ||
1763 | 657 | } | ||
1764 | 658 | break; | ||
1765 | 659 | |||
1766 | 660 | case GDK_KEY_W: | ||
1767 | 661 | case GDK_KEY_w: | ||
1768 | 662 | case GDK_KEY_F4: | ||
1769 | 663 | /* Close view */ | ||
1770 | 664 | if (MOD__CTRL_ONLY(event)) { | ||
1771 | 665 | sp_ui_close_view(NULL); | ||
1772 | 666 | ret = TRUE; | ||
1773 | 667 | } | ||
1774 | 668 | break; | ||
1775 | 669 | |||
1776 | 670 | case GDK_KEY_Left: // Ctrl Left | ||
1777 | 671 | case GDK_KEY_KP_Left: | ||
1778 | 672 | case GDK_KEY_KP_4: | ||
1779 | 673 | if (MOD__CTRL_ONLY(event)) { | ||
1780 | 674 | int i = (int) floor(key_scroll * accelerate_scroll(event, | ||
1781 | 675 | acceleration, desktop->getCanvas())); | ||
1782 | 676 | |||
1783 | 677 | gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); | ||
1784 | 678 | this->desktop->scroll_world(i, 0); | ||
1785 | 679 | ret = TRUE; | ||
1786 | 680 | } | ||
1787 | 681 | break; | ||
1788 | 682 | |||
1789 | 683 | case GDK_KEY_Up: // Ctrl Up | ||
1790 | 684 | case GDK_KEY_KP_Up: | ||
1791 | 685 | case GDK_KEY_KP_8: | ||
1792 | 686 | if (MOD__CTRL_ONLY(event)) { | ||
1793 | 687 | int i = (int) floor(key_scroll * accelerate_scroll(event, | ||
1794 | 688 | acceleration, desktop->getCanvas())); | ||
1795 | 689 | |||
1796 | 690 | gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); | ||
1797 | 691 | this->desktop->scroll_world(0, i); | ||
1798 | 692 | ret = TRUE; | ||
1799 | 693 | } | ||
1800 | 694 | break; | ||
1801 | 695 | |||
1802 | 696 | case GDK_KEY_Right: // Ctrl Right | ||
1803 | 697 | case GDK_KEY_KP_Right: | ||
1804 | 698 | case GDK_KEY_KP_6: | ||
1805 | 699 | if (MOD__CTRL_ONLY(event)) { | ||
1806 | 700 | int i = (int) floor(key_scroll * accelerate_scroll(event, | ||
1807 | 701 | acceleration, desktop->getCanvas())); | ||
1808 | 702 | |||
1809 | 703 | gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); | ||
1810 | 704 | this->desktop->scroll_world(-i, 0); | ||
1811 | 705 | ret = TRUE; | ||
1812 | 706 | } | ||
1813 | 707 | break; | ||
1814 | 708 | |||
1815 | 709 | case GDK_KEY_Down: // Ctrl Down | ||
1816 | 710 | case GDK_KEY_KP_Down: | ||
1817 | 711 | case GDK_KEY_KP_2: | ||
1818 | 712 | if (MOD__CTRL_ONLY(event)) { | ||
1819 | 713 | int i = (int) floor(key_scroll * accelerate_scroll(event, | ||
1820 | 714 | acceleration, desktop->getCanvas())); | ||
1821 | 715 | |||
1822 | 716 | gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); | ||
1823 | 717 | this->desktop->scroll_world(0, -i); | ||
1824 | 718 | ret = TRUE; | ||
1825 | 719 | } | ||
1826 | 720 | break; | ||
1827 | 721 | |||
1828 | 722 | case GDK_KEY_Menu: | ||
1829 | 723 | sp_event_root_menu_popup(desktop, NULL, event); | ||
1830 | 724 | ret = TRUE; | ||
1831 | 725 | break; | ||
1832 | 726 | |||
1833 | 727 | case GDK_KEY_F10: | ||
1834 | 728 | if (MOD__SHIFT_ONLY(event)) { | ||
1835 | 729 | sp_event_root_menu_popup(desktop, NULL, event); | ||
1836 | 730 | ret = TRUE; | ||
1837 | 731 | } | ||
1838 | 732 | break; | ||
1839 | 733 | |||
1840 | 734 | case GDK_KEY_space: | ||
1841 | 735 | if (event->key.state & GDK_CONTROL_MASK) { | ||
1842 | 736 | sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); | ||
1843 | 737 | desktop->canvas->startRotateTo(desktop->namedview->document_rotation); | ||
1844 | 738 | this->rotating_mode = true; | ||
1845 | 739 | this->message_context->set(Inkscape::INFORMATION_MESSAGE, | ||
1846 | 740 | _("<b>Space+mouse move</b> to rotate canvas, use modifiers on screen to change snaps")); | ||
1847 | 741 | } else { | ||
1848 | 742 | within_tolerance = true; | ||
1849 | 743 | xp = yp = 0; | ||
1850 | 744 | if (!allow_panning) break; | ||
1851 | 745 | panning = 4; | ||
1852 | 746 | this->space_panning = true; | ||
1853 | 747 | this->message_context->set(Inkscape::INFORMATION_MESSAGE, | ||
1854 | 748 | _("<b>Space+mouse move</b> to pan canvas")); | ||
1855 | 749 | } | ||
1856 | 750 | ret = TRUE; | ||
1857 | 751 | break; | ||
1858 | 752 | |||
1859 | 753 | case GDK_KEY_z: | ||
1860 | 754 | case GDK_KEY_Z: | ||
1861 | 755 | if (MOD__ALT_ONLY(event)) { | ||
1862 | 756 | desktop->zoom_grab_focus(); | ||
1863 | 757 | ret = TRUE; | ||
1864 | 758 | } | ||
1865 | 759 | break; | ||
1866 | 760 | |||
1867 | 761 | default: | ||
1868 | 762 | break; | ||
1869 | 763 | } | ||
1870 | 764 | } | ||
1871 | 765 | break; | ||
1872 | 766 | |||
1873 | 767 | case GDK_KEY_RELEASE: | ||
1874 | 768 | if (this->rotating_mode && | ||
1875 | 769 | get_group0_keyval(&event->key) != GDK_KEY_space && | ||
1876 | 770 | get_group0_keyval(&event->key) != GDK_KEY_Shift_L && | ||
1877 | 771 | get_group0_keyval(&event->key) != GDK_KEY_Shift_R && | ||
1878 | 772 | get_group0_keyval(&event->key) != GDK_KEY_Control_L && | ||
1879 | 773 | get_group0_keyval(&event->key) != GDK_KEY_Control_R && | ||
1880 | 774 | get_group0_keyval(&event->key) != GDK_KEY_Alt_L && | ||
1881 | 775 | get_group0_keyval(&event->key) != GDK_KEY_Alt_R ) | ||
1882 | 776 | { | ||
1883 | 777 | desktop->canvas->clearRotateTo(); | ||
1884 | 778 | this->rotating_mode = false; | ||
1885 | 779 | ret = TRUE; | ||
1886 | 780 | desktop->canvas->endRotateTo(); | ||
1887 | 781 | break; | ||
1888 | 782 | } | ||
1889 | 783 | |||
1890 | 784 | // Stop panning on any key release | ||
1891 | 785 | if (this->space_panning) { | ||
1892 | 786 | this->space_panning = false; | ||
1893 | 787 | this->message_context->clear(); | ||
1894 | 788 | } | ||
1895 | 509 | 789 | ||
1896 | 510 | if (panning) { | 790 | if (panning) { |
1897 | 511 | panning = 0; | 791 | panning = 0; |
1898 | 792 | xp = yp = 0; | ||
1899 | 793 | |||
1900 | 512 | sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), | 794 | sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), |
2217 | 513 | event->button.time); | 795 | event->key.time); |
2218 | 514 | } | 796 | |
2219 | 515 | 797 | desktop->updateNow(); | |
2220 | 516 | Geom::Point const event_w(event->button.x, event->button.y); | 798 | } |
2221 | 517 | Geom::Point const event_dt(desktop->w2d(event_w)); | 799 | |
2222 | 518 | 800 | if (panning_cursor == 1) { | |
2223 | 519 | double const zoom_inc = prefs->getDoubleLimited( | 801 | panning_cursor = 0; |
2224 | 520 | "/options/zoomincrement/value", M_SQRT2, 1.01, 10); | 802 | GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); |
2225 | 521 | 803 | gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); | |
2226 | 522 | desktop->zoom_relative_keep_point(event_dt, (event->button.state | 804 | } |
2227 | 523 | & GDK_SHIFT_MASK) ? 1 / zoom_inc : zoom_inc); | 805 | |
2228 | 524 | 806 | switch (get_group0_keyval(&event->key)) { | |
2229 | 525 | desktop->updateNow(); | 807 | case GDK_KEY_space: |
2230 | 526 | ret = TRUE; | 808 | if (this->rotating_mode) { |
2231 | 527 | } else if (panning == event->button.button) { | 809 | desktop->canvas->clearRotateTo(); |
2232 | 528 | panning = 0; | 810 | this->rotating_mode = false; |
2233 | 529 | sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), | 811 | ret = TRUE; |
2234 | 530 | event->button.time); | 812 | if (desktop->canvas->endRotateTo()) { |
2235 | 531 | 813 | sp_repr_set_svg_double(desktop->namedview->getRepr(), "inkscape:document-rotation", angle); | |
2236 | 532 | // in slow complex drawings, some of the motion events are lost; | 814 | } |
2237 | 533 | // to make up for this, we scroll it once again to the button-up event coordinates | 815 | } |
2238 | 534 | // (i.e. canvas will always get scrolled all the way to the mouse release point, | 816 | if (within_tolerance) { |
2239 | 535 | // even if few intermediate steps were visible) | 817 | // Space was pressed, but not panned |
2240 | 536 | Geom::Point const motion_w(event->button.x, event->button.y); | 818 | sp_toggle_selector(desktop); |
2241 | 537 | Geom::Point const moved_w(motion_w - button_w); | 819 | |
2242 | 538 | 820 | // Be careful, sp_toggle_selector will delete ourselves. | |
2243 | 539 | this->desktop->scroll_world(moved_w); | 821 | // Thus, make sure we return immediately. |
2244 | 540 | desktop->updateNow(); | 822 | return true; |
2245 | 541 | ret = TRUE; | 823 | } |
2246 | 542 | } else if (zoom_rb == event->button.button) { | 824 | break; |
2247 | 543 | zoom_rb = 0; | 825 | |
2248 | 544 | 826 | case GDK_KEY_Q: | |
2249 | 545 | Geom::OptRect const b = Inkscape::Rubberband::get(desktop)->getRectangle(); | 827 | case GDK_KEY_q: |
2250 | 546 | Inkscape::Rubberband::get(desktop)->stop(); | 828 | if (desktop->quick_zoomed()) { |
2251 | 547 | 829 | desktop->zoom_quick(false); | |
2252 | 548 | if (b && !within_tolerance) { | 830 | ret = TRUE; |
2253 | 549 | desktop->set_display_area(*b, 10); | 831 | } |
2254 | 550 | } | 832 | break; |
2255 | 551 | 833 | ||
2256 | 552 | ret = TRUE; | 834 | default: |
2257 | 553 | } | 835 | break; |
2258 | 554 | break; | 836 | } |
2259 | 555 | 837 | break; | |
2260 | 556 | case GDK_KEY_PRESS: { | 838 | |
2261 | 557 | double const acceleration = prefs->getDoubleLimited( | 839 | case GDK_SCROLL: { |
2262 | 558 | "/options/scrollingacceleration/value", 0, 0, 6); | 840 | if (this->rotating_mode) { |
2263 | 559 | int const key_scroll = prefs->getIntLimited("/options/keyscroll/value", | 841 | desktop->canvas->clearRotateTo(); |
2264 | 560 | 10, 0, 1000); | 842 | this->rotating_mode = false; |
2265 | 561 | 843 | desktop->canvas->endRotateTo(); | |
2266 | 562 | switch (get_group0_keyval(&event->key)) { | 844 | } |
2267 | 563 | // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets | 845 | bool ctrl = (event->scroll.state & GDK_CONTROL_MASK); |
2268 | 564 | // in the editing window). So we resteal them back and run our regular shortcut | 846 | bool wheelzooms = prefs->getBool("/options/wheelzooms/value"); |
2269 | 565 | // invoker on them. | 847 | |
2270 | 566 | unsigned int shortcut; | 848 | int const wheel_scroll = prefs->getIntLimited( |
2271 | 567 | case GDK_KEY_Tab: | 849 | "/options/wheelscroll/value", 40, 0, 1000); |
2272 | 568 | case GDK_KEY_ISO_Left_Tab: | 850 | |
2273 | 569 | case GDK_KEY_F1: | 851 | // Size of smooth-scrolls (only used in GTK+ 3) |
2274 | 570 | shortcut = get_group0_keyval(&event->key); | 852 | gdouble delta_x = 0; |
2275 | 571 | 853 | gdouble delta_y = 0; | |
2276 | 572 | if (event->key.state & GDK_SHIFT_MASK) { | 854 | |
2277 | 573 | shortcut |= SP_SHORTCUT_SHIFT_MASK; | 855 | /* shift + wheel, pan left--right */ |
2278 | 574 | } | 856 | if (event->scroll.state & GDK_SHIFT_MASK) { |
2279 | 575 | 857 | switch (event->scroll.direction) { | |
2280 | 576 | if (event->key.state & GDK_CONTROL_MASK) { | 858 | case GDK_SCROLL_UP: |
2281 | 577 | shortcut |= SP_SHORTCUT_CONTROL_MASK; | 859 | desktop->scroll_world(wheel_scroll, 0); |
2282 | 578 | } | 860 | break; |
2283 | 579 | 861 | ||
2284 | 580 | if (event->key.state & GDK_MOD1_MASK) { | 862 | case GDK_SCROLL_DOWN: |
2285 | 581 | shortcut |= SP_SHORTCUT_ALT_MASK; | 863 | desktop->scroll_world(-wheel_scroll, 0); |
2286 | 582 | } | 864 | break; |
2287 | 583 | 865 | ||
2288 | 584 | ret = sp_shortcut_invoke(shortcut, desktop); | 866 | default: |
2289 | 585 | break; | 867 | break; |
2290 | 586 | 868 | } | |
2291 | 587 | case GDK_KEY_Q: | 869 | |
2292 | 588 | case GDK_KEY_q: | 870 | /* ctrl + wheel, zoom in--out */ |
2293 | 589 | if (desktop->quick_zoomed()) { | 871 | } else if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) { |
2294 | 590 | ret = TRUE; | 872 | double rel_zoom; |
2295 | 591 | } | 873 | double const zoom_inc = prefs->getDoubleLimited( |
2296 | 592 | if (!MOD__SHIFT(event) && !MOD__CTRL(event) && !MOD__ALT(event)) { | 874 | "/options/zoomincrement/value", M_SQRT2, 1.01, 10); |
2297 | 593 | desktop->zoom_quick(true); | 875 | |
2298 | 594 | ret = TRUE; | 876 | switch (event->scroll.direction) { |
2299 | 595 | } | 877 | case GDK_SCROLL_UP: |
2300 | 596 | break; | 878 | rel_zoom = zoom_inc; |
2301 | 597 | 879 | break; | |
2302 | 598 | case GDK_KEY_W: | 880 | |
2303 | 599 | case GDK_KEY_w: | 881 | case GDK_SCROLL_DOWN: |
2304 | 600 | case GDK_KEY_F4: | 882 | rel_zoom = 1 / zoom_inc; |
2305 | 601 | /* Close view */ | 883 | break; |
2306 | 602 | if (MOD__CTRL_ONLY(event)) { | 884 | |
2307 | 603 | sp_ui_close_view(NULL); | 885 | default: |
2308 | 604 | ret = TRUE; | 886 | rel_zoom = 0.0; |
2309 | 605 | } | 887 | break; |
2310 | 606 | break; | 888 | } |
2311 | 607 | 889 | ||
2312 | 608 | case GDK_KEY_Left: // Ctrl Left | 890 | if (rel_zoom != 0.0) { |
2313 | 609 | case GDK_KEY_KP_Left: | 891 | Geom::Point const scroll_dt = desktop->point(); |
2314 | 610 | case GDK_KEY_KP_4: | 892 | desktop->zoom_relative_keep_point(scroll_dt, rel_zoom); |
2315 | 611 | if (MOD__CTRL_ONLY(event)) { | 893 | } |
2316 | 612 | int i = (int) floor(key_scroll * accelerate_scroll(event, | 894 | |
2317 | 613 | acceleration, desktop->getCanvas())); | 895 | /* no modifier, pan up--down (left--right on multiwheel mice?) */ |
2318 | 614 | 896 | } else { | |
2319 | 615 | gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); | 897 | switch (event->scroll.direction) { |
2320 | 616 | this->desktop->scroll_world(i, 0); | 898 | case GDK_SCROLL_UP: |
2321 | 617 | ret = TRUE; | 899 | desktop->scroll_world(0, wheel_scroll); |
2322 | 618 | } | 900 | break; |
2323 | 619 | break; | 901 | |
2324 | 620 | 902 | case GDK_SCROLL_DOWN: | |
2325 | 621 | case GDK_KEY_Up: // Ctrl Up | 903 | desktop->scroll_world(0, -wheel_scroll); |
2326 | 622 | case GDK_KEY_KP_Up: | 904 | break; |
2327 | 623 | case GDK_KEY_KP_8: | 905 | |
2328 | 624 | if (MOD__CTRL_ONLY(event)) { | 906 | case GDK_SCROLL_LEFT: |
2329 | 625 | int i = (int) floor(key_scroll * accelerate_scroll(event, | 907 | desktop->scroll_world(wheel_scroll, 0); |
2330 | 626 | acceleration, desktop->getCanvas())); | 908 | break; |
2331 | 627 | 909 | ||
2332 | 628 | gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); | 910 | case GDK_SCROLL_RIGHT: |
2333 | 629 | this->desktop->scroll_world(0, i); | 911 | desktop->scroll_world(-wheel_scroll, 0); |
2334 | 630 | ret = TRUE; | 912 | break; |
2335 | 631 | } | 913 | |
2336 | 632 | break; | 914 | case GDK_SCROLL_SMOOTH: |
2337 | 633 | 915 | gdk_event_get_scroll_deltas(event, &delta_x, &delta_y); | |
2338 | 634 | case GDK_KEY_Right: // Ctrl Right | 916 | desktop->scroll_world(delta_x, delta_y); |
2339 | 635 | case GDK_KEY_KP_Right: | 917 | break; |
2340 | 636 | case GDK_KEY_KP_6: | 918 | } |
2341 | 637 | if (MOD__CTRL_ONLY(event)) { | 919 | } |
2342 | 638 | int i = (int) floor(key_scroll * accelerate_scroll(event, | 920 | break; |
2343 | 639 | acceleration, desktop->getCanvas())); | 921 | } |
2344 | 640 | 922 | default: | |
2345 | 641 | gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); | 923 | break; |
2346 | 642 | this->desktop->scroll_world(-i, 0); | 924 | } |
2031 | 643 | ret = TRUE; | ||
2032 | 644 | } | ||
2033 | 645 | break; | ||
2034 | 646 | |||
2035 | 647 | case GDK_KEY_Down: // Ctrl Down | ||
2036 | 648 | case GDK_KEY_KP_Down: | ||
2037 | 649 | case GDK_KEY_KP_2: | ||
2038 | 650 | if (MOD__CTRL_ONLY(event)) { | ||
2039 | 651 | int i = (int) floor(key_scroll * accelerate_scroll(event, | ||
2040 | 652 | acceleration, desktop->getCanvas())); | ||
2041 | 653 | |||
2042 | 654 | gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); | ||
2043 | 655 | this->desktop->scroll_world(0, -i); | ||
2044 | 656 | ret = TRUE; | ||
2045 | 657 | } | ||
2046 | 658 | break; | ||
2047 | 659 | |||
2048 | 660 | case GDK_KEY_Menu: | ||
2049 | 661 | sp_event_root_menu_popup(desktop, NULL, event); | ||
2050 | 662 | ret = TRUE; | ||
2051 | 663 | break; | ||
2052 | 664 | |||
2053 | 665 | case GDK_KEY_F10: | ||
2054 | 666 | if (MOD__SHIFT_ONLY(event)) { | ||
2055 | 667 | sp_event_root_menu_popup(desktop, NULL, event); | ||
2056 | 668 | ret = TRUE; | ||
2057 | 669 | } | ||
2058 | 670 | break; | ||
2059 | 671 | |||
2060 | 672 | case GDK_KEY_space: | ||
2061 | 673 | within_tolerance = true; | ||
2062 | 674 | xp = yp = 0; | ||
2063 | 675 | if (!allow_panning) break; | ||
2064 | 676 | panning = 4; | ||
2065 | 677 | this->space_panning = true; | ||
2066 | 678 | this->message_context->set(Inkscape::INFORMATION_MESSAGE, | ||
2067 | 679 | _("<b>Space+mouse move</b> to pan canvas")); | ||
2068 | 680 | |||
2069 | 681 | ret = TRUE; | ||
2070 | 682 | break; | ||
2071 | 683 | |||
2072 | 684 | case GDK_KEY_z: | ||
2073 | 685 | case GDK_KEY_Z: | ||
2074 | 686 | if (MOD__ALT_ONLY(event)) { | ||
2075 | 687 | desktop->zoom_grab_focus(); | ||
2076 | 688 | ret = TRUE; | ||
2077 | 689 | } | ||
2078 | 690 | break; | ||
2079 | 691 | |||
2080 | 692 | default: | ||
2081 | 693 | break; | ||
2082 | 694 | } | ||
2083 | 695 | } | ||
2084 | 696 | break; | ||
2085 | 697 | |||
2086 | 698 | case GDK_KEY_RELEASE: | ||
2087 | 699 | // Stop panning on any key release | ||
2088 | 700 | if (this->space_panning) { | ||
2089 | 701 | this->space_panning = false; | ||
2090 | 702 | this->message_context->clear(); | ||
2091 | 703 | } | ||
2092 | 704 | |||
2093 | 705 | if (panning) { | ||
2094 | 706 | panning = 0; | ||
2095 | 707 | xp = yp = 0; | ||
2096 | 708 | |||
2097 | 709 | sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), | ||
2098 | 710 | event->key.time); | ||
2099 | 711 | |||
2100 | 712 | desktop->updateNow(); | ||
2101 | 713 | } | ||
2102 | 714 | |||
2103 | 715 | if (panning_cursor == 1) { | ||
2104 | 716 | panning_cursor = 0; | ||
2105 | 717 | GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); | ||
2106 | 718 | gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); | ||
2107 | 719 | } | ||
2108 | 720 | |||
2109 | 721 | switch (get_group0_keyval(&event->key)) { | ||
2110 | 722 | case GDK_KEY_space: | ||
2111 | 723 | if (within_tolerance) { | ||
2112 | 724 | // Space was pressed, but not panned | ||
2113 | 725 | sp_toggle_selector(desktop); | ||
2114 | 726 | |||
2115 | 727 | // Be careful, sp_toggle_selector will delete ourselves. | ||
2116 | 728 | // Thus, make sure we return immediately. | ||
2117 | 729 | return true; | ||
2118 | 730 | } | ||
2119 | 731 | |||
2120 | 732 | break; | ||
2121 | 733 | |||
2122 | 734 | case GDK_KEY_Q: | ||
2123 | 735 | case GDK_KEY_q: | ||
2124 | 736 | if (desktop->quick_zoomed()) { | ||
2125 | 737 | desktop->zoom_quick(false); | ||
2126 | 738 | ret = TRUE; | ||
2127 | 739 | } | ||
2128 | 740 | break; | ||
2129 | 741 | |||
2130 | 742 | default: | ||
2131 | 743 | break; | ||
2132 | 744 | } | ||
2133 | 745 | break; | ||
2134 | 746 | |||
2135 | 747 | case GDK_SCROLL: { | ||
2136 | 748 | bool ctrl = (event->scroll.state & GDK_CONTROL_MASK); | ||
2137 | 749 | bool wheelzooms = prefs->getBool("/options/wheelzooms/value"); | ||
2138 | 750 | |||
2139 | 751 | int const wheel_scroll = prefs->getIntLimited( | ||
2140 | 752 | "/options/wheelscroll/value", 40, 0, 1000); | ||
2141 | 753 | |||
2142 | 754 | // Size of smooth-scrolls (only used in GTK+ 3) | ||
2143 | 755 | gdouble delta_x = 0; | ||
2144 | 756 | gdouble delta_y = 0; | ||
2145 | 757 | |||
2146 | 758 | /* shift + wheel, pan left--right */ | ||
2147 | 759 | if (event->scroll.state & GDK_SHIFT_MASK) { | ||
2148 | 760 | switch (event->scroll.direction) { | ||
2149 | 761 | case GDK_SCROLL_UP: | ||
2150 | 762 | desktop->scroll_world(wheel_scroll, 0); | ||
2151 | 763 | break; | ||
2152 | 764 | |||
2153 | 765 | case GDK_SCROLL_DOWN: | ||
2154 | 766 | desktop->scroll_world(-wheel_scroll, 0); | ||
2155 | 767 | break; | ||
2156 | 768 | |||
2157 | 769 | default: | ||
2158 | 770 | break; | ||
2159 | 771 | } | ||
2160 | 772 | |||
2161 | 773 | /* ctrl + wheel, zoom in--out */ | ||
2162 | 774 | } else if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) { | ||
2163 | 775 | double rel_zoom; | ||
2164 | 776 | double const zoom_inc = prefs->getDoubleLimited( | ||
2165 | 777 | "/options/zoomincrement/value", M_SQRT2, 1.01, 10); | ||
2166 | 778 | |||
2167 | 779 | switch (event->scroll.direction) { | ||
2168 | 780 | case GDK_SCROLL_UP: | ||
2169 | 781 | rel_zoom = zoom_inc; | ||
2170 | 782 | break; | ||
2171 | 783 | |||
2172 | 784 | case GDK_SCROLL_DOWN: | ||
2173 | 785 | rel_zoom = 1 / zoom_inc; | ||
2174 | 786 | break; | ||
2175 | 787 | |||
2176 | 788 | default: | ||
2177 | 789 | rel_zoom = 0.0; | ||
2178 | 790 | break; | ||
2179 | 791 | } | ||
2180 | 792 | |||
2181 | 793 | if (rel_zoom != 0.0) { | ||
2182 | 794 | Geom::Point const scroll_dt = desktop->point(); | ||
2183 | 795 | desktop->zoom_relative_keep_point(scroll_dt, rel_zoom); | ||
2184 | 796 | } | ||
2185 | 797 | |||
2186 | 798 | /* no modifier, pan up--down (left--right on multiwheel mice?) */ | ||
2187 | 799 | } else { | ||
2188 | 800 | switch (event->scroll.direction) { | ||
2189 | 801 | case GDK_SCROLL_UP: | ||
2190 | 802 | desktop->scroll_world(0, wheel_scroll); | ||
2191 | 803 | break; | ||
2192 | 804 | |||
2193 | 805 | case GDK_SCROLL_DOWN: | ||
2194 | 806 | desktop->scroll_world(0, -wheel_scroll); | ||
2195 | 807 | break; | ||
2196 | 808 | |||
2197 | 809 | case GDK_SCROLL_LEFT: | ||
2198 | 810 | desktop->scroll_world(wheel_scroll, 0); | ||
2199 | 811 | break; | ||
2200 | 812 | |||
2201 | 813 | case GDK_SCROLL_RIGHT: | ||
2202 | 814 | desktop->scroll_world(-wheel_scroll, 0); | ||
2203 | 815 | break; | ||
2204 | 816 | |||
2205 | 817 | case GDK_SCROLL_SMOOTH: | ||
2206 | 818 | gdk_event_get_scroll_deltas(event, &delta_x, &delta_y); | ||
2207 | 819 | desktop->scroll_world(delta_x, delta_y); | ||
2208 | 820 | break; | ||
2209 | 821 | } | ||
2210 | 822 | } | ||
2211 | 823 | break; | ||
2212 | 824 | } | ||
2213 | 825 | default: | ||
2214 | 826 | break; | ||
2215 | 827 | } | ||
2216 | 828 | |||
2347 | 829 | return ret; | 925 | return ret; |
2348 | 830 | } | 926 | } |
2349 | 831 | 927 | ||
2350 | 832 | 928 | ||
2351 | === modified file 'src/ui/tools/tool-base.h' | |||
2352 | --- src/ui/tools/tool-base.h 2015-07-24 19:38:06 +0000 | |||
2353 | +++ src/ui/tools/tool-base.h 2017-01-24 17:53:20 +0000 | |||
2354 | @@ -176,6 +176,7 @@ | |||
2355 | 176 | ShapeEditor* shape_editor; | 176 | ShapeEditor* shape_editor; |
2356 | 177 | 177 | ||
2357 | 178 | bool space_panning; | 178 | bool space_panning; |
2358 | 179 | bool rotating_mode; | ||
2359 | 179 | 180 | ||
2360 | 180 | DelayedSnapEvent *_delayed_snap_event; | 181 | DelayedSnapEvent *_delayed_snap_event; |
2361 | 181 | bool _dse_callback_in_process; | 182 | bool _dse_callback_in_process; |
2362 | 182 | 183 | ||
2363 | === modified file 'src/viewbox.cpp' | |||
2364 | --- src/viewbox.cpp 2016-08-03 13:29:38 +0000 | |||
2365 | +++ src/viewbox.cpp 2017-01-24 17:53:20 +0000 | |||
2366 | @@ -17,6 +17,8 @@ | |||
2367 | 17 | #include "viewbox.h" | 17 | #include "viewbox.h" |
2368 | 18 | #include "enums.h" | 18 | #include "enums.h" |
2369 | 19 | #include "sp-item.h" | 19 | #include "sp-item.h" |
2370 | 20 | #include "inkscape.h" | ||
2371 | 21 | #include "desktop.h" | ||
2372 | 20 | 22 | ||
2373 | 21 | SPViewBox::SPViewBox() | 23 | SPViewBox::SPViewBox() |
2374 | 22 | : viewBox_set(false) | 24 | : viewBox_set(false) |
2375 | @@ -25,6 +27,11 @@ | |||
2376 | 25 | , aspect_align(SP_ASPECT_XMID_YMID) // Default per spec | 27 | , aspect_align(SP_ASPECT_XMID_YMID) // Default per spec |
2377 | 26 | , aspect_clip(SP_ASPECT_MEET) | 28 | , aspect_clip(SP_ASPECT_MEET) |
2378 | 27 | , c2p(Geom::identity()) | 29 | , c2p(Geom::identity()) |
2379 | 30 | , vbt(Geom::identity()) | ||
2380 | 31 | , rotation(Geom::identity()) | ||
2381 | 32 | , angle(0) | ||
2382 | 33 | , previous_angle(0) | ||
2383 | 34 | , rotated(false) | ||
2384 | 28 | { | 35 | { |
2385 | 29 | } | 36 | } |
2386 | 30 | 37 | ||
2387 | @@ -159,6 +166,16 @@ | |||
2388 | 159 | } | 166 | } |
2389 | 160 | } | 167 | } |
2390 | 161 | 168 | ||
2391 | 169 | double SPViewBox::get_rotation() { | ||
2392 | 170 | return this->angle; | ||
2393 | 171 | } | ||
2394 | 172 | |||
2395 | 173 | void SPViewBox::set_rotation(double angle_val) { | ||
2396 | 174 | this->previous_angle = this->angle; | ||
2397 | 175 | this->angle = angle_val; | ||
2398 | 176 | this->rotated = true; | ||
2399 | 177 | } | ||
2400 | 178 | |||
2401 | 162 | // Apply scaling from viewbox | 179 | // Apply scaling from viewbox |
2402 | 163 | void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { | 180 | void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { |
2403 | 164 | 181 | ||
2404 | @@ -222,22 +239,41 @@ | |||
2405 | 222 | break; | 239 | break; |
2406 | 223 | } | 240 | } |
2407 | 224 | } | 241 | } |
2408 | 225 | |||
2409 | 226 | /* Viewbox transform from scale and position */ | 242 | /* Viewbox transform from scale and position */ |
2422 | 227 | Geom::Affine q; | 243 | vbt = Geom::identity(); |
2423 | 228 | q[0] = scale_x; | 244 | vbt[0] = scale_x; |
2424 | 229 | q[1] = 0.0; | 245 | vbt[1] = 0.0; |
2425 | 230 | q[2] = 0.0; | 246 | vbt[2] = 0.0; |
2426 | 231 | q[3] = scale_y; | 247 | vbt[3] = scale_y; |
2427 | 232 | q[4] = x - scale_x * this->viewBox.left(); | 248 | vbt[4] = x - scale_x * this->viewBox.left(); |
2428 | 233 | q[5] = y - scale_y * this->viewBox.top(); | 249 | vbt[5] = y - scale_y * this->viewBox.top(); |
2429 | 234 | 250 | /* Append viewbox and turn transformation */ | |
2430 | 235 | // std::cout << " q\n" << q << std::endl; | 251 | Geom::Point page_center = this->viewBox.midpoint(); |
2431 | 236 | 252 | SPDesktop * desktop = SP_ACTIVE_DESKTOP; | |
2432 | 237 | /* Append viewbox transformation */ | 253 | if (this->angle > 0.0 || this->angle < 0.0 ) { //!0 |
2433 | 238 | this->c2p = q * this->c2p; | 254 | if (desktop) { |
2434 | 255 | rotation = Geom::Translate(page_center).inverse() * Geom::Rotate(Geom::rad_from_deg(angle)) * Geom::Translate(page_center); | ||
2435 | 256 | this->c2p = rotation * vbt * this->c2p; | ||
2436 | 257 | } else { | ||
2437 | 258 | this->c2p = vbt * this->c2p; | ||
2438 | 259 | } | ||
2439 | 260 | } else { | ||
2440 | 261 | this->c2p = vbt * this->c2p; | ||
2441 | 262 | } | ||
2442 | 263 | if (desktop && this->rotated) { | ||
2443 | 264 | Geom::Rect view = desktop->get_display_area(); | ||
2444 | 265 | Geom::Point view_center = desktop->doc2dt(view.midpoint()); | ||
2445 | 266 | Geom::Affine center_rotation = Geom::identity(); | ||
2446 | 267 | center_rotation *= Geom::Translate(page_center * vbt).inverse(); | ||
2447 | 268 | center_rotation *= Geom::Rotate(Geom::rad_from_deg(this->angle - this->previous_angle)); | ||
2448 | 269 | center_rotation *= Geom::Translate(page_center * vbt); | ||
2449 | 270 | view_center = desktop->dt2doc(view_center * center_rotation); | ||
2450 | 271 | desktop->zoom_relative(view_center[Geom::X], view_center[Geom::Y], 1.0); | ||
2451 | 272 | this->rotated = false; | ||
2452 | 273 | } | ||
2453 | 239 | } | 274 | } |
2454 | 240 | 275 | ||
2455 | 276 | |||
2456 | 241 | SPItemCtx SPViewBox::get_rctx(const SPItemCtx* ictx, double scale_none) { | 277 | SPItemCtx SPViewBox::get_rctx(const SPItemCtx* ictx, double scale_none) { |
2457 | 242 | 278 | ||
2458 | 243 | /* Create copy of item context */ | 279 | /* Create copy of item context */ |
2459 | 244 | 280 | ||
2460 | === modified file 'src/viewbox.h' | |||
2461 | --- src/viewbox.h 2015-02-12 16:17:54 +0000 | |||
2462 | +++ src/viewbox.h 2017-01-24 17:53:20 +0000 | |||
2463 | @@ -36,7 +36,14 @@ | |||
2464 | 36 | 36 | ||
2465 | 37 | /* Child to parent additional transform */ | 37 | /* Child to parent additional transform */ |
2466 | 38 | Geom::Affine c2p; | 38 | Geom::Affine c2p; |
2467 | 39 | Geom::Affine vbt; | ||
2468 | 40 | Geom::Affine rotation; | ||
2469 | 41 | double angle; | ||
2470 | 42 | double previous_angle; | ||
2471 | 43 | bool rotated; | ||
2472 | 39 | 44 | ||
2473 | 45 | double get_rotation(); | ||
2474 | 46 | void set_rotation(double angle_val); | ||
2475 | 40 | void set_viewBox(const gchar* value); | 47 | void set_viewBox(const gchar* value); |
2476 | 41 | void set_preserveAspectRatio(const gchar* value); | 48 | void set_preserveAspectRatio(const gchar* value); |
2477 | 42 | 49 | ||
2478 | 43 | 50 | ||
2479 | === modified file 'src/widgets/desktop-widget.cpp' | |||
2480 | --- src/widgets/desktop-widget.cpp 2016-11-11 20:04:49 +0000 | |||
2481 | +++ src/widgets/desktop-widget.cpp 2017-01-24 17:53:20 +0000 | |||
2482 | @@ -54,7 +54,7 @@ | |||
2483 | 54 | #include "ui/uxmanager.h" | 54 | #include "ui/uxmanager.h" |
2484 | 55 | #include "util/ege-appear-time-tracker.h" | 55 | #include "util/ege-appear-time-tracker.h" |
2485 | 56 | #include "sp-root.h" | 56 | #include "sp-root.h" |
2487 | 57 | 57 | #include "attributes.h" | |
2488 | 58 | // We're in the "widgets" directory, so no need to explicitly prefix these: | 58 | // We're in the "widgets" directory, so no need to explicitly prefix these: |
2489 | 59 | #include "button.h" | 59 | #include "button.h" |
2490 | 60 | #include "gimp/ruler.h" | 60 | #include "gimp/ruler.h" |
2491 | @@ -62,11 +62,11 @@ | |||
2492 | 62 | #include "spw-utilities.h" | 62 | #include "spw-utilities.h" |
2493 | 63 | #include "toolbox.h" | 63 | #include "toolbox.h" |
2494 | 64 | #include "widget-sizes.h" | 64 | #include "widget-sizes.h" |
2495 | 65 | |||
2496 | 66 | #include "verbs.h" | 65 | #include "verbs.h" |
2497 | 67 | #include <gtkmm/cssprovider.h> | 66 | #include <gtkmm/cssprovider.h> |
2498 | 68 | #include <gtkmm/paned.h> | 67 | #include <gtkmm/paned.h> |
2499 | 69 | #include <gtkmm/messagedialog.h> | 68 | #include <gtkmm/messagedialog.h> |
2500 | 69 | #include <iomanip> | ||
2501 | 70 | 70 | ||
2502 | 71 | #if defined (SOLARIS) && (SOLARIS == 8) | 71 | #if defined (SOLARIS) && (SOLARIS == 8) |
2503 | 72 | #include "round.h" | 72 | #include "round.h" |
2504 | @@ -105,8 +105,20 @@ | |||
2505 | 105 | static void cms_adjust_toggled( GtkWidget *button, gpointer data ); | 105 | static void cms_adjust_toggled( GtkWidget *button, gpointer data ); |
2506 | 106 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) | 106 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
2507 | 107 | static void cms_adjust_set_sensitive( SPDesktopWidget *dtw, bool enabled ); | 107 | static void cms_adjust_set_sensitive( SPDesktopWidget *dtw, bool enabled ); |
2508 | 108 | static void sp_desktop_widget_rotate_document(GtkSpinButton *spin, SPDesktopWidget *dtw); | ||
2509 | 108 | static void sp_desktop_widget_adjustment_value_changed (GtkAdjustment *adj, SPDesktopWidget *dtw); | 109 | static void sp_desktop_widget_adjustment_value_changed (GtkAdjustment *adj, SPDesktopWidget *dtw); |
2510 | 109 | 110 | ||
2511 | 111 | static gint sp_dtw_rotation_input (GtkSpinButton *spin, gdouble *new_val, gpointer data); | ||
2512 | 112 | static bool sp_dtw_rotation_output (GtkSpinButton *spin, gpointer data); | ||
2513 | 113 | static void sp_dtw_rotation_populate_popup (GtkEntry *entry, GtkMenu *menu, gpointer data); | ||
2514 | 114 | static void sp_dtw_rotate_minus_180 (GtkMenuItem *item, SPDesktopWidget * data); | ||
2515 | 115 | static void sp_dtw_rotate_minus_135 (GtkMenuItem *item, SPDesktopWidget * data); | ||
2516 | 116 | static void sp_dtw_rotate_minus_90 (GtkMenuItem *item, SPDesktopWidget * data); | ||
2517 | 117 | static void sp_dtw_rotate_minus_45 (GtkMenuItem *item, SPDesktopWidget * data); | ||
2518 | 118 | static void sp_dtw_rotate_0 (GtkMenuItem *item, SPDesktopWidget * data); | ||
2519 | 119 | static void sp_dtw_rotate_45 (GtkMenuItem *item, SPDesktopWidget * data); | ||
2520 | 120 | static void sp_dtw_rotate_90 (GtkMenuItem *item, SPDesktopWidget * data); | ||
2521 | 121 | static void sp_dtw_rotate_135 (GtkMenuItem *item, SPDesktopWidget * data); | ||
2522 | 110 | static gdouble sp_dtw_zoom_value_to_display (gdouble value); | 122 | static gdouble sp_dtw_zoom_value_to_display (gdouble value); |
2523 | 111 | static gdouble sp_dtw_zoom_display_to_value (gdouble value); | 123 | static gdouble sp_dtw_zoom_display_to_value (gdouble value); |
2524 | 112 | static gint sp_dtw_zoom_input (GtkSpinButton *spin, gdouble *new_val, gpointer data); | 124 | static gint sp_dtw_zoom_input (GtkSpinButton *spin, gdouble *new_val, gpointer data); |
2525 | @@ -593,6 +605,34 @@ | |||
2526 | 593 | g_signal_connect (G_OBJECT (dtw->zoom_status), "key-press-event", G_CALLBACK (spinbutton_keypress), dtw->zoom_status); | 605 | g_signal_connect (G_OBJECT (dtw->zoom_status), "key-press-event", G_CALLBACK (spinbutton_keypress), dtw->zoom_status); |
2527 | 594 | dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "value_changed", G_CALLBACK (sp_dtw_zoom_value_changed), dtw); | 606 | dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "value_changed", G_CALLBACK (sp_dtw_zoom_value_changed), dtw); |
2528 | 595 | dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "populate_popup", G_CALLBACK (sp_dtw_zoom_populate_popup), dtw); | 607 | dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "populate_popup", G_CALLBACK (sp_dtw_zoom_populate_popup), dtw); |
2529 | 608 | auto css_provider_spinbutton = Gtk::CssProvider::create(); | ||
2530 | 609 | css_provider_spinbutton->load_from_data("* { padding-left: 2; padding-right: 2; padding-top: 0; padding-bottom: 0;}"); | ||
2531 | 610 | auto zoomstat = Glib::wrap(dtw->zoom_status); | ||
2532 | 611 | zoomstat->set_name("ZoomStatus"); | ||
2533 | 612 | auto context_zoom = zoomstat->get_style_context(); | ||
2534 | 613 | context_zoom->add_provider(css_provider_spinbutton, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); | ||
2535 | 614 | |||
2536 | 615 | // Rotate status spinbutton | ||
2537 | 616 | dtw->rotation_status = gtk_spin_button_new_with_range (-360.0,360.0, 1.0); | ||
2538 | 617 | gtk_widget_set_tooltip_text (dtw->rotation_status, _("Rotation")); | ||
2539 | 618 | gtk_widget_set_size_request (dtw->rotation_status, STATUS_ROTATION_WIDTH, -1); | ||
2540 | 619 | gtk_entry_set_width_chars (GTK_ENTRY (dtw->rotation_status), 7); | ||
2541 | 620 | gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (dtw->rotation_status), FALSE); | ||
2542 | 621 | gtk_spin_button_set_digits (GTK_SPIN_BUTTON (dtw->rotation_status), 2); | ||
2543 | 622 | gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (dtw->rotation_status), GTK_UPDATE_ALWAYS); | ||
2544 | 623 | g_signal_connect (G_OBJECT (dtw->rotation_status), "input", G_CALLBACK (sp_dtw_rotation_input), dtw); | ||
2545 | 624 | g_signal_connect (G_OBJECT (dtw->rotation_status), "output", G_CALLBACK (sp_dtw_rotation_output), dtw); | ||
2546 | 625 | g_object_set_data (G_OBJECT (dtw->rotation_status), "dtw", dtw->canvas); | ||
2547 | 626 | g_signal_connect (G_OBJECT (dtw->rotation_status), "focus-in-event", G_CALLBACK (spinbutton_focus_in), dtw->rotation_status); | ||
2548 | 627 | g_signal_connect (G_OBJECT (dtw->rotation_status), "key-press-event", G_CALLBACK (spinbutton_keypress), dtw->rotation_status); | ||
2549 | 628 | dtw->rotation_update = g_signal_connect (G_OBJECT (dtw->rotation_status), "value_changed", G_CALLBACK (sp_desktop_widget_rotate_document), dtw); | ||
2550 | 629 | dtw->rotation_update = g_signal_connect (G_OBJECT (dtw->rotation_status), "populate_popup", G_CALLBACK (sp_dtw_rotation_populate_popup), dtw); | ||
2551 | 630 | |||
2552 | 631 | auto rotstat = Glib::wrap(dtw->rotation_status); | ||
2553 | 632 | rotstat->set_name("RotationStatus"); | ||
2554 | 633 | auto context_rotation = rotstat->get_style_context(); | ||
2555 | 634 | context_rotation->add_provider(css_provider_spinbutton, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); | ||
2556 | 635 | |||
2557 | 596 | 636 | ||
2558 | 597 | // Cursor coordinates | 637 | // Cursor coordinates |
2559 | 598 | dtw->coord_status = gtk_grid_new(); | 638 | dtw->coord_status = gtk_grid_new(); |
2560 | @@ -619,12 +659,16 @@ | |||
2561 | 619 | 659 | ||
2562 | 620 | auto label_z = gtk_label_new(_("Z:")); | 660 | auto label_z = gtk_label_new(_("Z:")); |
2563 | 621 | gtk_widget_set_name(label_z, "ZLabel"); | 661 | gtk_widget_set_name(label_z, "ZLabel"); |
2564 | 662 | auto label_r = gtk_label_new(_("R:")); | ||
2565 | 663 | gtk_widget_set_name(label_r, "RLabel"); | ||
2566 | 622 | gtk_widget_set_halign(dtw->coord_status_x, GTK_ALIGN_END); | 664 | gtk_widget_set_halign(dtw->coord_status_x, GTK_ALIGN_END); |
2567 | 623 | gtk_widget_set_halign(dtw->coord_status_y, GTK_ALIGN_END); | 665 | gtk_widget_set_halign(dtw->coord_status_y, GTK_ALIGN_END); |
2568 | 624 | gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_x, 2, 0, 1, 1); | 666 | gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_x, 2, 0, 1, 1); |
2569 | 625 | gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_y, 2, 1, 1, 1); | 667 | gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_y, 2, 1, 1, 1); |
2570 | 626 | gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2); | 668 | gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2); |
2571 | 669 | gtk_grid_attach(GTK_GRID(dtw->coord_status), label_r, 5, 0, 1, 2); | ||
2572 | 627 | gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 4, 0, 1, 2); | 670 | gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 4, 0, 1, 2); |
2573 | 671 | gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->rotation_status, 6, 0, 1, 2); | ||
2574 | 628 | 672 | ||
2575 | 629 | sp_set_font_size_smaller (dtw->coord_status); | 673 | sp_set_font_size_smaller (dtw->coord_status); |
2576 | 630 | 674 | ||
2577 | @@ -692,6 +736,11 @@ | |||
2578 | 692 | g_signal_handlers_disconnect_matched (G_OBJECT (dtw->zoom_status), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, dtw->zoom_status); | 736 | g_signal_handlers_disconnect_matched (G_OBJECT (dtw->zoom_status), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, dtw->zoom_status); |
2579 | 693 | g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_value_changed), dtw); | 737 | g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_value_changed), dtw); |
2580 | 694 | g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_populate_popup), dtw); | 738 | g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_populate_popup), dtw); |
2581 | 739 | g_signal_handlers_disconnect_by_func(G_OBJECT (dtw->rotation_status), (gpointer) G_CALLBACK(sp_dtw_rotation_input), dtw); | ||
2582 | 740 | g_signal_handlers_disconnect_by_func(G_OBJECT (dtw->rotation_status), (gpointer) G_CALLBACK(sp_dtw_rotation_output), dtw); | ||
2583 | 741 | g_signal_handlers_disconnect_matched (G_OBJECT (dtw->rotation_status), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, dtw->rotation_status); | ||
2584 | 742 | g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->rotation_status), (gpointer) G_CALLBACK (sp_desktop_widget_rotate_document), dtw); | ||
2585 | 743 | g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->rotation_status), (gpointer) G_CALLBACK (sp_dtw_rotation_populate_popup), dtw); | ||
2586 | 695 | g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas), (gpointer) G_CALLBACK (sp_desktop_widget_event), dtw); | 744 | g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas), (gpointer) G_CALLBACK (sp_desktop_widget_event), dtw); |
2587 | 696 | g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas_tbl), (gpointer) G_CALLBACK (canvas_tbl_size_allocate), dtw); | 745 | g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas_tbl), (gpointer) G_CALLBACK (canvas_tbl_size_allocate), dtw); |
2588 | 697 | 746 | ||
2589 | @@ -1423,7 +1472,7 @@ | |||
2590 | 1423 | } else { | 1472 | } else { |
2591 | 1424 | gtk_widget_show_all (dtw->menubar); | 1473 | gtk_widget_show_all (dtw->menubar); |
2592 | 1425 | } | 1474 | } |
2594 | 1426 | 1475 | ||
2595 | 1427 | if (!prefs->getBool(pref_root + "commands/state", true)) { | 1476 | if (!prefs->getBool(pref_root + "commands/state", true)) { |
2596 | 1428 | gtk_widget_hide (dtw->commands_toolbox); | 1477 | gtk_widget_hide (dtw->commands_toolbox); |
2597 | 1429 | } else { | 1478 | } else { |
2598 | @@ -1629,10 +1678,11 @@ | |||
2599 | 1629 | dtw->menubar = sp_ui_main_menubar (dtw->desktop); | 1678 | dtw->menubar = sp_ui_main_menubar (dtw->desktop); |
2600 | 1630 | gtk_widget_set_name(dtw->menubar, "MenuBar"); | 1679 | gtk_widget_set_name(dtw->menubar, "MenuBar"); |
2601 | 1631 | gtk_widget_show_all (dtw->menubar); | 1680 | gtk_widget_show_all (dtw->menubar); |
2604 | 1632 | gtk_box_pack_start (GTK_BOX (dtw->vbox), dtw->menubar, FALSE, FALSE, 0); | 1681 | SPNamedView *nv = dtw->desktop->namedview; |
2605 | 1633 | 1682 | gtk_box_pack_start (GTK_BOX (dtw->vbox), dtw->menubar, TRUE, TRUE, 0); | |
2606 | 1634 | dtw->layoutWidgets(); | 1683 | dtw->layoutWidgets(); |
2608 | 1635 | 1684 | gtk_spin_button_set_value(GTK_SPIN_BUTTON (dtw->rotation_status), namedview->document_rotation); | |
2609 | 1685 | sp_namedview_set_document_rotation(namedview); | ||
2610 | 1636 | std::vector<GtkWidget *> toolboxes; | 1686 | std::vector<GtkWidget *> toolboxes; |
2611 | 1637 | toolboxes.push_back(dtw->tool_toolbox); | 1687 | toolboxes.push_back(dtw->tool_toolbox); |
2612 | 1638 | toolboxes.push_back(dtw->aux_toolbox); | 1688 | toolboxes.push_back(dtw->aux_toolbox); |
2613 | @@ -1672,6 +1722,8 @@ | |||
2614 | 1672 | void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags) | 1722 | void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags) |
2615 | 1673 | { | 1723 | { |
2616 | 1674 | SPNamedView *nv=SP_NAMEDVIEW(obj); | 1724 | SPNamedView *nv=SP_NAMEDVIEW(obj); |
2617 | 1725 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(this->rotation_status), desktop->namedview->document_rotation); | ||
2618 | 1726 | sp_namedview_set_document_rotation(nv); | ||
2619 | 1675 | 1727 | ||
2620 | 1676 | if (flags & SP_OBJECT_MODIFIED_FLAG) { | 1728 | if (flags & SP_OBJECT_MODIFIED_FLAG) { |
2621 | 1677 | this->dt2r = 1. / nv->display_units->factor; | 1729 | this->dt2r = 1. / nv->display_units->factor; |
2622 | @@ -1723,6 +1775,18 @@ | |||
2623 | 1723 | } | 1775 | } |
2624 | 1724 | 1776 | ||
2625 | 1725 | static void | 1777 | static void |
2626 | 1778 | sp_desktop_widget_rotate_document(GtkSpinButton *spin, SPDesktopWidget *dtw) | ||
2627 | 1779 | { | ||
2628 | 1780 | SPNamedView *nv = dtw->desktop->namedview; | ||
2629 | 1781 | double value = gtk_spin_button_get_value (spin); | ||
2630 | 1782 | if (!dtw->desktop->getDocument()->getRoot()->rotated && value != nv->document_rotation) { | ||
2631 | 1783 | sp_repr_set_svg_double(nv->getRepr(), "inkscape:document-rotation", value); | ||
2632 | 1784 | } | ||
2633 | 1785 | spinbutton_defocus (GTK_WIDGET(spin)); | ||
2634 | 1786 | } | ||
2635 | 1787 | |||
2636 | 1788 | |||
2637 | 1789 | static void | ||
2638 | 1726 | sp_desktop_widget_adjustment_value_changed (GtkAdjustment */*adj*/, SPDesktopWidget *dtw) | 1790 | sp_desktop_widget_adjustment_value_changed (GtkAdjustment */*adj*/, SPDesktopWidget *dtw) |
2639 | 1727 | { | 1791 | { |
2640 | 1728 | if (dtw->update) | 1792 | if (dtw->update) |
2641 | @@ -1802,6 +1866,34 @@ | |||
2642 | 1802 | return TRUE; | 1866 | return TRUE; |
2643 | 1803 | } | 1867 | } |
2644 | 1804 | 1868 | ||
2645 | 1869 | static gint | ||
2646 | 1870 | sp_dtw_rotation_input (GtkSpinButton *spin, gdouble *new_val, gpointer /*data*/) | ||
2647 | 1871 | { | ||
2648 | 1872 | gdouble new_scrolled = gtk_spin_button_get_value (spin); | ||
2649 | 1873 | const gchar *b = gtk_entry_get_text (GTK_ENTRY (spin)); | ||
2650 | 1874 | gdouble new_typed = atof (b); | ||
2651 | 1875 | |||
2652 | 1876 | if (new_scrolled == new_typed) { // the new value is set by scrolling | ||
2653 | 1877 | *new_val = new_scrolled; | ||
2654 | 1878 | } else { // the new value is typed in | ||
2655 | 1879 | *new_val = new_typed; | ||
2656 | 1880 | } | ||
2657 | 1881 | |||
2658 | 1882 | return TRUE; | ||
2659 | 1883 | } | ||
2660 | 1884 | |||
2661 | 1885 | static bool | ||
2662 | 1886 | sp_dtw_rotation_output (GtkSpinButton *spin, gpointer /*data*/) | ||
2663 | 1887 | { | ||
2664 | 1888 | gchar b[64]; | ||
2665 | 1889 | double val = gtk_spin_button_get_value (spin); | ||
2666 | 1890 | std::ostringstream s; | ||
2667 | 1891 | s.imbue(std::locale(""));; | ||
2668 | 1892 | s << std::fixed << std::setprecision(2) << val << "º"; | ||
2669 | 1893 | gtk_entry_set_text (GTK_ENTRY (spin), s.str().c_str()); | ||
2670 | 1894 | return TRUE; | ||
2671 | 1895 | } | ||
2672 | 1896 | |||
2673 | 1805 | static void | 1897 | static void |
2674 | 1806 | sp_dtw_zoom_value_changed (GtkSpinButton *spin, gpointer data) | 1898 | sp_dtw_zoom_value_changed (GtkSpinButton *spin, gpointer data) |
2675 | 1807 | { | 1899 | { |
2676 | @@ -1940,6 +2032,110 @@ | |||
2677 | 1940 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); | 2032 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); |
2678 | 1941 | } | 2033 | } |
2679 | 1942 | 2034 | ||
2680 | 2035 | |||
2681 | 2036 | static void | ||
2682 | 2037 | sp_dtw_rotation_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data) | ||
2683 | 2038 | { | ||
2684 | 2039 | GList *children, *iter; | ||
2685 | 2040 | GtkWidget *item; | ||
2686 | 2041 | SPDesktopWidget *dtw = static_cast<SPDesktopWidget*>(data); | ||
2687 | 2042 | children = gtk_container_get_children (GTK_CONTAINER (menu)); | ||
2688 | 2043 | for ( iter = children ; iter ; iter = g_list_next (iter)) { | ||
2689 | 2044 | gtk_container_remove (GTK_CONTAINER (menu), GTK_WIDGET (iter->data)); | ||
2690 | 2045 | } | ||
2691 | 2046 | g_list_free (children); | ||
2692 | 2047 | |||
2693 | 2048 | item = gtk_menu_item_new_with_label ("-180º"); | ||
2694 | 2049 | g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_minus_180), dtw); | ||
2695 | 2050 | gtk_widget_show (item); | ||
2696 | 2051 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); | ||
2697 | 2052 | |||
2698 | 2053 | item = gtk_menu_item_new_with_label ("-135º"); | ||
2699 | 2054 | g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_minus_135), dtw); | ||
2700 | 2055 | gtk_widget_show (item); | ||
2701 | 2056 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); | ||
2702 | 2057 | |||
2703 | 2058 | item = gtk_menu_item_new_with_label ("-90º"); | ||
2704 | 2059 | g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_minus_90), dtw); | ||
2705 | 2060 | gtk_widget_show (item); | ||
2706 | 2061 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); | ||
2707 | 2062 | |||
2708 | 2063 | item = gtk_menu_item_new_with_label ("-45º"); | ||
2709 | 2064 | g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_minus_45), dtw); | ||
2710 | 2065 | gtk_widget_show (item); | ||
2711 | 2066 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); | ||
2712 | 2067 | |||
2713 | 2068 | item = gtk_menu_item_new_with_label ("0º"); | ||
2714 | 2069 | g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_0), dtw); | ||
2715 | 2070 | gtk_widget_show (item); | ||
2716 | 2071 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); | ||
2717 | 2072 | |||
2718 | 2073 | item = gtk_menu_item_new_with_label ("45º"); | ||
2719 | 2074 | g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_45), dtw); | ||
2720 | 2075 | gtk_widget_show (item); | ||
2721 | 2076 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); | ||
2722 | 2077 | |||
2723 | 2078 | |||
2724 | 2079 | item = gtk_menu_item_new_with_label ("90º"); | ||
2725 | 2080 | g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_90), dtw); | ||
2726 | 2081 | gtk_widget_show (item); | ||
2727 | 2082 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); | ||
2728 | 2083 | |||
2729 | 2084 | |||
2730 | 2085 | item = gtk_menu_item_new_with_label ("135º"); | ||
2731 | 2086 | g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_135), dtw); | ||
2732 | 2087 | gtk_widget_show (item); | ||
2733 | 2088 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); | ||
2734 | 2089 | } | ||
2735 | 2090 | |||
2736 | 2091 | static void | ||
2737 | 2092 | sp_dtw_rotate_minus_180 (GtkMenuItem */*item*/, SPDesktopWidget * data) | ||
2738 | 2093 | { | ||
2739 | 2094 | gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status),-180); | ||
2740 | 2095 | } | ||
2741 | 2096 | |||
2742 | 2097 | static void | ||
2743 | 2098 | sp_dtw_rotate_minus_135 (GtkMenuItem */*item*/, SPDesktopWidget * data) | ||
2744 | 2099 | { | ||
2745 | 2100 | gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), -135); | ||
2746 | 2101 | } | ||
2747 | 2102 | |||
2748 | 2103 | static void | ||
2749 | 2104 | sp_dtw_rotate_minus_90 (GtkMenuItem */*item*/, SPDesktopWidget * data) | ||
2750 | 2105 | { | ||
2751 | 2106 | gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), -90); | ||
2752 | 2107 | } | ||
2753 | 2108 | |||
2754 | 2109 | static void | ||
2755 | 2110 | sp_dtw_rotate_minus_45 (GtkMenuItem */*item*/, SPDesktopWidget * data) | ||
2756 | 2111 | { | ||
2757 | 2112 | gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), -45); | ||
2758 | 2113 | } | ||
2759 | 2114 | |||
2760 | 2115 | static void | ||
2761 | 2116 | sp_dtw_rotate_0 (GtkMenuItem */*item*/,SPDesktopWidget * data) | ||
2762 | 2117 | { | ||
2763 | 2118 | gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), 0); | ||
2764 | 2119 | } | ||
2765 | 2120 | |||
2766 | 2121 | static void | ||
2767 | 2122 | sp_dtw_rotate_45 (GtkMenuItem */*item*/, SPDesktopWidget * data) | ||
2768 | 2123 | { | ||
2769 | 2124 | gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), 45); | ||
2770 | 2125 | } | ||
2771 | 2126 | |||
2772 | 2127 | static void | ||
2773 | 2128 | sp_dtw_rotate_90 (GtkMenuItem */*item*/, SPDesktopWidget * data) | ||
2774 | 2129 | { | ||
2775 | 2130 | gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), 90); | ||
2776 | 2131 | } | ||
2777 | 2132 | |||
2778 | 2133 | static void | ||
2779 | 2134 | sp_dtw_rotate_135 (GtkMenuItem */*item*/, SPDesktopWidget * data) | ||
2780 | 2135 | { | ||
2781 | 2136 | gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), 135); | ||
2782 | 2137 | } | ||
2783 | 2138 | |||
2784 | 1943 | static void | 2139 | static void |
2785 | 1944 | sp_dtw_zoom_menu_handler (SPDesktop *dt, gdouble factor) | 2140 | sp_dtw_zoom_menu_handler (SPDesktop *dt, gdouble factor) |
2786 | 1945 | { | 2141 | { |
2787 | 1946 | 2142 | ||
2788 | === modified file 'src/widgets/desktop-widget.h' | |||
2789 | --- src/widgets/desktop-widget.h 2015-12-09 15:13:54 +0000 | |||
2790 | +++ src/widgets/desktop-widget.h 2017-01-24 17:53:20 +0000 | |||
2791 | @@ -78,7 +78,7 @@ | |||
2792 | 78 | 78 | ||
2793 | 79 | GtkWidget *hbox; | 79 | GtkWidget *hbox; |
2794 | 80 | 80 | ||
2796 | 81 | GtkWidget *menubar, *statusbar; | 81 | GtkWidget *menubar, *statusbar, *rotatebar; |
2797 | 82 | 82 | ||
2798 | 83 | Inkscape::UI::Dialogs::SwatchesPanel *panels; | 83 | Inkscape::UI::Dialogs::SwatchesPanel *panels; |
2799 | 84 | 84 | ||
2800 | @@ -97,7 +97,9 @@ | |||
2801 | 97 | GtkWidget *select_status; | 97 | GtkWidget *select_status; |
2802 | 98 | GtkWidget *select_status_eventbox; | 98 | GtkWidget *select_status_eventbox; |
2803 | 99 | GtkWidget *zoom_status; | 99 | GtkWidget *zoom_status; |
2804 | 100 | GtkWidget *rotation_status; | ||
2805 | 100 | gulong zoom_update; | 101 | gulong zoom_update; |
2806 | 102 | gulong rotation_update; | ||
2807 | 101 | 103 | ||
2808 | 102 | Inkscape::UI::Widget::Dock *dock; | 104 | Inkscape::UI::Widget::Dock *dock; |
2809 | 103 | 105 | ||
2810 | 104 | 106 | ||
2811 | === modified file 'src/widgets/widget-sizes.h' | |||
2812 | --- src/widgets/widget-sizes.h 2014-03-27 01:33:44 +0000 | |||
2813 | +++ src/widgets/widget-sizes.h 2017-01-24 17:53:20 +0000 | |||
2814 | @@ -28,6 +28,7 @@ | |||
2815 | 28 | #define STATUS_BAR_FONT_SIZE 10000 | 28 | #define STATUS_BAR_FONT_SIZE 10000 |
2816 | 29 | 29 | ||
2817 | 30 | #define STATUS_ZOOM_WIDTH 57 | 30 | #define STATUS_ZOOM_WIDTH 57 |
2818 | 31 | #define STATUS_ROTATION_WIDTH 57 | ||
2819 | 31 | 32 | ||
2820 | 32 | #define SELECTED_STYLE_SB_WIDTH 48 | 33 | #define SELECTED_STYLE_SB_WIDTH 48 |
2821 | 33 | #define SELECTED_STYLE_WIDTH 190 | 34 | #define SELECTED_STYLE_WIDTH 190 |
The namespace should be saved somewhere instead of re-specified each time:
DOCROTATE = "{http:// www.inkscape. org/namespaces/ inkscape}document_rotation"
for example.
Everything else looks remarkably good for such a large diff.