On Tue, 5 Nov 2024 22:39:57 GMT, Michael Strauß <mstra...@openjdk.org> wrote:

>> Perhaps I am not entirely clear.  But having these examples helped, thanks.
>> 
>> My point is that, in my opinion, we don't need two classes.  We only need 
>> one, with a single `'center'` property.  If the app needs 
>> leading/tailing/upper/lower/anythingElse, the app is free to use any 
>> container suitable for their need.
>> 
>> This way the platform provides the basis, which only the platform can 
>> provide.
>> 
>> So my suggestion would be to combine two classes into one with a single 
>> `'center'` property.
>> 
>> What do you think?
>
> I see where you're coming from. While that might be a possible way to skin 
> the cat, I think it has a few downsides. It would remove most API from 
> `HeaderBar`, and instead, as you say, accept a single node as content. This 
> would shift the concrete API from `HeaderBar` to whatever node/pane/layout 
> container is placed in it.
> 
> However, the layout container inside this hypothetical header bar would, for 
> many scenarios, need to have back-references to the header bar in order to 
> achieve its purpose, either directly or indirectly by inspecting its own 
> parents. One example is the centering behavior currently implemented for 
> `HeaderBar.center` with a center-aligned node: it needs to know how wide the 
> system insets are to compute the layout. This would mean that a layout 
> container needs to be created that is aware of the context in which it is 
> used, and changes its behavior (or maybe only meaningfully works) if it is 
> placed in a `HeaderBar`.
> 
> So even recreating the current `HeaderBar` would lead to a bad and 
> potentially fragile API. This, in my opinion, rules out the approach to 
> shifting all layout behavior to a user-supplied layout container.

aha!  this is the (good) argument I was asking for, thanks!

I mean, I am not buying it entirely, since "centering" may mean different 
things to different people - for example using window half-width may or may not 
be a good centering position if you have asymmetry due to the buttons on one 
side, perhaps it would be better to center across the empty area instead.

But if other people are ok with breaking up this thing into two classes, I 
won't object (much).

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1605#discussion_r1830098487

Reply via email to