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

[crop] Replace deprecated vf del #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion input.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ alt+c script-message-to crop start-crop soft
# delogo mode can be used like so
l script-message-to crop start-crop delogo
# remove the crop
d vf del -1
d script-message-to crop remove-crop

# or use the ready-made "toggle" binding
C script-message-to crop toggle-crop hard
Expand Down
26 changes: 25 additions & 1 deletion scripts/crop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,30 @@ function cancel_crop()
active = false
end

function remove_last_filter()
local vf_table = mp.get_property_native("vf")
local crop_filter_count = 0
local remove_last = 0

-- count filters
for i = 1, #vf_table do
if vf_table[i].name == "crop" or vf_table[i].name == "delogo" then
crop_filter_count = crop_filter_count + 1
remove_last = i
removed_filter_name = vf_table[i].name
end
end

-- remove last filter
if crop_filter_count > 0 then
table.remove(vf_table, remove_last)
mp.set_property_native("vf", vf_table)
mp.osd_message("Removed filter: #" .. tostring(crop_filter_count) .. " " .. removed_filter_name)
else
mp.osd_message("No filters to remove")
end
end

function start_crop(mode)
if active then return end
if not mp.get_property_native("osd-dimensions") then return end
Expand Down Expand Up @@ -429,6 +453,6 @@ bindings_repeat[opts.right_fine] = movement_func(opts.fine_movement, 0)
bindings_repeat[opts.up_fine] = movement_func(0, -opts.fine_movement)
bindings_repeat[opts.down_fine] = movement_func(0, opts.fine_movement)


mp.add_key_binding(nil, "remove-crop", remove_last_filter)
mp.add_key_binding(nil, "start-crop", start_crop)
mp.add_key_binding(nil, "toggle-crop", toggle_crop)