diff options
| author | Jabiertxof <jabier.arraiza@marker.es> | 2018-11-09 18:40:54 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2018-12-01 16:17:15 +0000 |
| commit | 70db44bc2652f6331a47a0de9074136c30f62184 (patch) | |
| tree | 6898e2d3472d1a65f681e250875778cc38c31197 /src | |
| parent | Adding draggin area (diff) | |
| download | inkscape-70db44bc2652f6331a47a0de9074136c30f62184.tar.gz inkscape-70db44bc2652f6331a47a0de9074136c30f62184.zip | |
Working with canvas to split
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/sp-canvas.cpp | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index bff1578df..ae7427f69 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1532,22 +1532,36 @@ int SPCanvas::handle_motion(GtkWidget *widget, GdkEventMotion *event) return FALSE; Geom::IntPoint cursor_pos = Geom::IntPoint(event->x,event->y); + std::cout << *canvas->_spliter << std::endl; + std::cout << cursor_pos << std::endl; + std::cout << canvas->_is_dragging << std::endl; + GdkDisplay *display = gdk_display_get_default(); if (canvas->_spliter && (*canvas->_spliter).contains(cursor_pos) && !canvas->_is_dragging) { - canvas->_oversplit = true; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool vertical = prefs->getBool("/window/splitcanvas/vertical", true); - GdkDisplay *display = gdk_display_get_default(); - GdkCursor *cursor = nullptr; - if(vertical) { - cursor = gdk_cursor_new_from_name (display, "ew-resize"); - } else { - cursor = gdk_cursor_new_from_name (display, "ns-resize"); - } - if (cursor) { - gdk_window_set_cursor (gtk_widget_get_window(widget), cursor); - g_object_unref (cursor); + if (!canvas->_oversplit) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool vertical = prefs->getBool("/window/splitcanvas/vertical", true); + GdkCursor *cursor = nullptr; + if(vertical) { + cursor = gdk_cursor_new_from_name (display, "ew-resize"); + } else { + cursor = gdk_cursor_new_from_name (display, "ns-resize"); + } + if (cursor) { + gdk_window_set_cursor (gtk_widget_get_window(widget), cursor); + g_object_unref (cursor); + } } + canvas->_oversplit = true; + std::cout << "overoverover" << std::endl; } else { + if (canvas->_oversplit) { + GdkCursorType cursor_type = GDK_HAND1; + GdkCursor *cursor = gdk_cursor_new_for_display(display, cursor_type); + if (cursor) { + gdk_window_set_cursor (gtk_widget_get_window(widget), cursor); + g_object_unref (cursor); + } + } canvas->_oversplit = false; } canvas->_state = event->state; @@ -1964,6 +1978,8 @@ int SPCanvas::paint() sp_canvas_item_invoke_update(_root, Geom::identity(), 0); _need_update = FALSE; } + GtkAllocation allocation; + gtk_widget_get_allocation(GTK_WIDGET(this), &allocation); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); SPDesktop *desktop = SP_ACTIVE_DESKTOP; SPCanvasArena *arena = nullptr; @@ -1978,10 +1994,12 @@ int SPCanvas::paint() arena = SP_CANVAS_ARENA (desktop->drawing); split_x = !vertical ? 1 : value; split_y = vertical ? 1 : value; + Geom::IntCoord coord1x = allocation.x + (int(allocation.width * (1-split_x))) - 1; + Geom::IntCoord coord1y = allocation.y + (int(allocation.height * (1-split_y))) - 1; + Geom::IntCoord coord2x = allocation.x + (int(allocation.width * split_x)) + 1; + Geom::IntCoord coord2y = allocation.y + (int(allocation.height * split_y)) + 1; + _spliter = Geom::OptIntRect(coord1x, coord1y, coord2x, coord2y); } - GtkAllocation allocation; - gtk_widget_get_allocation(GTK_WIDGET(this), &allocation); - cairo_rectangle_int_t crect = { _x0, _y0, int(allocation.width * split_x), int(allocation.height * split_y)}; cairo_rectangle_int_t crect_outline = { _x0 + int(allocation.width * (1-split_x)), _y0 + int(allocation.height * (1-split_y)), int(allocation.width * split_x), int(allocation.height * split_y)}; cairo_region_t *to_draw = nullptr; @@ -2030,12 +2048,6 @@ int SPCanvas::paint() arena->drawing.setRenderMode(rm); } - if (desktop && desktop->splitMode()) { - split_x = int(allocation.width * split_x); - split_y = int(allocation.height * split_y); - _spliter = Geom::OptIntRect(_x0 + split_x - 1, _y0 + split_y - 1,_x0 + split_x + 1, _y0 + split_y - 1); - } - // we've had a full unaborted redraw, reset the full redraw counter if (_forced_redraw_limit != -1) { _forced_redraw_count = 0; |
