Browse Source

Work on GUI & add test row to ListView

tags/v0.1
Starbeamrainbowlabs 2 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 @@
1 1
 using System;
2 2
 using System.Collections.Generic;
3 3
 using Gtk;
4
+using System.Security.Policy;
4 5
 
5 6
 namespace SilentorBit
6 7
 {
@@ -35,6 +36,8 @@ namespace SilentorBit
35 36
 		public event Action<T[]> ItemSelected;
36 37
 		public event Action<T> ItemActivated;
37 38
 
39
+		public bool ResizeableColumns { get; set; } = true;
40
+
38 41
 		protected abstract void RenderCell (CellRendererText render, int index, T item);
39 42
 
40 43
 		ListStore store = new ListStore (typeof(T));
@@ -52,6 +55,7 @@ namespace SilentorBit
52 55
 			this.Model = store;
53 56
 			foreach (string s in columnNames) {
54 57
 				TreeViewColumn c = this.AppendColumn (s, new CellRendererText (), this.ColumnCellData);
58
+				c.Resizable = ResizeableColumns; // Make the column resizeable - Added by Starbeamrainbowlabs
55 59
 				columns.Add (c);
56 60
 			}
57 61
 

+ 6
- 3
SpritePacker-GUI/SpriteListView.cs View File

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

Loading…
Cancel
Save