Some days ago I came across a weird discrepancy.
Caused by LabeledSkinBase.
It may use one of the two methods to obtain the graphic width/height:
graphic.getLayoutBounds().getWidth();
or:
Utils.boundedSize(w, graphic.minWidth(-1), graphic.maxWidth(-1));
Sometimes combined with the call:
graphic.autosize();
So I was wondering; What is the difference, why do both approaches and
methods exist at the same time?
Why is sometimes the former, sometimes the latter used?
The problem: If you set something as e.g. button graphic that extends
from Parent, the layout bounds are not the same as the minWidth /
maxWidth you specified or computed.
Instead, Parent will use the layoutBounds from the children, which may
produce different and wrong results. And since LabeledSkinBase uses both
methods, it depends on the Label settings, so it is just sometimes wrong.
This does not happen with anything extending Region (like Control),
because the layout bounds always use the width and height of the Region.
But for everything that does not extend Region but Parent instead, you
can NOT influence the layout bounds and the specified width/height is
not always used/honored. So if you override all computeXXX and
minXXX/maxXXX methods, they might not be used in that case.
Any thoughts?
-- Marius