2 Copyright (C) 2000-2010 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <gtkmm/table.h>
21 #include <gtkmm/comboboxtext.h>
22 #include <gtkmm/stock.h>
23 #include <gtkmm/alignment.h>
24 #include "insert_remove_time_dialog.h"
25 #include "audio_clock.h"
29 using namespace Editing;
31 InsertRemoveTimeDialog::InsertRemoveTimeDialog (PublicEditor& e, bool remove)
32 : ArdourDialog (remove ? _("Remove Time") : _("Insert Time"))
34 , _clock ("insertTimeClock", true, "", true, false, true, false)
36 set_session (_editor.session ());
38 framepos_t const pos = _editor.get_preferred_edit_position (EDIT_IGNORE_MOUSE);
40 get_vbox()->set_border_width (12);
41 get_vbox()->set_spacing (4);
43 Table* table = manage (new Table (2, 2));
44 table->set_spacings (4);
46 Label* time_label = manage (new Label (remove ? _("Time to remove") : _("Time to insert:")));
47 time_label->set_alignment (1, 0.5);
48 table->attach (*time_label, 0, 1, 0, 1, FILL | EXPAND);
50 _clock.set_session (_session);
51 _clock.set_bbt_reference (pos);
52 table->attach (_clock, 1, 2, 0, 1);
55 Label* intersected_label = manage (new Label (_("Intersected regions should:")));
56 intersected_label->set_alignment (1, 0.5);
57 table->attach (*intersected_label, 0, 1, 1, 2, FILL | EXPAND);
58 _intersected_combo.append_text (_("stay in position"));
59 _intersected_combo.append_text (_("move"));
60 _intersected_combo.append_text (_("be split"));
61 _intersected_combo.set_active (0);
62 table->attach (_intersected_combo, 1, 2, 1, 2);
65 get_vbox()->pack_start (*table);
67 _all_playlists.set_label (_("Apply to all the track's playlists"));
68 get_vbox()->pack_start (_all_playlists);
70 _move_glued.set_label (_("Move glued regions"));
71 get_vbox()->pack_start (_move_glued);
72 _move_markers.set_label (_("Move markers"));
73 get_vbox()->pack_start (_move_markers);
74 _move_markers.signal_toggled().connect (sigc::mem_fun (*this, &InsertRemoveTimeDialog::move_markers_toggled));
75 _move_glued_markers.set_label (_("Move glued markers"));
76 Alignment* indent = manage (new Alignment);
77 indent->set_padding (0, 0, 12, 0);
78 indent->add (_move_glued_markers);
79 get_vbox()->pack_start (*indent);
80 _move_locked_markers.set_label (_("Move locked markers"));
81 indent = manage (new Alignment);
82 indent->set_padding (0, 0, 12, 0);
83 indent->add (_move_locked_markers);
84 get_vbox()->pack_start (*indent);
85 tempo_label.set_markup (_("Move tempo and meter changes\n<i>(may cause oddities in the tempo map)</i>"));
86 HBox* tempo_box = manage (new HBox);
87 tempo_box->set_spacing (6);
88 tempo_box->pack_start (_move_tempos, false, false);
89 tempo_box->pack_start (tempo_label, false, false);
90 get_vbox()->pack_start (*tempo_box);
92 add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
93 add_button (remove ? _("Cut time") : _("Insert time"), Gtk::RESPONSE_OK);
96 move_markers_toggled ();
100 InsertRemoveTimeDialog::intersected_region_action ()
102 /* only setting this to keep GCC quiet */
103 InsertTimeOption opt = LeaveIntersected;
105 switch (_intersected_combo.get_active_row_number ()) {
107 opt = LeaveIntersected;
110 opt = MoveIntersected;
113 opt = SplitIntersected;
121 InsertRemoveTimeDialog::all_playlists () const
123 return _all_playlists.get_active ();
127 InsertRemoveTimeDialog::move_glued () const
129 return _move_glued.get_active ();
133 InsertRemoveTimeDialog::move_tempos () const
135 return _move_tempos.get_active ();
139 InsertRemoveTimeDialog::move_markers () const
141 return _move_markers.get_active ();
145 InsertRemoveTimeDialog::move_glued_markers () const
147 return _move_glued_markers.get_active ();
151 InsertRemoveTimeDialog::move_locked_markers () const
153 return _move_locked_markers.get_active ();
157 InsertRemoveTimeDialog::distance () const
159 return _clock.current_duration (_editor.get_preferred_edit_position ());
163 InsertRemoveTimeDialog::move_markers_toggled ()
165 _move_glued_markers.set_sensitive (_move_markers.get_active ());
166 _move_locked_markers.set_sensitive (_move_markers.get_active ());