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);
}
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();
}
}
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;
}
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;
}
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);
}
Aggregations