55c1b77d6404d7f0dd8724428ce195d17fa3de97
[ardour.git] / gtk2_ardour / automation_region_view.h
1 /*
2     Copyright (C) 2007 Paul Davis 
3     Author: Dave Robillard
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __gtk_ardour_automation_region_view_h__
21 #define __gtk_ardour_automation_region_view_h__
22
23 #include "ardour/diskstream.h"
24 #include "ardour/types.h"
25
26 #include "region_view.h"
27 #include "automation_time_axis.h"
28 #include "automation_line.h"
29 #include "enums.h"
30 #include "canvas.h"
31
32 namespace ARDOUR {
33         class AutomationList;
34         class Parameter;
35 };
36
37 class TimeAxisView;
38
39 class AutomationRegionView : public RegionView
40 {
41 public:
42         AutomationRegionView(ArdourCanvas::Group*,
43                              AutomationTimeAxisViewPtr,
44                              boost::shared_ptr<ARDOUR::Region>,
45                              const Evoral::Parameter& parameter,
46                              boost::shared_ptr<ARDOUR::AutomationList>,
47                              double initial_samples_per_unit,
48                              Gdk::Color const & basic_color);
49
50         ~AutomationRegionView() {}
51         
52         void init (Gdk::Color const & basic_color, bool wfd);
53         
54         inline AutomationTimeAxisViewPtr automation_view() const {
55                 return boost::dynamic_pointer_cast<AutomationTimeAxisView> (trackview);
56         }
57         
58         void set_line(boost::shared_ptr<AutomationLine> line) { _line = line; }
59         boost::shared_ptr<AutomationLine> line() { return _line; }
60         
61         // We are a ghost.  Meta ghosts?  Crazy talk.
62         virtual GhostRegion* add_ghost(TimeAxisViewPtr) { return 0; }
63         
64         void set_height (double);
65         void reset_width_dependent_items(double pixel_width);
66
67 protected:
68         void create_line(boost::shared_ptr<ARDOUR::AutomationList> list);
69         bool set_position(nframes_t pos, void* src, double* ignored);
70         void region_resized(ARDOUR::Change what_changed);
71         bool canvas_event(GdkEvent* ev);
72         void add_automation_event (GdkEvent* event, nframes_t when, double y);
73         void entered();
74         void exited();
75
76 private:
77         Evoral::Parameter                 _parameter;
78         boost::shared_ptr<AutomationLine> _line;
79 };
80
81 #endif /* __gtk_ardour_automation_region_view_h__ */