Author: spouliot
Date: 2007-10-03 15:33:00 -0400 (Wed, 03 Oct 2007)
New Revision: 86828

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/brush.cpp
   trunk/moon/src/brush.h
Log:
brush.cpp|h: SL and Cairo defaults to different values (end color versus start 
color) when a gradiant is restricted to a single color (e.g. if the start and 
end points of a linear gradient are identical).

Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-10-03 19:31:22 UTC (rev 86827)
+++ trunk/moon/src/ChangeLog    2007-10-03 19:33:00 UTC (rev 86828)
@@ -1,3 +1,10 @@
+2007-10-03  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * brush.cpp|h: SL and Cairo defaults to different values (end 
+       color versus start color) when a gradiant is restricted to a 
+       single color (e.g. if the start and end points of a linear 
+       gradient are identical).
+
 2007-10-03  Jeffrey Stedfast  <[EMAIL PROTECTED]>
 
        * text.cpp: Implemented the Glyphs element.

Modified: trunk/moon/src/brush.cpp
===================================================================
--- trunk/moon/src/brush.cpp    2007-10-03 19:31:22 UTC (rev 86827)
+++ trunk/moon/src/brush.cpp    2007-10-03 19:33:00 UTC (rev 86828)
@@ -288,7 +288,7 @@
 }
 
 void
-GradientBrush::SetupGradient (cairo_pattern_t *pattern, UIElement *uielement)
+GradientBrush::SetupGradient (cairo_pattern_t *pattern, UIElement *uielement, 
bool single)
 {
        GradientStopCollection *children = GetValue 
(GradientBrush::GradientStopsProperty)->AsGradientStopCollection ();
        GradientSpreadMethod gsm = gradient_brush_get_spread (this);
@@ -298,7 +298,15 @@
        // TODO - ColorInterpolationModeProperty is ignored (map to ?)
 
        double opacity = GetTotalOpacity (uielement);
-       node = (Collection::Node *) children->list->First ();
+
+       if (single) {
+               // if a single color is shown (e.g. start == end point) Cairo 
will,
+               // by default, use the start color while SL use the end color
+               node = (Collection::Node *) children->list->Last ();
+       } else {
+               node = (Collection::Node *) children->list->First ();
+       }
+
        for ( ; node != NULL; node = (Collection::Node *) node->next) {
                GradientStop *stop = (GradientStop *) node->obj;
                Color *color = gradient_stop_get_color (stop);
@@ -394,7 +402,8 @@
        cairo_matrix_invert (&matrix);
        cairo_pattern_set_matrix (pattern, &matrix);
 
-       GradientBrush::SetupGradient (pattern, uielement);
+       bool only_start = (x0 == x1 && y0 == y1);
+       GradientBrush::SetupGradient (pattern, uielement, only_start);
 
        cairo_set_source (cairo, pattern);
        cairo_pattern_destroy (pattern);

Modified: trunk/moon/src/brush.h
===================================================================
--- trunk/moon/src/brush.h      2007-10-03 19:31:22 UTC (rev 86827)
+++ trunk/moon/src/brush.h      2007-10-03 19:33:00 UTC (rev 86828)
@@ -106,7 +106,7 @@
 
        virtual void OnPropertyChanged (DependencyProperty *prop);
        virtual void OnCollectionChanged (Collection *col, CollectionChangeType 
type, DependencyObject *obj, DependencyProperty *prop);
-       virtual void SetupGradient (cairo_pattern_t *pattern, UIElement 
*uielement);
+       virtual void SetupGradient (cairo_pattern_t *pattern, UIElement 
*uielement, bool single = false);
 };
 
 GradientBrush* gradient_brush_new (void);

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

Reply via email to