Warning: session_start(): open(/var/lib/php/sessions/sess_cbip6b4dcbg5vpqaemtpbs4ui9, 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 = new(r {
revisualize2();
sleepSeconds(1);
});
bool shouldBeVertical() {
Rect r = dm_getBounds();
ret r != null && r.h > r.w*0.3;
}
JComponent visualize2() {
L buttons = makeButtons();
JLabel lblInvisible = onLeftClick(jLiveValueLabel(lvInvisible), r dm_showInvisibleModulesList);
if (vertical == null) vertical = shouldBeVertical();
ret vertical
? jscroll_dynamicvstack(dynamicVStack2(listPlusInBeginning(
(L) (L) buttons, withMargin(6, lblInvisible))))
: centerAndEast(hgrid(buttons), withLeftAndRightMargin(6, 3, lblInvisible));
}
enhanceFrame {
addTitlePopupMenuItems(f,
"Place on bottom", rThread placeOnBottom,
"Place on the right", rThread placeOnRight);
onResize(f, r {
if (vertical != shouldBeVertical()) {
vertical = shouldBeVertical();
print("Revisualizing task bar");
revisualize2();
}
});
}
void placeOnBottom {
if (!isFalse(vertical)) { vertical = false; revisualize2_impl(); }
Container frame = dm_frame();
Rectangle desktop = getBounds(dm_desktopPane());
if (frame != null && desktop != null) {
print("Packing frame");
packInternalFrameVertically_noFix((JInternalFrame) frame);
Rectangle me = getBounds(frame);
DynModule mod = dm_current();
dm_setBounds(mod, 0, desktop.height-me.height,
desktop.width, me.height);
}
}
void placeOnRight {
Rectangle desktop = getBounds(dm_desktopPane());
if (desktop != null) {
int w = min(desktop.width/4, 300);
dm_setBounds(dm_current(), desktop.width-w, 0, w, desktop.height);
}
}
void update { rst.trigger(); }
// TODO: make less often
L makeButtons() {
new L out;
new L invisible;
L modules = dm_listModules();
// TODO: get module names all at once
for (fO m : modules)
if (m != this)
if (dm_isVisible(m)) {
final WeakReference ref = new(m); // allow GC for modules
out.add(jbutton(dm_moduleName(m), r { dm_showModule(ref!) }));
} else invisible.add(m);
lvInvisible.set(empty(invisible) ? "" : "+ " + l(invisible) + " invisible");
ret out;
}
}