Search in sources :

Example 1 with GreedyDimensionValue

use of limelight.styles.values.GreedyDimensionValue in project limelight by slagyr.

the class PropPanelLayout method snapToSize.

public void snapToSize(PropPanel panel) {
    if (// can happen if removed from tree
    panel.getParent() == null)
        return;
    Box maxArea = panel.getParent().getChildConsumableBounds();
    Style style = panel.getStyle();
    if (style.getCompiledWidth() instanceof AutoDimensionValue && style.getCompiledHeight() instanceof GreedyDimensionValue)
        throw new LimelightException("A greedy height is not allowed with auto width.");
    int newWidth = style.getCompiledWidth().calculateDimension(maxArea.width, style.getCompiledMinWidth(), style.getCompiledMaxWidth(), panel.greediness.width);
    int newHeight = style.getCompiledHeight().calculateDimension(maxArea.height, style.getCompiledMinHeight(), style.getCompiledMaxHeight(), panel.greediness.height);
    // TODO MDM - Hacky Hack!!!!  More thought needs to go into the way layouts are down and how greedy fits into it all
    //    if(topLevel && style.getCompiledWidth() instanceof GreedyDimensionValue && panel.getWidth() > newWidth)
    //      newWidth = panel.getWidth();
    //    if(topLevel && style.getCompiledHeight() instanceof GreedyDimensionValue && panel.getHeight() > newHeight)
    //      newHeight = panel.getHeight();
    panel.setSize(newWidth, newHeight);
    panel.resetPendingSizeChange();
}
Also used : Style(limelight.styles.Style) Box(limelight.util.Box) AutoDimensionValue(limelight.styles.values.AutoDimensionValue) GreedyDimensionValue(limelight.styles.values.GreedyDimensionValue) LimelightException(limelight.LimelightException)

Aggregations

LimelightException (limelight.LimelightException)1 Style (limelight.styles.Style)1 AutoDimensionValue (limelight.styles.values.AutoDimensionValue)1 GreedyDimensionValue (limelight.styles.values.GreedyDimensionValue)1 Box (limelight.util.Box)1