summaryrefslogtreecommitdiff
path: root/gtk2_ardour/imageframe_time_axis_group.h
blob: 4619ae448a4da54016e40f636c46d2e336dc6085 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
/*
    Copyright (C) 2003 Paul Davis 

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

    $Id$
*/

#ifndef __ardour_imageframe_time_axis_group_h__
#define __ardour_imageframe_time_axis_group_h__

#include <list>
#include <cmath>

#include <gdkmm/color.h>

#include <libgnomecanvas/libgnomecanvas.h>
#include <jack/jack.h>
#include <ardour/types.h>
#include "imageframe_time_axis_view.h"

class PublicEditor ;
class ImageFrameView ;

/**
 * ImageFrameTimeAxisGroup defines a group/scene of ImageFrame view that can appear upon a time axis
 * At the moment this is a bit bare, we really want to add some kind of time constraints upon
 * items atht are added to the group, ie bounded by the start and end of the scene, which itself
 * needs fleshed out.
 * A viewable object may also be useful...
 *
 */
class ImageFrameTimeAxisGroup : public sigc::trackable
{
	public:
		//---------------------------------------------------------------------------------------//
		// Constructor / Desctructor
		
		/**
		 * Constructs a new ImageFrameTimeAxisGroup.
		 *
		 * @param iftav the parent ImageFrameTimeAxis of this view helper
		 * @param group_id the unique name/id of this group
		 */
		ImageFrameTimeAxisGroup(ImageFrameTimeAxisView& iftav, const string & group_id) ;
		
		/**
		 * Destructor
		 * Responsible for destroying any Items that may have been added to this group
		 *
		 */
		virtual ~ImageFrameTimeAxisGroup() ;
		
		
		//---------------------------------------------------------------------------------------//
		// Name/Id Accessors/Mutators
		
		/**
		 * Set the name/Id of this group.
		 *
		 * @param new_name the new name of this group
		 * @param src the identity of the object that initiated the change
		 */
		void set_group_name(const string & new_name, void* src) ;

		/**
		 * Returns the id of this group
		 * The group id must be unique upon a time axis
		 *
		 * @return the id of this group
		 */
		std::string get_group_name() const ;
		
		
		//---------------------------------------------------------------------------------------//
		// Parent/Child helper object accessors
		
		/**
		 * Returns the TimeAxisView thatt his object is acting as a helper for
		 *
		 * @return the TimeAxisView that this object is acting as a view helper for
		 */
		ImageFrameTimeAxisView& get_view() const { return _view_helper ; }
	
		
		
		//---------------------------------------------------------------------------------------//
		// ui methods & data
		
		/**
		 * Sets the height of the time axis view and the item upon it
		 *
		 * @param height the new height
		 */
		int set_item_heights(gdouble) ;
		
		/**
		 * Sets the current samples per unit.
		 * this method tells each item upon the time axis of the change
		 * 
		 * @param spu the new samples per canvas unit value
		 */
		int set_item_samples_per_units(gdouble spu) ;
		
		/**
		 * Sets the color of the items contained uopn this view helper
		 *
		 * @param color the new base color
		 */
		void apply_item_color(Gdk::Color&) ;
		
		
		//---------------------------------------------------------------------------------------//
		// child ImageFrameView methods
		
		/**
		 * Adds an ImageFrameView to the list of items upon this time axis view helper
		 * the new ImageFrameView is returned
		 *
		 * @param item_id the unique id of the new item
		 * @param image_id the id/name of the image data we are usin
		 * @param start the position the new item should be placed upon the time line
		 * @param duration the duration the new item should be placed upon the timeline
		 * @param rgb_data the rgb data of the image
		 * @param width the original image width of the rgb_data (not the size to display)
		 * @param height the irigianl height of the rgb_data
		 * @param num_channels the number of channles within the rgb_data
		 * @param src the identity of the object that initiated the change
		 */
		ImageFrameView* add_imageframe_item(const string & item_id, nframes_t start, nframes_t duration, unsigned char* rgb_data, uint32_t width, uint32_t height, uint32_t num_channels, void* src) ;
		
		/**
		 * Returns the named ImageFrameView or 0 if the named view does not exist on this view helper
		 *
		 * @param item_id the unique id of the item to search for
		 * @return the named ImageFrameView, or 0 if it is not held upon this view
		 */
		ImageFrameView* get_named_imageframe_item(const string & item_id) ;
		
		/**
		 * Removes the currently selected ImageFrameView
		 *
		 * @param src the identity of the object that initiated the change
		 * @see add_imageframe_view
		 */
		void remove_selected_imageframe_item(void* src) ;
		
