Geometry Management

Monte Goulding monte at sweattechnologies.com
Mon Apr 5 20:23:42 EDT 2004


Hi Chipp

> The reason I wrote this plugin is:
>
> 1) It creates resize handler scripts which can then be edited (unlike GM
> which when it doesn't work, you can't fix)
> 2) It *also* manages geometry for Mac, PC and *other* which is
> important. For instance, the tab control takes up a lot more space
> horizontally on Macs than on PCs.
> 3) It combines (IMO) the sweet spots of GeoMgr and Profiles in a way
> that neither GM or Profiles can do currently.

I still think that custom property based geometry management is the way to
go because if it's done right you can edit those properties via script.
There's a few two flaws in the Rev implementation that can be overcome by
simplifying things:
 - the custom property set is too complicated to edit directly via script or
via opening up the property set and hand editing if you need to
 - it doesn't handle relayering well if you are resizing or moving some
objects relative to others (things like grouping objects become a nightmare)

Both of these can be overcome with a simpler model and one that is aided by
the way the engine loops over controls. When I tackled the issue I decided
the simplest way to do things was to resize/position everything relative to
it's owner. So to create a resizable panel all one needed to do was group
objects and create a button that altered the geometry properties of the
panel then call resizeStack.

If I had my time again I'd now use the merge function at the core of my
geometry manager. Each object would have a custom property (could be a set
to handle platforms) that would contain a metge string like this:
[[item 1 of tOwnerRect+5,item 2 of tOwnerRect+5,item 3 of tOwnerRect-5,item
4 of tOwnerRect-5]]

Then all you need to do is get the rect of the owner and do the merge and
set the rect of the object. Simple.

To make things nice you could have a setProp handler that translated a
string like:
5,5,-5,-5 into the merge string. Or just let people set the whole thing
because then they could do what they wanted:
[[item 1 of tOwnerRect+5,item 2 of tOwnerRect+5,the top of btn "x"-5,the
left of btn "y"-5]]

Let's say you want an object to be positioned relative to the bottom left of
it's owner you just do that like this:
[[item 3 of tOwnerRect-25,item 4 of tOwnerRect-45,item 3 of
tOwnerRect-5,item 4 of tOwnerRect-5]]

Anyway... these later ideas are mostly theory as I didn't implement mine
this way. It's probably worth an investigation though.

Cheers

Monte



More information about the use-livecode mailing list