[longomatch] Set colors for home and away teams



commit 9cf579d7bfa266125dbe4bc4798d3271c04bbc09
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue Aug 6 11:51:42 2013 +0200

    Set colors for home and away teams

 LongoMatch.Core/Common/Color.cs                  |    8 ++++++++
 LongoMatch.GUI/Gui/Cairo.cs                      |   12 +++++++++---
 LongoMatch.GUI/Gui/Component/Stats/GameViewer.cs |   14 ++++++++++----
 3 files changed, 27 insertions(+), 7 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Color.cs b/LongoMatch.Core/Common/Color.cs
index 3c3a267..c7afabb 100644
--- a/LongoMatch.Core/Common/Color.cs
+++ b/LongoMatch.Core/Common/Color.cs
@@ -30,6 +30,14 @@ namespace LongoMatch.Common
                static public byte ShortToByte (ushort val) {
                        return (byte) (((float)val) / ushort.MaxValue * byte.MaxValue);
                }
+               
+               static public double ShortToDouble (ushort val) {
+                       return (double) (val) / ushort.MaxValue;
+               }
+               
+               static public double ByteToDouble (byte val) {
+                       return (double) (val) / byte.MaxValue;
+               }
        }
 }
 
diff --git a/LongoMatch.GUI/Gui/Cairo.cs b/LongoMatch.GUI/Gui/Cairo.cs
index 3df74a9..a1b6016 100644
--- a/LongoMatch.GUI/Gui/Cairo.cs
+++ b/LongoMatch.GUI/Gui/Cairo.cs
@@ -73,9 +73,15 @@ namespace LongoMatch.Common
                }
 
                public static Cairo.Color RGBToCairoColor(Gdk.Color gdkColor) {
-                       return   new Cairo.Color((double)(gdkColor.Red)/ushort.MaxValue,
-                                                (double)(gdkColor.Green)/ushort.MaxValue,
-                                                (double)(gdkColor.Blue)/ushort.MaxValue);
+                       return new Cairo.Color (ColorHelper.ShortToDouble (gdkColor.Red),
+                                               ColorHelper.ShortToDouble (gdkColor.Green),
+                                               ColorHelper.ShortToDouble (gdkColor.Blue));
+               }
+               
+               public static Cairo.Color ColorFromRGB (byte r, byte g, byte b) {
+                       return new Cairo.Color (ColorHelper.ByteToDouble (r),
+                                               ColorHelper.ByteToDouble (g),
+                                               ColorHelper.ByteToDouble (b));
                }
        }
 }
diff --git a/LongoMatch.GUI/Gui/Component/Stats/GameViewer.cs 
b/LongoMatch.GUI/Gui/Component/Stats/GameViewer.cs
index d1c3023..72f1fbe 100644
--- a/LongoMatch.GUI/Gui/Component/Stats/GameViewer.cs
+++ b/LongoMatch.GUI/Gui/Component/Stats/GameViewer.cs
@@ -151,7 +151,8 @@ namespace LongoMatch.Gui.Component
                        /* For subcategories, parent is the parent Category */
                        this.stat = stat;
                        this.category = category;
-                       Color = new Color(0, 200, 200);
+                       HomeColor = CairoUtils.ColorFromRGB (0xFF, 0x33, 0);
+                       AwayColor = CairoUtils.ColorFromRGB (0, 0x99, 0xFF);
                        layout =  new Pango.Layout(PangoContext);
                        layout.Wrap = Pango.WrapMode.Char;
                        layout.Alignment = Pango.Alignment.Center;
@@ -170,7 +171,12 @@ namespace LongoMatch.Gui.Component
                        }
                }
                
-               Cairo.Color Color {
+               Cairo.Color HomeColor {
+                       get;
+                       set;
+               }
+               
+               Cairo.Color AwayColor {
                        get;
                        set;
                }
@@ -217,10 +223,10 @@ namespace LongoMatch.Gui.Component
                                
                                /* Home bar */
                                CairoUtils.DrawRoundedRectangle (g, lCenter - localW, 0, localW, height, 0,
-                                                                Color, Color);
+                                                                HomeColor, HomeColor);
                                /* Away bar  */
                                CairoUtils.DrawRoundedRectangle (g, vCenter, 0, visitorW, height, 0,
-                                                                Color, Color);
+                                                                AwayColor, AwayColor);
                                                                 
                                /* Category name */
                                layout.Width = Pango.Units.FromPixels(textSize);


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