diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-26 22:36:23 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-26 22:36:23 +1000 |
| commit | 3c579d0e275cdaf6f2c9589abade94bde7905c82 (patch) | |
| tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /src/widgets/slider.tsx | |
| parent | schemes: fix (diff) | |
| download | caelestia-shell-3c579d0e275cdaf6f2c9589abade94bde7905c82.tar.gz caelestia-shell-3c579d0e275cdaf6f2c9589abade94bde7905c82.tar.bz2 caelestia-shell-3c579d0e275cdaf6f2c9589abade94bde7905c82.zip | |
clean
Remove everything
Diffstat (limited to 'src/widgets/slider.tsx')
| -rw-r--r-- | src/widgets/slider.tsx | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/src/widgets/slider.tsx b/src/widgets/slider.tsx deleted file mode 100644 index 0a66609..0000000 --- a/src/widgets/slider.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { bind, type Binding } from "astal"; -import { Gdk, Gtk, type Widget } from "astal/gtk3"; -import type cairo from "cairo"; - -export default ({ - value, - onChange, -}: { - value: Binding<number>; - onChange?: (self: Widget.DrawingArea, value: number) => void; -}) => ( - <drawingarea - hexpand - valign={Gtk.Align.CENTER} - className="slider" - css={bind(value).as(v => `font-size: ${Math.min(1, Math.max(0, v))}px;`)} - setup={self => { - const halfPi = Math.PI / 2; - - const styleContext = self.get_style_context(); - self.set_size_request(-1, styleContext.get_property("min-height", Gtk.StateFlags.NORMAL) as number); - - self.connect("draw", (_, cr: cairo.Context) => { - const styleContext = self.get_style_context(); - - const width = self.get_allocated_width(); - const height = styleContext.get_property("min-height", Gtk.StateFlags.NORMAL) as number; - self.set_size_request(-1, height); - - const progressValue = styleContext.get_property("font-size", Gtk.StateFlags.NORMAL) as number; - let radius = styleContext.get_property("border-radius", Gtk.StateFlags.NORMAL) as number; - - const bg = styleContext.get_background_color(Gtk.StateFlags.NORMAL); - cr.setSourceRGBA(bg.red, bg.green, bg.blue, bg.alpha); - - // Background - cr.arc(radius, radius, radius, -Math.PI, -halfPi); // Top left - cr.arc(width - radius, radius, radius, -halfPi, 0); // Top right - cr.arc(width - radius, height - radius, radius, 0, halfPi); // Bottom right - cr.arc(radius, height - radius, radius, halfPi, Math.PI); // Bottom left - cr.fill(); - - // Flatten when near 0 - radius = Math.min(radius, Math.min(width * progressValue, height) / 2); - - const progressPosition = width * progressValue - radius; - const fg = styleContext.get_color(Gtk.StateFlags.NORMAL); - cr.setSourceRGBA(fg.red, fg.green, fg.blue, fg.alpha); - - // Foreground - cr.arc(radius, radius, radius, -Math.PI, -halfPi); // Top left - cr.arc(progressPosition, radius, radius, -halfPi, 0); // Top right - cr.arc(progressPosition, height - radius, radius, 0, halfPi); // Bottom right - cr.arc(radius, height - radius, radius, halfPi, Math.PI); // Bottom left - cr.fill(); - }); - - self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK); - self.connect("button-press-event", (_, event: Gdk.Event) => - onChange?.(self, event.get_coords()[1] / self.get_allocated_width()) - ); - }} - /> -); |