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