Search in sources :

Example 1 with Rollup

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

the class RollupSkin method install.

@Override
public void install(Component component) {
    super.install(component);
    Rollup rollup = (Rollup) component;
    rollup.getRollupListeners().add(this);
    rollup.getRollupStateListeners().add(this);
}
Also used : Rollup(org.apache.pivot.wtk.Rollup)

Example 2 with Rollup

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

the class TerraRollupSkin method setSpacing.

public void setSpacing(int spacing) {
    Utils.checkNonNegative(spacing, "spacing");
    this.spacing = spacing;
    Rollup rollup = (Rollup) getComponent();
    if (rollup.isExpanded()) {
        invalidateComponent();
    }
}
Also used : Rollup(org.apache.pivot.wtk.Rollup)

Example 3 with Rollup

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

the class TerraRollupSkin method getBaseline.

@Override
public int getBaseline(int width, int height) {
    Rollup rollup = (Rollup) getComponent();
    Component heading = rollup.getHeading();
    int baseline = -1;
    if (heading != null) {
        int headingWidth, headingHeight;
        if (fill) {
            headingWidth = Math.max(width - rollupButton.getPreferredWidth(-1) - buffer, 0);
            headingHeight = heading.getPreferredHeight(headingWidth);
        } else {
            Dimensions headingPreferredSize = heading.getPreferredSize();
            headingWidth = headingPreferredSize.width;
            headingHeight = headingPreferredSize.height;
        }
        baseline = heading.getBaseline(headingWidth, headingHeight);
    }
    return baseline;
}
Also used : Rollup(org.apache.pivot.wtk.Rollup) Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component)

Example 4 with Rollup

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

the class TerraRollupSkin method getPreferredWidth.

@Override
public int getPreferredWidth(int height) {
    Rollup rollup = (Rollup) getComponent();
    Component heading = rollup.getHeading();
    Component content = rollup.getContent();
    int preferredWidth = 0;
    if (heading != null) {
        preferredWidth = heading.getPreferredWidth(-1);
    }
    if (content != null && (rollup.isExpanded() || (expandTransition != null && !expandTransition.isReversed()))) {
        preferredWidth = Math.max(preferredWidth, content.getPreferredWidth(-1));
    }
    preferredWidth += rollupButton.getPreferredWidth(-1) + buffer;
    return preferredWidth;
}
Also used : Rollup(org.apache.pivot.wtk.Rollup) Component(org.apache.pivot.wtk.Component)

Example 5 with Rollup

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

the class TerraRollupSkin method layout.

@Override
public void layout() {
    Rollup rollup = (Rollup) getComponent();
    Component heading = rollup.getHeading();
    Component content = rollup.getContent();
    Dimensions rollupButtonSize = rollupButton.getPreferredSize();
    rollupButton.setSize(rollupButtonSize.width, rollupButtonSize.height);
    int x = rollupButtonSize.width + buffer;
    int y = 0;
    int justifiedWidth = Math.max(getWidth() - rollupButtonSize.width - buffer, 0);
    if (heading != null) {
        int headingWidth, headingHeight;
        if (fill) {
            headingWidth = justifiedWidth;
            headingHeight = heading.getPreferredHeight(headingWidth);
        } else {
            Dimensions headingPreferredSize = heading.getPreferredSize();
            headingWidth = headingPreferredSize.width;
            headingHeight = headingPreferredSize.height;
        }
        heading.setLocation(x, y);
        heading.setSize(headingWidth, headingHeight);
        y += headingHeight + spacing;
    }
    if (content != null) {
        boolean contentVisible = false;
        if (rollup.isExpanded() || (expandTransition != null && !expandTransition.isReversed())) {
            Dimensions size;
            if (fill) {
                size = new Dimensions(justifiedWidth, content.getPreferredHeight(justifiedWidth));
            } else {
                size = content.getPreferredSize();
            }
            content.setLocation(x, y);
            content.setSize(size);
            contentVisible = true;
        }
        content.setVisible(contentVisible);
    }
    y = (heading == null ? 0 : (heading.getHeight() - rollupButtonSize.height) / 2 + 1);
    rollupButton.setLocation(0, y);
}
Also used : Rollup(org.apache.pivot.wtk.Rollup) Dimensions(org.apache.pivot.wtk.Dimensions) Component(org.apache.pivot.wtk.Component)

Aggregations

Rollup (org.apache.pivot.wtk.Rollup)7 Component (org.apache.pivot.wtk.Component)4 Dimensions (org.apache.pivot.wtk.Dimensions)2 Theme (org.apache.pivot.wtk.Theme)1