Posts Tagged ‘Phorg’

Core Data Twiddling

Monday, October 13th, 2008

I got the itch over the weekend to get back into application coding. I’ve been away doing level design for awhile now and the programming side of my brain was starting to feel neglected. So it’s time to get some book learnin’ done!

I decided to take another stab at a photo viewer. Unimaginative, I know, but it does provide a good platform for learning. I’m going to try a different tactic than I normally do. Normally, I create a monolithic application that evolves over time as I learn new things or better ways of doing existing things.

This time I’m taking it slow. I’m creating small applications that demonstrate one piece of technology that I need for the larger photo viewing application. For example, I created one on the weekend that takes a group of images and creates proportionally scaled thumbnails for them (for testing purposes, it wrote them out to my hard drive as well so I could physically see the results). After that, I started into an application to teach myself Core Data.

Core Data looks really interesting. I know that I want to store the thumbnails and tags and references to the original images in some sort of database – ideally using SQLite since the Mac has native support for that format. When I did this stuff the first time I wrote the database handling code by hand which was a major hassle so I decided to delve into Core Data this time around.

So far I’m definitely happy with what I’m seeing. Using the visual data modeler they have built into XCode is very easy and the fact that it generates the glue code to get to the database entities themselves is pretty slick. I really like how with 2 code changes you can switch from an SQLite database to an XML file. That will prove to be invaluable when it comes time to debug issues. Being able to see what was written to the database in text form makes it so nice.

I don’t have anything significant working yet but I’m on the right track here.

Phorg

Monday, January 28th, 2008

Another project I have on the go is a picture viewer. I know, not that exciting, but it’s entire purpose in life is to allow me to learn more about Mac programming. It loads the picture thumbnails using multithreading and it allows dynamic resizing of the window and the thumbnails.

Here’s a look at the window so far:

phorg_1.jpg

I was starting to code up a zoom window for it yesterday – so you could double click thumbnails and see the picture in a larger window – but then I got to wondering if it was possible to use the Quick Look window that comes with Leopard. It turns out, it IS possible! It’s a bit of a hack but the code I found to do it wasn’t that bad to look at and it’s contained in a small area of the code base so I can replace it later if the hack breaks. I found the info here.

So I changed the code to behave like Quick Look does in the Finder. Pressing SPACE will zoom the selected pictures into the Quick Look window and pressing it again will close the window. It works!

phorg_2.jpg

Quick Look is great. Imagine the possibilities this opens up for the ToeTag texture browser. Muhaha.

In closing, here’s a movie of the pictures loading using multithreading. Why? Why not? You’re at work and you’re bored.

.: Watch it! :.