[longomatch] Change selection API to support removals
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Change selection API to support removals
- Date: Mon, 7 Jul 2014 11:23:46 +0000 (UTC)
commit 13b85709369e37db5168483392b84b52e6f49577
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Tue May 27 18:46:49 2014 +0200
Change selection API to support removals
LongoMatch.Drawing/Canvas.cs | 19 +++++--------------
LongoMatch.Drawing/Widgets/PlaysTimeline.cs | 10 ++++++----
2 files changed, 11 insertions(+), 18 deletions(-)
---
diff --git a/LongoMatch.Drawing/Canvas.cs b/LongoMatch.Drawing/Canvas.cs
index 0dc7839..35bb27a 100644
--- a/LongoMatch.Drawing/Canvas.cs
+++ b/LongoMatch.Drawing/Canvas.cs
@@ -44,16 +44,6 @@ namespace LongoMatch.Drawing
set;
}
- public double Width {
- get;
- set;
- }
-
- public double Height {
- get;
- set;
- }
-
protected virtual void HandleDraw (object context, Area area) {
tk.Context = context;
for (int i=Objects.Count - 1; i >= 0; i--) {
@@ -99,10 +89,10 @@ namespace LongoMatch.Drawing
protected abstract void StartMove (Selection sel);
protected abstract void SelectionMoved (Selection sel);
protected abstract void StopMove ();
- protected abstract void ItemSelected (Selection sel);
+ protected abstract void SelectionChanged (List<Selection> sel);
protected abstract void ShowMenu (Point coords);
- void ClearSelection () {
+ public void ClearSelection () {
foreach (Selection sel in Selections) {
ICanvasSelectableObject po = sel.Drawable as ICanvasSelectableObject;
po.Selected = false;
@@ -111,17 +101,18 @@ namespace LongoMatch.Drawing
Selections.Clear ();
}
- void UpdateSelection (Selection sel) {
+ protected void UpdateSelection (Selection sel) {
ICanvasSelectableObject so = sel.Drawable as ICanvasSelectableObject;
Selection seldup = Selections.FirstOrDefault (s => s.Drawable == sel.Drawable);
if (seldup != null) {
so.Selected = false;
Selections.Remove (seldup);
+ SelectionChanged (Selections);
} else {
so.Selected = true;
Selections.Add (sel);
- ItemSelected (sel);
+ SelectionChanged (Selections);
}
widget.ReDraw (so);
}
diff --git a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
index b294f0c..be3715f 100644
--- a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
+++ b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
@@ -148,10 +148,12 @@ namespace LongoMatch.Drawing.Widgets
widget.ReDraw (categories[po.Play.Category]);
}
- protected override void ItemSelected (Selection sel) {
- PlayObject po = sel.Drawable as PlayObject;
- if (TimeNodeSelected != null) {
- TimeNodeSelected (po.Play);
+ protected override void SelectionChanged (List<Selection> selections) {
+ if (selections.Count > 0) {
+ PlayObject po = selections.Last().Drawable as PlayObject;
+ if (TimeNodeSelected != null) {
+ TimeNodeSelected (po.Play);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]