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

23
LINES

< > BotCompany Repo | #1016079 // formLayouter_rightAligned - splits available width among text areas

JavaX fragment (include)

static F1<Container, Dimension> formLayouter_rightAligned() {
  ret func(Container parent) -> Dimension {
    L<Component> l = getComponents(parent);
    BitSet bitOnes = layouting_bigOnes(l);
    int nBigOnes = bigOnes.cardinality();
    int mandatoryWidth = totalPreferredWidth(listWithoutIndicesInBitSet(l, bigOnes));
    int gap = 4, outerSpacing = 5;
    Dimension size = parent.getSize();
    int totalSpace = size.width-outerSpacing*2-(l(l)-1)*gap;
    int liberalSpace = totalSpace-mandatoryWidth;
    double perBigOne = doubleRatio(liberalSpace, nBigOnes);
    double x = nBigOnes == 0 ? size.width-outerSpacing-mandatoryWidth : outerSpacing;
    for i over l: {
      Component c = l.get(i);
      bool big = contains(bigOnes, i);
      double w = big ? perBigOne : c.getPreferredSize().width;
      int actualX = iround(x);
      c.setBounds(actualX, 10, iround(x+w)-actualX, size.height-outerSpacing*2);
      x += w+gap;
    }
    ret componentsBoundingSize(parent, outerSpacing);
  };
}

Author comment

Began life as a copy of #1014730

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

Snippet ID: #1016079
Snippet name: formLayouter_rightAligned - splits available width among text areas
Eternal ID of this version: #1016079/1
Text MD5: 9b555f7f5fcd6814f0a4795c2cb6e6a7
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-05 17:53:28
Source code size: 1022 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 366 / 410
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)