Added support for exporting mp4 chapter marks
[ardour.git] / gtk2_ardour / editor_markers.cc
index caeddb06eb899778be9156f7fd6ac80f12bd86e3..392b3bb6c1358f02eb178d4b2a03ffd1e48b0cf3 100644 (file)
@@ -163,11 +163,8 @@ Editor::add_new_location_internal (Location* location)
                lam->show ();
        }
 
-       location->start_changed.connect (*this, invalidator (*this), boost::bind (&Editor::location_changed, this, _1), gui_context());
-       location->end_changed.connect (*this, invalidator (*this), boost::bind (&Editor::location_changed, this, _1), gui_context());
-       location->changed.connect (*this, invalidator (*this), boost::bind (&Editor::location_changed, this, _1), gui_context());
        location->name_changed.connect (*this, invalidator (*this), boost::bind (&Editor::location_changed, this, _1), gui_context());
-       location->FlagsChanged.connect (*this, invalidator (*this), boost::bind (&Editor::location_flags_changed, this, _1, _2), gui_context());
+       location->FlagsChanged.connect (*this, invalidator (*this), boost::bind (&Editor::location_flags_changed, this, location), gui_context());
 
        pair<Location*,LocationMarkers*> newpair;
 
@@ -370,7 +367,7 @@ Editor::update_marker_labels (ArdourCanvas::Container* group)
 }
 
 void
-Editor::location_flags_changed (Location *location, void*)
+Editor::location_flags_changed (Location *location)
 {
        ENSURE_GUI_THREAD (*this, &Editor::location_flags_changed, location, src)
 
@@ -489,7 +486,7 @@ Editor::find_location_from_marker (Marker *marker, bool& is_start) const
 }
 
 void
-Editor::refresh_location_display_internal (Locations::LocationList& locations)
+Editor::refresh_location_display_internal (const Locations::LocationList& locations)
 {
        /* invalidate all */
 
@@ -499,7 +496,7 @@ Editor::refresh_location_display_internal (Locations::LocationList& locations)
 
        /* add new ones */
 
-       for (Locations::LocationList::iterator i = locations.begin(); i != locations.end(); ++i) {
+       for (Locations::LocationList::const_iterator i = locations.begin(); i != locations.end(); ++i) {
 
                LocationMarkerMap::iterator x;
 
@@ -639,30 +636,23 @@ Editor::LocationMarkers::setup_lines ()
 }
 
 void
-Editor::mouse_add_new_marker (framepos_t where, bool is_cd, bool is_xrun)
+Editor::mouse_add_new_marker (framepos_t where, bool is_cd)
 {
-       string markername, markerprefix;
+       string markername;
        int flags = (is_cd ? Location::IsCDMarker|Location::IsMark : Location::IsMark);
 
-       if (is_xrun) {
-               markerprefix = "xrun";
-               flags = Location::IsMark;
-       } else {
-               markerprefix = "mark";
-       }
-
        if (_session) {
-               _session->locations()->next_available_name(markername, markerprefix);
-               if (!is_xrun && !choose_new_marker_name(markername)) {
+               _session->locations()->next_available_name(markername, _("mark"));
+               if (!choose_new_marker_name(markername)) {
                        return;
                }
                Location *location = new Location (*_session, where, where, markername, (Location::Flags) flags);
-               _session->begin_reversible_command (_("add marker"));
+               begin_reversible_command (_("add marker"));
+
                XMLNode &before = _session->locations()->get_state();
                _session->locations()->add (location, true);
                XMLNode &after = _session->locations()->get_state();
                _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
-               _session->commit_reversible_command ();
 
                /* find the marker we just added */
 
@@ -671,7 +661,41 @@ Editor::mouse_add_new_marker (framepos_t where, bool is_cd, bool is_xrun)
                        /* make it the selected marker */
                        selection->set (lam->start);
                }
+
+               commit_reversible_command ();
+       }
+}
+
+void
+Editor::mouse_add_new_loop (framepos_t where)
+{
+       if (!_session) {
+               return;
+       }
+
+       /* Make this marker 1/8th of the visible area of the session so that
+          it's reasonably easy to manipulate after creation.
+       */
+
+       framepos_t const end = where + current_page_samples() / 8;
+
+       set_loop_range (where, end,  _("set loop range"));
+}
+
+void
+Editor::mouse_add_new_punch (framepos_t where)
+{
+       if (!_session) {
+               return;
        }
+
+       /* Make this marker 1/8th of the visible area of the session so that
+          it's reasonably easy to manipulate after creation.
+       */
+
+       framepos_t const end = where + current_page_samples() / 8;
+
+       set_punch_range (where, end,  _("set punch range"));
 }
 
 void
@@ -707,7 +731,7 @@ Editor::remove_marker (ArdourCanvas::Item& item, GdkEvent*)
 
        if ((marker = static_cast<Marker*> (item.get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        if (entered_marker == marker) {
@@ -724,12 +748,12 @@ Editor::remove_marker (ArdourCanvas::Item& item, GdkEvent*)
 gint
 Editor::really_remove_marker (Location* loc)
 {
-       _session->begin_reversible_command (_("remove marker"));
+       begin_reversible_command (_("remove marker"));
        XMLNode &before = _session->locations()->get_state();
        _session->locations()->remove (loc);
        XMLNode &after = _session->locations()->get_state();
        _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
-       _session->commit_reversible_command ();
+       commit_reversible_command ();
        return FALSE;
 }
 
@@ -794,7 +818,7 @@ Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
        Marker * marker;
        if ((marker = reinterpret_cast<Marker *> (item->get_data("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        bool is_start;
@@ -979,7 +1003,7 @@ Editor::marker_menu_hide ()
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        Location* l;
@@ -997,7 +1021,7 @@ Editor::marker_menu_select_using_range ()
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        Location* l;
@@ -1015,7 +1039,7 @@ Editor::marker_menu_select_all_selectables_using_range ()
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        Location* l;
@@ -1034,7 +1058,7 @@ Editor::marker_menu_separate_regions_using_location ()
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        Location* l;
@@ -1053,7 +1077,7 @@ Editor::marker_menu_play_from ()
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        Location* l;
@@ -1083,7 +1107,7 @@ Editor::marker_menu_set_playhead ()
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        Location* l;
@@ -1114,7 +1138,7 @@ Editor::marker_menu_range_to_next ()
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        Location* l;
@@ -1144,7 +1168,7 @@ Editor::marker_menu_set_from_playhead ()
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        Location* l;
@@ -1172,7 +1196,7 @@ Editor::marker_menu_set_from_selection (bool /*force_regions*/)
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        Location* l;
@@ -1203,7 +1227,7 @@ Editor::marker_menu_play_range ()
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        Location* l;
@@ -1228,7 +1252,7 @@ Editor::marker_menu_loop_range ()
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        Location* l;
@@ -1279,7 +1303,7 @@ Editor::dynamic_cast_marker_object (void* p, MeterMarker** m, TempoMarker** t) c
        Marker* marker = reinterpret_cast<Marker*> (p);
        if (!marker) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        *m = dynamic_cast<MeterMarker*> (marker);
@@ -1323,7 +1347,7 @@ Editor::toggle_marker_menu_lock ()
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        Location* loc;
@@ -1349,7 +1373,7 @@ Editor::marker_menu_rename ()
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
 
@@ -1543,7 +1567,7 @@ Editor::toggle_marker_menu_glue ()
 
        if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
                fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
-               /*NOTREACHED*/
+               abort(); /*NOTREACHED*/
        }
 
        Location* loc;