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.
23 #include <gtkmm2ext/utils.h>
25 #include "ardour/utils.h"
26 #include "ardour/configuration.h"
27 #include "ardour/session.h"
28 #include "pbd/memento_command.h"
30 #include "ardour_ui.h"
31 #include "clock_group.h"
32 #include "gui_thread.h"
34 #include "location_ui.h"
41 using namespace ARDOUR;
44 using namespace Gtkmm2ext;
46 LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
47 : SessionHandlePtr (0) /* explicitly set below */
49 , item_table (1, 6, false)
50 , start_clock (X_("locationstart"), true, "", true, false)
51 , start_to_playhead_button (_("Use PH"))
52 , end_clock (X_("locationend"), true, "", true, false)
53 , end_to_playhead_button (_("Use PH"))
54 , length_clock (X_("locationlength"), true, "", true, false, true)
55 , cd_check_button (_("CD"))
56 , hide_check_button (_("Hide"))
57 , lock_check_button (_("Lock"))
58 , glue_check_button (_("Glue"))
59 , scms_check_button (_("SCMS"))
60 , preemph_check_button (_("Pre-Emphasis"))
63 i_am_the_modifier = 0;
65 remove_button.set_image (*manage (new Image (Stock::REMOVE, Gtk::ICON_SIZE_MENU)));
67 number_label.set_name ("LocationEditNumberLabel");
68 name_label.set_name ("LocationEditNameLabel");
69 name_entry.set_name ("LocationEditNameEntry");
70 cd_check_button.set_name ("LocationEditCdButton");
71 hide_check_button.set_name ("LocationEditHideButton");
72 lock_check_button.set_name ("LocationEditLockButton");
73 glue_check_button.set_name ("LocationEditGlueButton");
74 remove_button.set_name ("LocationEditRemoveButton");
75 isrc_label.set_name ("LocationEditNumberLabel");
76 isrc_entry.set_name ("LocationEditNameEntry");
77 scms_check_button.set_name ("LocationEditCdButton");
78 preemph_check_button.set_name ("LocationEditCdButton");
79 performer_label.set_name ("LocationEditNumberLabel");
80 performer_entry.set_name ("LocationEditNameEntry");
81 composer_label.set_name ("LocationEditNumberLabel");
82 composer_entry.set_name ("LocationEditNameEntry");
84 isrc_label.set_text ("ISRC: ");
85 isrc_label.set_size_request (30, -1);
86 performer_label.set_text ("Performer: ");
87 performer_label.set_size_request (60, -1);
88 composer_label.set_text ("Composer: ");
89 composer_label.set_size_request (60, -1);
91 isrc_entry.set_size_request (112, -1);
92 isrc_entry.set_max_length(12);
93 isrc_entry.set_editable (true);
95 performer_entry.set_size_request (100, -1);
96 performer_entry.set_editable (true);
98 composer_entry.set_size_request (100, -1);
99 composer_entry.set_editable (true);
101 name_label.set_alignment (0, 0.5);
103 cd_track_details_hbox.pack_start (isrc_label, false, false);
104 cd_track_details_hbox.pack_start (isrc_entry, false, false);
105 cd_track_details_hbox.pack_start (scms_check_button, false, false);
106 cd_track_details_hbox.pack_start (preemph_check_button, false, false);
107 cd_track_details_hbox.pack_start (performer_label, false, false);
108 cd_track_details_hbox.pack_start (performer_entry, true, true);
109 cd_track_details_hbox.pack_start (composer_label, false, false);
110 cd_track_details_hbox.pack_start (composer_entry, true, true);
112 isrc_entry.signal_changed().connect (sigc::mem_fun(*this, &LocationEditRow::isrc_entry_changed));
113 performer_entry.signal_changed().connect (sigc::mem_fun(*this, &LocationEditRow::performer_entry_changed));
114 composer_entry.signal_changed().connect (sigc::mem_fun(*this, &LocationEditRow::composer_entry_changed));
115 scms_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::scms_toggled));
116 preemph_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::preemph_toggled));
120 start_hbox.set_spacing (2);
121 start_hbox.pack_start (start_clock, false, false);
122 start_hbox.pack_start (start_to_playhead_button, false, false);
124 /* this is always in this location, no matter what the location is */
126 VBox *rbox = manage (new VBox);
127 rbox->pack_start (remove_button, false, false);
129 item_table.attach (*rbox, 0, 1, 0, 1, FILL, Gtk::AttachOptions (0), 4, 0);
130 item_table.attach (start_hbox, 2, 3, 0, 1, FILL, Gtk::AttachOptions(0), 4, 0);
132 start_to_playhead_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::to_playhead_button_pressed), LocStart));
133 start_clock.ValueChanged.connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::clock_changed), LocStart));
135 end_hbox.set_spacing (2);
136 end_hbox.pack_start (end_clock, false, false);
137 end_hbox.pack_start (end_to_playhead_button, false, false);
139 end_to_playhead_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::to_playhead_button_pressed), LocEnd));
140 end_clock.ValueChanged.connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::clock_changed), LocEnd));
142 length_clock.ValueChanged.connect (sigc::bind ( sigc::mem_fun(*this, &LocationEditRow::clock_changed), LocLength));
144 cd_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::cd_toggled));
145 hide_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::hide_toggled));
146 lock_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::lock_toggled));
147 glue_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::glue_toggled));
149 remove_button.signal_clicked().connect(sigc::mem_fun(*this, &LocationEditRow::remove_button_pressed));
151 pack_start(item_table, true, true);
157 LocationEditRow::~LocationEditRow()
160 connections.drop_connections ();
164 _clock_group->remove (start_clock);
165 _clock_group->remove (end_clock);
166 _clock_group->remove (length_clock);
171 LocationEditRow::set_clock_group (ClockGroup& cg)
174 _clock_group->remove (start_clock);
175 _clock_group->remove (end_clock);
176 _clock_group->remove (length_clock);
181 _clock_group->add (start_clock);
182 _clock_group->add (end_clock);
183 _clock_group->add (length_clock);
187 LocationEditRow::set_session (Session *sess)
189 SessionHandlePtr::set_session (sess);
195 start_clock.set_session (_session);
196 end_clock.set_session (_session);
197 length_clock.set_session (_session);
201 LocationEditRow::set_number (int num)
206 number_label.set_text (string_compose ("%1", number));
211 LocationEditRow::set_location (Location *loc)
214 connections.drop_connections ();
225 if (!hide_check_button.get_parent()) {
226 item_table.attach (hide_check_button, 6, 7, 0, 1, FILL, Gtk::FILL, 4, 0);
227 item_table.attach (lock_check_button, 7, 8, 0, 1, FILL, Gtk::FILL, 4, 0);
228 item_table.attach (glue_check_button, 8, 9, 0, 1, FILL, Gtk::FILL, 4, 0);
230 hide_check_button.set_active (location->is_hidden());
231 lock_check_button.set_active (location->locked());
232 glue_check_button.set_active (location->position_lock_style() == MusicTime);
234 if (location->is_auto_loop() || location-> is_auto_punch()) {
235 // use label instead of entry
237 name_label.set_text (location->name());
238 name_label.set_size_request (80, -1);
240 if (!name_label.get_parent()) {
241 item_table.attach (name_label, 1, 2, 0, 1, FILL, FILL, 4, 0);
248 name_entry.set_text (location->name());
249 name_entry.set_size_request (100, -1);
250 name_entry.set_editable (true);
251 name_entry.signal_changed().connect (sigc::mem_fun(*this, &LocationEditRow::name_entry_changed));
253 if (!name_entry.get_parent()) {
254 item_table.attach (name_entry, 1, 2, 0, 1, FILL | EXPAND, FILL, 4, 0);
258 if (!cd_check_button.get_parent()) {
259 item_table.attach (cd_check_button, 5, 6, 0, 1, FILL, Gtk::AttachOptions (0), 4, 0);
262 if (location->is_session_range()) {
263 remove_button.set_sensitive (false);
266 cd_check_button.set_active (location->is_cd_marker());
267 cd_check_button.show();
269 if (location->start() == _session->current_start_frame()) {
270 cd_check_button.set_sensitive (false);
272 cd_check_button.set_sensitive (true);
275 hide_check_button.show();
276 lock_check_button.show();
277 glue_check_button.show();
280 start_clock.set (location->start(), true);
283 if (!location->is_mark()) {
284 if (!end_hbox.get_parent()) {
285 item_table.attach (end_hbox, 3, 4, 0, 1, FILL, Gtk::AttachOptions (0), 4, 0);
287 if (!length_clock.get_parent()) {
288 end_hbox.pack_start (length_clock, false, false);
291 end_clock.set (location->end(), true);
292 length_clock.set (location->length(), true);
297 ARDOUR_UI::instance()->set_tip (remove_button, _("Remove this range"));
298 ARDOUR_UI::instance()->set_tip (start_clock, _("Start time - middle click to locate here"));
299 ARDOUR_UI::instance()->set_tip (end_clock, _("End time - middle click to locate here"));
300 ARDOUR_UI::instance()->set_tip (length_clock, _("Length"));
302 ARDOUR_UI::instance()->tooltips().set_tip (start_to_playhead_button, _("Set range start from playhead location"));
303 ARDOUR_UI::instance()->tooltips().set_tip (end_to_playhead_button, _("Set range end from playhead location"));
307 ARDOUR_UI::instance()->set_tip (remove_button, _("Remove this marker"));
308 ARDOUR_UI::instance()->set_tip (start_clock, _("Position - middle click to locate here"));
310 ARDOUR_UI::instance()->tooltips().set_tip (start_to_playhead_button, _("Set marker time from playhead location"));
316 set_clock_sensitivity ();
320 location->start_changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::start_changed, this, _1), gui_context());
321 location->end_changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::end_changed, this, _1), gui_context());
322 location->name_changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::name_changed, this, _1), gui_context());
323 location->changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::location_changed, this, _1), gui_context());
324 location->FlagsChanged.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::flags_changed, this, _1, _2), gui_context());
325 location->LockChanged.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::lock_changed, this, _1), gui_context());
326 location->PositionLockStyleChanged.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::position_lock_style_changed, this, _1), gui_context());
330 LocationEditRow::name_entry_changed ()
332 ENSURE_GUI_THREAD (*this, &LocationEditRow::name_entry_changed)
334 if (i_am_the_modifier || !location) {
338 location->set_name (name_entry.get_text());
343 LocationEditRow::isrc_entry_changed ()
345 ENSURE_GUI_THREAD (*this, &LocationEditRow::isrc_entry_changed)
347 if (i_am_the_modifier || !location) return;
349 if (isrc_entry.get_text() != "" ) {
351 location->cd_info["isrc"] = isrc_entry.get_text();
354 location->cd_info.erase("isrc");
359 LocationEditRow::performer_entry_changed ()
361 ENSURE_GUI_THREAD (*this, &LocationEditRow::performer_entry_changed)
363 if (i_am_the_modifier || !location) return;
365 if (performer_entry.get_text() != "") {
366 location->cd_info["performer"] = performer_entry.get_text();
368 location->cd_info.erase("performer");
373 LocationEditRow::composer_entry_changed ()
375 ENSURE_GUI_THREAD (*this, &LocationEditRow::composer_entry_changed)
377 if (i_am_the_modifier || !location) return;
379 if (composer_entry.get_text() != "") {
380 location->cd_info["composer"] = composer_entry.get_text();
382 location->cd_info.erase("composer");
387 LocationEditRow::to_playhead_button_pressed (LocationPart part)
395 location->set_start (_session->transport_frame ());
398 location->set_end (_session->transport_frame ());
406 LocationEditRow::clock_changed (LocationPart part)
408 if (i_am_the_modifier || !location) {
414 location->set_start (start_clock.current_time());
417 location->set_end (end_clock.current_time());
420 location->set_end (location->start() + length_clock.current_duration());
427 LocationEditRow::cd_toggled ()
429 if (i_am_the_modifier || !location) {
433 //if (cd_check_button.get_active() == location->is_cd_marker()) {
437 if (cd_check_button.get_active()) {
438 if (location->start() <= _session->current_start_frame()) {
439 error << _("You cannot put a CD marker at the start of the session") << endmsg;
440 cd_check_button.set_active (false);
445 location->set_cd (cd_check_button.get_active(), this);
447 if (location->is_cd_marker() && !(location->is_mark())) {
449 if (location->cd_info.find("isrc") != location->cd_info.end()) {
450 isrc_entry.set_text(location->cd_info["isrc"]);
452 if (location->cd_info.find("performer") != location->cd_info.end()) {
453 performer_entry.set_text(location->cd_info["performer"]);
455 if (location->cd_info.find("composer") != location->cd_info.end()) {
456 composer_entry.set_text(location->cd_info["composer"]);
458 if (location->cd_info.find("scms") != location->cd_info.end()) {
459 scms_check_button.set_active(true);
461 if (location->cd_info.find("preemph") != location->cd_info.end()) {
462 preemph_check_button.set_active(true);
465 if (!cd_track_details_hbox.get_parent()) {
466 item_table.attach (cd_track_details_hbox, 0, 7, 1, 2, FILL | EXPAND, FILL, 4, 0);
468 // item_table.resize(2, 7);
469 cd_track_details_hbox.show_all();
471 } else if (cd_track_details_hbox.get_parent()){
473 item_table.remove (cd_track_details_hbox);
474 // item_table.resize(1, 7);
475 redraw_ranges(); /* EMIT_SIGNAL */
480 LocationEditRow::hide_toggled ()
482 if (i_am_the_modifier || !location) {
486 location->set_hidden (hide_check_button.get_active(), this);
490 LocationEditRow::lock_toggled ()
492 if (i_am_the_modifier || !location) {
496 if (location->locked()) {
504 LocationEditRow::glue_toggled ()
506 if (i_am_the_modifier || !location) {
510 if (location->position_lock_style() == AudioTime) {
511 location->set_position_lock_style (MusicTime);
513 location->set_position_lock_style (AudioTime);
518 LocationEditRow::remove_button_pressed ()
524 remove_requested (location); /* EMIT_SIGNAL */
530 LocationEditRow::scms_toggled ()
532 if (i_am_the_modifier || !location) return;
534 if (scms_check_button.get_active()) {
535 location->cd_info["scms"] = "on";
537 location->cd_info.erase("scms");
543 LocationEditRow::preemph_toggled ()
545 if (i_am_the_modifier || !location) return;
547 if (preemph_check_button.get_active()) {
548 location->cd_info["preemph"] = "on";
550 location->cd_info.erase("preemph");
555 LocationEditRow::end_changed (ARDOUR::Location *)
557 ENSURE_GUI_THREAD (*this, &LocationEditRow::end_changed, loc)
559 if (!location) return;
561 // update end and length
564 end_clock.set (location->end());
565 length_clock.set (location->length());
571 LocationEditRow::start_changed (ARDOUR::Location*)
573 if (!location) return;
575 // update end and length
578 start_clock.set (location->start());
580 if (location->start() == _session->current_start_frame()) {
581 cd_check_button.set_sensitive (false);
583 cd_check_button.set_sensitive (true);
590 LocationEditRow::name_changed (ARDOUR::Location *)
592 if (!location) return;
594 // update end and length
597 name_entry.set_text(location->name());
598 name_label.set_text(location->name());
605 LocationEditRow::location_changed (ARDOUR::Location*)
608 if (!location) return;
612 start_clock.set (location->start());
613 end_clock.set (location->end());
614 length_clock.set (location->length());
616 set_clock_sensitivity ();
623 LocationEditRow::flags_changed (ARDOUR::Location*, void *)
631 cd_check_button.set_active (location->is_cd_marker());
632 hide_check_button.set_active (location->is_hidden());
633 glue_check_button.set_active (location->position_lock_style() == MusicTime);
639 LocationEditRow::lock_changed (ARDOUR::Location*)
647 lock_check_button.set_active (location->locked());
649 set_clock_sensitivity ();
655 LocationEditRow::position_lock_style_changed (ARDOUR::Location*)
663 glue_check_button.set_active (location->position_lock_style() == MusicTime);
669 LocationEditRow::focus_name() {
670 name_entry.grab_focus();
674 LocationEditRow::set_clock_sensitivity ()
676 start_clock.set_sensitive (!location->locked());
677 end_clock.set_sensitive (!location->locked());
678 length_clock.set_sensitive (!location->locked());
681 /*------------------------------------------------------------------------*/
683 LocationUI::LocationUI ()
684 : add_location_button (_("New Marker"))
685 , add_range_button (_("New Range"))
687 i_am_the_modifier = 0;
689 _clock_group = new ClockGroup;
691 VBox* vbox = manage (new VBox);
693 Table* table = manage (new Table (2, 2));
694 table->set_spacings (2);
695 table->set_col_spacing (0, 32);
698 Label* l = manage (new Label (_("<b>Loop/Punch Ranges</b>")));
699 l->set_alignment (0, 0.5);
700 l->set_use_markup (true);
701 table->attach (*l, 0, 2, table_row, table_row + 1);
704 loop_edit_row.set_clock_group (*_clock_group);
705 punch_edit_row.set_clock_group (*_clock_group);
707 loop_punch_box.pack_start (loop_edit_row, false, false);
708 loop_punch_box.pack_start (punch_edit_row, false, false);
710 table->attach (loop_punch_box, 1, 2, table_row, table_row + 1);
713 vbox->pack_start (*table, false, false);
715 table = manage (new Table (3, 2));
716 table->set_spacings (2);
717 table->set_col_spacing (0, 32);
720 table->attach (*manage (new Label ("")), 0, 2, table_row, table_row + 1, Gtk::SHRINK, Gtk::SHRINK);
723 l = manage (new Label (_("<b>Markers (Including CD Index)</b>")));
724 l->set_alignment (0, 0.5);
725 l->set_use_markup (true);
726 table->attach (*l, 0, 2, table_row, table_row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
729 location_rows.set_name("LocationLocRows");
730 location_rows_scroller.add (location_rows);
731 location_rows_scroller.set_name ("LocationLocRowsScroller");
732 location_rows_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
733 location_rows_scroller.set_size_request (-1, 130);
737 loc_frame_box.set_spacing (5);
738 loc_frame_box.set_border_width (5);
739 loc_frame_box.set_name("LocationFrameBox");
741 loc_frame_box.pack_start (location_rows_scroller, true, true);
743 add_location_button.set_name ("LocationAddLocationButton");
745 table->attach (loc_frame_box, 0, 2, table_row, table_row + 1);
748 loc_range_panes.pack1 (*table, true, false);
750 table = manage (new Table (3, 2));
751 table->set_spacings (2);
752 table->set_col_spacing (0, 32);
755 table->attach (*manage (new Label ("")), 0, 2, table_row, table_row + 1, Gtk::SHRINK, Gtk::SHRINK);
758 l = manage (new Label (_("<b>Ranges (Including CD Track Ranges)</b>")));
759 l->set_alignment (0, 0.5);
760 l->set_use_markup (true);
761 table->attach (*l, 0, 2, table_row, table_row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
764 range_rows.set_name("LocationRangeRows");
765 range_rows_scroller.add (range_rows);
766 range_rows_scroller.set_name ("LocationRangeRowsScroller");
767 range_rows_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
768 range_rows_scroller.set_size_request (-1, 130);
770 range_frame_box.set_spacing (5);
771 range_frame_box.set_name("LocationFrameBox");
772 range_frame_box.set_border_width (5);
773 range_frame_box.pack_start (range_rows_scroller, true, true);
775 add_range_button.set_name ("LocationAddRangeButton");
777 table->attach (range_frame_box, 0, 2, table_row, table_row + 1);
780 loc_range_panes.pack2 (*table, true, false);
782 HBox* add_button_box = manage (new HBox);
783 add_button_box->pack_start (add_location_button, true, true);
784 add_button_box->pack_start (add_range_button, true, true);
786 vbox->pack_start (loc_range_panes, true, true);
787 vbox->pack_start (*add_button_box, false, false);
791 add_location_button.signal_clicked().connect (sigc::mem_fun(*this, &LocationUI::add_new_location));
792 add_range_button.signal_clicked().connect (sigc::mem_fun(*this, &LocationUI::add_new_range));
796 signal_map().connect (sigc::mem_fun (*this, &LocationUI::refresh_location_list));
799 LocationUI::~LocationUI()
805 LocationUI::do_location_remove (ARDOUR::Location *loc)
807 /* this is handled internally by Locations, but there's
808 no point saving state etc. when we know the marker
812 if (loc->is_session_range()) {
816 _session->begin_reversible_command (_("remove marker"));
817 XMLNode &before = _session->locations()->get_state();
818 _session->locations()->remove (loc);
819 XMLNode &after = _session->locations()->get_state();
820 _session->add_command(new MementoCommand<Locations>(*(_session->locations()), &before, &after));
821 _session->commit_reversible_command ();
827 LocationUI::location_remove_requested (ARDOUR::Location *loc)
829 // must do this to prevent problems when destroying
830 // the effective sender of this event
832 Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &LocationUI::do_location_remove), loc));
837 LocationUI::location_redraw_ranges ()
843 struct LocationSortByStart {
844 bool operator() (Location *a, Location *b) {
845 return a->start() < b->start();
850 LocationUI::location_added (Location* location)
852 if (location->is_auto_punch()) {
853 punch_edit_row.set_location(location);
854 } else if (location->is_auto_loop()) {
855 loop_edit_row.set_location(location);
856 } else if (location->is_range_marker() || location->is_mark()) {
857 Locations::LocationList loc = _session->locations()->list ();
858 loc.sort (LocationSortByStart ());
860 LocationEditRow* erow = manage (new LocationEditRow (_session, location));
862 erow->set_clock_group (*_clock_group);
863 erow->remove_requested.connect (sigc::mem_fun (*this, &LocationUI::location_remove_requested));
865 Box_Helpers::BoxList & children = location->is_range_marker() ? range_rows.children () : location_rows.children ();
867 /* Step through the location list and the GUI list to find the place to insert */
868 Locations::LocationList::iterator i = loc.begin ();
869 Box_Helpers::BoxList::iterator j = children.begin ();
870 while (i != loc.end()) {
872 if (location->flags() != (*i)->flags()) {
873 /* Skip locations in the session list that aren't of the right type */
878 if (*i == location) {
879 children.insert (j, Box_Helpers::Element (*erow, PACK_SHRINK, 1, PACK_START));
885 if (j != children.end()) {
890 range_rows.show_all ();
891 location_rows.show_all ();
896 LocationUI::location_removed (Location* location)
898 ENSURE_GUI_THREAD (*this, &LocationUI::location_removed, location)
900 if (location->is_auto_punch()) {
901 punch_edit_row.set_location(0);
902 } else if (location->is_auto_loop()) {
903 loop_edit_row.set_location(0);
904 } else if (location->is_range_marker() || location->is_mark()) {
905 Box_Helpers::BoxList& children = location->is_range_marker() ? range_rows.children () : location_rows.children ();
906 for (Box_Helpers::BoxList::iterator i = children.begin(); i != children.end(); ++i) {
907 LocationEditRow* r = dynamic_cast<LocationEditRow*> (i->get_widget());
908 if (r && r->get_location() == location) {
917 LocationUI::map_locations (Locations::LocationList& locations)
919 Locations::LocationList::iterator i;
922 Locations::LocationList temp = locations;
923 LocationSortByStart cmp;
928 for (n = 0, i = locations.begin(); i != locations.end(); ++n, ++i) {
930 Location* location = *i;
932 if (location->is_mark()) {
933 LocationEditRow* erow = manage (new LocationEditRow (_session, location, mark_n));
935 erow->set_clock_group (*_clock_group);
936 erow->remove_requested.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested));
937 erow->redraw_ranges.connect (sigc::mem_fun(*this, &LocationUI::location_redraw_ranges));
939 Box_Helpers::BoxList & loc_children = location_rows.children();
940 loc_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START));
941 if (location == newest_location) {
945 } else if (location->is_auto_punch()) {
946 punch_edit_row.set_session (_session);
947 punch_edit_row.set_location (location);
948 punch_edit_row.show_all();
949 } else if (location->is_auto_loop()) {
950 loop_edit_row.set_session (_session);
951 loop_edit_row.set_location (location);
952 loop_edit_row.show_all();
954 LocationEditRow* erow = manage (new LocationEditRow(_session, location));
956 erow->set_clock_group (*_clock_group);
957 erow->remove_requested.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested));
959 Box_Helpers::BoxList & range_children = range_rows.children();
960 range_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START));
964 range_rows.show_all();
965 location_rows.show_all();
969 LocationUI::add_new_location()
974 framepos_t where = _session->audible_frame();
975 _session->locations()->next_available_name(markername,"mark");
976 Location *location = new Location (*_session, where, where, markername, Location::IsMark);
977 if (Config->get_name_new_markers()) {
978 newest_location = location;
980 _session->begin_reversible_command (_("add marker"));
981 XMLNode &before = _session->locations()->get_state();
982 _session->locations()->add (location, true);
983 XMLNode &after = _session->locations()->get_state();
984 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
985 _session->commit_reversible_command ();
991 LocationUI::add_new_range()
996 framepos_t where = _session->audible_frame();
997 _session->locations()->next_available_name(rangename,"unnamed");
998 Location *location = new Location (*_session, where, where, rangename, Location::IsRangeMarker);
999 _session->begin_reversible_command (_("add range marker"));
1000 XMLNode &before = _session->locations()->get_state();
1001 _session->locations()->add (location, true);
1002 XMLNode &after = _session->locations()->get_state();
1003 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
1004 _session->commit_reversible_command ();
1009 LocationUI::refresh_location_list ()
1011 ENSURE_GUI_THREAD (*this, &LocationUI::refresh_location_list)
1012 using namespace Box_Helpers;
1014 // this is just too expensive to do when window is not shown
1019 BoxList & loc_children = location_rows.children();
1020 BoxList & range_children = range_rows.children();
1022 loc_children.clear();
1023 range_children.clear();
1026 _session->locations()->apply (*this, &LocationUI::map_locations);
1031 LocationUI::set_session(ARDOUR::Session* s)
1033 SessionHandlePtr::set_session (s);
1036 _session->locations()->changed.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::locations_changed, this, _1), gui_context());
1037 _session->locations()->StateChanged.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::refresh_location_list, this), gui_context());
1038 _session->locations()->added.connect (_session_connections, invalidator (*this), ui_bind (&LocationUI::location_added, this, _1), gui_context());
1039 _session->locations()->removed.connect (_session_connections, invalidator (*this), ui_bind (&LocationUI::location_removed, this, _1), gui_context());
1040 _clock_group->set_clock_mode (clock_mode_from_session_instant_xml ());
1043 loop_edit_row.set_session (s);
1044 punch_edit_row.set_session (s);
1046 refresh_location_list ();
1050 LocationUI::locations_changed (Locations::Change c)
1052 /* removal is signalled by both a removed and a changed signal emission from Locations,
1053 so we don't need to refresh the list on a removal
1055 if (c != Locations::REMOVAL) {
1056 refresh_location_list ();
1061 LocationUI::session_going_away()
1063 ENSURE_GUI_THREAD (*this, &LocationUI::session_going_away);
1065 using namespace Box_Helpers;
1066 BoxList & loc_children = location_rows.children();
1067 BoxList & range_children = range_rows.children();
1069 loc_children.clear();
1070 range_children.clear();
1072 loop_edit_row.set_session (0);
1073 loop_edit_row.set_location (0);
1075 punch_edit_row.set_session (0);
1076 punch_edit_row.set_location (0);
1078 SessionHandlePtr::session_going_away ();
1082 LocationUI::get_state () const
1084 XMLNode* node = new XMLNode (X_("LocationUI"));
1085 node->add_property (X_("clock-mode"), enum_2_string (_clock_group->clock_mode ()));
1090 LocationUI::clock_mode_from_session_instant_xml () const
1092 XMLNode* node = _session->instant_xml (X_("LocationUI"));
1094 return AudioClock::Frames;
1097 XMLProperty* p = node->property (X_("clock-mode"));
1099 return AudioClock::Frames;
1102 return (AudioClock::Mode) string_2_enum (p->value (), AudioClock::Mode);
1106 /*------------------------*/
1108 LocationUIWindow::LocationUIWindow ()
1109 : ArdourWindow (_("Locations"))
1111 set_wmclass(X_("ardour_locations"), PROGRAM_NAME);
1112 set_name ("LocationWindow");
1117 LocationUIWindow::~LocationUIWindow()
1122 LocationUIWindow::on_map ()
1124 ArdourWindow::on_map ();
1125 _ui.refresh_location_list();
1129 LocationUIWindow::on_delete_event (GdkEventAny*)
1136 LocationUIWindow::set_session (Session *s)
1138 ArdourWindow::set_session (s);
1139 _ui.set_session (s);
1143 LocationUIWindow::session_going_away ()
1145 ArdourWindow::session_going_away ();