summaryrefslogtreecommitdiff
path: root/gtk2_ardour
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 /gtk2_ardour
parent71fd94b422574d1efbcce1ab85c6ce3da22ba450 (diff)
Lua bindings to access editor selection + region selection bindings
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor.cc18
-rw-r--r--gtk2_ardour/editor.h4
-rw-r--r--gtk2_ardour/editor_selection.cc24
-rw-r--r--gtk2_ardour/luainstance.cc24
-rw-r--r--gtk2_ardour/public_editor.h5
5 files changed, 74 insertions, 1 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index bb769e30ef..ba07222bdf 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -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 ()
{
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 458753d638..01ef86874e 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -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;
diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc
index d214d48a32..8c6b16f51d 100644
--- a/gtk2_ardour/editor_selection.cc
+++ b/gtk2_ardour/editor_selection.cc
@@ -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)
diff --git a/gtk2_ardour/luainstance.cc b/gtk2_ardour/luainstance.cc
index 1a8bf12d62..c8a4fe9e3b 100644
--- a/gtk2_ardour/luainstance.cc
+++ b/gtk2_ardour/luainstance.cc
@@ -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
diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h
index 5cfedb11f1..62cb9f2bcb 100644
--- a/gtk2_ardour/public_editor.h
+++ b/gtk2_ardour/public_editor.h
@@ -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;