Fixed some valgrind errors from using uninitialized variables in
[ardour.git] / gtk2_ardour / pan_automation_time_axis.cc
1 /*
2     Copyright (C) 2003 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     $Id$
19 */
20
21 #include <ardour/curve.h>
22 #include <ardour/route.h>
23 #include <ardour/panner.h>
24
25 #include <gtkmm2ext/popup.h>
26
27 #include "pan_automation_time_axis.h"
28 #include "automation_line.h"
29 #include "canvas_impl.h"
30
31 #include "i18n.h"
32
33 using namespace ARDOUR;
34 using namespace Gtk;
35
36 PanAutomationTimeAxisView::PanAutomationTimeAxisView (Session& s, Route& r, PublicEditor& e, TimeAxisView& parent, Canvas& canvas, std::string n)
37
38         : AxisView (s),
39           AutomationTimeAxisView (s, r, e, parent, canvas, n, X_("pan"), "")
40 {
41 }
42
43 PanAutomationTimeAxisView::~PanAutomationTimeAxisView ()
44 {
45 }
46
47 void
48 PanAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item, GdkEvent* event, jack_nframes_t when, double y)
49 {
50         if (lines.empty()) {
51                 /* no data, possibly caused by no outputs/inputs */
52                 return;
53         }
54
55         if (lines.size() > 1) {
56
57                 Gtkmm2ext::PopUp* msg = new Gtkmm2ext::PopUp (Gtk::WIN_POS_MOUSE, 5000, true);
58                 
59                 msg->set_text (_("You can't graphically edit panning of more than stream"));
60                 msg->touch ();
61                 
62                 return;
63         }
64
65         double x = 0;
66
67         canvas_display->w2i (x, y);
68
69         /* compute vertical fractional position */
70
71         y = 1.0 - (y / height);
72
73         /* map using line */
74
75         lines.front()->view_to_model_y (y);
76
77         AutomationList& alist (lines.front()->the_list());
78
79         _session.begin_reversible_command (_("add pan automation event"));
80         _session.add_undo (alist.get_memento());
81         alist.add (when, y);
82         _session.add_undo (alist.get_memento());
83         _session.commit_reversible_command ();
84         _session.set_dirty ();
85 }
86
87 void
88 PanAutomationTimeAxisView::set_automation_state (AutoState state)
89 {
90         if (!ignore_state_request) {
91                 route.panner().set_automation_state (state);
92         }
93 }