Code

make more things private
authorbuliabyak <buliabyak@users.sourceforge.net>
Fri, 6 Feb 2009 23:17:40 +0000 (23:17 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Fri, 6 Feb 2009 23:17:40 +0000 (23:17 +0000)
src/shape-editor.cpp
src/shape-editor.h

index d7cafaed2ab12864d502e2e2f3a7c58d8f26593c..1b81e1a83acbefdda643ae52a4ad912ffea62500 100644 (file)
@@ -174,50 +174,55 @@ bool ShapeEditor::nodepath_edits_repr_key(gchar const *name) {
     return false;
 }
 
-static void shapeeditor_event_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *name,
-                                           gchar const */*old_value*/, gchar const */*new_value*/,
-                                           bool /*is_interactive*/, gpointer data)
+
+void ShapeEditor::shapeeditor_event_attr_changed(gchar const *name)
 {
     gboolean changed_np = FALSE;
     gboolean changed_kh = FALSE;
 
-    g_assert(data);
-    ShapeEditor *sh = ((ShapeEditor *) data);
-
-    if (sh->has_nodepath() && sh->nodepath_edits_repr_key(name))
+    if (has_nodepath() && nodepath_edits_repr_key(name))
     {
-        changed_np = !sh->has_local_change(SH_NODEPATH);
-        sh->decrement_local_change(SH_NODEPATH);
-
+        changed_np = !has_local_change(SH_NODEPATH);
+        decrement_local_change(SH_NODEPATH);
     }
 
     if (changed_np) {
         GList *saved = NULL;
-        if (sh->has_nodepath()) {
-            saved = sh->save_nodepath_selection();
+        if (has_nodepath()) {
+            saved = save_nodepath_selection();
         }
 
-        sh->reset_item(SH_NODEPATH);
+        reset_item(SH_NODEPATH);
 
-        if (sh->has_nodepath() && saved) {
-            sh->restore_nodepath_selection(saved);
+        if (has_nodepath() && saved) {
+            restore_nodepath_selection(saved);
             g_list_free (saved);
         }
     }
 
-
-    if (sh->has_knotholder())
+    if (has_knotholder())
     {
-        changed_kh = !sh->has_local_change(SH_KNOTHOLDER);
-        sh->decrement_local_change(SH_KNOTHOLDER);
+        changed_kh = !has_local_change(SH_KNOTHOLDER);
+        decrement_local_change(SH_KNOTHOLDER);
         if (changed_kh) {
             // this can happen if an LPEItem's knotholder handle was dragged, in which case we want
             // to keep the knotholder; in all other cases (e.g., if the LPE itself changes) we delete it
-            sh->reset_item(SH_KNOTHOLDER, !strcmp(name, "d"));
+            reset_item(SH_KNOTHOLDER, !strcmp(name, "d"));
         }
     }
 
-    sh->update_statusbar(); //TODO: sh->get_container()->update_statusbar();
+    update_statusbar(); //TODO: get_container()->update_statusbar();
+}
+
+
+static void shapeeditor_event_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *name,
+                                           gchar const */*old_value*/, gchar const */*new_value*/,
+                                           bool /*is_interactive*/, gpointer data)
+{
+    g_assert(data);
+    ShapeEditor *sh = ((ShapeEditor *) data);
+
+    sh->shapeeditor_event_attr_changed(name);
 }
 
 static Inkscape::XML::NodeEventVector shapeeditor_repr_events = {
@@ -230,8 +235,9 @@ static Inkscape::XML::NodeEventVector shapeeditor_repr_events = {
 
 
 void ShapeEditor::set_item(SPItem *item, SubType type, bool keep_knotholder) {
-    // this happens (and should only happen) when for an LPEItem having both knotholder and nodepath the knotholder
-    // is adapted; in this case we don't want to delete the knotholder since this freezes the handles
+    // this happens (and should only happen) when for an LPEItem having both knotholder and
+    // nodepath the knotholder is adapted; in this case we don't want to delete the knotholder
+    // since this freezes the handles
     unset_item(type, keep_knotholder);
 
     this->grab_node = -1;
@@ -305,23 +311,8 @@ void ShapeEditor::set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject,
     }
 }
 
-/** 
-*  pass a new knotholder to ShapeEditor to manage (and delete)
-*/
-void
-ShapeEditor::set_knotholder(KnotHolder * knot_holder)
-{
-    unset_item(SH_KNOTHOLDER);
-
-    this->grab_node = -1;
-
-    if (knot_holder) {
-        this->knotholder = knot_holder;
-    }
-}
-
 
-/** FIXME: think about this. Is this thing only called when the item needs to be updated?
+/** FIXME: This thing is only called when the item needs to be updated in response to repr change.
    Why not make a reload function in NodePath and in KnotHolder? */
 void ShapeEditor::reset_item (SubType type, bool keep_knotholder)
 {
index 8780586c40b7ac227e94c8955b23bfb57c2f7ce2..f30f1aa12f7d0bf045c63dc2a7eb4aae5ea8d994 100644 (file)
@@ -41,15 +41,10 @@ public:
 
     void set_item (SPItem *item, SubType type, bool keep_knotholder = false);
     void set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject, const char * key);
-    void set_knotholder(KnotHolder * knot_holder);
-    void reset_item (SubType type, bool keep_knotholder = true);
     void unset_item (SubType type, bool keep_knotholder = false);
 
-    const SPItem *get_item (SubType type);
-
-    bool has_nodepath ();
-    bool has_knotholder ();
-    void update_knotholder ();
+    bool has_nodepath (); //((deprecated))
+    void update_knotholder (); //((deprecated))
 
     bool has_local_change (SubType type);
     void decrement_local_change (SubType type);
@@ -122,10 +117,19 @@ public:
 
     bool nodepath_edits_repr_key(gchar const *name);
 
+    // this one is only public because it's called from non-C++ repr changed callback
+    void shapeeditor_event_attr_changed(gchar const *name);
+
 private:
+    bool has_knotholder ();
+    void reset_item (SubType type, bool keep_knotholder = true);
+    const SPItem *get_item (SubType type);
+
     SPDesktop *desktop;
 
     Inkscape::NodePath::Path *nodepath;
+
+    // TODO: std::list<KnotHolder *> knotholders;
     KnotHolder *knotholder;
 
     ShapeEditorsCollective *container;