Author: toshok
Date: 2007-07-07 16:21:36 -0400 (Sat, 07 Jul 2007)
New Revision: 81577
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/brush.cpp
trunk/moon/src/brush.h
trunk/moon/src/canvas.cpp
trunk/moon/src/frameworkelement.cpp
trunk/moon/src/frameworkelement.h
Log:
2007-07-07 Chris Toshok <[EMAIL PROTECTED]>
* brush.cpp: make sure to use GetSizeForBrush for everything
instead of cairo_stroke_extents, which won't work for non-stroked
elements like canvases. Also, notify changes to the
GradientStopCollection up the hierarchy properly.
* frameworkelement.h, frameworkelement.cpp: add a GetSizeForBrush
implementation for FrameworkElement so Canvases (and other
uielement subclasses) can have brushes assigned to them (canvas
uses it for its background.)
* canvas.cpp (Canvas::Render): remove the unused label.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-07-07 20:11:00 UTC (rev 81576)
+++ trunk/moon/src/ChangeLog 2007-07-07 20:21:36 UTC (rev 81577)
@@ -1,3 +1,17 @@
+2007-07-07 Chris Toshok <[EMAIL PROTECTED]>
+
+ * brush.cpp: make sure to use GetSizeForBrush for everything
+ instead of cairo_stroke_extents, which won't work for non-stroked
+ elements like canvases. Also, notify changes to the
+ GradientStopCollection up the hierarchy properly.
+
+ * frameworkelement.h, frameworkelement.cpp: add a GetSizeForBrush
+ implementation for FrameworkElement so Canvases (and other
+ uielement subclasses) can have brushes assigned to them (canvas
+ uses it for its background.)
+
+ * canvas.cpp (Canvas::Render): remove the unused label.
+
2007-07-06 Miguel de Icaza <[EMAIL PROTECTED]>
* media.cpp: Do not pass the filename as the result now on the
Modified: trunk/moon/src/brush.cpp
===================================================================
--- trunk/moon/src/brush.cpp 2007-07-07 20:11:00 UTC (rev 81576)
+++ trunk/moon/src/brush.cpp 2007-07-07 20:21:36 UTC (rev 81577)
@@ -285,6 +285,14 @@
NotifyAttacheesOfPropertyChange (prop);
}
+void
+GradientBrush::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
(GradientBrush::GradientStopsProperty);
+}
+
bool
GradientBrush::SetupGradient (cairo_pattern_t *pattern, UIElement *uielement)
{
@@ -357,8 +365,12 @@
if (uielement) {
uielement->GetSizeForBrush (cairo, &w, &h);
} else {
- h = framework_element_get_height ((FrameworkElement *)
uielement);
- w = framework_element_get_width ((FrameworkElement *)
uielement);
+ double x1, y1, x2, y2;
+
+ cairo_stroke_extents (cairo, &x1, &y1, &x2, &y2);
+
+ h = fabs (y2 - y1);
+ w = fabs (x2 - x1);
}
Point *start = linear_gradient_brush_get_start_point (this);
@@ -484,11 +496,21 @@
cairo_pattern_t *pattern = cairo_pattern_create_radial (ox, oy, 0.0,
cx, cy, ry);
- double x0, y0, x1, y1;
- cairo_stroke_extents (cairo, &x0, &y0, &x1, &y1);
+ double w, h;
+ if (uielement) {
+ uielement->GetSizeForBrush (cairo, &w, &h);
+ } else {
+ double x1, y1, x2, y2;
+
+ cairo_stroke_extents (cairo, &x1, &y1, &x2, &y2);
+
+ h = fabs (y2 - y1);
+ w = fabs (x2 - x1);
+ }
+
cairo_matrix_t matrix;
- cairo_matrix_init (&matrix, fabs (x1 - x0) * rx / ry, 0, 0, fabs (y1 -
y0), x0, y0);
+ cairo_matrix_init (&matrix, w * rx / ry, 0, 0, h, 0, 0);
Transform *transform = brush_get_transform (this);
if (transform) {
Modified: trunk/moon/src/brush.h
===================================================================
--- trunk/moon/src/brush.h 2007-07-07 20:11:00 UTC (rev 81576)
+++ trunk/moon/src/brush.h 2007-07-07 20:21:36 UTC (rev 81577)
@@ -106,6 +106,7 @@
virtual Type::Kind GetObjectType () { return Type::GRADIENTBRUSH; }
virtual void OnPropertyChanged (DependencyProperty *prop);
+ virtual void OnCollectionChanged (Collection *col, CollectionChangeType
type, DependencyObject *obj, DependencyProperty *prop);
virtual bool SetupGradient (cairo_pattern_t *pattern, UIElement
*uielement);
};
Modified: trunk/moon/src/canvas.cpp
===================================================================
--- trunk/moon/src/canvas.cpp 2007-07-07 20:11:00 UTC (rev 81576)
+++ trunk/moon/src/canvas.cpp 2007-07-07 20:21:36 UTC (rev 81577)
@@ -400,7 +400,6 @@
//printf ("RENDER: LEAVE\n");
//draw_grid (cr);
- leave:
level -= 4;
cairo_restore (cr);
}
Modified: trunk/moon/src/frameworkelement.cpp
===================================================================
--- trunk/moon/src/frameworkelement.cpp 2007-07-07 20:11:00 UTC (rev 81576)
+++ trunk/moon/src/frameworkelement.cpp 2007-07-07 20:21:36 UTC (rev 81577)
@@ -46,6 +46,22 @@
return true;
}
+void
+FrameworkElement::GetSizeForBrush (cairo_t *cr, double *width, double *height)
+{
+ double x1, x2, y1, y2;
+
+ x1 = y1 = 0.0;
+ x2 = framework_element_get_width (this);
+ y2 = framework_element_get_height (this);
+
+ cairo_matrix_transform_point (&absolute_xform, &x1, &y1);
+ cairo_matrix_transform_point (&absolute_xform, &x2, &y2);
+
+ *width = x2 - x1;
+ *height = y2 - y1;
+}
+
double
framework_element_get_height (FrameworkElement *framework_element)
{
Modified: trunk/moon/src/frameworkelement.h
===================================================================
--- trunk/moon/src/frameworkelement.h 2007-07-07 20:11:00 UTC (rev 81576)
+++ trunk/moon/src/frameworkelement.h 2007-07-07 20:21:36 UTC (rev 81577)
@@ -24,6 +24,8 @@
void OnPropertyChanged (DependencyProperty *prop);
virtual bool InsideObject (cairo_t *cr, double x, double y);
+
+ virtual void GetSizeForBrush (cairo_t *cr, double *width, double
*height);
};
G_BEGIN_DECLS
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches