[longomatch] Redraw widget correctly invalidating the drawing area



commit a562293216a0cf8ed8d19856bd7d054522275e3d
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Mon May 19 14:43:37 2014 +0200

    Redraw widget correctly invalidating the drawing area

 LongoMatch.Core/Interfaces/Drawing/IWidget.cs    |    5 +-
 LongoMatch.Drawing.Cairo/WidgetWrapper.cs        |   45 ++++++++++++---------
 LongoMatch.Drawing/CanvasObject/CategoryLabel.cs |    2 +-
 LongoMatch.Drawing/CanvasObject/PlayObject.cs    |    2 +-
 LongoMatch.Drawing/LongoMatch.Drawing.mdp        |    1 -
 LongoMatch.Drawing/Widgets/PlaysTimeline.cs      |    6 +-
 6 files changed, 33 insertions(+), 28 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/Drawing/IWidget.cs b/LongoMatch.Core/Interfaces/Drawing/IWidget.cs
index d2f8277..61effa2 100644
--- a/LongoMatch.Core/Interfaces/Drawing/IWidget.cs
+++ b/LongoMatch.Core/Interfaces/Drawing/IWidget.cs
@@ -30,9 +30,8 @@ namespace LongoMatch.Interfaces.Drawing
                
                double Width {get;set;}
                double Height {get;set;}
-               void QueueDraw ();
-               void Redraw (Area area = null);
-               void Redraw (ICanvasObject obj);
+               void ReDraw (Area area = null);
+               void ReDraw (IDrawable drawable);
                void SetCursor (CursorType type);
        }
 }
diff --git a/LongoMatch.Drawing.Cairo/WidgetWrapper.cs b/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
index 3100d40..b440e8c 100644
--- a/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
+++ b/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
@@ -69,26 +69,22 @@ namespace LongoMatch.Drawing.Cairo
                        }
                }
                
-               public void QueueDraw () {
-                       widget.QueueDraw ();
-               }
-               
-               public void Redraw (Area area) {
-                       if (DrawEvent != null) {
-                               using (Context c = CairoHelper.Create (widget.GdkWindow)) {
-                                       if (area == null) {
-                                               area = new Area (new Point (0, 0), Width, Height);
-                                       }
-                                       DrawEvent (c, area);
-                               }
+               public void ReDraw (Area area = null) {
+                       if (area == null) {
+                               Gdk.Region region = widget.GdkWindow.ClipRegion;
+                               widget.GdkWindow.InvalidateRegion(region,true);
+                       } else {
+                               widget.GdkWindow.InvalidateRect (
+                                       new Gdk.Rectangle ((int)area.Start.X, (int)area.Start.Y,
+                                                  (int)area.Width, (int)area.Height),
+                                       true);
                        }
+                       widget.GdkWindow.ProcessUpdates(true);
                }
                
-               public void Redraw (ICanvasObject obj) {
-                       using (Context c = CairoHelper.Create (widget.GdkWindow)) {
-                               Config.DrawingToolkit.Context = c;
-                               obj.Draw (Config.DrawingToolkit, new Area (new Point (0, 0), Width, Height));
-                       }
+               public void ReDraw (IDrawable drawable) {
+                       /* FIXME: get region from drawable */
+                       ReDraw ();
                }
                
                public void SetCursor (CursorType type) {
@@ -113,7 +109,18 @@ namespace LongoMatch.Drawing.Cairo
                        }
                        widget.GdkWindow.Cursor = new Cursor (gtype);
                }
-
+               
+               void Draw (Area area) {
+                       if (DrawEvent != null) {
+                               using (Context c = CairoHelper.Create (widget.GdkWindow)) {
+                                       if (area == null) {
+                                               area = new Area (new Point (0, 0), Width, Height);
+                                       }
+                                       DrawEvent (c, area);
+                               }
+                       }
+               }
+               
                ButtonType ParseButtonType (uint button) {
                        ButtonType bt;
                        
@@ -190,7 +197,7 @@ namespace LongoMatch.Drawing.Cairo
                        
                        r = args.Event.Area;
                        a = new Area (new Point (r.X, r.Y), r.Width, r.Height);
-                       Redraw (a);
+                       Draw (a);
                }
        }
 }
