Libraryless. Compilation Failed (12727L/78K).
1 | // params = text, image, action, text, image, action, ... |
2 | // or TextImageAction... |
3 | // or a list of above stuff |
4 | static <A extends DynamicStack> A makeNiceButtons_usingStack(A stack, O... params) { |
5 | params = flattenArray2(params); |
6 | for (int i = 0; i < l(params); ) { |
7 | TextImageAction tia = null; |
8 | if (params[i] instanceof TextImageAction) { |
9 | tia = (TextImageAction) params[i]; |
10 | i++; |
11 | } else { |
12 | tia = TextImageAction( |
13 | str(get(params, i)), |
14 | str(get(params, i+1)), |
15 | get(params, i+2)); |
16 | i += 3; |
17 | } |
18 | |
19 | final TextImageAction _tia = tia; |
20 | O action = tia.action; |
21 | fS buttonDesc = action == null |
22 | ? "actionless button " + sfu(_tia) |
23 | : "button " + sfu(cloneWithoutField(_tia, 'action)) |
24 | + " with action " + trim(simpleSpaces(newLinesToSpaces(shorten(str(tia.action), 40)))); |
25 | action = r { |
26 | appendToLocalMechLog("User actions", "User clicked on " + buttonDesc); |
27 | callF(_tia.action); |
28 | }; |
29 | JButton b = jImageAndTextButton(tia.imageID, tia.text, action); |
30 | if (nempty(tia.toolTip)) setToolTip(b, tia.toolTip); |
31 | componentPopupMenu(b, tia.popupMenuMaker); |
32 | resizeImageButtonToMax(b, niceButtons_maxImageSize()); |
33 | setVerticalTextPosition(JButton.TOP, setFontSize(15, makeBold(b))); |
34 | setVerticalAlignment(JButton.TOP, b); |
35 | setMargin(10, b); |
36 | |
37 | onMouseEnter(b, r { |
38 | appendToLocalMechLog("Mouse hovers", "Mouse hovered over " + buttonDesc) |
39 | }); |
40 | onMouseExit(b, r { |
41 | appendToLocalMechLog("Mouse hovers", "Mouse no longer hovers over " + buttonDesc) |
42 | }); |
43 | |
44 | metaSet(b, TextImageAction.class, tia); |
45 | stack.addComponent(b); |
46 | } |
47 | |
48 | ret stack; |
49 | } |
50 | |
51 | static DynamicHStack makeNiceButtons(O... params) { |
52 | ret makeNiceButtons_usingStack((DynamicHStack) dynamicHStack().spacing(20), params); |
53 | } |
Began life as a copy of #1015039
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: | #1015090 |
Snippet name: | makeNiceButtons |
Eternal ID of this version: | #1015090/23 |
Text MD5: | f3ee986c87471f0c0435c018f4b6a4aa |
Transpilation MD5: | 42bfacbaec4980b63f557b8c662f15f9 |
Author: | stefan |
Category: | javax / a.i. / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-02-12 22:08:38 |
Source code size: | 1868 bytes / 53 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 503 / 597 |
Version history: | 22 change(s) |
Referenced in: | [show references] |