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

Update CommandPost Overlays in Final Cut Pro to make use of FCPX Custom Overlays #2720

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
399 changes: 399 additions & 0 deletions src/extensions/cp/apple/finalcutpro/viewer/CustomOverlay.lua

Large diffs are not rendered by default.

41 changes: 40 additions & 1 deletion src/extensions/cp/apple/finalcutpro/viewer/Viewer.lua
Expand Up @@ -19,6 +19,7 @@ local notifier = require "cp.ui.notifier"
local prop = require "cp.prop"

local ControlBar = require "cp.apple.finalcutpro.viewer.ControlBar"
local CustomOverlay = require "cp.apple.finalcutpro.viewer.CustomOverlay"
local InfoBar = require "cp.apple.finalcutpro.viewer.InfoBar"
local PrimaryWindow = require "cp.apple.finalcutpro.main.PrimaryWindow"
local SecondaryWindow = require "cp.apple.finalcutpro.main.SecondaryWindow"
Expand Down Expand Up @@ -281,7 +282,9 @@ end
--- Field
--- The `Image` for the video content.
function Viewer.lazy.value:videoImage()
return Image(self, self.videoImageUI)
local videoImage = Image(self, self.videoImageUI)
videoImage.frame:monitor(self.frame)
return videoImage
end

--- cp.apple.finalcutpro.viewer.Viewer.infoBar <cp.apple.finalcutpro.viewer.InfoBar>
Expand Down Expand Up @@ -502,6 +505,42 @@ function Viewer.lazy.prop:framerate()
return self.infoBar.framerate
end

-----------------------------------------------------------------------
--
-- OVERLAYS:
--
-----------------------------------------------------------------------

--- cp.apple.finalcutpro.viewer.Viewer.isOverlayEnabled <cp.prop: boolean; live>
--- Field
--- Specifies if the custom overlay is enabled.
function Viewer.lazy.prop:isOverlayEnabled()
if self:isEventViewer() then
return CustomOverlay.isEnabledOnEventViewer
else
return CustomOverlay.isEnabledOnViewer
end
end

--- cp.apple.finalcutpro.viewer.Viewer.overlay <cp.prop: CustomOverlay; live>
--- Field
--- The current `CustomOverlay` instance. May be `nil` if none is specified.
--- May also be specified even if the overlay for the `Viewer` isn't enabled.
function Viewer.lazy.prop:overlay()
if self:isEventViewer() then
return CustomOverlay.eventViewerOverlay
else
return CustomOverlay.viewerOverlay
end
end

--- cp.apple.finalcutpro.viewer.Viewer.userOverlays <cp.prop: table of CustomOverlay; read-only>
--- Constant
--- Contains the current list of `CustomOverlay`s available.
function Viewer.lazy.prop.userOverlays()
return CustomOverlay.userOverlays
end

-----------------------------------------------------------------------
--
-- BROWSER UI:
Expand Down
3 changes: 3 additions & 0 deletions src/extensions/cp/prop/init.lua
Expand Up @@ -693,6 +693,9 @@ local NOTHING = {}
--- Notes:
--- * You can watch immutable values. Wrapped `cp.prop` instances may not be immutable, and any changes to them will cause watchers to be notified up the chain.
function prop.mt:watch(watchFn, notifyNow, uncloned)
if watchFn == nil then
error("the watchFn was nil", 2)
end
if not self._watchers then
self._watchers = {}
end
Expand Down
14 changes: 14 additions & 0 deletions src/extensions/cp/tools/init.lua
Expand Up @@ -1836,6 +1836,20 @@ function tools.getFileExtensionFromPath(path)
end
end

--- cp.tools.getNameAndExtensionFromFile(file) -> string, string | nil
--- Function
--- Extracts the name and the extension for the provided file name (eg. "foo.bar" -> "foo", "bar").
--- Does not remove any preceding path values from the string first.
---
--- Parameters:
--- * file - The `string` for the file name (eg. "image.jpg").
---
--- Returns:
--- * The name and extension strings, or `nil` if the file has no extension.
function tools.getNameAndExtensionFromFile(file)
return string.match(file, "^(.*)%.([^%.]+)$")
end

--- cp.tools.removeFilenameFromPath(string) -> string
--- Function
--- Removes the filename from a path.
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/core/menu/manager/init.lua
Expand Up @@ -185,6 +185,9 @@ function mod.generateMenuTable()
return mod.rootSection:generateMenuTable()
end

-- Makes the `section` API accessible outside the menu manger.
mod.section = section

local plugin = {
id = "core.menu.manager",
group = "core",
Expand Down