Author: miguel
Date: 2007-06-19 13:54:35 -0400 (Tue, 19 Jun 2007)
New Revision: 80212

Modified:
   trunk/moon/src/animation.cpp
   trunk/moon/src/animation.h
   trunk/moon/src/runtime.cpp
   trunk/moon/src/runtime.h
Log:
2007-06-19  Miguel de Icaza  <[EMAIL PROTECTED]>

        * runtime.cpp (Collection): Add new Insert method, and update all
        the callers that overwrote it.   We probably need to cleanup
        everything that is doing virtual overrides and is a no-op 



Modified: trunk/moon/src/animation.cpp
===================================================================
--- trunk/moon/src/animation.cpp        2007-06-19 17:53:49 UTC (rev 80211)
+++ trunk/moon/src/animation.cpp        2007-06-19 17:54:35 UTC (rev 80212)
@@ -680,6 +680,16 @@
 }
 
 void
+KeyFrameCollection::Insert (int index, DependencyObject *data)
+{
+       KeyFrame *kf = (KeyFrame *) data;
+
+       Collection::Insert (index, kf);
+       
+       sorted_list = g_slist_insert_sorted (sorted_list, kf, 
(GCompareFunc)compare_keyframes);
+}
+
+void
 KeyFrameCollection::Remove (DependencyObject *data)
 {
        KeyFrame *kf = (KeyFrame *) data;

Modified: trunk/moon/src/animation.h
===================================================================
--- trunk/moon/src/animation.h  2007-06-19 17:53:49 UTC (rev 80211)
+++ trunk/moon/src/animation.h  2007-06-19 17:54:35 UTC (rev 80212)
@@ -269,6 +269,7 @@
 
        virtual void Add (DependencyObject *obj);
        virtual void Remove (DependencyObject *obj);
+       virtual void Insert (int index, DependencyObject *data);
 
        KeyFrame *GetKeyFrameForTime (TimeSpan t, KeyFrame **previous_frame);
 

Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp  2007-06-19 17:53:49 UTC (rev 80211)
+++ trunk/moon/src/runtime.cpp  2007-06-19 17:54:35 UTC (rev 80212)
@@ -101,11 +101,28 @@
 }
 
 void
+Collection::SharedAdd (DependencyObject *data)
+{
+       data->ref ();
+       data->SetParent (this);
+       data->Attach (NULL, this);
+}
+
+void
 Collection::Add (DependencyObject *data)
 {
        g_return_if_fail 
(Type::Find(data->GetObjectType())->IsSubclassOf(GetElementType()));
 
        list = g_list_append (list, data);
+       SharedAdd (data);
+}
+
+void
+Collection::Insert (int index, DependencyObject *data)
+{
+       g_return_if_fail 
(Type::Find(data->GetObjectType())->IsSubclassOf(GetElementType()));
+
+       list = g_list_insert (list, data, index);
        data->ref ();
        data->SetParent (this);
        data->Attach (NULL, this);
@@ -163,6 +180,12 @@
        collection->Remove (data);
 }
 
+void
+collection_insert (Collection *collection, int index, DependencyObject *data)
+{
+       collection->Insert (index, data);
+}
+
 Type::Kind
 collection_get_element_type (Collection *collection)
 {
@@ -743,14 +766,11 @@
 }
 
 void
-VisualCollection::Add (DependencyObject *data)
+VisualCollection::VisualUpdate (DependencyObject *data)
 {
        Panel *panel = (Panel *) closure;
+       UIElement *item = (UIElement *) data;
        
-       UIElement *item = (UIElement *) data;
-
-       Collection::Add (item);
-
        item->parent = panel;
        item->update_xform ();
        item_update_bounds (panel);
@@ -758,6 +778,24 @@
 }
 
 void
+VisualCollection::Add (DependencyObject *data)
+{
+       UIElement *item = (UIElement *) data;
+       Collection::Add (item);
+       VisualUpdate (data);
+}
+
+void
+VisualCollection::Insert (int index, DependencyObject *data)
+{
+       UIElement *item = (UIElement *) data;
+
+       Collection::Insert (index, item);
+
+       VisualUpdate (data);
+}
+
+void
 VisualCollection::Remove (DependencyObject *data)
 {
        Panel *panel = (Panel *) closure;
@@ -2394,6 +2432,19 @@
 }
 
 void
+TriggerCollection::Insert (int index, DependencyObject *data)
+{
+       FrameworkElement *fwe = (FrameworkElement *) closure;
+       
+       printf ("Adding %p\n", data);
+       EventTrigger *trigger = (EventTrigger *) data;
+
+       Collection::Insert (index, trigger);
+
+       trigger->SetTarget (fwe);
+}
+
+void
 TriggerCollection::Remove (DependencyObject *data)
 {
        FrameworkElement *fwe = (FrameworkElement *) closure;

Modified: trunk/moon/src/runtime.h
===================================================================
--- trunk/moon/src/runtime.h    2007-06-19 17:53:49 UTC (rev 80211)
+++ trunk/moon/src/runtime.h    2007-06-19 17:54:35 UTC (rev 80212)
@@ -415,6 +415,10 @@
 
        virtual void Add    (DependencyObject *data);
        virtual void Remove (DependencyObject *data);
+       virtual void Insert (int index, DependencyObject *data);
+
+ private:
+       void SharedAdd (DependencyObject *data);
 };
 
 class CollectionIterator {
@@ -431,6 +435,8 @@
 
 void collection_add    (Collection *collection, DependencyObject *data);
 void collection_remove (Collection *collection, DependencyObject *data);
+void collection_insert (Collection *collection, int index, DependencyObject 
*data);
+
 Type::Kind collection_get_element_type (Collection *collection);
 CollectionIterator *collection_get_iterator (Collection *collection);
 
@@ -447,6 +453,10 @@
 
        virtual void Add    (DependencyObject *data);
        virtual void Remove (DependencyObject *data);
+       virtual void Insert (int index, DependencyObject *data);
+
+ private:
+       void VisualUpdate (DependencyObject *data);
 };
 
 class TriggerCollection : public Collection {
@@ -457,6 +467,7 @@
 
        virtual void Add    (DependencyObject *data);
        virtual void Remove (DependencyObject *data);
+       virtual void Insert (int index, DependencyObject *data);
 };
 
 class TriggerActionCollection : public Collection {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to