Skip to content

Commit

Permalink
Change track button width based on number of tracks (Issue #9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zren committed May 31, 2022
1 parent 242f857 commit 4f2c722
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions osc_tethys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1675,8 +1675,28 @@ seekbarThumb.overlayId = 1



-- Funcs

-- Render Funcs
function calcTrackButtonWidth(trackArr)
-- "ICON -/0" or "ICON 1/1" or "ICON 1/10"
local trackButtonSize = tethys.trackButtonSize
local trackIconWidth = trackButtonSize * (32/23.273)
local trackDigitWidth = trackButtonSize * 0.4
local spaceDigitRatio = 0.4
local slashDigitRatio = 0.7
-- print("trackButtonSize", trackButtonSize)
-- print("trackIconWidth", trackIconWidth)
-- print("trackDigitWidth", trackDigitWidth)
local numTrackDigits = 1
if trackArr ~= nil and #trackArr > 0 then
numTrackDigits = math.floor(math.log(#trackArr, 10)) + 1
end
local trackButtonWidth = math.ceil(trackIconWidth + trackDigitWidth * (spaceDigitRatio + numTrackDigits + slashDigitRatio + numTrackDigits))
-- print("numTrackDigits", numTrackDigits)
-- print("trackButtonWidth", trackButtonWidth)
return trackButtonWidth
end

-- Thumbnail Funcs
function canShowThumb(videoPath)
local isRemote = videoPath:find("://") ~= nil
ExecutableFinder:check()
Expand Down Expand Up @@ -1726,7 +1746,6 @@ function postRenderThumbnails()
thumbPostRender(seekbarThumb)
end

-- Render Utils
-- From: Slider.tooltipF(pos)
function formatTimestamp(percent)
local duration = mp.get_property_number("duration", nil)
Expand Down Expand Up @@ -3899,7 +3918,7 @@ layouts["tethys"] = function()

-- Subtitle track
local trackButtonSize = tethys.trackButtonSize
local trackButtonWidth = trackButtonSize * 2.5
local trackButtonWidth = calcTrackButtonWidth(tracks_osc.sub)
geo = {
x = rightX - rightSectionWidth - trackButtonWidth/2,
y = line1Y + buttonH/2,
Expand All @@ -3916,6 +3935,7 @@ layouts["tethys"] = function()
end

-- Audio track
trackButtonWidth = calcTrackButtonWidth(tracks_osc.audio)
geo = {
x = rightX - rightSectionWidth - trackButtonWidth/2,
y = line1Y + buttonH/2,
Expand Down

0 comments on commit 4f2c722

Please sign in to comment.