Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hide track elements if none available (audio, subtitle) #244

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 38 additions & 30 deletions modernz.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ local user_opts = {

-- Progress bar settings
seekbarhandlesize = 0.8, -- size ratio of the seekbar handle (range: 0 ~ 1)
handle_always_visible = false, -- control handle visibility: "true" always visible, "false" show on slider hover
handle_always_visible = true, -- control handle visibility: "true" always visible, "false" show on slider hover
seekrange = true, -- show seek range overlay
seekrangealpha = 150, -- transparency of the seek range
livemarkers = true, -- update chapter markers on the seekbar when duration changes
Expand Down Expand Up @@ -1649,6 +1649,8 @@ layouts["modern"] = function ()
lo.slider.tooltip_an = 0
end

local audio_track = audio_track_count > 0
local subtitle_track = sub_track_count > 0
local jump_buttons = user_opts.jump_buttons
local chapter_skip_buttons = user_opts.chapter_skip_buttons
local track_nextprev_buttons = user_opts.track_nextprev_buttons
Expand Down Expand Up @@ -1738,46 +1740,52 @@ layouts["modern"] = function ()
end

-- Audio
lo = add_layout("audio_track")
lo.geometry = {x = 37, y = refY - 40, an = 5, w = 24, h = 24}
lo.style = osc_styles.control_3
lo.visible = (osc_param.playresx >= 500 - outeroffset)
if audio_track then
lo = add_layout("audio_track")
lo.geometry = {x = 37, y = refY - 40, an = 5, w = 24, h = 24}
lo.style = osc_styles.control_3
lo.visible = (osc_param.playresx >= 500 - outeroffset)
end

-- Subtitle
lo = add_layout("sub_track")
lo.geometry = {x = 82, y = refY - 40, an = 5, w = 24, h = 24}
lo.style = osc_styles.control_3
lo.visible = (osc_param.playresx >= 600 - outeroffset)
if subtitle_track then
lo = add_layout("sub_track")
lo.geometry = {x = 82 - (audio_track and 0 or 45), y = refY - 40, an = 5, w = 24, h = 24}
lo.style = osc_styles.control_3
lo.visible = (osc_param.playresx >= 600 - outeroffset)
end

-- Playlist
if playlist_button then
lo = add_layout("tog_playlist")
lo.geometry = {x = 127, y = refY - 40, an = 5, w = 24, h = 24}
lo.geometry = {x = 127 - (audio_track and 0 or 45) - (subtitle_track and 0 or 45), y = refY - 40, an = 5, w = 24, h = 24}
lo.style = osc_styles.control_3
lo.visible = (osc_param.playresx >= 600 - outeroffset)
end

-- Volume
lo = add_layout("vol_ctrl")
lo.geometry = {x = 172 - (playlist_button and 0 or 45), y = refY - 40, an = 5, w = 24, h = 24}
lo.style = osc_styles.control_3
lo.visible = (osc_param.playresx >= 600 - outeroffset)
if audio_track then
-- Volume
lo = add_layout("vol_ctrl")
lo.geometry = {x = 172 - (audio_track and 0 or 45) - (subtitle_track and 0 or 45) - (playlist_button and 0 or 45), y = refY - 40, an = 5, w = 24, h = 24}
lo.style = osc_styles.control_3
lo.visible = (osc_param.playresx >= 600 - outeroffset)

-- Volumebar
lo = new_element("volumebarbg", "box")
lo.visible = (osc_param.playresx >= 920 - outeroffset) and user_opts.volume_control
lo = add_layout("volumebarbg")
lo.geometry = {x = 200 - (playlist_button and 0 or 45), y = refY - 40, an = 4, w = 80, h = 4}
lo.layer = 13
lo.alpha[1] = 128
lo.style = user_opts.volumebar_match_seek_color and osc_styles.seekbar_bg or osc_styles.volumebar_bg

lo = add_layout("volumebar")
lo.geometry = {x = 200 - (playlist_button and 0 or 45), y = refY - 40, an = 4, w = 80, h = 10}
lo.style = user_opts.volumebar_match_seek_color and osc_styles.seekbar_fg or osc_styles.volumebar_fg
lo.slider.gap = 3
lo.slider.tooltip_style = osc_styles.tooltip
lo.slider.tooltip_an = 2
-- Volumebar
lo = new_element("volumebarbg", "box")
lo.visible = (osc_param.playresx >= 920 - outeroffset) and user_opts.volume_control
lo = add_layout("volumebarbg")
lo.geometry = {x = 200 - (audio_track and 0 or 45) - (subtitle_track and 0 or 45) - (playlist_button and 0 or 45), y = refY - 40, an = 4, w = 80, h = 4}
lo.layer = 13
lo.alpha[1] = 128
lo.style = user_opts.volumebar_match_seek_color and osc_styles.seekbar_bg or osc_styles.volumebar_bg

lo = add_layout("volumebar")
lo.geometry = {x = 200 - (audio_track and 0 or 45) - (subtitle_track and 0 or 45) - (playlist_button and 0 or 45), y = refY - 40, an = 4, w = 80, h = 10}
lo.style = user_opts.volumebar_match_seek_color and osc_styles.seekbar_fg or osc_styles.volumebar_fg
lo.slider.gap = 3
lo.slider.tooltip_style = osc_styles.tooltip
lo.slider.tooltip_an = 2
end

-- Fullscreen/Info/Pin/Screenshot/Loop/Speed
if fullscreen_button then
Expand Down