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