Author: toshok
Date: 2007-11-08 15:14:39 -0500 (Thu, 08 Nov 2007)
New Revision: 89246
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/collection.cpp
trunk/moon/src/collection.h
trunk/moon/src/uielement.cpp
trunk/moon/src/uielement.h
Log:
2007-11-08 Chris Toshok <[EMAIL PROTECTED]>
[ may go a long way toward fixing #337714, if it doesn't fix it
outright ]
* uielement.h, uielement.cpp: add an overload of ChildInvalidated
that takes a UIElement* instead of a region. The implementation
just invalidates the entire bounds of the child in the parent.
* collection.h, collection.cpp: we weren't breaking the
item->parent link when removing visuals from a VisualCollection.
Add VisualRemoved, which invalidates the child's region (and stop
using child->Invalidate, since that won't work once the link to
the parent is broken) and breaks the parent link. Call
VisualRemoved from everywhere we remove/replace a visual in our
collection. Also, rename VisualUpdated to VisualAdded, since
that's more indicative of why the method is being called.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-11-08 19:50:58 UTC (rev 89245)
+++ trunk/moon/src/ChangeLog 2007-11-08 20:14:39 UTC (rev 89246)
@@ -1,3 +1,21 @@
+2007-11-08 Chris Toshok <[EMAIL PROTECTED]>
+
+ [ may go a long way toward fixing #337714, if it doesn't fix it
+ outright ]
+
+ * uielement.h, uielement.cpp: add an overload of ChildInvalidated
+ that takes a UIElement* instead of a region. The implementation
+ just invalidates the entire bounds of the child in the parent.
+
+ * collection.h, collection.cpp: we weren't breaking the
+ item->parent link when removing visuals from a VisualCollection.
+ Add VisualRemoved, which invalidates the child's region (and stop
+ using child->Invalidate, since that won't work once the link to
+ the parent is broken) and breaks the parent link. Call
+ VisualRemoved from everywhere we remove/replace a visual in our
+ collection. Also, rename VisualUpdated to VisualAdded, since
+ that's more indicative of why the method is being called.
+
2007-11-08 Jeffrey Stedfast <[EMAIL PROTECTED]>
* runtime.cpp (Attach): Emit the Resize event.
Modified: trunk/moon/src/collection.cpp
===================================================================
--- trunk/moon/src/collection.cpp 2007-11-08 19:50:58 UTC (rev 89245)
+++ trunk/moon/src/collection.cpp 2007-11-08 20:14:39 UTC (rev 89246)
@@ -436,10 +436,10 @@
void
-VisualCollection::VisualUpdate (DependencyObject *data)
+VisualCollection::VisualAdded (Visual *visual)
{
Panel *panel = (Panel *) closure;
- UIElement *item = (UIElement *) data;
+ UIElement *item = (UIElement *) visual;
if (panel == NULL)
return;
@@ -451,6 +451,25 @@
item->SetSurface (panel->GetSurface ());
}
+void
+VisualCollection::VisualRemoved (Visual *visual)
+{
+ UIElement *item = (UIElement *) visual;
+
+ if (item->parent == NULL)
+ return;
+
+ // we can't just call item->Invalidate() here, since
+ // dirty.cpp relies on the child->parent link being
+ // present. Instead we directly call ChildInvalidated
+ // with the entire bounds of the child (which is
+ // likely suboptimal, considering panels without
+ // backgrounds might have a more optimized region we
+ // can redraw).
+ item->parent->ChildInvalidated (item);
+ item->parent = NULL;
+}
+
bool
VisualCollection::Add (DependencyObject *data)
{
@@ -461,7 +480,7 @@
if (b) {
g_ptr_array_insert_sorted (z_sorted, UIElementZIndexComparer,
item);
- VisualUpdate (data);
+ VisualAdded (item);
if (closure && ((UIElement*)closure)->flags &
UIElement::IS_LOADED) {
/* emit loaded events on the new item if the tree
@@ -480,6 +499,8 @@
UIElement *old = (UIElement *) Collection::SetVal (index, item);
if (old) {
+ VisualRemoved (old);
+
g_ptr_array_remove (z_sorted, old);
g_ptr_array_insert_sorted (z_sorted, UIElementZIndexComparer,
item);
@@ -490,7 +511,7 @@
item->OnLoaded ();
}
- VisualUpdate (data);
+ VisualAdded (item);
}
return old;
@@ -512,7 +533,7 @@
item->OnLoaded ();
}
- VisualUpdate (data);
+ VisualAdded (item);
}
return b;
@@ -523,7 +544,8 @@
{
UIElement *item = (UIElement *) data;
- item->Invalidate ();
+ VisualRemoved (item);
+
bool b = Collection::Remove (item);
if (b)
@@ -541,7 +563,8 @@
UIElement *item = (UIElement *) n->obj;
- item->Invalidate ();
+ VisualRemoved (item);
+
bool b = Collection::RemoveAt (index);
if (b)
@@ -553,8 +576,9 @@
void
VisualCollection::Clear ()
{
- if (list->IsEmpty ())
- return;
+ Collection::Node *n;
+ for (n = (Collection::Node *) list->First (); n; n = (Collection::Node
*) n->next)
+ VisualRemoved ((UIElement*)n->obj);
g_ptr_array_set_size (z_sorted, 0);
Collection::Clear ();
Modified: trunk/moon/src/collection.h
===================================================================
--- trunk/moon/src/collection.h 2007-11-08 19:50:58 UTC (rev 89245)
+++ trunk/moon/src/collection.h 2007-11-08 20:14:39 UTC (rev 89246)
@@ -91,7 +91,8 @@
GPtrArray *z_sorted;
private:
- void VisualUpdate (DependencyObject *data);
+ void VisualAdded (Visual *visual);
+ void VisualRemoved (Visual *visual);
};
class TriggerCollection : public Collection {
Modified: trunk/moon/src/uielement.cpp
===================================================================
--- trunk/moon/src/uielement.cpp 2007-11-08 19:50:58 UTC (rev 89245)
+++ trunk/moon/src/uielement.cpp 2007-11-08 20:14:39 UTC (rev 89246)
@@ -326,6 +326,13 @@
}
void
+UIElement::ChildInvalidated (UIElement *child)
+{
+ Region region (child->GetBounds());
+ ChildInvalidated (®ion);
+}
+
+void
UIElement::ChildInvalidated (Region *region)
{
if (!GetVisible() || total_opacity <= 0.0)
Modified: trunk/moon/src/uielement.h
===================================================================
--- trunk/moon/src/uielement.h 2007-11-08 19:50:58 UTC (rev 89245)
+++ trunk/moon/src/uielement.h 2007-11-08 20:14:39 UTC (rev 89246)
@@ -184,6 +184,7 @@
//
bool InsideClip (cairo_t *cr, double x, double y);
+ void ChildInvalidated (UIElement *child);
void ChildInvalidated (Region *region);
//
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches