fix incorrect accumulation of export video options each time the dialog is used
[ardour.git] / gtk2_ardour / editor_markers.cc
index 64018f3f21cc418b11c9c0d8d081cc1ce6be7ab7..abe6d8a6588e83e7077de610408d48ddad4b015d 100644 (file)
@@ -165,6 +165,7 @@ Editor::add_new_location_internal (Location* location)
        }
 
        location->name_changed.connect (*this, invalidator (*this), boost::bind (&Editor::location_changed, this, _1), gui_context());
+       location->position_lock_style_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, location), gui_context());
 
        pair<Location*,LocationMarkers*> newpair;
@@ -205,7 +206,12 @@ Editor::location_changed (Location *location)
                return;
        }
 
-       lam->set_name (location->name ());
+       if (location->position_lock_style() == MusicTime) {
+               lam->set_name ("\u266B" + location->name ()); // BEAMED EIGHTH NOTES
+       } else {
+               lam->set_name (location->name ());
+       }
+
        lam->set_position (location->start(), location->end());
 
        if (location->is_auto_loop()) {
@@ -591,8 +597,8 @@ Editor::LocationMarkers::set_name (const string& str)
 }
 
 void
-Editor::LocationMarkers::set_position (framepos_t startf,
-                                      framepos_t endf)
+Editor::LocationMarkers::set_position (samplepos_t startf,
+                                      samplepos_t endf)
 {
        start->set_position (startf);
        if (end) {
@@ -637,7 +643,7 @@ Editor::LocationMarkers::setup_lines ()
 }
 
 void
-Editor::mouse_add_new_marker (framepos_t where, bool is_cd)
+Editor::mouse_add_new_marker (samplepos_t where, bool is_cd)
 {
        string markername;
        int flags = (is_cd ? Location::IsCDMarker|Location::IsMark : Location::IsMark);
@@ -668,7 +674,7 @@ Editor::mouse_add_new_marker (framepos_t where, bool is_cd)
 }
 
 void
-Editor::mouse_add_new_loop (framepos_t where)
+Editor::mouse_add_new_loop (samplepos_t where)
 {
        if (!_session) {
                return;
@@ -678,13 +684,13 @@ Editor::mouse_add_new_loop (framepos_t where)
           it's reasonably easy to manipulate after creation.
        */
 
-       framepos_t const end = where + current_page_samples() / 8;
+       samplepos_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)
+Editor::mouse_add_new_punch (samplepos_t where)
 {
        if (!_session) {
                return;
@@ -694,13 +700,13 @@ Editor::mouse_add_new_punch (framepos_t where)
           it's reasonably easy to manipulate after creation.
        */
 
-       framepos_t const end = where + current_page_samples() / 8;
+       samplepos_t const end = where + current_page_samples() / 8;
 
        set_punch_range (where, end,  _("set punch range"));
 }
 
 void
-Editor::mouse_add_new_range (framepos_t where)
+Editor::mouse_add_new_range (samplepos_t where)
 {
        if (!_session) {
                return;
@@ -710,7 +716,7 @@ Editor::mouse_add_new_range (framepos_t where)
           it's reasonably easy to manipulate after creation.
        */
 
-       framepos_t const end = where + current_page_samples() / 8;
+       samplepos_t const end = where + current_page_samples() / 8;
 
        string name;
        _session->locations()->next_available_name (name, _("range"));
@@ -905,6 +911,7 @@ Editor::build_marker_menu (Location* loc)
 
        items.push_back (MenuElem (_("Create Range to Next Marker"), sigc::mem_fun(*this, &Editor::marker_menu_range_to_next)));
 
+       items.push_back (MenuElem (_("Promote to Time Origin"), sigc::mem_fun(*this, &Editor::marker_menu_set_origin)));
        items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &Editor::marker_menu_hide)));
        items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &Editor::marker_menu_rename)));
 
