Bash Terminal

I have been playing around with GO for a while. I really like the language and I am slowly getting an understanding of the language syntax by building trivial apllications. These applications end up being simple command line tools and need some way off parsing command line arguments.

This GO Package was created to make it easy to add simple command-line interfaces, where the application can define what arguments are requires and pair the argument with an information message. This array of arguments are passed into the goArgs object which then can be used to parse the arguments and provide a help / usage message on any invalid arguments.

At somepoint I may create a more fully featured parser, though I'm not sure when I will get round to buliding it.

Read more…

NSToolbarBadgedItem

This is a custom NSToolbarItem that add's support for an iOS style badge within the standard OSX NSToolbar.

The custom class NSToolbarBadgedItem provides the ability to display small amount of text in the bottom right corner surrounded by a colored oval. This small badge could used to indicate that user has X messages or flag that there is a user action required.

Features

  • Display a custom NSString.
  • Set the NSFont.
  • Set the NSColor of the text.
  • Set the NSColor of the line round the oval.
  • Set the NSColor of the ovals fill color.
  • Set the NSColor of the shadow's.
  • Setup via Interface Builder using Runtime Attributes.
Badges

Issues

The current implementation is not perfect, I had trouble getting the text into the correct position within the oval. I tried to center the text horazontally and vertical using a combination of the bounding NSRect of the Glyph and the overall bounding NSRect of the full text. This calculation could probably be improved by using the NSFont's capHeight, descender, ascender.

  • Text position in the oval is sometimes incorrect, this can get really bad depednign on the font used.
  • Badge crops the text if it's is larger than the base image.
  • Layout is currently hard coded to position the oval at the bottom right.
  • Shadow offset and line width is calculated based on the pixel size of the image and can not be set externaly.

Read more…

NSAttributedAlert

This is a custom alert panel that permits the use of NSAttribuedString to display html or rich text content within an alerts message or information display block.

I have tried to keep a similar interface to the origional NSAlert class to make it easy to intigrate the class into a project, it is still missing a chunk of functionality that comes out of the box with the standard Alert.

The custom alert panel came about due to my frustration with trying to alter the existing panel post layout to include an NSTextView that would contain the rich text content, I did ended up with a working solution. But altering the postion of the Accessory View after the content was layed out felt kind of a brittle solution and could break if the NSAlert layout changed, also the code looked like the a massive hack. So the only solution I came to was to roll my own Alter Panel.

Features

  • Supports no icon (unlike NSAlert which is set to null reverts to the Application Icon).
  • Restructures the contents (if not message is provided i shift the information block up etc).
  • Supports Clickable HTML or Rich Text links.

Source

#import <Cocoa/Cocoa.h>

@interface NSAttributedAlert : NSPanel

- (id) init;

- (NSImage*) icon;
- (void) setIcon:(NSImage*)image;

- (NSArray*) buttons;
- (void) addButtonWithTitle:(NSString*)title;

- (void) setMessageText:(NSString*)text;
- (void) setMessageText:(NSString*)text containsHtml:(BOOL)state;
- (void) setMessageAttributedText:(NSAttributedString*)text;

- (void) setInformativeText:(NSString*)text;
- (void) setInformativeText:(NSString*)text containsHtml:(BOOL)state;
- (void) setInformativeAttributedText:(NSAttributedString*)text;

- (void)setAccessoryView:(NSView *)view;
- (NSView *)accessoryView;

- (void) layout;

- (NSInteger) runModal;

- (void)beginSheetModalForWindow:(NSWindow *)window
                   modalDelegate:(id)modalDelegate
                  didEndSelector:(SEL)alertDidEndSelector
                     contextInfo:(void *)contextInfo;
@end

Read more…

Electric2D

Several years ago when I started working with the iOS platform there were no good 2d render engines avaliable and like most developers each project was built with just the bare minimum of what was need to get the project done. After a couple project each using there own set of tech (open GL, UIKit) I decided to create a small and light weight 2d render engine that I could use in multiple projects. Electric2D is the result of that effort.

As the project has sat idle and there are a number of years and I always had the intention of open sourcing the project at some point. I have decide to release the project, please feel to use it for reference but I would suggest that there are some much nicer and well maintained projects out there that would be better suited for your own projects. I have been using cocos2d / cocos2d-x for the last while for work and my personal projects as well as Unity3D.

The render was built using Open GL 1.1 as I had no need to support shaders at the time, the project does include a nice bash script for creating a SDK. This was to make it very easy to integrate into a project by just including it in the project settings, it also removed the need to compile the lib all the time and let me keep the project separate from my game projects. This script is run using a target and does a command line build of the project. It will also package up the result into dmg if my memory serves me.

Read more…

Where's the old content?

Unfortunately the server I was hosting the original blog on was hacked, this resulted in the entire machine being formatted and a fresh OS installed. Luckily enough I still have a lot of the content in a sql file and I will try to resurrect some of the post that are still relevant.

Though this may take some time.

Update (2013-11-07):

I finally got round to writing a small Python script to parse the old content. It’s now up but the links and images are broken, the content may not be as relevant as it once was.

An Archive of the content is now in available.

Read more…

I started a blog several years ago, it was mostly about my life as a programmer and it gave me a place to post code and my own thoughts. This is the second attempt at getting back into it so please do wish me luck :)

The question that I ask my self is why has it taken so long to get start posting content again?

The truth of the matter my heart and head were not ready. A lot has happened over the past couple years and I felt lost for a long time. I just needed time to get back my head back and so I choice to hide away for a while. I am not one to talk about my personal life and I'm not going to start now sorry.

Suffice to say I'm still alive and kicking :)