Skip to content

Commit

Permalink
Merge pull request #3266 from CommandPost/issue/2260-toggle-keyframes
Browse files Browse the repository at this point in the history
Added actions to Toggle Video Inspector Keyframes
  • Loading branch information
latenitefilms committed Aug 31, 2023
2 parents 6360da0 + 0c77d28 commit 7683a41
Show file tree
Hide file tree
Showing 7 changed files with 387 additions and 51 deletions.
Expand Up @@ -291,6 +291,22 @@ local function simple(labelKey, prepareFn, index)
row.reset = Button(row, function() return childFromRight(row:children(), 1) end)
row.keyframe = Button(row, function() return childFromRight(row:children(), 2, Button.matches) end)
function row.keyframe:addKeyframe()
local ui = self:UI()
if ui then
local f = ui:attributeValue("AXFrame")
if f then
local point = {
x = f.x + f.w - 5,
y = f.y + (f.h / 2)
}
tools.ninjaMouseClick(point)
end
end
end
if prepareFn then
prepareFn(row)
end
Expand Down
1 change: 1 addition & 0 deletions src/extensions/languages/English_en.json
Expand Up @@ -2424,6 +2424,7 @@
"toggleControls": "Toggle Controls",
"toggleDaVinciResolveControlSurfaceSupport": "Toggle DaVinci Resolve Control Surface Support",
"toggleEffects": "Toggle Effects",
"toggleKeyframe": "Toggle Keyframe",
"toggleOpacityFadeHandlesInVideoAnimationPopupOnSelectedClips": "Toggle Opacity Fade Handles in Video Animation Popup on Selected Clips",
"toggleOpacityFadeHandlesInVideoAnimationPopupOnSelectedClipsDescription": "Due to a Final Cut Pro bug this doesn't work for clips in a Secondary Storyline",
"toggleOverlaysWithCapsLock": "Toggle Overlays with Caps Lock",
Expand Down
Expand Up @@ -5500,5 +5500,161 @@
{
"info": "Zoom the contents to fit the size of the Browser, Viewer, or Timeline",
"name": "Command Set Shortcuts.View.Zoom to Fit"
},
{
"info": "Adjusts the distort on the selected clip",
"name": "Video Inspector.Distort.Distort Bottom Left X",
"range": [
-5000,
5000
],
"reset": 0,
"step": 1,
"stepMin": 0.1
},
{
"info": "Adjusts the distort on the selected clip",
"name": "Video Inspector.Distort.Distort Bottom Left Y",
"range": [
-5000,
5000
],
"reset": 0,
"step": 1,
"stepMin": 0.1
},
{
"info": "Adjusts the distort on the selected clip",
"name": "Video Inspector.Distort.Distort Bottom Right X",
"range": [
-5000,
5000
],
"reset": 0,
"step": 1,
"stepMin": 0.1
},
{
"info": "Adjusts the distort on the selected clip",
"name": "Video Inspector.Distort.Distort Bottom Right Y",
"range": [
-5000,
5000
],
"reset": 0,
"step": 1,
"stepMin": 0.1
},
{
"info": "Adjusts the distort on the selected clip",
"name": "Video Inspector.Distort.Distort Top Right X",
"range": [
-5000,
5000
],
"reset": 0,
"step": 1,
"stepMin": 0.1
},
{
"info": "Adjusts the distort on the selected clip",
"name": "Video Inspector.Distort.Distort Top Right Y",
"range": [
-5000,
5000
],
"reset": 0,
"step": 1,
"stepMin": 0.1
},
{
"info": "Adjusts the distort on the selected clip",
"name": "Video Inspector.Distort.Distort Top Left X",
"range": [
-5000,
5000
],
"reset": 0,
"step": 1,
"stepMin": 0.1
},
{
"info": "Adjusts the distort on the selected clip",
"name": "Video Inspector.Distort.Distort Top Left Y",
"range": [
-5000,
5000
],
"reset": 0,
"step": 1,
"stepMin": 0.1
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Compositing.Opacity.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Transform.Position.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Transform.Position.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Transform.Rotation.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Transform.Scale All.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Transform.Scale X.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Transform.Scale Y.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Transform.Anchor.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Crop.Left.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Crop.Right.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Crop.Top.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Crop.Bottom.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Distort.Bottom Left.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Distort.Bottom Right.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Distort.Top Right.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Video Inspector",
"name": "Video Inspector.Distort.Top Left.Toggle Keyframe"
},
{
"info": "Mouse clicks the Add/Remove Keyframe button in the Title Inspector",
"name": "Title Inspector.MotionVFX Title.Animation Amount.Toggle Keyframe"
}
]
@@ -1 +1 @@
GuJfvDxtBqHf8u0GN6pkbhwJydLCXJumfqT1Mvr3jFbpXOQRim2o8hepvIPI3WGowY+fDX+P7Vaw8uBfJ/uuvBWrnzZ83ZdZhvSurV0PaAkFhwQwclhwBxx4CyqPH9J0C64180G0YPrtMDscUTbiBGFSpJJ4rseSsBfWa42tYp9G1q8gERxBDEHewidBk6JtJJuLwEifnvykRSCn221PVQuTVejXs4iO7YJq2gnkcQ4wkhcI0UMWr4Bv6Zn1hfC1zpTonO91EhEiqV5yrMO10205dNngQD7fJwiJsqeVv3fCFJnZB3kkW0erRU0WzZUzAAbkHL1JvpKcphocvTWtdw==
J3/5NFB5Sms5qDME3aOf1COWGQXF9WY6EEL3OoplAp9I0kDDODRK70IV9Ii3CSBJGqYIQZINdjvqXLXmgrrzWrC5+KCGypnTysDxGkac6bFITnHj10rqh4jOwl4nnymHp3urFRNgwZu21pgQK0tezyvoj3FO7H9CNoMf3pM91bvoqdtxLS37GMc9oRJo6VmJM4h5rHdInqijgI4DRSotpbeLNDVygUIN9E49rO/lMifUF87SQanKsy3yOR2/IBeD/dtht30WiOJjrS9C/0ThMwQCI7SrfU2lEs6mlCHmvFZysj49ePCWdHA/s/L2HY843fR57/2k9tiRC662wN92JA==
112 changes: 62 additions & 50 deletions src/plugins/finalcutpro/inspector/title.lua
Expand Up @@ -4,13 +4,14 @@

local require = require

local log = require "hs.logger".new "titleInspector"
--local log = require "hs.logger".new "titleInspector"

local axutils = require "cp.ui.axutils"
local deferred = require "cp.deferred"
local fcp = require "cp.apple.finalcutpro"
local tools = require "cp.tools"

local Button = require "cp.ui.Button"
local Slider = require "cp.ui.Slider"
local TextField = require "cp.ui.TextField"

Expand All @@ -22,17 +23,11 @@ local plugin = {
group = "finalcutpro",
dependencies = {
["finalcutpro.commands"] = "fcpxCmds",
["core.monogram.manager"] = "manager",
}
}

local mod = {}

-- DEFER_VALUE -> number
-- Constant
-- How long we should defer all the update functions.
local DEFER_VALUE = 0.01

--- plugins.finalcutpro.inspector.title.motionVFXAnimationTextField -> cp.ui.TextField
--- Field
--- MotionVFX Title Animation Amount Text Field
Expand All @@ -58,47 +53,65 @@ mod.motionVFXAnimationAmountSlider = Slider(fcp.inspector.title, function()
return animationAmountSliderUI
end)

--- plugins.finalcutpro.inspector.title.motionVFXAnimationAmountAddKeyframe -> cp.ui.Button
--- Field
--- MotionVFX Title Animation Amount Add Keyframe Button
mod.motionVFXAnimationAmountAddKeyframeButton = Button(fcp.inspector.title, function()
local title = fcp.inspector.title
local ui = title and title:UI()
local groupA = ui and axutils.childAtIndex(ui, 1)
local groupB = groupA and axutils.childAtIndex(groupA, 1)
local animationAmountSliderUI = groupB and axutils.childWithDescription(groupB, "animation amount add a keyframe")
return animationAmountSliderUI
end)

