API addition to Region & change to SkinBase method signatures
Gerrit Grunwald
han.solo at muenster.de
Tue Apr 16 21:13:51 PDT 2013
Very nice idea... +1
Gerrit
Am 17.04.2013 um 00:32 schrieb Jasper Potts <jasper.potts at oracle.com>:
> Hi All,
>
> We have been endlessly chasing bugs in UI Controls Skins where we are not reliably and consistently snapping to pixels the insets/padding values used in computePref/Min/Max etc methods and in the layoutChildren method.
>
> So I am suggesting adding some helper methods to Region and passing in values to the compute methods so that its much easier for developers to have the correctly snapped values at hand.
>
> Region Additions
>
> public class Region {
> …..
> public int snappedTopInset()
> public int snappedBottomInset()
> public int snappedRightInset()
> public int snappedBottomInset()
> …..
> }
>
> These will the the equivalent of "snapSize(getInsets().getTop())" but implemented in a more efficient way.
>
> Changes to SkinBase
>
> OLD
> public abstract class SkinBase<C extends Control> implements Skin<C> {
> …..
> protected double computeMinWidth(double height)
> protected double computeMinHeight(double width)
> protected double computeMaxWidth(double height)
> protected double computeMaxHeight(double width)
> protected double computePrefWidth(double height)
> protected double computePrefHeight(double width)
> public double getBaselineOffset()
> …..
> }
>
> NEW
> public abstract class SkinBase<C extends Control> implements Skin<C> {
> …..
> protected double computeMinWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset)
> protected double computeMinHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset)
> protected double computeMaxWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset)
> protected double computeMaxHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset)
> protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset)
> protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset)
> public double computeBaselineOffset()
> …..
> }
>
> The topInsets etc will be calculated as getSkinnable().snappedTopInset(). The change from getBaselineOffset() to computeBaselineOffset() is just to make it clear this method is responsible for computing this value not getting one someone else has computed. We are not passing insets into computeBaselineOffset() because we so far have never needed them, they are easy to get with the snappedXXX methods if needed.
>
> I am really hopping this will make it easy to maintain constant behavior as we work on controls implementations in the futrure.
>
> Thanks
>
> Jasper
More information about the openjfx-dev
mailing list