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"
32 #include "location_ui.h"
35 #include "gui_thread.h"
40 using namespace ARDOUR;
43 using namespace Gtkmm2ext;
45 LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
46 : SessionHandlePtr (0), /* explicitly set below */
48 item_table (1, 6, false),
49 start_clock (X_("locationstart"), true, X_("LocationEditRowClock"), true, false),
50 end_clock (X_("locationend"), true, X_("LocationEditRowClock"), true, false),
51 length_clock (X_("locationlength"), true, X_("LocationEditRowClock"), true, false, true),
52 cd_check_button (_("CD")),
53 hide_check_button (_("Hide")),
54 scms_check_button (_("SCMS")),
55 preemph_check_button (_("Pre-Emphasis"))
58 i_am_the_modifier = 0;
60 start_go_button.set_image (*manage (new Image (Stock::JUMP_TO, Gtk::ICON_SIZE_SMALL_TOOLBAR)));
61 end_go_button.set_image (*manage (new Image (Stock::JUMP_TO, Gtk::ICON_SIZE_SMALL_TOOLBAR)));
62 remove_button.set_image (*manage (new Image (Stock::REMOVE, Gtk::ICON_SIZE_SMALL_TOOLBAR)));
64 number_label.set_name ("LocationEditNumberLabel");
65 name_label.set_name ("LocationEditNameLabel");
66 name_entry.set_name ("LocationEditNameEntry");
67 start_go_button.set_name ("LocationEditGoButton");
68 end_go_button.set_name ("LocationEditGoButton");
69 cd_check_button.set_name ("LocationEditCdButton");
70 hide_check_button.set_name ("LocationEditHideButton");
71 remove_button.set_name ("LocationEditRemoveButton");
72 isrc_label.set_name ("LocationEditNumberLabel");
73 isrc_entry.set_name ("LocationEditNameEntry");
74 scms_check_button.set_name ("LocationEditCdButton");
75 preemph_check_button.set_name ("LocationEditCdButton");
76 performer_label.set_name ("LocationEditNumberLabel");
77 performer_entry.set_name ("LocationEditNameEntry");
78 composer_label.set_name ("LocationEditNumberLabel");
79 composer_entry.set_name ("LocationEditNameEntry");
81 isrc_label.set_text ("ISRC: ");
82 isrc_label.set_size_request (30, -1);
83 performer_label.set_text ("Performer: ");
84 performer_label.set_size_request (60, -1);
85 composer_label.set_text ("Composer: ");
86 composer_label.set_size_request (60, -1);
88 isrc_entry.set_size_request (112, -1);
89 isrc_entry.set_max_length(12);
90 isrc_entry.set_editable (true);
92 performer_entry.set_size_request (100, -1);
93 performer_entry.set_editable (true);
95 composer_entry.set_size_request (100, -1);
96 composer_entry.set_editable (true);
98 name_label.set_alignment (0, 0.5);
100 cd_track_details_hbox.pack_start (isrc_label, false, false);
101 cd_track_details_hbox.pack_start (isrc_entry, false, false);
102 cd_track_details_hbox.pack_start (scms_check_button, false, false);
103 cd_track_details_hbox.pack_start (preemph_check_button, false, false);
104 cd_track_details_hbox.pack_start (performer_label, false, false);
105 cd_track_details_hbox.pack_start (performer_entry, true, true);
106 cd_track_details_hbox.pack_start (composer_label, false, false);
107 cd_track_details_hbox.pack_start (composer_entry, true, true);
109 isrc_entry.signal_changed().connect (sigc::mem_fun(*this, &LocationEditRow::isrc_entry_changed));
110 performer_entry.signal_changed().connect (sigc::mem_fun(*this, &LocationEditRow::performer_entry_changed));
111 composer_entry.signal_changed().connect (sigc::mem_fun(*this, &LocationEditRow::composer_entry_changed));
112 scms_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::scms_toggled));
113 preemph_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::preemph_toggled));
117 // start_hbox.pack_start (start_go_button, false, false);
118 start_hbox.pack_start (start_clock, false, false);
120 /* this is always in this location, no matter what the location is */
122 item_table.attach (start_hbox, 1, 2, 0, 1, FILL, FILL, 4, 0);
124 start_go_button.signal_clicked().connect(sigc::bind (sigc::mem_fun (*this, &LocationEditRow::go_button_pressed), LocStart));
125 start_clock.ValueChanged.connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::clock_changed), LocStart));
126 start_clock.ChangeAborted.connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::change_aborted), LocStart));
128 // end_hbox.pack_start (end_go_button, false, false);
129 end_hbox.pack_start (end_clock, false, false);
131 end_go_button.signal_clicked().connect(sigc::bind (sigc::mem_fun (*this, &LocationEditRow::go_button_pressed), LocEnd));
132 end_clock.ValueChanged.connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::clock_changed), LocEnd));
133 end_clock.ChangeAborted.connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::change_aborted), LocEnd));
135 length_clock.ValueChanged.connect (sigc::bind ( sigc::mem_fun(*this, &LocationEditRow::clock_changed), LocLength));
136 length_clock.ChangeAborted.connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::change_aborted), LocLength));
138 cd_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::cd_toggled));
139 hide_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::hide_toggled));
141 remove_button.signal_clicked().connect(sigc::mem_fun(*this, &LocationEditRow::remove_button_pressed));
143 pack_start(item_table, true, true);
149 LocationEditRow::~LocationEditRow()
152 connections.drop_connections ();
157 LocationEditRow::set_session (Session *sess)
159 SessionHandlePtr::set_session (sess);
165 start_clock.set_session (_session);
166 end_clock.set_session (_session);
167 length_clock.set_session (_session);
172 LocationEditRow::set_number (int num)
177 number_label.set_text (string_compose ("%1", number));
182 LocationEditRow::set_location (Location *loc)
185 connections.drop_connections ();
190 if (!location) return;
192 if (!hide_check_button.get_parent()) {
193 item_table.attach (hide_check_button, 5, 6, 0, 1, FILL, Gtk::FILL, 4, 0);
195 hide_check_button.set_active (location->is_hidden());
197 if (location->is_auto_loop() || location-> is_auto_punch()) {
198 // use label instead of entry
200 name_label.set_text (location->name());
201 name_label.set_size_request (80, -1);
203 if (!name_label.get_parent()) {
204 item_table.attach (name_label, 0, 1, 0, 1, FILL, FILL, 4, 0);
211 name_entry.set_text (location->name());
212 name_entry.set_size_request (100, -1);
213 name_entry.set_editable (true);
214 name_entry.signal_changed().connect (sigc::mem_fun(*this, &LocationEditRow::name_entry_changed));
216 if (!name_entry.get_parent()) {
217 item_table.attach (name_entry, 0, 1, 0, 1, FILL | EXPAND, FILL, 4, 0);
221 if (!cd_check_button.get_parent()) {
222 item_table.attach (cd_check_button, 4, 5, 0, 1, FILL, FILL, 4, 0);
224 if (!remove_button.get_parent()) {
225 item_table.attach (remove_button, 6, 7, 0, 1, FILL, FILL, 4, 0);
228 if (location->is_session_range()) {
229 remove_button.set_sensitive (false);
232 cd_check_button.set_active (location->is_cd_marker());
233 cd_check_button.show();
235 if (location->start() == _session->current_start_frame()) {
236 cd_check_button.set_sensitive (false);
238 cd_check_button.set_sensitive (true);
241 hide_check_button.show();
244 start_clock.set (location->start(), true);
247 if (!location->is_mark()) {
248 if (!end_hbox.get_parent()) {
249 item_table.attach (end_hbox, 2, 3, 0, 1, FILL, FILL, 4, 0);
251 if (!length_clock.get_parent()) {
252 item_table.attach (length_clock, 3, 4, 0, 1, FILL, FILL, 4, 0);
255 end_clock.set (location->end(), true);
256 length_clock.set (location->length(), true);
258 end_go_button.show();
262 ARDOUR_UI::instance()->set_tip (end_go_button, _("Jump to the end of this range"));
263 ARDOUR_UI::instance()->set_tip (start_go_button, _("Jump to the start of this range"));
264 ARDOUR_UI::instance()->set_tip (remove_button, _("Forget this range"));
265 ARDOUR_UI::instance()->set_tip (start_clock, _("Start time"));
266 ARDOUR_UI::instance()->set_tip (end_clock, _("End time"));
267 ARDOUR_UI::instance()->set_tip (length_clock, _("Length"));
271 ARDOUR_UI::instance()->set_tip (start_go_button, _("Jump to this marker"));
272 ARDOUR_UI::instance()->set_tip (remove_button, _("Forget this marker"));
273 ARDOUR_UI::instance()->set_tip (start_clock, _("Position"));
275 end_go_button.hide();
280 start_clock.set_sensitive (!location->locked());
281 end_clock.set_sensitive (!location->locked());
282 length_clock.set_sensitive (!location->locked());
284 location->start_changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::start_changed, this, _1), gui_context());
285 location->end_changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::end_changed, this, _1), gui_context());
286 location->name_changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::name_changed, this, _1), gui_context());
287 location->changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::location_changed, this, _1), gui_context());
288 location->FlagsChanged.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::flags_changed, this, _1, _2), gui_context());
292 LocationEditRow::name_entry_changed ()
294 ENSURE_GUI_THREAD (*this, &LocationEditRow::name_entry_changed)
295 if (i_am_the_modifier || !location) return;
297 location->set_name (name_entry.get_text());
302 LocationEditRow::isrc_entry_changed ()
304 ENSURE_GUI_THREAD (*this, &LocationEditRow::isrc_entry_changed)
306 if (i_am_the_modifier || !location) return;
308 if (isrc_entry.get_text() != "" ) {
310 location->cd_info["isrc"] = isrc_entry.get_text();
313 location->cd_info.erase("isrc");
318 LocationEditRow::performer_entry_changed ()
320 ENSURE_GUI_THREAD (*this, &LocationEditRow::performer_entry_changed)
322 if (i_am_the_modifier || !location) return;
324 if (performer_entry.get_text() != "") {
325 location->cd_info["performer"] = performer_entry.get_text();
327 location->cd_info.erase("performer");
332 LocationEditRow::composer_entry_changed ()
334 ENSURE_GUI_THREAD (*this, &LocationEditRow::composer_entry_changed)
336 if (i_am_the_modifier || !location) return;
338 if (composer_entry.get_text() != "") {
339 location->cd_info["composer"] = composer_entry.get_text();
341 location->cd_info.erase("composer");
347 LocationEditRow::go_button_pressed (LocationPart part)
349 if (!location) return;
353 ARDOUR_UI::instance()->do_transport_locate (location->start());
356 ARDOUR_UI::instance()->do_transport_locate (location->end());
364 LocationEditRow::clock_changed (LocationPart part)
366 if (i_am_the_modifier || !location) return;
370 location->set_start (start_clock.current_time());
373 location->set_end (end_clock.current_time());
376 location->set_end (location->start() + length_clock.current_duration());
384 LocationEditRow::change_aborted (LocationPart /*part*/)
386 if (i_am_the_modifier || !location) return;
388 set_location(location);
392 LocationEditRow::cd_toggled ()
394 if (i_am_the_modifier || !location) {
398 //if (cd_check_button.get_active() == location->is_cd_marker()) {
402 if (cd_check_button.get_active()) {
403 if (location->start() <= _session->current_start_frame()) {
404 error << _("You cannot put a CD marker at the start of the session") << endmsg;
405 cd_check_button.set_active (false);
410 location->set_cd (cd_check_button.get_active(), this);
412 if (location->is_cd_marker() && !(location->is_mark())) {
414 if (location->cd_info.find("isrc") != location->cd_info.end()) {
415 isrc_entry.set_text(location->cd_info["isrc"]);
417 if (location->cd_info.find("performer") != location->cd_info.end()) {
418 performer_entry.set_text(location->cd_info["performer"]);
420 if (location->cd_info.find("composer") != location->cd_info.end()) {
421 composer_entry.set_text(location->cd_info["composer"]);
423 if (location->cd_info.find("scms") != location->cd_info.end()) {
424 scms_check_button.set_active(true);
426 if (location->cd_info.find("preemph") != location->cd_info.end()) {
427 preemph_check_button.set_active(true);
430 if (!cd_track_details_hbox.get_parent()) {
431 item_table.attach (cd_track_details_hbox, 0, 7, 1, 2, FILL | EXPAND, FILL, 4, 0);
433 // item_table.resize(2, 7);
434 cd_track_details_hbox.show_all();
436 } else if (cd_track_details_hbox.get_parent()){
438 item_table.remove (cd_track_details_hbox);
439 // item_table.resize(1, 7);
440 redraw_ranges(); /* EMIT_SIGNAL */
445 LocationEditRow::hide_toggled ()
447 if (i_am_the_modifier || !location) return;
449 location->set_hidden (hide_check_button.get_active(), this);
453 LocationEditRow::remove_button_pressed ()
455 if (!location) return;
457 remove_requested(location); /* EMIT_SIGNAL */
463 LocationEditRow::scms_toggled ()
465 if (i_am_the_modifier || !location) return;
467 if (scms_check_button.get_active()) {
468 location->cd_info["scms"] = "on";
470 location->cd_info.erase("scms");
476 LocationEditRow::preemph_toggled ()
478 if (i_am_the_modifier || !location) return;
480 if (preemph_check_button.get_active()) {
481 location->cd_info["preemph"] = "on";
483 location->cd_info.erase("preemph");
488 LocationEditRow::end_changed (ARDOUR::Location *loc)
490 ENSURE_GUI_THREAD (*this, &LocationEditRow::end_changed, loc)
492 if (!location) return;
494 // update end and length
497 end_clock.set (location->end());
498 length_clock.set (location->length());
504 LocationEditRow::start_changed (ARDOUR::Location *loc)
506 ENSURE_GUI_THREAD (*this, &LocationEditRow::start_changed, loc)
508 if (!location) return;
510 // update end and length
513 start_clock.set (location->start());
515 if (location->start() == _session->current_start_frame()) {
516 cd_check_button.set_sensitive (false);
518 cd_check_button.set_sensitive (true);
525 LocationEditRow::name_changed (ARDOUR::Location *loc)
527 ENSURE_GUI_THREAD (*this, &LocationEditRow::name_changed, loc)
529 if (!location) return;
531 // update end and length
534 name_entry.set_text(location->name());
535 name_label.set_text(location->name());
542 LocationEditRow::location_changed (ARDOUR::Location *loc)
544 ENSURE_GUI_THREAD (*this, &LocationEditRow::location_changed, loc)
546 if (!location) return;
550 start_clock.set (location->start());
551 end_clock.set (location->end());
552 length_clock.set (location->length());
554 start_clock.set_sensitive (!location->locked());
555 end_clock.set_sensitive (!location->locked());
556 length_clock.set_sensitive (!location->locked());
563 LocationEditRow::flags_changed (ARDOUR::Location *loc, void *src)
565 ENSURE_GUI_THREAD (*this, &LocationEditRow::flags_changed, loc, src)
567 if (!location) return;
571 cd_check_button.set_active (location->is_cd_marker());
572 hide_check_button.set_active (location->is_hidden());
578 LocationEditRow::focus_name() {
579 name_entry.grab_focus();
583 LocationUI::LocationUI ()
584 : add_location_button (_("New Marker"))
585 , add_range_button (_("New Range"))
587 i_am_the_modifier = 0;
589 location_vpacker.set_spacing (5);
591 add_location_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON)));
592 add_range_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON)));
594 loop_punch_box.pack_start (loop_edit_row, false, false);
595 loop_punch_box.pack_start (punch_edit_row, false, false);
597 loop_punch_scroller.add (loop_punch_box);
598 loop_punch_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_NEVER);
599 loop_punch_scroller.set_shadow_type (Gtk::SHADOW_NONE);
601 location_vpacker.pack_start (loop_punch_scroller, false, false);
603 location_rows.set_name("LocationLocRows");
604 location_rows_scroller.add (location_rows);
605 location_rows_scroller.set_name ("LocationLocRowsScroller");
606 location_rows_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
607 location_rows_scroller.set_size_request (-1, 130);
611 loc_frame_box.set_spacing (5);
612 loc_frame_box.set_border_width (5);
613 loc_frame_box.set_name("LocationFrameBox");
615 loc_frame_box.pack_start (location_rows_scroller, true, true);
617 add_location_button.set_name ("LocationAddLocationButton");
619 HBox* add_button_box = manage (new HBox);
621 // loc_frame_box.pack_start (add_location_button, false, false);
622 add_button_box->pack_start (add_location_button, true, true);
624 loc_frame.set_name ("LocationLocEditorFrame");
625 loc_frame.set_label (_("Markers (including CD index)"));
626 loc_frame.add (loc_frame_box);
627 loc_range_panes.pack1(loc_frame, true, false);
630 range_rows.set_name("LocationRangeRows");
631 range_rows_scroller.add (range_rows);
632 range_rows_scroller.set_name ("LocationRangeRowsScroller");
633 range_rows_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
634 range_rows_scroller.set_size_request (-1, 130);
636 range_frame_box.set_spacing (5);
637 range_frame_box.set_name("LocationFrameBox");
638 range_frame_box.set_border_width (5);
639 range_frame_box.pack_start (range_rows_scroller, true, true);
641 add_range_button.set_name ("LocationAddRangeButton");
642 //range_frame_box.pack_start (add_range_button, false, false);
644 add_button_box->pack_start (add_range_button, true, true);
646 range_frame.set_name ("LocationRangeEditorFrame");
647 range_frame.set_label (_("Ranges (including CD track ranges)"));
648 range_frame.add (range_frame_box);
649 loc_range_panes.pack2(range_frame, true, false);
650 location_vpacker.pack_start (loc_range_panes, true, true);
651 location_vpacker.pack_start (*add_button_box, false, false);
653 pack_start (location_vpacker, true, true);
655 add_location_button.signal_clicked().connect (sigc::mem_fun(*this, &LocationUI::add_new_location));
656 add_range_button.signal_clicked().connect (sigc::mem_fun(*this, &LocationUI::add_new_range));
661 LocationUI::~LocationUI()
666 LocationUI::do_location_remove (ARDOUR::Location *loc)
668 /* this is handled internally by Locations, but there's
669 no point saving state etc. when we know the marker
673 if (loc->is_session_range()) {
677 _session->begin_reversible_command (_("remove marker"));
678 XMLNode &before = _session->locations()->get_state();
679 _session->locations()->remove (loc);
680 XMLNode &after = _session->locations()->get_state();
681 _session->add_command(new MementoCommand<Locations>(*(_session->locations()), &before, &after));
682 _session->commit_reversible_command ();
688 LocationUI::location_remove_requested (ARDOUR::Location *loc)
690 // must do this to prevent problems when destroying
691 // the effective sender of this event
693 Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &LocationUI::do_location_remove), loc));
698 LocationUI::location_redraw_ranges ()
705 LocationUI::location_added (Location* location)
707 ENSURE_GUI_THREAD (*this, &LocationUI::location_added, location)
709 if (location->is_auto_punch()) {
710 punch_edit_row.set_location(location);
712 else if (location->is_auto_loop()) {
713 loop_edit_row.set_location(location);
716 refresh_location_list ();
721 LocationUI::location_removed (Location* location)
723 ENSURE_GUI_THREAD (*this, &LocationUI::location_removed, location)
725 if (location->is_auto_punch()) {
726 punch_edit_row.set_location(0);
728 else if (location->is_auto_loop()) {
729 loop_edit_row.set_location(0);
732 refresh_location_list ();
736 struct LocationSortByStart {
737 bool operator() (Location *a, Location *b) {
738 return a->start() < b->start();
743 LocationUI::map_locations (Locations::LocationList& locations)
745 Locations::LocationList::iterator i;
749 Locations::LocationList temp = locations;
750 LocationSortByStart cmp;
755 Box_Helpers::BoxList & loc_children = location_rows.children();
756 Box_Helpers::BoxList & range_children = range_rows.children();
757 LocationEditRow * erow;
759 for (n = 0, i = locations.begin(); i != locations.end(); ++n, ++i) {
763 if (location->is_mark()) {
765 erow = manage (new LocationEditRow(_session, location, mark_n));
766 erow->remove_requested.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested));
767 erow->redraw_ranges.connect (sigc::mem_fun(*this, &LocationUI::location_redraw_ranges));
768 loc_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START));
769 if (location == newest_location) {
774 else if (location->is_auto_punch()) {
775 punch_edit_row.set_session (_session);
776 punch_edit_row.set_location (location);
777 punch_edit_row.show_all();
779 else if (location->is_auto_loop()) {
780 loop_edit_row.set_session (_session);
781 loop_edit_row.set_location (location);
782 loop_edit_row.show_all();
785 erow = manage (new LocationEditRow(_session, location));
786 erow->remove_requested.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested));
787 range_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START));
791 range_rows.show_all();
792 location_rows.show_all();
796 LocationUI::add_new_location()
801 nframes_t where = _session->audible_frame();
802 _session->locations()->next_available_name(markername,"mark");
803 Location *location = new Location (where, where, markername, Location::IsMark);
804 if (Config->get_name_new_markers()) {
805 newest_location = location;
807 _session->begin_reversible_command (_("add marker"));
808 XMLNode &before = _session->locations()->get_state();
809 _session->locations()->add (location, true);
810 XMLNode &after = _session->locations()->get_state();
811 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
812 _session->commit_reversible_command ();
818 LocationUI::add_new_range()
823 nframes_t where = _session->audible_frame();
824 _session->locations()->next_available_name(rangename,"unnamed");
825 Location *location = new Location (where, where, rangename, Location::IsRangeMarker);
826 _session->begin_reversible_command (_("add range marker"));
827 XMLNode &before = _session->locations()->get_state();
828 _session->locations()->add (location, true);
829 XMLNode &after = _session->locations()->get_state();
830 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
831 _session->commit_reversible_command ();
836 LocationUI::refresh_location_list ()
838 ENSURE_GUI_THREAD (*this, &LocationUI::refresh_location_list)
839 using namespace Box_Helpers;
841 // this is just too expensive to do when window is not shown
842 if (!is_visible()) return;
844 BoxList & loc_children = location_rows.children();
845 BoxList & range_children = range_rows.children();
847 loc_children.clear();
848 range_children.clear();
851 _session->locations()->apply (*this, &LocationUI::map_locations);
857 LocationUI::set_session(ARDOUR::Session* s)
859 SessionHandlePtr::set_session (s);
862 _session->locations()->changed.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::refresh_location_list, this), gui_context());
863 _session->locations()->StateChanged.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::refresh_location_list, this), gui_context());
864 _session->locations()->added.connect (_session_connections, invalidator (*this), ui_bind (&LocationUI::location_added, this, _1), gui_context());
865 _session->locations()->removed.connect (_session_connections, invalidator (*this), ui_bind (&LocationUI::location_removed, this, _1), gui_context());
868 loop_edit_row.set_session (s);
869 punch_edit_row.set_session (s);
871 refresh_location_list ();
875 LocationUI::session_going_away()
877 ENSURE_GUI_THREAD (*this, &LocationUI::session_going_away);
879 using namespace Box_Helpers;
880 BoxList & loc_children = location_rows.children();
881 BoxList & range_children = range_rows.children();
883 loc_children.clear();
884 range_children.clear();
886 loop_edit_row.set_session (0);
887 loop_edit_row.set_location (0);
889 punch_edit_row.set_session (0);
890 punch_edit_row.set_location (0);
892 SessionHandlePtr::session_going_away ();
895 /*------------------------*/
897 LocationUIWindow::LocationUIWindow ()
898 : ArdourDialog (_("Locations"))
900 set_wmclass(X_("ardour_locations"), "Ardour");
901 set_name ("LocationWindow");
903 get_vbox()->pack_start (_ui);
906 LocationUIWindow::~LocationUIWindow()
911 LocationUIWindow::on_show()
913 _ui.refresh_location_list();
914 ArdourDialog::on_show();
918 LocationUIWindow::on_delete_event (GdkEventAny*)
925 LocationUIWindow::set_session (Session *s)
927 ArdourDialog::set_session (s);
932 LocationUIWindow::session_going_away ()
934 ArdourDialog::session_going_away ();