From 977a59afb32553c0990a3964404652e9606428dc Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 29 Mar 2025 18:13:21 +1100 Subject: sidebar: allow seeking --- src/widgets/slider.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/slider.tsx b/src/widgets/slider.tsx index fb219bd..c047d5f 100644 --- a/src/widgets/slider.tsx +++ b/src/widgets/slider.tsx @@ -1,8 +1,14 @@ import { bind, type Binding } from "astal"; -import { Gtk } from "astal/gtk3"; +import { Gdk, Gtk, type Widget } from "astal/gtk3"; import type cairo from "cairo"; -export default ({ value }: { value: Binding }) => ( +export default ({ + value, + onChange, +}: { + value: Binding; + onChange?: (self: Widget.DrawingArea, value: number) => void; +}) => ( }) => ( 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()) + ); }} /> ); -- cgit v1.2.3-freya