[longomatch] Draw anchors in the center and take more selection space



commit 1c4e6bd1863731e9f44e9d6198610be55b868ea4
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue Apr 14 12:53:38 2015 +0200

    Draw anchors in the center and take more selection space

 .../CanvasObjects/Dashboard/ActionLinkObject.cs    |   17 +++++----
 .../CanvasObjects/Dashboard/CategoryObject.cs      |   15 ++++++--
 .../Dashboard/DashboardButtonObject.cs             |    2 +-
 .../CanvasObjects/Dashboard/LinkAnchorObject.cs    |   38 +++++++++++++++++---
 4 files changed, 56 insertions(+), 16 deletions(-)
---
diff --git a/LongoMatch.Drawing/CanvasObjects/Dashboard/ActionLinkObject.cs 
b/LongoMatch.Drawing/CanvasObjects/Dashboard/ActionLinkObject.cs
index 834db23..4893cde 100644
--- a/LongoMatch.Drawing/CanvasObjects/Dashboard/ActionLinkObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/Dashboard/ActionLinkObject.cs
@@ -24,11 +24,14 @@ using LongoMatch.Core.Store.Drawables;
 
 namespace LongoMatch.Drawing.CanvasObjects.Dashboard
 {
+       /// <summary>
+       /// Represents an <see cref="ActionLink"/> in the canvas.
+       /// </summary>
        public class ActionLinkObject: CanvasObject, ICanvasSelectableObject
        {
-               Line line;
+               readonly Line line;
+               const int selectionSize = 4;
                Point stop;
-               int selectionSize = 4;
 
                public ActionLinkObject (LinkAnchorObject source,
                                         LinkAnchorObject destination,
@@ -38,12 +41,12 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
                        Source = source;
                        Destination = destination;
                        if (destination == null) {
-                               stop = source.Position;
+                               stop = source.Center;
                        } else {
-                               stop = destination.Position;
+                               stop = destination.Center;
                        }
                        line = new Line ();
-                       line.Start = source.Position;
+                       line.Start = source.Center;
                        line.Stop = stop;
                }
 
@@ -64,9 +67,9 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
 
                public virtual Area Area {
                        get {
-                               line.Start = Source.Position;
+                               line.Start = Source.Center;
                                if (Destination != null) {
-                                       line.Stop = Destination.Position;
+                                       line.Stop = Destination.Center;
                                } else {
                                        line.Stop = this.stop;
                                }
diff --git a/LongoMatch.Drawing/CanvasObjects/Dashboard/CategoryObject.cs 
b/LongoMatch.Drawing/CanvasObjects/Dashboard/CategoryObject.cs
index 38aba75..60ef846 100644
--- a/LongoMatch.Drawing/CanvasObjects/Dashboard/CategoryObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/Dashboard/CategoryObject.cs
@@ -83,7 +83,7 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
                        MinHeight = HeaderHeight * 2;
                        subcatAnchors = new Dictionary<Tag, LinkAnchorObject> ();
                        foreach (Tag tag in category.AnalysisEventType.Tags) {
-                               AddSubcatAnchor (tag, new Point (0, 0));
+                               AddSubcatAnchor (tag, new Point (0, 0), 100, HeaderHeight);
                        }
                }
 
@@ -257,7 +257,7 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
                        set;
                }
 
-               void AddSubcatAnchor (Tag tag, Point point)
+               void AddSubcatAnchor (Tag tag, Point point, double width, double height)
                {
                        LinkAnchorObject anchor;
 
@@ -271,6 +271,8 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
                                };
                                subcatAnchors.Add (tag, anchor);
                        }
+                       anchor.Width = width;
+                       anchor.Height = height;
                }
 
                bool CheckRect (Point p, Rectangle rect, object obj)
@@ -390,7 +392,8 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
                                        start.Y + yptr + row * heightPerRow);
                                tag = tags [i];
 
