update drobilla's fascistic dir-locals.el to force emacs users into whitespace submis...
[ardour.git] / gtk2_ardour / insert_time_dialog.cc
1 /*
2     Copyright (C) 2000-2010 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #include <gtkmm/table.h>
21 #include <gtkmm/comboboxtext.h>
22 #include <gtkmm/stock.h>
23 #include <gtkmm/alignment.h>
24 #include "insert_time_dialog.h"
25 #include "audio_clock.h"
26 #include "i18n.h"
27
28 using namespace Gtk;
29 using namespace Editing;
30
31 InsertTimeDialog::InsertTimeDialog (PublicEditor& e)
32         : ArdourDialog (_("Insert Time"))
33         , _editor (e)
34         , _clock ("insertTimeClock", true, X_("InsertTimeClock"), true, false, true, true)
35 {
36         set_session (_editor.session ());
37         
38         framepos_t const pos = _editor.get_preferred_edit_position ();
39
40         get_vbox()->set_border_width (12);
41         get_vbox()->set_spacing (4);
42
43         Table* table = manage (new Table (2, 2));
44         table->set_spacings (4);
45
46         Label* time_label = manage (new Label (_("Time to insert:")));
47         time_label->set_alignment (1, 0.5);
48         table->attach (*time_label, 0, 1, 0, 1, FILL | EXPAND);
49         _clock.set (0);
50         _clock.set_session (_session);
51         _clock.set_bbt_reference (pos);
52         table->attach (_clock, 1, 2, 0, 1);
53
54         Label* intersected_label = manage (new Label (_("Intersected regions should:")));
55         intersected_label->set_alignment (1, 0.5);
56         table->attach (*intersected_label, 0, 1, 1, 2, FILL | EXPAND);
57         _intersected_combo.append_text (_("stay in position"));
58         _intersected_combo.append_text (_("move"));
59         _intersected_combo.append_text (_("be split"));
60         _intersected_combo.set_active (0);
61         table->attach (_intersected_combo, 1, 2, 1, 2);
62
63         get_vbox()->pack_start (*table);
64
65         _move_glued.set_label (_("Move glued regions"));
66         get_vbox()->pack_start (_move_glued);
67         _move_markers.set_label (_("Move markers"));
68         get_vbox()->pack_start (_move_markers);
69         _move_markers.signal_toggled().connect (sigc::mem_fun (*this, &InsertTimeDialog::move_markers_toggled));
70         _move_glued_markers.set_label (_("Move glued markers"));
71         Alignment* indent = manage (new Alignment);
72         indent->set_padding (0, 0, 12, 0);
73         indent->add (_move_glued_markers);
74         get_vbox()->pack_start (*indent);
75         _move_locked_markers.set_label (_("Move locked markers"));
76         indent = manage (new Alignment);
77         indent->set_padding (0, 0, 12, 0);
78         indent->add (_move_locked_markers);
79         get_vbox()->pack_start (*indent);
80         _move_tempos.set_label (_("Move tempo and meter changes"));
81         get_vbox()->pack_start (_move_tempos);
82
83         add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
84         add_button (_("Insert time"), Gtk::RESPONSE_OK);
85         show_all ();
86
87         move_markers_toggled ();
88 }
89
90 InsertTimeOption
91 InsertTimeDialog::intersected_region_action ()
92 {
93         /* only setting this to keep GCC quiet */
94         InsertTimeOption opt = LeaveIntersected;
95
96         switch (_intersected_combo.get_active_row_number ()) {
97         case 0:
98                 opt = LeaveIntersected;
99                 break;
100         case 1:
101                 opt = MoveIntersected;
102                 break;
103         case 2:
104                 opt = SplitIntersected;
105                 break;
106         }
107
108         return opt;
109 }
110
111 bool
112 InsertTimeDialog::move_glued () const
113 {
114         return _move_glued.get_active ();
115 }
116
117 bool
118 InsertTimeDialog::move_tempos () const
119 {
120         return _move_tempos.get_active ();
121 }
122
123 bool
124 InsertTimeDialog::move_markers () const
125 {
126         return _move_markers.get_active ();
127 }
128
129 bool
130 InsertTimeDialog::move_glued_markers () const
131 {
132         return _move_glued_markers.get_active ();
133 }
134
135 bool
136 InsertTimeDialog::move_locked_markers () const
137 {
138         return _move_locked_markers.get_active ();
139 }
140
141 framepos_t
142 InsertTimeDialog::distance () const
143 {
144         return _clock.current_duration (_editor.get_preferred_edit_position ());
145 }
146
147 void
148 InsertTimeDialog::move_markers_toggled ()
149 {
150         _move_glued_markers.set_sensitive (_move_markers.get_active ());
151         _move_locked_markers.set_sensitive (_move_markers.get_active ());
152 }