Extending Builders: Layout Builders
Tom Schindl
tom.schindl at bestsolution.at
Thu Nov 29 11:25:09 PST 2012
Am 29.11.12 19:42, schrieb Tom Eugelink:
> On 2012-11-29 19:03, Tom Schindl wrote:
>> Am 29.11.12 17:38, schrieb Richard Bair:
>>>
>>> Actually, every node already has properties on it to support layout
>>> -- isResizable, layoutBounds, and so on. So having the constraints on
>>> the Node fits right in (and in fact is how we had done it
>>> previously). The bigger concern (if I remember correctly), is what is
>>> the *type* of this constraints object? Do all layout containers have
>>> to cast this and perform an instance of check? Having to do an
>>> instance of is distasteful, as is having a base class type that
>>> really isn't overly useful (you are likely to fail in finding a
>>> least-common-denominator for all constraints types).
>>>
>>> Further, one advantage to having the layout constraints in the
>>> dynamic properties map is that you can have the constraints for two
>>> different layout managers at the same time. Niche, but the idea is
>>> that you could move a node from one layout container to another and
>>> it would just have the right settings. I don't think that is really
>>> all that important, but it is a use case.
>>>
>> Correct and but what if they by chance use the same key for different
>> values, then you hit an even worse problem today ;-)
>
> Why would constraints need to have a common super class? Constraints can
> be so different that trying to force a general API IMHO always will be a
> bit of a kludge.
>
> And I have a working proposal for the
> constraints-for-multiple-different-layout-managers in the JFXtras
> versions: each layout holds the contraints in a WeakHashmap<Node,
> Constaint>. As soon as a Node is no longer referenced, all its
> constraints are cleared. And this has another advantage: you can have
> different constaints; so a node can be left aligned in one layout and
> right aligned in the other.
>
I think storing the constraint on the owner is not a good idea because
you don't have an API for e.g. bulk-operations.
The Layout#add(Node,Constraint) API should only be a convenience one for
developers.
Tom
--
B e s t S o l u t i o n . a t EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl geschäftsführer/CEO
------------------------------------------------------------------------
eduard-bodem-gasse 5-7/1 A-6020 innsbruck fax ++43 512 935833
http://www.BestSolution.at phone ++43 512 935834
More information about the openjfx-dev
mailing list