Code

New Grids are now ready to go. bug testing can start i think.
authorjohanengelen <johanengelen@users.sourceforge.net>
Fri, 13 Apr 2007 20:49:26 +0000 (20:49 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Fri, 13 Apr 2007 20:49:26 +0000 (20:49 +0000)
src/desktop.cpp
src/display/canvas-grid.cpp
src/display/canvas-grid.h
src/snap.cpp
src/snap.h
src/sp-namedview.cpp
src/ui/dialog/document-properties.cpp

index 23a3bf959a89245e959c8d051a537efef3cd143b..4236fd7d8ee97af8bd76e5550176c6d6989337b9 100644 (file)
@@ -301,7 +301,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas)
     //   (Setting up after the connections are all in place, as it may use some of them)
     layer_manager = new Inkscape::LayerManager( this );
     
-    grids_visible = false;
+    grids_visible = true;
 }
 
 
index 6644092dffb3298d2f6e034b016655652999aa7f..6ca6b7f8335b732d1243d1997fb7479a94d1a884 100644 (file)
@@ -137,9 +137,6 @@ grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i
 
 CanvasGrid::CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr)
 {
-    snapenabled = true;
-    visible = true;
-
     repr = in_repr;
     if (repr) {
         repr->addListener (&_repr_events, this);
@@ -221,11 +218,7 @@ CanvasGrid::createCanvasItem(SPDesktop * desktop)
 
     GridCanvasItem * item = INKSCAPE_GRID_CANVASITEM( sp_canvas_item_new(sp_desktop_gridgroup(desktop), INKSCAPE_TYPE_GRID_CANVASITEM, NULL) );
     item->grid = this;
-    if (desktop->gridsEnabled()) {
-        sp_canvas_item_show(SP_CANVAS_ITEM(item));
-    } else {
-        sp_canvas_item_hide(SP_CANVAS_ITEM(item));
-    }
+    sp_canvas_item_show(SP_CANVAS_ITEM(item));
 
     gtk_object_ref(GTK_OBJECT(item));    // since we're keeping a link to this item, we need to bump up the ref count
     canvasitems = g_slist_prepend(canvasitems, item);
@@ -233,45 +226,6 @@ CanvasGrid::createCanvasItem(SPDesktop * desktop)
     return item;
 }
 
-
-void
-CanvasGrid::hide()
-{
-    for (GSList *l = canvasitems; l != NULL; l = l->next) {
-        sp_canvas_item_hide ( SP_CANVAS_ITEM(l->data) );
-    }
-    visible = false;
-    disable_snapping(); // temporary hack, because at the moment visibilty and snapping are linked
-}
-
-void
-CanvasGrid::show()
-{
-    for (GSList *l = canvasitems; l != NULL; l = l->next) {
-        sp_canvas_item_show ( SP_CANVAS_ITEM(l->data) );
-    }
-    visible = true;
-    enable_snapping(); // temporary hack, because at the moment visibilty and snapping are linked
-}
-
-void
-CanvasGrid::set_visibility(bool visible)
-{
-    this->visible = visible;
-    if(visible) {
-        show();
-    } else {
-        hide();
-    }
-}
-
-void
-CanvasGrid::toggle_visibility()
-{
-    visible = !visible;
-    set_visibility(visible);
-}
-
 void
 CanvasGrid::on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data)
 {
index db0f29f40cec4ca46df0d47d82b69f34f9270cc4..984ddad7983053e7cec67c3dc125bc4d0a939438 100644 (file)
@@ -75,14 +75,6 @@ public:
     
     virtual Gtk::Widget & getWidget() = 0;
 
-    void hide();
-    void show();
-    void set_visibility(bool visible);
-    void toggle_visibility();
-    void enable_snapping()  { snapenabled = true; snapper->setEnabled(true); } ;
-    void disable_snapping() { snapenabled = false; snapper->setEnabled(false); } ;
-    void toggle_snapping()  { snapenabled = !snapenabled; snapper->setEnabled(snapenabled);};
-
     Inkscape::XML::Node * repr;
     
     Inkscape::Snapper* snapper;
@@ -96,9 +88,6 @@ protected:
     
     Gtk::VBox vbox;
 
-    bool snapenabled;
-    bool visible;
-
 private:
     CanvasGrid(const CanvasGrid&);
     CanvasGrid& operator=(const CanvasGrid&);
index e9bdb70636405eb5789baca619086d9c4d8c7bfc..4f871e73670873e14b288795545130262f7a0588 100644 (file)
@@ -23,6 +23,9 @@
 
 #include "display/canvas-grid.h"
 
+#include "inkscape.h"
+#include "desktop.h"
+
 /**
  *  Construct a SnapManager for a SPNamedView.
  *
@@ -50,16 +53,14 @@ SnapManager::SnapperList SnapManager::getSnappers() const
     s.push_back(&guide);
     s.push_back(&object);
 
-    //add new grid snappers that are active for this desktop
-//    SPDesktop* desktop = SP_ACTIVE_DESKTOP;
-//    if (desktop) {
-
+    //FIXME: this code should do this: add new grid snappers that are active for this desktop
+    SPDesktop* desktop = SP_ACTIVE_DESKTOP;
+    if (desktop && desktop->gridsEnabled()) {
         for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) {
             Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data;
             s.push_back(grid->snapper);
         }
-
-//    }
+    }
 
     return s;
 }
index 09c527c749114552f59e85d4ab51699cf337345f..2f8e83b1364e28265e882ccdc56d5fa09dfb2bdf 100644 (file)
@@ -10,7 +10,7 @@
  *   Frank Felfe <innerspace@iname.com>
  *   Carl Hetherington <inkscape@carlh.net>
  *
- * Copyright (C) 2006      Johan Engelen <johan@shouraizou.nl>
+ * Copyright (C) 2006-2007 Johan Engelen <johan@shouraizou.nl>
  * Copyright (C) 2000-2002 Lauris Kaplinski
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
@@ -106,7 +106,6 @@ public:
 
     typedef std::list<const Inkscape::Snapper*> SnapperList;
     SnapperList getSnappers() const;
-    SnapperList gridSnappers;          ///< List of grid snappers to enable multiple grids
 
 protected:
     SPNamedView const *_named_view;
index c62c6b62e0c829deceda348526c38d6555bd11eb..a11904570dd626b2e08d61f231460900685f0a6b 100644 (file)
@@ -563,7 +563,6 @@ sp_namedview_add_grid(SPNamedView *nv, Inkscape::XML::Node *repr, SPDesktop *des
         //add canvasitem only for specified desktop
         grid->createCanvasItem(desktop);
     }
-    grid->show();
 
     return grid;
 }
index 8a6955003cef2cbcafca642916e7543ba38d8d3b..fa1ea475033c860bafef4a6f518ad4ef1bf809a2 100644 (file)
@@ -9,7 +9,7 @@
  *   Jon Phillips <jon@rejon.org>
  *   Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
  *
- * Copyright (C) 2006 Johan Engelen  <johan@shouraizou.nl>
+ * Copyright (C) 2006-2007 Johan Engelen  <johan@shouraizou.nl>
  * Copyright (C) 2000 - 2005 Authors
  *
  * Released under GNU GPL.  Read the file 'COPYING' for more information