merge with master
[ardour.git] / gtk2_ardour / imageframe_time_axis.h
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 #ifndef __ardour_imageframe_time_axis_h__
21 #define __ardour_imageframe_time_axis_h__
22
23 #include <list>
24
25
26 #include "ardour_dialog.h"
27 #include "enums.h"
28 #include "time_axis_view.h"
29 #include "visual_time_axis.h"
30
31 namespace ARDOUR
32 {
33         class Session ;
34 }
35 namespace Gtk {
36         class Menu;
37 }
38
39 class PublicEditor ;
40 class ImageFrameView ;
41 class ImageFrameTimeAxisView ;
42 class MarkersTimeAxisView ;
43 class MarkerTimeAxis;
44
45 /**
46  * ImageFrameTimeAxis defines a visual time axis view for holding and arranging image items.
47  *
48  */
49 class ImageFrameTimeAxis : public VisualTimeAxis
50 {
51         public:
52                 //---------------------------------------------------------------------------------------//
53                 // Constructor / Desctructor
54
55                 /**
56                  * Constructs a new ImageFrameTimeAxis.
57                  *
58                  * @param track_id the track name/id
59                  * @param ed the PublicEditor
60                  * @param sess the current session
61                  * @param canvas the parent canvas item
62                  */
63                 ImageFrameTimeAxis(const std::string & track_id, PublicEditor& ed, ARDOUR::Session* sess, ArdourCanvas::Canvas& canvas) ;
64
65                 /**
66                  * Destructor
67                  * Responsible for destroying any child image items that may have been added to thie time axis
68                  */
69                 virtual ~ImageFrameTimeAxis() ;
70
71                 //---------------------------------------------------------------------------------------//
72                 // ui methods & data
73
74                 /**
75                  * Sets the height of this TrackView to one of ths TrackHeghts
76                  *
77                  * @param h the number of pixels to set the height too
78                  */
79                 virtual void set_height(uint32_t h) ;
80
81                 virtual void set_samples_per_pixel (double);
82
83                 /**
84                  * Returns the available height for images to be drawn onto
85                  *
86                  * @return the available height for an image item to be drawn onto
87                  */
88                 int get_image_display_height() ;
89
90
91                 /**
92                  * Show the popup edit menu
93                  *
94                  * @param button the mouse button pressed
95                  * @param time when to show the popup
96                  * @param clicked_imageframe the ImageFrameItem that the event ocured upon, or 0 if none
97                  * @param with_item true if an item has been selected upon the time axis, used to set context menu
98                  */
99                 void popup_imageframe_edit_menu(int button, int32_t time, ImageFrameView* clicked_imageframe, bool with_item) ;
100
101
102                 //---------------------------------------------------------------------------------------//
103                 // Marker Time Axis Methods
104
105                 /**
106                  * Add a MarkerTimeAxis to the ilst of MarkerTimeAxis' associated with this ImageFrameTimeAxis
107                  *
108                  * @param marker_track the MarkerTimeAxis to add
109                  * @param src the identity of the object that initiated the change
110                  * @return true if the addition was a success,
111                  *         false otherwise
112                  */
113                 bool add_marker_time_axis(MarkerTimeAxis* marker_track, void* src) ;
114
115                 /**
116                  * Returns the named MarkerTimeAxis associated with this ImageFrameTimeAxis
117                  *
118                  * @param track_id the track_id of the MarkerTimeAxis to search for
119                  * @return the named markerTimeAxis, or 0 if the named MarkerTimeAxis is not associated with this ImageFrameTimeAxis
120                  */
121                 MarkerTimeAxis* get_named_marker_time_axis(const std::string & track_id) ;
122
123                 /**
124                  * Removes the named markerTimeAxis from those associated with this ImageFrameTimeAxis
125                  *
126                  * @param track_id the track id of the MarkerTimeAxis to remove
127                  * @param src the identity of the object that initiated the change
128                  * @return the removed MarkerTimeAxis
129                  */
130                 MarkerTimeAxis* remove_named_marker_time_axis(const std::string & track_id, void* src) ;
131
132                 /**
133                  * Potentially removes a MarkerTimeAxisView from the list of MarkerTimaAxis associated with this ImageFrameTimeAxis
134                  *
135                  * @param tav the TimeAxis to remove
136                  * @param src the identity of the object that initiated the change
137                  */
138                 void remove_time_axis_view (TimeAxisView* av);
139
140
141                 //---------------------------------------------------------------------------------------//
142                 // Parent/Child helper object accessors
143
144                 /**
145                  * Returns the view helper of this TimeAxis
146                  *
147                  * @return the view helper of this TimeAxis
148                  */
149                 ImageFrameTimeAxisView* get_view() ;
150
151
152                 //---------------------------------------------------------------------------------//
153                 // Emitted Signals
154
155                 /** Emitted when a Marker Time Axis is Added, or associated with, this time axis */
156                 sigc::signal<void,MarkerTimeAxis*,void*> MarkerTimeAxisAdded ;
157
158                 /** Emitted when a Marker Time Axis is removed, from this time axis */
159                 sigc::signal<void,std::string,void*> MarkerTimeAxisRemoved ;
160
161         protected:
162
163         private:
164                 /**
165                  * convenience method to select a new track color and apply it to the view and view items
166                  *
167                  */
168                 void select_track_color() ;
169
170                 /**
171                  * Handles the building of the popup menu
172                  */
173                 virtual void build_display_menu() ;
174
175                 /**
176                  * handles the building of the ImageFrameView sub menu
177                  */
178                 void create_imageframe_menu() ;
179
180                 /* We may have multiple marker views, but each marker view should only be associated with one timeaxisview */
181                 typedef std::list<MarkerTimeAxis*> MarkerTimeAxisList ;
182                 MarkerTimeAxisList marker_time_axis_list;
183
184                 /* the TimeAxis view helper */
185                 ImageFrameTimeAxisView *view ;
186
187                 // popup menu widgets
188                 Gtk::Menu *image_action_menu ;
189                 Gtk::Menu *imageframe_menu ;
190                 Gtk::Menu *imageframe_item_menu ;
191
192 }; /* class ImageFrameTimeAxis */
193
194 #endif /* __ardour_imageframe_time_axis_h__ */
195