Lua bindings to access editor selection + region selection bindings
This commit is contained in:
parent
71fd94b422
commit
1e4e97019d
@ -5087,6 +5087,24 @@ Editor::get_regions_corresponding_to (boost::shared_ptr<Region> region, vector<R
|
||||
}
|
||||
}
|
||||
|
||||
RegionView*
|
||||
Editor::get_regionview_from_region (boost::shared_ptr<Region> region) const
|
||||
{
|
||||
for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
||||
RouteTimeAxisView* tatv;
|
||||
if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
|
||||
if (!tatv->track()) {
|
||||
continue;
|
||||
}
|
||||
RegionView* marv = tatv->view()->find_view (region);
|
||||
if (marv) {
|
||||
return marv;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
Editor::show_rhythm_ferret ()
|
||||
{
|
||||
|
@ -257,6 +257,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||
bool get_selection_extents (framepos_t &start, framepos_t &end) const; // the time extents of the current selection, whether Range, Region(s), Control Points, or Notes
|
||||
Selection& get_cut_buffer() const { return *cut_buffer; }
|
||||
|
||||
void set_selection (std::list<Selectable*>, Selection::Operation);
|
||||
|
||||
bool extend_selection_to_track (TimeAxisView&);
|
||||
|
||||
void play_selection ();
|
||||
@ -732,6 +734,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||
|
||||
void get_equivalent_regions (RegionView* rv, std::vector<RegionView*> &, PBD::PropertyID) const;
|
||||
RegionSelection get_equivalent_regions (RegionSelection &, PBD::PropertyID) const;
|
||||
RegionView* get_regionview_from_region (boost::shared_ptr<ARDOUR::Region>) const;
|
||||
|
||||
void mapover_tracks (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*, PBD::PropertyID) const;
|
||||
void mapover_tracks_with_unique_playlists (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*, PBD::PropertyID) const;
|
||||
|
||||
|
@ -893,6 +893,30 @@ out:
|
||||
return commit;
|
||||
}
|
||||
|
||||
void
|
||||
Editor::set_selection (std::list<Selectable*> s, Selection::Operation op)
|
||||
{
|
||||
if (s.empty()) {
|
||||
return;
|
||||
}
|
||||
begin_reversible_selection_op (X_("set selection"));
|
||||
switch (op) {
|
||||
case Selection::Toggle:
|
||||
selection->toggle (s);
|
||||
break;
|
||||
case Selection::Set:
|
||||
selection->set (s);
|
||||
break;
|
||||
case Selection::Extend:
|
||||
selection->add (s);
|
||||
break;
|
||||
case Selection::Add:
|
||||
selection->add (s);
|
||||
break;
|
||||
}
|
||||
|
||||
commit_reversible_selection_op () ;
|
||||
}
|
||||
|
||||
void
|
||||
Editor::set_selected_regionview_from_region_list (boost::shared_ptr<Region> region, Selection::Operation op)
|
||||
|
@ -37,8 +37,10 @@
|
||||
#include "luainstance.h"
|
||||
#include "luasignal.h"
|
||||
#include "marker.h"
|
||||
#include "region_view.h"
|
||||
#include "processor_box.h"
|
||||
#include "time_axis_view.h"
|
||||
#include "time_axis_view_item.h"
|
||||
#include "selection.h"
|
||||
#include "script_selector.h"
|
||||
#include "timers.h"
|
||||
@ -582,8 +584,17 @@ LuaInstance::register_classes (lua_State* L)
|
||||
.endClass ()
|
||||
#endif
|
||||
|
||||
.beginClass <Selectable> ("Selectable")
|
||||
.endClass ()
|
||||
.deriveClass <TimeAxisViewItem, Selectable> ("TimeAxisViewItem")
|
||||
.endClass ()
|
||||
.deriveClass <RegionView, TimeAxisViewItem> ("RegionView")
|
||||
.endClass ()
|
||||
|
||||
.beginStdCPtrList <Selectable> ("SelectionList")
|
||||
.endClass ()
|
||||
|
||||
.beginClass <RegionSelection> ("RegionSelection")
|
||||
.addFunction ("clear_all", &RegionSelection::clear_all)
|
||||
.addFunction ("start", &RegionSelection::start)
|
||||
.addFunction ("end_frame", &RegionSelection::end_frame)
|
||||
.addFunction ("n_midi_regions", &RegionSelection::n_midi_regions)
|
||||
@ -646,6 +657,8 @@ LuaInstance::register_classes (lua_State* L)
|
||||
.addFunction ("get_cut_buffer", &PublicEditor::get_cut_buffer)
|
||||
.addRefFunction ("get_selection_extents", &PublicEditor::get_selection_extents)
|
||||
|
||||
.addFunction ("set_selection", &PublicEditor::set_selection)
|
||||
|
||||
.addFunction ("play_selection", &PublicEditor::play_selection)
|
||||
.addFunction ("play_with_preroll", &PublicEditor::play_with_preroll)
|
||||
.addFunction ("maybe_locate_with_edit_preroll", &PublicEditor::maybe_locate_with_edit_preroll)
|
||||
@ -691,6 +704,8 @@ LuaInstance::register_classes (lua_State* L)
|
||||
.addFunction ("set_selected_mixer_strip", &PublicEditor::set_selected_mixer_strip)
|
||||
.addFunction ("hide_track_in_display", &PublicEditor::hide_track_in_display)
|
||||
#endif
|
||||
|
||||
.addFunction ("get_regionview_from_region", &PublicEditor::get_regionview_from_region)
|
||||
.addFunction ("set_stationary_playhead", &PublicEditor::set_stationary_playhead)
|
||||
.addFunction ("stationary_playhead", &PublicEditor::stationary_playhead)
|
||||
.addFunction ("set_follow_playhead", &PublicEditor::set_follow_playhead)
|
||||
@ -783,6 +798,13 @@ LuaInstance::register_classes (lua_State* L)
|
||||
.addConst ("PunchOut", ArdourMarker::Type(ArdourMarker::PunchOut))
|
||||
.endNamespace ()
|
||||
|
||||
.beginNamespace ("SelectionOp")
|
||||
.addConst ("Toggle", Selection::Operation(Selection::Toggle))
|
||||
.addConst ("Set", Selection::Operation(Selection::Set))
|
||||
.addConst ("Extend", Selection::Operation(Selection::Extend))
|
||||
.addConst ("Add", Selection::Operation(Selection::Add))
|
||||
.endNamespace ()
|
||||
|
||||
.endNamespace (); // end ArdourUI
|
||||
|
||||
// Editing Symbols
|
||||
|
@ -204,9 +204,13 @@ class PublicEditor : public Gtkmm2ext::Tabbable {
|
||||
virtual framepos_t playhead_cursor_sample () const = 0;
|
||||
virtual double sample_to_pixel (framepos_t frame) const = 0;
|
||||
virtual double sample_to_pixel_unrounded (framepos_t frame) const = 0;
|
||||
|
||||
virtual Selection& get_selection () const = 0;
|
||||
virtual bool get_selection_extents (framepos_t &start, framepos_t &end) const = 0;
|
||||
virtual Selection& get_cut_buffer () const = 0;
|
||||
|
||||
virtual void set_selection (std::list<Selectable*>, Selection::Operation) = 0;
|
||||
|
||||
virtual bool extend_selection_to_track (TimeAxisView&) = 0;
|
||||
virtual void play_selection () = 0;
|
||||
virtual void play_with_preroll () = 0;
|
||||
@ -348,6 +352,7 @@ class PublicEditor : public Gtkmm2ext::Tabbable {
|
||||
virtual RouteTimeAxisView* get_route_view_by_route_id (const PBD::ID& id) const = 0;
|
||||
|
||||
virtual void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&, PBD::PropertyID) const = 0;
|
||||
virtual RegionView* get_regionview_from_region (boost::shared_ptr<ARDOUR::Region>) const = 0;
|
||||
|
||||
sigc::signal<void> ZoomChanged;
|
||||
sigc::signal<void> Realized;
|
||||
|
42
scripts/select_every_2nd_region.lua
Normal file
42
scripts/select_every_2nd_region.lua
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user