Work on GUI & add test row to ListView
This commit is contained in:
parent
c4ecc51245
commit
aa3f114f0c
2 changed files with 10 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Gtk;
|
using Gtk;
|
||||||
|
using System.Security.Policy;
|
||||||
|
|
||||||
namespace SilentorBit
|
namespace SilentorBit
|
||||||
{
|
{
|
||||||
|
@ -35,6 +36,8 @@ namespace SilentorBit
|
||||||
public event Action<T[]> ItemSelected;
|
public event Action<T[]> ItemSelected;
|
||||||
public event Action<T> ItemActivated;
|
public event Action<T> ItemActivated;
|
||||||
|
|
||||||
|
public bool ResizeableColumns { get; set; } = true;
|
||||||
|
|
||||||
protected abstract void RenderCell (CellRendererText render, int index, T item);
|
protected abstract void RenderCell (CellRendererText render, int index, T item);
|
||||||
|
|
||||||
ListStore store = new ListStore (typeof(T));
|
ListStore store = new ListStore (typeof(T));
|
||||||
|
@ -52,6 +55,7 @@ namespace SilentorBit
|
||||||
this.Model = store;
|
this.Model = store;
|
||||||
foreach (string s in columnNames) {
|
foreach (string s in columnNames) {
|
||||||
TreeViewColumn c = this.AppendColumn (s, new CellRendererText (), this.ColumnCellData);
|
TreeViewColumn c = this.AppendColumn (s, new CellRendererText (), this.ColumnCellData);
|
||||||
|
c.Resizable = ResizeableColumns; // Make the column resizeable - Added by Starbeamrainbowlabs
|
||||||
columns.Add (c);
|
columns.Add (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,11 @@ namespace SpritePacker.GUI
|
||||||
{
|
{
|
||||||
public class SpriteListView : ListView<Sprite>
|
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)
|
switch(index)
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,10 @@ namespace SpritePacker.GUI
|
||||||
render.Text = index.ToString();
|
render.Text = index.ToString();
|
||||||
break;
|
break;
|
||||||
case 1:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new InvalidDataException($"Invalid column index {index}");
|
throw new InvalidDataException($"Invalid column index {index}");
|
||||||
|
|
Loading…
Reference in a new issue