me

/

vendetta Public
17 commits 0 issues 0 pull requests 1 contributor Discussions Projects Snippets LOC history Platform CI

adding skip to double-clicked items

diviocity committed last Nov 7 · 18961e95223a6030fd007472d4b38a498fd1ed14 View patch
Unverified signature 2 files changed +26 -3
build.vsh +1 -1

@@ -1,5 +1,5 @@

11#!/usr/bin/env -S v run

2-import imp

2+import x.imp

33

44// one architecture per build: vab links every ABI against the same -L path, and

55// lld stops at the first libmpv.so it finds (libvendetta/mpv/android/README.md)

src/player.v +25 -2

@@ -225,8 +225,12 @@ mut:

225225 queue_scroll f64

226226 queue_serial u64

227227 queue_frame ui2.Rect

228- theme Theme

229- theme_name string = default_theme_name

228+ // Double-click tracking for queue rows: a second click on the same row

229+ // within a short window plays that entry instead of just selecting it.

230+ queue_last_click_key string

231+ queue_last_click_t i64

232+ theme Theme

233+ theme_name string = default_theme_name

230234 // The theme editor panel: the theme the edits start from, the fields'

231235 // texts, and each colour row's chooser.

232236 theme_editor_open bool

@@ -710,6 +714,8 @@ fn (mut p Player) queue_reset_keys() {

710714 p.queue_keys = []string{cap: p.queue.len}

711715 p.queue_state = ui2.ReorderState{}

712716 p.queue_scroll = 0

717+ p.queue_last_click_key = ''

718+ p.queue_last_click_t = 0

713719 for _ in 0 .. p.queue.len {

714720 p.queue_keys << p.queue_new_key()

715721 }

@@ -727,6 +733,23 @@ fn (p &Player) queue_index(key string) int {

727733fn (mut p Player) queue_apply_step(step ui2.ReorderStep) {

728734 p.queue_state = step.state

729735 if !step.moved {

736+ // A click that lands and stays put is a selection, not a reorder. Two

737+ // of them on the same row within a short window play that entry, so a

738+ // row can be jumped to without hunting next/previous.

739+ if step.clicked != '' {

740+ now := time.ticks()

741+ if step.clicked == p.queue_last_click_key && now - p.queue_last_click_t <= 500 {

742+ index := p.queue_index(step.clicked)

743+ if index >= 0 && p.render_ctx != unsafe { nil } {

744+ mpv.command_async(p.mpv_ctx, u64(87), ['playlist-play-index', '${index}'])

745+ }

746+ p.queue_last_click_key = ''

747+ p.queue_last_click_t = 0

748+ } else {

749+ p.queue_last_click_key = step.clicked

750+ p.queue_last_click_t = now

751+ }

752+ }

730753 return

731754 }

732755 p.queue = ui2.reorder_move(p.queue, step.from, step.to)