summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-10-23 19:18:11 +0000
committerjabiertxof <info@marker.es>2016-10-23 19:18:11 +0000
commitb65d3fdc9c15af81c5e433d8f1b714ef4ab61487 (patch)
treeaf8cc5ec762018954d19001e2521d44c63ca7341 /src
parentAdd right click rotation panning (diff)
downloadinkscape-b65d3fdc9c15af81c5e433d8f1b714ef4ab61487.tar.gz
inkscape-b65d3fdc9c15af81c5e433d8f1b714ef4ab61487.zip
Add right click rotation panning, some fixes
(bzr r15142.1.23)
Diffstat (limited to 'src')
-rw-r--r--src/display/sp-canvas.cpp113
-rw-r--r--src/display/sp-canvas.h2
-rw-r--r--src/ui/tools/tool-base.cpp15
-rw-r--r--src/widgets/desktop-widget.cpp12
4 files changed, 82 insertions, 60 deletions
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index 115b8c613..242a30248 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -2101,12 +2101,21 @@ void SPCanvas::clearRotateTo()
if (!started) {
return;
}
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(&_widget, &allocation);
+ cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height);
+ cairo_t *cr = cairo_create(new_backing_store);
+ cairo_set_source(cr, _background);
+ cairo_paint(cr);
+ cairo_destroy(cr);
+ cairo_surface_destroy(_backing_store);
+ _backing_store = new_backing_store;
gtk_widget_queue_draw(GTK_WIDGET(this));
dirtyAll();
addIdle();
}
-void SPCanvas::rotateTo(SPCanvasItem * item, double angle, bool widget)
+void SPCanvas::rotateTo(SPCanvasItem * item, double angle)
{
if (!_backing_store || !started) {
return;
@@ -2163,58 +2172,56 @@ void SPCanvas::rotateTo(SPCanvasItem * item, double angle, bool widget)
cairo_fill(cr);
cairo_translate(cr, half_w, half_h);
cairo_rotate(cr, -angle*(M_PI/180.));
- if (!widget) {
- cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
- cairo_set_font_size(cr, 15.0);
- cairo_text_extents_t extents;
- std::ostringstream s;
- s << _("Original angle ") << std::fixed << std::setprecision(2) << start_angle << "º";
- cairo_text_extents(cr, s.str().c_str(), &extents);
- cairo_translate(cr, half_w - extents.width -15 ,-half_h + 25);
- cairo_set_source_rgba (cr, 1, 1, 1, 1);
- cairo_text_path(cr, s.str().c_str());
- cairo_fill(cr);
- cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 25) *-1);
- s.str("");
- s << _("New angle ") << std::fixed << std::setprecision(2) << angle << "º";
- cairo_text_extents(cr, s.str().c_str(), &extents);
- cairo_translate(cr, half_w - extents.width -15 ,-half_h + 45);
- cairo_text_path(cr, s.str().c_str());
- cairo_fill(cr);
- cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 45) *-1);
- s.str("");
- s << _("Gap ") << std::fixed << std::setprecision(2) << std::abs(start_angle-angle) << "º";
- cairo_text_extents(cr, s.str().c_str(), &extents);
- cairo_translate(cr, half_w - extents.width -15 ,-half_h + 65);
- cairo_text_path(cr, s.str().c_str());
- cairo_fill(cr);
- cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 65) *-1);
- cairo_translate(cr, -half_w + 10 ,-half_h + 25);
- s.str("");
- cairo_set_font_size(cr, 12.0);
- s << _("Normal mode, 1º round step");
- cairo_text_path(cr, s.str().c_str());
- cairo_fill(cr);
- cairo_translate(cr, (-half_w +10) * -1 ,(-half_h + 25) * -1);
- cairo_translate(cr, -half_w + 10 ,-half_h + 40);
- s.str("");
- s << _("+CTRL, Fractional degrees");
- cairo_text_path(cr, s.str().c_str());
- cairo_fill(cr);
- cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 40) * -1);
- cairo_translate(cr, -half_w + 10 ,-half_h + 55);
- s.str("");
- s << _("+SHIFT, 5º round step");
- cairo_text_path(cr, s.str().c_str());
- cairo_fill(cr);
- cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 55) * -1);
- cairo_translate(cr, -half_w + 10 ,-half_h + 70);
- s.str("");
- s << _("+CTRL+SHIFT, Reset");
- cairo_text_path(cr, s.str().c_str());
- cairo_fill(cr);
- //cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 60) * -1);
- }
+ cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+ cairo_set_font_size(cr, 15.0);
+ cairo_text_extents_t extents;
+ std::ostringstream s;
+ s << _("Original angle ") << std::fixed << std::setprecision(2) << start_angle << "º";
+ cairo_text_extents(cr, s.str().c_str(), &extents);
+ cairo_translate(cr, half_w - extents.width -15 ,-half_h + 25);
+ cairo_set_source_rgba (cr, 1, 1, 1, 1);
+ cairo_text_path(cr, s.str().c_str());
+ cairo_fill(cr);
+ cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 25) *-1);
+ s.str("");
+ s << _("New angle ") << std::fixed << std::setprecision(2) << angle << "º";
+ cairo_text_extents(cr, s.str().c_str(), &extents);
+ cairo_translate(cr, half_w - extents.width -15 ,-half_h + 45);
+ cairo_text_path(cr, s.str().c_str());
+ cairo_fill(cr);
+ cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 45) *-1);
+ s.str("");
+ s << _("Gap ") << std::fixed << std::setprecision(2) << std::abs(start_angle-angle) << "º";
+ cairo_text_extents(cr, s.str().c_str(), &extents);
+ cairo_translate(cr, half_w - extents.width -15 ,-half_h + 65);
+ cairo_text_path(cr, s.str().c_str());
+ cairo_fill(cr);
+ cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 65) *-1);
+ cairo_translate(cr, -half_w + 10 ,-half_h + 25);
+ s.str("");
+ cairo_set_font_size(cr, 12.0);
+ s << _("Normal mode, 1º round step");
+ cairo_text_path(cr, s.str().c_str());
+ cairo_fill(cr);
+ cairo_translate(cr, (-half_w +10) * -1 ,(-half_h + 25) * -1);
+ cairo_translate(cr, -half_w + 10 ,-half_h + 40);
+ s.str("");
+ s << _("+CTRL, Fractional degrees");
+ cairo_text_path(cr, s.str().c_str());
+ cairo_fill(cr);
+ cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 40) * -1);
+ cairo_translate(cr, -half_w + 10 ,-half_h + 55);
+ s.str("");
+ s << _("+SHIFT, 5º round step");
+ cairo_text_path(cr, s.str().c_str());
+ cairo_fill(cr);
+ cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 55) * -1);
+ cairo_translate(cr, -half_w + 10 ,-half_h + 70);
+ s.str("");
+ s << _("+CTRL+SHIFT, Reset");
+ cairo_text_path(cr, s.str().c_str());
+ cairo_fill(cr);
+ //cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 60) * -1);
cairo_destroy(cr);
cairo_surface_destroy(_backing_store);
_backing_store = new_backing_store;
diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h
index 628bc74ca..53b852140 100644
--- a/src/display/sp-canvas.h
+++ b/src/display/sp-canvas.h
@@ -73,7 +73,7 @@ struct SPCanvas {
/// Scrolls canvas to specific position (cx and cy are measured in screen pixels).
void scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling = false);
void startRotateTo(double angle);
- void rotateTo(SPCanvasItem * item, double angle, bool widget = false);
+ void rotateTo(SPCanvasItem * item, double angle);
bool endRotateTo();
void clearRotateTo();
/// Synchronously updates the canvas if necessary.
diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp
index 33c0492d7..f7315c648 100644
--- a/src/ui/tools/tool-base.cpp
+++ b/src/ui/tools/tool-base.cpp
@@ -516,7 +516,21 @@ bool ToolBase::root_handler(GdkEvent* event) {
break;
case GDK_BUTTON_RELEASE:
+ desktop->canvas->clearRotateTo();
if (this->space_panning && event->button.button == 3) {
+ xp = yp = 0;
+ if (panning_cursor == 1) {
+ panning_cursor = 0;
+ GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas());
+ gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor);
+ }
+ zoom_rb = 0;
+ if (panning) {
+ panning = 0;
+ sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
+ event->button.time);
+ }
+ ret = TRUE;
if (desktop->canvas->endRotateTo()) {
sp_repr_set_svg_double(desktop->namedview->getRepr(), "inkscape:document-rotation", angle);
SPObject *updated = SP_OBJECT(desktop->namedview);
@@ -580,7 +594,6 @@ bool ToolBase::root_handler(GdkEvent* event) {
ret = TRUE;
}
}
- desktop->canvas->clearRotateTo();
break;
case GDK_KEY_PRESS: {
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index bc08c4f58..477414342 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -1792,11 +1792,13 @@ sp_desktop_widget_rotate_document(GtkSpinButton *spin, SPDesktopWidget *dtw)
if (updated) {
updated->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
- //dtw->desktop->canvas->endRotateTo();
- }// else if( value != nv->document_rotation ) {
- //dtw->desktop->canvas->startRotateTo(value);
- // dtw->desktop->canvas->rotateTo(dtw->desktop->getDrawing(),value);
- // }
+ dtw->desktop->canvas->endRotateTo();
+ }
+// } else if( value != nv->document_rotation ) {
+// dtw->desktop->canvas->clearRotateTo();
+// dtw->desktop->canvas->startRotateTo(value);
+// dtw->desktop->canvas->rotateTo(dtw->desktop->getDrawing(),value);
+// }
spinbutton_defocus (GTK_WIDGET(spin));
}