Skip to content

Commit

Permalink
feat: timeline_step option now accepts ! suffix to enable exact s…
Browse files Browse the repository at this point in the history
…eeks

closes #941
  • Loading branch information
tomasklaen committed Aug 29, 2024
1 parent 3b7443f commit 003f9ee
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/uosc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ timeline_size=40
timeline_persistency=
# Top border of background color to help visually separate timeline from video
timeline_border=1
# When scrolling above timeline, wheel will seek by this amount of seconds
# When scrolling above timeline, wheel will seek by this amount of seconds.
# Default uses fast seeking. Add `!` suffix to enable exact seeks. Example: `5!`
timeline_step=5
# Render cache indicators for streaming content
timeline_cache=yes
Expand Down
8 changes: 6 additions & 2 deletions src/uosc/elements/Timeline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,12 @@ function Timeline:render()
cursor:once('primary_up', function() self:handle_cursor_up() end)
end)
if options.timeline_step ~= 0 then
cursor:zone('wheel_down', self, function() mp.commandv('seek', -options.timeline_step) end)
cursor:zone('wheel_up', self, function() mp.commandv('seek', options.timeline_step) end)
cursor:zone('wheel_down', self, function()
mp.commandv('seek', -config.timeline_step, config.timeline_step_flag)
end)
cursor:zone('wheel_up', self, function()
mp.commandv('seek', config.timeline_step, config.timeline_step_flag)
end)
end
end

Expand Down
11 changes: 10 additions & 1 deletion src/uosc/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defaults = {
progress_line_width = 20,
timeline_persistency = '',
timeline_border = 1,
timeline_step = 5,
timeline_step = '5',
timeline_cache = true,

controls =
Expand Down Expand Up @@ -236,6 +236,8 @@ config = {
color = table_copy(config_defaults.color),
opacity = table_copy(config_defaults.opacity),
cursor_leave_fadeout_elements = {'timeline', 'volume', 'top_bar', 'controls'},
timeline_step = 5,
timeline_step_flag = '',
}

-- Updates config with values dependent on options
Expand Down Expand Up @@ -265,6 +267,13 @@ function update_config()
-- Global color shorthands
fg, bg = config.color.foreground, config.color.background
fgt, bgt = config.color.foreground_text, config.color.background_text

-- Timeline step
do
local is_exact = options.timeline_step:sub(-1) == '!'
config.timeline_step = tonumber(is_exact and options.timeline_step:sub(1, -2) or options.timeline_step)
config.timeline_step_flag = is_exact and 'exact' or ''
end
end
update_config()

Expand Down

0 comments on commit 003f9ee

Please sign in to comment.