From 4a0131d1899c373cda20b36da683e9597b88ba87 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sat, 4 Feb 2017 01:10:10 +0100 Subject: Disable rotate guides in doc rotation (bzr r15470) --- src/sp-namedview.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src/sp-namedview.cpp') diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index c9e71955f..d430f6321 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -958,26 +958,26 @@ static void sp_namedview_lock_guides(SPNamedView *nv) } } -void sp_namedview_doc_rotate_guides(SPNamedView *nv) -{ - bool saved = DocumentUndo::getUndoSensitive(nv->document); - DocumentUndo::setUndoSensitive(nv->document, false); - SPRoot * root = nv->document->getRoot(); - Geom::Point page_center = root->viewBox.midpoint() * root->vbt; - Geom::Affine rot = Geom::identity(); - rot *= Geom::Translate(page_center).inverse(); - rot *= Geom::Rotate(Geom::rad_from_deg((nv->document_rotation - root->get_rotation()) * -1)); - rot *= Geom::Translate(page_center); - for(std::vector::iterator it=nv->guides.begin();it!=nv->guides.end();++it ) { - Geom::Point const on_line = (*it)->getPoint() * rot ; - (*it)->moveto(on_line, true); - Geom::Affine rot_normal_affine = Geom::Rotate(Geom::rad_from_deg((nv->document_rotation - root->get_rotation()) * -1)); - Geom::Point const rot_normal = (*it)->getNormal() * rot_normal_affine; - (*it)->set_normal(rot_normal, true); - } - DocumentUndo::setUndoSensitive(nv->document, saved); - nv->document->setModifiedSinceSave(); -} +//void sp_namedview_doc_rotate_guides(SPNamedView *nv) +//{ +// bool saved = DocumentUndo::getUndoSensitive(nv->document); +// DocumentUndo::setUndoSensitive(nv->document, false); +// SPRoot * root = nv->document->getRoot(); +// Geom::Point page_center = root->viewBox.midpoint() * root->vbt; +// Geom::Affine rot = Geom::identity(); +// rot *= Geom::Translate(page_center).inverse(); +// rot *= Geom::Rotate(Geom::rad_from_deg((nv->document_rotation - root->get_rotation()) * -1)); +// rot *= Geom::Translate(page_center); +// for(std::vector::iterator it=nv->guides.begin();it!=nv->guides.end();++it ) { +// Geom::Point const on_line = (*it)->getPoint() * rot ; +// (*it)->moveto(on_line, true); +// Geom::Affine rot_normal_affine = Geom::Rotate(Geom::rad_from_deg((nv->document_rotation - root->get_rotation()) * -1)); +// Geom::Point const rot_normal = (*it)->getNormal() * rot_normal_affine; +// (*it)->set_normal(rot_normal, true); +// } +// DocumentUndo::setUndoSensitive(nv->document, saved); +// nv->document->setModifiedSinceSave(); +//} void sp_namedview_set_document_rotation(SPNamedView *nv) { @@ -1005,7 +1005,7 @@ void sp_namedview_set_document_rotation(SPNamedView *nv) sp_canvas_item_affine_absolute(canvas_border, rot * root->vbt); nv->page_border_rotated = desktop->add_temporary_canvasitem(canvas_border, 0); } - sp_namedview_doc_rotate_guides(nv); + //sp_namedview_doc_rotate_guides(nv); nv->document->getRoot()->set_rotation(nv->document_rotation); c->unref(); } -- cgit v1.2.3 From 0dc3e9ec72db77e707135e42023bfb2d8e04bcbd Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 11 Feb 2017 21:55:19 +0100 Subject: Fix and improve window sizing and positioning behavior when opening new documents * The option "Remember and use last window's geometry" often had no effect. * When setting "Default window size" to "Large" the functions gdk_screen_width() / gdk_screen_height() were used to derive the size of the Inkscape window. However those functions return the combined screen size of all attached monitors resulting in window sizes that were too large. Now the size of the primary display is used. * In many cases the Inkscape window was moved to the top left corner of the combined screen area (which could be on a different monitor at best and outside of the visible screen area at worst). Inkscape should always spawn on the primary monitor now when not restoring the previous position. Fixed bugs: - https://launchpad.net/bugs/1190828 - https://launchpad.net/bugs/195683 - https://launchpad.net/bugs/568867 - https://launchpad.net/bugs/1654464 (bzr r15507) --- src/sp-namedview.cpp | 64 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 26 deletions(-) (limited to 'src/sp-namedview.cpp') diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index d430f6321..166e90238 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -754,7 +754,7 @@ void SPNamedView::show(SPDesktop *desktop) namespace { -gint const MIN_ONSCREEN_DISTANCE = 50; +gint const MIN_ONSCREEN_DISTANCE = 100; gdouble const NEWDOC_X_SCALE = 0.75; gdouble const NEWDOC_Y_SCALE = NEWDOC_X_SCALE; @@ -774,12 +774,6 @@ Geom::Point calcAnchorPoint(gint const x, gint const y, } // namespace -void SPNamedView::writeNewGrid(SPDocument *document,int gridtype) -{ - g_assert(this->getRepr() != NULL); - Inkscape::CanvasGrid::writeNewGridToRepr(this->getRepr(),document,static_cast(gridtype)); -} - /* * Restores window geometry from the document settings or defaults in prefs */ @@ -788,22 +782,42 @@ void sp_namedview_window_from_document(SPDesktop *desktop) SPNamedView *nv = desktop->namedview; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool geometry_from_file = (1 == prefs->getInt("/options/savewindowgeometry/value", 0)); + bool geometry_from_last = (2 == prefs->getInt("/options/savewindowgeometry/value", 0)); gint default_geometry = prefs->getInt("/options/defaultwindowsize/value", 1); bool new_document = (nv->window_width <= 0) || (nv->window_height <= 0); bool show_dialogs = true; // restore window size and position stored with the document - bool sizeSet = false; - - if ((geometry_from_file && nv->window_maximized) || (new_document && (default_geometry == 2))) { + if (geometry_from_last) { + // do nothing, as we already have code for that in interface.cpp + // TODO: Probably should not do similar things in two places + } else if ((geometry_from_file && nv->window_maximized) || (new_document && (default_geometry == 2))) { Gtk::Window *win = desktop->getToplevel(); if (win) { win->maximize(); } - sizeSet = true; - } else if (geometry_from_file && !nv->window_maximized) { - gint w = MIN(gdk_screen_width(), nv->window_width); - gint h = MIN(gdk_screen_height(), nv->window_height); + } else { + // gdk_screen_width() / gdk_screen_height() return the dimensions of all displays combined + // therefore we have to get the dimensions of one monitor explicitly (currently the primary monitor) + // TODO: account for multi-monitor setups (i.e. on which monitor do we want to display Inkscape?) + gint monitor_number; + GdkRectangle monitor_geometry; + monitor_number = gdk_screen_get_primary_monitor(gdk_screen_get_default()); + gdk_screen_get_monitor_geometry(gdk_screen_get_default(), monitor_number, &monitor_geometry); + + gint w = monitor_geometry.width; + gint h = monitor_geometry.height; + bool move_to_screen = false; + if (geometry_from_file and !new_document) { + w = MIN(w, nv->window_width); + h = MIN(h, nv->window_height); + move_to_screen = true; + } else if (default_geometry == 1) { + w *= NEWDOC_X_SCALE; + h *= NEWDOC_Y_SCALE; + } else if (default_geometry == 0) { + w = h = 0; // use the smallest possible window size; could be a factor like NEWDOC_X_SCALE in future + } if ((w > 0) && (h > 0)) { #ifndef WIN32 gint dx= 0; @@ -817,22 +831,14 @@ void sp_namedview_window_from_document(SPDesktop *desktop) show_dialogs = FALSE; } #endif - Geom::Point origin = calcAnchorPoint(nv->window_x, nv->window_y, w, h, MIN_ONSCREEN_DISTANCE); desktop->setWindowSize(w, h); - desktop->setWindowPosition(origin); - sizeSet = true; + if (move_to_screen) { + Geom::Point origin = calcAnchorPoint(nv->window_x, nv->window_y, w, h, MIN_ONSCREEN_DISTANCE); + desktop->setWindowPosition(origin); + } } } - if (!sizeSet && new_document && (default_geometry == 1)) - { - gint w = gdk_screen_width() * NEWDOC_X_SCALE; - gint h = gdk_screen_height() * NEWDOC_Y_SCALE; - Geom::Point origin = calcAnchorPoint(nv->window_x, nv->window_y, w, h, MIN_ONSCREEN_DISTANCE); - desktop->setWindowSize(w, h); - desktop->setWindowPosition(origin); - } - // restore zoom and view if (nv->zoom != 0 && nv->zoom != HUGE_VAL && !IS_NAN(nv->zoom) && nv->cx != HUGE_VAL && !IS_NAN(nv->cx) @@ -850,6 +856,12 @@ void sp_namedview_window_from_document(SPDesktop *desktop) } } +void SPNamedView::writeNewGrid(SPDocument *document,int gridtype) +{ + g_assert(this->getRepr() != NULL); + Inkscape::CanvasGrid::writeNewGridToRepr(this->getRepr(),document,static_cast(gridtype)); +} + bool SPNamedView::getSnapGlobal() const { return this->snap_manager.snapprefs.getSnapEnabledGlobally(); -- cgit v1.2.3 From 014489163050d8abe9e5c4949fb80f3c21b1c17b Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 13 Mar 2017 15:22:22 +0100 Subject: Replace rectangle based zooming by affine based zooming. This allows a rotation to be included in the drawing to window mapping. General code cleanup. Added documentation. Any change to zooming behavior is probably a bug. (bzr r15592) --- src/sp-namedview.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/sp-namedview.cpp') diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 166e90238..403b8a41b 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -839,18 +839,18 @@ void sp_namedview_window_from_document(SPDesktop *desktop) } } + // Cancel any history of transforms up to this point (must be before call to zoom). + desktop->clear_transform_history(); + // restore zoom and view if (nv->zoom != 0 && nv->zoom != HUGE_VAL && !IS_NAN(nv->zoom) && nv->cx != HUGE_VAL && !IS_NAN(nv->cx) && nv->cy != HUGE_VAL && !IS_NAN(nv->cy)) { - desktop->zoom_absolute(nv->cx, nv->cy, nv->zoom); + desktop->zoom_absolute_center_point( Geom::Point(nv->cx, nv->cy), nv->zoom ); } else if (desktop->getDocument()) { // document without saved zoom, zoom to its page desktop->zoom_page(); } - // cancel any history of zooms up to this point - desktop->zooms_past.clear(); - if (show_dialogs) { desktop->show_dialogs(); } @@ -1280,7 +1280,7 @@ void SPNamedView::translateGrids(Geom::Translate const &tr) { void SPNamedView::scrollAllDesktops(double dx, double dy, bool is_scrolling) { for(std::vector::iterator it=this->views.begin();it!=this->views.end();++it ) { - (*it)->scroll_world_in_svg_coords(dx, dy, is_scrolling); + (*it)->scroll_relative_in_svg_coords(dx, dy, is_scrolling); } } -- cgit v1.2.3