[longomatch/newui: 105/157] Add a custom cell renderers for lists of plays



commit 6f3cb55a1ff328e15676172bc037e931ae5a9a56
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Aug 27 10:44:05 2014 +0200

    Add a custom cell renderers for lists of plays

 LongoMatch.Core/Common/Enums.cs                 |    9 +
 LongoMatch.Core/StyleConf.cs                    |    7 +
 LongoMatch.Drawing/Makefile.am                  |    1 +
 LongoMatch.Drawing/PlayslistCellRenderer.cs     |  203 +++++++++++++++++++++++
 LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs |  161 ++++++------------
 LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs |   50 +-----
 LongoMatch.GUI/Gui/TreeView/PlayersTreeView.cs  |    6 -
 LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs    |   11 +-
 LongoMatch.GUI/LongoMatch.GUI.mdp               |    1 -
 9 files changed, 288 insertions(+), 161 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Enums.cs b/LongoMatch.Core/Common/Enums.cs
index 51f9e52..4d1f524 100644
--- a/LongoMatch.Core/Common/Enums.cs
+++ b/LongoMatch.Core/Common/Enums.cs
@@ -249,5 +249,14 @@ namespace LongoMatch.Common
                Fit,
                Original
        }
+       
+       [Flags]
+       public enum CellState {
+               Selected = 1,
+               Prelit = 2,
+               Insensitive = 4,
+               Sorted = 8,
+               Focused = 16
+       }
 }
 
diff --git a/LongoMatch.Core/StyleConf.cs b/LongoMatch.Core/StyleConf.cs
index cf02347..f1ddb41 100644
--- a/LongoMatch.Core/StyleConf.cs
+++ b/LongoMatch.Core/StyleConf.cs
@@ -49,6 +49,13 @@ namespace LongoMatch.Common
                public const int NewTeamsSpacing = 60;
                public const int NewTaggerSpacing = 35;
 
+               public const int ListSelectedWidth = 16;
+               public const int ListTextWidth = 200;
+               public const int ListImageWidth = 50;
+               public const int ListCategoryHeight = 50;
+               public const int ListCountRadio = 10;
+               public const int ListCountWidth = 20;
+
                public const int TeamsShieldIconSize = 45;
                
                public const string TimelineNeedleResource = 
"hicolor/scalable/actions/longomatch-timeline-needle-big.svg";
diff --git a/LongoMatch.Drawing/Makefile.am b/LongoMatch.Drawing/Makefile.am
index ae01b5b..186e0c8 100644
--- a/LongoMatch.Drawing/Makefile.am
+++ b/LongoMatch.Drawing/Makefile.am
@@ -29,6 +29,7 @@ SOURCES = Canvas.cs \
        CanvasObjects/TimelineObject.cs \
        CanvasObjects/TimerObject.cs \
        Constants.cs \
+       PlayslistCellRenderer.cs \
        Utils.cs \
        Widgets/Blackboard.cs \
        Widgets/CategoriesLabels.cs \
