From 935f4e2f7e369494f0530877d429307ea6b4a438 Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 22 Jun 2020 21:26:15 +0000 Subject: Added initial controls. --- SpriteEd/Main.storyboard | 453 ++++++++++++++++++++---------------- SpriteEd/NSSpriteEdit.cs | 48 ++++ SpriteEd/ViewController.cs | 22 +- SpriteEd/ViewController.designer.cs | 45 +++- 4 files changed, 353 insertions(+), 215 deletions(-) diff --git a/SpriteEd/Main.storyboard b/SpriteEd/Main.storyboard index 5366561..b6d561e 100644 --- a/SpriteEd/Main.storyboard +++ b/SpriteEd/Main.storyboard @@ -1,7 +1,8 @@ - - + + - + + @@ -11,323 +12,323 @@ - + - + - + - - - + + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -337,259 +338,259 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + Default - + - + Left to Right - + - + Right to Left - + - + - + - + Default - + - + Left to Right - + - + Right to Left - + - + - + - + - + - + - + - + - + @@ -599,69 +600,69 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -670,48 +671,90 @@ - + - - - + + + - + - - - - - + + + + + + - + - + - + - + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + diff --git a/SpriteEd/NSSpriteEdit.cs b/SpriteEd/NSSpriteEdit.cs index 3490544..4f6d0c5 100644 --- a/SpriteEd/NSSpriteEdit.cs +++ b/SpriteEd/NSSpriteEdit.cs @@ -23,11 +23,59 @@ using CoreGraphics; namespace SpriteEd { + /// + /// Sprite editor control. + /// [Register("NSSpriteEdit")] public class NSSpriteEdit : NSControl { + /// + /// The sprite being edited. + /// + public Sprite Sprite {get;set;} + + /// + /// Default constructor + /// public NSSpriteEdit() { + Init(); + } + + /// + /// Constructor. + /// + /// The handle. + public NSSpriteEdit(IntPtr handle) : base(handle) + { + Init(); + } + + /// + /// Constructor. + /// + /// The frame rectangle + [Export ("initWithFrame:")] + public NSSpriteEdit(CGRect frameRect) : base(frameRect) + { + Init(); + } + + private void Init() + { + WantsLayer = true; + LayerContentsRedrawPolicy = NSViewLayerContentsRedrawPolicy.OnSetNeedsDisplay; + } + + /// + /// Redraw the control. + /// + /// The dirty rectangle + public override void DrawRect (CGRect dirtyRect) + { + base.DrawRect (dirtyRect); + + // TODO: Draw control } } } diff --git a/SpriteEd/ViewController.cs b/SpriteEd/ViewController.cs index 8c9459f..82732a3 100644 --- a/SpriteEd/ViewController.cs +++ b/SpriteEd/ViewController.cs @@ -23,6 +23,9 @@ namespace SpriteEd { public partial class ViewController : NSViewController { + private Palette m_Palette; + private SpriteSet m_SpriteSet; + public ViewController(IntPtr handle) : base(handle) { } @@ -31,7 +34,14 @@ namespace SpriteEd { base.ViewDidLoad(); - // Do any additional setup after loading the view. + m_SpriteNumber.IntValue = 0; + m_Stepper.IntValue = 0; + + m_Palette = new Palette(2); + m_Palette[0] = new Colour(0, 0, 0); + m_Palette[1] = new Colour(255, 255, 255); + + m_SpriteSet = new SpriteSet(8, 8, m_Palette, false, false); } public override NSObject RepresentedObject @@ -46,5 +56,15 @@ namespace SpriteEd // Update the view, if already loaded. } } + + partial void OnStepper(NSObject sender) + { + NSStepper stepper = sender as NSStepper; + + if (stepper != null) + { + m_SpriteNumber.IntValue = stepper.IntValue; + } + } } } diff --git a/SpriteEd/ViewController.designer.cs b/SpriteEd/ViewController.designer.cs index 17b5bfd..9ea3fc9 100644 --- a/SpriteEd/ViewController.designer.cs +++ b/SpriteEd/ViewController.designer.cs @@ -1,18 +1,45 @@ -// WARNING +// WARNING // -// This file has been generated automatically by Xamarin Studio to store outlets and +// This file has been generated automatically by Visual Studio to store outlets and // actions made in the UI designer. If it is removed, they will be lost. // Manual changes to this file may not be handled correctly. // using Foundation; +using System.CodeDom.Compiler; namespace SpriteEd { - [Register("ViewController")] - partial class ViewController - { - void ReleaseDesignerOutlets() - { - } - } + [Register ("ViewController")] + partial class ViewController + { + [Outlet] + SpriteEd.NSSpriteEdit m_SpriteEdit { get; set; } + + [Outlet] + AppKit.NSTextField m_SpriteNumber { get; set; } + + [Outlet] + AppKit.NSStepper m_Stepper { get; set; } + + [Action ("OnStepper:")] + partial void OnStepper (Foundation.NSObject sender); + + void ReleaseDesignerOutlets () + { + if (m_SpriteNumber != null) { + m_SpriteNumber.Dispose (); + m_SpriteNumber = null; + } + + if (m_Stepper != null) { + m_Stepper.Dispose (); + m_Stepper = null; + } + + if (m_SpriteEdit != null) { + m_SpriteEdit.Dispose (); + m_SpriteEdit = null; + } + } + } } -- cgit v1.2.3