-                               AddSubcatAnchor (tag, new Point (pos.X - Position.X, pos.Y - Position.Y));
+                               AddSubcatAnchor (tag, new Point (pos.X - Position.X, pos.Y - Position.Y),
+                                       rowwidth, heightPerRow);
                                if (!Button.ShowSubcategories) {
                                        continue;
                                }
@@ -603,6 +606,12 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
                {
                        if (!ShowLinks)
                                return;
+
+                       if (Button.ShowSubcategories) {
+                               anchor.Height = HeaderHeight;
+                       } else {
+                               anchor.Height = Button.Height;
+                       }
                        DrawAnchor (tk, null);
                        foreach (LinkAnchorObject anchor in subcatAnchors.Values) {
                                anchor.Draw (tk, null);
diff --git a/LongoMatch.Drawing/CanvasObjects/Dashboard/DashboardButtonObject.cs 
b/LongoMatch.Drawing/CanvasObjects/Dashboard/DashboardButtonObject.cs
index 3580a5a..e8165c5 100644
--- a/LongoMatch.Drawing/CanvasObjects/Dashboard/DashboardButtonObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/Dashboard/DashboardButtonObject.cs
@@ -32,7 +32,7 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
                {
                        Button = tagger;
                        SupportsLinks = true;
-                       anchor = new LinkAnchorObject (this, null, new Point (5, 5));
+                       anchor = new LinkAnchorObject (this, null, new Point (0, 0));
                        anchor.RedrawEvent += (co, area) => {
                                EmitRedrawEvent (anchor, area);
                        };
diff --git a/LongoMatch.Drawing/CanvasObjects/Dashboard/LinkAnchorObject.cs 
b/LongoMatch.Drawing/CanvasObjects/Dashboard/LinkAnchorObject.cs
index 82d39f0..3d783d5 100644
--- a/LongoMatch.Drawing/CanvasObjects/Dashboard/LinkAnchorObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/Dashboard/LinkAnchorObject.cs
@@ -27,10 +27,16 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
        public class LinkAnchorObject: CanvasObject, ICanvasSelectableObject
        {
 
+               Rectangle rect;
+
+
                public LinkAnchorObject (DashboardButtonObject button, List<Tag> tags, Point relPos)
                {
                        RelativePosition = relPos;
+                       Width = button.Width;
+                       Height = button.Height;
                        Button = button;
+                       rect = new Rectangle (Position, Width, Height);
                        if (tags == null)
                                tags = new List<Tag> ();
                        Tags = tags;
@@ -46,6 +52,16 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
                        set;
                }
 
+               public double Width {
+                       get;
+                       set;
+               }
+
+               public double Height {
+                       get;
+                       set;
+               }
+
                public List<Tag> Tags {
                        get;
                        set;
@@ -57,6 +73,15 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
                        }
                }
 
+               public Point Center {
+                       get {
+                               Point pos = Position;
+                               pos.X += Width / 2;
+                               pos.Y += Height / 2;
+                               return pos;
+                       }
+               }
+
                public bool CanLink (LinkAnchorObject anchor)
                {
                        if (anchor == null)
@@ -74,12 +99,15 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
 
                public Selection GetSelection (Point point, double precision, bool inMotion = false)
                {
-                       Point pos = Position;
+                       Selection sel;
 
-                       if (Math.Abs (pos.X - point.X) < 2 && Math.Abs (pos.Y - point.Y) < 2) {
-                               return new Selection (this, SelectionPosition.All, 0);
+                       rect = new Rectangle (Position, Width, Height);
+                       sel = rect.GetSelection (point, precision, inMotion);
+                       if (sel != null) {
+                               sel.Drawable = this;
+                               sel.Position = SelectionPosition.All;
                        }
-                       return null;
+                       return sel;
                }
 
                public void Move (Selection s, Point dst, Point start)
@@ -97,7 +125,7 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
                        tk.LineWidth = 2;
                        tk.FillColor = color;
                        tk.StrokeColor = color;
-                       tk.DrawCircle (Position, 2);
+                       tk.DrawCircle (Center, 5);
                        tk.End ();
                }
        }


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