diff --git a/LongoMatch.Drawing/PlayslistCellRenderer.cs b/LongoMatch.Drawing/PlayslistCellRenderer.cs
new file mode 100644
index 0000000..8f43f12
--- /dev/null
+++ b/LongoMatch.Drawing/PlayslistCellRenderer.cs
@@ -0,0 +1,203 @@
+//
+//  Copyright (C) 2014 Andoni Morales Alastruey
+//
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System;
+using LongoMatch.Interfaces.Drawing;
+using LongoMatch.Common;
+using LongoMatch.Store;
+using LongoMatch.Store.Playlists;
+
+namespace LongoMatch.Drawing
+{
+       public class PlayslistCellRenderer
+       {
+       
+               public static void RenderSeparationLine (IDrawingToolkit tk, IContext context, Area 
backgroundArea)
+               {
+                       
+                       double x1, x2, y;
+                       
+                       x1 = backgroundArea.Start.X;
+                       x2 = x1 + backgroundArea.Width;
+                       y = backgroundArea.Start.Y + backgroundArea.Height; 
+                       tk.LineWidth = 1;
+                       tk.StrokeColor = Config.Style.PaletteBackgroundLight;
+                       tk.DrawLine (new Point (x1, y), new Point (x2, y));
+               }
+
+               static void RenderCount (Color color, int count, IDrawingToolkit tk, Area backgroundArea, 
Area cellArea)
+               {
+                       double countX1, countX2, countY, countYC;
+                       
+                       countX1 = cellArea.Start.X + cellArea.Width - StyleConf.ListImageWidth + 
StyleConf.ListCountRadio;
+                       countX2 = countX1 + StyleConf.ListCountWidth;
+                       countYC = backgroundArea.Start.Y + backgroundArea.Height / 2;
+                       countY = countYC - StyleConf.ListCountRadio;
+                       tk.LineWidth = 0;
+                       tk.FillColor = color;
+                       tk.DrawCircle (new Point (countX1, countYC), StyleConf.ListCountRadio);
+                       tk.DrawCircle (new Point (countX2, countYC), StyleConf.ListCountRadio);
+                       tk.DrawRectangle (new Point (countX1, countY), StyleConf.ListCountWidth, 2 * 
StyleConf.ListCountRadio);
+                       tk.StrokeColor = Config.Style.PaletteBackgroundDark;
+                       tk.FontAlignment = FontAlignment.Center;
+                       tk.DrawText (new Point (countX1, countY), StyleConf.ListCountWidth, 2 * 
StyleConf.ListCountRadio, count.ToString ());
+               }
+
+               static void RenderBackgroundAndText (bool isExpanded, IDrawingToolkit tk, Area 
backgroundArea, Point textP, double textW, string text)
+               {
+                       Color textColor, backgroundColor;
+
+                       /* Background */
+                       tk.LineWidth = 0;
+                       if (isExpanded) {
+                               backgroundColor = Config.Style.PaletteBackgroundLight;
+                               textColor = Config.Style.PaletteSelected;
+                       }
+                       else {
+                               backgroundColor = Config.Style.PaletteBackground;
+                               textColor = Config.Style.PaletteWidgets;
+                       }
+                       tk.FillColor = backgroundColor;
+                       tk.DrawRectangle (backgroundArea.Start, backgroundArea.Width, backgroundArea.Height);
+
+                       /* Text */
+                       tk.StrokeColor = textColor;
+                       tk.FontSize = 14;
+                       tk.FontWeight = FontWeight.Bold;
+                       tk.FontAlignment = FontAlignment.Left;
+                       tk.DrawText (textP, textW, backgroundArea.Height, text);
+               }
+
+               public static void RenderPlayer (Player player, int count, bool isExpanded, IDrawingToolkit 
tk,
+                                              IContext context, Area backgroundArea, Area cellArea)
+               {
+                       Point image, text;
+                       double textWidth;
+
+                       image = new Point (cellArea.Start.X + 10, cellArea.Start.Y);
+                       text = new Point (image.X + StyleConf.ListImageWidth, cellArea.Start.Y);
+                       textWidth = cellArea.Start.X + cellArea.Width - text.X;
+
+                       tk.Context = context;
+                       tk.Begin ();
+                       RenderBackgroundAndText (isExpanded, tk, backgroundArea, text, textWidth, 
player.ToString());
+                       /* Photo */
+                       if (player.Photo != null) {
+                               tk.DrawImage (image, StyleConf.ListImageWidth, backgroundArea.Height, 
player.Photo, true); 
+                       }
+                       RenderCount (Config.Style.PaletteActive, count, tk, backgroundArea, cellArea);
+                       RenderSeparationLine (tk, context, backgroundArea);
+                       tk.End ();
+               }
+
+               public static void RenderPlaylist (Playlist playlist, int count, bool isExpanded, 
IDrawingToolkit tk,
+                                                  IContext context, Area backgroundArea, Area cellArea)
+               {
+                       tk.Context = context;
+                       tk.Begin ();
+                       RenderBackgroundAndText (isExpanded, tk, backgroundArea, cellArea.Start, 
cellArea.Width, playlist.Name);
+                       RenderCount (Config.Style.PaletteActive, count, tk, backgroundArea, cellArea);
+                       RenderSeparationLine (tk, context, backgroundArea);
+                       tk.End ();
+               }
+
+               public static void RenderAnalysisCategory (AnalysisCategory cat, int count, bool isExpanded, 
IDrawingToolkit tk,
+                                                          IContext context, Area backgroundArea, Area 
cellArea)
+               {
+                       tk.Context = context;
+                       tk.Begin ();
+                       RenderBackgroundAndText (isExpanded, tk, backgroundArea, cellArea.Start, 
cellArea.Width, cat.Name);
+                       RenderCount (cat.Color, count, tk, backgroundArea, cellArea);
+                       RenderSeparationLine (tk, context, backgroundArea);
+                       tk.End ();
+               }
+               
+               public static void RenderPlay (Color color, Image ss, bool selected, string desc,
+                                              int count, bool isExpanded, IDrawingToolkit tk,
+                                              IContext context, Area backgroundArea, Area cellArea, 
CellState state)
+               {
+                       Point selectPoint, textPoint, imagePoint, circlePoint;
+                       double textWidth;
+                       
+                       
+                       selectPoint = new Point (backgroundArea.Start.X, backgroundArea.Start.Y);
+                       textPoint = new Point (selectPoint.X + StyleConf.ListSelectedWidth + 10, 
selectPoint.Y);
+                       imagePoint = new Point (backgroundArea.Start.X + backgroundArea.Width - 
StyleConf.ListImageWidth - 10,
+                                               selectPoint.Y);
+                       textWidth = imagePoint.X - textPoint.X; 
+                       circlePoint = new Point (selectPoint.X + StyleConf.ListSelectedWidth / 2,
+                                                selectPoint.Y + backgroundArea.Height / 2);
+
+                       tk.Context = context;
+                       tk.Begin ();
+                       
+                       tk.LineWidth = 0;
+                       if (state.HasFlag (CellState.Prelit)) {
+                               tk.FillColor = Config.Style.PaletteBackgroundLight;
+                       } else if (state.HasFlag (CellState.Selected)) {
+                               tk.FillColor = Config.Style.PaletteBackground;
+                       } else {
+                               tk.FillColor = Config.Style.PaletteBackgroundDark;
+                       }
+                       tk.DrawRectangle (backgroundArea.Start, backgroundArea.Width, backgroundArea.Height);
+
+                       /* Selection rectangle */
+                       tk.LineWidth = 0;
+                       tk.FillColor = color;
+                       tk.DrawRectangle (selectPoint, StyleConf.ListSelectedWidth, backgroundArea.Height);
+                       tk.FillColor = Config.Style.PaletteBackgroundDark;
+                       tk.DrawCircle (circlePoint, (StyleConf.ListSelectedWidth / 2) - 1); 
+                       if (selected) {
+                               tk.FillColor = Config.Style.PaletteActive;
+                               tk.DrawCircle (circlePoint, (StyleConf.ListSelectedWidth / 2) - 2); 
+                       }
+
+                       tk.FontSize = 10;
+                       tk.FontWeight = FontWeight.Normal;
+                       tk.StrokeColor = Config.Style.PaletteSelected;
+                       tk.FontAlignment = FontAlignment.Left;
+                       tk.DrawText (textPoint, textWidth, cellArea.Height, desc);
+                       
+                       if (ss != null) {
+                               tk.DrawImage (imagePoint, StyleConf.ListImageWidth, cellArea.Height, ss, 
true);
+                       }
+                       RenderSeparationLine (tk, context, backgroundArea);
+                       tk.End ();
+               }
+               
+               public static void Render (object item, int count, bool isExpanded, IDrawingToolkit tk,
+                                          IContext context, Area backgroundArea, Area cellArea, CellState 
state)
+               {
+                       if (item is AnalysisCategory) {
+                               RenderAnalysisCategory (item as AnalysisCategory, count, isExpanded, tk,
+                                                       context, backgroundArea, cellArea);
+                       } else if (item is Play) {
+                               Play p = item as Play;
+                               RenderPlay (p.Category.Color, p.Miniature, p.Selected, p.Description, count, 
isExpanded, tk,
+                                           context, backgroundArea, cellArea, state);
+                       } else if (item is Player) {
+                               RenderPlayer (item as Player, count, isExpanded, tk, context, backgroundArea, 
cellArea);
+                       } else if (item is Playlist) {
+                               RenderPlaylist (item as Playlist, count, isExpanded, tk, context, 
backgroundArea, cellArea);
+                       } else if (item is PlaylistPlayElement) {
+                               PlaylistPlayElement p = item as PlaylistPlayElement;
+                               RenderPlay (p.Play.Category.Color, p.Miniature, p.Selected, p.Description, 
count, isExpanded, tk,
+                                           context, backgroundArea, cellArea, state);
+                       }
+               }
+       }
+}
diff --git a/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs b/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs
index af22f1d..b10599d 100644
--- a/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs
+++ b/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs
@@ -24,12 +24,14 @@ using Gtk;
 using Mono.Unix;
 
 using LongoMatch.Common;
