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/location.h>
28 #include <ardour/profile.h>
29 #include <pbd/memento_command.h>
33 #include "selection.h"
35 #include "gui_thread.h"
36 #include "simplerect.h"
44 using namespace ARDOUR;
47 using namespace Gtkmm2ext;
50 Editor::clear_marker_display ()
52 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
56 location_markers.clear ();
60 Editor::add_new_location (Location *location)
62 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::add_new_location), location));
64 LocationMarkers *lam = new LocationMarkers;
67 if (location->is_cd_marker()) {
68 color = location_cd_marker_color;
69 } else if (location->is_mark()) {
70 color = location_marker_color;
71 } else if (location->is_auto_loop()) {
72 color = location_loop_color;
73 } else if (location->is_auto_punch()) {
74 color = location_punch_color;
76 color = location_range_color;
79 if (location->is_mark()) {
81 if (location->is_cd_marker() && ruler_cd_marker_action->get_active()) {
82 lam->start = new Marker (*this, *cd_marker_group, color, location->name(), Marker::Mark, location->start());
85 lam->start = new Marker (*this, *marker_group, color, location->name(), Marker::Mark, location->start());
89 } else if (location->is_auto_loop()) {
91 lam->start = new Marker (*this, *transport_marker_group, color,
92 location->name(), Marker::LoopStart, location->start());
93 lam->end = new Marker (*this, *transport_marker_group, color,
94 location->name(), Marker::LoopEnd, location->end());
96 } else if (location->is_auto_punch()) {
98 lam->start = new Marker (*this, *transport_marker_group, color,
99 location->name(), Marker::PunchIn, location->start());
100 lam->end = new Marker (*this, *transport_marker_group, color,
101 location->name(), Marker::PunchOut, location->end());
105 if (location->is_cd_marker() && ruler_cd_marker_action->get_active()) {
106 lam->start = new Marker (*this, *cd_marker_group, color,
107 location->name(), Marker::Start, location->start());
108 lam->end = new Marker (*this, *cd_marker_group, color,
109 location->name(), Marker::End, location->end());
113 lam->start = new Marker (*this, *range_marker_group, color,
114 location->name(), Marker::Start, location->start());
115 lam->end = new Marker (*this, *range_marker_group, color,
116 location->name(), Marker::End, location->end());
120 if (location->is_hidden ()) {
126 location->start_changed.connect (mem_fun(*this, &Editor::location_changed));
127 location->end_changed.connect (mem_fun(*this, &Editor::location_changed));
128 location->changed.connect (mem_fun(*this, &Editor::location_changed));
129 location->name_changed.connect (mem_fun(*this, &Editor::location_changed));
130 location->FlagsChanged.connect (mem_fun(*this, &Editor::location_flags_changed));
132 pair<Location*,LocationMarkers*> newpair;
134 newpair.first = location;
135 newpair.second = lam;
137 location_markers.insert (newpair);
139 if (select_new_marker && location->is_mark()) {
140 selection->set (lam->start);
141 select_new_marker = false;
146 Editor::location_changed (Location *location)
148 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::location_changed), location));
150 LocationMarkers *lam = find_location_markers (location);
153 /* a location that isn't "marked" with markers */
157 lam->set_name (location->name());
158 lam->set_position (location->start(), location->end());
160 if (location->is_auto_loop()) {
161 update_loop_range_view ();
162 } else if (location->is_auto_punch()) {
163 update_punch_range_view ();
168 Editor::location_flags_changed (Location *location, void *src)
170 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::location_flags_changed), location, src));
172 LocationMarkers *lam = find_location_markers (location);
175 /* a location that isn't "marked" with markers */
179 // move cd markers to/from cd marker bar as appropriate
180 ensure_cd_marker_updated (lam, location);
182 if (location->is_cd_marker()) {
183 lam->set_color_rgba (location_cd_marker_color);
184 } else if (location->is_mark()) {
185 lam->set_color_rgba (location_marker_color);
186 } else if (location->is_auto_punch()) {
187 lam->set_color_rgba (location_punch_color);
188 } else if (location->is_auto_loop()) {
189 lam->set_color_rgba (location_loop_color);
191 lam->set_color_rgba (location_range_color);
194 if (location->is_hidden()) {
201 void Editor::update_cd_marker_display ()
203 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
204 LocationMarkers * lam = i->second;
205 Location * location = i->first;
207 ensure_cd_marker_updated (lam, location);
211 void Editor::ensure_cd_marker_updated (LocationMarkers * lam, Location * location)
213 if (location->is_cd_marker()
214 && (ruler_cd_marker_action->get_active() && lam->start->get_parent() != cd_marker_group))
216 //cerr << "reparenting non-cd marker so it can be relocated: " << location->name() << endl;
218 lam->start->reparent (*cd_marker_group);
221 lam->end->reparent (*cd_marker_group);
224 else if ( (!location->is_cd_marker() || !ruler_cd_marker_action->get_active())
225 && (lam->start->get_parent() == cd_marker_group))
227 //cerr << "reparenting non-cd marker so it can be relocated: " << location->name() << endl;
228 if (location->is_mark()) {
230 lam->start->reparent (*marker_group);
233 lam->end->reparent (*marker_group);
238 lam->start->reparent (*range_marker_group);
241 lam->end->reparent (*range_marker_group);
247 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(mem_fun(*this, &Editor::refresh_location_display));
341 session->locations()->apply (*this, &Editor::refresh_location_display_internal);
346 Editor::refresh_location_display_s (Change ignored)
348 ENSURE_GUI_THREAD(bind (mem_fun(*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 start->set_name (str);
373 if (end) { end->set_name (str); }
377 Editor::LocationMarkers::set_position (nframes64_t startf,
380 start->set_position (startf);
381 if (end) { end->set_position (endf); }
385 Editor::LocationMarkers::set_color_rgba (uint32_t rgba)
387 start->set_color_rgba (rgba);
388 if (end) { end->set_color_rgba (rgba); }
392 Editor::mouse_add_new_marker (nframes64_t where, bool is_cd, bool is_xrun)
394 string markername, markerprefix;
395 int flags = (is_cd ? Location::IsCDMarker|Location::IsMark : Location::IsMark);
398 markerprefix = "xrun";
399 flags = Location::IsMark;
401 markerprefix = "mark";
405 session->locations()->next_available_name(markername, markerprefix);
406 if (!is_xrun && !choose_new_marker_name(markername)) {
409 Location *location = new Location (where, where, markername, (Location::Flags) flags);
410 session->begin_reversible_command (_("add marker"));
411 XMLNode &before = session->locations()->get_state();
412 session->locations()->add (location, true);
413 XMLNode &after = session->locations()->get_state();
414 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
415 session->commit_reversible_command ();
417 /* find the marker we just added */
419 LocationMarkers *lam = find_location_markers (location);
421 /* make it the selected marker */
422 selection->set (lam->start);
428 Editor::remove_marker (ArdourCanvas::Item& item, GdkEvent* event)
433 if ((marker = static_cast<Marker*> (item.get_data ("marker"))) == 0) {
434 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
438 if (entered_marker == marker) {
439 entered_marker = NULL;
442 Location* loc = find_location_from_marker (marker, is_start);
444 if (session && loc) {
445 Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::really_remove_marker), loc));
450 Editor::really_remove_marker (Location* loc)
452 session->begin_reversible_command (_("remove marker"));
453 XMLNode &before = session->locations()->get_state();
454 session->locations()->remove (loc);
455 XMLNode &after = session->locations()->get_state();
456 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
457 session->commit_reversible_command ();
462 Editor::location_gone (Location *location)
464 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::location_gone), location));
466 LocationMarkerMap::iterator i;
468 if (location == transport_loop_location()) {
469 update_loop_range_view (true);
472 if (location == transport_punch_location()) {
473 update_punch_range_view (true);
476 for (i = location_markers.begin(); i != location_markers.end(); ++i) {
477 if ((*i).first == location) {
479 location_markers.erase (i);
486 Editor::tm_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
488 if (tm_marker_menu == 0) {
489 build_tm_marker_menu ();
492 marker_menu_item = item;
493 tm_marker_menu->popup (1, ev->time);
498 Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
501 if ((marker = reinterpret_cast<Marker *> (item->get_data("marker"))) == 0) {
502 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
507 Location * loc = find_location_from_marker (marker, is_start);
508 if (loc == transport_loop_location() || loc == transport_punch_location()) {
509 if (transport_marker_menu == 0) {
510 build_range_marker_menu (true);
512 marker_menu_item = item;
513 transport_marker_menu->popup (1, ev->time);
516 if (loc->is_mark()) {
517 bool start_or_end = loc->is_start() || loc->is_end();
520 if (start_end_marker_menu == 0)
521 build_marker_menu (true);
522 markerMenu = start_end_marker_menu;
524 if (marker_menu == 0)
525 build_marker_menu (false);
526 markerMenu = marker_menu;
530 // GTK2FIX use action group sensitivity
532 if (children.size() >= 3) {
533 MenuItem * loopitem = &children[2];
535 if (loc->is_mark()) {
536 loopitem->set_sensitive(false);
539 loopitem->set_sensitive(true);
544 marker_menu_item = item;
545 markerMenu->popup (1, ev->time);
548 if (loc->is_range_marker()) {
549 if (range_marker_menu == 0){
550 build_range_marker_menu (false);
552 marker_menu_item = item;
553 range_marker_menu->popup (1, ev->time);
559 Editor::new_transport_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
561 if (new_transport_marker_menu == 0) {
562 build_new_transport_marker_menu ();
565 new_transport_marker_menu->popup (1, ev->time);
570 Editor::transport_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
572 if (transport_marker_menu == 0) {
573 build_range_marker_menu (true);
576 transport_marker_menu->popup (1, ev->time);
580 Editor::build_marker_menu (bool start_or_end)
582 using namespace Menu_Helpers;
584 Menu *markerMenu = new Menu;
586 start_end_marker_menu = markerMenu;
588 marker_menu = markerMenu;
590 MenuList& items = markerMenu->items();
591 markerMenu->set_name ("ArdourContextMenu");
593 items.push_back (MenuElem (_("Locate to here"), mem_fun(*this, &Editor::marker_menu_set_playhead)));
594 items.push_back (MenuElem (_("Play from here"), mem_fun(*this, &Editor::marker_menu_play_from)));
595 items.push_back (MenuElem (_("Move Mark to Playhead"), mem_fun(*this, &Editor::marker_menu_set_from_playhead)));
597 items.push_back (SeparatorElem());
599 items.push_back (MenuElem (_("Create range to next marker"), mem_fun(*this, &Editor::marker_menu_range_to_next)));
601 items.push_back (MenuElem (_("Hide"), mem_fun(*this, &Editor::marker_menu_hide)));
602 if (start_or_end) return;
603 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &Editor::marker_menu_rename)));
604 items.push_back (MenuElem (_("Lock"), bind (mem_fun(*this, &Editor::marker_menu_lock), true)));
605 items.push_back (MenuElem (_("Unlock"), bind (mem_fun(*this, &Editor::marker_menu_lock), false)));
607 items.push_back (SeparatorElem());
609 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::marker_menu_remove)));
613 Editor::build_range_marker_menu (bool loop_or_punch)
615 using namespace Menu_Helpers;
617 Menu *markerMenu = new Menu;
619 transport_marker_menu = markerMenu;
621 range_marker_menu = markerMenu;
624 MenuList& items = markerMenu->items();
625 markerMenu->set_name ("ArdourContextMenu");
627 items.push_back (MenuElem (_("Play Range"), mem_fun(*this, &Editor::marker_menu_play_range)));
628 items.push_back (MenuElem (_("Locate to Range Mark"), mem_fun(*this, &Editor::marker_menu_set_playhead)));
629 items.push_back (MenuElem (_("Play from Range Mark"), mem_fun(*this, &Editor::marker_menu_play_from)));
630 if (!loop_or_punch) {
631 items.push_back (MenuElem (_("Loop Range"), mem_fun(*this, &Editor::marker_menu_loop_range)));
633 items.push_back (MenuElem (_("Set Range Mark from Playhead"), mem_fun(*this, &Editor::marker_menu_set_from_playhead)));
634 if (!Profile->get_sae()) {
635 items.push_back (MenuElem (_("Set Range from Range Selection"), mem_fun(*this, &Editor::marker_menu_set_from_selection)));
638 items.push_back (SeparatorElem());
640 items.push_back (MenuElem (_("Export Range"), mem_fun(*this, &Editor::marker_menu_export_range)));
642 items.push_back (SeparatorElem());
644 if (!loop_or_punch) {
645 items.push_back (MenuElem (_("Hide Range"), mem_fun(*this, &Editor::marker_menu_hide)));
646 items.push_back (MenuElem (_("Rename Range"), mem_fun(*this, &Editor::marker_menu_rename)));
647 items.push_back (MenuElem (_("Remove Range"), mem_fun(*this, &Editor::marker_menu_remove)));
650 items.push_back (SeparatorElem());
652 items.push_back (MenuElem (_("Separate Regions in Range"), mem_fun(*this, &Editor::marker_menu_separate_regions_using_location)));
653 items.push_back (MenuElem (_("Select All in Range"), mem_fun(*this, &Editor::marker_menu_select_all_selectables_using_range)));
654 if (!Profile->get_sae()) {
655 items.push_back (MenuElem (_("Select Range"), mem_fun(*this, &Editor::marker_menu_select_using_range)));
660 Editor::build_tm_marker_menu ()
662 using namespace Menu_Helpers;
664 tm_marker_menu = new Menu;
665 MenuList& items = tm_marker_menu->items();
666 tm_marker_menu->set_name ("ArdourContextMenu");
668 items.push_back (MenuElem (_("Edit"), mem_fun(*this, &Editor::marker_menu_edit)));
669 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::marker_menu_remove)));
673 Editor::build_new_transport_marker_menu ()
675 using namespace Menu_Helpers;
677 new_transport_marker_menu = new Menu;
678 MenuList& items = new_transport_marker_menu->items();
679 new_transport_marker_menu->set_name ("ArdourContextMenu");
681 items.push_back (MenuElem (_("Set Loop Range"), mem_fun(*this, &Editor::new_transport_marker_menu_set_loop)));
682 items.push_back (MenuElem (_("Set Punch Range"), mem_fun(*this, &Editor::new_transport_marker_menu_set_punch)));
684 new_transport_marker_menu->signal_unmap().connect ( mem_fun(*this, &Editor::new_transport_marker_menu_popdown));
688 Editor::marker_menu_hide ()
692 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
693 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
700 if ((l = find_location_from_marker (marker, is_start)) != 0) {
701 l->set_hidden (true, this);
706 Editor::marker_menu_select_using_range ()
710 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
711 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
718 if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
719 set_selection_from_range (*l);
724 Editor::marker_menu_select_all_selectables_using_range ()
728 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
729 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
736 if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
737 select_all_within (l->start(), l->end() - 1, 0, DBL_MAX, track_views, Selection::Set);
743 Editor::marker_menu_separate_regions_using_location ()
747 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
748 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
755 if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
756 separate_regions_using_location (*l);
762 Editor::marker_menu_play_from ()
766 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
767 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
774 if ((l = find_location_from_marker (marker, is_start)) != 0) {
777 session->request_locate (l->start(), true);
780 //session->request_bounded_roll (l->start(), l->end());
783 session->request_locate (l->start(), true);
785 session->request_locate (l->end(), true);
792 Editor::marker_menu_set_playhead ()
796 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
797 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
804 if ((l = find_location_from_marker (marker, is_start)) != 0) {
807 session->request_locate (l->start(), false);
811 session->request_locate (l->start(), false);
813 session->request_locate (l->end(), false);
820 Editor::marker_menu_export_range ()
824 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
825 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
832 if ((l = find_location_from_marker (marker, is_start)) != 0) {
833 if (l->is_range_marker()) {
834 export_range (l->start(), l->end());
840 Editor::marker_menu_range_to_next ()
847 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
848 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
855 if ((l = find_location_from_marker (marker, is_start)) == 0) {
859 nframes_t end = session->locations()->first_mark_after (marker->position());
861 if (end != max_frames) {
862 string range_name = l->name();
863 range_name += "-range";
865 Location* newrange = new Location (marker->position(), end, range_name, Location::IsRangeMarker);
866 session->locations()->add (newrange);
871 Editor::marker_menu_set_from_playhead ()
875 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
876 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
883 if ((l = find_location_from_marker (marker, is_start)) != 0) {
886 l->set_start (session->audible_frame ());
890 l->set_start (session->audible_frame ());
892 l->set_end (session->audible_frame ());
899 Editor::marker_menu_set_from_selection ()
903 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
904 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
911 if ((l = find_location_from_marker (marker, is_start)) != 0) {
917 /* if range selection use first to last */
919 if (mouse_mode == Editing::MouseRange) {
920 if (!selection->time.empty()) {
921 l->set_start (selection->time.start());
922 l->set_end (selection->time.end_frame());
926 if (!selection->regions.empty()) {
927 l->set_start (selection->regions.start());
928 l->set_end (selection->regions.end_frame());
937 Editor::marker_menu_play_range ()
941 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
942 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
949 if ((l = find_location_from_marker (marker, is_start)) != 0) {
952 session->request_locate (l->start(), true);
955 session->request_bounded_roll (l->start(), l->end());
962 Editor::marker_menu_loop_range ()
966 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
967 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
974 if ((l = find_location_from_marker (marker, is_start)) != 0) {
976 if ((l2 = transport_loop_location()) != 0) {
977 l2->set (l->start(), l->end());
979 // enable looping, reposition and start rolling
980 session->request_play_loop(true);
981 session->request_locate (l2->start(), true);
987 Editor::marker_menu_edit ()
993 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
994 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
998 if ((mm = dynamic_cast<MeterMarker*> (marker)) != 0) {
999 edit_meter_section (&mm->meter());
1000 } else if ((tm = dynamic_cast<TempoMarker*> (marker)) != 0) {
1001 edit_tempo_section (&tm->tempo());
1003 fatal << X_("programming erorr: unhandled marker type in Editor::marker_menu_edit")
1010 Editor::marker_menu_remove ()
1016 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1017 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1021 if ((mm = dynamic_cast<MeterMarker*> (marker)) != 0) {
1022 remove_meter_marker (marker_menu_item);
1023 } else if ((tm = dynamic_cast<TempoMarker*> (marker)) != 0) {
1024 remove_tempo_marker (marker_menu_item);
1026 remove_marker (*marker_menu_item, (GdkEvent*) 0);
1031 Editor::marker_menu_lock (bool yn)
1036 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1037 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1044 loc = find_location_from_marker (marker, ignored);
1056 Editor::marker_menu_rename ()
1060 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1061 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1068 loc = find_location_from_marker (marker, is_start);
1072 ArdourPrompter dialog (true);
1075 dialog.set_prompt (_("New Name:"));
1077 if (loc->is_mark()) {
1078 dialog.set_title (_("Rename Mark"));
1080 dialog.set_title (_("Rename Range"));
1083 dialog.set_name ("MarkRenameWindow");
1084 dialog.set_size_request (250, -1);
1085 dialog.set_position (Gtk::WIN_POS_MOUSE);
1087 dialog.add_button (_("Rename"), RESPONSE_ACCEPT);
1088 dialog.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1089 dialog.set_initial_text (loc->name());
1093 switch (dialog.run ()) {
1094 case RESPONSE_ACCEPT:
1100 begin_reversible_command ( _("rename marker") );
1101 XMLNode &before = session->locations()->get_state();
1103 dialog.get_result(txt);
1104 loc->set_name (txt);
1106 XMLNode &after = session->locations()->get_state();
1107 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
1108 commit_reversible_command ();
1112 Editor::new_transport_marker_menu_popdown ()
1115 transport_bar_drag_rect->hide();
1116 range_marker_drag_rect->hide();
1120 Editor::new_transport_marker_menu_set_loop ()
1122 set_loop_range (temp_location->start(), temp_location->end(), _("set loop range"));
1126 Editor::new_transport_marker_menu_set_punch ()
1128 set_punch_range (temp_location->start(), temp_location->end(), _("set punch range"));
1132 Editor::update_loop_range_view (bool visibility)
1140 if (session->get_play_loop() && ((tll = transport_loop_location()) != 0)) {
1142 double x1 = frame_to_pixel (tll->start());
1143 double x2 = frame_to_pixel (tll->end());
1145 transport_loop_range_rect->property_x1() = x1;
1146 transport_loop_range_rect->property_x2() = x2;
1149 transport_loop_range_rect->show();
1152 } else if (visibility) {
1153 transport_loop_range_rect->hide();
1158 Editor::update_punch_range_view (bool visibility)
1166 if ((Config->get_punch_in() || Config->get_punch_out()) && ((tpl = transport_punch_location()) != 0)) {
1167 guint track_canvas_width,track_canvas_height;
1168 track_canvas->get_size(track_canvas_width,track_canvas_height);
1169 if (Config->get_punch_in()) {
1170 transport_punch_range_rect->property_x1() = frame_to_pixel (tpl->start());
1171 transport_punch_range_rect->property_x2() = (Config->get_punch_out() ? frame_to_pixel (tpl->end()) : frame_to_pixel (JACK_MAX_FRAMES));
1173 transport_punch_range_rect->property_x1() = 0;
1174 transport_punch_range_rect->property_x2() = (Config->get_punch_out() ? frame_to_pixel (tpl->end()) : track_canvas_width);
1178 transport_punch_range_rect->show();
1180 } else if (visibility) {
1181 transport_punch_range_rect->hide();
1186 Editor::marker_selection_changed ()
1188 if (session && session->deletion_in_progress()) {
1192 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
1193 LocationMarkers* lam = i->second;
1196 lam->start->hide_line();
1200 lam->end->hide_line();
1204 edit_point_clock_connection_a.disconnect();
1205 edit_point_clock_connection_b.disconnect();
1207 if (selection->markers.empty()) {
1208 edit_point_clock.set (0);
1212 for (MarkerSelection::iterator x = selection->markers.begin(); x != selection->markers.end(); ++x) {
1213 (*x)->add_line (cursor_group, 0, canvas_height);
1217 edit_point_clock.set (selection->markers.front()->position());
1220 Location* loc = find_location_from_marker (selection->markers.front(), ignored);
1223 edit_point_clock_connection_a = loc->changed.connect (mem_fun (*this, &Editor::selected_marker_moved));
1224 edit_point_clock_connection_b = loc->start_changed.connect (mem_fun (*this, &Editor::selected_marker_moved));
1229 Editor::selected_marker_moved (Location* loc)
1231 edit_point_clock.set (loc->start());
1234 struct SortLocationsByPosition {
1235 bool operator() (Location* a, Location* b) {
1236 return a->start() < b->start();
1241 Editor::goto_nth_marker (int n)
1246 const Locations::LocationList& l (session->locations()->list());
1247 Locations::LocationList ordered;
1250 SortLocationsByPosition cmp;
1253 for (Locations::LocationList::iterator i = ordered.begin(); n >= 0 && i != ordered.end(); ++i) {
1254 if ((*i)->is_mark() && !(*i)->is_hidden() && !(*i)->is_start()) {
1256 session->request_locate ((*i)->start(), session->transport_rolling());