Playing With Blocks: Demo Time

Since my last “Playing with Blocks” post, on the DragHandleConnector class, I’ve been hard at work (when time permitted) fleshing out the application to get to the point where I could post a demo. That point has finally arrived, and you can see the results for yourself. Here’s a screen shot:

There is a lot you still can’t do in the demo. You can’t select objects and change them, move them, or delete them, for example. That’s actually the next area I’ll be working on. What you can do is edit styles and lay down shapes and text. The style editing encompasses all of the visual properties that apply to shapes and text, including opacity, fill and stroke, etc.

As often happens a ton of work has gone into producing only a very few features, because so much infrastructure had to be designed, implemented, and tweaked. There have been quite a few changes along the way, some major, as I figured out that some earlier ideas wouldn’t work as I had hoped they would. But a lot of it did, and since I like the way most of it has turned out I’ll say a couple of words about how it works.

The bulk of the work involved how tools would be defined, and interfaced to. I wanted an extensible mechanism that loaded tools dynamically. Currently tools are defined in a library that is loaded when the application starts. That’s the slight delay between the display of the main window and the appearance of the controls. Each tool defines how it will appear in the toolbox, the editor class that should be invoked to do whatever the tool does, a default Style to be applied to new instances of whatever shape it creates, and potentially the style control needed to manipulate the properties of the shape. The library provides a list of those style controls to the application when it is first loaded.

Styles are used to carry information about the appearance of shapes between the various subsystems in the app. When a tool is first loaded it provides a default style to the StyleBox, which loads the appropriate controls for editing that style, and gives each control a chance to initialize itself from the setter values in the Style. When the user makes changes to the style these are preserved in the editor for future use until the application is restarted. A lot of the tweaking I had to do involved learning how to create, manipulate, and apply styles dynamically. Some of that was interesting, and may be the subject of a future post. For now it’s back to the drawing board to begin working on shape selection and manipulation.

Leave a Reply

Your email address will not be published. Required fields are marked *