-using LongoMatch.Handlers;
 using LongoMatch.Store;
-using LongoMatch.Gui.Helpers;
+using LongoMatch.Drawing;
 using Image = LongoMatch.Common.Image;
+using Point = LongoMatch.Common.Point;
 using Color = Gdk.Color;
 using LongoMatch.Gui.Menus;
+using LongoMatch.Drawing.Cairo;
+using LongoMatch.Interfaces.Drawing;
 
 namespace LongoMatch.Gui.Component
 {
@@ -37,15 +39,12 @@ namespace LongoMatch.Gui.Component
 
        public abstract class ListTreeViewBase:TreeView
        {
-               protected Gtk.CellRendererText nameCell;
-               protected Gtk.TreeViewColumn nameColumn;
                protected bool editing;
                protected bool enableCategoryMove = false;
                protected PlaysMenu playsMenu;
                
                TreeModelFilter modelFilter;
                PlaysFilter filter;
-               Dictionary<MenuItem, Category> catsDict;
 
                public event EventHandler NewRenderingJob;
 
@@ -56,21 +55,14 @@ namespace LongoMatch.Gui.Component
                        RowActivated += new RowActivatedHandler(OnTreeviewRowActivated);
                        HeadersVisible = false;
                        
-                       nameColumn = new Gtk.TreeViewColumn();
-                       nameColumn.Title = "Name";
-                       nameCell = new Gtk.CellRendererText();
-                       nameCell.Edited += OnNameCellEdited;
-                       Gtk.CellRendererPixbuf miniatureCell = new Gtk.CellRendererPixbuf();
-                       nameColumn.PackStart(nameCell, true);
-                       nameColumn.PackEnd(miniatureCell, true);
-
-                       nameColumn.SetCellDataFunc(miniatureCell, new Gtk.TreeCellDataFunc(RenderMiniature));
-                       nameColumn.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc(RenderName));
+                       TreeViewColumn custColumn = new TreeViewColumn ();
+                       CellRenderer cr = new PlaysCellRenderer ();
+                       custColumn.PackStart (cr, true);
+                       custColumn.SetCellDataFunc (cr, RenderElement); 
 
                        playsMenu = new PlaysMenu ();
                        playsMenu.EditNameEvent += OnEdit;
-                       AppendColumn(nameColumn);
-
+                       AppendColumn(custColumn);
                }
 
                public bool Colors {
@@ -140,103 +132,18 @@ namespace LongoMatch.Gui.Component
                        return modelFilter.GetValue(iter,0);
                }
                
