Libraryless. Click here for Pure Java version (6068L/42K).
!7 sclass TaskBar extends DynSCP { transient SimpleLiveValue<S> lvInvisible = stringLiveValue(); transient Bool vertical; transient ReliableSingleThread rst = dm_rstWithPostDelay(this, 1.0, r revisualize2); transient L<L> status; transient L<JButton> buttons; bool sortByName = true; start { if (dm_getBounds() == null) placeOnRight(); //DynSCP.verbose = true; ownResource(vmBus_onMessages(vmBus_modulesListChangeMessages(), rst)); } bool shouldBeVertical() { Rect r = dm_getBounds(); ret r != null && r.h > r.w*0.3; } JComponent visualize2() { temp enter(); if (vertical == null) vertical = shouldBeVertical(); time "makeButtons" { bool mb = makeButtons(); } if (!mb && getComponent() != null) ret getComponent(); JLabel lblInvisible = onLeftClick(jLiveValueLabel(lvInvisible), r dm_showInvisibleModulesList); ret vertical ? jscroll_dynamicvstack(withRightMargin(6, dynamicVStack2(listPlusInBeginning( (L<JComponent>) (L) buttons, withMargin(6, lblInvisible))))) : centerAndEast(hgrid(buttons), withLeftAndRightMargin(6, 3, lblInvisible)); } void enhanceFrame(final Container f) { super.enhanceFrame(f); addTitlePopupMenuItems(f, "Place on bottom", rThread placeOnBottom, "Place on the right", rThread placeOnRight); onResize(f, r { //print("onResize " + jGetSize(f)); if (vertical == shouldBeVertical()) ret; vertical = shouldBeVertical(); revisualize2(); }); } void placeOnBottom { temp enter(); if (!isFalse(vertical)) { vertical = false; revisualize2_impl(); } // for height calculation dm_placeOnBottom(); } void placeOnRight { temp enter(); dm_placeOnRight(); } void update { /*printStackTrace();*/ rst.trigger(); } // returns true if change bool makeButtons() { Pair<L> p = dm_visibleAndInvisibleModules(); LS namesVis = map dm_moduleName(p.a); final Map<O, S> namesMap = zipTwoListsToMap(p.a, namesVis); L vis = p.a; if (sortByName) { vis = sortedByMapLookupCI(vis, namesMap); //print("Sorted by map: " + namesMap); } LS namesInvis = map dm_moduleName(p.b); L status = ll(vertical, map dm_moduleID(vis), map dm_moduleID(p.b), map(vis, func(O mod) -> S { namesMap.get(mod) }), l(namesInvis)); if (eq(status, this.status)) false; this.status = status; print("Task bar: Making new buttons"); new L<JButton> out; L modules = dm_listModules(); L<Pair<S, VF1<O>>> moduleItems = dm_moduleMenuItems(); for (int i = 0; i < l(vis); i++) if (vis.get(i) != this) { final WeakReference ref = new(vis.get(i)); // allow GC for modules JButton btn = jbutton(namesMap.get(vis.get(i)), r { dm_showModule(ref!) }); for (final Pair<S, VF1<O>> p2 : moduleItems) componentPopupMenuItem(btn, p2.a, rThread { O mod = ref!; if (mod != null) callF(p2.b, ref!) }); out.add(btn); } lvInvisible.set(empty(p.b) ? "" : "+ " + l(p.b) + " invisible"); buttons = out; true; } }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018410 |
Snippet name: | Task Bar v2 [Dyn Module] |
Eternal ID of this version: | #1018410/34 |
Text MD5: | 23d383ab0cda53250faaa8466a35b9f2 |
Transpilation MD5: | 3635e78ca5d2452258ea7ef4e3bde648 |
Author: | stefan |
Category: | |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-28 13:57:03 |
Source code size: | 3196 bytes / 91 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 419 / 4358 |
Version history: | 33 change(s) |
Referenced in: | #1019051 - Linux Task Bar [Dyn Module] #1019172 - Task Bar [vertical only, faster than #1018410] #1019712 - Vertical Task Bar As List [faster than #1018410, older version] |