		/**
		 * Removes and returns the named ImageFrameView from the list of ImageFrameViews held by this view helper
		 *
		 * @param item_id the ImageFrameView unique id to remove
		 * @param src the identity of the object that initiated the change
		 * @see add_imageframe_view
		 */
		ImageFrameView* remove_named_imageframe_item(const string & item_id, void* src) ;
		
		/**
		 * Removes ifv from the list of ImageFrameViews upon this TimeAxis.
		 * if ifv is not upon this TimeAxis, this method takes no action
		 *
		 * @param ifv the ImageFrameView to remove
		 */
		void remove_imageframe_item(ImageFrameView*, void* src) ;
		
	
		//---------------------------------------------------------------------------------------//
		// Selected group methods
		

		// removed in favour of a track level selectewd item
		// this is simply easier to manage a singularly selected item, rather than
		// a selected item within each group
		
		/**
		 * Sets the currently selected item upon this time axis
		 *
		 * @param ifv the item to set selected
		 */
		//void set_selected_imageframe_item(ImageFrameView* ifv) ;
		
		/**
		 * Sets the currently selected item upon this time axis to the named item
		 *
		 * @param item_id the name/id of the item to set selected
		 */
		//void set_selected_imageframe_item(std::string item_id) ;

		/**
		 * Returns the currently selected item upon this time axis
		 *
		 * @return the currently selected item pon this time axis
		 */		
		//ImageFrameView* get_selected_imageframe_item() ;
		
		/**
		 * Returns whether this grou pis currently selected
		 *
		 * @returns true if this group is currently selected
		 */
		bool get_selected() const ;
		
		/**
		 * Sets he selected state of this group
		 *
		 * @param yn set true if this group is selected, false otherwise
		 */
		void set_selected(bool yn) ;
		
		//---------------------------------------------------------------------------------------//
		// Handle group removal
		
		/**
		 * Handles the Removal of this VisualTimeAxis
		 * This _needs_ to be called to alert others of the removal properly, ie where the source
		 * of the removal came from.
		 *
		 * XXX Although im not too happy about this method of doing things, I cant think of a cleaner method
		 *     just now to capture the source of the removal
		 *
		 * @param src the identity of the object that initiated the change
		 */
		virtual void remove_this_group(void* src) ;

		//---------------------------------------------------------------------------------//
		// Emitted Signals
		
		sigc::signal<void> GoingAway ;
		
		/**
		 * Emitted when this Group has been removed
		 * This is different to the GoingAway signal in that this signal
		 * is emitted during the deletion of this Time Axis, and not during
		 * the destructor, this allows us to capture the source of the deletion
		 * event
		 */
		sigc::signal<void,std::string,void*> GroupRemoved ;
		
		/** Emitted when we have changed the name of this TimeAxis */
		sigc::signal<void,std::string,std::string,void*> NameChanged ;
		
		/** Emitted when an ImageFrameView is added to this group */
		sigc::signal<void, ImageFrameView*, void*> ImageFrameAdded ;
		
		/** Emitted when an ImageFrameView is removed from this group */
		sigc::signal<void, const string &, const string &, const string &, void*> ImageFrameRemoved ;
		
	protected:


	private:
		/**
		 * convenience method to re-get the samples per unit and tell items upon this view
		 *
		 */
		void reset_samples_per_unit() ;
		
		/**
		 * Callback used to remove this group during the gtk idle loop
		 * This is used to avoid deleting the obejct while inside the remove_this_group
		 * method
		 *
		 * @param group the ImageFrameTimeAxisGroup to remove
		 * @param src the identity of the object that initiated the change
		 */
		static gint idle_remove_this_group(ImageFrameTimeAxisGroup* group, void* src) ;
		
		/** The list of ImageFrameViews held by this view helper */
		typedef std::list<ImageFrameView *> ImageFrameViewList ;
		ImageFrameViewList imageframe_views ;
		
		/** the currently selected time axis item upon this time axis */
		ImageFrameView* selected_imageframe_item ;
		
		/** the view helper that this object is acting as a container upon on */
		ImageFrameTimeAxisView& _view_helper ;
		
		/** the is of this group */ 
		std::string _group_id ;
		
		/* XXX why are these different? */
		Gdk::Color region_color ;
		uint32_t stream_base_color ;
		
		/** indicates if this group is currently selected */
		bool is_selected ;
		
} ; /* class ImageFrameTimeAxisGroup */

#endif /* __ardour_imageframe_time_axis_group_h__ */