-               protected void RenderMiniature(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, 
Gtk.TreeModel model, Gtk.TreeIter iter)
-               {
-                       var item = model.GetValue(iter, 0);
-                       var c = cell as CellRendererPixbuf;
-
-                       if(item is Play) {
-                               Image img = (item as Play).Miniature;
-                               c.Pixbuf = img != null ? img.Value : null;
-                               if(Colors) {
-                                       c.CellBackgroundGdk = Helpers.Misc.ToGdkColor((item as 
Play).Category.Color);
-                               } else {
-                                       c.CellBackground = "white";
-                               }
-                       }
-                       else if(item is Player) {
-                               Image img = (item as Player).Photo;
-                               c.Pixbuf = img != null ? img.Value : null;
-                               c.CellBackground = "white";
-                       }
-                       else {
-                               c.Pixbuf = null;
-                               c.CellBackground = "white";
-                       }
-               }
-
-               protected void RenderName(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel 
model, Gtk.TreeIter iter)
-               {
-                       object o = model.GetValue(iter, 0);
-                       var c = cell as CellRendererText;
-
-                       /* Handle special case in which we replace the text in the cell by the name of the 
TimeNode
-                        * We need to check if we are editing and only change it for the path that's 
currently beeing edited */
-                       if(editing && Selection.IterIsSelected(iter)) {
-                               if(o is Player)
-                                       c.Markup = GLib.Markup.EscapeText ((o as Player).Name);
-                               else
-                                       c.Markup = GLib.Markup.EscapeText ((o as Category).Name);
-                               return;
-                       }
-
-                       if(o is Play) {
-                               var mtn = o as Play;
-                               if(Colors) {
-                                       Color col = Helpers.Misc.ToGdkColor(mtn.Category.Color);
-                                       c.CellBackgroundGdk = col;
-                                       c.BackgroundGdk = col;
-                               } else {
-                                       c.Background = "white";
-                                       c.CellBackground = "white";
-                               }
-                               c.Markup = GLib.Markup.EscapeText (mtn.ToString());
-                       } else if(o is Player) {
-                               c.Background = "white";
-                               c.CellBackground = "white";
-                               c.Markup = String.Format("{0} ({1})", GLib.Markup.EscapeText ((o as 
Player).ToString()),
-                                                        modelFilter.IterNChildren(iter));
-                       } else if(o is Category) {
-                               c.Background = "white";
-                               c.CellBackground = "white";
-                               c.Markup = String.Format("{0} ({1})", GLib.Markup.EscapeText ((o as 
Category).Name),
-                                                        modelFilter.IterNChildren(iter));
-                       }
-               }
-
                protected bool FilterFunction(TreeModel model, TreeIter iter) {
                        if (Filter == null)
                                return true;
                        object o = model.GetValue(iter, 0);
                        return Filter.IsVisible(o);
                }       