--- plugins.finalcutpro.inspector.title.motionVFXAnimationAmountDeleteKeyframe -> cp.ui.Button
--- Field
--- MotionVFX Title Animation Amount Delete Keyframe Button
mod.motionVFXAnimationAmountDeleteKeyframeButton = Button(fcp.inspector.title, function()
local title = fcp.inspector.title
local ui = title and title:UI()
local groupA = ui and axutils.childAtIndex(ui, 1)
local groupB = groupA and axutils.childAtIndex(groupA, 1)
local animationAmountSliderUI = groupB and axutils.childWithDescription(groupB, "animation amount delete keyframe")
return animationAmountSliderUI
end)

--- plugins.finalcutpro.inspector.title.motionVFXAnimationAmountAnimationButton -> cp.ui.Button
--- Field
--- MotionVFX Title Animation Amount Keyframe Button
mod.motionVFXAnimationAmountKeyframeButton = Button(fcp.inspector.title, function()
local title = fcp.inspector.title
local ui = title and title:UI()
local groupA = ui and axutils.childAtIndex(ui, 1)
local groupB = groupA and axutils.childAtIndex(groupA, 1)
local animationAmountSliderUI = groupB and axutils.childWithDescription(groupB, "animation amount animation button")
return animationAmountSliderUI
end)

-- Mirror the Slider to the Text Box, otherwise it doesn't update correctly:
mod.motionVFXAnimationAmountSlider.value:mirror(mod.motionVFXAnimationTextField.value)

-- makeSliderHandler(finderFn) -> function
-- Function
-- Creates a 'handler' for slider controls, applying them to the slider returned by the `finderFn`
--
-- Parameters:
-- * finderFn - a function that will return the slider to apply the value to.
--
-- Returns:
-- * a function that will receive the Monogram control metadata table and process it.
local function makeSliderHandler(finderFn)
local absolute
local shift = 0
local slider = finderFn()

local updateUI = deferred.new(DEFER_VALUE):action(function()

if slider:isShowing() then
if absolute then
slider:value(absolute)
absolute = nil
else
local current = slider:value()
slider:value(current + shift)
shift = 0
end
else
slider:show()
end
end)

return function(data)
if data.operation == "+" then
local increment = data.params and data.params[1]
shift = shift + increment
updateUI()
elseif data.operation == "=" then
absolute = data.params and data.params[1]
updateUI()
--- plugins.finalcutpro.inspector.title.toggleMotionVFXAnimationAmountKeyframe() -> none
--- Function
--- Toggles the MotionVFX Title Animation Amount Keyframe button.
---
--- Parameters:
--- * None
---
--- Returns:
--- * None
function mod.toggleMotionVFXAnimationAmountKeyframe()
mod.motionVFXAnimationAmountAddKeyframeButton:show()
local ui = mod.motionVFXAnimationAmountKeyframeButton:UI() or mod.motionVFXAnimationAmountAddKeyframeButton:UI() or mod.motionVFXAnimationAmountDeleteKeyframeButton:UI()
if ui then
local f = ui:attributeValue("AXFrame")
if f then
local point = {
x = f.x + f.w - 5,
y = f.y + (f.h / 2)
}
tools.ninjaMouseClick(point)
end
end
end
Expand Down Expand Up @@ -149,11 +162,10 @@ function plugin.init(deps)
end)
:titled("MotionVFX Title - Animation Amount - Set to Zero")

--------------------------------------------------------------------------------
-- MotionVFX - Title - Animation Amount - Monogram Slider:
--------------------------------------------------------------------------------
local registerAction = deps.manager.registerAction
registerAction("Title Inspector.MotionVFX Title.Animation Amount", makeSliderHandler(function() return mod.motionVFXAnimationAmountSlider end))
deps.fcpxCmds
:add("motionVFXAnimationAmountToggleKeyframe")
:whenActivated(mod.toggleMotionVFXAnimationAmountKeyframe)
:titled("MotionVFX Title - Animation Amount - Toggle Keyframe")

return mod
end
Expand Down

0 comments on commit 7683a41

Please sign in to comment.