2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
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.
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.
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.
21 #ifndef __GST_EDITOR_H__
22 #define __GST_EDITOR_H__
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;
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)))
58 /* the actual pipeline to be associated with this thing */
59 GstPipeline *pipeline;
61 /* the editor canvas */
62 GstEditorCanvas *canvas;
64 /* the canvas and scrollwindow */
65 GtkWidget *canvaswidget;
66 GtkWidget *scrollwindow;
69 struct _GstEditorClass {
70 GnomeCanvasClass parent_class;
74 GtkType gst_editor_get_type();
75 GstEditor *gst_editor_new(gchar *name);
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"))
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)))
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)
101 struct _GstEditorElement {
104 /* parent object (NULL if I am the parent) */
105 GstEditorBin *parent;
107 /* toplevel canvas (myself if I am the toplevel) */
108 GstEditorCanvas *canvas;
110 /* the element we're associated with */
113 /* whether we've been realized or not */
116 /* toplevel group, must be !NULL */
117 GnomeCanvasGroup *group; // parent group
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
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?
135 GnomeCanvasGroup *insidegroup; // contents if any
137 gboolean resize; // does it need resizing?
140 GList *srcpads,*sinkpads;
141 gboolean padlistchange;
143 /* interaction state */
144 gboolean dragging,resizing,moved,hesitating;
145 gdouble offx,offy,dragx,dragy;
148 struct _GstEditorElementClass {
149 GnomeCanvasGroupClass parent_class;
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);
159 GtkType gst_editor_element_get_type();
160 GstEditorElement *gst_editor_element_new(GstEditorBin *parent,
162 const gchar *first_arg_name,...);
163 void gst_editor_element_construct(GstEditorElement *element,
164 GstEditorBin *parent,
165 const gchar *first_arg_name,
167 void gst_editor_element_repack(GstEditorElement *element);
168 GstEditorPad *gst_editor_element_add_pad(GstEditorElement *element,
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)))
183 struct _GstEditorBin {
184 GstEditorElement element;
186 /* lists of GUI elements and connections */
187 GList *elements, *connections;
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
198 struct _GstEditorBinClass {
199 GstEditorElementClass parent_class;
204 GtkType gst_editor_bin_get_type();
205 GstEditorBin *gst_editor_bin_new(GstEditorBin *parent,GstBin *bin,
206 const gchar *first_arg_name,...);
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)))
222 struct _GstEditorCanvas {
230 struct _GstEditorCanvasClass {
231 GnomeCanvasClass parent_class;
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);
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)))
253 struct _GstEditorPad {
257 GstEditorElement *parent;
259 /* toplevel canvas */
260 GstEditorCanvas *canvas;
262 /* the pad we're associated with */
264 /* if this is a sink (convenience) */
267 /* whether we've been realized or not */
271 GstEditorConnection *connection;
272 GstEditorConnection *ghostconnection;
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?
283 /* interaction state */
284 gboolean dragging,resizing,moved;
288 // GnomeCanvasItem *connection; // can't use
289 //GstEditorConnection
292 struct _GstEditorPadClass {
293 GtkObjectClass parent_class;
295 void (*realize) (GstEditorPad *pad);
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);
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)))
319 struct _GstEditorConnection {
323 GstEditorElement *parent;
325 /* the two pads we're connecting */
326 GstEditorPad *frompad, *topad;
327 /* is this starting at a source (convenience) */
330 /* toplevel canvas */
331 GstEditorCanvas *canvas;
333 /* whether we've been realized or not */
336 /* are we a ghosted connection? */
340 GnomeCanvasItem *line;
341 GnomeCanvasPoints *points;
342 gdouble x,y; // terminating point
343 gboolean resize; // does it need resizing?
346 struct _GstEditorConnectionClass {
347 GtkObjectClass parent_class;
348 void (*realize) (GstEditorConnection *connection);
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,
357 void gst_editor_connection_connect(GstEditorConnection *connection);
360 #endif /* __GST_EDITOR_H__ */