-               
-               protected virtual void OnNameCellEdited(object o, Gtk.EditedArgs args)
-               {
-                       Gtk.TreeIter iter;
-                       object item;
-
-                       modelFilter.GetIter(out iter, new Gtk.TreePath(args.Path));
-                       item = modelFilter.GetValue(iter,0);
-
-                       if(item is TimeNode) {
-                               (item as TimeNode).Name = args.NewText;
-                               Config.EventsBroker.EmitTimeNodeChanged (
-                                       (item as TimeNode), args.NewText);
-                       } else if(item is Player) {
-                               (item as Player).Name = args.NewText;
-                       }
-                       editing = false;
-                       nameCell.Editable=false;
-
-               }
 
                protected virtual void OnTreeviewRowActivated(object o, Gtk.RowActivatedArgs args)
                {
                        Gtk.TreeIter iter;
                        modelFilter.GetIter(out iter, args.Path);
                        object item = modelFilter.GetValue(iter, 0);
-
                        if(!(item is Play))
                                return;
 
@@ -246,17 +153,61 @@ namespace LongoMatch.Gui.Component
                protected virtual void OnEdit (object obj, EventArgs args) {
                        TreePath[] paths = Selection.GetSelectedRows();
 
-                       editing = true;
-                       nameCell.Editable = true;
-                       SetCursor(paths[0],  nameColumn, true);
+                       //editing = true;
+                       //nameCell.Editable = true;
+                       //SetCursor(paths[0],  nameColumn, true);
                }
 
                protected void OnFilterUpdated() {
                        modelFilter.Refilter();
                }
                
+               protected void RenderElement (TreeViewColumn column, CellRenderer cell, TreeModel model, 
TreeIter iter)
+               {
+                       var item = model.GetValue (iter, 0);
+                       PlaysCellRenderer c = cell as PlaysCellRenderer;
+                       c.Item = item;
+                       c.Count = model.IterNChildren (iter);
+               }
+
                protected abstract bool SelectFunction(TreeSelection selection, TreeModel model, TreePath 
path, bool selected);
                protected abstract int SortFunction(TreeModel model, TreeIter a, TreeIter b);
                
        }
