johnfn / Illumination

2 stars 0 forks source link

Autopositioner #21

Open johnfn opened 14 years ago

johnfn commented 14 years ago

If we still have a lot of panels to go, or we want to make things pretty (and that is always a good idea), this is what I suggest...

The ideal way to make a panel is like this (pseudocode):

Panel p = new Panel();
p.addComponent(new Label("Hello world"));
p.addComponent(new Button("Please press me", eventHandler));
p.addComponent(new GameWinner("After you press this button, you win."));

The Panel object would take care of arranging all of the labels, buttons, DirectionHandlers, StatusBars, GameWinners, and so on. The easiest way would just be to align them 1 at a time down the page. Of course, we could make life more interesting by adding other ways to align stuff (direction on the left, everything else aligned on the right).

The Panel object would not have any coordinates hardcoded into it. It would figure out the next coordinate by spacing objects appropriately, and taking into consideration their bounding box.

I don't know how much work remains on panels, and I'm not saying that we necessarily have to overhaul the whole system. However, debugging/changing a huge system of hardcoded constants is a nightmare...

dwu4 commented 14 years ago

I completely agree. This is the way I was thinking about using panels... and the way it works in Java :)

Having autopositioning and self-adjustment will also come in handy when we change screen resolution/sizes - for instance, toggle full screen now (F12) and you'll see what I mean. I also don't like magic numbers :P

johnfn commented 14 years ago

Java is where I got the inspiration from :-)

dwu4 commented 14 years ago

Also, just out of curiosity, how do you specify the inline code block on the issue comment? That looks really cool :D

johnfn commented 14 years ago

You put 4 spaces in front of any line with code on it.

They say they use markdown, which means you get all sorts of nice effects...