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

Various Improvements & Changes to cp.ui #3000

Draft
wants to merge 38 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e48b65c
Fixed bottomUp sort, added test cases
randomeizer Apr 28, 2022
10e5bc9
New implementation of ElementCache
randomeizer Apr 29, 2022
4c5f939
Stickler fix
randomeizer Apr 29, 2022
89d968c
Added `Element:inspect()` to allow easier inspection
randomeizer Apr 29, 2022
0465c37
Added `Menu:doSelectItemWhere(predicate)` to allow predicate selection
randomeizer Apr 29, 2022
4fdc39b
Added cp.slice
randomeizer May 19, 2022
db54798
Fixed bug in is_spec
randomeizer May 19, 2022
a4709de
Added fn.equals
randomeizer May 19, 2022
117b7ca
Fixed bug when checking elements with no AXFrame
randomeizer May 19, 2022
c809273
Fixed some documentation
randomeizer May 19, 2022
1925fc0
Initial commit of `cp.ui.has` api
randomeizer May 31, 2022
09b76dc
Additional handlers for `cp.ui.has` API.
randomeizer May 31, 2022
c3251f1
Added SynchronizeClipSheets, using `cp.ui.has`
randomeizer May 31, 2022
bc2bb0f
Improved `tostring` output for basic UI elements.
randomeizer May 31, 2022
2c2aa21
Improvements to cp.ui.has and related classes
randomeizer Jun 1, 2022
3426627
Big update.
randomeizer Jun 2, 2022
1f5fe91
Fixed some issues with ElementRepeater.
randomeizer Jun 2, 2022
5d6d281
Merge branch 'develop' into play/improve-ui
randomeizer Jun 3, 2022
8a917a2
Added `isClassFor`, `isSuperclassFor`, `isSuperclassOf` to `middlecla…
randomeizer Jun 4, 2022
0970ac3
Lots of documentation and tweaks.
randomeizer Jul 12, 2022
a4262ac
Merge branch 'develop' into play/improve-ui
randomeizer Jul 12, 2022
d91a7f8
Improvements to applying video/audio effects with new UI system
randomeizer Jul 14, 2022
7c7d1f1
Merge branch 'develop' into play/improve-ui
latenitefilms Aug 13, 2022
c720666
Fixed @stickler-ci complaints
latenitefilms Aug 13, 2022
a1b5198
Fixed @stickler-ci errors
latenitefilms Aug 13, 2022
43b5f7b
Fixed @stickler-ci complaints
latenitefilms Aug 13, 2022
1ac71d3
Merge branch 'develop' into play/improve-ui
latenitefilms Aug 18, 2022
a9fb830
* Fixed Generator `apply` operations
randomeizer Aug 25, 2022
132db49
Merge branch 'play/improve-ui' of github.com:CommandPost/CommandPost …
randomeizer Aug 25, 2022
f03d006
Stickler fix
randomeizer Aug 25, 2022
8afc105
Minor tweaks to documentation etc.
randomeizer Aug 28, 2022
8463c66
Initial fixes for Titles, still not fully ported from Generators update
randomeizer Aug 28, 2022
852bf15
Fixed applying of titles.
randomeizer Aug 28, 2022
ddca951
Added UI for 'New Multicam Clip" Sheet
randomeizer Aug 28, 2022
e8fd109
* Added CompoundClipSheet and `PrimaryWindow.compoundClip`
randomeizer Aug 28, 2022
72afab7
Fixed typos in documentation/cynchronizedClip
randomeizer Aug 29, 2022
7cd4475
Added layout saving/loading on SynchronizedClipSheet.
randomeizer Dec 20, 2022
7d91fb5
Merge branch 'develop' into play/improve-ui
randomeizer Dec 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 27 additions & 20 deletions src/extensions/cp/apple/finalcutpro/cmd/CommandDetail.lua
@@ -1,6 +1,8 @@
--- === cp.apple.finalcutpro.cmd.CommandDetail ===
---
--- This class provides a UI for displaying the details of a command when it is selected on the `CommandList`.
---
--- Extends: [Group](cp.ui.Group.md)

local require = require

Expand All @@ -12,9 +14,11 @@ local Group = require "cp.ui.Group"
local StaticText = require "cp.ui.StaticText"
local ScrollArea = require "cp.ui.ScrollArea"
local TextArea = require "cp.ui.TextArea"
local has = require "cp.ui.has"

local chain = fn.chain
local matchesExactItems = fn.table.matchesExactItems
local list, alias = has.list, has.alias

local CommandDetail = Group:subclass("cp.apple.finalcutpro.cmd.CommandDetail")

Expand Down Expand Up @@ -46,39 +50,42 @@ CommandDetail.static.matches = ax.matchesIf(
)
)

-- cp.apple.finalcutpro.cmd.CommandDetail._contentGroupUI <cp.prop: axuielement>
-- Field
-- The [axuielement](cp.prop.axuielement) for the content Group.
function CommandDetail.lazy.prop:_contentGroupUI()
return self.UI:mutate(ax.childMatching(Group.matches))
end
--- cp.apple.finalcutpro.cmd.CommandDetail.children <cp.ui.has.UIHandler>
--- Constant
--- UI Handler for the children of this class.
CommandDetail.static.children = list {
Group:containing {
alias "label" { StaticText },
alias "detail" { ScrollArea:containing(TextArea) }
}
}

-- cp.apple.finalcutpro.cmd.CommandDetail._labelUI <cp.prop: axuielement>
-- Field
-- The [axuielement](cp.prop.axuielement) for the label.
function CommandDetail.lazy.prop:_labelUI()
return self._contentGroupUI:mutate(ax.childMatching(StaticText.matches))
--- cp.apple.finalcutpro.cmd.CommandDetail(parent, uiFinder) -> cp.apple.finalcutpro.cmd.CommandDetail
--- Constructor
--- Creates a new CommandDetail.
---
--- Parameters:
--- * parent - The parent object.
--- * uiFinder - The uiFinder object.
---
--- Returns:
--- * The new CommandDetail object.
function CommandDetail:initialize(parent, uiFinder)
Group.initialize(self, parent, uiFinder, CommandDetail.children)
end

--- cp.apple.finalcutpro.cmd.CommandDetail.label <cp.ui.StaticText>
--- Field
--- The StaticText that displays the label.
function CommandDetail.lazy.value:label()
return StaticText(self, self._labelUI)
end

-- cp.apple.finalcutpro.cmd.CommandDetail._detailUI <cp.prop: axuielement>
-- Field
-- The [axuielement](cp.prop.axuielement) for the detail `AXScrollArea`.
function CommandDetail.lazy.prop:_detailUI()
return self._contentGroupUI:mutate(ax.childMatching(ScrollArea.matches))
return self.children[1].label
end

--- cp.apple.finalcutpro.cmd.CommandDetail.detail <cp.ui.ScrollArea>
--- Field
--- The [ScrollArea](cp.ui.ScrollArea.md) that displays the contained [TextArea](cp.ui.TextArea.md).
function CommandDetail.lazy.value:detail()
return ScrollArea:containing(TextArea)(self, self._detailUI)
return self.children[1].detail
end

--- cp.apple.finalcutpro.cmd.CommandDetail.contents <cp.ui.TextArea>
Expand Down
126 changes: 72 additions & 54 deletions src/extensions/cp/apple/finalcutpro/cmd/CommandEditor.lua
@@ -1,18 +1,22 @@
--- === cp.apple.finalcutpro.cmd.CommandEditor ===
---
--- Command Editor Module.
---
--- Extends: [Dialog](cp.ui.Dialog.md)

local require = require

local log = require "hs.logger" .new "CmdEditor"

local just = require "cp.just"

local has = require "cp.ui.has"
local Button = require "cp.ui.Button"
local CheckBox = require "cp.ui.CheckBox"
local Dialog = require "cp.ui.Dialog"
local Group = require "cp.ui.Group"
local PopUpButton = require "cp.ui.PopUpButton"
local StaticText = require "cp.ui.StaticText"
local TextField = require "cp.ui.TextField"

local CommandDetail = require "cp.apple.finalcutpro.cmd.CommandDetail"
Expand All @@ -29,7 +33,9 @@ local WaitUntil = require "cp.rx.go.WaitUntil"
local fn = require "cp.fn"
local ax = require "cp.fn.ax"
local chain = fn.chain
local get, sort = fn.table.get, fn.table.sort
local get = fn.table.get

local list, alias, oneOf = has.list, has.alias, has.oneOf

local CommandEditor = Dialog:subclass("cp.apple.finalcutpro.cmd.CommandEditor")

Expand All @@ -48,7 +54,7 @@ CommandEditor.static.matches = ax.matchesIf(
-- It's modal
get "AXModal",
-- It has the required children:
chain // ax.children >> sort(ax.topDown) >> fn.all(
chain // ax.childrenTopDown >> fn.all(
-- The `commandSet` PopUpButton ...
chain // get(5) >> PopUpButton.matches,
-- The `keyboard` Group...
Expand All @@ -58,6 +64,33 @@ CommandEditor.static.matches = ax.matchesIf(
)
)

CommandEditor.static.children = list {
alias "close" { Button }, alias "minimize" { Button }, alias "zoom" { Button },
alias "windowTitle" { StaticText },
alias "commandSet" { PopUpButton },
alias "modifiers" {
Group:containing {
alias "command" { CheckBox },
alias "shift" { CheckBox },
alias "option" { CheckBox },
alias "control" { CheckBox },
}
},
alias "keyboardToggle" { CheckBox },
alias "search" { TextField:forcingFocus(true) },
alias "keyboard" { Group },
alias "commandList" { CommandList },
alias "detail" {
oneOf {
alias "commandDetail" { CommandDetail },
alias "keyDetail" { KeyDetail },
},
},
Button, -- "Close"
alias "saveButton" { Button },
has.ended
}

--- cp.apple.finalcutpro.cmd.CommandEditor(app) -> CommandEditor
--- Constructor
--- Creates a new Command Editor object.
Expand Down Expand Up @@ -148,7 +181,7 @@ end
--- Returns:
--- * The `cp.apple.finalcutpro.cmd.CommandEditor` object for method chaining.
function CommandEditor:hide()
self.close:press()
self.closeButton:press()
return self
end

Expand Down Expand Up @@ -214,114 +247,103 @@ function CommandEditor.lazy.method:doClose()
return self.closeButton:doPress()
end

-- ==== Command Editor UI ====
-----------------------------------------------------------------------
-- Command Editor UI
-----------------------------------------------------------------------

--- cp.apple.finalcutpro.cmd.CommandEditor.save <cp.ui.Button>
--- cp.apple.finalcutpro.cmd.CommandEditor.childrenUI <cp.prop: axuielement; read-only; live?>
--- Field
--- The "Save" [Button](cp.ui.Button.md).
function CommandEditor.lazy.value:save()
return Button(self, self.UI:mutate(
ax.childMatching(Button.matches, 1, ax.bottomUp)
))
--- The `axuielement` list for the children of the Command Editor.
function CommandEditor.lazy.prop:childrenUI()
return ax.prop(self.UI, "AXChildren")
end

--- cp.apple.finalcutpro.cmd.CommandEditor.childrenInNavigationOrderUI <cp.prop: axuielement; read-only; live?>
--- Field
--- The `axuielement` list for the children of the Command Editor, in navigation order.
function CommandEditor.lazy.prop:childrenInNavigationOrderUI()
return ax.prop(self.UI, "AXChildrenInNavigationOrder")
end

--- cp.apple.finalcutpro.cmd.CommandEditor.children <cp.ui.has.ElementList>
--- Field
--- The [ElementList](cp.ui.ElementList.md) of the children of the Command Editor.
function CommandEditor.lazy.value:children()
return self.class.children:build(self, self.childrenInNavigationOrderUI)
end

--- cp.apple.finalcutpro.cmd.CommandEditor.closeButton <cp.ui.Button>
--- cp.apple.finalcutpro.cmd.CommandEditor.saveButton <cp.ui.Button>
--- Field
--- The "Close" [Button](cp.ui.Button.md).
function CommandEditor.lazy.value:closeButton()
return Button(self, self.UI:mutate(
ax.childMatching(Button.matches, 2, ax.bottomUp)
))
--- The "Save" [Button](cp.ui.Button.md).
function CommandEditor.lazy.value:saveButton()
return self.children.saveButton
end

--- cp.apple.finalcutpro.cmd.CommandEditor.commandSet <cp.ui.PopUpButton>
--- Field
--- The "Command Set" [PopUpButton](cp.ui.PopUpButton.md).
function CommandEditor.lazy.value:commandSet()
return PopUpButton(self, self.UI:mutate(
ax.childMatching(PopUpButton.matches)
))
end

--- cp.apple.finalcutpro.cmd.CommandEditor.modifiers <cp.ui.Group>
--- Field
--- The [Group](cp.ui.Group.md) containing 'modifier' checkboxes (Cmd, Shift, etc).
function CommandEditor.lazy.value:modifiers()
return Group(self, self.UI:mutate(
ax.childMatching(Group.matches, 1)
))
return self.children.modifiers
end

--- cp.apple.finalcutpro.cmd.CommandEditor.command <cp.ui.CheckBox>
--- Field
--- The "Command" [CheckBox](cp.ui.CheckBox.md).
function CommandEditor.lazy.value:command()
return CheckBox(self, self.modifiers.UI:mutate(
ax.childMatching(CheckBox.matches, 1)
))
return self.modifiers.children.command
end

--- cp.apple.finalcutpro.cmd.CommandEditor.shift <cp.ui.CheckBox>
--- Field
--- The "Shift" [CheckBox](cp.ui.CheckBox.md).
function CommandEditor.lazy.value:shift()
return CheckBox(self, self.modifiers.UI:mutate(
ax.childMatching(CheckBox.matches, 2)
))
return self.modifiers.children.shift
end

--- cp.apple.finalcutpro.cmd.CommandEditor.option <cp.ui.CheckBox>
--- Field
--- The "Option" [CheckBox](cp.ui.CheckBox.md).
function CommandEditor.lazy.value:option()
return CheckBox(self, self.modifiers.UI:mutate(
ax.childMatching(CheckBox.matches, 3)
))
return self.modifiers.children.option
end

--- cp.apple.finalcutpro.cmd.CommandEditor.control <cp.ui.CheckBox>
--- Field
--- The "Control" [CheckBox](cp.ui.CheckBox.md).
function CommandEditor.lazy.value:control()
return CheckBox(self, self.modifiers.UI:mutate(
ax.childMatching(CheckBox.matches, 4)
))
return self.modifiers.children.control
end

--- cp.apple.finalcutpro.cmd.CommandEditor.keyboardToggle <cp.ui.CheckBox>
--- Field
--- The "Keyboard Toggle" [CheckBox](cp.ui.CheckBox.md) (next to the Search field).
function CommandEditor.lazy.value:keyboardToggle()
return CheckBox(self, self.UI:mutate(
ax.childMatching(CheckBox.matches)
))
return self.children.keyboardToggle
end

--- cp.apple.finalcutpro.cmd.CommandEditor.search <cp.ui.TextField>
--- Field
--- The "Search" [TextField](cp.ui.TextField.md).
function CommandEditor.lazy.value:search()
return TextField(self, self.UI:mutate(
ax.childMatching(TextField.matches)
)):forceFocus()
return self.children.search
end

--- cp.apple.finalcutpro.cmd.CommandEditor.keyboard <cp.ui.Group>
--- Field
--- The [Group](cp.ui.Group.md) containing the keyboard shortcuts. Does not seem to expose the actual key buttons.
function CommandEditor.lazy.value:keyboard()
return Group(self, self.UI:mutate(
ax.childMatching(Group.matches, 2)
))
return self.children.keyboard
end

--- cp.apple.finalcutpro.cmd.CommandEditor.commandList <cp.apple.finalcutpro.cmd.CommandList>
--- Field
--- The [CommandList](cp.apple.finalcutpro.cmd.CommandList.md).
function CommandEditor.lazy.value:commandList()
return CommandList(self, self.UI:mutate(
ax.childMatching(CommandList.matches)
))
return self.children.commandList
end

--- cp.apple.finalcutpro.cmd.CommandEditor.commands <cp.apple.finalcutpro.cmd.Commands>
Expand All @@ -343,19 +365,15 @@ end
--- The [KeyDetail](cp.apple.finalcutpro.cmd.KeyDetail.md) section.
--- Either this or [commandDetail](#commandDetail) will be visible at any given time.
function CommandEditor.lazy.value:keyDetail()
return KeyDetail(self, self.UI:mutate(
ax.childMatching(KeyDetail.matches)
))
return self.children.detail.keyDetail
end

--- cp.apple.finalcutpro.cmd.CommandEditor.commandDetail <cp.apple.finalcutpro.cmd.CommandDetail>
--- Field
--- The [CommandDetail](cp.apple.finalcutpro.cmd.CommandDetail.md) section.
--- Either this or [keyDetail](#keyDetail) will be visible at any given time.
function CommandEditor.lazy.value:commandDetail()
return CommandDetail(self, self.UI:mutate(
ax.childMatching(CommandDetail.matches)
))
return self.children.detail.commandDetail
end

--- cp.apple.finalcutpro.cmd.CommandEditor:doFindCommandID(commandID, [highlight]) -> cp.rx.go.Statement
Expand Down