Search in sources :

Example 6 with FillPane

use of org.apache.pivot.wtk.FillPane in project pivot by apache.

the class FillPaneSkin method getBaseline.

@Override
public int getBaseline(int width, int height) {
    FillPane fillPane = (FillPane) getComponent();
    int baseline = -1;
    int contentHeight = 0;
    switch(fillPane.getOrientation()) {
        case HORIZONTAL:
            {
                int clientHeight = Math.max(height - padding.getHeight(), 0);
                for (Component component : fillPane) {
                    if (component.isVisible()) {
                        int componentWidth = component.getPreferredWidth(clientHeight);
                        baseline = Math.max(baseline, component.getBaseline(componentWidth, clientHeight));
                    }
                }
                break;
            }
        case VERTICAL:
            {
                int clientWidth = Math.max(width - padding.getWidth(), 0);
                for (Component component : fillPane) {
                    if (component.isVisible()) {
                        Dimensions size;
                        size = new Dimensions(clientWidth, component.getPreferredHeight(clientWidth));
                        if (baseline == -1) {
                            baseline = component.getBaseline(size.width, size.height);
                            if (baseline != -1) {
                                baseline += contentHeight;
                            }
                        }
                        contentHeight += size.height + spacing;
                    }
                }
                break;
            }
        default:
            {
                break;
            }
    }
    if (baseline != -1) {
        baseline += padding.top;
    }
    return baseline;
}
Also used : FillPane(org.apache.pivot.wtk.FillPane) Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component)

Aggregations

FillPane (org.apache.pivot.wtk.FillPane)6 Component (org.apache.pivot.wtk.Component)5 Orientation (org.apache.pivot.wtk.Orientation)3 Dimensions (org.apache.pivot.wtk.Dimensions)2