rendered paste bodyIndex: enums.h
===================================================================
--- enums.h (revision 80804)
+++ enums.h (working copy)
@@ -58,4 +58,12 @@
VisibilityHidden
};
+enum CollectionChangeType {
+ CollectionChangeTypeItemAdded,
+ CollectionChangeTypeItemRemoved,
+ CollectionChangeTypeItemChanged,
+
+ CollectionChangeTypeChanged
+};
+
#endif
Index: geometry.h
===================================================================
--- geometry.h (revision 80804)
+++ geometry.h (working copy)
@@ -50,8 +50,6 @@
GeometryCollection () {}
virtual Type::Kind GetObjectType () { return Type::GEOMETRY_COLLECTION; }
virtual Type::Kind GetElementType () { return Type::GEOMETRY; }
-
- virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyProperty *subprop);
};
GeometryCollection* geometry_collection_new ();
@@ -68,6 +66,7 @@
virtual void OnPropertyChanged (DependencyProperty *prop);
virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyProperty *subprop);
+ virtual void OnCollectionChanged (Collection *col, CollectionChangeType type, DependencyObject *obj, DependencyProperty *prop);
virtual void Draw (cairo_t *cr);
};
@@ -124,8 +123,6 @@
PathFigureCollection () {}
virtual Type::Kind GetObjectType () { return Type::PATHFIGURE_COLLECTION; }
virtual Type::Kind GetElementType () { return Type::PATHFIGURE; }
-
- virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyProperty *subprop);
};
PathFigureCollection* path_figure_collection_new ();
@@ -141,6 +138,7 @@
virtual Type::Kind GetObjectType () { return Type::PATHGEOMETRY; };
virtual void OnPropertyChanged (DependencyProperty *prop);
+ virtual void OnCollectionChanged (Collection *col, CollectionChangeType type, DependencyObject *obj, DependencyProperty *prop);
virtual void Draw (cairo_t *cr);
// this is an element-by-element decision
@@ -180,8 +178,6 @@
PathSegmentCollection () {}
virtual Type::Kind GetObjectType () { return Type::PATHSEGMENT_COLLECTION; }
virtual Type::Kind GetElementType () { return Type::PATHSEGMENT; }
-
- virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyProperty *subprop);
};
PathSegmentCollection* path_segment_collection_new ();
@@ -200,6 +196,7 @@
virtual Type::Kind GetObjectType () { return Type::PATHFIGURE; };
virtual void OnPropertyChanged (DependencyProperty *prop);
+ virtual void OnCollectionChanged (Collection *col, CollectionChangeType type, DependencyObject *obj, DependencyProperty *prop);
virtual void Draw (cairo_t *cr);
};
PathFigure* path_figure_new ();
@@ -282,6 +279,8 @@
virtual Type::Kind GetObjectType () { return Type::LINESEGMENT; };
virtual void Draw (cairo_t *cr);
+
+ virtual void OnPropertyChanged (DependencyProperty *prop);
};
LineSegment *line_segment_new ();
Point* line_segment_get_point (LineSegment *segment);
Index: collection.h
===================================================================
--- collection.h (revision 80804)
+++ collection.h (working copy)
@@ -30,7 +30,7 @@
};
List *list;
- void *closure;
+ DependencyObject *closure;
Collection ();
virtual ~Collection ();
@@ -42,6 +42,8 @@
virtual void Insert (int index, DependencyObject *data);
virtual void Clear ();
+ virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyProperty *subprop);
+
private:
void SharedAdd (DependencyObject *data);
};
Index: dependencyobject.h
===================================================================
--- dependencyobject.h (revision 80804)
+++ dependencyobject.h (working copy)
@@ -11,6 +11,7 @@
#define __MONO_DEPOBJECT_H__
#include "value.h"
+#include "enums.h"
typedef void (*EventHandler) (gpointer data);
@@ -85,7 +86,13 @@
// returning TRUE.
//
virtual bool OnChildPropertyChanged (DependencyProperty *prop, DependencyObject *child) { return FALSE; }
-
+
+
+ //
+ // OnCollectionPropertyChanged:
+ //
+ virtual void OnCollectionChanged (Collection *col, CollectionChangeType type, DependencyObject *obj, DependencyProperty *prop) { }
+
virtual Type::Kind GetObjectType ();
Type* GetType ()
{
Index: geometry.cpp
===================================================================
--- geometry.cpp (revision 80804)
+++ geometry.cpp (working copy)
@@ -119,6 +119,14 @@
}
void
+GeometryGroup::OnCollectionChanged (Collection *col, CollectionChangeType type, DependencyObject *obj, DependencyProperty *prop)
+{
+ // GeometryGroup only has one collection, so let's save the hash lookup
+ //if (col == GetValue (GeometryGroup::ChildrenProperty)->AsGeometryCollection())
+ NotifyAttacheesOfPropertyChange (GeometryGroup::ChildrenProperty);
+}
+
+void
GeometryGroup::Draw (cairo_t *cr)
{
GeometryCollection *children = geometry_group_get_children (this);
@@ -156,12 +164,6 @@
return new GeometryCollection ();
}
-void
-GeometryCollection::OnSubPropertyChanged (DependencyProperty *prop, DependencyProperty *subprop)
-{
- NotifyAttacheesOfPropertyChange (subprop);
-}
-
//
// PathFigureCollection
//
@@ -172,12 +174,6 @@
return new PathFigureCollection ();
}
-void
-PathFigureCollection::OnSubPropertyChanged (DependencyProperty *prop, DependencyProperty *subprop)
-{
- NotifyAttacheesOfPropertyChange (subprop);
-}
-
//
// PathSegmentCollection
//
@@ -188,12 +184,6 @@
return new PathSegmentCollection ();
}
-void
-PathSegmentCollection::OnSubPropertyChanged (DependencyProperty *prop, DependencyProperty *subprop)
-{
- NotifyAttacheesOfPropertyChange (subprop);
-}
-
//
// EllipseGeometry
//
@@ -346,6 +336,14 @@
}
void
+PathGeometry::OnCollectionChanged (Collection *col, CollectionChangeType type, DependencyObject *obj, DependencyProperty *prop)
+{
+ // PathGeometry only has one collection, so let's save the hash lookup
+ //if (col == GetValue (PathGeometry::FiguresProperty)->AsPathFigureCollection ())
+ NotifyAttacheesOfPropertyChange (PathGeometry::FiguresProperty);
+}
+
+void
PathGeometry::Draw (cairo_t *cr)
{
PathFigureCollection *children = GetValue (PathGeometry::FiguresProperty)->AsPathFigureCollection();
@@ -480,9 +478,21 @@
newcol->closure = this;
}
}
+
+ if (prop->type == Type::PATHFIGURE) {
+ NotifyAttacheesOfPropertyChange (prop);
+ }
}
void
+PathFigure::OnCollectionChanged (Collection *col, CollectionChangeType type, DependencyObject *obj, DependencyProperty *prop)
+{
+ // PathFigure only has one collection, so let's save the hash lookup
+ //if (col == GetValue (PathFigure::SegmentsProperty)->AsPathSegmentCollection())
+ NotifyAttacheesOfPropertyChange (PathFigure::SegmentsProperty);
+}
+
+void
PathFigure::Draw (cairo_t *cr)
{
PathSegmentCollection *children = GetValue (PathFigure::SegmentsProperty)->AsPathSegmentCollection ();
@@ -754,6 +764,15 @@
cairo_line_to (cr, x, y);
}
+void
+LineSegment::OnPropertyChanged (DependencyProperty *prop)
+{
+ if (prop->type == Type::LINESEGMENT)
+ NotifyAttacheesOfPropertyChange (prop);
+ else
+ PathSegment::OnPropertyChanged (prop);
+}
+
//
// PolyBezierSegment
//
Index: collection.cpp
===================================================================
--- collection.cpp (revision 80804)
+++ collection.cpp (working copy)
@@ -60,6 +60,11 @@
g_return_if_fail (Type::Find(data->GetObjectType())->IsSubclassOf(GetElementType()));
list->Append (new Collection::Node (data, this));
+
+ data->Attach (NULL, this);
+
+ if (closure)
+ closure->OnCollectionChanged (this, CollectionChangeTypeItemAdded, data, NULL);
}
void
@@ -68,9 +73,24 @@
g_return_if_fail (Type::Find(data->GetObjectType())->IsSubclassOf(GetElementType()));
list->Insert (new Collection::Node (data, this), index);
+
+ data->Attach (NULL, this);
+
+ if (closure)
+ closure->OnCollectionChanged (this, CollectionChangeTypeItemAdded, data, NULL);
}
void
+Collection::OnSubPropertyChanged (DependencyProperty *prop, DependencyProperty *subprop)
+{
+ if (closure) {
+ /* unfortunately OnSubPropertyChanged doesn't give us
+ enough info to fill in the obj parameter here */
+ closure->OnCollectionChanged (this, CollectionChangeTypeItemChanged, NULL, subprop);
+ }
+}
+
+void
Collection::Remove (DependencyObject *data)
{
Collection::Node *n;
@@ -79,6 +99,9 @@
return;
n->Unlink ();
+
+ if (closure)
+ closure->OnCollectionChanged (this, CollectionChangeTypeItemRemoved, data, NULL);
delete n;
}
@@ -87,6 +110,9 @@
Collection::Clear ()
{
list->Clear (true);
+
+ if (closure)
+ closure->OnCollectionChanged (this, CollectionChangeTypeChanged, NULL, NULL);
}
void
Index: shape.cpp
===================================================================
--- shape.cpp (revision 80804)
+++ shape.cpp (working copy)
@@ -1089,6 +1089,13 @@
Shape::OnPropertyChanged (prop);
}
+void
+Path::OnSubPropertyChanged (DependencyProperty *prop, DependencyProperty *subprop)
+{
+ CleanupCache ();
+ FullInvalidate (false);
+}
+
Geometry *
path_get_data (Path *path)
{
Index: shape.h
===================================================================
--- shape.h (revision 80804)
+++ shape.h (working copy)
@@ -253,6 +253,7 @@
virtual bool CanFill ();
virtual void OnPropertyChanged (DependencyProperty *prop);
+ virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyProperty *subprop);
};
Path *path_new (void);