Work on GUI & add test row to ListView

This commit is contained in:
Starbeamrainbowlabs 2016-08-01 20:16:10 +01:00
parent c4ecc51245
commit aa3f114f0c
2 changed files with 10 additions and 3 deletions

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Gtk;
using System.Security.Policy;
namespace SilentorBit
{
@ -35,6 +36,8 @@ namespace SilentorBit
public event Action<T[]> ItemSelected;
public event Action<T> ItemActivated;
public bool ResizeableColumns { get; set; } = true;
protected abstract void RenderCell (CellRendererText render, int index, T item);
ListStore store = new ListStore (typeof(T));
@ -52,6 +55,7 @@ namespace SilentorBit
this.Model = store;
foreach (string s in columnNames) {
TreeViewColumn c = this.AppendColumn (s, new CellRendererText (), this.ColumnCellData);
c.Resizable = ResizeableColumns; // Make the column resizeable - Added by Starbeamrainbowlabs
columns.Add (c);
}

View file

@ -6,11 +6,11 @@ namespace SpritePacker.GUI
{
public class SpriteListView : ListView<Sprite>
{
public SpriteListView() : base("Number", "Filepath")
public SpriteListView() : base("#", "Filename", "Image Size")
{
}
protected override void RenderCell(Gtk.CellRendererText render, int index, Sprite item)
protected override void RenderCell(Gtk.CellRendererText render, int index, Sprite sprite)
{
switch(index)
{
@ -18,7 +18,10 @@ namespace SpritePacker.GUI
render.Text = index.ToString();
break;
case 1:
render.Text = item.Filename;
render.Text = System.IO.Path.GetFileName(sprite.Filename);
break;
case 2:
render.Text = $"{sprite.Width} x {sprite.Height}";
break;
default:
throw new InvalidDataException($"Invalid column index {index}");