@@ -964,6 +971,7 @@ Editor::build_range_marker_menu (Location* loc, bool loop_or_punch, bool session
        items.push_back (MenuElem (_("Export Range..."), sigc::mem_fun(*this, &Editor::export_range)));
        items.push_back (SeparatorElem());
 
+       items.push_back (MenuElem (_("Promote to Time Origin"), sigc::mem_fun(*this, &Editor::marker_menu_set_origin)));
        if (!loop_or_punch_or_session) {
                items.push_back (MenuElem (_("Hide Range"), sigc::mem_fun(*this, &Editor::marker_menu_hide)));
                items.push_back (MenuElem (_("Rename Range..."), sigc::mem_fun(*this, &Editor::marker_menu_rename)));
@@ -994,15 +1002,14 @@ Editor::build_tempo_marker_menu (TempoMarker* loc, bool can_remove)
 
        if (!loc->tempo().initial()) {
                if (loc->tempo().clamped()) {
-                       items.push_back (MenuElem (_("Unlock Continue"), sigc::mem_fun(*this, &Editor::toggle_tempo_clamped)));
+                       items.push_back (MenuElem (_("Don't Continue"), sigc::mem_fun(*this, &Editor::toggle_tempo_clamped)));
                } else {
-                       items.push_back (MenuElem (_("Lock Continue"), sigc::mem_fun(*this, &Editor::toggle_tempo_clamped)));
+                       items.push_back (MenuElem (_("Continue"), sigc::mem_fun(*this, &Editor::toggle_tempo_clamped)));
                }
+       }
 
-               TempoSection* prev_ts = _session->tempo_map().previous_tempo_section (&loc->tempo());
-               if (prev_ts && prev_ts->end_note_types_per_minute() != loc->tempo().note_types_per_minute()) {
-                       items.push_back (MenuElem (_("Continue"), sigc::mem_fun(*this, &Editor::continue_previous_tempo)));
-               }
+       if (loc->tempo().type() == TempoSection::Ramp) {
+               items.push_back (MenuElem (_("Set Constant"), sigc::mem_fun(*this, &Editor::toggle_tempo_type)));
        }
 
        TempoSection* next_ts = _session->tempo_map().next_tempo_section (&loc->tempo());
@@ -1010,16 +1017,16 @@ Editor::build_tempo_marker_menu (TempoMarker* loc, bool can_remove)
                items.push_back (MenuElem (_("Ramp to Next"), sigc::mem_fun(*this, &Editor::ramp_to_next_tempo)));
        }
 
-       if (loc->tempo().type() == TempoSection::Ramp) {
-               items.push_back (MenuElem (_("Set Constant"), sigc::mem_fun(*this, &Editor::toggle_tempo_type)));
-       }
-
        if (loc->tempo().position_lock_style() == AudioTime && can_remove) {
+               items.push_back (SeparatorElem());
                items.push_back (MenuElem (_("Lock to Music"), sigc::mem_fun(*this, &Editor::toggle_marker_lock_style)));
        } else if (can_remove) {
+               items.push_back (SeparatorElem());
                items.push_back (MenuElem (_("Lock to Audio"), sigc::mem_fun(*this, &Editor::toggle_marker_lock_style)));
        }
 
+       items.push_back (SeparatorElem());
+
        items.push_back (MenuElem (_("Edit..."), sigc::mem_fun(*this, &Editor::marker_menu_edit)));
        items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
        items.back().set_sensitive (can_remove);
@@ -1081,6 +1088,24 @@ Editor::marker_menu_hide ()
        }
 }
 
+void
+Editor::marker_menu_set_origin ()
+{
+       ArdourMarker* marker;
+
+       if ((marker = reinterpret_cast<ArdourMarker *> (marker_menu_item->get_data ("marker"))) == 0) {
+               fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
+               abort(); /*NOTREACHED*/
+       }
+
+       Location* l;
+       bool is_start;
+
+       if ((l = find_location_from_marker (marker, is_start)) != 0) {
+               _session->locations()->set_clock_origin (l, this);
+       }
+}
+
 void
 Editor::marker_menu_select_using_range ()
 {
@@ -1215,11 +1240,11 @@ Editor::marker_menu_range_to_next ()
                return;
        }
 
-       framepos_t start;
-       framepos_t end;
+       samplepos_t start;
+       samplepos_t end;
        _session->locations()->marks_either_side (marker->position(), start, end);
 
-       if (end != max_framepos) {
+       if (end != max_samplepos) {
                string range_name = l->name();
                range_name += "-range";
 
@@ -1245,13 +1270,13 @@ Editor::marker_menu_set_from_playhead ()
        if ((l = find_location_from_marker (marker, is_start)) != 0) {
 
                if (l->is_mark()) {
-                       l->set_start (_session->audible_frame (), false, true, divisions);
+                       l->set_start (_session->audible_sample (), false, true, divisions);
                }
                else {
                        if (is_start) {
-                               l->set_start (_session->audible_frame (), false, true, divisions);
+                               l->set_start (_session->audible_sample (), false, true, divisions);
                        } else {
-                               l->set_end (_session->audible_frame (), false, true, divisions);
+                               l->set_end (_session->audible_sample (), false, true, divisions);
                        }
                }
        }
@@ -1279,9 +1304,9 @@ Editor::marker_menu_set_from_selection (bool /*force_regions*/)
                } else {
 
                        if (!selection->time.empty()) {
-                               l->set (selection->time.start(), selection->time.end_frame());
+                               l->set (selection->time.start(), selection->time.end_sample());
                        } else if (!selection->regions.empty()) {
-                               l->set (selection->regions.start(), selection->regions.end_frame());
+                               l->set (selection->regions.start(), selection->regions.end_sample());
                        }
                }
        }
@@ -1348,18 +1373,18 @@ Editor::marker_menu_zoom_to_range ()
                return;
        }
 
-       framecnt_t const extra = l->length() * 0.05;
-       framepos_t a = l->start ();
+       samplecnt_t const extra = l->length() * 0.05;
+       samplepos_t a = l->start ();
        if (a >= extra) {
                a -= extra;
        }
 
