Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

32
LINES

< > BotCompany Repo | #1021052 // formLayouter1_old1

JavaX fragment (include)

static F1<Container, Dimension> formLayouter1_old1() {
  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;
    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);
    if (parent.getHeight() == 0) // pre-showing - maybe we should always do this
      pref.height = totalPreferredHeight(l)+gapsAndMargins;
    ret pref;
  };
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021052
Snippet name: formLayouter1_old1
Eternal ID of this version: #1021052/1
Text MD5: 01feeafeed48a7da7ae0a30746865ed0
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-19 22:21:57
Source code size: 1276 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 305 / 315
Referenced in: [show references]