2 Copyright (C) 2000 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <sigc++/retype.h>
24 #include <libgnomecanvas/libgnomecanvas.h>
25 #include <gtkmm2ext/gtk_ui.h>
27 #include "ardour/session.h"
28 #include "ardour/location.h"
29 #include "ardour/profile.h"
30 #include "pbd/memento_command.h"
34 #include "selection.h"
36 #include "gui_thread.h"
37 #include "simplerect.h"
40 #include "editor_drag.h"
45 using namespace ARDOUR;
48 using namespace Gtkmm2ext;
51 Editor::clear_marker_display ()
53 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
57 location_markers.clear ();
61 Editor::add_new_location (Location *location)
63 ENSURE_GUI_THREAD (*this, &Editor::add_new_location, location)
65 LocationMarkers *lam = new LocationMarkers;
68 if (location->is_cd_marker()) {
69 color = location_cd_marker_color;
70 } else if (location->is_mark()) {
71 color = location_marker_color;
72 } else if (location->is_auto_loop()) {
73 color = location_loop_color;
74 } else if (location->is_auto_punch()) {
75 color = location_punch_color;
77 color = location_range_color;
80 if (location->is_mark()) {
82 if (location->is_cd_marker() && ruler_cd_marker_action->get_active()) {
83 lam->start = new Marker (*this, *cd_marker_group, color, location->name(), Marker::Mark, location->start());
86 lam->start = new Marker (*this, *marker_group, color, location->name(), Marker::Mark, location->start());
90 } else if (location->is_auto_loop()) {
92 lam->start = new Marker (*this, *transport_marker_group, color,
93 location->name(), Marker::LoopStart, location->start());
94 lam->end = new Marker (*this, *transport_marker_group, color,
95 location->name(), Marker::LoopEnd, location->end());
97 } else if (location->is_auto_punch()) {
99 lam->start = new Marker (*this, *transport_marker_group, color,
100 location->name(), Marker::PunchIn, location->start());
101 lam->end = new Marker (*this, *transport_marker_group, color,
102 location->name(), Marker::PunchOut, location->end());
104 } else if (location->is_session_range()) {
106 lam->start = new Marker (*this, *marker_group, color, _("start"), Marker::Start, location->start());
107 lam->end = new Marker (*this, *marker_group, color, _("end"), Marker::End, location->end());
111 if (location->is_cd_marker() && ruler_cd_marker_action->get_active()) {
112 lam->start = new Marker (*this, *cd_marker_group, color,
113 location->name(), Marker::Start, location->start());
114 lam->end = new Marker (*this, *cd_marker_group, color,
115 location->name(), Marker::End, location->end());
118 lam->start = new Marker (*this, *range_marker_group, color,
119 location->name(), Marker::Start, location->start());
120 lam->end = new Marker (*this, *range_marker_group, color,
121 location->name(), Marker::End, location->end());
125 if (location->is_hidden ()) {
131 location->start_changed.connect (*this, invalidator (*this), ui_bind (&Editor::location_changed, this, _1), gui_context());
132 location->end_changed.connect (*this, invalidator (*this), ui_bind (&Editor::location_changed, this, _1), gui_context());
133 location->changed.connect (*this, invalidator (*this), ui_bind (&Editor::location_changed, this, _1), gui_context());
134 location->name_changed.connect (*this, invalidator (*this), ui_bind (&Editor::location_changed, this, _1), gui_context());
135 location->FlagsChanged.connect (*this, invalidator (*this), ui_bind (&Editor::location_flags_changed, this, _1, _2), gui_context());
137 pair<Location*,LocationMarkers*> newpair;
139 newpair.first = location;
140 newpair.second = lam;
142 location_markers.insert (newpair);
144 if (select_new_marker && location->is_mark()) {
145 selection->set (lam->start);
146 select_new_marker = false;
151 Editor::location_changed (Location *location)
153 ENSURE_GUI_THREAD (*this, &Editor::location_changed, location)
155 LocationMarkers *lam = find_location_markers (location);
158 /* a location that isn't "marked" with markers */
162 lam->set_name (location->name ());
163 lam->set_position (location->start(), location->end());
165 if (location->is_auto_loop()) {
166 update_loop_range_view ();
167 } else if (location->is_auto_punch()) {
168 update_punch_range_view ();
173 Editor::location_flags_changed (Location *location, void*)
175 ENSURE_GUI_THREAD (*this, &Editor::location_flags_changed, location, src)
177 LocationMarkers *lam = find_location_markers (location);
180 /* a location that isn't "marked" with markers */
184 // move cd markers to/from cd marker bar as appropriate
185 ensure_cd_marker_updated (lam, location);
187 if (location->is_cd_marker()) {
188 lam->set_color_rgba (location_cd_marker_color);
189 } else if (location->is_mark()) {
190 lam->set_color_rgba (location_marker_color);
191 } else if (location->is_auto_punch()) {
192 lam->set_color_rgba (location_punch_color);
193 } else if (location->is_auto_loop()) {
194 lam->set_color_rgba (location_loop_color);
196 lam->set_color_rgba (location_range_color);
199 if (location->is_hidden()) {
206 void Editor::update_cd_marker_display ()
208 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
209 LocationMarkers * lam = i->second;
210 Location * location = i->first;
212 ensure_cd_marker_updated (lam, location);
216 void Editor::ensure_cd_marker_updated (LocationMarkers * lam, Location * location)
218 if (location->is_cd_marker()
219 && (ruler_cd_marker_action->get_active() && lam->start->get_parent() != cd_marker_group))
221 //cerr << "reparenting non-cd marker so it can be relocated: " << location->name() << endl;
223 lam->start->reparent (*cd_marker_group);
226 lam->end->reparent (*cd_marker_group);
229 else if ( (!location->is_cd_marker() || !ruler_cd_marker_action->get_active())
230 && (lam->start->get_parent() == cd_marker_group))
232 //cerr << "reparenting non-cd marker so it can be relocated: " << location->name() << endl;
233 if (location->is_mark()) {
235 lam->start->reparent (*marker_group);
238 lam->end->reparent (*marker_group);
243 lam->start->reparent (*range_marker_group);
246 lam->end->reparent (*range_marker_group);
252 Editor::LocationMarkers::~LocationMarkers ()
258 Editor::LocationMarkers *
259 Editor::find_location_markers (Location *location) const
261 LocationMarkerMap::const_iterator i;
263 for (i = location_markers.begin(); i != location_markers.end(); ++i) {
264 if ((*i).first == location) {
273 Editor::find_location_from_marker (Marker *marker, bool& is_start) const
275 LocationMarkerMap::const_iterator i;
277 for (i = location_markers.begin(); i != location_markers.end(); ++i) {
278 LocationMarkers *lm = (*i).second;
279 if (lm->start == marker) {
282 } else if (lm->end == marker) {
292 Editor::refresh_location_display_internal (Locations::LocationList& locations)
296 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
297 i->second->valid = false;
302 for (Locations::LocationList::iterator i = locations.begin(); i != locations.end(); ++i) {
304 LocationMarkerMap::iterator x;
306 if ((x = location_markers.find (*i)) != location_markers.end()) {
307 x->second->valid = true;
311 add_new_location (*i);
314 /* remove dead ones */
316 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ) {
318 LocationMarkerMap::iterator tmp;
323 if (!i->second->valid) {
325 location_markers.erase (i);
331 update_punch_range_view (false);
332 update_loop_range_view (false);
336 Editor::refresh_location_display ()
338 ENSURE_GUI_THREAD (*this, &Editor::refresh_location_display)
341 _session->locations()->apply (*this, &Editor::refresh_location_display_internal);
346 Editor::refresh_location_display_s (const PropertyChange&)
348 ENSURE_GUI_THREAD (*this, &Editor::refresh_location_display_s, ignored)
351 _session->locations()->apply (*this, &Editor::refresh_location_display_internal);
356 Editor::LocationMarkers::hide()
359 if (end) { end->hide(); }
363 Editor::LocationMarkers::show()
366 if (end) { end->show(); }
370 Editor::LocationMarkers::set_name (const string& str)
372 /* XXX: hack: don't change names of session start/end markers */
374 if (start->type() != Marker::Start) {
375 start->set_name (str);
378 if (end && end->type() != Marker::End) {
384 Editor::LocationMarkers::set_position (nframes64_t startf,
387 start->set_position (startf);
388 if (end) { end->set_position (endf); }
392 Editor::LocationMarkers::set_color_rgba (uint32_t rgba)
394 start->set_color_rgba (rgba);
395 if (end) { end->set_color_rgba (rgba); }
399 Editor::mouse_add_new_marker (nframes64_t where, bool is_cd, bool is_xrun)
401 string markername, markerprefix;
402 int flags = (is_cd ? Location::IsCDMarker|Location::IsMark : Location::IsMark);
405 markerprefix = "xrun";
406 flags = Location::IsMark;
408 markerprefix = "mark";
412 _session->locations()->next_available_name(markername, markerprefix);
413 if (!is_xrun && !choose_new_marker_name(markername)) {
416 Location *location = new Location (where, where, markername, (Location::Flags) flags);
417 _session->begin_reversible_command (_("add marker"));
418 XMLNode &before = _session->locations()->get_state();
419 _session->locations()->add (location, true);
420 XMLNode &after = _session->locations()->get_state();
421 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
422 _session->commit_reversible_command ();
424 /* find the marker we just added */
426 LocationMarkers *lam = find_location_markers (location);
428 /* make it the selected marker */
429 selection->set (lam->start);
435 Editor::remove_marker (ArdourCanvas::Item& item, GdkEvent*)
440 if ((marker = static_cast<Marker*> (item.get_data ("marker"))) == 0) {
441 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
445 if (entered_marker == marker) {
446 entered_marker = NULL;
449 Location* loc = find_location_from_marker (marker, is_start);
451 if (_session && loc) {
452 Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &Editor::really_remove_marker), loc));
457 Editor::really_remove_marker (Location* loc)
459 _session->begin_reversible_command (_("remove marker"));
460 XMLNode &before = _session->locations()->get_state();
461 _session->locations()->remove (loc);
462 XMLNode &after = _session->locations()->get_state();
463 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
464 _session->commit_reversible_command ();
469 Editor::location_gone (Location *location)
471 ENSURE_GUI_THREAD (*this, &Editor::location_gone, location)
473 LocationMarkerMap::iterator i;
475 if (location == transport_loop_location()) {
476 update_loop_range_view (true);
479 if (location == transport_punch_location()) {
480 update_punch_range_view (true);
483 for (i = location_markers.begin(); i != location_markers.end(); ++i) {
484 if ((*i).first == location) {
486 location_markers.erase (i);
493 Editor::tm_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
495 if (tm_marker_menu == 0) {
496 build_tm_marker_menu ();
499 marker_menu_item = item;
500 tm_marker_menu->popup (1, ev->time);
505 Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
508 if ((marker = reinterpret_cast<Marker *> (item->get_data("marker"))) == 0) {
509 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
514 Location * loc = find_location_from_marker (marker, is_start);
515 if (loc == transport_loop_location() || loc == transport_punch_location()) {
516 if (transport_marker_menu == 0) {
517 build_range_marker_menu (true);
519 marker_menu_item = item;
520 transport_marker_menu->popup (1, ev->time);
523 if (loc->is_mark()) {
525 if (loc->is_session_range ()) {
526 if (session_range_marker_menu == 0) {
527 build_marker_menu (true);
529 markerMenu = session_range_marker_menu;
531 if (marker_menu == 0)
532 build_marker_menu (false);
533 markerMenu = marker_menu;
537 // GTK2FIX use action group sensitivity
539 if (children.size() >= 3) {
540 MenuItem * loopitem = &children[2];
542 if (loc->is_mark()) {
543 loopitem->set_sensitive(false);
546 loopitem->set_sensitive(true);
551 marker_menu_item = item;
552 markerMenu->popup (1, ev->time);
555 if (loc->is_range_marker()) {
556 if (range_marker_menu == 0){
557 build_range_marker_menu (false);
559 marker_menu_item = item;
560 range_marker_menu->popup (1, ev->time);
566 Editor::new_transport_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item*)
568 if (new_transport_marker_menu == 0) {
569 build_new_transport_marker_menu ();
572 new_transport_marker_menu->popup (1, ev->time);
577 Editor::transport_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item*)
579 if (transport_marker_menu == 0) {
580 build_range_marker_menu (true);
583 transport_marker_menu->popup (1, ev->time);
587 Editor::build_marker_menu (bool session_range)
589 using namespace Menu_Helpers;
591 Menu *markerMenu = new Menu;
593 session_range_marker_menu = markerMenu;
595 marker_menu = markerMenu;
597 MenuList& items = markerMenu->items();
598 markerMenu->set_name ("ArdourContextMenu");
600 items.push_back (MenuElem (_("Locate to here"), sigc::mem_fun(*this, &Editor::marker_menu_set_playhead)));
601 items.push_back (MenuElem (_("Play from here"), sigc::mem_fun(*this, &Editor::marker_menu_play_from)));
602 items.push_back (MenuElem (_("Move Mark to Playhead"), sigc::mem_fun(*this, &Editor::marker_menu_set_from_playhead)));
604 items.push_back (SeparatorElem());
606 items.push_back (MenuElem (_("Create range to next marker"), sigc::mem_fun(*this, &Editor::marker_menu_range_to_next)));
608 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &Editor::marker_menu_hide)));
612 items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &Editor::marker_menu_rename)));
613 items.push_back (MenuElem (_("Lock"), sigc::bind (sigc::mem_fun(*this, &Editor::marker_menu_lock), true)));
614 items.push_back (MenuElem (_("Unlock"), sigc::bind (sigc::mem_fun(*this, &Editor::marker_menu_lock), false)));
616 items.push_back (SeparatorElem());
618 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
622 Editor::build_range_marker_menu (bool loop_or_punch)
624 using namespace Menu_Helpers;
626 Menu *markerMenu = new Menu;
628 transport_marker_menu = markerMenu;
630 range_marker_menu = markerMenu;
632 MenuList& items = markerMenu->items();
633 markerMenu->set_name ("ArdourContextMenu");
635 items.push_back (MenuElem (_("Play Range"), sigc::mem_fun(*this, &Editor::marker_menu_play_range)));
636 items.push_back (MenuElem (_("Locate to Range Mark"), sigc::mem_fun(*this, &Editor::marker_menu_set_playhead)));
637 items.push_back (MenuElem (_("Play from Range Mark"), sigc::mem_fun(*this, &Editor::marker_menu_play_from)));
638 if (! loop_or_punch) {
639 items.push_back (MenuElem (_("Loop Range"), sigc::mem_fun(*this, &Editor::marker_menu_loop_range)));
641 items.push_back (MenuElem (_("Set Range Mark from Playhead"), sigc::mem_fun(*this, &Editor::marker_menu_set_from_playhead)));
642 if (!Profile->get_sae()) {
643 items.push_back (MenuElem (_("Set Range from Range Selection"), sigc::mem_fun(*this, &Editor::marker_menu_set_from_selection)));
646 items.push_back (SeparatorElem());
647 items.push_back (MenuElem (_("Export Range"), sigc::mem_fun(*this, &Editor::export_range)));
648 items.push_back (SeparatorElem());
650 if (!loop_or_punch) {
651 items.push_back (MenuElem (_("Hide Range"), sigc::mem_fun(*this, &Editor::marker_menu_hide)));
652 items.push_back (MenuElem (_("Rename Range"), sigc::mem_fun(*this, &Editor::marker_menu_rename)));
653 items.push_back (MenuElem (_("Remove Range"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
654 items.push_back (SeparatorElem());
657 items.push_back (MenuElem (_("Separate Regions in Range"), sigc::mem_fun(*this, &Editor::marker_menu_separate_regions_using_location)));
658 items.push_back (MenuElem (_("Select All in Range"), sigc::mem_fun(*this, &Editor::marker_menu_select_all_selectables_using_range)));
659 if (!Profile->get_sae()) {
660 items.push_back (MenuElem (_("Select Range"), sigc::mem_fun(*this, &Editor::marker_menu_select_using_range)));
665 Editor::build_tm_marker_menu ()
667 using namespace Menu_Helpers;
669 tm_marker_menu = new Menu;
670 MenuList& items = tm_marker_menu->items();
671 tm_marker_menu->set_name ("ArdourContextMenu");
673 items.push_back (MenuElem (_("Edit"), sigc::mem_fun(*this, &Editor::marker_menu_edit)));
674 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
678 Editor::build_new_transport_marker_menu ()
680 using namespace Menu_Helpers;
682 new_transport_marker_menu = new Menu;
683 MenuList& items = new_transport_marker_menu->items();
684 new_transport_marker_menu->set_name ("ArdourContextMenu");
686 items.push_back (MenuElem (_("Set Loop Range"), sigc::mem_fun(*this, &Editor::new_transport_marker_menu_set_loop)));
687 items.push_back (MenuElem (_("Set Punch Range"), sigc::mem_fun(*this, &Editor::new_transport_marker_menu_set_punch)));
689 new_transport_marker_menu->signal_unmap().connect ( sigc::mem_fun(*this, &Editor::new_transport_marker_menu_popdown));
693 Editor::marker_menu_hide ()
697 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
698 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
705 if ((l = find_location_from_marker (marker, is_start)) != 0) {
706 l->set_hidden (true, this);
711 Editor::marker_menu_select_using_range ()
715 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
716 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
723 if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
724 set_selection_from_range (*l);
729 Editor::marker_menu_select_all_selectables_using_range ()
733 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
734 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
741 if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
742 select_all_within (l->start(), l->end() - 1, 0, DBL_MAX, track_views, Selection::Set);
748 Editor::marker_menu_separate_regions_using_location ()
752 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
753 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
760 if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
761 separate_regions_using_location (*l);
767 Editor::marker_menu_play_from ()
771 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
772 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
779 if ((l = find_location_from_marker (marker, is_start)) != 0) {
782 _session->request_locate (l->start(), true);
785 //_session->request_bounded_roll (l->start(), l->end());
788 _session->request_locate (l->start(), true);
790 _session->request_locate (l->end(), true);
797 Editor::marker_menu_set_playhead ()
801 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
802 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
809 if ((l = find_location_from_marker (marker, is_start)) != 0) {
812 _session->request_locate (l->start(), false);
816 _session->request_locate (l->start(), false);
818 _session->request_locate (l->end(), false);
825 Editor::marker_menu_range_to_next ()
832 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
833 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
840 if ((l = find_location_from_marker (marker, is_start)) == 0) {
846 _session->locations()->marks_either_side (marker->position(), start, end);
848 if (end != max_frames) {
849 string range_name = l->name();
850 range_name += "-range";
852 Location* newrange = new Location (marker->position(), end, range_name, Location::IsRangeMarker);
853 _session->locations()->add (newrange);
858 Editor::marker_menu_set_from_playhead ()
862 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
863 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
870 if ((l = find_location_from_marker (marker, is_start)) != 0) {
873 l->set_start (_session->audible_frame ());
877 l->set_start (_session->audible_frame ());
879 l->set_end (_session->audible_frame ());
886 Editor::marker_menu_set_from_selection ()
890 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
891 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
898 if ((l = find_location_from_marker (marker, is_start)) != 0) {
905 /* if range selection use first to last */
907 if (mouse_mode == Editing::MouseRange) {
908 if (!selection->time.empty()) {
909 l->set_start (selection->time.start());
910 l->set_end (selection->time.end_frame());
914 if (!selection->regions.empty()) {
915 l->set_start (selection->regions.start());
916 l->set_end (selection->regions.end_frame());
925 Editor::marker_menu_play_range ()
929 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
930 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
937 if ((l = find_location_from_marker (marker, is_start)) != 0) {
940 _session->request_locate (l->start(), true);
943 _session->request_bounded_roll (l->start(), l->end());
950 Editor::marker_menu_loop_range ()
954 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
955 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
962 if ((l = find_location_from_marker (marker, is_start)) != 0) {
964 if ((l2 = transport_loop_location()) != 0) {
965 l2->set (l->start(), l->end());
967 // enable looping, reposition and start rolling
968 _session->request_play_loop(true);
969 _session->request_locate (l2->start(), true);
975 Editor::marker_menu_edit ()
981 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
982 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
986 if ((mm = dynamic_cast<MeterMarker*> (marker)) != 0) {
987 edit_meter_section (&mm->meter());
988 } else if ((tm = dynamic_cast<TempoMarker*> (marker)) != 0) {
989 edit_tempo_section (&tm->tempo());
991 fatal << X_("programming erorr: unhandled marker type in Editor::marker_menu_edit")
998 Editor::marker_menu_remove ()
1004 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1005 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1009 if ((mm = dynamic_cast<MeterMarker*> (marker)) != 0) {
1010 remove_meter_marker (marker_menu_item);
1011 } else if ((tm = dynamic_cast<TempoMarker*> (marker)) != 0) {
1012 remove_tempo_marker (marker_menu_item);
1014 remove_marker (*marker_menu_item, (GdkEvent*) 0);
1019 Editor::marker_menu_lock (bool yn)
1024 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1025 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1032 loc = find_location_from_marker (marker, ignored);
1044 Editor::marker_menu_rename ()
1048 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1049 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1056 loc = find_location_from_marker (marker, is_start);
1060 ArdourPrompter dialog (true);
1063 dialog.set_prompt (_("New Name:"));
1065 if (loc->is_mark()) {
1066 dialog.set_title (_("Rename Mark"));
1068 dialog.set_title (_("Rename Range"));
1071 dialog.set_name ("MarkRenameWindow");
1072 dialog.set_size_request (250, -1);
1073 dialog.set_position (Gtk::WIN_POS_MOUSE);
1075 dialog.add_button (_("Rename"), RESPONSE_ACCEPT);
1076 dialog.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1077 dialog.set_initial_text (loc->name());
1081 switch (dialog.run ()) {
1082 case RESPONSE_ACCEPT:
1088 begin_reversible_command ( _("rename marker") );
1089 XMLNode &before = _session->locations()->get_state();
1091 dialog.get_result(txt);
1092 loc->set_name (txt);
1094 XMLNode &after = _session->locations()->get_state();
1095 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
1096 commit_reversible_command ();
1100 Editor::new_transport_marker_menu_popdown ()
1103 transport_bar_drag_rect->hide();
1105 _drags->break_drag ();
1109 Editor::new_transport_marker_menu_set_loop ()
1111 set_loop_range (temp_location->start(), temp_location->end(), _("set loop range"));
1115 Editor::new_transport_marker_menu_set_punch ()
1117 set_punch_range (temp_location->start(), temp_location->end(), _("set punch range"));
1121 Editor::update_loop_range_view (bool visibility)
1123 if (_session == 0) {
1129 if (_session->get_play_loop() && ((tll = transport_loop_location()) != 0)) {
1131 double x1 = frame_to_pixel (tll->start());
1132 double x2 = frame_to_pixel (tll->end());
1134 transport_loop_range_rect->property_x1() = x1;
1135 transport_loop_range_rect->property_x2() = x2;
1138 transport_loop_range_rect->show();
1141 } else if (visibility) {
1142 transport_loop_range_rect->hide();
1147 Editor::update_punch_range_view (bool visibility)
1149 if (_session == 0) {
1155 if ((_session->config.get_punch_in() || _session->config.get_punch_out()) && ((tpl = transport_punch_location()) != 0)) {
1156 guint track_canvas_width,track_canvas_height;
1157 track_canvas->get_size(track_canvas_width,track_canvas_height);
1158 if (_session->config.get_punch_in()) {
1159 transport_punch_range_rect->property_x1() = frame_to_pixel (tpl->start());
1160 transport_punch_range_rect->property_x2() = (_session->config.get_punch_out() ? frame_to_pixel (tpl->end()) : frame_to_pixel (JACK_MAX_FRAMES));
1162 transport_punch_range_rect->property_x1() = 0;
1163 transport_punch_range_rect->property_x2() = (_session->config.get_punch_out() ? frame_to_pixel (tpl->end()) : track_canvas_width);
1167 transport_punch_range_rect->show();
1169 } else if (visibility) {
1170 transport_punch_range_rect->hide();
1175 Editor::marker_selection_changed ()
1177 if (_session && _session->deletion_in_progress()) {
1181 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
1182 LocationMarkers* lam = i->second;
1185 lam->start->hide_line();
1189 lam->end->hide_line();
1193 for (MarkerSelection::iterator x = selection->markers.begin(); x != selection->markers.end(); ++x) {
1194 (*x)->add_line (cursor_group, 0, _canvas_height);
1199 struct SortLocationsByPosition {
1200 bool operator() (Location* a, Location* b) {
1201 return a->start() < b->start();
1206 Editor::goto_nth_marker (int n)
1211 const Locations::LocationList& l (_session->locations()->list());
1212 Locations::LocationList ordered;
1215 SortLocationsByPosition cmp;
1218 for (Locations::LocationList::iterator i = ordered.begin(); n >= 0 && i != ordered.end(); ++i) {
1219 if ((*i)->is_mark() && !(*i)->is_hidden() && !(*i)->is_session_range()) {
1221 _session->request_locate ((*i)->start(), _session->transport_rolling());