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

59
LINES

< > BotCompany Repo | #1034544 // CollapsibleLeftPanel - collapsible side panel

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (14626L/86K).

1  
sclass CollapsibleLeftPanel > MetaWithChangeListeners is Swingable {
2  
  settableWithVar volatile S sidePanelName;
3  
  JComponent sideComponent, mainComponent;
4  
  JSplitPane splitPane;
5  
  settableWithVar volatile bool expanded;
6  
  SingleComponentPanel scp = singleComponentPanel();
7  
  
8  
  *(bool *expanded, S *sidePanelName, JComponent *sideComponent, JComponent *mainComponent) {
9  
  }
10  
  
11  
  void expand {
12  
    if (scaffolding()) print("CollapsibleLeftPanel.expand");
13  
    setExpanded(true);
14  
  }
15  
  
16  
  void collapse { setExpanded(false); }
17  
  
18  
  scaffolded void updateScp() swing {
19  
    if (expanded) {
20  
      splitPane().setRightComponent(jMinWidth0(mainComponent));
21  
      scp.set(splitPane());
22  
    } else {
23  
      splitPane().setRightComponent(jMinWidth0(jpanel()));
24  
      scp.set(westAndCenterWithMargin(
25  
        sidePanelMargins(vstack(expandButton())), mainComponent));
26  
    }
27  
  }
28  
  
29  
  JComponent expandButton() {
30  
    ret jClickableImage_instantToolTip(#1103075, "Expand " + sidePanelName, r expand);
31  
  }
32  
  
33  
  JComponent collapseButton() {
34  
    ret jClickableImage_instantToolTip(#1103076, "Collapse " + sidePanelName, r collapse);
35  
  }
36  
  
37  
  JComponent wrappedSideComponent() {
38  
    ret sidePanelMargins(northAndCenterWithMargin(
39  
      westAndCenterWithMargin(collapseButton(), liveValueLabel(varSidePanelName())),
40  
      sideComponent
41  
    ));
42  
  }
43  
44  
  JSplitPane splitPane() {
45  
    if (scaffolding()) print("splitPane " + splitPane);
46  
    if (splitPane == null) {
47  
      splitPane = jhsplit_minZero(0.25, wrappedSideComponent(), null);
48  
      varExpanded().onChangeAndNow(r updateScp);
49  
    }
50  
    ret splitPane;
51  
  }
52  
  
53  
  swappable JComponent sidePanelMargins(JComponent c) { ret c; }
54  
  
55  
  visualize {
56  
    splitPane();
57  
    ret scp;
58  
  }
59  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034544
Snippet name: CollapsibleLeftPanel - collapsible side panel
Eternal ID of this version: #1034544/29
Text MD5: 8bc55321b692c6bd240f0f6d00a38011
Transpilation MD5: 5c3ab07febc1df6d8d7f109bd05eacfa
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-27 05:39:13
Source code size: 1770 bytes / 59 lines
Pitched / IR pitched: No / No
Views / Downloads: 227 / 417
Version history: 28 change(s)
Referenced in: [show references]