Lua bindings to access editor selection + region selection bindings
[ardour.git] / gtk2_ardour / luainstance.cc
index bfa72b2907696d0b3a352c9c10fe6c64e894f569..c8a4fe9e3b09f9033d1f7e72fee18555d6d85acd 100644 (file)
 #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"
@@ -308,6 +310,11 @@ class PangoLayout {
                        pango_cairo_show_layout (c->cobj (), _layout->gobj());
                }
 
+               void layout_cairo_path (Cairo::Context* c) {
+                       pango_cairo_update_layout (c->cobj (), _layout->gobj());
+                       pango_cairo_layout_path (c->cobj (), _layout->gobj());
+               }
+
        private:
                Glib::RefPtr<Pango::Layout> _layout;
 };
@@ -491,6 +498,7 @@ LuaInstance::bind_cairo (lua_State* L)
                .addFunction ("get_text", &LuaCairo::PangoLayout::get_text)
                .addFunction ("set_text", &LuaCairo::PangoLayout::set_text)
                .addFunction ("show_in_cairo_context", &LuaCairo::PangoLayout::show_in_cairo_context)
+               .addFunction ("layout_cairo_path", &LuaCairo::PangoLayout::layout_cairo_path)
                .addFunction ("set_markup", &LuaCairo::PangoLayout::set_markup)
                .addFunction ("set_width", &LuaCairo::PangoLayout::set_width)
                .addFunction ("set_ellipsize", &LuaCairo::PangoLayout::set_ellipsize)
@@ -576,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)
@@ -640,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)
@@ -685,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)
@@ -777,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