Skip to content

Commit

Permalink
fix: better thumbnail clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
po5 committed Oct 31, 2022
1 parent a54a9a8 commit 74c9a43
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
8 changes: 8 additions & 0 deletions scripts/uosc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,16 @@ function update_mouse_pos(_, mouse, ignore_hover)
end
mp.observe_property('mouse-pos', 'native', update_mouse_pos)
mp.observe_property('osc', 'bool', function(name, value) if value == true then mp.set_property('osc', 'no') end end)

function clear_thumbnail()
if not thumbnail_state.render.thumbnail then return end
mp.commandv('script-message-to', 'thumbfast', 'clear')
thumbnail_state.render.thumbnail = false
thumbnail_state.updated = true
end
mp.register_event('file-loaded', function()
set_state('path', normalize_path(mp.get_property_native('path')))
clear_thumbnail()
end)
mp.register_event('end-file', function(event)
if event.reason == 'eof' then
Expand Down
15 changes: 6 additions & 9 deletions scripts/uosc_shared/elements/Timeline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ function Timeline:set_from_cursor(fast)
mp.commandv('seek', self:get_time_at_x(cursor.x), fast and 'absolute+keyframes' or 'absolute+exact')
end
end
function Timeline:clear_thumbnail()
mp.commandv('script-message-to', 'thumbfast', 'clear')
thumbnail_state.render.thumbnail = false
thumbnail_state.updated = true
end

function Timeline:on_mbtn_left_down()
self.pressed = true
Expand All @@ -101,17 +96,14 @@ function Timeline:on_prop_time() self:decide_enabled() end
function Timeline:on_prop_border() self:update_dimensions() end
function Timeline:on_prop_fullormaxed() self:update_dimensions() end
function Timeline:on_display() self:update_dimensions() end
function Timeline:on_mouse_leave() self:clear_thumbnail() end
function Timeline:on_global_mbtn_left_up()
if self.pressed then
mp.set_property_native('pause', self.pressed_pause)
self.pressed = false
end
self:clear_thumbnail()
end
function Timeline:on_global_mouse_leave()
self.pressed = false
self:clear_thumbnail()
end

Timeline.seek_timer = mp.add_timeout(0.05, function() Elements.timeline:set_from_cursor() end)
Expand All @@ -135,7 +127,10 @@ function Timeline:render()
local size = self:get_effective_size()
local visibility = self:get_visibility()

if size < 1 then return end
if size < 1 then
clear_thumbnail()
return
end

local ass = assdraw.ass_new()

Expand Down Expand Up @@ -340,6 +335,8 @@ function Timeline:render()
})
end
end
else
clear_thumbnail()
end

return ass
Expand Down

0 comments on commit 74c9a43

Please sign in to comment.