+       
+       public class PlaysCellRenderer: CellRenderer {
+
+               public object Item {
+                       get;
+                       set;
+               }
+               
+               public int Count {
+                       get;
+                       set;
+               }
+               
+               public override void GetSize (Widget widget, ref Rectangle cell_area, out int x_offset, out 
int y_offset, out int width, out int height)
+               {
+                       x_offset = 0;
+                       y_offset = 0;
+                       width = StyleConf.ListSelectedWidth + StyleConf.ListTextWidth + 
StyleConf.ListImageWidth;
+                       height = StyleConf.ListCategoryHeight;
+               }
+
+               protected override void Render (Drawable window, Widget widget, Rectangle backgroundArea,
+                                             Rectangle cellArea, Rectangle exposeArea, CellRendererState 
flags)
+               {
+                       CellState state = (CellState) flags;
+                       
+                       using (IContext context = new CairoContext (window)) {
+                               Area bkg = new Area (new Point (backgroundArea.X, backgroundArea.Y),
+                                                    backgroundArea.Width, backgroundArea.Height);
+                               Area cell = new Area (new Point (cellArea.X, cellArea.Y),
+                                                     cellArea.Width, cellArea.Height);
+                               PlayslistCellRenderer.Render (Item, Count, IsExpanded, Config.DrawingToolkit,
+                                                             context, bkg, cell, state);
+                       }
+               }
+       }
 }
diff --git a/LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs b/LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs
index 644fef2..05b8d2a 100644
--- a/LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs
@@ -47,19 +47,11 @@ namespace LongoMatch.Gui.Component
                        EnableGridLines = TreeViewGridLines.None;
                        EnableTreeLines = false;
                        
-                       TreeViewColumn imageColumn = new TreeViewColumn ();
-                       imageColumn.Title = Catalog.GetString ("Image");
-                       CellRendererPixbuf imageCell = new CellRendererPixbuf ();
-                       imageColumn.PackStart (imageCell, true);
-                       imageColumn.SetCellDataFunc (imageCell, new TreeCellDataFunc (RenderImage));
-                       AppendColumn (imageColumn);
-                       
-                       TreeViewColumn nameColumn = new TreeViewColumn ();
-                       nameColumn.Title = Catalog.GetString ("Name");
-                       CellRendererText nameCell = new CellRendererText ();
-                       nameColumn.PackStart (nameCell, true);
-                       nameColumn.SetCellDataFunc (nameCell, new TreeCellDataFunc (RenderName));
-                       AppendColumn (nameColumn);
+                       TreeViewColumn custColumn = new TreeViewColumn ();
+                       CellRenderer cr = new PlaysCellRenderer ();
+                       custColumn.PackStart (cr, true);
+                       custColumn.SetCellDataFunc (cr, RenderElement); 
+                       AppendColumn (custColumn);
                }
 
                public Project Project {
@@ -88,34 +80,12 @@ namespace LongoMatch.Gui.Component
                        Model = store;
                }
 
