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;
149 if (_show_marker_lines) {
150 lam->show_lines (cursor_group, _canvas_height);
157 Editor::location_changed (Location *location)
159 ENSURE_GUI_THREAD (*this, &Editor::location_changed, location)
161 LocationMarkers *lam = find_location_markers (location);
164 /* a location that isn't "marked" with markers */
168 lam->set_name (location->name ());
169 lam->set_position (location->start(), location->end());
171 if (location->is_auto_loop()) {
172 update_loop_range_view ();
173 } else if (location->is_auto_punch()) {
174 update_punch_range_view ();
179 Editor::location_flags_changed (Location *location, void*)
181 ENSURE_GUI_THREAD (*this, &Editor::location_flags_changed, location, src)
183 LocationMarkers *lam = find_location_markers (location);
186 /* a location that isn't "marked" with markers */
190 // move cd markers to/from cd marker bar as appropriate
191 ensure_cd_marker_updated (lam, location);
193 if (location->is_cd_marker()) {
194 lam->set_color_rgba (location_cd_marker_color);
195 } else if (location->is_mark()) {
196 lam->set_color_rgba (location_marker_color);
197 } else if (location->is_auto_punch()) {
198 lam->set_color_rgba (location_punch_color);
199 } else if (location->is_auto_loop()) {
200 lam->set_color_rgba (location_loop_color);
202 lam->set_color_rgba (location_range_color);
205 if (location->is_hidden()) {
212 void Editor::update_cd_marker_display ()
214 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
215 LocationMarkers * lam = i->second;
216 Location * location = i->first;
218 ensure_cd_marker_updated (lam, location);
222 void Editor::ensure_cd_marker_updated (LocationMarkers * lam, Location * location)
224 if (location->is_cd_marker()
225 && (ruler_cd_marker_action->get_active() && lam->start->get_parent() != cd_marker_group))
227 //cerr << "reparenting non-cd marker so it can be relocated: " << location->name() << endl;
229 lam->start->reparent (*cd_marker_group);
232 lam->end->reparent (*cd_marker_group);
235 else if ( (!location->is_cd_marker() || !ruler_cd_marker_action->get_active())
236 && (lam->start->get_parent() == cd_marker_group))
238 //cerr << "reparenting non-cd marker so it can be relocated: " << location->name() << endl;
239 if (location->is_mark()) {
241 lam->start->reparent (*marker_group);
244 lam->end->reparent (*marker_group);
249 lam->start->reparent (*range_marker_group);
252 lam->end->reparent (*range_marker_group);
258 Editor::LocationMarkers::~LocationMarkers ()
264 Editor::LocationMarkers *
265 Editor::find_location_markers (Location *location) const
267 LocationMarkerMap::const_iterator i;
269 for (i = location_markers.begin(); i != location_markers.end(); ++i) {
270 if ((*i).first == location) {
279 Editor::find_location_from_marker (Marker *marker, bool& is_start) const
281 LocationMarkerMap::const_iterator i;
283 for (i = location_markers.begin(); i != location_markers.end(); ++i) {
284 LocationMarkers *lm = (*i).second;
285 if (lm->start == marker) {
288 } else if (lm->end == marker) {
298 Editor::refresh_location_display_internal (Locations::LocationList& locations)
302 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
303 i->second->valid = false;
308 for (Locations::LocationList::iterator i = locations.begin(); i != locations.end(); ++i) {
310 LocationMarkerMap::iterator x;
312 if ((x = location_markers.find (*i)) != location_markers.end()) {
313 x->second->valid = true;
317 add_new_location (*i);
320 /* remove dead ones */
322 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ) {
324 LocationMarkerMap::iterator tmp;
329 if (!i->second->valid) {
331 location_markers.erase (i);
337 update_punch_range_view (false);
338 update_loop_range_view (false);
342 Editor::refresh_location_display ()
344 ENSURE_GUI_THREAD (*this, &Editor::refresh_location_display)
347 _session->locations()->apply (*this, &Editor::refresh_location_display_internal);
352 Editor::refresh_location_display_s (const PropertyChange&)
354 ENSURE_GUI_THREAD (*this, &Editor::refresh_location_display_s, ignored)
357 _session->locations()->apply (*this, &Editor::refresh_location_display_internal);
362 Editor::LocationMarkers::hide()
371 Editor::LocationMarkers::show()
380 Editor::LocationMarkers::show_lines (ArdourCanvas::Group* g, double h)
382 /* add_line may be required, and it calls show_line even if it isn't */
384 start->add_line (g, 0, h);
387 end->add_line (g, 0, h);
392 Editor::LocationMarkers::hide_lines ()
401 Editor::LocationMarkers::set_lines_vpos (double y, double h)
403 start->set_line_vpos (y, h);
405 end->set_line_vpos (y, h);
410 Editor::LocationMarkers::set_name (const string& str)
412 /* XXX: hack: don't change names of session start/end markers */
414 if (start->type() != Marker::Start) {
415 start->set_name (str);
418 if (end && end->type() != Marker::End) {
424 Editor::LocationMarkers::set_position (framepos_t startf,
427 start->set_position (startf);
428 if (end) { end->set_position (endf); }
432 Editor::LocationMarkers::set_color_rgba (uint32_t rgba)
434 start->set_color_rgba (rgba);
435 if (end) { end->set_color_rgba (rgba); }
439 Editor::mouse_add_new_marker (framepos_t where, bool is_cd, bool is_xrun)
441 string markername, markerprefix;
442 int flags = (is_cd ? Location::IsCDMarker|Location::IsMark : Location::IsMark);
445 markerprefix = "xrun";
446 flags = Location::IsMark;
448 markerprefix = "mark";
452 _session->locations()->next_available_name(markername, markerprefix);
453 if (!is_xrun && !choose_new_marker_name(markername)) {
456 Location *location = new Location (*_session, where, where, markername, (Location::Flags) flags);
457 _session->begin_reversible_command (_("add marker"));
458 XMLNode &before = _session->locations()->get_state();
459 _session->locations()->add (location, true);
460 XMLNode &after = _session->locations()->get_state();
461 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
462 _session->commit_reversible_command ();
464 /* find the marker we just added */
466 LocationMarkers *lam = find_location_markers (location);
468 /* make it the selected marker */
469 selection->set (lam->start);
475 Editor::remove_marker (ArdourCanvas::Item& item, GdkEvent*)
480 if ((marker = static_cast<Marker*> (item.get_data ("marker"))) == 0) {
481 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
485 if (entered_marker == marker) {
486 entered_marker = NULL;
489 Location* loc = find_location_from_marker (marker, is_start);
491 if (_session && loc) {
492 Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &Editor::really_remove_marker), loc));
497 Editor::really_remove_marker (Location* loc)
499 _session->begin_reversible_command (_("remove marker"));
500 XMLNode &before = _session->locations()->get_state();
501 _session->locations()->remove (loc);
502 XMLNode &after = _session->locations()->get_state();
503 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
504 _session->commit_reversible_command ();
509 Editor::location_gone (Location *location)
511 ENSURE_GUI_THREAD (*this, &Editor::location_gone, location)
513 LocationMarkerMap::iterator i;
515 if (location == transport_loop_location()) {
516 update_loop_range_view (true);
519 if (location == transport_punch_location()) {
520 update_punch_range_view (true);
523 for (i = location_markers.begin(); i != location_markers.end(); ++i) {
524 if ((*i).first == location) {
526 location_markers.erase (i);
533 Editor::tempo_or_meter_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
535 marker_menu_item = item;
539 dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
541 bool can_remove = false;
544 can_remove = mm->meter().movable ();
546 can_remove = tm->tempo().movable ();
551 delete tempo_or_meter_marker_menu;
552 build_tempo_or_meter_marker_menu (can_remove);
553 tempo_or_meter_marker_menu->popup (1, ev->time);
557 Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
560 if ((marker = reinterpret_cast<Marker *> (item->get_data("marker"))) == 0) {
561 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
566 Location * loc = find_location_from_marker (marker, is_start);
567 if (loc == transport_loop_location() || loc == transport_punch_location()) {
568 if (transport_marker_menu == 0) {
569 build_range_marker_menu (true);
571 marker_menu_item = item;
572 transport_marker_menu->popup (1, ev->time);
575 if (loc->is_mark()) {
577 if (loc->is_session_range ()) {
578 delete session_range_marker_menu;
579 build_marker_menu (true, loc);
580 markerMenu = session_range_marker_menu;
583 build_marker_menu (false, loc);
584 markerMenu = marker_menu;
588 // GTK2FIX use action group sensitivity
590 if (children.size() >= 3) {
591 MenuItem * loopitem = &children[2];
593 if (loc->is_mark()) {
594 loopitem->set_sensitive(false);
597 loopitem->set_sensitive(true);
602 marker_menu_item = item;
603 markerMenu->popup (1, ev->time);
606 if (loc->is_range_marker()) {
607 if (range_marker_menu == 0){
608 build_range_marker_menu (false);
610 marker_menu_item = item;
611 range_marker_menu->popup (1, ev->time);
617 Editor::new_transport_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item*)
619 if (new_transport_marker_menu == 0) {
620 build_new_transport_marker_menu ();
623 new_transport_marker_menu->popup (1, ev->time);
628 Editor::transport_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item*)
630 if (transport_marker_menu == 0) {
631 build_range_marker_menu (true);
634 transport_marker_menu->popup (1, ev->time);
638 Editor::build_marker_menu (bool session_range, Location* loc)
640 using namespace Menu_Helpers;
642 Menu *markerMenu = new Menu;
644 session_range_marker_menu = markerMenu;
646 marker_menu = markerMenu;
648 MenuList& items = markerMenu->items();
649 markerMenu->set_name ("ArdourContextMenu");
651 items.push_back (MenuElem (_("Locate to Here"), sigc::mem_fun(*this, &Editor::marker_menu_set_playhead)));
652 items.push_back (MenuElem (_("Play from Here"), sigc::mem_fun(*this, &Editor::marker_menu_play_from)));
653 items.push_back (MenuElem (_("Move Mark to Playhead"), sigc::mem_fun(*this, &Editor::marker_menu_set_from_playhead)));
655 items.push_back (SeparatorElem());
657 items.push_back (MenuElem (_("Create Range to Next Marker"), sigc::mem_fun(*this, &Editor::marker_menu_range_to_next)));
659 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &Editor::marker_menu_hide)));
663 items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &Editor::marker_menu_rename)));
665 items.push_back (CheckMenuElem (_("Lock")));
666 CheckMenuItem* lock_item = static_cast<CheckMenuItem*> (&items.back());
667 if (loc->locked ()) {
668 lock_item->set_active ();
670 lock_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_marker_menu_lock));
672 items.push_back (CheckMenuElem (_("Glue to Bars and Beats")));
673 CheckMenuItem* glue_item = static_cast<CheckMenuItem*> (&items.back());
674 if (loc->position_lock_style() == MusicTime) {
675 glue_item->set_active ();
677 glue_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_marker_menu_glue));
679 items.push_back (SeparatorElem());
681 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
685 Editor::build_range_marker_menu (bool loop_or_punch)
687 using namespace Menu_Helpers;
689 Menu *markerMenu = new Menu;
691 transport_marker_menu = markerMenu;
693 range_marker_menu = markerMenu;
695 MenuList& items = markerMenu->items();
696 markerMenu->set_name ("ArdourContextMenu");
698 items.push_back (MenuElem (_("Play Range"), sigc::mem_fun(*this, &Editor::marker_menu_play_range)));
699 items.push_back (MenuElem (_("Locate to Range Mark"), sigc::mem_fun(*this, &Editor::marker_menu_set_playhead)));
700 items.push_back (MenuElem (_("Play from Range Mark"), sigc::mem_fun(*this, &Editor::marker_menu_play_from)));
701 if (! loop_or_punch) {
702 items.push_back (MenuElem (_("Loop Range"), sigc::mem_fun(*this, &Editor::marker_menu_loop_range)));
704 items.push_back (MenuElem (_("Set Range Mark from Playhead"), sigc::mem_fun(*this, &Editor::marker_menu_set_from_playhead)));
705 if (!Profile->get_sae()) {
706 items.push_back (MenuElem (_("Set Range from Range Selection"), sigc::mem_fun(*this, &Editor::marker_menu_set_from_selection)));
709 items.push_back (SeparatorElem());
710 items.push_back (MenuElem (_("Export Range"), sigc::mem_fun(*this, &Editor::export_range)));
711 items.push_back (SeparatorElem());
713 if (!loop_or_punch) {
714 items.push_back (MenuElem (_("Hide Range"), sigc::mem_fun(*this, &Editor::marker_menu_hide)));
715 items.push_back (MenuElem (_("Rename Range"), sigc::mem_fun(*this, &Editor::marker_menu_rename)));
716 items.push_back (MenuElem (_("Remove Range"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
717 items.push_back (SeparatorElem());
720 items.push_back (MenuElem (_("Separate Regions in Range"), sigc::mem_fun(*this, &Editor::marker_menu_separate_regions_using_location)));
721 items.push_back (MenuElem (_("Select All in Range"), sigc::mem_fun(*this, &Editor::marker_menu_select_all_selectables_using_range)));
722 if (!Profile->get_sae()) {
723 items.push_back (MenuElem (_("Select Range"), sigc::mem_fun(*this, &Editor::marker_menu_select_using_range)));
728 Editor::build_tempo_or_meter_marker_menu (bool can_remove)
730 using namespace Menu_Helpers;
732 tempo_or_meter_marker_menu = new Menu;
733 MenuList& items = tempo_or_meter_marker_menu->items();
734 tempo_or_meter_marker_menu->set_name ("ArdourContextMenu");
736 items.push_back (MenuElem (_("Edit"), sigc::mem_fun(*this, &Editor::marker_menu_edit)));
737 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
739 items.back().set_sensitive (can_remove);
743 Editor::build_new_transport_marker_menu ()
745 using namespace Menu_Helpers;
747 new_transport_marker_menu = new Menu;
748 MenuList& items = new_transport_marker_menu->items();
749 new_transport_marker_menu->set_name ("ArdourContextMenu");
751 items.push_back (MenuElem (_("Set Loop Range"), sigc::mem_fun(*this, &Editor::new_transport_marker_menu_set_loop)));
752 items.push_back (MenuElem (_("Set Punch Range"), sigc::mem_fun(*this, &Editor::new_transport_marker_menu_set_punch)));
754 new_transport_marker_menu->signal_unmap().connect ( sigc::mem_fun(*this, &Editor::new_transport_marker_menu_popdown));
758 Editor::marker_menu_hide ()
762 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
763 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
770 if ((l = find_location_from_marker (marker, is_start)) != 0) {
771 l->set_hidden (true, this);
776 Editor::marker_menu_select_using_range ()
780 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
781 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
788 if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
789 set_selection_from_range (*l);
794 Editor::marker_menu_select_all_selectables_using_range ()
798 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
799 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
806 if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
807 select_all_within (l->start(), l->end() - 1, 0, DBL_MAX, track_views, Selection::Set, false);
813 Editor::marker_menu_separate_regions_using_location ()
817 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
818 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
825 if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
826 separate_regions_using_location (*l);
832 Editor::marker_menu_play_from ()
836 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
837 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
844 if ((l = find_location_from_marker (marker, is_start)) != 0) {
847 _session->request_locate (l->start(), true);
850 //_session->request_bounded_roll (l->start(), l->end());
853 _session->request_locate (l->start(), true);
855 _session->request_locate (l->end(), true);
862 Editor::marker_menu_set_playhead ()
866 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
867 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
874 if ((l = find_location_from_marker (marker, is_start)) != 0) {
877 _session->request_locate (l->start(), false);
881 _session->request_locate (l->start(), false);
883 _session->request_locate (l->end(), false);
890 Editor::marker_menu_range_to_next ()
897 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
898 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
905 if ((l = find_location_from_marker (marker, is_start)) == 0) {
911 _session->locations()->marks_either_side (marker->position(), start, end);
913 if (end != max_framepos) {
914 string range_name = l->name();
915 range_name += "-range";
917 Location* newrange = new Location (*_session, marker->position(), end, range_name, Location::IsRangeMarker);
918 _session->locations()->add (newrange);
923 Editor::marker_menu_set_from_playhead ()
927 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
928 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
935 if ((l = find_location_from_marker (marker, is_start)) != 0) {
938 l->set_start (_session->audible_frame ());
942 l->set_start (_session->audible_frame ());
944 l->set_end (_session->audible_frame ());
951 Editor::marker_menu_set_from_selection ()
955 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
956 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
963 if ((l = find_location_from_marker (marker, is_start)) != 0) {
970 /* if range selection use first to last */
972 if (mouse_mode == Editing::MouseRange) {
973 if (!selection->time.empty()) {
974 l->set_start (selection->time.start());
975 l->set_end (selection->time.end_frame());
979 if (!selection->regions.empty()) {
980 l->set_start (selection->regions.start());
981 l->set_end (selection->regions.end_frame());
990 Editor::marker_menu_play_range ()
994 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
995 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1002 if ((l = find_location_from_marker (marker, is_start)) != 0) {
1005 _session->request_locate (l->start(), true);
1008 _session->request_bounded_roll (l->start(), l->end());
1015 Editor::marker_menu_loop_range ()
1019 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1020 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1027 if ((l = find_location_from_marker (marker, is_start)) != 0) {
1029 if ((l2 = transport_loop_location()) != 0) {
1030 l2->set (l->start(), l->end());
1032 // enable looping, reposition and start rolling
1033 _session->request_play_loop(true);
1034 _session->request_locate (l2->start(), true);
1040 Editor::dynamic_cast_marker_object (void* p, MeterMarker** m, TempoMarker** t) const
1042 Marker* marker = reinterpret_cast<Marker*> (p);
1044 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1048 *m = dynamic_cast<MeterMarker*> (marker);
1049 *t = dynamic_cast<TempoMarker*> (marker);
1053 Editor::marker_menu_edit ()
1057 dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
1060 edit_meter_section (&mm->meter());
1062 edit_tempo_section (&tm->tempo());
1067 Editor::marker_menu_remove ()
1071 dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
1074 remove_meter_marker (marker_menu_item);
1076 remove_tempo_marker (marker_menu_item);
1078 remove_marker (*marker_menu_item, (GdkEvent*) 0);
1083 Editor::toggle_marker_menu_lock ()
1087 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1088 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1095 loc = find_location_from_marker (marker, ignored);
1101 if (loc->locked()) {
1109 Editor::marker_menu_rename ()
1113 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1114 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1121 loc = find_location_from_marker (marker, is_start);
1125 ArdourPrompter dialog (true);
1128 dialog.set_prompt (_("New Name:"));
1130 if (loc->is_mark()) {
1131 dialog.set_title (_("Rename Mark"));
1133 dialog.set_title (_("Rename Range"));
1136 dialog.set_name ("MarkRenameWindow");
1137 dialog.set_size_request (250, -1);
1138 dialog.set_position (Gtk::WIN_POS_MOUSE);
1140 dialog.add_button (_("Rename"), RESPONSE_ACCEPT);
1141 dialog.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1142 dialog.set_initial_text (loc->name());
1146 switch (dialog.run ()) {
1147 case RESPONSE_ACCEPT:
1153 begin_reversible_command ( _("rename marker") );
1154 XMLNode &before = _session->locations()->get_state();
1156 dialog.get_result(txt);
1157 loc->set_name (txt);
1159 XMLNode &after = _session->locations()->get_state();
1160 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
1161 commit_reversible_command ();
1165 Editor::new_transport_marker_menu_popdown ()
1168 transport_bar_drag_rect->hide();
1174 Editor::new_transport_marker_menu_set_loop ()
1176 set_loop_range (temp_location->start(), temp_location->end(), _("set loop range"));
1180 Editor::new_transport_marker_menu_set_punch ()
1182 set_punch_range (temp_location->start(), temp_location->end(), _("set punch range"));
1186 Editor::update_loop_range_view (bool visibility)
1188 if (_session == 0) {
1194 if (_session->get_play_loop() && ((tll = transport_loop_location()) != 0)) {
1196 double x1 = frame_to_pixel (tll->start());
1197 double x2 = frame_to_pixel (tll->end());
1199 transport_loop_range_rect->property_x1() = x1;
1200 transport_loop_range_rect->property_x2() = x2;
1203 transport_loop_range_rect->show();
1206 } else if (visibility) {
1207 transport_loop_range_rect->hide();
1212 Editor::update_punch_range_view (bool visibility)
1214 if (_session == 0) {
1220 if ((_session->config.get_punch_in() || _session->config.get_punch_out()) && ((tpl = transport_punch_location()) != 0)) {
1221 guint track_canvas_width,track_canvas_height;
1222 track_canvas->get_size(track_canvas_width,track_canvas_height);
1223 if (_session->config.get_punch_in()) {
1224 transport_punch_range_rect->property_x1() = frame_to_pixel (tpl->start());
1225 transport_punch_range_rect->property_x2() = (_session->config.get_punch_out() ? frame_to_pixel (tpl->end()) : frame_to_pixel (JACK_MAX_FRAMES));
1227 transport_punch_range_rect->property_x1() = 0;
1228 transport_punch_range_rect->property_x2() = (_session->config.get_punch_out() ? frame_to_pixel (tpl->end()) : track_canvas_width);
1232 transport_punch_range_rect->show();
1234 } else if (visibility) {
1235 transport_punch_range_rect->hide();
1240 Editor::marker_selection_changed ()
1242 if (_session && _session->deletion_in_progress()) {
1246 if (!_show_marker_lines) {
1247 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
1248 i->second->hide_lines ();
1252 for (MarkerSelection::iterator x = selection->markers.begin(); x != selection->markers.end(); ++x) {
1253 (*x)->add_line (cursor_group, 0, _canvas_height);
1258 struct SortLocationsByPosition {
1259 bool operator() (Location* a, Location* b) {
1260 return a->start() < b->start();
1265 Editor::goto_nth_marker (int n)
1270 const Locations::LocationList& l (_session->locations()->list());
1271 Locations::LocationList ordered;
1274 SortLocationsByPosition cmp;
1277 for (Locations::LocationList::iterator i = ordered.begin(); n >= 0 && i != ordered.end(); ++i) {
1278 if ((*i)->is_mark() && !(*i)->is_hidden() && !(*i)->is_session_range()) {
1280 _session->request_locate ((*i)->start(), _session->transport_rolling());
1289 Editor::toggle_marker_menu_glue ()
1293 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1294 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1301 loc = find_location_from_marker (marker, ignored);
1307 if (loc->position_lock_style() == MusicTime) {
1308 loc->set_position_lock_style (AudioTime);
1310 loc->set_position_lock_style (MusicTime);
1316 Editor::toggle_marker_lines ()
1318 _show_marker_lines = !_show_marker_lines;
1320 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
1321 if (_show_marker_lines) {
1322 i->second->show_lines (cursor_group, _canvas_height);
1324 i->second->hide_lines ();