[f-spot: 23/41] use the CheckPattern for rendering, QueueDraw on CheckPattern change



commit c7577002a7aca4c2ec9f33f9e896bf0e113b8cca
Author: Stephane Delcroix <stephane delcroix org>
Date:   Wed Jun 10 10:57:50 2009 +0200

    use the CheckPattern for rendering, QueueDraw on CheckPattern change

 src/Widgets/CheckPattern.cs |   14 ++++++++++++++
 src/Widgets/ImageView.cs    |   18 ++++++++++--------
 2 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/src/Widgets/CheckPattern.cs b/src/Widgets/CheckPattern.cs
index 33e3321..53fa5eb 100644
--- a/src/Widgets/CheckPattern.cs
+++ b/src/Widgets/CheckPattern.cs
@@ -65,6 +65,20 @@ namespace FSpot.Widgets
 		public static CheckPattern Gray = new CheckPattern (0x00808080, 0x00808080, 8);
 		public static CheckPattern White = new CheckPattern (0x00ffffff, 0x00ffffff, 8);
 
+		public static bool operator== (CheckPattern left, CheckPattern right)
+		{
+			return (left.color1 == right.color1) &&
+			       (left.color2 == right.color2) &&
+			       (left.color1 == left.color2 || left.check_size == right.check_size);
+		}
+
+		public static bool operator!= (CheckPattern left, CheckPattern right)
+		{
+			return (left.color1 != right.color1) || 
+			       (left.color2 != right.color2) ||
+			       (left.color1 != left.color2 && left.check_size != right.check_size);
+		}
+
 		static uint s_to_h (string color)
 		{
 			return (uint)(Byte.Parse (color.Substring (1,2), System.Globalization.NumberStyles.AllowHexSpecifier) << 16) +
diff --git a/src/Widgets/ImageView.cs b/src/Widgets/ImageView.cs
index ea939a5..a0c5222 100644
--- a/src/Widgets/ImageView.cs
+++ b/src/Widgets/ImageView.cs
@@ -55,7 +55,12 @@ namespace FSpot.Widgets
 		CheckPattern check_pattern = CheckPattern.Dark;
 		public CheckPattern CheckPattern {
 			get { return check_pattern; } 
-			set { check_pattern = value; } 
+			set { 
+				if (check_pattern == value)
+					return;
+				check_pattern = value;
+				QueueDraw ();
+			} 
 		}
 
 		public PointerMode PointerMode {
@@ -221,7 +226,9 @@ namespace FSpot.Widgets
 			area.Intersect (new Rectangle (x_offset, y_offset, (int)Width, (int)Height));
 
 			//Short circuit for 1:1 zoom
-			if (zoom == 1.0) {
+			if (zoom == 1.0 &&
+			    !Pixbuf.HasAlpha &&
+			    Pixbuf.BitsPerSample == 8) {
 				BinWindow.DrawPixbuf (Style.BlackGC,
 						      Pixbuf,
 						      area.X, area.Y,
@@ -236,11 +243,6 @@ namespace FSpot.Widgets
 				if (Pixbuf.HasAlpha)
 					temp_pixbuf.Fill (0x00000000);
 
-				//FIXME: compute check pattern
-				uint check_black = 0x00000000;
-				uint check_dark = 0x00555555;
-				int check_medium = 8;
-
 				Pixbuf.CompositeColor (temp_pixbuf,
 						       0, 0,
 						       area.Width, area.Height,
@@ -248,7 +250,7 @@ namespace FSpot.Widgets
 						       zoom, zoom,
 						       zoom == 1.0 ? InterpType.Nearest : interpolation, 255,
 						       area.X - x_offset, area.Y - y_offset,
-						       check_medium, check_black, check_dark);
+						       CheckPattern.CheckSize, CheckPattern.Color1, CheckPattern.Color2);
 
 				BinWindow.DrawPixbuf (Style.BlackGC,
 						      temp_pixbuf,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]