summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-02-23 22:31:03 +0100
committerRobin Gareus <robin@gareus.org>2017-02-23 22:32:32 +0100
commit1e4e97019da3e90f89614da51ac537ed2041bb55 (patch)
tree0f8177b0fa20002f475a614e0d907634dbd71338 /scripts
parent71fd94b422574d1efbcce1ab85c6ce3da22ba450 (diff)
Lua bindings to access editor selection + region selection bindings
Diffstat (limited to 'scripts')
-rw-r--r--scripts/select_every_2nd_region.lua42
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/select_every_2nd_region.lua b/scripts/select_every_2nd_region.lua
new file mode 100644
index 0000000000..4e6d156f5a
--- /dev/null
+++ b/scripts/select_every_2nd_region.lua
@@ -0,0 +1,42 @@
+ardour {
+ ["type"] = "EditorAction",
+ name = "Region Select/2",
+ license = "MIT",
+ author = "Ardour Team",
+ description = [[select every 2nd region on all selected tracks]]
+}
+
+-- select every 2nd region on all selected tracks
+function factory () return function ()
+
+ local sl = ArdourUI.SelectionList () -- empty selection list
+
+ local sel = Editor:get_selection () -- get current selection
+ -- for each selected track/bus..
+ for route in sel.tracks:routelist ():iter () do
+ -- consider only tracks
+ local track = route:to_track ()
+ if track:isnil() then
+ goto continue
+ end
+
+ local skip = false;
+ -- iterate over all regions of the given track
+ for region in track:playlist():region_list():iter() do
+ if skip then
+ -- skip every 2nd region
+ skip = false;
+ else
+ skip = true;
+ -- get RegionView (GUI object to be selected)
+ local rv = Editor:get_regionview_from_region (region)
+ -- add it to the list of Objects to be selected
+ sl:push_back (rv);
+ end
+ end
+ ::continue::
+ end
+
+ -- set/replace current selection in the editor
+ Editor:set_selection (sl, ArdourUI.SelectionOp.Set);
+end end