added stuff

This commit is contained in:
Charlie Root 2024-04-09 23:11:33 +02:00
commit 9d0ebdfbd0
907 changed files with 70990 additions and 0 deletions

View file

@ -0,0 +1,58 @@
import { Widget, Utils } from "../../imports.js";
import Brightness from "../../services/brightness.js";
const { Box, Slider, Label, Revealer } = Widget;
const BrightnessIcon = () =>
Label({
className: "brtPopupIcon",
setup: (self) => {
self.hook(Brightness, (self) => {
const icons = ["", "", "", "", "", "", "", "", ""];
let index = Math.floor((Brightness.screen * 100) / 11);
index = Math.max(0, Math.min(index, icons.length - 1));
if (index >= 0 && index < icons.length) {
self.label = icons[index].toString();
} else {
log("Index out of bounds:", index);
}
});
},
});
const PercentBar = () =>
Slider({
className: "brtPopupBar",
drawValue: false,
onChange: ({ value }) => (Brightness.screen = value),
setup: (self) => {
self.hook(Brightness, (self) => (self.value = Brightness.screen));
},
});
export const BrightnessPopup = () =>
Box({
css: `min-height: 1px;
min-width: 1px;`,
child: Revealer({
transition: "slide_up",
child: Box({
className: "brightnessPopup",
children: [BrightnessIcon(), PercentBar()],
}),
attribute: { count: 0 },
setup: (self) => {
self.hook(Brightness, (self) => {
self.revealChild = true;
self.attribute.count++;
Utils.timeout(1500, () => {
self.attribute.count--;
if (self.attribute.count === 0)
self.revealChild = false;
});
});
},
}),
});

View file

@ -0,0 +1,18 @@
import { Widget } from "../../imports.js";
// Widgets
import { BrightnessPopup } from "./brightnessPopup.js";
import { VolumePopup } from "./volumePopup.js";
export const Popups = () =>
Widget.Window({
name: "popups",
className: "popups",
anchor: ["bottom", "right"],
layer: "overlay",
margins: [0, 12, 8, 0],
child: Widget.Box({
vertical: true,
children: [BrightnessPopup(), VolumePopup()],
}),
});

View file

@ -0,0 +1,36 @@
import { Widget, Utils, Audio } from "../../imports.js";
import { getSliderIcon, volumePercentBar } from "../../utils/audio.js";
const { Box, Revealer } = Widget;
const { speaker } = Audio;
const { timeout } = Utils;
export const VolumePopup = () =>
Box({
css: `
min-height: 2px;
min-width: 2px;
`,
child: Revealer({
transition: "slide_up",
child: Box({
className: "volumePopup",
children: [getSliderIcon(), volumePercentBar()],
}),
attribute: { count: 0 },
setup: (self) =>
self.hook(
speaker,
() => {
self.reveal_child = true;
self.attribute.count++;
timeout(1500, () => {
self.attribute.count--;
if (self.attribute.count === 0)
self.reveal_child = false;
});
},
"notify::volume",
),
}),
});