Use a list of ControlPoints to hold the automation selection,
[ardour.git] / gtk2_ardour / control_point.h
1 /*
2     Copyright (C) 2002-2007 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 #ifndef __ardour_control_point_h__
21 #define __ardour_control_point_h__
22
23 #include <sys/types.h>
24
25 #include "ardour/automation_list.h"
26
27 #include "canvas.h"
28 #include "simplerect.h"
29 #include "selectable.h"
30
31 class AutomationLine;
32 class ControlPoint;
33 class PointSelection;
34 class TimeAxisView;
35 class AutomationTimeAxisView;
36 class Selectable;
37 class Selection;
38
39 namespace Gnome {
40         namespace Canvas {
41                 class SimpleRect;
42                 class Diamond;
43         }
44 }
45
46 class ControlPoint : public Selectable
47 {
48   public:
49         ControlPoint (AutomationLine& al);
50         ControlPoint (const ControlPoint&, bool dummy_arg_to_force_special_copy_constructor);
51         virtual ~ControlPoint ();
52
53         enum ShapeType {
54                 Full,
55                 Start,
56                 End
57         };
58
59         void move_to (double x, double y, ShapeType);
60         void reset (double x, double y, ARDOUR::AutomationList::iterator, uint32_t, ShapeType);
61         double get_x() const { return _x; }
62         double get_y() const { return _y; }
63
64         void hide ();
65         void show ();
66         void set_color ();
67
68         double size () const {
69                 return _size;
70         }
71
72         void set_size (double);
73         void set_visible (bool);
74         bool visible () const;
75
76         bool     can_slide() const          { return _can_slide; }
77         void     set_can_slide(bool yn)     { _can_slide = yn; }
78         uint32_t view_index() const         { return _view_index; }
79         void     set_view_index(uint32_t i) { _view_index = i; }
80
81         void i2w (double &, double &) const;
82
83         ARDOUR::AutomationList::iterator model() const { return _model; }
84         AutomationLine&                  line()  const { return _line; }
85
86         static PBD::Signal1<void, ControlPoint *> CatchDeletion;
87         
88   private:
89         ArdourCanvas::SimpleRect*        _item;
90         AutomationLine&                  _line;
91         ARDOUR::AutomationList::iterator _model;
92         uint32_t                         _view_index;
93         bool                             _can_slide;
94         double                           _x;
95         double                           _y;
96         double                           _size;
97         ShapeType                        _shape;
98
99         virtual bool event_handler (GdkEvent*);
100
101 };
102
103
104 #endif /* __ardour_control_point_h__ */
105