24 February 2007

The Important Constant in Your GUI Application

Right there at the top of the View in your MVC application, because you do use the Model-View-Controller model and I'm willing to travel to visit Pattern rage on your head if you don't, should be the immortal equivalent of:
   /**
    * Golden Ratio for layout calculations.
    */
   private static final double PHI = 1.61803398874989842;

For anything else is heretical. Your PHI is the ratio to split all your width-height ratios. Initial window sizes, initial positions, split pane ratios, button height-widths, main vertical widget heights relative to minor widgets, etc, etc.

Recognise that any other GUI layout magic numbers are deeply sh*t. And go home to cry when you see these elsewises. Oh... the tears for all those 100px:900px splits on 1000px square windows.

And the real magic is it is impossible to overuse the golden ratio. No really... the more PHI the better. I sing of arms and the pairs:
   private static final int HEIGHT = 512;
   private static final int WIDTH = (int) (HEIGHT * PHI);
Delightfully wide. :) If only TV was done like this in place of its own madness. Sigh.

No comments: