Per-region MIDI CC "automation".
[ardour.git] / gtk2_ardour / marker_view.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 */
19
20 #include <gtkmm.h>
21
22 #include "imageframe_time_axis.h"
23 #include "imageframe_view.h"
24 #include "canvas-simplerect.h"
25 #include "public_editor.h"
26 #include "marker_view.h"
27
28 using namespace ARDOUR ;
29 using namespace sigc;
30
31 sigc::signal<void,MarkerView*> MarkerView::GoingAway;
32
33 //---------------------------------------------------------------------------------------//
34 // Constructor / Desctructor
35
36 /**
37  * Constructs a new MarkerView
38  * 
39  * @param parent the parent canvas item
40  * @param tv the parent TimeAxisView of this item
41  * @param tavi the TimeAxisViewItem that this item is to be assciated (marking) with
42  * @param spu the current samples per unit 
43  * @param base_color
44  * @param mark_type the marker type/name text, eg fade out, pan up etc.
45  * @param mark_id unique name/id of this item
46  * @param start the start time of this item
47  * @param duration the duration of this item
48  */
49 MarkerView::MarkerView(ArdourCanvas::Group *parent,
50                        TimeAxisView* tv,
51                        ImageFrameView* marked,
52                        double spu,
53                        Gdk::Color& basic_color,
54                        std::string mark_type,
55                        std::string mark_id,
56                        nframes_t start,
57                        nframes_t duration)
58   : TimeAxisViewItem(mark_id, *parent,*tv,spu,basic_color,start,duration)
59 {
60         mark_type_text = mark_type ;
61         marked_item = marked ;
62
63         // set the canvas item text to the marker type, not the id
64         set_name_text(mark_type_text) ;
65
66         // hook up our canvas events
67
68         frame_handle_start->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_markerview_start_handle_event), frame_handle_start, this));
69         frame_handle_end->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_markerview_end_handle_event), frame_handle_end, this));
70         group->signal_event().connect (bind (mem_fun (PublicEditor::instance(), &PublicEditor::canvas_markerview_item_view_event), group, this));
71         
72         set_position(start, this) ;
73         set_duration(duration, this) ;
74 }
75
76 /**
77  * Destructor
78  * Destroys this Marker Item and removes the association between itself and the item it is marking.
79  */
80 MarkerView::~MarkerView()
81 {
82         // remove the association our marked may still have to us
83         if(marked_item)
84         {
85                 marked_item->remove_marker_view_item(this, this) ;
86         }
87 }
88
89         
90 //---------------------------------------------------------------------------------------//
91 // Marker Type Methods
92
93 /**
94  * Sets the marker Type text of this this MarkerItem, eg fade_out, pan up etc. 
95  *
96  * @param type_text the marker type text of this item
97  */
98 void
99 MarkerView::set_mark_type_text(std::string type_text)
100 {
101         mark_type_text = type_text ;
102          MarkTypeChanged(mark_type_text, this) ; /* EMIT_SIGNAL */
103 }
104                 
105 /**
106  * Returns the marker Type of this this MarkerItem, eg fade_out, pan up etc. 
107  *
108  * @return the marker type text of this item
109  */
110 std::string
111 MarkerView::get_mark_type_text() const
112 {
113         return(mark_type_text) ;
114 }
115
116
117 //---------------------------------------------------------------------------------------//
118 // Marked Item Methods
119
120 ImageFrameView*
121 MarkerView::set_marked_item(ImageFrameView* item)
122 {
123         ImageFrameView* temp = marked_item ;
124         marked_item = item ;
125         
126          MarkedItemChanged(marked_item, this) ; /* EMIT_SIGNAL */
127         return(temp) ;
128 }
129
130 ImageFrameView*
131 MarkerView::get_marked_item()
132 {
133         return(marked_item) ;
134 }