| @@ -280,7 +280,7 @@ function get_slider_value(element) · 279 unmodified lines |
| 280 | end | 280 | end |
| 281 | | 281 | |
| 282 | function countone(val) | 282 | function countone(val) |
| 283 | if not (user_opts.iamaprogrammer) then | 283 | if not user_opts.iamaprogrammer then |
| 284 | val = val + 1 | 284 | val = val + 1 |
| 285 | end | 285 | end |
| 286 | return val | 286 | return val |
| @@ -301,7 +301,7 @@ end · 14 unmodified lines |
| 301 | | 301 | |
| 302 | function add_area(name, x1, y1, x2, y2) | 302 | function add_area(name, x1, y1, x2, y2) |
| 303 | -- create area if needed | 303 | -- create area if needed |
| 304 | if (osc_param.areas[name] == nil) then | 304 | if osc_param.areas[name] == nil then |
| 305 | osc_param.areas[name] = {} | 305 | osc_param.areas[name] = {} |
| 306 | end | 306 | end |
| 307 | table.insert(osc_param.areas[name], {x1=x1, y1=y1, x2=x2, y2=y2}) | 307 | table.insert(osc_param.areas[name], {x1=x1, y1=y1, x2=x2, y2=y2}) |
| @@ -356,7 +356,7 @@ function update_tracklist() · 48 unmodified lines |
| 356 | tracks_mpv = {} | 356 | tracks_mpv = {} |
| 357 | tracks_mpv.video, tracks_mpv.audio, tracks_mpv.sub = {}, {}, {} | 357 | tracks_mpv.video, tracks_mpv.audio, tracks_mpv.sub = {}, {}, {} |
| 358 | for n = 1, #tracktable do | 358 | for n = 1, #tracktable do |
| 359 | if not (tracktable[n].type == "unknown") then | 359 | if tracktable[n].type ~= "unknown" then |
| 360 | local type = tracktable[n].type | 360 | local type = tracktable[n].type |
| 361 | local mpv_id = tonumber(tracktable[n].id) | 361 | local mpv_id = tonumber(tracktable[n].id) |
| 362 | | 362 | |
| @@ -379,9 +379,9 @@ function get_tracklist(type) · 16 unmodified lines |
| 379 | for n = 1, #tracks_osc[type] do | 379 | for n = 1, #tracks_osc[type] do |
| 380 | local track = tracks_osc[type][n] | 380 | local track = tracks_osc[type][n] |
| 381 | local lang, title, selected = "unknown", "", "○" | 381 | local lang, title, selected = "unknown", "", "○" |
| 382 | if not(track.lang == nil) then lang = track.lang end | 382 | if track.lang ~= nil then lang = track.lang end |
| 383 | if not(track.title == nil) then title = track.title end | 383 | if track.title ~= nil then title = track.title end |
| 384 | if (track.id == tonumber(mp.get_property(type))) then | 384 | if track.id == tonumber(mp.get_property(type)) then |
| 385 | selected = "●" | 385 | selected = "●" |
| 386 | end | 386 | end |
| 387 | msg = msg.."\n"..selected.." "..n..": ["..lang.."] "..title | 387 | msg = msg.."\n"..selected.." "..n..": ["..lang.."] "..title |
| @@ -394,7 +394,7 @@ end · 6 unmodified lines |
| 394 | --(+1 -> next, -1 -> previous) | 394 | --(+1 -> next, -1 -> previous) |
| 395 | function set_track(type, next) | 395 | function set_track(type, next) |
| 396 | local current_track_mpv, current_track_osc | 396 | local current_track_mpv, current_track_osc |
| 397 | if (mp.get_property(type) == "no") then | 397 | if mp.get_property(type) == "no" then |
| 398 | current_track_osc = 0 | 398 | current_track_osc = 0 |
| 399 | else | 399 | else |
| 400 | current_track_mpv = tonumber(mp.get_property(type)) | 400 | current_track_mpv = tonumber(mp.get_property(type)) |
| @@ -410,7 +410,7 @@ function set_track(type, next) · 9 unmodified lines |
| 410 | | 410 | |
| 411 | mp.commandv("set", type, new_track_mpv) | 411 | mp.commandv("set", type, new_track_mpv) |
| 412 | | 412 | |
| 413 | if (new_track_osc == 0) then | 413 | if new_track_osc == 0 then |
| 414 | show_message(nicetypes[type] .. " Track: none") | 414 | show_message(nicetypes[type] .. " Track: none") |
| 415 | else | 415 | else |
| 416 | show_message(nicetypes[type] .. " Track: " | 416 | show_message(nicetypes[type] .. " Track: " |
| @@ -457,7 +457,7 @@ function prepare_elements() · 40 unmodified lines |
| 457 | -- remove elements without layout or invisible | 457 | -- remove elements without layout or invisible |
| 458 | local elements2 = {} | 458 | local elements2 = {} |
| 459 | for n, element in pairs(elements) do | 459 | for n, element in pairs(elements) do |
| 460 | if not (element.layout == nil) and (element.visible) then | 460 | if element.layout ~= nil and element.visible then |
| 461 | table.insert(elements2, element) | 461 | table.insert(elements2, element) |
| 462 | end | 462 | end |
| 463 | end | 463 | end |
| @@ -492,14 +492,14 @@ function prepare_elements() · 28 unmodified lines |
| 492 | local static_ass = assdraw.ass_new() | 492 | local static_ass = assdraw.ass_new() |
| 493 | | 493 | |
| 494 | | 494 | |
| 495 | if (element.type == "box") then | 495 | if element.type == "box" then |
| 496 | --draw box | 496 | --draw box |
| 497 | static_ass:draw_start() | 497 | static_ass:draw_start() |
| 498 | ass_draw_rr_h_cw(static_ass, 0, 0, elem_geo.w, elem_geo.h, | 498 | ass_draw_rr_h_cw(static_ass, 0, 0, elem_geo.w, elem_geo.h, |
| 499 | element.layout.box.radius, element.layout.box.hexagon) | 499 | element.layout.box.radius, element.layout.box.hexagon) |
| 500 | static_ass:draw_stop() | 500 | static_ass:draw_stop() |
| 501 | | 501 | |
| 502 | elseif (element.type == "slider") then | 502 | elseif element.type == "slider" then |
| 503 | --draw static slider parts | 503 | --draw static slider parts |
| 504 | | 504 | |
| 505 | local r1 = 0 | 505 | local r1 = 0 |
| @@ -509,13 +509,13 @@ function prepare_elements() · 3 unmodified lines |
| 509 | local foV = slider_lo.border + slider_lo.gap | 509 | local foV = slider_lo.border + slider_lo.gap |
| 510 | | 510 | |
| 511 | -- calculate positions of min and max points | 511 | -- calculate positions of min and max points |
| 512 | if (slider_lo.stype ~= "bar") then | 512 | if slider_lo.stype ~= "bar" then |
| 513 | r1 = elem_geo.h / 2 | 513 | r1 = elem_geo.h / 2 |
| 514 | element.slider.min.ele_pos = elem_geo.h / 2 | 514 | element.slider.min.ele_pos = elem_geo.h / 2 |
| 515 | element.slider.max.ele_pos = elem_geo.w - (elem_geo.h / 2) | 515 | element.slider.max.ele_pos = elem_geo.w - (elem_geo.h / 2) |
| 516 | if (slider_lo.stype == "diamond") then | 516 | if slider_lo.stype == "diamond" then |
| 517 | r2 = (elem_geo.h - 2 * slider_lo.border) / 2 | 517 | r2 = (elem_geo.h - 2 * slider_lo.border) / 2 |
| 518 | elseif (slider_lo.stype == "knob") then | 518 | elseif slider_lo.stype == "knob" then |
| 519 | r2 = r1 | 519 | r2 = r1 |
| 520 | end | 520 | end |
| 521 | else | 521 | else |
| @@ -543,45 +543,45 @@ function prepare_elements() · 21 unmodified lines |
| 543 | r2, slider_lo.stype == "diamond") | 543 | r2, slider_lo.stype == "diamond") |
| 544 | | 544 | |
| 545 | -- marker nibbles | 545 | -- marker nibbles |
| 546 | if not (element.slider.markerF == nil) and (slider_lo.gap > 0) then | 546 | if element.slider.markerF ~= nil and slider_lo.gap > 0 then |
| 547 | local markers = element.slider.markerF() | 547 | local markers = element.slider.markerF() |
| 548 | for _,marker in pairs(markers) do | 548 | for _,marker in pairs(markers) do |
| 549 | if (marker > element.slider.min.value) and | 549 | if marker > element.slider.min.value and |
| 550 | (marker < element.slider.max.value) then | 550 | marker < element.slider.max.value then |
| 551 | | 551 | |
| 552 | local s = get_slider_ele_pos_for(element, marker) | 552 | local s = get_slider_ele_pos_for(element, marker) |
| 553 | | 553 | |
| 554 | if (slider_lo.gap > 1) then -- draw triangles | 554 | if slider_lo.gap > 1 then -- draw triangles |
| 555 | | 555 | |
| 556 | local a = slider_lo.gap / 0.5 --0.866 | 556 | local a = slider_lo.gap / 0.5 --0.866 |
| 557 | | 557 | |
| 558 | --top | 558 | --top |
| 559 | if (slider_lo.nibbles_top) then | 559 | if slider_lo.nibbles_top then |
| 560 | static_ass:move_to(s - (a/2), slider_lo.border) | 560 | static_ass:move_to(s - (a / 2), slider_lo.border) |
| 561 | static_ass:line_to(s + (a/2), slider_lo.border) | 561 | static_ass:line_to(s + (a / 2), slider_lo.border) |
| 562 | static_ass:line_to(s, foV) | 562 | static_ass:line_to(s, foV) |
| 563 | end | 563 | end |
| 564 | | 564 | |
| 565 | --bottom | 565 | --bottom |
| 566 | if (slider_lo.nibbles_bottom) then | 566 | if slider_lo.nibbles_bottom then |
| 567 | static_ass:move_to(s - (a/2), | 567 | static_ass:move_to(s - (a / 2), |
| 568 | elem_geo.h - slider_lo.border) | 568 | elem_geo.h - slider_lo.border) |
| 569 | static_ass:line_to(s, | 569 | static_ass:line_to(s, |
| 570 | elem_geo.h - foV) | 570 | elem_geo.h - foV) |
| 571 | static_ass:line_to(s + (a/2), | 571 | static_ass:line_to(s + (a / 2), |
| 572 | elem_geo.h - slider_lo.border) | 572 | elem_geo.h - slider_lo.border) |
| 573 | end | 573 | end |
| 574 | | 574 | |
| 575 | else -- draw 2x1px nibbles | 575 | else -- draw 2x1px nibbles |
| 576 | | 576 | |
| 577 | --top | 577 | --top |
| 578 | if (slider_lo.nibbles_top) then | 578 | if slider_lo.nibbles_top then |
| 579 | static_ass:rect_cw(s - 1, slider_lo.border, | 579 | static_ass:rect_cw(s - 1, slider_lo.border, |
| 580 | s + 1, slider_lo.border + slider_lo.gap); | 580 | s + 1, slider_lo.border + slider_lo.gap); |
| 581 | end | 581 | end |
| 582 | | 582 | |
| 583 | --bottom | 583 | --bottom |
| 584 | if (slider_lo.nibbles_bottom) then | 584 | if slider_lo.nibbles_bottom then |
| 585 | static_ass:rect_cw(s - 1, | 585 | static_ass:rect_cw(s - 1, |
| 586 | elem_geo.h -slider_lo.border -slider_lo.gap, | 586 | elem_geo.h -slider_lo.border -slider_lo.gap, |
| 587 | s + 1, elem_geo.h - slider_lo.border); | 587 | s + 1, elem_geo.h - slider_lo.border); |
| @@ -597,7 +597,7 @@ function prepare_elements() · 9 unmodified lines |
| 597 | | 597 | |
| 598 | -- if the element is supposed to be disabled, | 598 | -- if the element is supposed to be disabled, |
| 599 | -- style it accordingly and kill the eventresponders | 599 | -- style it accordingly and kill the eventresponders |
| 600 | if not (element.enabled) then | 600 | if not element.enabled then |
| 601 | element.layout.alpha[1] = 136 | 601 | element.layout.alpha[1] = 136 |
| 602 | element.eventresponder = nil | 602 | element.eventresponder = nil |
| 603 | end | 603 | end |
| @@ -648,18 +648,18 @@ function render_elements(master_ass) · 44 unmodified lines |
| 648 | if element.eventresponder and (state.active_element == n) then | 648 | if element.eventresponder and (state.active_element == n) then |
| 649 | | 649 | |
| 650 | -- run render event functions | 650 | -- run render event functions |
| 651 | if not (element.eventresponder.render == nil) then | 651 | if element.eventresponder.render ~= nil then |
| 652 | element.eventresponder.render(element) | 652 | element.eventresponder.render(element) |
| 653 | end | 653 | end |
| 654 | | 654 | |
| 655 | if mouse_hit(element) then | 655 | if mouse_hit(element) then |
| 656 | -- mouse down styling | 656 | -- mouse down styling |
| 657 | if (element.styledown) then | 657 | if element.styledown then |
| 658 | style_ass:append(osc_styles.elementDown) | 658 | style_ass:append(osc_styles.elementDown) |
| 659 | end | 659 | end |
| 660 | | 660 | |
| 661 | if (element.softrepeat) and (state.mouse_down_counter >= 15 | 661 | if element.softrepeat and state.mouse_down_counter >= 15 |
| 662 | and state.mouse_down_counter % 5 == 0) then | 662 | and state.mouse_down_counter % 5 == 0 then |
| 663 | | 663 | |
| 664 | element.eventresponder[state.active_event_source.."_down"](element) | 664 | element.eventresponder[state.active_event_source.."_down"](element) |
| 665 | end | 665 | end |
| @@ -672,11 +672,11 @@ function render_elements(master_ass) · 6 unmodified lines |
| 672 | | 672 | |
| 673 | elem_ass:merge(style_ass) | 673 | elem_ass:merge(style_ass) |
| 674 | | 674 | |
| 675 | if not (element.type == "button") then | 675 | if element.type ~= "button" then |
| 676 | elem_ass:merge(element.static_ass) | 676 | elem_ass:merge(element.static_ass) |
| 677 | end | 677 | end |
| 678 | | 678 | |
| 679 | if (element.type == "slider") then | 679 | if element.type == "slider" then |
| 680 | | 680 | |
| 681 | local slider_lo = element.layout.slider | 681 | local slider_lo = element.layout.slider |
| 682 | local elem_geo = element.layout.geometry | 682 | local elem_geo = element.layout.geometry |
| @@ -794,8 +794,7 @@ function render_elements(master_ass) · 111 unmodified lines |
| 794 | elem_ass:draw_stop() | 794 | elem_ass:draw_stop() |
| 795 | | 795 | |
| 796 | -- add tooltip | 796 | -- add tooltip |
| 797 | if not (element.slider.tooltipF == nil) then | 797 | if element.slider.tooltipF ~= nil then |
| 798 | | | |
| 799 | if mouse_hit(element) then | 798 | if mouse_hit(element) then |
| 800 | local sliderpos = get_slider_value(element) | 799 | local sliderpos = get_slider_value(element) |
| 801 | local tooltiplabel = element.slider.tooltipF(sliderpos) | 800 | local tooltiplabel = element.slider.tooltipF(sliderpos) |
| @@ -804,21 +803,21 @@ function render_elements(master_ass) · 2 unmodified lines |
| 804 | | 803 | |
| 805 | local ty | 804 | local ty |
| 806 | | 805 | |
| 807 | if (an == 2) then | 806 | if an == 2 then |
| 808 | ty = element.hitbox.y1 - slider_lo.border | 807 | ty = element.hitbox.y1 - slider_lo.border |
| 809 | else | 808 | else |
| 810 | ty = element.hitbox.y1 + elem_geo.h/2 | 809 | ty = element.hitbox.y1 + elem_geo.h / 2 |
| 811 | end | 810 | end |
| 812 | | 811 | |
| 813 | local tx = get_virt_mouse_pos() | 812 | local tx = get_virt_mouse_pos() |
| 814 | if (slider_lo.adjust_tooltip) then | 813 | if slider_lo.adjust_tooltip then |
| 815 | if (an == 2) then | 814 | if an == 2 then |
| 816 | if (sliderpos < (s_min + 3)) then | 815 | if sliderpos < (s_min + 3) then |
| 817 | an = an - 1 | 816 | an = an - 1 |
| 818 | elseif (sliderpos > (s_max - 3)) then | 817 | elseif sliderpos > (s_max - 3) then |
| 819 | an = an + 1 | 818 | an = an + 1 |
| 820 | end | 819 | end |
| 821 | elseif (sliderpos > (s_max+s_min)/2) then | 820 | elseif sliderpos > (s_max+s_min) / 2 then |
| 822 | an = an + 1 | 821 | an = an + 1 |
| 823 | tx = tx - 5 | 822 | tx = tx - 5 |
| 824 | else | 823 | else |
| @@ -838,20 +837,20 @@ function render_elements(master_ass) · 13 unmodified lines |
| 838 | end | 837 | end |
| 839 | end | 838 | end |
| 840 | | 839 | |
| 841 | elseif (element.type == "button") then | 840 | elseif element.type == "button" then |
| 842 | | 841 | |
| 843 | local buttontext | 842 | local buttontext |
| 844 | if type(element.content) == "function" then | 843 | if type(element.content) == "function" then |
| 845 | buttontext = element.content() -- function objects | 844 | buttontext = element.content() -- function objects |
| 846 | elseif not (element.content == nil) then | 845 | elseif element.content ~= nil then |
| 847 | buttontext = element.content -- text objects | 846 | buttontext = element.content -- text objects |
| 848 | end | 847 | end |
| 849 | | 848 | |
| 850 | local maxchars = element.layout.button.maxchars | 849 | local maxchars = element.layout.button.maxchars |
| 851 | if not (maxchars == nil) and (#buttontext > maxchars) then | 850 | if maxchars ~= nil and #buttontext > maxchars then |
| 852 | local max_ratio = 1.25 -- up to 25% more chars while shrinking | 851 | local max_ratio = 1.25 -- up to 25% more chars while shrinking |
| 853 | local limit = math.max(0, math.floor(maxchars * max_ratio) - 3) | 852 | local limit = math.max(0, math.floor(maxchars * max_ratio) - 3) |
| 854 | if (#buttontext > limit) then | 853 | if #buttontext > limit then |
| 855 | while (#buttontext > limit) do | 854 | while (#buttontext > limit) do |
| 856 | buttontext = buttontext:gsub(".[\128-\191]*$", "") | 855 | buttontext = buttontext:gsub(".[\128-\191]*$", "") |
| 857 | end | 856 | end |
| @@ -1007,7 +1006,7 @@ function new_element(name, type) · 149 unmodified lines |
| 1007 | elements[name].styledown = (type == "button") | 1006 | elements[name].styledown = (type == "button") |
| 1008 | elements[name].state = {} | 1007 | elements[name].state = {} |
| 1009 | | 1008 | |
| 1010 | if (type == "slider") then | 1009 | if type == "slider" then |
| 1011 | elements[name].slider = {min = {value = 0}, max = {value = 100}} | 1010 | elements[name].slider = {min = {value = 0}, max = {value = 100}} |
| 1012 | end | 1011 | end |
| 1013 | | 1012 | |
| @@ -1016,7 +1015,7 @@ function new_element(name, type) · 2 unmodified lines |
| 1016 | end | 1015 | end |
| 1017 | | 1016 | |
| 1018 | function add_layout(name) | 1017 | function add_layout(name) |
| 1019 | if not (elements[name] == nil) then | 1018 | if elements[name] ~= nil then |
| 1020 | -- new layout | 1019 | -- new layout |
| 1021 | elements[name].layout = {} | 1020 | elements[name].layout = {} |
| 1022 | | 1021 | |
| @@ -1024,11 +1023,11 @@ function add_layout(name) · 1 unmodified line |
| 1024 | elements[name].layout.layer = 50 | 1023 | elements[name].layout.layer = 50 |
| 1025 | elements[name].layout.alpha = {[1] = 0, [2] = 255, [3] = 255, [4] = 255} | 1024 | elements[name].layout.alpha = {[1] = 0, [2] = 255, [3] = 255, [4] = 255} |
| 1026 | | 1025 | |
| 1027 | if (elements[name].type == "button") then | 1026 | if elements[name].type == "button" then |
| 1028 | elements[name].layout.button = { | 1027 | elements[name].layout.button = { |
| 1029 | maxchars = nil, | 1028 | maxchars = nil, |
| 1030 | } | 1029 | } |
| 1031 | elseif (elements[name].type == "slider") then | 1030 | elseif elements[name].type == "slider" then |
| 1032 | -- slider defaults | 1031 | -- slider defaults |
| 1033 | elements[name].layout.slider = { | 1032 | elements[name].layout.slider = { |
| 1034 | border = 1, | 1033 | border = 1, |
| @@ -1041,7 +1040,7 @@ function add_layout(name) · 6 unmodified lines |
| 1041 | tooltip_an = 2, | 1040 | tooltip_an = 2, |
| 1042 | alpha = {[1] = 0, [2] = 255, [3] = 88, [4] = 255}, | 1041 | alpha = {[1] = 0, [2] = 255, [3] = 88, [4] = 255}, |
| 1043 | } | 1042 | } |
| 1044 | elseif (elements[name].type == "box") then | 1043 | elseif elements[name].type == "box" then |
| 1045 | elements[name].layout.box = {radius = 0, hexagon = false} | 1044 | elements[name].layout.box = {radius = 0, hexagon = false} |
| 1046 | end | 1045 | end |
| 1047 | | 1046 | |
| @@ -1196,8 +1195,8 @@ layouts["box"] = function () · 148 unmodified lines |
| 1196 | } | 1195 | } |
| 1197 | | 1196 | |
| 1198 | -- make sure the OSC actually fits into the video | 1197 | -- make sure the OSC actually fits into the video |
| 1199 | if (osc_param.playresx < (osc_geo.w + (2 * osc_geo.p))) then | 1198 | if osc_param.playresx < (osc_geo.w + (2 * osc_geo.p)) then |
| 1200 | osc_param.playresy = (osc_geo.w+(2*osc_geo.p))/osc_param.display_aspect | 1199 | osc_param.playresy = (osc_geo.w + (2 * osc_geo.p)) / osc_param.display_aspect |
| 1201 | osc_param.playresx = osc_param.playresy * osc_param.display_aspect | 1200 | osc_param.playresx = osc_param.playresy * osc_param.display_aspect |
| 1202 | end | 1201 | end |
| 1203 | | 1202 | |
| @@ -1371,8 +1370,8 @@ layouts["slimbox"] = function () · 167 unmodified lines |
| 1371 | } | 1370 | } |
| 1372 | | 1371 | |
| 1373 | -- make sure the OSC actually fits into the video | 1372 | -- make sure the OSC actually fits into the video |
| 1374 | if (osc_param.playresx < (osc_geo.w)) then | 1373 | if osc_param.playresx < (osc_geo.w) then |
| 1375 | osc_param.playresy = (osc_geo.w)/osc_param.display_aspect | 1374 | osc_param.playresy = (osc_geo.w) / osc_param.display_aspect |
| 1376 | osc_param.playresx = osc_param.playresy * osc_param.display_aspect | 1375 | osc_param.playresx = osc_param.playresy * osc_param.display_aspect |
| 1377 | end | 1376 | end |
| 1378 | | 1377 | |
| @@ -1423,7 +1422,7 @@ layouts["slimbox"] = function () · 44 unmodified lines |
| 1423 | lo.style = osc_styles.box | 1422 | lo.style = osc_styles.box |
| 1424 | lo.alpha[1] = user_opts.boxalpha | 1423 | lo.alpha[1] = user_opts.boxalpha |
| 1425 | lo.alpha[3] = 0 | 1424 | lo.alpha[3] = 0 |
| 1426 | if not (user_opts["seekbarstyle"] == "bar") then | 1425 | if user_opts["seekbarstyle"] ~= "bar" then |
| 1427 | lo.box.radius = osc_geo.r | 1426 | lo.box.radius = osc_geo.r |
| 1428 | lo.box.hexagon = user_opts["seekbarstyle"] == "diamond" | 1427 | lo.box.hexagon = user_opts["seekbarstyle"] == "diamond" |
| 1429 | end | 1428 | end |
| @@ -1505,7 +1504,7 @@ function bar_layout(direction) · 75 unmodified lines |
| 1505 | padwc_r = window_control_box_width | 1504 | padwc_r = window_control_box_width |
| 1506 | end | 1505 | end |
| 1507 | | 1506 | |
| 1508 | if ((osc_param.display_aspect > 0) and (osc_param.playresx < minW)) then | 1507 | if osc_param.display_aspect > 0 and osc_param.playresx < minW then |
| 1509 | osc_param.playresy = minW / osc_param.display_aspect | 1508 | osc_param.playresy = minW / osc_param.display_aspect |
| 1510 | osc_param.playresx = osc_param.playresy * osc_param.display_aspect | 1509 | osc_param.playresx = osc_param.playresy * osc_param.display_aspect |
| 1511 | end | 1510 | end |
| @@ -1654,7 +1653,7 @@ function bar_layout(direction) · 142 unmodified lines |
| 1654 | lo.style = osc_styles.timecodesBar | 1653 | lo.style = osc_styles.timecodesBar |
| 1655 | lo.alpha[1] = | 1654 | lo.alpha[1] = |
| 1656 | math.min(255, user_opts.boxalpha + (255 - user_opts.boxalpha)*0.8) | 1655 | math.min(255, user_opts.boxalpha + (255 - user_opts.boxalpha)*0.8) |
| 1657 | if not (user_opts["seekbarstyle"] == "bar") then | 1656 | if user_opts["seekbarstyle"] ~= "bar" then |
| 1658 | lo.box.radius = geo.h / 2 | 1657 | lo.box.radius = geo.h / 2 |
| 1659 | lo.box.hexagon = user_opts["seekbarstyle"] == "diamond" | 1658 | lo.box.hexagon = user_opts["seekbarstyle"] == "diamond" |
| 1660 | end | 1659 | end |
| @@ -1749,7 +1748,7 @@ function osc_init() · 88 unmodified lines |
| 1749 | local display_w, display_h, display_aspect = mp.get_osd_size() | 1748 | local display_w, display_h, display_aspect = mp.get_osd_size() |
| 1750 | local scale = 1 | 1749 | local scale = 1 |
| 1751 | | 1750 | |
| 1752 | if (mp.get_property("video") == "no") then -- dummy/forced window | 1751 | if mp.get_property("video") == "no" then -- dummy/forced window |
| 1753 | scale = user_opts.scaleforcedwindow | 1752 | scale = user_opts.scaleforcedwindow |
| 1754 | elseif state.fullscreen then | 1753 | elseif state.fullscreen then |
| 1755 | scale = user_opts.scalefullscreen | 1754 | scale = user_opts.scalefullscreen |
| @@ -1763,7 +1762,7 @@ function osc_init() · 7 unmodified lines |
| 1763 | osc_param.unscaled_y = display_h | 1762 | osc_param.unscaled_y = display_h |
| 1764 | end | 1763 | end |
| 1765 | osc_param.playresy = osc_param.unscaled_y / scale | 1764 | osc_param.playresy = osc_param.unscaled_y / scale |
| 1766 | if (display_aspect > 0) then | 1765 | if display_aspect > 0 then |
| 1767 | osc_param.display_aspect = display_aspect | 1766 | osc_param.display_aspect = display_aspect |
| 1768 | end | 1767 | end |
| 1769 | osc_param.playresx = osc_param.playresy * osc_param.display_aspect | 1768 | osc_param.playresx = osc_param.playresy * osc_param.display_aspect |
| @@ -1797,7 +1796,7 @@ function osc_init() · 27 unmodified lines |
| 1797 | | 1796 | |
| 1798 | ne.eventresponder["mbtn_left_up"] = function () | 1797 | ne.eventresponder["mbtn_left_up"] = function () |
| 1799 | local title = mp.get_property_osd("media-title") | 1798 | local title = mp.get_property_osd("media-title") |
| 1800 | if (have_pl) then | 1799 | if have_pl then |
| 1801 | title = string.format("[%d/%d] %s", countone(pl_pos - 1), | 1800 | title = string.format("[%d/%d] %s", countone(pl_pos - 1), |
| 1802 | pl_count, title) | 1801 | pl_count, title) |
| 1803 | end | 1802 | end |
| @@ -1926,7 +1925,7 @@ function osc_init() · 122 unmodified lines |
| 1926 | ne.enabled = (#tracks_osc.audio > 0) | 1925 | ne.enabled = (#tracks_osc.audio > 0) |
| 1927 | ne.content = function () | 1926 | ne.content = function () |
| 1928 | local aid = "–" | 1927 | local aid = "–" |
| 1929 | if not (get_track("audio") == 0) then | 1928 | if get_track("audio") ~= 0 then |
| 1930 | aid = get_track("audio") | 1929 | aid = get_track("audio") |
| 1931 | end | 1930 | end |
| 1932 | return ("\238\132\134" .. osc_styles.smallButtonsLlabel | 1931 | return ("\238\132\134" .. osc_styles.smallButtonsLlabel |
| @@ -1949,7 +1948,7 @@ function osc_init() · 16 unmodified lines |
| 1949 | ne.enabled = (#tracks_osc.sub > 0) | 1948 | ne.enabled = (#tracks_osc.sub > 0) |
| 1950 | ne.content = function () | 1949 | ne.content = function () |
| 1951 | local sid = "–" | 1950 | local sid = "–" |
| 1952 | if not (get_track("sub") == 0) then | 1951 | if get_track("sub") ~= 0 then |
| 1953 | sid = get_track("sub") | 1952 | sid = get_track("sub") |
| 1954 | end | 1953 | end |
| 1955 | return ("\238\132\135" .. osc_styles.smallButtonsLlabel | 1954 | return ("\238\132\135" .. osc_styles.smallButtonsLlabel |
| @@ -1969,7 +1968,7 @@ function osc_init() · 13 unmodified lines |
| 1969 | --tog_fs | 1968 | --tog_fs |
| 1970 | ne = new_element("tog_fs", "button") | 1969 | ne = new_element("tog_fs", "button") |
| 1971 | ne.content = function () | 1970 | ne.content = function () |
| 1972 | if (state.fullscreen) then | 1971 | if state.fullscreen then |
| 1973 | return ("\238\132\137") | 1972 | return ("\238\132\137") |
| 1974 | else | 1973 | else |
| 1975 | return ("\238\132\136") | 1974 | return ("\238\132\136") |
| @@ -1981,11 +1980,11 @@ function osc_init() · 5 unmodified lines |
| 1981 | --seekbar | 1980 | --seekbar |
| 1982 | ne = new_element("seekbar", "slider") | 1981 | ne = new_element("seekbar", "slider") |
| 1983 | | 1982 | |
| 1984 | ne.enabled = not (mp.get_property("percent-pos") == nil) | 1983 | ne.enabled = mp.get_property("percent-pos") ~= nil |
| 1985 | state.slider_element = ne.enabled and ne or nil -- used for forced_title | 1984 | state.slider_element = ne.enabled and ne or nil -- used for forced_title |
| 1986 | ne.slider.markerF = function () | 1985 | ne.slider.markerF = function () |
| 1987 | local duration = mp.get_property_number("duration", nil) | 1986 | local duration = mp.get_property_number("duration", nil) |
| 1988 | if not (duration == nil) then | 1987 | if duration ~= nil then |
| 1989 | local chapters = mp.get_property_native("chapter-list", {}) | 1988 | local chapters = mp.get_property_native("chapter-list", {}) |
| 1990 | local markers = {} | 1989 | local markers = {} |
| 1991 | for n = 1, #chapters do | 1990 | for n = 1, #chapters do |
| @@ -2000,7 +1999,7 @@ function osc_init() · 8 unmodified lines |
| 2000 | function () return mp.get_property_number("percent-pos", nil) end | 1999 | function () return mp.get_property_number("percent-pos", nil) end |
| 2001 | ne.slider.tooltipF = function (pos) | 2000 | ne.slider.tooltipF = function (pos) |
| 2002 | local duration = mp.get_property_number("duration", nil) | 2001 | local duration = mp.get_property_number("duration", nil) |
| 2003 | if not ((duration == nil) or (pos == nil)) then | 2002 | if duration ~= nil and pos ~= nil then |
| 2004 | possec = duration * (pos / 100) | 2003 | possec = duration * (pos / 100) |
| 2005 | return mp.format_time(possec) | 2004 | return mp.format_time(possec) |
| 2006 | else | 2005 | else |
| @@ -2016,7 +2015,7 @@ function osc_init() · 9 unmodified lines |
| 2016 | return nil | 2015 | return nil |
| 2017 | end | 2016 | end |
| 2018 | local duration = mp.get_property_number("duration", nil) | 2017 | local duration = mp.get_property_number("duration", nil) |
| 2019 | if (duration == nil) or duration <= 0 then | 2018 | if duration == nil or duration <= 0 then |
| 2020 | return nil | 2019 | return nil |
| 2021 | end | 2020 | end |
| 2022 | local ranges = cache_state["seekable-ranges"] | 2021 | local ranges = cache_state["seekable-ranges"] |
| @@ -2038,8 +2037,8 @@ function osc_init() · 15 unmodified lines |
| 2038 | -- sent when the user is done seeking, so we need to throw away | 2037 | -- sent when the user is done seeking, so we need to throw away |
| 2039 | -- identical seeks | 2038 | -- identical seeks |
| 2040 | local seekto = get_slider_value(element) | 2039 | local seekto = get_slider_value(element) |
| 2041 | if (element.state.lastseek == nil) or | 2040 | if element.state.lastseek == nil or |
| 2042 | (not (element.state.lastseek == seekto)) then | 2041 | element.state.lastseek ~= seekto then |
| 2043 | local flags = "absolute-percent" | 2042 | local flags = "absolute-percent" |
| 2044 | if not user_opts.seekbarkeyframes then | 2043 | if not user_opts.seekbarkeyframes then |
| 2045 | flags = flags .. "+exact" | 2044 | flags = flags .. "+exact" |
| @@ -2064,7 +2063,7 @@ function osc_init() · 18 unmodified lines |
| 2064 | ne = new_element("tc_left", "button") | 2063 | ne = new_element("tc_left", "button") |
| 2065 | | 2064 | |
| 2066 | ne.content = function () | 2065 | ne.content = function () |
| 2067 | if (state.tc_ms) then | 2066 | if state.tc_ms then |
| 2068 | return (mp.get_property_osd("playback-time/full")) | 2067 | return (mp.get_property_osd("playback-time/full")) |
| 2069 | else | 2068 | else |
| 2070 | return (mp.get_property_osd("playback-time")) | 2069 | return (mp.get_property_osd("playback-time")) |
| @@ -2080,7 +2079,7 @@ function osc_init() · 9 unmodified lines |
| 2080 | | 2079 | |
| 2081 | ne.visible = (mp.get_property_number("duration", 0) > 0) | 2080 | ne.visible = (mp.get_property_number("duration", 0) > 0) |
| 2082 | ne.content = function () | 2081 | ne.content = function () |
| 2083 | if (state.rightTC_trem) then | 2082 | if state.rightTC_trem then |
| 2084 | local minus = user_opts.unicodeminus and UNICODE_MINUS or "-" | 2083 | local minus = user_opts.unicodeminus and UNICODE_MINUS or "-" |
| 2085 | local property = user_opts.remaining_playtime and "playtime-remaining" | 2084 | local property = user_opts.remaining_playtime and "playtime-remaining" |
| 2086 | or "time-remaining" | 2085 | or "time-remaining" |
| @@ -2174,7 +2173,7 @@ function update_margins() · 87 unmodified lines |
| 2174 | local margins = osc_param.video_margins | 2173 | local margins = osc_param.video_margins |
| 2175 | | 2174 | |
| 2176 | -- Don't use margins if it's visible only temporarily. | 2175 | -- Don't use margins if it's visible only temporarily. |
| 2177 | if (not state.osc_visible) or (get_hidetimeout() >= 0) or | 2176 | if not state.osc_visible or get_hidetimeout() >= 0 or |
| 2178 | (state.fullscreen and not user_opts.showfullscreen) or | 2177 | (state.fullscreen and not user_opts.showfullscreen) or |
| 2179 | (not state.fullscreen and not user_opts.showwindowed) | 2178 | (not state.fullscreen and not user_opts.showwindowed) |
| 2180 | then | 2179 | then |
| @@ -2196,7 +2195,7 @@ function update_margins() · 15 unmodified lines |
| 2196 | if not margins_used then | 2195 | if not margins_used then |
| 2197 | for _, opt in ipairs(margins_opts) do | 2196 | for _, opt in ipairs(margins_opts) do |
| 2198 | local v = margins[opt[1]] | 2197 | local v = margins[opt[1]] |
| 2199 | if (v ~= 0) or state.using_video_margins then | 2198 | if v ~= 0 or state.using_video_margins then |
| 2200 | mp.set_property_number(opt[2], v) | 2199 | mp.set_property_number(opt[2], v) |
| 2201 | state.using_video_margins = true | 2200 | state.using_video_margins = true |
| 2202 | end | 2201 | end |
| @@ -2229,7 +2228,7 @@ function show_osc() · 26 unmodified lines |
| 2229 | | 2228 | |
| 2230 | osc_visible(true) | 2229 | osc_visible(true) |
| 2231 | | 2230 | |
| 2232 | if (user_opts.fadeduration > 0) then | 2231 | if user_opts.fadeduration > 0 then |
| 2233 | state.anitype = nil | 2232 | state.anitype = nil |
| 2234 | end | 2233 | end |
| 2235 | end | 2234 | end |
| @@ -2241,8 +2240,8 @@ function hide_osc() · 5 unmodified lines |
| 2241 | -- no-op and won't render again to remove the osc, so do that manually. | 2240 | -- no-op and won't render again to remove the osc, so do that manually. |
| 2242 | state.osc_visible = false | 2241 | state.osc_visible = false |
| 2243 | render_wipe() | 2242 | render_wipe() |
| 2244 | elseif (user_opts.fadeduration > 0) then | 2243 | elseif user_opts.fadeduration > 0 then |
| 2245 | if not(state.osc_visible == false) then | 2244 | if state.osc_visible then |
| 2246 | state.anitype = "out" | 2245 | state.anitype = "out" |
| 2247 | request_tick() | 2246 | request_tick() |
| 2248 | end | 2247 | end |
| @@ -2324,8 +2323,8 @@ function render() · 75 unmodified lines |
| 2324 | local now = mp.get_time() | 2323 | local now = mp.get_time() |
| 2325 | | 2324 | |
| 2326 | -- check if display changed, if so request reinit | 2325 | -- check if display changed, if so request reinit |
| 2327 | if not (state.mp_screen_sizeX == current_screen_sizeX | 2326 | if state.mp_screen_sizeX ~= current_screen_sizeX |
| 2328 | and state.mp_screen_sizeY == current_screen_sizeY) then | 2327 | or state.mp_screen_sizeY ~= current_screen_sizeY then |
| 2329 | | 2328 | |
| 2330 | request_init_resize() | 2329 | request_init_resize() |
| 2331 | | 2330 | |
| @@ -2355,27 +2354,27 @@ function render() · 23 unmodified lines |
| 2355 | | 2354 | |
| 2356 | | 2355 | |
| 2357 | -- fade animation | 2356 | -- fade animation |
| 2358 | if not(state.anitype == nil) then | 2357 | if state.anitype ~= nil then |
| 2359 | | 2358 | |
| 2360 | if (state.anistart == nil) then | 2359 | if state.anistart == nil then |
| 2361 | state.anistart = now | 2360 | state.anistart = now |
| 2362 | end | 2361 | end |
| 2363 | | 2362 | |
| 2364 | if (now < state.anistart + (user_opts.fadeduration/1000)) then | 2363 | if now < state.anistart + (user_opts.fadeduration / 1000) then |
| 2365 | | 2364 | |
| 2366 | if (state.anitype == "in") then --fade in | 2365 | if state.anitype == "in" then --fade in |
| 2367 | osc_visible(true) | 2366 | osc_visible(true) |
| 2368 | state.animation = scale_value(state.anistart, | 2367 | state.animation = scale_value(state.anistart, |
| 2369 | (state.anistart + (user_opts.fadeduration/1000)), | 2368 | (state.anistart + (user_opts.fadeduration / 1000)), |
| 2370 | 255, 0, now) | 2369 | 255, 0, now) |
| 2371 | elseif (state.anitype == "out") then --fade out | 2370 | elseif state.anitype == "out" then --fade out |
| 2372 | state.animation = scale_value(state.anistart, | 2371 | state.animation = scale_value(state.anistart, |
| 2373 | (state.anistart + (user_opts.fadeduration/1000)), | 2372 | (state.anistart + (user_opts.fadeduration / 1000)), |
| 2374 | 0, 255, now) | 2373 | 0, 255, now) |
| 2375 | end | 2374 | end |
| 2376 | | 2375 | |
| 2377 | else | 2376 | else |
| 2378 | if (state.anitype == "out") then | 2377 | if state.anitype == "out" then |
| 2379 | osc_visible(false) | 2378 | osc_visible(false) |
| 2380 | end | 2379 | end |
| 2381 | kill_animation() | 2380 | kill_animation() |
| @@ -2413,7 +2412,7 @@ function render() · 31 unmodified lines |
| 2413 | state.input_enabled = state.osc_visible | 2412 | state.input_enabled = state.osc_visible |
| 2414 | end | 2413 | end |
| 2415 | | 2414 | |
| 2416 | if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then | 2415 | if mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2) then |
| 2417 | mouse_over_osc = true | 2416 | mouse_over_osc = true |
| 2418 | end | 2417 | end |
| 2419 | end | 2418 | end |
| @@ -2432,7 +2431,7 @@ function render() · 12 unmodified lines |
| 2432 | state.windowcontrols_buttons = state.osc_visible | 2431 | state.windowcontrols_buttons = state.osc_visible |
| 2433 | end | 2432 | end |
| 2434 | | 2433 | |
| 2435 | if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then | 2434 | if mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2) then |
| 2436 | mouse_over_osc = true | 2435 | mouse_over_osc = true |
| 2437 | end | 2436 | end |
| 2438 | end | 2437 | end |
| @@ -2440,17 +2439,17 @@ function render() · 1 unmodified line |
| 2440 | | 2439 | |
| 2441 | if osc_param.areas["window-controls-title"] then | 2440 | if osc_param.areas["window-controls-title"] then |
| 2442 | for _,cords in ipairs(osc_param.areas["window-controls-title"]) do | 2441 | for _,cords in ipairs(osc_param.areas["window-controls-title"]) do |
| 2443 | if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then | 2442 | if mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2) then |
| 2444 | mouse_over_osc = true | 2443 | mouse_over_osc = true |
| 2445 | end | 2444 | end |
| 2446 | end | 2445 | end |
| 2447 | end | 2446 | end |
| 2448 | | 2447 | |
| 2449 | -- autohide | 2448 | -- autohide |
| 2450 | if not (state.showtime == nil) and (get_hidetimeout() >= 0) then | 2449 | if state.showtime ~= nil and get_hidetimeout() >= 0 then |
| 2451 | local timeout = state.showtime + (get_hidetimeout()/1000) - now | 2450 | local timeout = state.showtime + (get_hidetimeout() / 1000) - now |
| 2452 | if timeout <= 0 then | 2451 | if timeout <= 0 then |
| 2453 | if (state.active_element == nil) and not (mouse_over_osc) then | 2452 | if state.active_element == nil and not mouse_over_osc then |
| 2454 | hide_osc() | 2453 | hide_osc() |
| 2455 | end | 2454 | end |
| 2456 | else | 2455 | else |
| @@ -2544,8 +2543,8 @@ function process_event(source, what) · 87 unmodified lines |
| 2544 | state.mouse_in_window = true | 2543 | state.mouse_in_window = true |
| 2545 | | 2544 | |
| 2546 | local mouseX, mouseY = get_virt_mouse_pos() | 2545 | local mouseX, mouseY = get_virt_mouse_pos() |
| 2547 | if (user_opts.minmousemove == 0) or | 2546 | if user_opts.minmousemove == 0 or |
| 2548 | (not ((state.last_mouseX == nil) or (state.last_mouseY == nil)) and | 2547 | ((state.last_mouseX ~= nil and state.last_mouseY ~= nil) and |
| 2549 | ((math.abs(mouseX - state.last_mouseX) >= user_opts.minmousemove) | 2548 | ((math.abs(mouseX - state.last_mouseX) >= user_opts.minmousemove) |
| 2550 | or (math.abs(mouseY - state.last_mouseY) >= user_opts.minmousemove) | 2549 | or (math.abs(mouseY - state.last_mouseY) >= user_opts.minmousemove) |
| 2551 | ) | 2550 | ) |
| @@ -2597,9 +2596,9 @@ function tick() · 45 unmodified lines |
| 2597 | state.marginsREQ = false | 2596 | state.marginsREQ = false |
| 2598 | end | 2597 | end |
| 2599 | | 2598 | |
| 2600 | if (not state.enabled) then return end | 2599 | if not state.enabled then return end |
| 2601 | | 2600 | |
| 2602 | if (state.idle) then | 2601 | if state.idle then |
| 2603 | | 2602 | |
| 2604 | -- render idle message | 2603 | -- render idle message |
| 2605 | msg.trace("idle message") | 2604 | msg.trace("idle message") |
| @@ -2645,7 +2644,7 @@ function tick() · 39 unmodified lines |
| 2645 | end | 2644 | end |
| 2646 | | 2645 | |
| 2647 | | 2646 | |
| 2648 | elseif (state.fullscreen and user_opts.showfullscreen) | 2647 | elseif state.fullscreen and user_opts.showfullscreen |
| 2649 | or (not state.fullscreen and user_opts.showwindowed) then | 2648 | or (not state.fullscreen and user_opts.showwindowed) then |
| 2650 | | 2649 | |
| 2651 | -- render the OSC | 2650 | -- render the OSC |
| @@ -2708,7 +2707,7 @@ function update_duration_watch() · 56 unmodified lines |
| 2708 | (mp.get_property_number("chapters", 0) or 0) > 0 and | 2707 | (mp.get_property_number("chapters", 0) or 0) > 0 and |
| 2709 | true or false -- ensure it's a boolean | 2708 | true or false -- ensure it's a boolean |
| 2710 | | 2709 | |
| 2711 | if (want_watch ~= duration_watched) then | 2710 | if want_watch ~= duration_watched then |
| 2712 | if want_watch then | 2711 | if want_watch then |
| 2713 | mp.observe_property("duration", nil, on_duration) | 2712 | mp.observe_property("duration", nil, on_duration) |
| 2714 | else | 2713 | else |