Transpiled version (3091L) is out of date.
1 | static int formLayouter1b_yPlus = 0; // make higher (bug fixing) |
2 | static int formLayouter1b_fixer2 = 0; |
3 | |
4 | static F1<Container, Pair<Dimension>> formLayouter1b() { |
5 | final int yplus = formLayouter1b_yPlus, fixer2 = formLayouter1b_fixer2; |
6 | ret func(Container parent) -> Pair<Dimension> { |
7 | L<Component> l = getComponents(parent); |
8 | new BitSet bigOnes; |
9 | for i over l: |
10 | if (containsATextArea(l.get(i))) add(bigOnes, i); |
11 | |
12 | int nBigOnes = bigOnes.cardinality(); |
13 | int mandatoryHeight = totalPreferredHeight(listWithoutIndicesInBitSet(l, bigOnes)); |
14 | int gap = 4, outerSpacing = 5; |
15 | Dimension size = parent.getSize(); |
16 | int gapsAndMargins = outerSpacing*2-(l(l)-1)*gap; |
17 | int totalSpace = size.height-gapsAndMargins-fixer2; |
18 | int liberalSpace = totalSpace-mandatoryHeight; |
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, size.width-outerSpacing*2, iround(y+h)-actualY); |
27 | y += h+gap; |
28 | } |
29 | |
30 | // return preferred size |
31 | Dimension pref = componentsBoundingSize(parent, outerSpacing); |
32 | ifdef formLayouter1_debug |
33 | printVars_str formLayouter1b(+pref, parentHeight := parent.getHeight()); |
34 | endifdef |
35 | if (parent.getHeight() <= 0) { // pre-showing - maybe we should always do this |
36 | int tph = totalPreferredHeight(l); |
37 | pref.height = tph/*+gapsAndMargins*/-outerSpacing*2; |
38 | ifdef formLayouter1_debug |
39 | printVars_str formLayouter1b(+pref, +tph, +gapsAndMargins, +yplus); |
40 | endifdef |
41 | } |
42 | |
43 | int tmh = totalMinimumHeight(l); |
44 | Dimension min = new(100, tmh/*+gapsAndMargins*/-outerSpacing*2); |
45 | ifdef formLayouter1_debug |
46 | printVars_str formLayouter1b(+tmh, +gapsAndMargins, +yplus, +min); |
47 | endifdef |
48 | |
49 | ret pair(pref, min); |
50 | }; |
51 | } |
Began life as a copy of #1014730
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030808 |
Snippet name: | formLayouter1b - also returns minimum size |
Eternal ID of this version: | #1030808/6 |
Text MD5: | d9c82b322253fd0a3c1b0f841f23180f |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-03-29 14:06:35 |
Source code size: | 2020 bytes / 51 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 183 / 277 |
Version history: | 5 change(s) |
Referenced in: | [show references] |