Libraryless. Click here for Pure Java version (24463L/158K).
// TODO: this "nice buttons" logic is pretty horrific transient sclass JGallery extends MetaWithChangeListeners is Swingable { settableWithVar L<File> files; gettable File selectedFile; settable bool horizontal = true; event adaptingButton(JButton button, File file); simplyCached DynamicStack buttons() { ret horizontal ? makeNiceButtons() : verticalNiceButtons(); } simplyCached ButtonImageLoader imageLoader() { ret new ButtonImageLoader(buttons()); } void setImageFiles(Cl<File> filesCollection) swing { var files = asList(filesCollection); if (eq(this.files, files)) ret; setFiles(files); //printVars("JGallery.setImageFiles", n2(files)); L<TextImageAction> l = filesForNiceButtons(files, lambda1 openImage); replaceNiceButtons(buttons(), l); for (btn, file : unpair zip(allButtons(buttons()), files)) adaptingButton(btn, file); File selectedFile = selectedFile(); selectFile(selectedFile); imageLoader().update(); } void selectFile(File file) swing { selectedFile = file; int idx = indexOf(files, file); for (int i, JButton btn : unpair iterateWithIndex(allButtons(buttons()))) { bool selected = i == idx; setSelected(btn, selected); if (selected) { print("Selected button: " + btn); scrollIntoView(btn); } } } cachedVisual jHigherScrollPane(jfullcenter(buttons())); swappable void openImage(File f) { showImage(f); } }
Began life as a copy of #1019109
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033910 |
Snippet name: | JGallery - should rewrite |
Eternal ID of this version: | #1033910/32 |
Text MD5: | 3a0d45ff6be06d17a146207817b90fa0 |
Transpilation MD5: | 20eb460fbefa996ef85c6a7acd6ae41a |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-16 21:19:39 |
Source code size: | 1540 bytes / 49 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 216 / 453 |
Version history: | 31 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |