sidebar: allow seeking
This commit is contained in:
parent
611b6c046e
commit
977a59afb3
4 changed files with 15 additions and 5 deletions
|
|
@ -108,7 +108,7 @@ const Media = ({ player }: { player: AstalMpris.Player | null }) => {
|
|||
label=""
|
||||
/>
|
||||
</box>
|
||||
<Slider value={bind(position)} />
|
||||
<Slider value={bind(position)} onChange={(_, v) => player?.set_position(v * player.length)} />
|
||||
<box className="time">
|
||||
<label label={player ? bind(player, "position").as(lengthStr) : "-1:-1"} />
|
||||
<box hexpand />
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ const Player = ({ player }: { player: AstalMpris.Player }) => {
|
|||
{bind(player, "coverArt").as(a => (a ? <box visible={false} /> : <label xalign={0.4} label="" />))}
|
||||
</box>
|
||||
<box vertical className="progress">
|
||||
<Slider value={bind(position)} />
|
||||
<Slider value={bind(position)} onChange={(_, v) => player.set_position(v * player.length)} />
|
||||
<box className="time">
|
||||
<label label={bind(player, "position").as(lengthStr)} />
|
||||
<box hexpand />
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ const Stream = ({ stream, playing }: IStream) => (
|
|||
showFillLevel
|
||||
restrictToFillLevel={false}
|
||||
fillLevel={2 / 3}
|
||||
cursor="pointer"
|
||||
value={bind(stream, "volume").as(v => v * (2 / 3))}
|
||||
setup={self => self.connect("value-changed", () => stream.set_volume(self.value * 1.5))}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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<number> }) => (
|
||||
export default ({
|
||||
value,
|
||||
onChange,
|
||||
}: {
|
||||
value: Binding<number>;
|
||||
onChange?: (self: Widget.DrawingArea, value: number) => void;
|
||||
}) => (
|
||||
<drawingarea
|
||||
hexpand
|
||||
valign={Gtk.Align.CENTER}
|
||||
|
|
@ -48,6 +54,11 @@ export default ({ value }: { value: Binding<number> }) => (
|
|||
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())
|
||||
);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue