Thursday, September 22, 2011

Interfacing

After a couple of weeks of dredging through 'ground work' I've finally come out above ground level. I've got the inner workings of my 'Interface' class working properly and it's looking to work pretty well! Right now it handles just panels and buttons. The window manager knows how to draw 'em in all their states (like, if you mouse over a button etc.) And the proper 'hooks' are in place to connect buttons to certain events.



Initially I was going to have the buttons 'perform events' by providing them with a function pointer to the function they need to execute, an idea by a friend of mine. However I found, having implemented most of this already, that function pointers cannot point to parenthesized functions. Quite a problem considering most of my code is designed with a reasonably strict class hierarchy. The interface class, for instance, doesn't 'know' about any of the higher level classes like those part of the Editor.

In stead of this method I decided to do a crude implementation of an 'event' structure. I have an array of booleans which correspond to 'actions'. A button is supplied a pointer to a particular boolean, this defines which action it'll perform when pressed. After the interface has been handled each cycle, the Editor will see if any of these booleans where set to true and then perform the function associated with that boolean. Pretty simple stuff.

The next step will be to design the UI using my existing (and probably some new) Interface elements and hook it up to functionality. Most of this will rely on the foundation I've been building the past few months.

Also, good news for me and anyone keeping track of this, I recently took an internship in a nearby town and thus will have a regular commute over there and back. This provides ample opportunity to do more coding. Couple this with the fact that I'm back into 'not boring foundation work' zone and it should make for some productive times!

Until next time!

No comments: