Warning: session_start(): open(/var/lib/php/sessions/sess_gmfsri85dnusph43d520cj8bm1, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
sclass TaskBar extends DynSCP {
transient SimpleLiveValue lvInvisible = stringLiveValue();
transient Bool vertical;
transient ReliableSingleThread rst = dm_rstWithPostDelay(this, 1.0, r revisualize2);
transient L status;
transient L buttons;
bool sortByName = true;
start {
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();
if (!makeButtons() && getComponent() != null) ret getComponent();
JLabel lblInvisible = onLeftClick(jLiveValueLabel(lvInvisible), r dm_showInvisibleModulesList);
ret vertical
? jscroll_dynamicvstack(withRightMargin(6, dynamicVStack2(listPlusInBeginning(
(L) (L) buttons, withMargin(6, lblInvisible)))))
: centerAndEast(hgrid(buttons), withLeftAndRightMargin(6, 3, lblInvisible));
}
void enhanceFrame(Container f) {
super.enhanceFrame(f);
addTitlePopupMenuItems((RootPaneContainer) f,
"Place on bottom", rThread placeOnBottom,
"Place on the right", rThread placeOnRight);
onResize(f, r {
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 { rst.trigger(); }
// returns true if change
bool makeButtons() {
print('makeButtons);
Pair p = dm_visibleAndInvisibleModules();
LS namesVis = map dm_moduleName(p.a);
final Map 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 out;
L modules = dm_listModules();
L>> 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> 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;
}
}