-               void RenderName (TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
-               {
-                       var obj = model.GetValue (iter, 0);
-                       
-                       if (obj is IPlaylistElement) {
-                               IPlaylistElement ple = obj as IPlaylistElement;
-                               (cell as Gtk.CellRendererText).Text = ple.Description;
-                               if (ple.Selected) {
-                                       (cell as Gtk.CellRendererText).Foreground = "blue";
-                               } else {
-                                       (cell as Gtk.CellRendererText).Foreground = "black";
-                               }
-                       } else {
-                               (cell as Gtk.CellRendererText).Text = (obj as Playlist).Name;
-                               (cell as Gtk.CellRendererText).Foreground = "black";
-                       }
-               }
-
-               void RenderImage (TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
+               void RenderElement (TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
                {
-                       var obj = model.GetValue (iter, 0);
-                       
-                       if (obj is IPlaylistElement) {
-                               IPlaylistElement ple = obj as IPlaylistElement;
-                               (cell as CellRendererPixbuf).Pixbuf = ple.Miniature.Value;
-                       } else {
-                               (cell as CellRendererPixbuf).Pixbuf = null;
-                       }
+                       var item = model.GetValue (iter, 0);
+                       PlaysCellRenderer c = cell as PlaysCellRenderer;
+                       c.Item = item;
+                       c.Count = model.IterNChildren (iter);
                }
 
                void ShowPlaylistElementMenu (Playlist playlist, IPlaylistElement element)
diff --git a/LongoMatch.GUI/Gui/TreeView/PlayersTreeView.cs b/LongoMatch.GUI/Gui/TreeView/PlayersTreeView.cs
index 6461454..4ec03a3 100644
--- a/LongoMatch.GUI/Gui/TreeView/PlayersTreeView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/PlayersTreeView.cs
@@ -87,12 +87,6 @@ namespace LongoMatch.Gui.Component
                        return false;
                }
 
-               override protected void OnNameCellEdited(object o, Gtk.EditedArgs args)
-               {
-                       base.OnNameCellEdited(o, args);
-                       Model.SetSortFunc(0, SortFunction);
-               }
-
                override protected bool OnButtonPressEvent(Gdk.EventButton evnt)
                {
                        TreePath[] paths = Selection.GetSelectedRows();
diff --git a/LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs b/LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs
index 5a73db1..a2bce9d 100644
--- a/LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs
@@ -106,7 +106,6 @@ namespace LongoMatch.Gui.Component
 
                        categoriesMenu = manager.GetWidget("/CategoryMenu") as Menu;
 
-                       edit.Activated += OnEdit;
                        sortByName.Activated += OnSortActivated;
                        sortByStart.Activated += OnSortActivated;
                        sortByStop.Activated += OnSortActivated;
@@ -203,21 +202,15 @@ namespace LongoMatch.Gui.Component
                        // Don't allow multiselect for categories
                        if(!selected && selection.GetSelectedRows().Length > 0) {
                                if(selection.GetSelectedRows().Length == 1 &&
-                                               GetValueFromPath(selection.GetSelectedRows()[0]) is Category)
+                                               GetValueFromPath(selection.GetSelectedRows()[0]) is 
AnalysisCategory)
                                        return false;
-                               return !(GetValueFromPath(path) is Category);
+                               return !(GetValueFromPath(path) is AnalysisCategory);
                        }
                        // Always unselect
                        else
                                return true;
                }
 
-               override protected void OnNameCellEdited(object o, Gtk.EditedArgs args)
-               {
-                       base.OnNameCellEdited(o, args);
-                       Model.SetSortFunc(0, SortFunction);
-               }
-
                override protected bool OnButtonPressEvent(Gdk.EventButton evnt)
                {
                        TreePath[] paths = Selection.GetSelectedRows();
diff --git a/LongoMatch.GUI/LongoMatch.GUI.mdp b/LongoMatch.GUI/LongoMatch.GUI.mdp
index 18b23fe..b64dcc0 100644
--- a/LongoMatch.GUI/LongoMatch.GUI.mdp
+++ b/LongoMatch.GUI/LongoMatch.GUI.mdp
@@ -27,7 +27,6 @@
     <File subtype="Code" buildaction="Compile" name="Gui/Dialog/HotKeySelectorDialog.cs" />
     <File subtype="Directory" buildaction="Compile" name="Gui/TreeView" />
     <File subtype="Code" buildaction="Compile" name="Gui/TreeView/PlayersTreeView.cs" />
-    <File subtype="Code" buildaction="Compile" name="Gui/TreeView/PlayerPropertiesTreeView.cs" />
     <File subtype="Code" buildaction="Compile" name="Gui/TreeView/PlayListTreeView.cs" />
     <File subtype="Code" buildaction="Compile" name="Gui/TreeView/PlaysTreeView.cs" />
     <File subtype="Code" buildaction="Compile" name="Gui/Dialog/SnapshotsDialog.cs" />


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