From 9e543beb569f40edb3312c3c213d21b763b30d5a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 24 Feb 2017 13:03:24 +0100 Subject: [PATCH] Add some convenient public editor methods (for lua-bindings) and s/get// in the old API for consistency. --- gtk2_ardour/editor.cc | 31 +++++++++++++++++++++++++- gtk2_ardour/editor.h | 4 +++- gtk2_ardour/luainstance.cc | 34 +++++++++++++++++------------ gtk2_ardour/public_editor.h | 4 +++- scripts/select_every_2nd_region.lua | 2 +- 5 files changed, 57 insertions(+), 18 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index ba07222bdf..351812aef4 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -5088,7 +5088,7 @@ Editor::get_regions_corresponding_to (boost::shared_ptr region, vector region) const +Editor::regionview_from_region (boost::shared_ptr region) const { for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) { RouteTimeAxisView* tatv; @@ -5105,6 +5105,20 @@ Editor::get_regionview_from_region (boost::shared_ptr region) const return NULL; } +RouteTimeAxisView* +Editor::rtav_from_route (boost::shared_ptr route) const +{ + for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) { + RouteTimeAxisView* rtav; + if ((rtav = dynamic_cast (*i)) != 0) { + if (rtav->route() == route) { + return rtav; + } + } + } + return NULL; +} + void Editor::show_rhythm_ferret () { @@ -5484,6 +5498,9 @@ Editor::timeaxisview_deleted (TimeAxisView *tv) void Editor::hide_track_in_display (TimeAxisView* tv, bool apply_to_selection) { + if (!tv) { + return; + } if (apply_to_selection) { for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ) { @@ -5506,6 +5523,18 @@ Editor::hide_track_in_display (TimeAxisView* tv, bool apply_to_selection) } } +void +Editor::show_track_in_display (TimeAxisView* tv, bool move_into_view) +{ + if (!tv) { + return; + } + _routes->show_track_in_display (*tv); + if (move_into_view) { + ensure_time_axis_view_is_visible (*tv, false); + } +} + bool Editor::sync_track_view_list_and_routes () { diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 01ef86874e..d21cc4e1b0 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -331,6 +331,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void set_selected_mixer_strip (TimeAxisView&); void mixer_strip_width_changed (); void hide_track_in_display (TimeAxisView* tv, bool apply_to_selection = false); + void show_track_in_display (TimeAxisView* tv, bool move_into_view = false); /* nudge is initiated by transport controls owned by ARDOUR_UI */ @@ -734,7 +735,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void get_equivalent_regions (RegionView* rv, std::vector &, PBD::PropertyID) const; RegionSelection get_equivalent_regions (RegionSelection &, PBD::PropertyID) const; - RegionView* get_regionview_from_region (boost::shared_ptr) const; + RegionView* regionview_from_region (boost::shared_ptr) const; + RouteTimeAxisView* rtav_from_route (boost::shared_ptr) const; void mapover_tracks (sigc::slot sl, TimeAxisView*, PBD::PropertyID) const; void mapover_tracks_with_unique_playlists (sigc::slot sl, TimeAxisView*, PBD::PropertyID) const; diff --git a/gtk2_ardour/luainstance.cc b/gtk2_ardour/luainstance.cc index 59ebd80e85..b8dbb4accf 100644 --- a/gtk2_ardour/luainstance.cc +++ b/gtk2_ardour/luainstance.cc @@ -597,9 +597,15 @@ LuaInstance::register_classes (lua_State* L) .addCast ("to_timeaxisview") .endClass () + // std::list .beginStdCPtrList ("SelectionList") .endClass () + // std::list + .beginStdCPtrList ("TrackViewStdList") + .endClass () + + .beginClass ("RegionSelection") .addFunction ("start", &RegionSelection::start) .addFunction ("end_frame", &RegionSelection::end_frame) @@ -616,8 +622,9 @@ LuaInstance::register_classes (lua_State* L) .deriveClass > ("MarkerSelection") .endClass () - .beginClass ("TrackViewList") - .addFunction ("routelist", &TrackViewList::routelist) // XXX check windows binding (libardour) + .deriveClass > ("TrackViewList") + .addFunction ("contains", &TrackViewList::contains) + .addFunction ("routelist", &TrackViewList::routelist) .endClass () .deriveClass ("TrackSelection") @@ -695,23 +702,23 @@ LuaInstance::register_classes (lua_State* L) .addFunction ("get_current_zoom", &PublicEditor::get_current_zoom) .addFunction ("reset_zoom", &PublicEditor::reset_zoom) -#if 0 // These need TimeAxisView* which isn't exposed, yet - .addFunction ("playlist_selector", &PublicEditor::playlist_selector) .addFunction ("clear_playlist", &PublicEditor::clear_playlist) .addFunction ("new_playlists", &PublicEditor::new_playlists) .addFunction ("copy_playlists", &PublicEditor::copy_playlists) .addFunction ("clear_playlists", &PublicEditor::clear_playlists) -#endif .addFunction ("select_all_tracks", &PublicEditor::select_all_tracks) .addFunction ("deselect_all", &PublicEditor::deselect_all) -#if 0 + +#if 0 // TimeAxisView& can't be bound (pure virtual fn) .addFunction ("set_selected_track", &PublicEditor::set_selected_track) .addFunction ("set_selected_mixer_strip", &PublicEditor::set_selected_mixer_strip) - .addFunction ("hide_track_in_display", &PublicEditor::hide_track_in_display) + .addFunction ("ensure_time_axis_view_is_visible", &PublicEditor::ensure_time_axis_view_is_visible) #endif + .addFunction ("hide_track_in_display", &PublicEditor::hide_track_in_display) + .addFunction ("show_track_in_display", &PublicEditor::show_track_in_display) - .addFunction ("get_regionview_from_region", &PublicEditor::get_regionview_from_region) + .addFunction ("regionview_from_region", &PublicEditor::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) @@ -722,7 +729,6 @@ LuaInstance::register_classes (lua_State* L) .addFunction ("current_page_samples", &PublicEditor::current_page_samples) .addFunction ("visible_canvas_height", &PublicEditor::visible_canvas_height) .addFunction ("temporal_zoom_step", &PublicEditor::temporal_zoom_step) - //.addFunction ("ensure_time_axis_view_is_visible", &PublicEditor::ensure_time_axis_view_is_visible) .addFunction ("override_visible_track_count", &PublicEditor::override_visible_track_count) .addFunction ("scroll_tracks_down_line", &PublicEditor::scroll_tracks_down_line) @@ -754,15 +760,15 @@ LuaInstance::register_classes (lua_State* L) .addFunction ("set_video_timeline_height", &PublicEditor::set_video_timeline_height) #if 0 - .addFunction ("get_route_view_by_route_id", &PublicEditor::get_route_view_by_route_id) .addFunction ("get_equivalent_regions", &PublicEditor::get_equivalent_regions) - - .addFunction ("axis_view_from_route", &PublicEditor::axis_view_from_route) - .addFunction ("axis_views_from_routes", &PublicEditor::axis_views_from_routes) - .addFunction ("get_track_views", &PublicEditor::get_track_views) .addFunction ("drags", &PublicEditor::drags) #endif + .addFunction ("get_route_view_by_route_id", &PublicEditor::get_route_view_by_route_id) + .addFunction ("get_track_views", &PublicEditor::get_track_views) + .addFunction ("rtav_from_route", &PublicEditor::rtav_from_route) + .addFunction ("axis_views_from_routes", &PublicEditor::axis_views_from_routes) + .addFunction ("center_screen", &PublicEditor::center_screen) .addFunction ("get_smart_mode", &PublicEditor::get_smart_mode) diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 62cb9f2bcb..a9c4f53169 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -286,6 +286,7 @@ class PublicEditor : public Gtkmm2ext::Tabbable { virtual void set_selected_track (TimeAxisView&, Selection::Operation op = Selection::Set, bool no_remove = false) = 0; virtual void set_selected_mixer_strip (TimeAxisView&) = 0; virtual void hide_track_in_display (TimeAxisView* tv, bool apply_to_selection = false) = 0; + virtual void show_track_in_display (TimeAxisView* tv, bool move_into_view = false) = 0; virtual void set_stationary_playhead (bool yn) = 0; virtual void toggle_stationary_playhead () = 0; @@ -352,7 +353,8 @@ 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&, PBD::PropertyID) const = 0; - virtual RegionView* get_regionview_from_region (boost::shared_ptr) const = 0; + virtual RegionView* regionview_from_region (boost::shared_ptr) const = 0; + virtual RouteTimeAxisView* rtav_from_route (boost::shared_ptr) const = 0; sigc::signal ZoomChanged; sigc::signal Realized; diff --git a/scripts/select_every_2nd_region.lua b/scripts/select_every_2nd_region.lua index 4e6d156f5a..0ffba5b826 100644 --- a/scripts/select_every_2nd_region.lua +++ b/scripts/select_every_2nd_region.lua @@ -29,7 +29,7 @@ function factory () return function () else skip = true; -- get RegionView (GUI object to be selected) - local rv = Editor:get_regionview_from_region (region) + local rv = Editor:regionview_from_region (region) -- add it to the list of Objects to be selected sl:push_back (rv); end