Skip to content

Commit 3f4ea4b

Browse files
authored
feat: add force_seek_tooltip option
force show seedkbar tooltip (ie: thumbnail) on mouse drag, even if not hovering seekbar, while holding down mouse button
1 parent b38043d commit 3f4ea4b

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

modernz.lua

+18-12
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ local user_opts = {
3939
bottomhover_zone = 130, -- height of hover zone for bottomhover (in pixels)
4040
osc_on_seek = false, -- show OSC when seeking
4141
mouse_seek_pause = true, -- pause video while seeking with mouse move (on button hold)
42+
force_seek_tooltip = false, -- force show seedkbar tooltip on mouse drag, even if not hovering seekbar
4243

4344
vidscale = "auto", -- scale osc with the video
4445
scalewindowed = 1.0, -- osc scale factor when windowed
@@ -511,9 +512,8 @@ local state = {
511512
initialborder = mp.get_property("border"),
512513
playtime_hour_force_init = false, -- used to force request_init() once
513514
playtime_nohour_force_init = false, -- used to force request_init() once
514-
playingWhilstSeeking = false,
515-
playingWhilstSeekingWaitingForEnd = false,
516-
persistentprogresstoggle = user_opts.persistentprogress,
515+
playing_and_seeking = false,
516+
persistent_progress_toggle = user_opts.persistentprogress,
517517
original_subpos = mp.get_property_number("sub-pos") or 100,
518518
downloaded_once = false,
519519
downloading = false,
@@ -1139,7 +1139,13 @@ local function render_elements(master_ass)
11391139

11401140
-- add tooltip
11411141
if element.slider.tooltipF ~= nil and element.enabled then
1142-
if mouse_hit(element) then
1142+
local force_seek_tooltip = user_opts.force_seek_tooltip
1143+
and element.name == "seekbar"
1144+
and element.eventresponder["mbtn_left_down"]
1145+
and element.state.mbtnleft
1146+
and state.mouse_down_counter > 0
1147+
and state.playing_and_seeking
1148+
if mouse_hit(element) or force_seek_tooltip then
11431149
local sliderpos = get_slider_value(element)
11441150
local tooltiplabel = element.slider.tooltipF(sliderpos)
11451151
local an = slider_lo.tooltip_an
@@ -1703,7 +1709,7 @@ layouts["modern"] = function ()
17031709
lo.slider.tooltip_style = osc_styles.tooltip
17041710
lo.slider.tooltip_an = 2
17051711

1706-
if user_opts.persistentprogress or state.persistentprogresstoggle then
1712+
if user_opts.persistentprogress or state.persistent_progress_toggle then
17071713
lo = add_layout("persistentseekbar")
17081714
lo.geometry = {x = refX, y = refY, an = 5, w = osc_geo.w, h = user_opts.persistentprogressheight}
17091715
lo.style = osc_styles.seekbar_fg
@@ -2247,7 +2253,7 @@ local function osc_init()
22472253
ne.content = function ()
22482254
if mp.get_property("eof-reached") == "yes" then
22492255
return icons.replay
2250-
elseif mp.get_property("pause") == "yes" and not state.playingWhilstSeeking then
2256+
elseif mp.get_property("pause") == "yes" and not state.playing_and_seeking then
22512257
return icons.play
22522258
else
22532259
return icons.pause
@@ -2669,8 +2675,8 @@ local function osc_init()
26692675
-- mouse move events may pile up during seeking and may still get
26702676
-- sent when the user is done seeking, so we need to throw away
26712677
-- identical seeks
2678+
state.playing_and_seeking = true
26722679
if mp.get_property("pause") == "no" and user_opts.mouse_seek_pause then
2673-
state.playingWhilstSeeking = true
26742680
mp.commandv("cycle", "pause")
26752681
end
26762682
local seekto = get_slider_value(element)
@@ -2713,11 +2719,11 @@ local function osc_init()
27132719
end
27142720
ne.eventresponder["reset"] = function (element)
27152721
element.state.lastseek = nil
2716-
if state.playingWhilstSeeking then
2717-
if mp.get_property("eof-reached") == "no" then
2722+
if state.playing_and_seeking then
2723+
if mp.get_property("eof-reached") == "no" and user_opts.mouse_seek_pause then
27182724
mp.commandv("cycle", "pause")
27192725
end
2720-
state.playingWhilstSeeking = false
2726+
state.playing_and_seeking = false
27212727
end
27222728
end
27232729
ne.eventresponder["wheel_up_press"] = function () mp.commandv("seek", 10) end
@@ -3197,7 +3203,7 @@ local function render()
31973203
render_elements(ass)
31983204
end
31993205

3200-
if user_opts.persistentprogress or state.persistentprogresstoggle then
3206+
if user_opts.persistentprogress or state.persistent_progress_toggle then
32013207
render_persistentprogressbar(ass)
32023208
end
32033209

@@ -3559,7 +3565,7 @@ end)
35593565
mp.add_key_binding(nil, "visibility", function() visibility_mode("cycle") end)
35603566
mp.add_key_binding(nil, "progress-toggle", function()
35613567
user_opts.persistentprogress = not user_opts.persistentprogress
3562-
state.persistentprogresstoggle = user_opts.persistentprogress
3568+
state.persistent_progress_toggle = user_opts.persistentprogress
35633569
request_init()
35643570
end)
35653571
mp.register_script_message("osc-idlescreen", idlescreen_visibility)

0 commit comments

Comments
 (0)