Skip to content

Commit

Permalink
Added and action to control Timeline Zoom
Browse files Browse the repository at this point in the history
- Fixed some documentation bugs as well.
- Closes #2395
  • Loading branch information
latenitefilms committed Aug 17, 2020
1 parent db927ba commit 0aea37b
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 25 deletions.
10 changes: 7 additions & 3 deletions src/extensions/cp/apple/finalcutpro/prefs/Panel.lua
@@ -1,4 +1,8 @@
local require = require
--- === cp.apple.finalcutpro.prefs.Panel ===
---
--- Preferences Panel.

local require = require

local strings = require "cp.apple.finalcutpro.strings"

Expand All @@ -8,8 +12,8 @@ local Group = require "cp.ui.Group"

local If = require "cp.rx.go".If

local childMatching = axutils.childMatching
local childWith = axutils.childWith
local childMatching = axutils.childMatching
local childWith = axutils.childWith

local Panel = Group:subclass("cp.apple.finalcutpro.prefs.Panel")

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/cp/apple/finalcutpro/timeline/Timeline.lua
Expand Up @@ -437,7 +437,7 @@ function Timeline.lazy.value:transitions()
end

--- cp.apple.finalcutpro.timeline.Timeline.playhead <Playhead>
--- Value
--- Field
--- The Timeline Playhead.
function Timeline.lazy.value:playhead()
return self.contents.playhead
Expand Down
9 changes: 9 additions & 0 deletions src/extensions/cp/ui/List.lua
Expand Up @@ -25,6 +25,15 @@ function List.static.matches(element)
end

--- cp.ui.List(parent, uiFinder, itemAdaptorFn)
--- Constructor
--- Creates a new List.
---
--- Parameters:
--- * parent - The parent table. Should have a `isShowing` property.
--- * uiFinder - The `function` or `cp.prop` that provides the current `hs._asm.axuielement`.
---
--- Returns:
--- * The new `List` instance.
function List:initialize(parent, uiFinder, itemAdaptorFn)
if type(itemAdaptorFn) ~= "function" then
error("The itemAdaptor must be a function")
Expand Down
4 changes: 4 additions & 0 deletions src/extensions/languages/English.json
Expand Up @@ -281,6 +281,7 @@
"controlFCPUIElementAbsolute": "Control Final Cut Pro User Interface Element (Absolute)",
"controlFCPUIElementRelative": "Control Final Cut Pro User Interface Element (Relative)",
"controlFCPUIElementRelativeNote": "Hover mouse over a UI Element, hold CONTROL, then adjust MIDI Knob/Fader to register.",
"controlsTimelineZoomViaTheAppearancePopup": "Controls Timeline Zoom via the Appearance Popup",
"controlSurfaces": "Control Surfaces",
"copy": "Copy",
"copyActiveApplicationTo": "Copy Active Application To",
Expand All @@ -298,6 +299,7 @@
"core_accessibility_screenrecording_label": "Screen Recording Permissions",
"core_action_manager_label": "Manager: Actions",
"core_application_manager_label": "Application Manager",
"core_audioswift_prefs_label": "Preferences: AudioSwift",
"core_commands_actions_label": "Commands Actions",
"core_commands_global_label": "Global Commands",
"core_console_applications_label": "Console: Applications",
Expand All @@ -316,6 +318,7 @@
"core_helpandsupport_userguide_label": "Help & Support: User Guide",
"core_language_label": "Language Module",
"core_loupedeck_prefs_label": "Preferences: Loupedeck",
"core_loupedeckct_changeapplications_label": "Loupedeck CT Applications",
"core_loupedeckct_manager_label": "Loupedeck CT Manager",
"core_loupedeckct_prefs_label": "Preferences: Loupedeck CT",
"core_loupedeckplus_banks_label": "Loupedeck+: Banks",
Expand Down Expand Up @@ -931,6 +934,7 @@
"finalcutpro_timeline_transcode_label": "Timeline: Transcode",
"finalcutpro_timeline_transitions_label": "Timeline: Transitions",
"finalcutpro_timeline_videoeffects_label": "Timeline: Video Effects",
"finalcutpro_timeline_zoom_label": "Timeline: Zoom",
"finalcutpro_timeline_zoomtoselection_label": "Timeline: Zoom to Selection",
"finalcutpro_toolbox_fcpxmltitles_label": "Toolbox: FCPXML Titles",
"finalcutpro_touchbar_manager_label": "Manager: Touch Bar",
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/core/midi/manager/init.lua
Expand Up @@ -87,14 +87,14 @@ mod.controls = controls
-- A table of all the MIDI actions.
local midiActions = {}

--- deviceNames -> table
--- Variable
--- MIDI Device Names.
-- deviceNames -> table
-- Variable
-- MIDI Device Names.
local deviceNames = {}

--- virtualDevices -> table
--- Variable
--- MIDI Virtual Devices.
-- virtualDevices -> table
-- Variable
-- MIDI Virtual Devices.
local virtualDevices = {}

-- loupedeckFnPressed -> boolean
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/core/tangent/manager/action.lua
Expand Up @@ -38,7 +38,7 @@ function action.lazy.prop:localActive()
return prop.THIS(self._localActive == true)
end

--- plugin.core.tangent.manager.action.active <cp.prop: boolean; read-only>
--- plugins.core.tangent.manager.action.active <cp.prop: boolean; read-only>
--- Field
--- Indicates if the action is active. It will only be active if
--- the current action is `enabled` and if the parent group (if present) is `active`.
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/core/tangent/manager/controls.lua
Expand Up @@ -29,14 +29,14 @@ function controls:initialize()
self.ids = {}
end

--- plugins.core.tangent.controls.enabled <cp.prop: boolean>
--- Field
--- Indicates if the controls are enabled.
--- plugins.core.tangent.manager.controls.enabled <cp.prop: boolean>
--- Field
--- Indicates if the controls are enabled.
function controls.lazy.prop.enabled()
return prop.TRUE()
end

--- plugins.core.tangent.controls.active <cp.prop: boolean; read-only>
--- plugins.core.tangent.manager.controls.active <cp.prop: boolean; read-only>
--- Field
--- Indicates if the controls are active. They will be active if `enabled` is `true`.
function controls.lazy.prop:active()
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/core/tangent/manager/group.lua
Expand Up @@ -57,7 +57,7 @@ function group.lazy.prop:localActive()
return prop.THIS(self._localActive == true)
end

--- plugin.core.tangent.manager.group.active <cp.prop: boolean; read-only>
--- plugins.core.tangent.manager.group.active <cp.prop: boolean; read-only>
--- Field
--- Indicates if the group is active. It will only be active if
--- the current group is `enabled` and if the parent group (if present) is `active`.
Expand All @@ -79,7 +79,7 @@ function group.static.is(thing)
return type(thing) == "table" and thing.isInstanceOf ~= nil and thing:isInstanceOf(group)
end

--- plugin.core.tangent.manager.group:name() -> string
--- plugins.core.tangent.manager.group:name() -> string
--- Method
--- Returns the `name` given to the group.
---
Expand Down
16 changes: 8 additions & 8 deletions src/plugins/core/tangent/manager/named.lua
Expand Up @@ -21,7 +21,7 @@ local named = class "core.tangent.manager.named" :include(lazy)

local NAMES_KEY = {}

--- hub.named(id, name[, parent]) -> named
--- plugins.core.tangent.manager.named(id, name[, parent]) -> named
--- Constructor
--- Creates a new `named` instance, with the specified base name.
---
Expand All @@ -34,17 +34,17 @@ function named:initialize(id, name, parent)
self._name = name
end

-- --- plugins.core.tangent.manager.parameter.enabled <cp.prop: boolean>
-- --- Field
-- --- Indicates if the parameter is enabled.
--- plugins.core.tangent.manager.named.enabled <cp.prop: boolean>
--- Field
--- Indicates if the parameter is enabled.
function named.lazy.prop.enabled()
return prop.TRUE()
end

-- --- plugin.core.tangent.manager.parameter.active <cp.prop: boolean; read-only>
-- --- Field
-- --- Indicates if the parameter is active. It will only be active if
-- --- the current parameter is `enabled` and if the parent group (if present) is `active`.
--- plugins.core.tangent.manager.named.active <cp.prop: boolean; read-only>
--- Field
--- Indicates if the parameter is active. It will only be active if
--- the current parameter is `enabled` and if the parent group (if present) is `active`.
function named.lazy.prop:active()
local parent = self:parent()
return parent and parent.active:AND(self.enabled) or self.enabled:IMMUTABLE()
Expand Down
58 changes: 58 additions & 0 deletions src/plugins/finalcutpro/timeline/zoom.lua
@@ -0,0 +1,58 @@
--- === plugins.finalcutpro.timeline.zoom ===
---
--- Action for changing Final Cut Pro's Timeline Zoom Level

local require = require

local timer = require "hs.timer"

local deferred = require "cp.deferred"
local fcp = require "cp.apple.finalcutpro"
local i18n = require "cp.i18n"

local delayed = timer.delayed

local plugin = {
id = "finalcutpro.timeline.zoom",
group = "finalcutpro",
dependencies = {
["finalcutpro.commands"] = "fcpxCmds",
}
}

function plugin.init(deps)
local fcpxCmds = deps.fcpxCmds
local appearance = fcp.timeline.toolbar.appearance

local appearancePopUpCloser = delayed.new(1, function()
appearance:hide()
end)

local zoomShift = 0
local updateZoom = deferred.new(0.0000001):action(function()
appearance:show()
appearance.zoomAmount:shiftValue(zoomShift)
zoomShift = 0
appearancePopUpCloser:start()
end)

fcpxCmds
:add("timelineZoomIncrease")
:whenActivated(function()
zoomShift = zoomShift + 0.2
updateZoom()
end)
:titled(i18n("timelineZoom") .. " " .. i18n("increase"))
:subtitled(i18n("controlsTimelineZoomViaTheAppearancePopup"))

fcpxCmds
:add("timelineZoomDecrease")
:whenActivated(function()
zoomShift = zoomShift - 0.2
updateZoom()
end)
:titled(i18n("timelineZoom") .. " " .. i18n("decrease"))
:subtitled(i18n("controlsTimelineZoomViaTheAppearancePopup"))
end

return plugin

0 comments on commit 0aea37b

Please sign in to comment.