[API Review]: Node validation
Martin Sladecek
martin.sladecek at oracle.com
Fri Jul 12 06:39:04 PDT 2013
The thing is that in order to compute the layout correctly, you have to
start from the layout root. The concept of layout roots is not
documented well in the API ( we use the term in few place, but never
define it) and people would have to know how to identify the layout root
and also know that they need to start from the layout root. Also,
there's no way to check which Node is the layout root, although you can
identify it using managedProperty(), it's parent and/or subscene.
The validate methods finds the layout root of the subtree where the Node
resides and does the layout from that layout root. If somebody needs
more precise control over layout, we can leave the layout() methods
public. But I expect people will be confused that simply calling the
layout() on a Node will not result in the layout they will see after pulse.
-Martin
On 07/12/2013 03:05 PM, steve.x.northover at oracle.com wrote:
> I don't agree. It's pretty clear that when you call applyCSS(), then
> CSS is applied. The rest of the JFX API works exactly as expected and
> as documented. The programmer has precise control over what happens,
> when it happens and where it happens.
>
> Can you summarize what "validate" does? Is it sent to a leaf or the
> root node or does it matter?
>
> Steve
>
> On 12/07/2013 6:36 AM, Martin Sladecek wrote:
>> What you suggest would be quite hard to use. Actually I think most of
>> the developers will not know how to use it properly in order to get
>> the right measurement.
>> Simple "validate" call would be more convenient and less error-prone.
>>
>> -Martin
>>
>> On 07/12/2013 12:02 AM, steve.x.northover at oracle.com wrote:
>>> I don't think I understand the answer. Are you saying that what we
>>> are suggesting is wrong conceptually or hard to implement or ...?
>>>
>>> Steve
>>>
>>> On 11/07/2013 1:23 PM, Martin Sladecek wrote:
>>>> No, I will change the dirty roots to dirty flags on every node.
>>>> With them, it's possible to use it the way you suggest (applyCSS &
>>>> layout on nearest layout root), but it's much more convenient if we
>>>> could identify the layout root of the subtree and apply the layout
>>>> from there downwards. I think it's something most of the usecases
>>>> would want (SB, snapshot) but it's not that simple to identify
>>>> layout root (we have private flag for that in every Node, so
>>>> internally it's just one boolean check).
>>>>
>>>> -Martin
>>>>
>>>> On 07/11/2013 05:15 PM, Richard Bair wrote:
>>>>>>> This might work for CSS, but won't for layout. The second
>>>>>>> example won't work because you'd just do layout of the node
>>>>>>> itself. It might get a different size from it's parent during
>>>>>>> the next layout pass (and the parent from it's parent, etc...).
>>>>>>> So the layout will look different after the next pulse. This is
>>>>>>> why we need more than layout() call and it's not just about
>>>>>>> adding the CSS.
>>>>>> If I understand properly this would be the correct behavior. If I
>>>>>> ask a subtree of nodes to layout after setting the size of the
>>>>>> subtree root, then go farther up the tree to an ancestor, ensure
>>>>>> the ancestor has a size and layout again, the original subtree
>>>>>> might be layed out differently and I would expect that. If I
>>>>>> need to take a snapshot of a child and it has to be in context of
>>>>>> the entire tree, I do CC in the root, force layout in the root
>>>>>> and then take a snapshot of the child.
>>>>> That was what I was thinking as well, I don't understand why we
>>>>> have to do more than provide a way to apply CSS in order to
>>>>> satisfy all the use cases? Note that the old implementation (with
>>>>> lists of dirty roots on the Scene, or is this still the way we do
>>>>> it?) might be problematic here, I don't know, but from an API
>>>>> point of view, it seems like this is exactly what you want.
>>>>>
>>>>> Richard
>>>>
>>>
>>
>
More information about the openjfx-dev
mailing list