Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rectangle Layout #44

Open
samreid opened this issue Oct 22, 2015 · 1 comment
Open

Rectangle Layout #44

samreid opened this issue Oct 22, 2015 · 1 comment

Comments

@samreid
Copy link
Member

samreid commented Oct 22, 2015

@jonathanolson suggested putting the core of the rectangle layout engine here in dot. See phetsims/bending-light#265

@jonathanolson or @samreid can work on it at their leisure.

@samreid
Copy link
Member Author

samreid commented Oct 23, 2015

It seems like what we really want is a language for describing the a dynamic flexible layout of the entire simulation. This seems a daunting task! I haven't really been satisfied with the Java layout containers. Maybe a simple rule that still gives us complete flexibility is to treat every layout-able object as having a Property, then writing rules for aligning objects relative to other Property. Then if we want a button to align to the top right corner of the visible stage bounds (with some padding), it would have a rule that does so. Then if we want a control panel below that button, it would have a separate rule. Then when the top-level layout changes, the Property notifications cascade and everything relays itself out properly.

And we don't even need to give names for the relative layout strategies such as "within parent bounds in the top right with paddingx and paddingy) (there would be many of them (!) ), we can just use a function in each case and use vanilla scenery code.

// This is a fictional case where there is a button in the top right of the screen, and a control panel below it.
visibleScreenBoundsProperty.link(function(visibleScreenBounds){
  button.right = visibleScreenBounds.right - insetX;
  button.top = visibleScreenBounds.top+insetY;
});

buttonBoundsProperty.link(function(buttonBounds){
  controlPanel.right = buttonBounds.right;
  controlPanel.top = buttonBounds.bottom+insetY;
});

@jonathanolson what do you think of that plan?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants