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 ()
459 remove_requested (location
); /* EMIT_SIGNAL */
465 LocationEditRow::scms_toggled ()
467 if (i_am_the_modifier
|| !location
) return;
469 if (scms_check_button
.get_active()) {
470 location
->cd_info
["scms"] = "on";
472 location
->cd_info
.erase("scms");
478 LocationEditRow::preemph_toggled ()
480 if (i_am_the_modifier
|| !location
) return;
482 if (preemph_check_button
.get_active()) {
483 location
->cd_info
["preemph"] = "on";
485 location
->cd_info
.erase("preemph");
490 LocationEditRow::end_changed (ARDOUR::Location
*loc
)
492 ENSURE_GUI_THREAD (*this, &LocationEditRow::end_changed
, loc
)
494 if (!location
) return;
496 // update end and length
499 end_clock
.set (location
->end());
500 length_clock
.set (location
->length());
506 LocationEditRow::start_changed (ARDOUR::Location
*loc
)
508 ENSURE_GUI_THREAD (*this, &LocationEditRow::start_changed
, loc
)
510 if (!location
) return;
512 // update end and length
515 start_clock
.set (location
->start());
517 if (location
->start() == _session
->current_start_frame()) {
518 cd_check_button
.set_sensitive (false);
520 cd_check_button
.set_sensitive (true);
527 LocationEditRow::name_changed (ARDOUR::Location
*loc
)
529 ENSURE_GUI_THREAD (*this, &LocationEditRow::name_changed
, loc
)
531 if (!location
) return;
533 // update end and length
536 name_entry
.set_text(location
->name());
537 name_label
.set_text(location
->name());
544 LocationEditRow::location_changed (ARDOUR::Location
*loc
)
546 ENSURE_GUI_THREAD (*this, &LocationEditRow::location_changed
, loc
)
548 if (!location
) return;
552 start_clock
.set (location
->start());
553 end_clock
.set (location
->end());
554 length_clock
.set (location
->length());
556 start_clock
.set_sensitive (!location
->locked());
557 end_clock
.set_sensitive (!location
->locked());
558 length_clock
.set_sensitive (!location
->locked());
565 LocationEditRow::flags_changed (ARDOUR::Location
*loc
, void *src
)
567 ENSURE_GUI_THREAD (*this, &LocationEditRow::flags_changed
, loc
, src
)
569 if (!location
) return;
573 cd_check_button
.set_active (location
->is_cd_marker());
574 hide_check_button
.set_active (location
->is_hidden());
580 LocationEditRow::focus_name() {
581 name_entry
.grab_focus();
585 LocationUI::LocationUI ()
586 : add_location_button (_("New Marker"))
587 , add_range_button (_("New Range"))
589 i_am_the_modifier
= 0;
591 location_vpacker
.set_spacing (5);
593 add_location_button
.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::ADD
, Gtk::ICON_SIZE_BUTTON
)));
594 add_range_button
.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::ADD
, Gtk::ICON_SIZE_BUTTON
)));
596 loop_punch_box
.pack_start (loop_edit_row
, false, false);
597 loop_punch_box
.pack_start (punch_edit_row
, false, false);
599 loop_punch_scroller
.add (loop_punch_box
);
600 loop_punch_scroller
.set_policy (Gtk::POLICY_NEVER
, Gtk::POLICY_NEVER
);
601 loop_punch_scroller
.set_shadow_type (Gtk::SHADOW_NONE
);
603 location_vpacker
.pack_start (loop_punch_scroller
, false, false);
605 location_rows
.set_name("LocationLocRows");
606 location_rows_scroller
.add (location_rows
);
607 location_rows_scroller
.set_name ("LocationLocRowsScroller");
608 location_rows_scroller
.set_policy (Gtk::POLICY_NEVER
, Gtk::POLICY_AUTOMATIC
);
609 location_rows_scroller
.set_size_request (-1, 130);
613 loc_frame_box
.set_spacing (5);
614 loc_frame_box
.set_border_width (5);
615 loc_frame_box
.set_name("LocationFrameBox");
617 loc_frame_box
.pack_start (location_rows_scroller
, true, true);
619 add_location_button
.set_name ("LocationAddLocationButton");
621 HBox
* add_button_box
= manage (new HBox
);
623 // loc_frame_box.pack_start (add_location_button, false, false);
624 add_button_box
->pack_start (add_location_button
, true, true);
626 loc_frame
.set_name ("LocationLocEditorFrame");
627 loc_frame
.set_label (_("Markers (including CD index)"));
628 loc_frame
.add (loc_frame_box
);
629 loc_range_panes
.pack1(loc_frame
, true, false);
632 range_rows
.set_name("LocationRangeRows");
633 range_rows_scroller
.add (range_rows
);
634 range_rows_scroller
.set_name ("LocationRangeRowsScroller");
635 range_rows_scroller
.set_policy (Gtk::POLICY_NEVER
, Gtk::POLICY_AUTOMATIC
);
636 range_rows_scroller
.set_size_request (-1, 130);
638 range_frame_box
.set_spacing (5);
639 range_frame_box
.set_name("LocationFrameBox");
640 range_frame_box
.set_border_width (5);
641 range_frame_box
.pack_start (range_rows_scroller
, true, true);
643 add_range_button
.set_name ("LocationAddRangeButton");
644 //range_frame_box.pack_start (add_range_button, false, false);
646 add_button_box
->pack_start (add_range_button
, true, true);
648 range_frame
.set_name ("LocationRangeEditorFrame");
649 range_frame
.set_label (_("Ranges (including CD track ranges)"));
650 range_frame
.add (range_frame_box
);
651 loc_range_panes
.pack2(range_frame
, true, false);
652 location_vpacker
.pack_start (loc_range_panes
, true, true);
653 location_vpacker
.pack_start (*add_button_box
, false, false);
655 pack_start (location_vpacker
, true, true);
657 add_location_button
.signal_clicked().connect (sigc::mem_fun(*this, &LocationUI::add_new_location
));
658 add_range_button
.signal_clicked().connect (sigc::mem_fun(*this, &LocationUI::add_new_range
));
663 LocationUI::~LocationUI()
668 LocationUI::do_location_remove (ARDOUR::Location
*loc
)
670 /* this is handled internally by Locations, but there's
671 no point saving state etc. when we know the marker
675 if (loc
->is_session_range()) {
679 _session
->begin_reversible_command (_("remove marker"));
680 XMLNode
&before
= _session
->locations()->get_state();
681 _session
->locations()->remove (loc
);
682 XMLNode
&after
= _session
->locations()->get_state();
683 _session
->add_command(new MementoCommand
<Locations
>(*(_session
->locations()), &before
, &after
));
684 _session
->commit_reversible_command ();
690 LocationUI::location_remove_requested (ARDOUR::Location
*loc
)
692 // must do this to prevent problems when destroying
693 // the effective sender of this event
695 Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &LocationUI::do_location_remove
), loc
));
700 LocationUI::location_redraw_ranges ()
706 struct LocationSortByStart
{
707 bool operator() (Location
*a
, Location
*b
) {
708 return a
->start() < b
->start();
713 LocationUI::location_added (Location
* location
)
715 ENSURE_GUI_THREAD (*this, &LocationUI::location_added
, location
)
717 if (location
->is_auto_punch()) {
718 punch_edit_row
.set_location(location
);
719 } else if (location
->is_auto_loop()) {
720 loop_edit_row
.set_location(location
);
721 } else if (location
->is_range_marker() || location
->is_mark()) {
722 Locations::LocationList loc
= _session
->locations()->list ();
723 loc
.sort (LocationSortByStart ());
725 LocationEditRow
* erow
= manage (new LocationEditRow (_session
, location
));
726 erow
->remove_requested
.connect (sigc::mem_fun (*this, &LocationUI::location_remove_requested
));
727 Box_Helpers::BoxList
& children
= location
->is_range_marker() ? range_rows
.children () : location_rows
.children ();
729 /* Step through the location list and the GUI list to find the place to insert */
730 Locations::LocationList::iterator i
= loc
.begin ();
731 Box_Helpers::BoxList::iterator j
= children
.begin ();
732 while (i
!= loc
.end()) {
734 if (location
->flags() != (*i
)->flags()) {
735 /* Skip locations in the session list that aren't of the right type */
740 if (*i
== location
) {
741 children
.insert (j
, Box_Helpers::Element (*erow
, PACK_SHRINK
, 1, PACK_START
));
747 if (j
!= children
.end()) {
752 range_rows
.show_all ();
753 location_rows
.show_all ();
758 LocationUI::location_removed (Location
* location
)
760 ENSURE_GUI_THREAD (*this, &LocationUI::location_removed
, location
)
762 if (location
->is_auto_punch()) {
763 punch_edit_row
.set_location(0);
764 } else if (location
->is_auto_loop()) {
765 loop_edit_row
.set_location(0);
766 } else if (location
->is_range_marker() || location
->is_mark()) {
767 Box_Helpers::BoxList
& children
= location
->is_range_marker() ? range_rows
.children () : location_rows
.children ();
768 for (Box_Helpers::BoxList::iterator i
= children
.begin(); i
!= children
.end(); ++i
) {
769 LocationEditRow
* r
= dynamic_cast<LocationEditRow
*> (i
->get_widget());
770 if (r
&& r
->get_location() == location
) {
779 LocationUI::map_locations (Locations::LocationList
& locations
)
781 Locations::LocationList::iterator i
;
784 Locations::LocationList temp
= locations
;
785 LocationSortByStart cmp
;
790 for (n
= 0, i
= locations
.begin(); i
!= locations
.end(); ++n
, ++i
) {
792 Location
* location
= *i
;
794 if (location
->is_mark()) {
795 LocationEditRow
* erow
= manage (new LocationEditRow (_session
, location
, mark_n
));
796 erow
->remove_requested
.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested
));
797 erow
->redraw_ranges
.connect (sigc::mem_fun(*this, &LocationUI::location_redraw_ranges
));
798 Box_Helpers::BoxList
& loc_children
= location_rows
.children();
799 loc_children
.push_back(Box_Helpers::Element(*erow
, PACK_SHRINK
, 1, PACK_START
));
800 if (location
== newest_location
) {
804 } else if (location
->is_auto_punch()) {
805 punch_edit_row
.set_session (_session
);
806 punch_edit_row
.set_location (location
);
807 punch_edit_row
.show_all();
808 } else if (location
->is_auto_loop()) {
809 loop_edit_row
.set_session (_session
);
810 loop_edit_row
.set_location (location
);
811 loop_edit_row
.show_all();
813 LocationEditRow
* erow
= manage (new LocationEditRow(_session
, location
));
814 erow
->remove_requested
.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested
));
815 Box_Helpers::BoxList
& range_children
= range_rows
.children();
816 range_children
.push_back(Box_Helpers::Element(*erow
, PACK_SHRINK
, 1, PACK_START
));
820 range_rows
.show_all();
821 location_rows
.show_all();
825 LocationUI::add_new_location()
830 nframes_t where
= _session
->audible_frame();
831 _session
->locations()->next_available_name(markername
,"mark");
832 Location
*location
= new Location (where
, where
, markername
, Location::IsMark
);
833 if (Config
->get_name_new_markers()) {
834 newest_location
= location
;
836 _session
->begin_reversible_command (_("add marker"));
837 XMLNode
&before
= _session
->locations()->get_state();
838 _session
->locations()->add (location
, true);
839 XMLNode
&after
= _session
->locations()->get_state();
840 _session
->add_command (new MementoCommand
<Locations
>(*(_session
->locations()), &before
, &after
));
841 _session
->commit_reversible_command ();
847 LocationUI::add_new_range()
852 nframes_t where
= _session
->audible_frame();
853 _session
->locations()->next_available_name(rangename
,"unnamed");
854 Location
*location
= new Location (where
, where
, rangename
, Location::IsRangeMarker
);
855 _session
->begin_reversible_command (_("add range marker"));
856 XMLNode
&before
= _session
->locations()->get_state();
857 _session
->locations()->add (location
, true);
858 XMLNode
&after
= _session
->locations()->get_state();
859 _session
->add_command (new MementoCommand
<Locations
>(*(_session
->locations()), &before
, &after
));
860 _session
->commit_reversible_command ();
865 LocationUI::refresh_location_list ()
867 ENSURE_GUI_THREAD (*this, &LocationUI::refresh_location_list
)
868 using namespace Box_Helpers
;
870 // this is just too expensive to do when window is not shown
871 if (!is_visible()) return;
873 BoxList
& loc_children
= location_rows
.children();
874 BoxList
& range_children
= range_rows
.children();
876 loc_children
.clear();
877 range_children
.clear();
880 _session
->locations()->apply (*this, &LocationUI::map_locations
);
886 LocationUI::set_session(ARDOUR::Session
* s
)
888 SessionHandlePtr::set_session (s
);
891 _session
->locations()->changed
.connect (_session_connections
, invalidator (*this), boost::bind (&LocationUI::locations_changed
, this, _1
), gui_context());
892 _session
->locations()->StateChanged
.connect (_session_connections
, invalidator (*this), boost::bind (&LocationUI::refresh_location_list
, this), gui_context());
893 _session
->locations()->added
.connect (_session_connections
, invalidator (*this), ui_bind (&LocationUI::location_added
, this, _1
), gui_context());
894 _session
->locations()->removed
.connect (_session_connections
, invalidator (*this), ui_bind (&LocationUI::location_removed
, this, _1
), gui_context());
897 loop_edit_row
.set_session (s
);
898 punch_edit_row
.set_session (s
);
900 refresh_location_list ();
904 LocationUI::locations_changed (Locations::Change c
)
906 /* removal is signalled by both a removed and a changed signal emission from Locations,
907 so we don't need to refresh the list on a removal
909 if (c
!= Locations::REMOVAL
) {
910 refresh_location_list ();
915 LocationUI::session_going_away()
917 ENSURE_GUI_THREAD (*this, &LocationUI::session_going_away
);
919 using namespace Box_Helpers
;
920 BoxList
& loc_children
= location_rows
.children();
921 BoxList
& range_children
= range_rows
.children();
923 loc_children
.clear();
924 range_children
.clear();
926 loop_edit_row
.set_session (0);
927 loop_edit_row
.set_location (0);
929 punch_edit_row
.set_session (0);
930 punch_edit_row
.set_location (0);
932 SessionHandlePtr::session_going_away ();
935 /*------------------------*/
937 LocationUIWindow::LocationUIWindow ()
938 : ArdourDialog (_("Locations"))
940 set_wmclass(X_("ardour_locations"), "Ardour");
941 set_name ("LocationWindow");
943 get_vbox()->pack_start (_ui
);
946 LocationUIWindow::~LocationUIWindow()
951 LocationUIWindow::on_show()
953 _ui
.refresh_location_list();
954 ArdourDialog::on_show();
958 LocationUIWindow::on_delete_event (GdkEventAny
*)
965 LocationUIWindow::set_session (Session
*s
)
967 ArdourDialog::set_session (s
);
972 LocationUIWindow::session_going_away ()
974 ArdourDialog::session_going_away ();