[longomatch] Ellipsize text in headers



commit 2f5d0e08bddd5268b29155b6a8563b24ce0a96e0
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Oct 22 01:58:36 2014 +0200

    Ellipsize text in headers

 .../Interfaces/Drawing/IDrawingToolkit.cs          |    2 +-
 LongoMatch.Drawing.Cairo/CairoBackend.cs           |    8 +++++++-
 LongoMatch.Drawing/CanvasObjects/CategoryObject.cs |    4 +++-
 LongoMatch.Drawing/CanvasObjects/TimerObject.cs    |    2 +-
 4 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs 
b/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
index e40c1da..9fa3b47 100644
--- a/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
+++ b/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
@@ -64,7 +64,7 @@ namespace LongoMatch.Core.Interfaces.Drawing
                void DrawPoint (Point point);
                void DrawCircle (Point center, double radius);
                void DrawEllipse (Point center, double axisX, double axisY);
-               void DrawText (Point point, double width, double height, string text, bool escape=false);
+               void DrawText (Point point, double width, double height, string text, bool escape=false, bool 
ellipsize=false);
                void DrawImage (Image image); 
                void DrawImage (Point start, double width, double height, Image image, bool scale, bool 
masked=false); 
                void DrawArrow(Point start, Point stop, int lenght, double degrees, bool closed);
diff --git a/LongoMatch.Drawing.Cairo/CairoBackend.cs b/LongoMatch.Drawing.Cairo/CairoBackend.cs
index 5600cee..9c0b961 100644
--- a/LongoMatch.Drawing.Cairo/CairoBackend.cs
+++ b/LongoMatch.Drawing.Cairo/CairoBackend.cs
@@ -342,7 +342,8 @@ namespace LongoMatch.Drawing.Cairo
                        DrawCircle (point, LineWidth);
                }
 
-               public void DrawText (Point point, double width, double height, string text, bool 
escape=false)
+               public void DrawText (Point point, double width, double height, string text,
+                                   bool escape=false, bool ellipsize=false)
                {
                        Layout layout = null;
                        Pango.Rectangle inkRect, logRect;
@@ -361,6 +362,11 @@ namespace LongoMatch.Drawing.Cairo
                        if (layout == null) {
                                layout = Pango.CairoHelper.CreateLayout (CContext);
                        }
+                       if (ellipsize) {
+                               layout.Ellipsize = EllipsizeMode.End;
+                       } else {
+                               layout.Ellipsize = EllipsizeMode.None;
+                       }
                        layout.FontDescription = FontDescription.FromString (
                                String.Format ("{0} {1}px", FontFamily, FontSize));
                        layout.FontDescription.Weight = fWeight;
diff --git a/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs 
b/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
index b5e7695..9c6916b 100644
--- a/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
@@ -367,6 +367,7 @@ namespace LongoMatch.Drawing.CanvasObjects
                        Point pos;
                        double width, height;
                        int fontSize;
+                       bool ellipsize = true;
 
                        if (Active) {
                                textColor = BackgroundColor;
@@ -391,6 +392,7 @@ namespace LongoMatch.Drawing.CanvasObjects
                                        height = Height - HeaderHeight;
                                        pos = new Point (Position.X, Position.Y + HeaderHeight);
                                        fontSize = StyleConf.ButtonNameFontSize;
+                                       ellipsize = false;
                                }
                                rects.Add (new Rectangle (Position, Width, Height), Button);
                        }
@@ -398,7 +400,7 @@ namespace LongoMatch.Drawing.CanvasObjects
                        tk.StrokeColor = BackgroundColor;
                        tk.StrokeColor = textColor;
                        tk.FontWeight = FontWeight.Light;
-                       tk.DrawText (pos, width, height, Button.AnalysisEventType.Name);
+                       tk.DrawText (pos, width, height, Button.AnalysisEventType.Name, false, ellipsize);
                }
 
                void DrawEditButton (IDrawingToolkit tk)
diff --git a/LongoMatch.Drawing/CanvasObjects/TimerObject.cs b/LongoMatch.Drawing/CanvasObjects/TimerObject.cs
index 1ceff63..374d8c1 100644
--- a/LongoMatch.Drawing/CanvasObjects/TimerObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/TimerObject.cs
@@ -140,7 +140,7 @@ namespace LongoMatch.Drawing.CanvasObjects
                                tk.FontAlignment = FontAlignment.Center;
                                tk.DrawText (new Point (Position.X, Position.Y + iconImage.Height),
                                             Button.Width, Button.Height - iconImage.Height,
-                                            PartialTime.ToSecondsString ());
+                                            PartialTime.ToSecondsString (), false, true);
                        } else {
                                Text = Button.Timer.Name;
                                DrawText (tk);


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