[longomatch] Add new event for size changed



commit 6a78356612cb654e55d5d5480373bf965fed013e
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue Jun 17 21:20:30 2014 +0200

    Add new event for size changed

 LongoMatch.Drawing.Cairo/WidgetWrapper.cs |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/LongoMatch.Drawing.Cairo/WidgetWrapper.cs b/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
index d0942f9..ff4135b 100644
--- a/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
+++ b/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
@@ -36,8 +36,10 @@ namespace LongoMatch.Drawing.Cairo
                public event ButtonPressedHandler ButtonPressEvent;
                public event ButtonReleasedHandler ButtonReleasedEvent;
                public event MotionHandler MotionEvent;
+               public event LongoMatch.Handlers.Drawing.SizeChangedHandler SizeChangedEvent;
 
                DrawingArea widget;
+               int currentWidth, currentHeight;
                
                public WidgetWrapper (DrawingArea widget)
                {
@@ -53,7 +55,7 @@ namespace LongoMatch.Drawing.Cairo
 
                public double Width {
                        get {
-                               return widget.Allocation.Width;
+                               return currentWidth;
                        }
                        set {
                                widget.WidthRequest = (int) value;
@@ -62,7 +64,7 @@ namespace LongoMatch.Drawing.Cairo
 
                public double Height {
                        get {
-                               return widget.Allocation.Height;
+                               return currentHeight;
                        }
                        set {
                                widget.HeightRequest = (int) value;
@@ -197,6 +199,15 @@ namespace LongoMatch.Drawing.Cairo
                {
                        Rectangle r;
                        Area a;
+                       bool size_changed;
+                       
+                       size_changed = widget.Allocation.Height != currentHeight;
+                       size_changed |= widget.Allocation.Width != currentWidth;
+                       currentWidth = widget.Allocation.Width;
+                       currentHeight = widget.Allocation.Height;
+                       if (size_changed && SizeChangedEvent != null) {
+                               SizeChangedEvent ();
+                       }
                        
                        r = args.Event.Area;
                        a = new Area (new Point (r.X, r.Y), r.Width, r.Height);


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