diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/desktop.cpp | 14 | ||||
| -rw-r--r-- | src/desktop.h | 3 | ||||
| -rw-r--r-- | src/display/drawing-item.cpp | 2 | ||||
| -rw-r--r-- | src/display/drawing.h | 1 | ||||
| -rw-r--r-- | src/display/sp-canvas.cpp | 56 | ||||
| -rw-r--r-- | src/preferences-skeleton.h | 1 | ||||
| -rw-r--r-- | src/ui/interface.cpp | 3 | ||||
| -rw-r--r-- | src/verbs.cpp | 10 | ||||
| -rw-r--r-- | src/verbs.h | 1 | ||||
| -rw-r--r-- | src/widgets/desktop-widget.cpp | 30 | ||||
| -rw-r--r-- | src/widgets/desktop-widget.h | 3 |
11 files changed, 114 insertions, 10 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp index 27d5582f1..027e6ff45 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -121,6 +121,7 @@ SPDesktop::SPDesktop() : _reconstruction_old_layer_id(), // an id attribute is not allowed to be the empty string _display_mode(Inkscape::RENDERMODE_NORMAL), _display_color_mode(Inkscape::COLORMODE_NORMAL), + _split_canvas(false), _widget( nullptr ), _guides_message_context( nullptr ), _active( false ), @@ -1545,6 +1546,19 @@ void SPDesktop::toggleGrids() } } +void SPDesktop::toggleSplitMode() +{ + Gtk::Window *parent = getToplevel(); + if (parent) { + _split_canvas = !_split_canvas; + SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget")); + dtw->splitCanvas(_split_canvas); + GtkAllocation allocation; + gtk_widget_get_allocation(GTK_WIDGET(dtw->canvas), &allocation); + getCanvas()->requestRedraw(getCanvas()->_x0, getCanvas()->_y0, allocation.width, allocation.height); + } +} + void SPDesktop::showGrids(bool show, bool dirty_document) { grids_visible = show; diff --git a/src/desktop.h b/src/desktop.h index ffee1ecf6..82ce3e1d6 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -402,6 +402,8 @@ public: bool colorProfAdjustEnabled(); void toggleGrids(); + void toggleSplitMode(); + bool splitMode() const { return _split_canvas; }; void toggleSnapGlobal(); bool gridsEnabled() const { return grids_visible; }; void showGrids(bool show, bool dirty_document = true); @@ -531,6 +533,7 @@ private: DesktopAffine _current_affine; std::list<DesktopAffine> transforms_past; std::list<DesktopAffine> transforms_future; + bool _split_canvas; bool _quick_zoom_enabled; ///< Signifies that currently we're in quick zoom mode DesktopAffine _quick_zoom_affine; ///< The transform of the screen before quick zoom diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index c8499e200..c9697043b 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -710,7 +710,7 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag { bool outline = _drawing.outline(); bool render_filters = _drawing.renderFilters(); - + std::cout << outline << "outline"<< std::endl; // stop_at is handled in DrawingGroup, but this check is required to handle the case // where a filtered item with background-accessing filter has enable-background: new if (this == stop_at) return RENDER_STOP; diff --git a/src/display/drawing.h b/src/display/drawing.h index 0204b4e4e..ecef4d8ee 100644 --- a/src/display/drawing.h +++ b/src/display/drawing.h @@ -60,6 +60,7 @@ public: void setBlurQuality(int q); void setFilterQuality(int q); void setExact(bool e); + bool getExact() const {return _exact;}; Geom::OptIntRect const &cacheLimit() const; void setCacheLimit(Geom::OptIntRect const &r); diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 947a2a6e3..927d7c9cd 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -32,6 +32,7 @@ #include <2geom/affine.h> #include "display/sp-canvas.h" #include "display/sp-canvas-group.h" +#include "display/canvas-arena.h" #include "display/rendermode.h" #include "display/cairo-utils.h" #include "preferences.h" @@ -1942,12 +1943,36 @@ int SPCanvas::paint() sp_canvas_item_invoke_update(_root, Geom::identity(), 0); _need_update = FALSE; } - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + SPCanvasArena *arena = nullptr; + bool split = false; + bool inverse = prefs->getBool("/window/splitcanvas/inverse", false); + double split_x = 1; + double split_y = 1; + double split_width = 1; + double split_height = 1; + if (desktop && desktop->splitMode()) { + split = desktop->splitMode(); + arena = SP_CANVAS_ARENA (desktop->drawing); + split_x = prefs->getDoubleLimited("/window/splitcanvas/x", 0.5, 0, 1); + split_y = prefs->getDoubleLimited("/window/splitcanvas/y", 1 , 0, 1); + } GtkAllocation allocation; gtk_widget_get_allocation(GTK_WIDGET(this), &allocation); - cairo_rectangle_int_t crect = { _x0, _y0, allocation.width, allocation.height }; - cairo_region_t *to_draw = cairo_region_create_rectangle(&crect); + 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; + cairo_region_t *to_draw_outline = nullptr; + if (inverse && split) { + to_draw = cairo_region_create_rectangle(&crect_outline); + to_draw_outline = cairo_region_create_rectangle(&crect); + } else { + to_draw = cairo_region_create_rectangle(&crect); + to_draw_outline = cairo_region_create_rectangle(&crect_outline); + } cairo_region_subtract(to_draw, _clean_region); + cairo_region_subtract(to_draw_outline, _clean_region); int n_rects = cairo_region_num_rectangles(to_draw); for (int i = 0; i < n_rects; ++i) { @@ -1956,16 +1981,39 @@ int SPCanvas::paint() if (!paintRect(crect.x, crect.y, crect.x + crect.width, crect.y + crect.height)) { // Aborted cairo_region_destroy(to_draw); + cairo_region_destroy(to_draw_outline); return FALSE; }; } - + + if (arena) { + Inkscape::RenderMode rm = arena->drawing.renderMode(); + arena->drawing.setRenderMode(Inkscape::RENDERMODE_OUTLINE); + bool exact = arena->drawing.getExact(); + arena->drawing.setExact(false); + int n_rects = cairo_region_num_rectangles(to_draw_outline); + for (int i = 0; i < n_rects; ++i) { + cairo_rectangle_int_t crect; + cairo_region_get_rectangle(to_draw_outline, i, &crect); + if (!paintRect(crect.x, crect.y, crect.x + crect.width, crect.y + crect.height)) { + // Aborted + arena->drawing.setExact(exact); + arena->drawing.setRenderMode(rm); + cairo_region_destroy(to_draw); + cairo_region_destroy(to_draw_outline); + return FALSE; + }; + } + arena->drawing.setExact(exact); + arena->drawing.setRenderMode(rm); + } // we've had a full unaborted redraw, reset the full redraw counter if (_forced_redraw_limit != -1) { _forced_redraw_count = 0; } cairo_region_destroy(to_draw); + cairo_region_destroy(to_draw_outline); return TRUE; } diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 0d7e6df91..144ad5096 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -37,6 +37,7 @@ static char const preferences_skeleton[] = " <group id=\"panels\" state=\"1\"/>\n" " <group id=\"rulers\" state=\"1\"/>\n" " <group id=\"scrollbars\" state=\"1\"/>\n" +" <group id=\"splitcanvas\" x=\"0.5\" y=\"0\" inverse=\"0\" />\n" " </group>\n" " <group id=\"fullscreen\">\n" " <group id=\"task\" />\n" diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 088419edd..a760cd9d1 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -624,6 +624,9 @@ static gboolean checkitem_update(GtkWidget *widget, cairo_t * /*cr*/, gpointer u else if (!strcmp(action->id, "ViewCmsToggle")) { ison = dt->colorProfAdjustEnabled(); } + else if (!strcmp(action->id, "ViewSplitModeToggle")) { + ison = dt->splitMode(); + } else { ison = getViewStateFromPref(view, pref); } diff --git a/src/verbs.cpp b/src/verbs.cpp index a167d20a7..fa87cc691 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -2146,6 +2146,9 @@ void ZoomVerb::perform(SPAction *action, void *data) case SP_VERB_VIEW_COLOR_MODE_TOGGLE: dt->displayColorModeToggle(); break; + case SP_VERB_VIEW_TOGGLE_SPLIT: + dt->toggleSplitMode(); + break; case SP_VERB_VIEW_CMS_TOGGLE: dt->toggleColorProfAdjust(); break; @@ -3118,10 +3121,13 @@ Verb *Verb::_base_verbs[] = { // N_("Switch to print colors preview mode"), NULL), new ZoomVerb(SP_VERB_VIEW_COLOR_MODE_TOGGLE, "ViewColorModeToggle", N_("_Toggle"), N_("Toggle between normal and grayscale color display modes"), nullptr), - + + new ZoomVerb(SP_VERB_VIEW_TOGGLE_SPLIT, "ViewSplitModeToggle", N_("Togg_le Split View Mode"), + N_("Split canvas in 2 to show outline"), INKSCAPE_ICON("dot")), + new ZoomVerb(SP_VERB_VIEW_CMS_TOGGLE, "ViewCmsToggle", N_("Color-managed view"), N_("Toggle color-managed display for this document window"), INKSCAPE_ICON("color-management")), - + new ZoomVerb(SP_VERB_VIEW_ICON_PREVIEW, "ViewIconPreview", N_("Ico_n Preview..."), N_("Open a window to preview objects at different icon resolutions"), INKSCAPE_ICON("dialog-icon-preview")), diff --git a/src/verbs.h b/src/verbs.h index d93f63da5..153d793ab 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -303,6 +303,7 @@ enum { // SP_VERB_VIEW_COLOR_MODE_PRINT_COLORS_PREVIEW, SP_VERB_VIEW_COLOR_MODE_TOGGLE, + SP_VERB_VIEW_TOGGLE_SPLIT, SP_VERB_VIEW_CMS_TOGGLE, SP_VERB_VIEW_ICON_PREVIEW, diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 8a6f3365a..e4cc1d633 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -59,6 +59,7 @@ #include "extension/db.h" #include "helper/action.h" +#include "helper/icon-loader.h" #include "object/sp-image.h" #include "object/sp-namedview.h" @@ -87,6 +88,7 @@ #include "toolbox.h" #include "widget-sizes.h" + using Inkscape::UI::Widget::UnitTracker; using Inkscape::UI::UXManager; using Inkscape::UI::ToolboxFactory; @@ -105,6 +107,12 @@ static void sp_desktop_widget_realize (GtkWidget *widget); static gint sp_desktop_widget_event (GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dtw); static void sp_dtw_color_profile_event(EgeColorProfTracker *widget, SPDesktopWidget *dtw); + +static void sp_update_guides_lock( GtkWidget *button, gpointer data ); +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +static void cms_adjust_toggled( GtkWidget *button, gpointer data ); +#endif // defined(HAVE_LIBLCMS1)GtkImage || defined(HAVE_LIBLCMS2) +static void cms_adjust_set_sensitive( SPDesktopWidget *dtw, bool enabled ); static void sp_desktop_widget_adjustment_value_changed (GtkAdjustment *adj, SPDesktopWidget *dtw); static gdouble sp_dtw_zoom_value_to_display (gdouble value); @@ -378,6 +386,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_widget_set_name(dtw->canvas_tbl, "CanvasTable"); // Added to table wrapper later either directly or via paned window shared with dock. + + + // Lock guides button dtw->_guides_lock = Glib::wrap(GTK_TOGGLE_BUTTON( sp_button_new_from_data( GTK_ICON_SIZE_MENU, @@ -496,7 +507,6 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) } watcher->add(dtw); } - /* Canvas */ dtw->canvas = SP_CANVAS(SPCanvas::createAA()); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -522,7 +532,6 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_widget_set_hexpand(GTK_WIDGET(dtw->canvas), TRUE); gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas), TRUE); - gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 1, 1, 1); /* Dock */ bool create_dock = @@ -776,7 +785,22 @@ SPDesktopWidget::dispose(GObject *object) } } - +void +SPDesktopWidget::splitCanvas(bool split) +{ + if(split) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double split_x = prefs->getDoubleLimited("/window/splitcanvas/x", 0.5, 0, 1); + double split_y = prefs->getDoubleLimited("/window/splitcanvas/y", 1 , 0, 1); + int width = gtk_widget_get_allocated_width(GTK_WIDGET(this->canvas)); + int height = gtk_widget_get_allocated_height(GTK_WIDGET(this->canvas)); + gtk_widget_set_margin_start(this->split_button, width * split_x); + gtk_widget_set_margin_end(this->split_button, height * split_y); + gtk_widget_set_visible(this->split_button, true); + } else { + gtk_widget_set_visible(this->split_button, false); + } +} /** * Set the title in the desktop-window (if desktop has an own window). * diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 198fd23c6..cc116d812 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -16,6 +16,8 @@ */ #include <gtkmm/window.h> +#include <gtkmm/overlay.h> +#include "include/gtkmm_version.h" #include "message.h" #include "ui/view/view-widget.h" #include "ui/view/edit-widget-interface.h" @@ -253,6 +255,7 @@ public: void requestCanvasUpdateAndWait(); void enableInteraction(); void disableInteraction(); + void splitCanvas(bool split); void updateTitle(gchar const *uri); bool onFocusInEvent(GdkEventFocus*); |