diff --git a/LongoMatch.Drawing/CanvasObject/CategoryLabel.cs 
b/LongoMatch.Drawing/CanvasObject/CategoryLabel.cs
index 34d0bc6..9a6da67 100644
--- a/LongoMatch.Drawing/CanvasObject/CategoryLabel.cs
+++ b/LongoMatch.Drawing/CanvasObject/CategoryLabel.cs
@@ -47,7 +47,7 @@ namespace LongoMatch.Drawing.CanvasObject
                        double y = offset.Y - Scroll;
                        tk.Begin();
                        tk.FillColor = category.Color;
-                       tk.StrokeColor = Common.TEXT_COLOR;
+                       tk.StrokeColor = category.Color;
                        tk.DrawRoundedRectangle (new Point(0, y + 1), width, height - 1, 3);  
                        tk.FillColor = Common.TEXT_COLOR;
                        tk.StrokeColor = Common.TEXT_COLOR;
diff --git a/LongoMatch.Drawing/CanvasObject/PlayObject.cs b/LongoMatch.Drawing/CanvasObject/PlayObject.cs
index 969e361..3929cea 100644
--- a/LongoMatch.Drawing/CanvasObject/PlayObject.cs
+++ b/LongoMatch.Drawing/CanvasObject/PlayObject.cs
@@ -78,7 +78,7 @@ namespace LongoMatch.Drawing.CanvasObject
                        if (Selected) {
                                tk.StrokeColor = Common.PLAY_OBJECT_SELECTED_COLOR;
                        } else {
-                               tk.StrokeColor = Common.PLAY_OBJECT_UNSELECTED_COLOR;
+                               tk.StrokeColor = Play.Category.Color;
                        }
                        tk.LineWidth = 2;
                        tk.DrawRoundedRectangle (new Point (StartX, OffsetY),
diff --git a/LongoMatch.Drawing/LongoMatch.Drawing.mdp b/LongoMatch.Drawing/LongoMatch.Drawing.mdp
index 2accd98..558c431 100644
--- a/LongoMatch.Drawing/LongoMatch.Drawing.mdp
+++ b/LongoMatch.Drawing/LongoMatch.Drawing.mdp
@@ -26,7 +26,6 @@
     <File subtype="Code" buildaction="Compile" name="Common.cs" />
     <File subtype="Code" buildaction="Compile" name="Widgets/PlaysTimeline.cs" />
     <File subtype="Code" buildaction="Compile" name="CanvasObject/CategoryTimeline.cs" />
-    <File subtype="Directory" buildaction="Compile" name="Interfaces" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="System, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089" />
diff --git a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
index fc98b7c..dd5662a 100644
--- a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
+++ b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
@@ -134,14 +134,14 @@ namespace LongoMatch.Drawing.Widgets
                void RedrawSelection (Selection sel)
                {
                        PlayObject po = sel.Drawable as PlayObject;
-                       widget.Redraw (categories[po.Play.Category]);
+                       widget.ReDraw (categories[po.Play.Category]);
                }               
                
                void ClearSelection () {
                        foreach (Selection sel in selectionList) {
                                PlayObject po = sel.Drawable as PlayObject;
                                po.Selected = false;
-                               widget.Redraw (po);
+                               widget.ReDraw (po);
                        }
                        selectionList.Clear ();
                }
@@ -160,7 +160,7 @@ namespace LongoMatch.Drawing.Widgets
                                        TimeNodeSelected (po.Play);
                                }
                        }
-                       widget.Redraw (po);
+                       widget.ReDraw (po);
                }
                
                void HandleLeftButton (Point coords, ButtonModifier modif) {


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