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

32
LINES

< > BotCompany Repo | #1021052 // formLayouter1_old1

JavaX fragment (include)

1  
static F1<Container, Dimension> formLayouter1_old1() {
2  
  ret func(Container parent) -> Dimension {
3  
    L<Component> l = getComponents(parent);
4  
    new BitSet bigOnes;
5  
    for i over l:
6  
      if (containsATextArea(l.get(i))) add(bigOnes, i);
7  
      
8  
    int nBigOnes = bigOnes.cardinality();
9  
    int mandatoryHeight = totalPreferredHeight(listWithoutIndicesInBitSet(l, bigOnes));
10  
    int gap = 4, outerSpacing = 5;
11  
    Dimension size = parent.getSize();
12  
    int gapsAndMargins = outerSpacing*2-(l(l)-1)*gap;
13  
    int totalSpace = size.height-gapsAndMargins;
14  
    int liberalSpace = totalSpace-mandatoryHeight;
15  
    double perBigOne = doubleRatio(liberalSpace, nBigOnes);
16  
    double y = outerSpacing;
17  
    for i over l: {
18  
      Component c = l.get(i);
19  
      bool big = contains(bigOnes, i);
20  
      double h = big ? perBigOne : c.getPreferredSize().height;
21  
      int actualY = iround(y);
22  
      c.setBounds(10, actualY, size.width-outerSpacing*2, iround(y+h)-actualY);
23  
      y += h+gap;
24  
    }
25  
    
26  
    // return preferred size
27  
    Dimension pref = componentsBoundingSize(parent, outerSpacing);
28  
    if (parent.getHeight() == 0) // pre-showing - maybe we should always do this
29  
      pref.height = totalPreferredHeight(l)+gapsAndMargins;
30  
    ret pref;
31  
  };
32  
}

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: 231 / 254
Referenced in: [show references]