Browse Source

Work on GUI & add test row to ListView

tags/v0.1
Starbeamrainbowlabs 3 years ago
parent
commit
aa3f114f0c
2 changed files with 10 additions and 3 deletions
  1. 4
    0
      SpritePacker-GUI/ListView.cs
  2. 6
    3
      SpritePacker-GUI/SpriteListView.cs

+ 4
- 0
SpritePacker-GUI/ListView.cs 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);
}


+ 6
- 3
SpritePacker-GUI/SpriteListView.cs 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}");

Loading…
Cancel
Save