1 | static F1<Container, Dimension> formLayouter2(O... _) { |
2 | int yplus = optPar yPlus(_, 5); // make higher (bug fixing) |
3 | int fixer2 = optPar fixer2(_, 0); |
4 | int rightMargin = optPar rightMargin(_, 10); |
5 | ret func(Container parent) -> Dimension { |
6 | L<Component> l = getComponents(parent); |
7 | new BitSet bigOnes; |
8 | for i over l: |
9 | if (containsATextArea(l.get(i))) add(bigOnes, i); |
10 | |
11 | int nBigOnes = bigOnes.cardinality(); |
12 | int mandatoryHeight = totalPreferredHeight(listWithoutIndicesInBitSet(l, bigOnes)); |
13 | int gap = 4, outerSpacing = 5; |
14 | Dimension size = parent.getSize(); |
15 | int gapsAndMargins = outerSpacing*2-(l(l)-1)*gap; |
16 | int totalSpace = size.height-gapsAndMargins-fixer2; |
17 | int liberalSpace = totalSpace-mandatoryHeight; |
18 | int width = size.width-outerSpacing*2-rightMargin; |
19 | double perBigOne = doubleRatio(liberalSpace, nBigOnes); |
20 | double y = outerSpacing; |
21 | for i over l: { |
22 | Component c = l.get(i); |
23 | bool big = contains(bigOnes, i); |
24 | double h = big ? perBigOne : c.getPreferredSize().height; |
25 | int actualY = iround(y); |
26 | c.setBounds(10, actualY, width, iround(y+h)-actualY); |
27 | y += h+gap; |
28 | } |
29 | |
30 | // return preferred size |
31 | Dimension pref = componentsBoundingSize(parent, outerSpacing); |
32 | if (parent.getHeight() == 0) // pre-showing - maybe we should always do this |
33 | pref.height = totalPreferredHeight(l)+gapsAndMargins+yplus; |
34 | ret pref; |
35 | }; |
36 | } |
Began life as a copy of #1014730
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1022754 |
Snippet name: | formLayouter2 - splits available height among text areas |
Eternal ID of this version: | #1022754/1 |
Text MD5: | 59451f429672e9eef8e46d130b87fa8d |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-04-06 13:33:01 |
Source code size: | 1474 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 274 / 305 |
Referenced in: | [show references] |