use of com.codename1.ui.layouts.LayeredLayout.LayeredLayoutConstraint.Inset in project CodenameOne by codenameone.
the class SplitPane method changeInsets.
/**
* Changes the minimum, preferred, and maximum insets of the split pane. This will also
* update the current divider position to the supplied preferred inset.
* @param minInset The minimum inset. Can be expressed in pixels (px), millimetres (mm), or percent (%). E.g. "25%"
* @param preferredInset The preferred inset. Can be expressed in pixels (px), millimetres (mm), or percent (%). E.g. "25%"
* @param maxInset Can be expressed in pixels (px), millimetres (mm), or percent (%). E.g. "25%"
*/
public void changeInsets(String minInset, String preferredInset, String maxInset) {
LayeredLayout l = (LayeredLayout) getLayout();
initDividerInset(l.createConstraint(), preferredInset).copyTo(this.preferredInset);
initDividerInset(l.createConstraint(), minInset).copyTo(this.minInset);
initDividerInset(l.createConstraint(), maxInset).copyTo(this.maxInset);
l.setInsets(this.topOrLeft, "0 0 0 0").setInsets(this.topOrLeft, "0 0 0 0");
this.preferredInset.copyTo(l.getOrCreateConstraint(divider));
}
use of com.codename1.ui.layouts.LayeredLayout.LayeredLayoutConstraint.Inset in project CodenameOne by codenameone.
the class SplitPane method clampInset.
private void clampInset() {
int px = getDividerInset().getAbsolutePixels(divider);
isCollapsed = false;
isExpanded = false;
Inset minInset = getMinDividerInset();
if (minInset.getAbsolutePixels(divider) >= px) {
minInset.copyTo(getDividerInset());
isCollapsed = true;
isExpanded = false;
}
Inset maxInset = getMaxDividerInset();
if (maxInset.getAbsolutePixels(divider) <= px) {
maxInset.copyTo(getDividerInset());
isExpanded = true;
isCollapsed = false;
}
px = getAutoInset().getAbsolutePixels(divider);
if (px < 0) {
// Make sure that the divider is fully visible
getDividerInset().translatePixels(px, true, divider.getParent());
isExpanded = true;
isCollapsed = false;
}
}
use of com.codename1.ui.layouts.LayeredLayout.LayeredLayoutConstraint.Inset in project CodenameOne by codenameone.
the class LayeredLayout method layoutComponent.
/**
* Lays out the specific component within the container. This will first lay out any components that it depends on.
* @param parent The parent container being laid out.
* @param cmp The component being laid out.
* @param top
* @param left
* @param bottom
* @param right
*/
private void layoutComponent(Container parent, Component cmp, int top, int left, int bottom, int right) {
if (tmpLaidOut.contains(cmp)) {
return;
}
tmpLaidOut.add(cmp);
LayeredLayoutConstraint constraint = (LayeredLayoutConstraint) getComponentConstraint(cmp);
if (constraint != null) {
constraint.fixDependencies(parent);
for (LayeredLayoutConstraint.Inset inset : constraint.insets) {
if (inset.referenceComponent != null && inset.referenceComponent.getParent() == parent) {
layoutComponent(parent, inset.referenceComponent, top, left, bottom, right);
}
}
}
Style s = cmp.getStyle();
if (constraint != null) {
// int innerTop = top;
// int innerBottom = bottom;
// left = 0;
// right = parent.getLayoutWidth();
int leftInset = constraint.insets[Component.LEFT].calculate(cmp, top, left, bottom, right);
int rightInset = constraint.insets[Component.RIGHT].calculate(cmp, top, left, bottom, right);
int topInset = constraint.insets[Component.TOP].calculate(cmp, top, left, bottom, right);
int bottomInset = constraint.insets[Component.BOTTOM].calculate(cmp, top, left, bottom, right);
cmp.setX(left + leftInset + s.getMarginLeft(parent.isRTL()));
cmp.setY(top + topInset + s.getMarginTop());
cmp.setWidth(Math.max(0, right - cmp.getX() - s.getMarginRight(parent.isRTL()) - rightInset));
// cmp.setWidth(Math.max(0, right - left - s.getHorizontalMargins() - rightInset - leftInset));
// cmp.setHeight(Math.max(0, bottom - top - s.getVerticalMargins() - bottomInset - topInset));
cmp.setHeight(Math.max(0, bottom - cmp.getY() - s.getMarginBottom() - bottomInset));
} else {
int x = left + s.getMarginLeft(parent.isRTL());
int y = top + s.getMarginTop();
int w = right - left - s.getHorizontalMargins();
int h = bottom - top - s.getVerticalMargins();
cmp.setX(x);
cmp.setY(y);
cmp.setWidth(Math.max(0, w));
cmp.setHeight(Math.max(0, h));
// System.out.println("Component laid out "+cmp);
}
}
use of com.codename1.ui.layouts.LayeredLayout.LayeredLayoutConstraint.Inset in project CodenameOne by codenameone.
the class SplitPane method initDividerInset.
private LayeredLayoutConstraint initDividerInset(LayeredLayoutConstraint cnst, String insetVal) {
getFixedInset(cnst).setValueAsString(insetVal);
getAutoInset(cnst).setValueAsString("auto");
for (Inset i : getZeroInsets(cnst)) {
i.setValueAsString("0");
}
return cnst;
}
use of com.codename1.ui.layouts.LayeredLayout.LayeredLayoutConstraint.Inset in project CodenameOne by codenameone.
the class LayeredLayout method calcPreferredValues.
private void calcPreferredValues(Component cmp) {
if (tmpLaidOut.contains(cmp)) {
return;
}
tmpLaidOut.add(cmp);
LayeredLayoutConstraint constraint = (LayeredLayoutConstraint) getComponentConstraint(cmp);
if (constraint != null) {
constraint.fixDependencies(cmp.getParent());
for (LayeredLayoutConstraint.Inset inset : constraint.insets) {
if (inset.referenceComponent != null && inset.referenceComponent.getParent() == cmp.getParent()) {
calcPreferredValues(inset.referenceComponent);
}
inset.calcPreferredValue(cmp.getParent(), cmp);
}
}
}
Aggregations