Libraryless. Click here for Pure Java version (3079L/18K).
static int formLayouter1_yPlus = 5; // make higher (bug fixing) static int formLayouter1_fixer2 = 0; static F1<Container, Dimension> formLayouter1() { final int yplus = formLayouter1_yPlus, fixer2 = formLayouter1_fixer2; ret func(Container parent) -> Dimension { L<Component> l = getComponents(parent); new BitSet bigOnes; for i over l: if (containsATextArea(l.get(i))) add(bigOnes, i); int nBigOnes = bigOnes.cardinality(); int mandatoryHeight = totalPreferredHeight(listWithoutIndicesInBitSet(l, bigOnes)); int gap = 4, outerSpacing = 5; Dimension size = parent.getSize(); int gapsAndMargins = outerSpacing*2-(l(l)-1)*gap; int totalSpace = size.height-gapsAndMargins-fixer2; int liberalSpace = totalSpace-mandatoryHeight; double perBigOne = doubleRatio(liberalSpace, nBigOnes); double y = outerSpacing; for i over l: { Component c = l.get(i); bool big = contains(bigOnes, i); double h = big ? perBigOne : c.getPreferredSize().height; int actualY = iround(y); c.setBounds(10, actualY, size.width-outerSpacing*2, iround(y+h)-actualY); y += h+gap; } // return preferred size Dimension pref = componentsBoundingSize(parent, outerSpacing); ifdef formLayouter1_debug printVars_str formLayouter1(+pref, parentHeight := parent.getHeight()); endifdef if (parent.getHeight() <= 0) { // pre-showing - maybe we should always do this int tph = totalPreferredHeight(l); pref.height = tph+gapsAndMargins+yplus; ifdef formLayouter1_debug printVars_str formLayouter1(+pref, +tph, +gapsAndMargins, +yplus); endifdef } ret pref; }; }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment