-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
119 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,58 @@ | ||
local runner = require('command.runner') | ||
local state_interface = require('state_machine.state_interface') | ||
local config = require 'definitions.config'.general | ||
local unselectAllButLastTouchedTrack = require('custom_actions.utils').unselectAllButLastTouchedTrack | ||
|
||
local function normalTrackMotion(track_operator, track_motion) | ||
runner.runAction("SaveTrackSelection") | ||
runner.makeSelectionFromTrackMotion(track_motion, 1) | ||
runner.runAction(track_operator) | ||
if type(track_operator) ~= 'table' or not track_operator['setTrackSelection'] then | ||
runner.runAction("RestoreTrackSelection") | ||
end | ||
end | ||
|
||
local function normalTrackSelector(track_operator, track_selector) | ||
runner.runAction("SaveTrackSelection") | ||
runner.runAction(track_selector) | ||
runner.runAction(track_operator) | ||
if type(track_operator) ~= 'table' or not track_operator['setTrackSelection'] then | ||
runner.runAction("RestoreTrackSelection") | ||
end | ||
end | ||
|
||
local function visualTrackTrackOperator(track_operator) | ||
runner.runAction(track_operator) | ||
state_interface.setModeToNormal() | ||
if not config.persist_visual_track_selection and (type(track_operator) ~= 'table' or not track_operator['setTrackSelection']) then | ||
local track = reaper.GetLastTouchedTrack() | ||
if track then reaper.SetOnlyTrackSelected(track) end | ||
end | ||
end | ||
|
||
local function visualTrackTrackMotion(track_motion) | ||
local args = { track_motion, 1 } | ||
local sel_function = runner.makeSelectionFromTrackMotion | ||
runner.extendTrackSelection(sel_function, args) | ||
end | ||
|
||
local function visualTrackTimelineMotion(timeline_motion) | ||
if config.allow_timeline_movement_in_visual_mode then | ||
runner.runAction(timeline_motion) | ||
end | ||
end | ||
|
||
---@type ActionModes | ||
return { | ||
all_modes = { | ||
{ { 'track_motion' }, runner.runAction } | ||
}, | ||
all_modes = { { { 'track_motion' }, runner.runAction } }, | ||
normal = { | ||
{ | ||
{ 'track_operator', 'track_motion' }, | ||
function(track_operator, track_motion) | ||
runner.runAction("SaveTrackSelection") | ||
runner.makeSelectionFromTrackMotion(track_motion, 1) | ||
runner.runAction(track_operator) | ||
if type(track_operator) ~= 'table' or not track_operator['setTrackSelection'] then | ||
runner.runAction("RestoreTrackSelection") | ||
end | ||
end | ||
}, | ||
{ | ||
{ 'track_operator', 'track_selector' }, | ||
function(track_operator, track_selector) | ||
runner.runAction("SaveTrackSelection") | ||
runner.runAction(track_selector) | ||
runner.runAction(track_operator) | ||
if type(track_operator) ~= 'table' or not track_operator['setTrackSelection'] then | ||
runner.runAction("RestoreTrackSelection") | ||
end | ||
end | ||
}, | ||
{ { 'track_operator', 'track_motion' }, normalTrackMotion }, | ||
{ { 'track_operator', 'track_selector' }, normalTrackSelector }, | ||
}, | ||
visual_track = { | ||
{ { 'visual_track_command' }, runner.runAction }, | ||
{ | ||
{ 'track_operator' }, | ||
function(track_operator) | ||
runner.runAction(track_operator) | ||
state_interface.setModeToNormal() | ||
if not config.persist_visual_track_selection and (type(track_operator) ~= 'table' or not track_operator['setTrackSelection']) then | ||
unselectAllButLastTouchedTrack() | ||
end | ||
end | ||
}, | ||
{ { 'track_operator' }, visualTrackTrackOperator }, | ||
{ { 'track_selector' }, runner.runAction }, | ||
{ | ||
{ 'track_motion' }, | ||
function(track_motion) | ||
local args = { track_motion, 1 } | ||
local sel_function = runner.makeSelectionFromTrackMotion | ||
runner.extendTrackSelection(sel_function, args) | ||
end | ||
}, | ||
{ | ||
{ 'timeline_motion' }, | ||
function(timeline_motion) | ||
if config.allow_timeline_movement_in_visual_mode then | ||
runner.runAction(timeline_motion) | ||
end | ||
end | ||
}, | ||
{ { 'track_motion' }, visualTrackTrackMotion }, | ||
{ { 'timeline_motion' }, visualTrackTimelineMotion }, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters