updated .cvsignores
[platform/upstream/gstreamer.git] / editor / gsteditor.h
1 /* Gnome-Streamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20
21 #ifndef __GST_EDITOR_H__
22 #define __GST_EDITOR_H__
23
24 #include <gnome.h>
25 #include <gst/gst.h>
26
27
28 typedef struct _GstEditor GstEditor;
29 typedef struct _GstEditorClass GstEditorClass;
30 typedef struct _GstEditorElement GstEditorElement;
31 typedef struct _GstEditorElementClass GstEditorElementClass;
32 typedef struct _GstEditorBin GstEditorBin;
33 typedef struct _GstEditorBinClass GstEditorBinClass;
34 typedef struct _GstEditorCanvas GstEditorCanvas;
35 typedef struct _GstEditorCanvasClass GstEditorCanvasClass;
36 typedef struct _GstEditorPad GstEditorPad;
37 typedef struct _GstEditorPadClass GstEditorPadClass;
38 typedef struct _GstEditorConnection GstEditorConnection;
39 typedef struct _GstEditorConnectionClass GstEditorConnectionClass;
40
41
42
43 #define GST_TYPE_EDITOR \
44   (gst_editor_get_type())
45 #define GST_EDITOR(obj) \
46   (GTK_CHECK_CAST((obj),GST_TYPE_EDITOR,GstEditor))
47 #define GST_EDITOR_CLASS(klass) \
48   (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_EDITOR,GstEditorClass))
49 #define GST_IS_EDITOR(obj) \
50   (GTK_CHECK_TYPE((obj),GST_TYPE_EDITOR))
51 #define GST_IS_EDITOR_CLASS(obj) \
52   (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EDITOR)))
53
54
55 struct _GstEditor {
56   GtkFrame frame;
57
58   /* the actual pipeline to be associated with this thing */
59   GstPipeline *pipeline;
60
61   /* the editor canvas */
62   GstEditorCanvas *canvas;
63
64   /* the canvas and scrollwindow */
65   GtkWidget *canvaswidget;
66   GtkWidget *scrollwindow;
67 };
68
69 struct _GstEditorClass {
70   GnomeCanvasClass parent_class;
71 };
72
73
74 GtkType gst_editor_get_type();
75 GstEditor *gst_editor_new(gchar *name);
76
77
78
79 #define GST_EDITOR_SET_OBJECT(item,object) \
80   (gtk_object_set_data(GTK_OBJECT(item),"gsteditorobject",(object)))
81 #define GST_EDTIOR_GET_OBJECT(item) \
82   (gtk_object_get_data(GTK_OBJECT(item),"gsteditorobject"))
83
84
85
86 #define GST_TYPE_EDITOR_ELEMENT \
87   (gst_editor_element_get_type())
88 #define GST_EDITOR_ELEMENT(obj) \
89   (GTK_CHECK_CAST((obj),GST_TYPE_EDITOR_ELEMENT,GstEditorElement))
90 #define GST_EDITOR_ELEMENT_CLASS(klass) \
91   (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_EDITOR_ELEMENT,GstEditorElementClass))
92 #define GST_IS_EDITOR_ELEMENT(obj) \
93   (GTK_CHECK_TYPE((obj),GST_TYPE_EDITOR_ELEMENT))
94 #define GST_IS_EDITOR_ELEMENT_CLASS(obj) \
95   (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EDITOR_ELEMENT)))
96
97 #define GST_EDITOR_ELEMENT_PARENT(obj) (GST_EDITOR_ELEMENT(obj)->parent)
98 #define GST_EDITOR_ELEMENT_GROUP(obj) (GST_EDITOR_ELEMENT(obj)->group)
99 #define GST_EDITOR_ELEMENT_CANVAS(obj) (GST_EDITOR_ELEMENT(obj)->canvas)
100
101 struct _GstEditorElement {
102   GstObject object;
103
104   /* parent object (NULL if I am the parent) */
105   GstEditorBin *parent;
106
107   /* toplevel canvas (myself if I am the toplevel) */
108   GstEditorCanvas *canvas;
109
110   /* the element we're associated with */
111   GstElement *element;
112
113   /* whether we've been realized or not */
114   gboolean realized;
115
116   /* toplevel group, must be !NULL */
117   GnomeCanvasGroup *group;                      // parent group
118
119   /* visual stuff */
120   gdouble x,y;                                  // center
121   gdouble width,height;                         // size
122   GnomeCanvasItem *border,*title,*resizebox;    // easy ones
123   GnomeCanvasItem *statebox[4],*statetext[4];   // GST_STATE_*
124   GnomeCanvasItem *playbox,*playtext;           // playstate
125   gboolean states[5];                           // visual states
126
127   gdouble insidewidth,insideheight;             // minimum space inside
128   gdouble minwidth,minheight;                   // minimum size
129   gdouble titlewidth,titleheight;               // size of title
130   gdouble statewidth,stateheight;               // size of state boxes
131   gdouble sinkwidth,sinkheight;                 // size of sink pads
132   gdouble srcwidth,srcheight;                   // size of src pads
133   gint sinks,srcs;                              // how many pads?
134
135   GnomeCanvasGroup *insidegroup;                // contents if any
136
137   gboolean resize;                              // does it need resizing?
138
139   /* list of pads */
140   GList *srcpads,*sinkpads;
141   gboolean padlistchange;
142
143   /* interaction state */
144   gboolean dragging,resizing,moved,hesitating;
145   gdouble offx,offy,dragx,dragy;
146 };
147
148 struct _GstEditorElementClass {
149   GnomeCanvasGroupClass parent_class;
150
151   void (*realize) (GstEditorElement *element);
152   gint (*event) (GnomeCanvasItem *item,GdkEvent *event,
153                 GstEditorElement *element);
154   gint (*button_event) (GnomeCanvasItem *item,GdkEvent *event,
155                         GstEditorElement *element);
156 };
157
158
159 GtkType gst_editor_element_get_type();
160 GstEditorElement *gst_editor_element_new(GstEditorBin *parent,
161                                          GstElement *element,
162                                          const gchar *first_arg_name,...);
163 void gst_editor_element_construct(GstEditorElement *element,
164                                   GstEditorBin *parent,
165                                   const gchar *first_arg_name,
166                                   va_list args);
167 void gst_editor_element_repack(GstEditorElement *element);
168 GstEditorPad *gst_editor_element_add_pad(GstEditorElement *element,
169                                          GstPad *pad);  
170
171
172 #define GST_TYPE_EDITOR_BIN \
173   (gst_editor_bin_get_type())
174 #define GST_EDITOR_BIN(obj) \
175   (GTK_CHECK_CAST((obj),GST_TYPE_EDITOR_BIN,GstEditorBin))
176 #define GST_EDITOR_BIN_CLASS(klass) \
177   (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_EDITOR_BIN,GstEditorBin))
178 #define GST_IS_EDITOR_BIN(obj) \
179   (GTK_CHECK_TYPE((obj),GST_TYPE_EDITOR_BIN))
180 #define GST_IS_EDITOR_BIN_CLASS(obj) \
181   (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EDITOR_BIN)))
182   
183 struct _GstEditorBin {
184   GstEditorElement element;
185
186   /* lists of GUI elements and connections */ 
187   GList *elements, *connections;
188
189   /* connection state */
190   GstEditorPad *frompad;                // where the drawing started from
191   gboolean fromsrc;                     // are we connecting *from* a source?
192   gboolean connecting;                  // if we're trying to connect right now
193   GstEditorConnection *connection;      // the connection we're operating on
194   GstEditorPad *ghostpad;               // potential ghost pad
195   gboolean inpadregion;                 // is cursor in pad region
196 };
197
198 struct _GstEditorBinClass {
199   GstEditorElementClass parent_class;
200 };
201
202
203
204 GtkType gst_editor_bin_get_type();
205 GstEditorBin *gst_editor_bin_new(GstEditorBin *parent,GstBin *bin,
206                                  const gchar *first_arg_name,...);
207
208
209
210 #define GST_TYPE_EDITOR_CANVAS \
211   (gst_editor_canvas_get_type())
212 #define GST_EDITOR_CANVAS(obj) \
213   (GTK_CHECK_CAST((obj),GST_TYPE_EDITOR_CANVAS,GstEditorCanvas))
214 #define GST_EDITOR_CANVAS_CLASS(klass) \
215   (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_EDITOR_CANVAS,GstEditorCanvasClass))
216 #define GST_IS_EDITOR_CANVAS(obj) \
217   (GTK_CHECK_TYPE((obj),GST_TYPE_EDITOR_CANVAS))
218 #define GST_IS_EDITOR_CANVAS_CLASS(obj) \
219   (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EDITOR_CANVAS)))
220
221
222 struct _GstEditorCanvas {
223   GstEditorBin bin;
224
225   gboolean inchild;
226
227   GnomeCanvas *canvas;
228 };
229
230 struct _GstEditorCanvasClass {
231   GnomeCanvasClass parent_class;
232 };
233
234
235 GtkType gst_editor_canvas_get_type();
236 GstEditorCanvas *gst_editor_canvas_new(GstBin *bin,
237                                        const gchar *first_arg_name,...);
238 GtkWidget *gst_editor_canvas_get_canvas(GstEditorCanvas *canvas);
239 void gst_editor_bin_add(GstEditorBin *parent,GstEditorElement *element);
240
241
242 #define GST_TYPE_EDITOR_PAD \
243   (gst_editor_pad_get_type())
244 #define GST_EDITOR_PAD(obj) \
245   (GTK_CHECK_CAST((obj),GST_TYPE_EDITOR_PAD,GstEditorPad))
246 #define GST_EDITOR_PAD_CLASS(klass) \
247   (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_EDITOR_PAD,GstEditorPadClass))
248 #define GST_IS_EDITOR_PAD(obj) \
249   (GTK_CHECK_TYPE((obj),GST_TYPE_EDITOR_PAD))
250 #define GST_IS_EDITOR_PAD_CLASS(obj) \
251   (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EDITOR_PAD)))
252
253 struct _GstEditorPad {
254   GtkObject object; 
255
256   /* parent element */
257   GstEditorElement *parent;
258
259   /* toplevel canvas */
260   GstEditorCanvas *canvas;
261
262   /* the pad we're associated with */
263   GstPad *pad;
264   /* if this is a sink (convenience) */
265   gboolean issrc;
266
267   /* whether we've been realized or not */
268   gboolean realized;
269
270   /* connections */
271   GstEditorConnection *connection;
272   GstEditorConnection *ghostconnection;
273
274   /* visual stuff */
275   GnomeCanvasGroup *group;
276   GnomeCanvasItem *border,*title,*padbox;
277   gboolean sinkpad;                             // is this a sink pad?
278   gdouble x,y;                                  // location
279   gdouble width,height;                         // actual size
280   gdouble boxwidth,boxheight;                   // size of pad box
281   gboolean resize;                              // does it need resizing?
282   
283   /* interaction state */
284   gboolean dragging,resizing,moved;
285   gdouble dragx,dragy;
286
287   /* connection */
288 //  GnomeCanvasItem *connection;                // can't use
289 //GstEditorConnection
290 };
291   
292 struct _GstEditorPadClass {
293   GtkObjectClass parent_class;
294
295   void (*realize) (GstEditorPad *pad);
296 };
297   
298 GtkType gst_editor_pad_get_type();
299 GstEditorPad *gst_editor_pad_new(GstEditorElement *parent,GstPad *pad,
300                                  const gchar *first_arg_name, ...);
301 void gst_editor_pad_construct(GstEditorPad *element,
302                               GstEditorElement *parent,
303                               const gchar *first_arg_name,va_list args);
304 void gst_editor_pad_repack(GstEditorPad *pad);
305
306
307
308 #define GST_TYPE_EDITOR_CONNECTION \
309   (gst_editor_connection_get_type())
310 #define GST_EDITOR_CONNECTION(obj) \
311   (GTK_CHECK_CAST((obj),GST_TYPE_EDITOR_CONNECTION,GstEditorConnection))
312 #define GST_EDITOR_CONNECTION_CLASS(klass) \
313   (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_EDITOR_CONNECTION,GstEditorConnectionClass))
314 #define GST_IS_EDITOR_CONNECTION(obj) \
315   (GTK_CHECK_TYPE((obj),GST_TYPE_EDITOR_CONNECTION))
316 #define GST_IS_EDITOR_CONNECTION_CLASS(obj) \
317   (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EDITOR_CONNECTION)))
318
319 struct _GstEditorConnection {
320   GtkObject object;
321
322   /* our parent */
323   GstEditorElement *parent;
324
325   /* the two pads we're connecting */
326   GstEditorPad *frompad, *topad;
327   /* is this starting at a source (convenience) */
328   gboolean fromsrc;
329
330   /* toplevel canvas */
331   GstEditorCanvas *canvas;
332
333   /* whether we've been realized or not */
334   gboolean realized;
335
336   /* are we a ghosted connection? */
337   gboolean ghost;
338
339   /* visual stuff */
340   GnomeCanvasItem *line;
341   GnomeCanvasPoints *points;
342   gdouble x,y;                                  // terminating point
343   gboolean resize;                             // does it need resizing?
344 };
345
346 struct _GstEditorConnectionClass {
347   GtkObjectClass parent_class;
348   void (*realize) (GstEditorConnection *connection);
349 };
350
351 GtkType gst_editor_connection_get_type();
352 void gst_editor_connection_resize(GstEditorConnection *connection);
353 void gst_editor_connection_set_endpoint(GstEditorConnection *connection,
354                                         gdouble x,gdouble y);
355 void gst_editor_connection_set_endpad(GstEditorConnection *connection,
356                                       GstEditorPad *pad);
357 void gst_editor_connection_connect(GstEditorConnection *connection);
358
359
360 #endif /* __GST_EDITOR_H__ */