2016-08-01 18:54:47 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
using Gtk;
|
2016-08-01 19:26:20 +00:00
|
|
|
|
using Ext.SilentorBit;
|
2016-08-01 18:54:47 +00:00
|
|
|
|
|
|
|
|
|
namespace SpritePacker.GUI
|
|
|
|
|
{
|
|
|
|
|
public class MainWindow : Window
|
|
|
|
|
{
|
|
|
|
|
private static bool initialised = false;
|
|
|
|
|
|
|
|
|
|
private SpriteListView spriteListDisplay;
|
|
|
|
|
|
|
|
|
|
public MainWindow() : base("SpritePacker GUI")
|
|
|
|
|
{
|
|
|
|
|
if (!initialised)
|
|
|
|
|
throw new InvalidOperationException("Error: Gtk hasn't been initialised yet, so you can't create a new window.");
|
|
|
|
|
|
|
|
|
|
SetDefaultSize(500, 300);
|
|
|
|
|
SetPosition(WindowPosition.Center);
|
|
|
|
|
|
|
|
|
|
// Quit when the close button is pressed
|
|
|
|
|
DeleteEvent += (object o, DeleteEventArgs args) => {
|
|
|
|
|
Application.Quit();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
setupLayout();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initilise GTK# to make it ready for use.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void Init()
|
|
|
|
|
{
|
|
|
|
|
initialised = true;
|
|
|
|
|
Application.Init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Start()
|
|
|
|
|
{
|
|
|
|
|
ShowAll();
|
|
|
|
|
Application.Run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setupLayout()
|
|
|
|
|
{
|
|
|
|
|
HBox masterContainer = new HBox(true, 10);
|
|
|
|
|
VBox leftPanel = new VBox(false, 0) { MarginRight = 5 };
|
|
|
|
|
VBox rightPanel = new VBox(false, 0) { MarginLeft = 5 };
|
|
|
|
|
Frame leftPanelFrame = new Frame("Sprites") { Child = leftPanel, Margin = 10, MarginRight = 5 };
|
|
|
|
|
Frame rightPanelFrame = new Frame("Preview") { Child = rightPanel, Margin = 10, MarginLeft = 5 };
|
|
|
|
|
|
|
|
|
|
spriteListDisplay = new SpriteListView() { Margin = 10 };
|
|
|
|
|
spriteListDisplay.AddItem(new Sprite("/home/sbrl/Pictures/Spaghetti.png"));
|
|
|
|
|
|
|
|
|
|
leftPanel.OverrideBackgroundColor(StateFlags.Normal, Gdk.RGBA.Zero);
|
|
|
|
|
leftPanel.PackStart(spriteListDisplay, true, true, 0);
|
|
|
|
|
|
|
|
|
|
masterContainer.PackStart(leftPanelFrame, true, true, 0);
|
|
|
|
|
masterContainer.PackStart(rightPanelFrame, true, true, 0);
|
|
|
|
|
|
|
|
|
|
Add(masterContainer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|