-       framepos_t b = l->end ();
-       if (b < (max_framepos - extra)) {
+       samplepos_t b = l->end ();
+       if (b < (max_samplepos - extra)) {
                b += extra;
        }
 
-       temporal_zoom_by_frame (a, b);
+       temporal_zoom_by_sample (a, b);
 }
 
 void
@@ -1421,7 +1446,7 @@ Editor::toggle_marker_lock_style ()
                const Timecode::BBT_Time bbt (msp->bbt());
                const PositionLockStyle pls = (msp->position_lock_style() == AudioTime) ? MusicTime : AudioTime;
 
-               _session->tempo_map().replace_meter (*msp, meter, bbt, msp->frame(), pls);
+               _session->tempo_map().replace_meter (*msp, meter, bbt, msp->sample(), pls);
 
                XMLNode &after = _session->tempo_map().get_state();
                _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
@@ -1430,14 +1455,14 @@ Editor::toggle_marker_lock_style ()
                TempoSection* tsp = &tm->tempo();
 
                const double pulse = tsp->pulse();
-               const framepos_t frame = tsp->frame();
+               const samplepos_t sample = tsp->sample();
                const PositionLockStyle pls = (tsp->position_lock_style() == AudioTime) ? MusicTime : AudioTime;
                const Tempo tempo (tsp->note_types_per_minute(), tsp->note_type(), tsp->end_note_types_per_minute());
 
                begin_reversible_command (_("change tempo lock style"));
                XMLNode &before = _session->tempo_map().get_state();
 
-               _session->tempo_map().replace_tempo (*tsp, tempo, pulse, frame, pls);
+               _session->tempo_map().replace_tempo (*tsp, tempo, pulse, sample, pls);
 
                XMLNode &after = _session->tempo_map().get_state();
                _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
@@ -1457,13 +1482,13 @@ Editor::toggle_tempo_type ()
 
                const Tempo tempo (tsp->note_types_per_minute(), tsp->note_type());
                const double pulse = tsp->pulse();
-               const framepos_t frame = tsp->frame();
+               const samplepos_t sample = tsp->sample();
                const PositionLockStyle pls = tsp->position_lock_style();
 
                begin_reversible_command (_("set tempo to constant"));
                XMLNode &before = _session->tempo_map().get_state();
 
-               _session->tempo_map().replace_tempo (*tsp, tempo, pulse, frame, pls);
+               _session->tempo_map().replace_tempo (*tsp, tempo, pulse, sample, pls);
 
                XMLNode &after = _session->tempo_map().get_state();
                _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
@@ -1499,35 +1524,6 @@ Editor::toggle_tempo_clamped ()
        }
 }
 
-void
-Editor::continue_previous_tempo ()
-{
-       TempoMarker* tm;
-       MeterMarker* mm;
-       dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
-
-       if (tm) {
-               TempoMap& tmap (_session->tempo_map());
-               TempoSection* tsp = &tm->tempo();
-               TempoSection* prev_ts = tmap.previous_tempo_section (&tm->tempo());
-               if (prev_ts) {
-                       const Tempo tempo (prev_ts->end_note_types_per_minute(), tsp->note_type(), tsp->end_note_types_per_minute());
-                       const double pulse = tsp->pulse();
-                       const framepos_t frame = tsp->frame();
-                       const PositionLockStyle pls = tsp->position_lock_style();
-
-                       begin_reversible_command (_("continue previous tempo"));
-                       XMLNode &before = _session->tempo_map().get_state();
-
-                       tmap.replace_tempo (*tsp, tempo, pulse, frame, pls);
-
-                       XMLNode &after = _session->tempo_map().get_state();
-                       _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
-                       commit_reversible_command ();
-               }
-       }
-}
-
 void
 Editor::ramp_to_next_tempo ()
 {
@@ -1542,13 +1538,13 @@ Editor::ramp_to_next_tempo ()
                if (next_ts) {
                        const Tempo tempo (tsp->note_types_per_minute(), tsp->note_type(), next_ts->note_types_per_minute());
                        const double pulse = tsp->pulse();
-                       const framepos_t frame = tsp->frame();
+                       const samplepos_t sample = tsp->sample();
                        const PositionLockStyle pls = tsp->position_lock_style();
 
                        begin_reversible_command (_("ramp to next tempo"));
                        XMLNode &before = _session->tempo_map().get_state();
 
-                       tmap.replace_tempo (*tsp, tempo, pulse, frame, pls);
+                       tmap.replace_tempo (*tsp, tempo, pulse, sample, pls);
 
                        XMLNode &after = _session->tempo_map().get_state();
                        _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
@@ -1720,7 +1716,7 @@ Editor::update_punch_range_view ()
                if (_session->config.get_punch_out()) {
                        pixel_end = sample_to_pixel (tpl->end());
                } else {
-                       pixel_end = sample_to_pixel (max_framepos);
+                       pixel_end = sample_to_pixel (max_samplepos);
                }
 
                transport_punch_range_rect->set_x0 (pixel_start);