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>
24 #include <gtkmm2ext/stop_signal.h>
25 #include <gtkmm2ext/window_title.h>
27 #include <ardour/utils.h>
28 #include <ardour/configuration.h>
29 #include <ardour/session.h>
30 #include <pbd/memento_command.h>
32 #include "ardour_ui.h"
34 #include "location_ui.h"
37 #include "gui_thread.h"
41 using namespace ARDOUR
;
44 using namespace Gtkmm2ext
;
46 LocationEditRow::LocationEditRow(Session
* sess
, Location
* loc
, int32_t num
)
47 : location(0), session(0),
48 item_table (1, 7, false),
49 start_set_button (_("Use PH")),
50 start_go_button (_("Go")),
51 start_clock (X_("locationstart"), true, X_("LocationEditRowClock"), true),
52 end_set_button (_("Use PH")),
53 end_go_button (_("Go")),
54 end_clock (X_("locationend"), true, X_("LocationEditRowClock"), true),
55 length_clock (X_("locationlength"), true, X_("LocationEditRowClock"), true, true),
56 cd_check_button (_("CD")),
57 hide_check_button (_("Hidden")),
58 remove_button (_("Remove")),
59 scms_check_button (_("SCMS")),
60 preemph_check_button (_("Pre-Emphasis"))
64 i_am_the_modifier
= 0;
66 number_label
.set_name ("LocationEditNumberLabel");
67 name_label
.set_name ("LocationEditNameLabel");
68 name_entry
.set_name ("LocationEditNameEntry");
69 start_set_button
.set_name ("LocationEditSetButton");
70 start_go_button
.set_name ("LocationEditGoButton");
71 end_set_button
.set_name ("LocationEditSetButton");
72 end_go_button
.set_name ("LocationEditGoButton");
73 cd_check_button
.set_name ("LocationEditCdButton");
74 hide_check_button
.set_name ("LocationEditHideButton");
75 remove_button
.set_name ("LocationEditRemoveButton");
76 isrc_label
.set_name ("LocationEditNumberLabel");
77 isrc_entry
.set_name ("LocationEditNameEntry");
78 scms_check_button
.set_name ("LocationEditCdButton");
79 preemph_check_button
.set_name ("LocationEditCdButton");
80 performer_label
.set_name ("LocationEditNumberLabel");
81 performer_entry
.set_name ("LocationEditNameEntry");
82 composer_label
.set_name ("LocationEditNumberLabel");
83 composer_entry
.set_name ("LocationEditNameEntry");
85 ARDOUR_UI::instance()->tooltips().set_tip(start_set_button
, _("Set value to Playhead"));
86 ARDOUR_UI::instance()->tooltips().set_tip(end_set_button
, _("Set value to Playhead"));
88 isrc_label
.set_text ("ISRC: ");
89 isrc_label
.set_size_request (30, -1);
90 performer_label
.set_text ("Performer: ");
91 performer_label
.set_size_request (60, -1);
92 composer_label
.set_text ("Composer: ");
93 composer_label
.set_size_request (60, -1);
95 isrc_entry
.set_size_request (112, -1);
96 isrc_entry
.set_max_length(12);
97 isrc_entry
.set_editable (true);
99 performer_entry
.set_size_request (100, -1);
100 performer_entry
.set_editable (true);
102 composer_entry
.set_size_request (100, -1);
103 composer_entry
.set_editable (true);
105 cd_track_details_hbox
.pack_start (isrc_label
, false, false);
106 cd_track_details_hbox
.pack_start (isrc_entry
, false, false);
107 cd_track_details_hbox
.pack_start (scms_check_button
, false, false);
108 cd_track_details_hbox
.pack_start (preemph_check_button
, false, false);
109 cd_track_details_hbox
.pack_start (performer_label
, false, false);
110 cd_track_details_hbox
.pack_start (performer_entry
, true, true);
111 cd_track_details_hbox
.pack_start (composer_label
, false, false);
112 cd_track_details_hbox
.pack_start (composer_entry
, true, true);
114 isrc_entry
.signal_changed().connect (mem_fun(*this, &LocationEditRow::isrc_entry_changed
));
115 performer_entry
.signal_changed().connect (mem_fun(*this, &LocationEditRow::performer_entry_changed
));
116 composer_entry
.signal_changed().connect (mem_fun(*this, &LocationEditRow::composer_entry_changed
));
117 scms_check_button
.signal_toggled().connect(mem_fun(*this, &LocationEditRow::scms_toggled
));
118 preemph_check_button
.signal_toggled().connect(mem_fun(*this, &LocationEditRow::preemph_toggled
));
124 item_table
.attach (number_label
, 0, 1, 0, 1, FILL
, FILL
, 3, 0);
126 start_hbox
.pack_start (start_go_button
, false, false);
127 start_hbox
.pack_start (start_clock
, false, false);
128 start_hbox
.pack_start (start_set_button
, false, false);
130 item_table
.attach (start_hbox
, 2, 3, 0, 1, FILL
, FILL
, 4, 0);
133 start_set_button
.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::set_button_pressed
), LocStart
));
134 start_go_button
.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::go_button_pressed
), LocStart
));
135 start_clock
.ValueChanged
.connect (bind (mem_fun (*this, &LocationEditRow::clock_changed
), LocStart
));
136 start_clock
.ChangeAborted
.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted
), LocStart
));
139 end_hbox
.pack_start (end_go_button
, false, false);
140 end_hbox
.pack_start (end_clock
, false, false);
141 end_hbox
.pack_start (end_set_button
, false, false);
143 //item_table.attach (end_hbox, 2, 3, 0, 1, 0, 0, 4, 0);
145 end_set_button
.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::set_button_pressed
), LocEnd
));
146 end_go_button
.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::go_button_pressed
), LocEnd
));
147 end_clock
.ValueChanged
.connect (bind (mem_fun (*this, &LocationEditRow::clock_changed
), LocEnd
));
148 end_clock
.ChangeAborted
.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted
), LocEnd
));
150 // item_table.attach (length_clock, 3, 4, 0, 1, 0, 0, 4, 0);
151 length_clock
.ValueChanged
.connect (bind ( mem_fun(*this, &LocationEditRow::clock_changed
), LocLength
));
152 length_clock
.ChangeAborted
.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted
), LocLength
));
154 // item_table.attach (cd_check_button, 4, 5, 0, 1, 0, Gtk::FILL, 4, 0);
155 // item_table.attach (hide_check_button, 5, 6, 0, 1, 0, Gtk::FILL, 4, 0);
156 // item_table.attach (remove_button, 7, 8, 0, 1, 0, Gtk::FILL, 4, 0);
158 cd_check_button
.signal_toggled().connect(mem_fun(*this, &LocationEditRow::cd_toggled
));
159 hide_check_button
.signal_toggled().connect(mem_fun(*this, &LocationEditRow::hide_toggled
));
161 remove_button
.signal_clicked().connect(mem_fun(*this, &LocationEditRow::remove_button_pressed
));
163 pack_start(item_table
, true, true);
169 LocationEditRow::~LocationEditRow()
172 start_changed_connection
.disconnect();
173 end_changed_connection
.disconnect();
174 name_changed_connection
.disconnect();
175 changed_connection
.disconnect();
176 flags_changed_connection
.disconnect();
181 LocationEditRow::set_session (Session
*sess
)
185 if (!session
) return;
187 start_clock
.set_session (session
);
188 end_clock
.set_session (session
);
189 length_clock
.set_session (session
);
194 LocationEditRow::set_number (int num
)
199 number_label
.set_text (string_compose ("%1", number
));
204 LocationEditRow::set_location (Location
*loc
)
207 start_changed_connection
.disconnect();
208 end_changed_connection
.disconnect();
209 name_changed_connection
.disconnect();
210 changed_connection
.disconnect();
211 flags_changed_connection
.disconnect();
216 if (!location
) return;
218 if (!hide_check_button
.get_parent()) {
219 item_table
.attach (hide_check_button
, 6, 7, 0, 1, FILL
, Gtk::FILL
, 4, 0);
221 hide_check_button
.set_active (location
->is_hidden());
223 if (location
->is_auto_loop() || location
-> is_auto_punch()) {
224 // use label instead of entry
226 name_label
.set_text (location
->name());
227 name_label
.set_size_request (80, -1);
229 if (!name_label
.get_parent()) {
230 item_table
.attach (name_label
, 1, 2, 0, 1, FILL
, FILL
, 4, 0);
237 name_entry
.set_text (location
->name());
238 name_entry
.set_size_request (100, -1);
239 name_entry
.set_editable (true);
240 name_entry
.signal_changed().connect (mem_fun(*this, &LocationEditRow::name_entry_changed
));
242 if (!name_entry
.get_parent()) {
243 item_table
.attach (name_entry
, 1, 2, 0, 1, FILL
| EXPAND
, FILL
, 4, 0);
247 if (!cd_check_button
.get_parent()) {
248 item_table
.attach (cd_check_button
, 5, 6, 0, 1, FILL
, FILL
, 4, 0);
250 if (!remove_button
.get_parent()) {
251 item_table
.attach (remove_button
, 7, 8, 0, 1, FILL
, FILL
, 4, 0);
254 /* XXX i can't find a way to hide the button without messing up
255 the row spacing, so make it insensitive (paul).
258 if (location
->is_end() || location
->is_start()) {
259 remove_button
.set_sensitive (false);
262 cd_check_button
.set_active (location
->is_cd_marker());
263 cd_check_button
.show();
265 if (location
->start() == session
->current_start_frame()) {
266 cd_check_button
.set_sensitive (false);
268 cd_check_button
.set_sensitive (true);
271 hide_check_button
.show();
274 start_clock
.set (location
->start(), true);
277 if (!location
->is_mark()) {
278 if (!end_hbox
.get_parent()) {
279 item_table
.attach (end_hbox
, 3, 4, 0, 1, FILL
, FILL
, 4, 0);
281 if (!length_clock
.get_parent()) {
282 item_table
.attach (length_clock
, 4, 5, 0, 1, FILL
, FILL
, 4, 0);
285 end_clock
.set (location
->end(), true);
286 length_clock
.set (location
->length(), true);
288 end_set_button
.show();
289 end_go_button
.show();
295 end_set_button
.hide();
296 end_go_button
.hide();
302 start_clock
.set_sensitive (!location
->locked());
303 end_clock
.set_sensitive (!location
->locked());
304 length_clock
.set_sensitive (!location
->locked());
306 start_changed_connection
= location
->start_changed
.connect (mem_fun(*this, &LocationEditRow::start_changed
));
307 end_changed_connection
= location
->end_changed
.connect (mem_fun(*this, &LocationEditRow::end_changed
));
308 name_changed_connection
= location
->name_changed
.connect (mem_fun(*this, &LocationEditRow::name_changed
));
309 changed_connection
= location
->changed
.connect (mem_fun(*this, &LocationEditRow::location_changed
));
310 flags_changed_connection
= location
->FlagsChanged
.connect (mem_fun(*this, &LocationEditRow::flags_changed
));
314 LocationEditRow::name_entry_changed ()
316 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::name_entry_changed
));
317 if (i_am_the_modifier
|| !location
) return;
319 location
->set_name (name_entry
.get_text());
324 LocationEditRow::isrc_entry_changed ()
326 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::isrc_entry_changed
));
328 if (i_am_the_modifier
|| !location
) return;
330 if (isrc_entry
.get_text() != "" ) {
332 location
->cd_info
["isrc"] = isrc_entry
.get_text();
335 location
->cd_info
.erase("isrc");
340 LocationEditRow::performer_entry_changed ()
342 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::performer_entry_changed
));
344 if (i_am_the_modifier
|| !location
) return;
346 if (performer_entry
.get_text() != "") {
347 location
->cd_info
["performer"] = performer_entry
.get_text();
349 location
->cd_info
.erase("performer");
354 LocationEditRow::composer_entry_changed ()
356 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::composer_entry_changed
));
358 if (i_am_the_modifier
|| !location
) return;
360 if (composer_entry
.get_text() != "") {
361 location
->cd_info
["composer"] = composer_entry
.get_text();
363 location
->cd_info
.erase("composer");
369 LocationEditRow::set_button_pressed (LocationPart part
)
371 if (!location
) return;
375 location
->set_start (session
->transport_frame ());
378 location
->set_end (session
->transport_frame ());
386 LocationEditRow::go_button_pressed (LocationPart part
)
388 if (!location
) return;
392 ARDOUR_UI::instance()->do_transport_locate (location
->start());
395 ARDOUR_UI::instance()->do_transport_locate (location
->end());
403 LocationEditRow::clock_changed (LocationPart part
)
405 if (i_am_the_modifier
|| !location
) return;
409 location
->set_start (start_clock
.current_time());
412 location
->set_end (end_clock
.current_time());
415 location
->set_end (location
->start() + length_clock
.current_duration());
423 LocationEditRow::change_aborted (LocationPart part
)
425 if (i_am_the_modifier
|| !location
) return;
427 set_location(location
);
431 LocationEditRow::cd_toggled ()
433 if (i_am_the_modifier
|| !location
) {
437 //if (cd_check_button.get_active() == location->is_cd_marker()) {
441 if (cd_check_button
.get_active()) {
442 if (location
->start() <= session
->current_start_frame()) {
443 error
<< _("You cannot put a CD marker at the start of the session") << endmsg
;
444 cd_check_button
.set_active (false);
449 location
->set_cd (cd_check_button
.get_active(), this);
451 if (location
->is_cd_marker() && !(location
->is_mark())) {
453 if (location
->cd_info
.find("isrc") != location
->cd_info
.end()) {
454 isrc_entry
.set_text(location
->cd_info
["isrc"]);
456 if (location
->cd_info
.find("performer") != location
->cd_info
.end()) {
457 performer_entry
.set_text(location
->cd_info
["performer"]);
459 if (location
->cd_info
.find("composer") != location
->cd_info
.end()) {
460 composer_entry
.set_text(location
->cd_info
["composer"]);
462 if (location
->cd_info
.find("scms") != location
->cd_info
.end()) {
463 scms_check_button
.set_active(true);
465 if (location
->cd_info
.find("preemph") != location
->cd_info
.end()) {
466 preemph_check_button
.set_active(true);
469 if (!cd_track_details_hbox
.get_parent()) {
470 item_table
.attach (cd_track_details_hbox
, 1, 8, 1, 2, FILL
| EXPAND
, FILL
, 4, 0);
472 // item_table.resize(2, 7);
473 cd_track_details_hbox
.show_all();
475 } else if (cd_track_details_hbox
.get_parent()){
477 item_table
.remove (cd_track_details_hbox
);
478 // item_table.resize(1, 7);
479 redraw_ranges(); /* EMIT_SIGNAL */
484 LocationEditRow::hide_toggled ()
486 if (i_am_the_modifier
|| !location
) return;
488 location
->set_hidden (hide_check_button
.get_active(), this);
492 LocationEditRow::remove_button_pressed ()
494 if (!location
) return;
496 remove_requested(location
); /* EMIT_SIGNAL */
502 LocationEditRow::scms_toggled ()
504 if (i_am_the_modifier
|| !location
) return;
506 if (scms_check_button
.get_active()) {
507 location
->cd_info
["scms"] = "on";
509 location
->cd_info
.erase("scms");
515 LocationEditRow::preemph_toggled ()
517 if (i_am_the_modifier
|| !location
) return;
519 if (preemph_check_button
.get_active()) {
520 location
->cd_info
["preemph"] = "on";
522 location
->cd_info
.erase("preemph");
527 LocationEditRow::end_changed (ARDOUR::Location
*loc
)
529 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::end_changed
), loc
));
531 if (!location
) return;
533 // update end and length
536 end_clock
.set (location
->end());
537 length_clock
.set (location
->length());
543 LocationEditRow::start_changed (ARDOUR::Location
*loc
)
545 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::start_changed
), loc
));
547 if (!location
) return;
549 // update end and length
552 start_clock
.set (location
->start());
554 if (location
->start() == session
->current_start_frame()) {
555 cd_check_button
.set_sensitive (false);
557 cd_check_button
.set_sensitive (true);
564 LocationEditRow::name_changed (ARDOUR::Location
*loc
)
566 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::name_changed
), loc
));
568 if (!location
) return;
570 // update end and length
573 name_entry
.set_text(location
->name());
574 name_label
.set_text(location
->name());
581 LocationEditRow::location_changed (ARDOUR::Location
*loc
)
583 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::location_changed
), loc
));
585 if (!location
) return;
589 start_clock
.set (location
->start());
590 end_clock
.set (location
->end());
591 length_clock
.set (location
->length());
593 start_clock
.set_sensitive (!location
->locked());
594 end_clock
.set_sensitive (!location
->locked());
595 length_clock
.set_sensitive (!location
->locked());
602 LocationEditRow::flags_changed (ARDOUR::Location
*loc
, void *src
)
604 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::flags_changed
), loc
, src
));
606 if (!location
) return;
610 cd_check_button
.set_active (location
->is_cd_marker());
611 hide_check_button
.set_active (location
->is_hidden());
617 LocationEditRow::focus_name() {
618 name_entry
.grab_focus();
622 LocationUI::LocationUI ()
623 : ArdourDialog ("locations dialog"),
624 add_location_button (_("Add New Location")),
625 add_range_button (_("Add New Range"))
627 i_am_the_modifier
= 0;
629 WindowTitle
title(Glib::get_application_name());
630 title
+= _("Locations");
632 set_title(title
.get_string());
633 set_wmclass(X_("ardour_locations"), "Ardour");
635 set_name ("LocationWindow");
637 get_vbox()->pack_start (location_hpacker
);
639 location_vpacker
.set_border_width (10);
640 location_vpacker
.set_spacing (5);
642 location_vpacker
.pack_start (loop_edit_row
, false, false);
643 location_vpacker
.pack_start (punch_edit_row
, false, false);
645 location_rows
.set_name("LocationLocRows");
646 location_rows_scroller
.add (location_rows
);
647 location_rows_scroller
.set_name ("LocationLocRowsScroller");
648 location_rows_scroller
.set_policy (Gtk::POLICY_NEVER
, Gtk::POLICY_AUTOMATIC
);
649 location_rows_scroller
.set_size_request (-1, 130);
653 loc_frame_box
.set_spacing (5);
654 loc_frame_box
.set_border_width (5);
655 loc_frame_box
.set_name("LocationFrameBox");
657 loc_frame_box
.pack_start (location_rows_scroller
, true, true);
659 add_location_button
.set_name ("LocationAddLocationButton");
660 loc_frame_box
.pack_start (add_location_button
, false, false);
662 loc_frame
.set_name ("LocationLocEditorFrame");
663 loc_frame
.set_label (_("Location (CD Index) Markers"));
664 loc_frame
.add (loc_frame_box
);
665 loc_range_panes
.pack1(loc_frame
, true, false);
668 range_rows
.set_name("LocationRangeRows");
669 range_rows_scroller
.add (range_rows
);
670 range_rows_scroller
.set_name ("LocationRangeRowsScroller");
671 range_rows_scroller
.set_policy (Gtk::POLICY_NEVER
, Gtk::POLICY_AUTOMATIC
);
672 range_rows_scroller
.set_size_request (-1, 130);
674 range_frame_box
.set_spacing (5);
675 range_frame_box
.set_name("LocationFrameBox");
676 range_frame_box
.set_border_width (5);
677 range_frame_box
.pack_start (range_rows_scroller
, true, true);
679 add_range_button
.set_name ("LocationAddRangeButton");
680 range_frame_box
.pack_start (add_range_button
, false, false);
682 range_frame
.set_name ("LocationRangeEditorFrame");
683 range_frame
.set_label (_("Range (CD Track) Markers"));
684 range_frame
.add (range_frame_box
);
685 loc_range_panes
.pack2(range_frame
, true, false);
686 location_vpacker
.pack_start (loc_range_panes
, true, true);
688 location_hpacker
.pack_start (location_vpacker
, true, true);
690 add_location_button
.signal_clicked().connect (mem_fun(*this, &LocationUI::add_new_location
));
691 add_range_button
.signal_clicked().connect (mem_fun(*this, &LocationUI::add_new_range
));
693 //add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_RELEASE_MASK);
698 LocationUI::~LocationUI()
702 void LocationUI::on_show()
704 ArdourDialog::on_show();
705 refresh_location_list();
709 gint
LocationUI::do_location_remove (ARDOUR::Location
*loc
)
711 /* this is handled internally by Locations, but there's
712 no point saving state etc. when we know the marker
720 session
->begin_reversible_command (_("remove marker"));
721 XMLNode
&before
= session
->locations()->get_state();
722 session
->locations()->remove (loc
);
723 XMLNode
&after
= session
->locations()->get_state();
724 session
->add_command(new MementoCommand
<Locations
>(*(session
->locations()), &before
, &after
));
725 session
->commit_reversible_command ();
730 void LocationUI::location_remove_requested (ARDOUR::Location
*loc
)
732 // must do this to prevent problems when destroying
733 // the effective sender of this event
735 Glib::signal_idle().connect (bind (mem_fun(*this, &LocationUI::do_location_remove
), loc
));
739 void LocationUI::location_redraw_ranges ()
749 LocationUI::location_added (Location
* location
)
751 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationUI::location_added
), location
));
753 if (location
->is_auto_punch()) {
754 punch_edit_row
.set_location(location
);
756 else if (location
->is_auto_loop()) {
757 loop_edit_row
.set_location(location
);
760 refresh_location_list ();
765 LocationUI::location_removed (Location
* location
)
767 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationUI::location_removed
), location
));
769 if (location
->is_auto_punch()) {
770 punch_edit_row
.set_location(0);
772 else if (location
->is_auto_loop()) {
773 loop_edit_row
.set_location(0);
776 refresh_location_list ();
780 struct LocationSortByStart
{
781 bool operator() (Location
*a
, Location
*b
) {
782 return a
->start() < b
->start();
787 LocationUI::map_locations (Locations::LocationList
& locations
)
789 Locations::LocationList::iterator i
;
793 Locations::LocationList temp
= locations
;
794 LocationSortByStart cmp
;
799 Box_Helpers::BoxList
& loc_children
= location_rows
.children();
800 Box_Helpers::BoxList
& range_children
= range_rows
.children();
801 LocationEditRow
* erow
;
803 for (n
= 0, i
= locations
.begin(); i
!= locations
.end(); ++n
, ++i
) {
807 if (location
->is_mark()) {
809 erow
= manage (new LocationEditRow(session
, location
, mark_n
));
810 erow
->remove_requested
.connect (mem_fun(*this, &LocationUI::location_remove_requested
));
811 erow
->redraw_ranges
.connect (mem_fun(*this, &LocationUI::location_redraw_ranges
));
812 loc_children
.push_back(Box_Helpers::Element(*erow
, PACK_SHRINK
, 1, PACK_START
));
813 if (location
== newest_location
) {
818 else if (location
->is_auto_punch()) {
819 punch_edit_row
.set_session (session
);
820 punch_edit_row
.set_location (location
);
821 punch_edit_row
.show_all();
823 else if (location
->is_auto_loop()) {
824 loop_edit_row
.set_session (session
);
825 loop_edit_row
.set_location (location
);
826 loop_edit_row
.show_all();
829 erow
= manage (new LocationEditRow(session
, location
));
830 erow
->remove_requested
.connect (mem_fun(*this, &LocationUI::location_remove_requested
));
831 range_children
.push_back(Box_Helpers::Element(*erow
, PACK_SHRINK
, 1, PACK_START
));
835 range_rows
.show_all();
836 location_rows
.show_all();
840 LocationUI::add_new_location()
845 nframes_t where
= session
->audible_frame();
846 session
->locations()->next_available_name(markername
,"mark");
847 Location
*location
= new Location (where
, where
, markername
, Location::IsMark
);
848 if (Config
->get_name_new_markers()) {
849 newest_location
= location
;
851 session
->begin_reversible_command (_("add marker"));
852 XMLNode
&before
= session
->locations()->get_state();
853 session
->locations()->add (location
, true);
854 XMLNode
&after
= session
->locations()->get_state();
855 session
->add_command (new MementoCommand
<Locations
>(*(session
->locations()), &before
, &after
));
856 session
->commit_reversible_command ();
862 LocationUI::add_new_range()
867 nframes_t where
= session
->audible_frame();
868 session
->locations()->next_available_name(rangename
,"unnamed");
869 Location
*location
= new Location (where
, where
, rangename
, Location::IsRangeMarker
);
870 session
->begin_reversible_command (_("add range marker"));
871 XMLNode
&before
= session
->locations()->get_state();
872 session
->locations()->add (location
, true);
873 XMLNode
&after
= session
->locations()->get_state();
874 session
->add_command (new MementoCommand
<Locations
>(*(session
->locations()), &before
, &after
));
875 session
->commit_reversible_command ();
881 LocationUI::refresh_location_list_s (Change ignored
)
883 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationUI::refresh_location_list_s
), ignored
));
885 refresh_location_list ();
889 LocationUI::refresh_location_list ()
891 ENSURE_GUI_THREAD(mem_fun(*this, &LocationUI::refresh_location_list
));
892 using namespace Box_Helpers
;
894 // this is just too expensive to do when window is not shown
895 if (!is_visible()) return;
897 BoxList
& loc_children
= location_rows
.children();
898 BoxList
& range_children
= range_rows
.children();
900 loc_children
.clear();
901 range_children
.clear();
904 session
->locations()->apply (*this, &LocationUI::map_locations
);
910 LocationUI::set_session(ARDOUR::Session
* sess
)
912 ArdourDialog::set_session (sess
);
915 session
->locations()->changed
.connect (mem_fun(*this, &LocationUI::refresh_location_list
));
916 session
->locations()->StateChanged
.connect (mem_fun(*this, &LocationUI::refresh_location_list_s
));
917 session
->locations()->added
.connect (mem_fun(*this, &LocationUI::location_added
));
918 session
->locations()->removed
.connect (mem_fun(*this, &LocationUI::location_removed
));
919 session
->GoingAway
.connect (mem_fun(*this, &LocationUI::session_gone
));
921 refresh_location_list ();
925 LocationUI::session_gone()
927 ENSURE_GUI_THREAD(mem_fun(*this, &LocationUI::session_gone
));
931 using namespace Box_Helpers
;
932 BoxList
& loc_children
= location_rows
.children();
933 BoxList
& range_children
= range_rows
.children();
935 loc_children
.clear();
936 range_children
.clear();
938 loop_edit_row
.set_session (0);
939 loop_edit_row
.set_location (0);
941 punch_edit_row
.set_session (0);
942 punch_edit_row
.set_location (0);
944 ArdourDialog::session_gone ();
948 LocationUI::on_delete_event (GdkEventAny
* ev
)