Tiled Gallery: Extract shape computation logic.

Moved the Tiled Gallery Shape classes out of the plugin file to its own file.