Code

Make curvature work again by fixing a minor omission
[inkscape.git] / src / sp-namedview.cpp
index 9b4b7b3e754c1a58221a60766b28f1c3d1edef9a..47720c5d64f12fb9409e1f74aa7a537b457d0fe8 100644 (file)
@@ -19,6 +19,7 @@
 #include <string>
 
 #include "display/canvas-grid.h"
+#include "display/guideline.h"
 #include "helper/units.h"
 #include "svg/svg-color.h"
 #include "xml/repr.h"
@@ -53,6 +54,7 @@ static void sp_namedview_remove_child(SPObject *object, Inkscape::XML::Node *chi
 static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
 
 static void sp_namedview_setup_guides(SPNamedView * nv);
+static void sp_namedview_show_single_guide(SPGuide* guide, bool show);
 
 static gboolean sp_str_to_bool(const gchar *str);
 static gboolean sp_nv_read_opacity(const gchar *str, guint32 *color);
@@ -644,15 +646,7 @@ static void sp_namedview_child_added(SPObject *object, Inkscape::XML::Node *chil
                         sp_guide_sensitize(g,
                                            sp_desktop_canvas(static_cast<SPDesktop*> (l->data)),
                                            TRUE);
-                    if (nv->showguides) {
-                        for (GSList *v = SP_GUIDE(g)->views; v != NULL; v = v->next) {
-                            sp_canvas_item_show(SP_CANVAS_ITEM(v->data));
-                        }
-                    } else {
-                        for (GSList *v = SP_GUIDE(g)->views; v != NULL; v = v->next) {
-                            sp_canvas_item_hide(SP_CANVAS_ITEM(v->data));
-                        }
-                    }
+                    sp_namedview_show_single_guide(SP_GUIDE(g), nv->showguides);
                 }
             }
         }
@@ -712,15 +706,7 @@ void SPNamedView::show(SPDesktop *desktop)
         if (desktop->guides_active) {
             sp_guide_sensitize(SP_GUIDE(l->data), sp_desktop_canvas(desktop), TRUE);
         }
-        if (showguides) {
-            for (GSList *v = SP_GUIDE(l->data)->views; v != NULL; v = v->next) {
-                sp_canvas_item_show(SP_CANVAS_ITEM(v->data));
-            }
-        } else {
-            for (GSList *v = SP_GUIDE(l->data)->views; v != NULL; v = v->next) {
-                sp_canvas_item_hide(SP_CANVAS_ITEM(v->data));
-            }
-        }
+        sp_namedview_show_single_guide(SP_GUIDE(l->data), showguides);
     }
 
     views = g_slist_prepend(views, desktop);
@@ -759,12 +745,14 @@ void sp_namedview_window_from_document(SPDesktop *desktop)
        } else {
                gint w = MIN(gdk_screen_width(), nv->window_width);
                        gint h = MIN(gdk_screen_height(), nv->window_height);
+                       // prevent the window from moving off the screen to the right or to the bottom
                        gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x);
                        gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, nv->window_y);
+                       // prevent the window from moving off the screen to the left or to the top
+                       x = MAX(MIN_ONSCREEN_DISTANCE - nv->window_width, x);
+                       y = MAX(MIN_ONSCREEN_DISTANCE - nv->window_height, y);
                        if (w>0 && h>0) {
                                desktop->setWindowSize(w, h);
-                               x = MIN(gdk_screen_width() - w, x);
-                               y = MIN(gdk_screen_height() - h, y);
                                desktop->setWindowPosition(Geom::Point(x, y));
                        }
        }
@@ -873,18 +861,23 @@ void SPNamedView::activateGuides(gpointer desktop, gboolean active)
 static void sp_namedview_setup_guides(SPNamedView *nv)
 {
     for (GSList *l = nv->guides; l != NULL; l = l->next) {
-        if (nv->showguides) {
-            for (GSList *v = SP_GUIDE(l->data)->views; v != NULL; v = v->next) {
-                sp_canvas_item_show(SP_CANVAS_ITEM(v->data));
-            }
-        } else {
-            for (GSList *v = SP_GUIDE(l->data)->views; v != NULL; v = v->next) {
-                sp_canvas_item_hide(SP_CANVAS_ITEM(v->data));
-            }
-        }
+       sp_namedview_show_single_guide(SP_GUIDE(l->data), nv->showguides);
     }
 }
 
+static void sp_namedview_show_single_guide(SPGuide* guide, bool show)
+{
+       for (GSList *v = guide->views; v != NULL; v = v->next) {
+               if (show) {
+                       sp_canvas_item_show(SP_CANVAS_ITEM(v->data));
+                       sp_canvas_item_show(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin));
+               } else {
+                       sp_canvas_item_hide(SP_CANVAS_ITEM(v->data));
+                       sp_canvas_item_hide(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin));
+               }
+       }
+}
+
 void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr)
 {
     unsigned int v;