Search in sources :

Example 1 with ContainerWrapper

use of com.codename1.ui.layouts.mig.ContainerWrapper in project CodenameOne by codenameone.

the class MigLayout method checkCache.

/**
 * Check if something has changed and if so recreate it to the cached
 * objects.
 *
 * @param parent The parent that is the target for this layout manager.
 */
private void checkCache(Container parent) {
    if (parent == null) {
        return;
    }
    if (dirty) {
        grid = null;
    }
    cleanConstraintMaps(parent);
    // Check if the grid is valid
    int mc = PlatformDefaults.getModCount();
    if (lastModCount != mc) {
        grid = null;
        lastModCount = mc;
    }
    // if (!parent.isValid()) {
    if (!lastWasInvalid) {
        lastWasInvalid = true;
        int hash = 0;
        // Added in 3.7.3 to resolve a timing regression introduced in 3.7.1
        boolean resetLastInvalidOnParent = false;
        for (ComponentWrapper wrapper : ccMap.keySet()) {
            Object component = wrapper.getComponent();
            if (component instanceof TextArea) {
                resetLastInvalidOnParent = true;
            }
            hash ^= wrapper.getLayoutHashCode();
            hash += 285134905;
        }
        if (resetLastInvalidOnParent) {
            resetLastInvalidOnParent(parent);
        }
        if (hash != lastHash) {
            grid = null;
            lastHash = hash;
        }
        Dimension ps = new Dimension(parent.getWidth(), parent.getHeight());
        if (lastInvalidSize == null || !lastInvalidSize.equals(ps)) {
            grid = null;
            lastInvalidSize = ps;
        }
    }
    /*} else {
         lastWasInvalid = false;
         }*/
    ContainerWrapper par = checkParent(parent);
    setDebug(par, getDebugMillis() > 0);
    if (grid == null) {
        grid = new Grid(par, lc, rowSpecs, colSpecs, ccMap, callbackList);
    }
    dirty = false;
}
Also used : TextArea(com.codename1.ui.TextArea) Grid(com.codename1.ui.layouts.mig.Grid) Dimension(com.codename1.ui.geom.Dimension) ContainerWrapper(com.codename1.ui.layouts.mig.ContainerWrapper) ComponentWrapper(com.codename1.ui.layouts.mig.ComponentWrapper)

Example 2 with ContainerWrapper

use of com.codename1.ui.layouts.mig.ContainerWrapper in project CodenameOne by codenameone.

the class MigLayout method layoutContainer.

public void layoutContainer(final Container parent) {
    checkCache(parent);
    Style i = parent.getStyle();
    int[] b = new int[] { i.getMarginLeftNoRTL(), i.getMarginTop(), parent.getWidth() - i.getHorizontalMargins(), parent.getHeight() - i.getVerticalMargins() };
    if (grid.layout(b, lc.getAlignX(), lc.getAlignY(), getDebug())) {
        grid = null;
        checkCache(parent);
        grid.layout(b, lc.getAlignX(), lc.getAlignY(), getDebug());
    }
    /*long newSize = grid.getHeight()[1] + (((long) grid.getWidth()[1]) << 32);
         if (lastSize != newSize) {
         lastSize = newSize;
         final ContainerWrapper containerWrapper = checkParent(parent);
         Window win = ((Window) SwingUtilities.getAncestorOfClass(Window.class, (Component)containerWrapper.getComponent()));
         if (win != null) {
         if (win.isVisible()) {
         SwingUtilities.invokeLater(new Runnable() {
         public void run() {
         adjustWindowSize(containerWrapper);
         }
         });
         } else {
         adjustWindowSize(containerWrapper);
         }
         }
         }*/
    lastInvalidSize = null;
}
Also used : Style(com.codename1.ui.plaf.Style)

Example 3 with ContainerWrapper

use of com.codename1.ui.layouts.mig.ContainerWrapper in project CodenameOne by codenameone.

the class MigLayout method constrain.

private int constrain(ContainerWrapper parent, int winSize, int prefSize, BoundSize constrain) {
    if (constrain == null) {
        return winSize;
    }
    int retSize = winSize;
    UnitValue wUV = constrain.getPreferred();
    if (wUV != null) {
        retSize = wUV.getPixels(prefSize, parent, parent);
    }
    retSize = constrain.constrain(retSize, prefSize, parent);
    return constrain.getGapPush() ? Math.max(winSize, retSize) : retSize;
}
Also used : UnitValue(com.codename1.ui.layouts.mig.UnitValue)

Aggregations

TextArea (com.codename1.ui.TextArea)1 Dimension (com.codename1.ui.geom.Dimension)1 ComponentWrapper (com.codename1.ui.layouts.mig.ComponentWrapper)1 ContainerWrapper (com.codename1.ui.layouts.mig.ContainerWrapper)1 Grid (com.codename1.ui.layouts.mig.Grid)1 UnitValue (com.codename1.ui.layouts.mig.UnitValue)1 Style (com.codename1.ui.plaf.Style)1