Monday 11 April 2011

Grid intensity

There is a grid intensity value in Brick Atelier. It's of course cooler than regular grids, because it's using the current pixel's color and darkening it. I wanted to add an adjusting option for the intensity, but the current dialog system was unable to handle that kind of adjusting. It was the way dialogs were constructed, using values and buttons as pairs. Buttons were linked to the dialog in Dialog_Set class. But then I realized that with more complex dialog items it was kind of difficult to set the locations of buttons.

I refactored the dialog system by adding buttons in the individual Dialog_Item class (a Dialog_Set is a list of Dialog_Items). Now, I hope, it's easier to add different dialog types. Refactoring this one was hard, and easy. Easy in a way that I have learned to write modular code and I only needed to change Dialog_Set and Dialog_Item classes. Everything else like setting up the dialogs and processing them didn't need any changes. That's the bonus you get from writing good public interfaces.

No comments: