Author: jbevain
Date: 2007-10-09 17:11:22 -0400 (Tue, 09 Oct 2007)
New Revision: 87225
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/media.cpp
trunk/moon/src/panel.cpp
trunk/moon/src/shape.cpp
trunk/moon/src/uielement.cpp
trunk/moon/src/uielement.h
Log:
2007-10-09 Jb Evain <[EMAIL PROTECTED]>
* uielement.h: define new methods RenderClipPath and
IntersectBoundsWithClipPath.
* uielement.cpp: implement them.
* panel.cpp, shape.cpp, media.cpp: use them.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-10-09 21:08:57 UTC (rev 87224)
+++ trunk/moon/src/ChangeLog 2007-10-09 21:11:22 UTC (rev 87225)
@@ -1,3 +1,10 @@
+2007-10-09 Jb Evain <[EMAIL PROTECTED]>
+
+ * uielement.h: define new methods RenderClipPath and
+ IntersectBoundsWithClipPath.
+ * uielement.cpp: implement them.
+ * panel.cpp, shape.cpp, media.cpp: use them.
+
2007-10-09 Chris Toshok <[EMAIL PROTECTED]>
* clock.cpp, trigger.cpp, uielement.cpp, geometry.cpp, shape.cpp,
Modified: trunk/moon/src/media.cpp
===================================================================
--- trunk/moon/src/media.cpp 2007-10-09 21:08:57 UTC (rev 87224)
+++ trunk/moon/src/media.cpp 2007-10-09 21:11:22 UTC (rev 87225)
@@ -320,13 +320,9 @@
Rect box = Rect (0, 0, w, h);
- Value *value = GetValue (UIElement::ClipProperty);
- if (value) {
- Geometry *geometry = value->AsGeometry ();
- box = box.Intersection (geometry->ComputeBounds (NULL));
- }
-
bounds = bounding_rect_for_transformed_rect (&absolute_xform, box);
+
+ IntersectBoundsWithClipPath ();
}
Point
@@ -373,12 +369,8 @@
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
cairo_set_matrix (cr, &absolute_xform);
- Value *value = GetValue (UIElement::ClipProperty);
- if (value) {
- Geometry *geometry = value->AsGeometry ();
- geometry->Draw (NULL, cr);
- cairo_clip (cr);
- }
+
+ RenderClipPath (cr);
pattern = image_brush_create_pattern (cr, surface, mplayer->width,
mplayer->height, pattern_opacity);
@@ -1293,12 +1285,7 @@
cairo_set_matrix (cr, &absolute_xform);
- Value *value = GetValue (UIElement::ClipProperty);
- if (value) {
- Geometry *geometry = value->AsGeometry ();
- geometry->Draw (NULL, cr);
- cairo_clip (cr);
- }
+ RenderClipPath (cr);
Stretch stretch = media_base_get_stretch (this);
@@ -1363,15 +1350,10 @@
Rect box = Rect (0,0,
framework_element_get_width (this),
framework_element_get_height (this));
-
- Value *value = GetValue (UIElement::ClipProperty);
- if (value) {
- Geometry *geometry = value->AsGeometry ();
- box = box.Intersection (geometry->ComputeBounds (NULL));
- }
-
- bounds = bounding_rect_for_transformed_rect (&absolute_xform,
- box);
+
+ bounds = bounding_rect_for_transformed_rect (&absolute_xform, box);
+
+ IntersectBoundsWithClipPath ();
// no-op bounds.GrowBy (1);
}
Modified: trunk/moon/src/panel.cpp
===================================================================
--- trunk/moon/src/panel.cpp 2007-10-09 21:08:57 UTC (rev 87224)
+++ trunk/moon/src/panel.cpp 2007-10-09 21:11:22 UTC (rev 87225)
@@ -139,16 +139,8 @@
bounds = bounds.Union (fw_rect);
}
- Value *value = GetValue (UIElement::ClipProperty);
- if (value) {
- Geometry *geometry = value->AsGeometry ();
- Rect box = geometry->ComputeBounds (NULL);
- box = bounding_rect_for_transformed_rect (&absolute_xform,
- box);
- bounds = box.Intersection (bounds);
- }
+ IntersectBoundsWithClipPath ();
-
/* standard "grow the rectangle by enough to cover our
asses because of cairo's floating point rendering"
thing */
@@ -239,14 +231,9 @@
cairo_set_matrix (cr, &absolute_xform);
- Value *value = GetValue (UIElement::ClipProperty);
- if (value) {
- Geometry *geometry = value->AsGeometry ();
- geometry->Draw (NULL, cr);
- cairo_clip (cr);
- }
+ RenderClipPath (cr);
- value = GetValue (Panel::BackgroundProperty);
+ Value *value = GetValue (Panel::BackgroundProperty);
if (value) {
double fwidth = framework_element_get_width (this);
double fheight = framework_element_get_height (this);
Modified: trunk/moon/src/shape.cpp
===================================================================
--- trunk/moon/src/shape.cpp 2007-10-09 21:08:57 UTC (rev 87224)
+++ trunk/moon/src/shape.cpp 2007-10-09 21:11:22 UTC (rev 87225)
@@ -138,12 +138,7 @@
cairo_set_matrix (cr, &absolute_xform);
- Value *value = GetValue (UIElement::ClipProperty);
- if (value) {
- Geometry *geometry = value->AsGeometry ();
- geometry->Draw (NULL, cr);
- cairo_clip (cr);
- }
+ RenderClipPath (cr);
// printf ("Draw, xform: %g %g %g %g %g %g\n",
// absolute_xform.xy,
@@ -292,14 +287,7 @@
//printf ("%f,%f,%f,%f\n", bounds.x, bounds.y, bounds.w,
bounds.h);
}
- Value *value = GetValue (UIElement::ClipProperty);
- if (value) {
- Geometry *geometry = value->AsGeometry ();
- Rect box = geometry->ComputeBounds (NULL);
- box = bounding_rect_for_transformed_rect (&absolute_xform,
- box);
- bounds = box.Intersection (bounds);
- }
+ IntersectBoundsWithClipPath ();
/* standard "grow the rectangle by enough to cover our
asses because of cairo's floating point rendering"
@@ -992,14 +980,7 @@
calc_line_bounds (line_get_x1 (this), line_get_x2 (this), line_get_y1
(this), line_get_y2 (this), thickness, &bounds);
bounds = bounding_rect_for_transformed_rect (&absolute_xform, bounds);
- Value *value = GetValue (UIElement::ClipProperty);
- if (value) {
- Geometry *geometry = value->AsGeometry ();
- Rect box = geometry->ComputeBounds (NULL);
- box = bounding_rect_for_transformed_rect (&absolute_xform,
- box);
- bounds = box.Intersection (bounds);
- }
+ IntersectBoundsWithClipPath ();
}
double
@@ -1265,14 +1246,7 @@
bounds = bounding_rect_for_transformed_rect (&absolute_xform, bounds);
- Value *value = GetValue (UIElement::ClipProperty);
- if (value) {
- Geometry *geometry = value->AsGeometry ();
- Rect box = geometry->ComputeBounds (NULL);
- box = bounding_rect_for_transformed_rect (&absolute_xform,
- box);
- bounds = box.Intersection (bounds);
- }
+ IntersectBoundsWithClipPath ();
}
void
@@ -1477,14 +1451,7 @@
bounds = bounding_rect_for_transformed_rect (&absolute_xform, bounds);
- Value *value = GetValue (UIElement::ClipProperty);
- if (value) {
- Geometry *geometry = value->AsGeometry ();
- Rect box = geometry->ComputeBounds (NULL);
- box = bounding_rect_for_transformed_rect (&absolute_xform,
- box);
- bounds = box.Intersection (bounds);
- }
+ IntersectBoundsWithClipPath ();
}
void
@@ -1660,14 +1627,7 @@
bounds = bounding_rect_for_transformed_rect (&absolute_xform, bounds);
- Value *value = GetValue (UIElement::ClipProperty);
- if (value) {
- Geometry *geometry = value->AsGeometry ();
- Rect box = geometry->ComputeBounds (NULL);
- box = bounding_rect_for_transformed_rect (&absolute_xform,
- box);
- bounds = box.Intersection (bounds);
- }
+ IntersectBoundsWithClipPath ();
}
void
Modified: trunk/moon/src/uielement.cpp
===================================================================
--- trunk/moon/src/uielement.cpp 2007-10-09 21:08:57 UTC (rev 87224)
+++ trunk/moon/src/uielement.cpp 2007-10-09 21:11:22 UTC (rev 87225)
@@ -77,6 +77,31 @@
}
void
+UIElement::IntersectBoundsWithClipPath ()
+{
+ Value *value = GetValue (UIElement::ClipProperty);
+ if (!value)
+ return;
+
+ Geometry *geometry = value->AsGeometry ();
+ Rect box = geometry->ComputeBounds (NULL);
+ box = bounding_rect_for_transformed_rect (&absolute_xform, box);
+ bounds = box.Intersection (bounds);
+}
+
+void
+UIElement::RenderClipPath (cairo_t *cr)
+{
+ Value *value = GetValue (UIElement::ClipProperty);
+ if (!value)
+ return;
+
+ Geometry *geometry = value->AsGeometry ();
+ geometry->Draw (NULL, cr);
+ cairo_clip (cr);
+}
+
+void
UIElement::OnPropertyChanged (DependencyProperty *prop)
{
if (prop->type != Type::UIELEMENT) {
Modified: trunk/moon/src/uielement.h
===================================================================
--- trunk/moon/src/uielement.h 2007-10-09 21:08:57 UTC (rev 87224)
+++ trunk/moon/src/uielement.h 2007-10-09 21:11:22 UTC (rev 87225)
@@ -35,7 +35,10 @@
Brush *opacityMask;
double total_opacity;
- public:
+protected:
+ void IntersectBoundsWithClipPath ();
+ void RenderClipPath (cairo_t *cr);
+public:
UIElement ();
virtual ~UIElement ();
virtual Type::Kind GetObjectType () { return Type::UIELEMENT; };
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches