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, *cursor_group, color, location->name(), Marker::Mark, location->start());
86 lam->start = new Marker (*this, *marker_group, *cursor_group, color, location->name(), Marker::Mark, location->start());
90 } else if (location->is_auto_loop()) {
92 lam->start = new Marker (*this, *transport_marker_group, *cursor_group, color,
93 location->name(), Marker::LoopStart, location->start());
94 lam->end = new Marker (*this, *transport_marker_group, *cursor_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, *cursor_group, color,
100 location->name(), Marker::PunchIn, location->start());
101 lam->end = new Marker (*this, *transport_marker_group, *cursor_group, color,
102 location->name(), Marker::PunchOut, location->end());
104 } else if (location->is_session_range()) {
106 lam->start = new Marker (*this, *marker_group, *cursor_group, color, _("start"), Marker::SessionStart, location->start());
107 lam->end = new Marker (*this, *marker_group, *cursor_group, color, _("end"), Marker::SessionEnd, location->end());
111 if (location->is_cd_marker() && ruler_cd_marker_action->get_active()) {
112 lam->start = new Marker (*this, *cd_marker_group, *cursor_group, color,
113 location->name(), Marker::RangeStart, location->start());
114 lam->end = new Marker (*this, *cd_marker_group, *cursor_group, color,
115 location->name(), Marker::RangeEnd, location->end());
118 lam->start = new Marker (*this, *range_marker_group, *cursor_group, color,
119 location->name(), Marker::RangeStart, location->start());
120 lam->end = new Marker (*this, *range_marker_group, *cursor_group, color,
121 location->name(), Marker::RangeEnd, 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 lam->canvas_height_set (_canvas_height);
150 lam->set_show_lines (_show_marker_lines);
154 Editor::location_changed (Location *location)
156 ENSURE_GUI_THREAD (*this, &Editor::location_changed, location)
158 LocationMarkers *lam = find_location_markers (location);
161 /* a location that isn't "marked" with markers */
165 lam->set_name (location->name ());
166 lam->set_position (location->start(), location->end());
168 if (location->is_auto_loop()) {
169 update_loop_range_view ();
170 } else if (location->is_auto_punch()) {
171 update_punch_range_view ();
176 Editor::location_flags_changed (Location *location, void*)
178 ENSURE_GUI_THREAD (*this, &Editor::location_flags_changed, location, src)
180 LocationMarkers *lam = find_location_markers (location);
183 /* a location that isn't "marked" with markers */
187 // move cd markers to/from cd marker bar as appropriate
188 ensure_cd_marker_updated (lam, location);
190 if (location->is_cd_marker()) {
191 lam->set_color_rgba (location_cd_marker_color);
192 } else if (location->is_mark()) {
193 lam->set_color_rgba (location_marker_color);
194 } else if (location->is_auto_punch()) {
195 lam->set_color_rgba (location_punch_color);
196 } else if (location->is_auto_loop()) {
197 lam->set_color_rgba (location_loop_color);
199 lam->set_color_rgba (location_range_color);
202 if (location->is_hidden()) {
209 void Editor::update_cd_marker_display ()
211 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
212 LocationMarkers * lam = i->second;
213 Location * location = i->first;
215 ensure_cd_marker_updated (lam, location);
219 void Editor::ensure_cd_marker_updated (LocationMarkers * lam, Location * location)
221 if (location->is_cd_marker()
222 && (ruler_cd_marker_action->get_active() && lam->start->get_parent() != cd_marker_group))
224 //cerr << "reparenting non-cd marker so it can be relocated: " << location->name() << endl;
226 lam->start->reparent (*cd_marker_group);
229 lam->end->reparent (*cd_marker_group);
232 else if ( (!location->is_cd_marker() || !ruler_cd_marker_action->get_active())
233 && (lam->start->get_parent() == cd_marker_group))
235 //cerr << "reparenting non-cd marker so it can be relocated: " << location->name() << endl;
236 if (location->is_mark()) {
238 lam->start->reparent (*marker_group);
241 lam->end->reparent (*marker_group);
246 lam->start->reparent (*range_marker_group);
249 lam->end->reparent (*range_marker_group);
255 Editor::LocationMarkers::~LocationMarkers ()
261 Editor::LocationMarkers *
262 Editor::find_location_markers (Location *location) const
264 LocationMarkerMap::const_iterator i;
266 for (i = location_markers.begin(); i != location_markers.end(); ++i) {
267 if ((*i).first == location) {
276 Editor::find_location_from_marker (Marker *marker, bool& is_start) const
278 LocationMarkerMap::const_iterator i;
280 for (i = location_markers.begin(); i != location_markers.end(); ++i) {
281 LocationMarkers *lm = (*i).second;
282 if (lm->start == marker) {
285 } else if (lm->end == marker) {
295 Editor::refresh_location_display_internal (Locations::LocationList& locations)
299 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
300 i->second->valid = false;
305 for (Locations::LocationList::iterator i = locations.begin(); i != locations.end(); ++i) {
307 LocationMarkerMap::iterator x;
309 if ((x = location_markers.find (*i)) != location_markers.end()) {
310 x->second->valid = true;
314 add_new_location (*i);
317 /* remove dead ones */
319 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ) {
321 LocationMarkerMap::iterator tmp;
326 if (!i->second->valid) {
328 location_markers.erase (i);
334 update_punch_range_view (false);
335 update_loop_range_view (false);
339 Editor::refresh_location_display ()
341 ENSURE_GUI_THREAD (*this, &Editor::refresh_location_display)
344 _session->locations()->apply (*this, &Editor::refresh_location_display_internal);
349 Editor::refresh_location_display_s (const PropertyChange&)
351 ENSURE_GUI_THREAD (*this, &Editor::refresh_location_display_s, ignored)
354 _session->locations()->apply (*this, &Editor::refresh_location_display_internal);
359 Editor::LocationMarkers::hide()
368 Editor::LocationMarkers::show()
377 Editor::LocationMarkers::canvas_height_set (double h)
379 start->canvas_height_set (h);
381 end->canvas_height_set (h);
386 Editor::LocationMarkers::set_name (const string& str)
388 /* XXX: hack: don't change names of session start/end markers */
390 if (start->type() != Marker::SessionStart) {
391 start->set_name (str);
394 if (end && end->type() != Marker::SessionEnd) {
400 Editor::LocationMarkers::set_position (framepos_t startf,
403 start->set_position (startf);
405 end->set_position (endf);
410 Editor::LocationMarkers::set_color_rgba (uint32_t rgba)
412 start->set_color_rgba (rgba);
414 end->set_color_rgba (rgba);
419 Editor::LocationMarkers::set_show_lines (bool s)
421 start->set_show_line (s);
423 end->set_show_line (s);
428 Editor::LocationMarkers::set_selected (bool s)
430 start->set_selected (s);
432 end->set_selected (s);
437 Editor::LocationMarkers::setup_lines ()
439 start->setup_line ();
446 Editor::mouse_add_new_marker (framepos_t where, bool is_cd, bool is_xrun)
448 string markername, markerprefix;
449 int flags = (is_cd ? Location::IsCDMarker|Location::IsMark : Location::IsMark);
452 markerprefix = "xrun";
453 flags = Location::IsMark;
455 markerprefix = "mark";
459 _session->locations()->next_available_name(markername, markerprefix);
460 if (!is_xrun && !choose_new_marker_name(markername)) {
463 Location *location = new Location (*_session, where, where, markername, (Location::Flags) flags);
464 _session->begin_reversible_command (_("add marker"));
465 XMLNode &before = _session->locations()->get_state();
466 _session->locations()->add (location, true);
467 XMLNode &after = _session->locations()->get_state();
468 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
469 _session->commit_reversible_command ();
471 /* find the marker we just added */
473 LocationMarkers *lam = find_location_markers (location);
475 /* make it the selected marker */
476 selection->set (lam->start);
482 Editor::remove_marker (ArdourCanvas::Item& item, GdkEvent*)
487 if ((marker = static_cast<Marker*> (item.get_data ("marker"))) == 0) {
488 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
492 if (entered_marker == marker) {
493 entered_marker = NULL;
496 Location* loc = find_location_from_marker (marker, is_start);
498 if (_session && loc) {
499 Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &Editor::really_remove_marker), loc));
504 Editor::really_remove_marker (Location* loc)
506 _session->begin_reversible_command (_("remove marker"));
507 XMLNode &before = _session->locations()->get_state();
508 _session->locations()->remove (loc);
509 XMLNode &after = _session->locations()->get_state();
510 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
511 _session->commit_reversible_command ();
516 Editor::location_gone (Location *location)
518 ENSURE_GUI_THREAD (*this, &Editor::location_gone, location)
520 LocationMarkerMap::iterator i;
522 if (location == transport_loop_location()) {
523 update_loop_range_view (true);
526 if (location == transport_punch_location()) {
527 update_punch_range_view (true);
530 for (i = location_markers.begin(); i != location_markers.end(); ++i) {
531 if ((*i).first == location) {
533 location_markers.erase (i);
540 Editor::tempo_or_meter_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
542 marker_menu_item = item;
546 dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
548 bool can_remove = false;
551 can_remove = mm->meter().movable ();
553 can_remove = tm->tempo().movable ();
558 delete tempo_or_meter_marker_menu;
559 build_tempo_or_meter_marker_menu (can_remove);
560 tempo_or_meter_marker_menu->popup (1, ev->time);
564 Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
567 if ((marker = reinterpret_cast<Marker *> (item->get_data("marker"))) == 0) {
568 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
573 Location * loc = find_location_from_marker (marker, is_start);
574 if (loc == transport_loop_location() || loc == transport_punch_location()) {
575 if (transport_marker_menu == 0) {
576 build_range_marker_menu (true);
578 marker_menu_item = item;
579 transport_marker_menu->popup (1, ev->time);
582 if (loc->is_mark()) {
584 if (loc->is_session_range ()) {
585 delete session_range_marker_menu;
586 build_marker_menu (true, loc);
587 markerMenu = session_range_marker_menu;
590 build_marker_menu (false, loc);
591 markerMenu = marker_menu;
595 // GTK2FIX use action group sensitivity
597 if (children.size() >= 3) {
598 MenuItem * loopitem = &children[2];
600 if (loc->is_mark()) {
601 loopitem->set_sensitive(false);
604 loopitem->set_sensitive(true);
609 marker_menu_item = item;
610 markerMenu->popup (1, ev->time);
613 if (loc->is_range_marker()) {
614 if (range_marker_menu == 0){
615 build_range_marker_menu (false);
617 marker_menu_item = item;
618 range_marker_menu->popup (1, ev->time);
624 Editor::new_transport_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item*)
626 if (new_transport_marker_menu == 0) {
627 build_new_transport_marker_menu ();
630 new_transport_marker_menu->popup (1, ev->time);
635 Editor::transport_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item*)
637 if (transport_marker_menu == 0) {
638 build_range_marker_menu (true);
641 transport_marker_menu->popup (1, ev->time);
645 Editor::build_marker_menu (bool session_range, Location* loc)
647 using namespace Menu_Helpers;
649 Menu *markerMenu = new Menu;
651 session_range_marker_menu = markerMenu;
653 marker_menu = markerMenu;
655 MenuList& items = markerMenu->items();
656 markerMenu->set_name ("ArdourContextMenu");
658 items.push_back (MenuElem (_("Locate to Here"), sigc::mem_fun(*this, &Editor::marker_menu_set_playhead)));
659 items.push_back (MenuElem (_("Play from Here"), sigc::mem_fun(*this, &Editor::marker_menu_play_from)));
660 items.push_back (MenuElem (_("Move Mark to Playhead"), sigc::mem_fun(*this, &Editor::marker_menu_set_from_playhead)));
662 items.push_back (SeparatorElem());
664 items.push_back (MenuElem (_("Create Range to Next Marker"), sigc::mem_fun(*this, &Editor::marker_menu_range_to_next)));
666 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &Editor::marker_menu_hide)));
670 items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &Editor::marker_menu_rename)));
672 items.push_back (CheckMenuElem (_("Lock")));
673 CheckMenuItem* lock_item = static_cast<CheckMenuItem*> (&items.back());
674 if (loc->locked ()) {
675 lock_item->set_active ();
677 lock_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_marker_menu_lock));
679 items.push_back (CheckMenuElem (_("Glue to Bars and Beats")));
680 CheckMenuItem* glue_item = static_cast<CheckMenuItem*> (&items.back());
681 if (loc->position_lock_style() == MusicTime) {
682 glue_item->set_active ();
684 glue_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_marker_menu_glue));
686 items.push_back (SeparatorElem());
688 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
692 Editor::build_range_marker_menu (bool loop_or_punch)
694 using namespace Menu_Helpers;
696 Menu *markerMenu = new Menu;
698 transport_marker_menu = markerMenu;
700 range_marker_menu = markerMenu;
702 MenuList& items = markerMenu->items();
703 markerMenu->set_name ("ArdourContextMenu");
705 items.push_back (MenuElem (_("Play Range"), sigc::mem_fun(*this, &Editor::marker_menu_play_range)));
706 items.push_back (MenuElem (_("Locate to Range Mark"), sigc::mem_fun(*this, &Editor::marker_menu_set_playhead)));
707 items.push_back (MenuElem (_("Play from Range Mark"), sigc::mem_fun(*this, &Editor::marker_menu_play_from)));
708 if (! loop_or_punch) {
709 items.push_back (MenuElem (_("Loop Range"), sigc::mem_fun(*this, &Editor::marker_menu_loop_range)));
711 items.push_back (MenuElem (_("Set Range Mark from Playhead"), sigc::mem_fun(*this, &Editor::marker_menu_set_from_playhead)));
712 if (!Profile->get_sae()) {
713 items.push_back (MenuElem (_("Set Range from Range Selection"), sigc::mem_fun(*this, &Editor::marker_menu_set_from_selection)));
716 items.push_back (SeparatorElem());
717 items.push_back (MenuElem (_("Export Range"), sigc::mem_fun(*this, &Editor::export_range)));
718 items.push_back (SeparatorElem());
720 if (!loop_or_punch) {
721 items.push_back (MenuElem (_("Hide Range"), sigc::mem_fun(*this, &Editor::marker_menu_hide)));
722 items.push_back (MenuElem (_("Rename Range"), sigc::mem_fun(*this, &Editor::marker_menu_rename)));
723 items.push_back (MenuElem (_("Remove Range"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
724 items.push_back (SeparatorElem());
727 items.push_back (MenuElem (_("Separate Regions in Range"), sigc::mem_fun(*this, &Editor::marker_menu_separate_regions_using_location)));
728 items.push_back (MenuElem (_("Select All in Range"), sigc::mem_fun(*this, &Editor::marker_menu_select_all_selectables_using_range)));
729 if (!Profile->get_sae()) {
730 items.push_back (MenuElem (_("Select Range"), sigc::mem_fun(*this, &Editor::marker_menu_select_using_range)));
735 Editor::build_tempo_or_meter_marker_menu (bool can_remove)
737 using namespace Menu_Helpers;
739 tempo_or_meter_marker_menu = new Menu;
740 MenuList& items = tempo_or_meter_marker_menu->items();
741 tempo_or_meter_marker_menu->set_name ("ArdourContextMenu");
743 items.push_back (MenuElem (_("Edit"), sigc::mem_fun(*this, &Editor::marker_menu_edit)));
744 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
746 items.back().set_sensitive (can_remove);
750 Editor::build_new_transport_marker_menu ()
752 using namespace Menu_Helpers;
754 new_transport_marker_menu = new Menu;
755 MenuList& items = new_transport_marker_menu->items();
756 new_transport_marker_menu->set_name ("ArdourContextMenu");
758 items.push_back (MenuElem (_("Set Loop Range"), sigc::mem_fun(*this, &Editor::new_transport_marker_menu_set_loop)));
759 items.push_back (MenuElem (_("Set Punch Range"), sigc::mem_fun(*this, &Editor::new_transport_marker_menu_set_punch)));
761 new_transport_marker_menu->signal_unmap().connect ( sigc::mem_fun(*this, &Editor::new_transport_marker_menu_popdown));
765 Editor::marker_menu_hide ()
769 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
770 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
777 if ((l = find_location_from_marker (marker, is_start)) != 0) {
778 l->set_hidden (true, this);
783 Editor::marker_menu_select_using_range ()
787 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
788 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
795 if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
796 set_selection_from_range (*l);
801 Editor::marker_menu_select_all_selectables_using_range ()
805 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
806 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
813 if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
814 select_all_within (l->start(), l->end() - 1, 0, DBL_MAX, track_views, Selection::Set, false);
820 Editor::marker_menu_separate_regions_using_location ()
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) && (l->end() > l->start())) {
833 separate_regions_using_location (*l);
839 Editor::marker_menu_play_from ()
843 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
844 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
851 if ((l = find_location_from_marker (marker, is_start)) != 0) {
854 _session->request_locate (l->start(), true);
857 //_session->request_bounded_roll (l->start(), l->end());
860 _session->request_locate (l->start(), true);
862 _session->request_locate (l->end(), true);
869 Editor::marker_menu_set_playhead ()
873 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
874 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
881 if ((l = find_location_from_marker (marker, is_start)) != 0) {
884 _session->request_locate (l->start(), false);
888 _session->request_locate (l->start(), false);
890 _session->request_locate (l->end(), false);
897 Editor::marker_menu_range_to_next ()
904 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
905 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
912 if ((l = find_location_from_marker (marker, is_start)) == 0) {
918 _session->locations()->marks_either_side (marker->position(), start, end);
920 if (end != max_framepos) {
921 string range_name = l->name();
922 range_name += "-range";
924 Location* newrange = new Location (*_session, marker->position(), end, range_name, Location::IsRangeMarker);
925 _session->locations()->add (newrange);
930 Editor::marker_menu_set_from_playhead ()
934 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
935 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
942 if ((l = find_location_from_marker (marker, is_start)) != 0) {
945 l->set_start (_session->audible_frame ());
949 l->set_start (_session->audible_frame ());
951 l->set_end (_session->audible_frame ());
958 Editor::marker_menu_set_from_selection ()
962 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
963 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
970 if ((l = find_location_from_marker (marker, is_start)) != 0) {
977 /* if range selection use first to last */
979 if (mouse_mode == Editing::MouseRange) {
980 if (!selection->time.empty()) {
981 l->set_start (selection->time.start());
982 l->set_end (selection->time.end_frame());
986 if (!selection->regions.empty()) {
987 l->set_start (selection->regions.start());
988 l->set_end (selection->regions.end_frame());
997 Editor::marker_menu_play_range ()
1001 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1002 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1009 if ((l = find_location_from_marker (marker, is_start)) != 0) {
1012 _session->request_locate (l->start(), true);
1015 _session->request_bounded_roll (l->start(), l->end());
1022 Editor::marker_menu_loop_range ()
1026 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1027 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1034 if ((l = find_location_from_marker (marker, is_start)) != 0) {
1036 if ((l2 = transport_loop_location()) != 0) {
1037 l2->set (l->start(), l->end());
1039 // enable looping, reposition and start rolling
1040 _session->request_play_loop(true);
1041 _session->request_locate (l2->start(), true);
1047 Editor::dynamic_cast_marker_object (void* p, MeterMarker** m, TempoMarker** t) const
1049 Marker* marker = reinterpret_cast<Marker*> (p);
1051 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1055 *m = dynamic_cast<MeterMarker*> (marker);
1056 *t = dynamic_cast<TempoMarker*> (marker);
1060 Editor::marker_menu_edit ()
1064 dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
1067 edit_meter_section (&mm->meter());
1069 edit_tempo_section (&tm->tempo());
1074 Editor::marker_menu_remove ()
1078 dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
1081 remove_meter_marker (marker_menu_item);
1083 remove_tempo_marker (marker_menu_item);
1085 remove_marker (*marker_menu_item, (GdkEvent*) 0);
1090 Editor::toggle_marker_menu_lock ()
1094 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1095 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1102 loc = find_location_from_marker (marker, ignored);
1108 if (loc->locked()) {
1116 Editor::marker_menu_rename ()
1120 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1121 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1128 loc = find_location_from_marker (marker, is_start);
1132 ArdourPrompter dialog (true);
1135 dialog.set_prompt (_("New Name:"));
1137 if (loc->is_mark()) {
1138 dialog.set_title (_("Rename Mark"));
1140 dialog.set_title (_("Rename Range"));
1143 dialog.set_name ("MarkRenameWindow");
1144 dialog.set_size_request (250, -1);
1145 dialog.set_position (Gtk::WIN_POS_MOUSE);
1147 dialog.add_button (_("Rename"), RESPONSE_ACCEPT);
1148 dialog.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1149 dialog.set_initial_text (loc->name());
1153 switch (dialog.run ()) {
1154 case RESPONSE_ACCEPT:
1160 begin_reversible_command ( _("rename marker") );
1161 XMLNode &before = _session->locations()->get_state();
1163 dialog.get_result(txt);
1164 loc->set_name (txt);
1166 XMLNode &after = _session->locations()->get_state();
1167 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
1168 commit_reversible_command ();
1172 Editor::new_transport_marker_menu_popdown ()
1175 transport_bar_drag_rect->hide();
1181 Editor::new_transport_marker_menu_set_loop ()
1183 set_loop_range (temp_location->start(), temp_location->end(), _("set loop range"));
1187 Editor::new_transport_marker_menu_set_punch ()
1189 set_punch_range (temp_location->start(), temp_location->end(), _("set punch range"));
1193 Editor::update_loop_range_view (bool visibility)
1195 if (_session == 0) {
1201 if (_session->get_play_loop() && ((tll = transport_loop_location()) != 0)) {
1203 double x1 = frame_to_pixel (tll->start());
1204 double x2 = frame_to_pixel (tll->end());
1206 transport_loop_range_rect->property_x1() = x1;
1207 transport_loop_range_rect->property_x2() = x2;
1210 transport_loop_range_rect->show();
1213 } else if (visibility) {
1214 transport_loop_range_rect->hide();
1219 Editor::update_punch_range_view (bool visibility)
1221 if (_session == 0) {
1227 if ((_session->config.get_punch_in() || _session->config.get_punch_out()) && ((tpl = transport_punch_location()) != 0)) {
1228 guint track_canvas_width,track_canvas_height;
1229 track_canvas->get_size(track_canvas_width,track_canvas_height);
1230 if (_session->config.get_punch_in()) {
1231 transport_punch_range_rect->property_x1() = frame_to_pixel (tpl->start());
1232 transport_punch_range_rect->property_x2() = (_session->config.get_punch_out() ? frame_to_pixel (tpl->end()) : frame_to_pixel (JACK_MAX_FRAMES));
1234 transport_punch_range_rect->property_x1() = 0;
1235 transport_punch_range_rect->property_x2() = (_session->config.get_punch_out() ? frame_to_pixel (tpl->end()) : track_canvas_width);
1239 transport_punch_range_rect->show();
1241 } else if (visibility) {
1242 transport_punch_range_rect->hide();
1247 Editor::marker_selection_changed ()
1249 if (_session && _session->deletion_in_progress()) {
1253 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
1254 i->second->set_selected (false);
1257 for (MarkerSelection::iterator x = selection->markers.begin(); x != selection->markers.end(); ++x) {
1258 (*x)->set_selected (true);
1262 struct SortLocationsByPosition {
1263 bool operator() (Location* a, Location* b) {
1264 return a->start() < b->start();
1269 Editor::goto_nth_marker (int n)
1274 const Locations::LocationList& l (_session->locations()->list());
1275 Locations::LocationList ordered;
1278 SortLocationsByPosition cmp;
1281 for (Locations::LocationList::iterator i = ordered.begin(); n >= 0 && i != ordered.end(); ++i) {
1282 if ((*i)->is_mark() && !(*i)->is_hidden() && !(*i)->is_session_range()) {
1284 _session->request_locate ((*i)->start(), _session->transport_rolling());
1293 Editor::toggle_marker_menu_glue ()
1297 if ((marker = reinterpret_cast<Marker *> (marker_menu_item->get_data ("marker"))) == 0) {
1298 fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
1305 loc = find_location_from_marker (marker, ignored);
1311 if (loc->position_lock_style() == MusicTime) {
1312 loc->set_position_lock_style (AudioTime);
1314 loc->set_position_lock_style (MusicTime);
1320 Editor::toggle_marker_lines ()
1322 _show_marker_lines = !_show_marker_lines;
1324 for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
1325 i->second->set_show_lines (_show_marker_lines);