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