2000-01-30 10:44:33 +00:00
|
|
|
/* Gnome-Streamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <gnome.h>
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/gstutils.h>
|
|
|
|
|
|
|
|
#include "gsteditor.h"
|
2000-10-01 21:46:33 +00:00
|
|
|
#include "gsteditorproject.h"
|
|
|
|
#include "gsteditorproperty.h"
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
/* class functions */
|
2000-12-25 01:33:06 +00:00
|
|
|
static void gst_editor_element_class_init (GstEditorElementClass *klass);
|
|
|
|
static void gst_editor_element_init (GstEditorElement *element);
|
|
|
|
|
|
|
|
static void gst_editor_element_set_arg (GtkObject *object,GtkArg *arg,guint id);
|
|
|
|
static void gst_editor_element_get_arg (GtkObject *object,GtkArg *arg,guint id);
|
|
|
|
|
|
|
|
static void gst_editor_element_realize (GstEditorElement *element);
|
|
|
|
static gint gst_editor_element_event (GnomeCanvasItem *item,
|
|
|
|
GdkEvent *event,
|
|
|
|
GstEditorElement *element);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
/* events fired by items within self */
|
2000-12-25 01:33:06 +00:00
|
|
|
static gint gst_editor_element_resizebox_event (GnomeCanvasItem *item,
|
|
|
|
GdkEvent *event,
|
|
|
|
GstEditorElement *element);
|
|
|
|
static gint gst_editor_element_group_event (GnomeCanvasItem *item,
|
|
|
|
GdkEvent *event,
|
|
|
|
GstEditorElement *element);
|
|
|
|
static gint gst_editor_element_state_event (GnomeCanvasItem *item,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
/* utility functions */
|
2000-12-25 01:33:06 +00:00
|
|
|
static void gst_editor_element_resize (GstEditorElement *element);
|
|
|
|
static void gst_editor_element_set_state (GstEditorElement *element,
|
|
|
|
gint id,gboolean set);
|
2000-12-28 02:51:07 +00:00
|
|
|
static void gst_editor_element_add_pad_wrapper (GstEditorElement *element,
|
|
|
|
GstPad *pad);
|
|
|
|
static void gst_editor_element_add_pad (GstEditorElement *element,
|
|
|
|
GstPad *pad);
|
|
|
|
GstEditorPadTemplate* gst_editor_element_add_padtemplate (GstEditorElement *element,
|
|
|
|
GstPadTemplate *pad);
|
2000-12-25 01:33:06 +00:00
|
|
|
static void gst_editor_element_sync_state (GstEditorElement *element);
|
2000-12-28 02:51:07 +00:00
|
|
|
static void gst_editor_element_sync_state_wrapper (GstEditorElement *element);
|
2000-12-25 01:33:06 +00:00
|
|
|
static void gst_editor_element_move (GstEditorElement *element,
|
|
|
|
gdouble dx,gdouble dy);
|
2000-12-28 02:51:07 +00:00
|
|
|
static void gst_editor_element_position_changed (GstEditorElement *element,
|
|
|
|
GstEditorElement *parent);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2000-10-01 21:46:33 +00:00
|
|
|
static gchar *_gst_editor_element_states[] = { "S","R","P","F" };
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2000-10-01 21:46:33 +00:00
|
|
|
static GstElementState _gst_element_states[] = {
|
|
|
|
GST_STATE_NULL,
|
|
|
|
GST_STATE_READY,
|
|
|
|
GST_STATE_PLAYING,
|
|
|
|
GST_STATE_PAUSED,
|
|
|
|
};
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
ARG_0,
|
|
|
|
ARG_X,
|
|
|
|
ARG_Y,
|
|
|
|
ARG_WIDTH,
|
|
|
|
ARG_HEIGHT,
|
|
|
|
ARG_X1,
|
|
|
|
ARG_Y1,
|
|
|
|
ARG_X2,
|
|
|
|
ARG_Y2,
|
|
|
|
ARG_ELEMENT,
|
2000-12-25 01:33:06 +00:00
|
|
|
ARG_ACTIVE,
|
2000-01-30 10:44:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2000-10-01 21:46:33 +00:00
|
|
|
NAME_CHANGED,
|
2000-12-25 01:33:06 +00:00
|
|
|
POSITION_CHANGED,
|
|
|
|
SIZE_CHANGED,
|
2000-01-30 10:44:33 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static GtkObjectClass *parent_class;
|
|
|
|
static guint gst_editor_element_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
GtkType
|
|
|
|
gst_editor_element_get_type(void)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
static GtkType element_type = 0;
|
|
|
|
|
|
|
|
if (!element_type) {
|
|
|
|
static const GtkTypeInfo element_info = {
|
|
|
|
"GstEditorElement",
|
|
|
|
sizeof(GstEditorElement),
|
|
|
|
sizeof(GstEditorElementClass),
|
|
|
|
(GtkClassInitFunc)gst_editor_element_class_init,
|
|
|
|
(GtkObjectInitFunc)gst_editor_element_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GtkClassInitFunc)NULL,
|
|
|
|
};
|
|
|
|
element_type = gtk_type_unique(gtk_object_get_type(),&element_info);
|
|
|
|
}
|
|
|
|
return element_type;
|
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void
|
|
|
|
gst_editor_element_class_init (GstEditorElementClass *klass)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GtkObjectClass *object_class;
|
|
|
|
|
|
|
|
object_class = (GtkObjectClass*)klass;
|
|
|
|
|
|
|
|
parent_class = gtk_type_class(gtk_object_get_type());
|
|
|
|
|
2000-10-01 21:46:33 +00:00
|
|
|
gst_editor_element_signals[NAME_CHANGED] =
|
2000-12-25 01:33:06 +00:00
|
|
|
gtk_signal_new ("name_changed", GTK_RUN_FIRST, object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GstEditorElementClass, name_changed),
|
|
|
|
gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1,
|
|
|
|
GST_TYPE_EDITOR_ELEMENT);
|
|
|
|
gst_editor_element_signals[POSITION_CHANGED] =
|
|
|
|
gtk_signal_new ("position_changed", GTK_RUN_FIRST, object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GstEditorElementClass, position_changed),
|
|
|
|
gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1,
|
|
|
|
GST_TYPE_EDITOR_ELEMENT);
|
|
|
|
gst_editor_element_signals[SIZE_CHANGED] =
|
|
|
|
gtk_signal_new ("size_changed", GTK_RUN_FIRST, object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GstEditorElementClass, size_changed),
|
|
|
|
gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1,
|
|
|
|
GST_TYPE_EDITOR_ELEMENT);
|
2000-10-01 21:46:33 +00:00
|
|
|
|
|
|
|
gtk_object_class_add_signals(object_class,gst_editor_element_signals,LAST_SIGNAL);
|
|
|
|
|
2000-01-30 10:44:33 +00:00
|
|
|
gtk_object_add_arg_type("GstEditorElement::x",GTK_TYPE_DOUBLE,
|
|
|
|
GTK_ARG_READWRITE|GTK_ARG_CONSTRUCT_ONLY,
|
|
|
|
ARG_X);
|
|
|
|
gtk_object_add_arg_type("GstEditorElement::y",GTK_TYPE_DOUBLE,
|
|
|
|
GTK_ARG_READWRITE|GTK_ARG_CONSTRUCT_ONLY,
|
|
|
|
ARG_Y);
|
|
|
|
gtk_object_add_arg_type("GstEditorElement::width",GTK_TYPE_DOUBLE,
|
|
|
|
GTK_ARG_READWRITE|GTK_ARG_CONSTRUCT_ONLY,
|
|
|
|
ARG_WIDTH);
|
|
|
|
gtk_object_add_arg_type("GstEditorElement::height",GTK_TYPE_DOUBLE,
|
|
|
|
GTK_ARG_READWRITE|GTK_ARG_CONSTRUCT_ONLY,
|
|
|
|
ARG_HEIGHT);
|
|
|
|
gtk_object_add_arg_type("GstEditorElement::x1",GTK_TYPE_DOUBLE,
|
2000-12-25 01:33:06 +00:00
|
|
|
GTK_ARG_READWRITE, ARG_X1);
|
2000-01-30 10:44:33 +00:00
|
|
|
gtk_object_add_arg_type("GstEditorElement::y1",GTK_TYPE_DOUBLE,
|
2000-12-25 01:33:06 +00:00
|
|
|
GTK_ARG_READWRITE, ARG_Y1);
|
2000-01-30 10:44:33 +00:00
|
|
|
gtk_object_add_arg_type("GstEditorElement::x2",GTK_TYPE_DOUBLE,
|
2000-12-25 01:33:06 +00:00
|
|
|
GTK_ARG_READWRITE, ARG_X2);
|
2000-01-30 10:44:33 +00:00
|
|
|
gtk_object_add_arg_type("GstEditorElement::y2",GTK_TYPE_DOUBLE,
|
2000-12-25 01:33:06 +00:00
|
|
|
GTK_ARG_READWRITE, ARG_Y2);
|
2000-01-30 10:44:33 +00:00
|
|
|
gtk_object_add_arg_type("GstEditorElement::element",GTK_TYPE_POINTER,
|
2000-12-25 01:33:06 +00:00
|
|
|
GTK_ARG_READABLE, ARG_ELEMENT);
|
|
|
|
gtk_object_add_arg_type("GstEditorElement::active",GTK_TYPE_BOOL,
|
|
|
|
GTK_ARG_READWRITE, ARG_ACTIVE);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
klass->realize = gst_editor_element_realize;
|
|
|
|
klass->event = gst_editor_element_event;
|
|
|
|
|
|
|
|
object_class->set_arg = gst_editor_element_set_arg;
|
|
|
|
object_class->get_arg = gst_editor_element_get_arg;
|
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void
|
|
|
|
gst_editor_element_init (GstEditorElement *element)
|
|
|
|
{
|
|
|
|
element->active = FALSE;
|
2000-01-30 10:44:33 +00:00
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
GstEditorElement*
|
|
|
|
gst_editor_element_new (GstElement *element,
|
|
|
|
const gchar *first_arg_name, ...)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GstEditorElement *editorelement;
|
|
|
|
va_list args;
|
|
|
|
|
2000-10-01 21:46:33 +00:00
|
|
|
g_return_val_if_fail(element != NULL, NULL);
|
|
|
|
g_return_val_if_fail(GST_IS_ELEMENT(element), NULL);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
editorelement = GST_EDITOR_ELEMENT(gtk_type_new(GST_TYPE_EDITOR_ELEMENT));
|
|
|
|
editorelement->element = element;
|
2000-12-25 01:33:06 +00:00
|
|
|
GST_EDITOR_SET_OBJECT(element, editorelement);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
va_start(args,first_arg_name);
|
2000-12-25 01:33:06 +00:00
|
|
|
gst_editor_element_construct(editorelement,first_arg_name,args);
|
2000-01-30 10:44:33 +00:00
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
return editorelement;
|
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
void
|
|
|
|
gst_editor_element_set_name (GstEditorElement *element,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
2000-10-01 21:46:33 +00:00
|
|
|
g_return_if_fail(GST_IS_EDITOR_ELEMENT(element));
|
|
|
|
g_return_if_fail(name != NULL);
|
|
|
|
|
|
|
|
gst_element_set_name(element->element, (gchar *)name);
|
|
|
|
gnome_canvas_item_set(element->title, "text", name, NULL);
|
|
|
|
gtk_signal_emit(GTK_OBJECT(element),gst_editor_element_signals[NAME_CHANGED], element);
|
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
const gchar*
|
|
|
|
gst_editor_element_get_name (GstEditorElement *element)
|
|
|
|
{
|
2000-10-01 21:46:33 +00:00
|
|
|
g_return_val_if_fail(GST_IS_EDITOR_ELEMENT(element), NULL);
|
|
|
|
|
|
|
|
return gst_element_get_name(element->element);
|
|
|
|
}
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
void
|
2000-12-25 01:33:06 +00:00
|
|
|
gst_editor_element_construct (GstEditorElement *element,
|
|
|
|
const gchar *first_arg_name,
|
|
|
|
va_list args)
|
2000-12-16 17:12:28 +00:00
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GtkObject *obj = GTK_OBJECT(element);
|
|
|
|
GSList *arg_list = NULL, *info_list = NULL;
|
|
|
|
gchar *error;
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("in gst_editor_element_construct()\n"); */
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
error = gtk_object_args_collect(GTK_OBJECT_TYPE(obj),&arg_list,
|
|
|
|
&info_list,first_arg_name,args);
|
|
|
|
if (error) {
|
|
|
|
g_warning("gst_editor_element_construct(): %s",error);
|
|
|
|
g_free(error);
|
|
|
|
} else {
|
|
|
|
GSList *arg,*info;
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("setting all the arguments on the element\n"); */
|
2000-01-30 10:44:33 +00:00
|
|
|
for (arg=arg_list,info=info_list;arg;arg=arg->next,info=info->next)
|
|
|
|
gtk_object_arg_set(obj,arg->data,info->data);
|
|
|
|
gtk_args_collect_cleanup(arg_list,info_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void
|
|
|
|
gst_editor_element_set_arg (GtkObject *object, GtkArg *arg, guint id)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GstEditorElement *element;
|
|
|
|
|
|
|
|
/* get the major types of this object */
|
|
|
|
element = GST_EDITOR_ELEMENT(object);
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
case ARG_X:
|
|
|
|
element->x = GTK_VALUE_DOUBLE(*arg);
|
|
|
|
break;
|
|
|
|
case ARG_Y:
|
|
|
|
element->y = GTK_VALUE_DOUBLE(*arg);
|
|
|
|
break;
|
|
|
|
case ARG_WIDTH:
|
|
|
|
element->width = GTK_VALUE_DOUBLE(*arg);
|
|
|
|
element->resize = TRUE;
|
|
|
|
break;
|
|
|
|
case ARG_HEIGHT:
|
|
|
|
element->height = GTK_VALUE_DOUBLE(*arg);
|
|
|
|
element->resize = TRUE;
|
|
|
|
break;
|
|
|
|
case ARG_X1:
|
|
|
|
element->x = GTK_VALUE_DOUBLE(*arg);
|
|
|
|
element->resize = TRUE;
|
|
|
|
break;
|
|
|
|
case ARG_Y1:
|
|
|
|
element->y = GTK_VALUE_DOUBLE(*arg);
|
|
|
|
element->resize = TRUE;
|
|
|
|
break;
|
|
|
|
case ARG_X2:
|
2001-12-14 21:34:56 +00:00
|
|
|
/* make sure it's big enough, grow if not */
|
2000-01-30 10:44:33 +00:00
|
|
|
element->width = MAX(GTK_VALUE_DOUBLE(*arg),element->minwidth);
|
|
|
|
element->resize = TRUE;
|
|
|
|
break;
|
|
|
|
case ARG_Y2:
|
2001-12-14 21:34:56 +00:00
|
|
|
/* make sure it's big enough, grow if not */
|
2000-01-30 10:44:33 +00:00
|
|
|
element->height = MAX(GTK_VALUE_DOUBLE(*arg),element->minheight);
|
|
|
|
element->resize = TRUE;
|
|
|
|
break;
|
2000-12-25 01:33:06 +00:00
|
|
|
case ARG_ACTIVE:
|
|
|
|
element->active = GTK_VALUE_BOOL(*arg);
|
|
|
|
gnome_canvas_item_set(GNOME_CANVAS_ITEM(element->border),
|
|
|
|
"width_units", (element->active ? 2.0 : 1.0), NULL);
|
|
|
|
break;
|
2000-01-30 10:44:33 +00:00
|
|
|
default:
|
|
|
|
g_warning("gsteditorelement: unknown arg!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void
|
|
|
|
gst_editor_element_get_arg(GtkObject *object, GtkArg *arg, guint id)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GstEditorElement *element;
|
|
|
|
|
|
|
|
/* get the major types of this object */
|
|
|
|
element = GST_EDITOR_ELEMENT(object);
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
case ARG_X:
|
|
|
|
GTK_VALUE_INT(*arg) = element->x + (element->width / 2.0);
|
|
|
|
break;
|
|
|
|
case ARG_Y:
|
|
|
|
GTK_VALUE_INT(*arg) = element->y + (element->height / 2.0);
|
|
|
|
break;
|
|
|
|
case ARG_WIDTH:
|
|
|
|
GTK_VALUE_INT(*arg) = element->width;
|
|
|
|
break;
|
|
|
|
case ARG_HEIGHT:
|
|
|
|
GTK_VALUE_INT(*arg) = element->height;
|
|
|
|
break;
|
|
|
|
case ARG_X1:
|
|
|
|
GTK_VALUE_INT(*arg) = element->x;
|
|
|
|
break;
|
|
|
|
case ARG_Y1:
|
|
|
|
GTK_VALUE_INT(*arg) = element->y;
|
|
|
|
break;
|
|
|
|
case ARG_X2:
|
|
|
|
GTK_VALUE_INT(*arg) = element->x + element->width;
|
|
|
|
break;
|
|
|
|
case ARG_Y2:
|
|
|
|
GTK_VALUE_INT(*arg) = element->y + element->height;
|
|
|
|
break;
|
|
|
|
case ARG_ELEMENT:
|
|
|
|
GTK_VALUE_POINTER(*arg) = element->element;
|
|
|
|
break;
|
2000-12-25 01:33:06 +00:00
|
|
|
case ARG_ACTIVE:
|
|
|
|
GTK_VALUE_BOOL(*arg) = element->active;
|
|
|
|
break;
|
2000-01-30 10:44:33 +00:00
|
|
|
default:
|
|
|
|
arg->type = GTK_TYPE_INVALID;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static GtkMenu*
|
|
|
|
gst_editor_element_get_popup_menu (GstEditorElement *element)
|
|
|
|
{
|
|
|
|
GtkMenu *menu;
|
|
|
|
|
|
|
|
menu = GTK_MENU (gtk_menu_new ());
|
|
|
|
gtk_menu_append (menu, gtk_menu_item_new_with_label ("cut"));
|
|
|
|
gtk_menu_append (menu, gtk_menu_item_new_with_label ("copy"));
|
|
|
|
gtk_menu_append (menu, gtk_menu_item_new_with_label ("paste"));
|
|
|
|
gtk_widget_show_all (GTK_WIDGET (menu));
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_editor_element_realize (GstEditorElement *element)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GnomeCanvasGroup *parentgroup;
|
|
|
|
gint i;
|
|
|
|
gdouble x1,y1,x2,y2;
|
|
|
|
GList *pads;
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("realizing editor element %p\n",element); */
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
/* we have to have a parent by this point */
|
|
|
|
g_return_if_fail(element->parent != NULL);
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* set the state signal of the actual element */
|
2000-12-28 02:51:07 +00:00
|
|
|
gtk_signal_connect_object (GTK_OBJECT(element->element),"state_change",
|
|
|
|
GTK_SIGNAL_FUNC(gst_editor_element_sync_state_wrapper),
|
|
|
|
GTK_OBJECT (element));
|
|
|
|
|
|
|
|
gtk_signal_connect_object (GTK_OBJECT(element->element),"new_pad",
|
|
|
|
GTK_SIGNAL_FUNC(gst_editor_element_add_pad_wrapper),
|
|
|
|
GTK_OBJECT (element));
|
|
|
|
|
|
|
|
gtk_signal_connect_object (GTK_OBJECT(element->parent),"position_changed",
|
|
|
|
GTK_SIGNAL_FUNC(gst_editor_element_position_changed),
|
|
|
|
GTK_OBJECT (element));
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* create the bounds if we haven't had them set */
|
|
|
|
/* g_print("centering element at %.2fx%.2f (%.2fx%.2f)\n", */
|
|
|
|
/* element->x,element->y,element->width,element->height); */
|
|
|
|
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
/* create the group holding all the stuff for this element */
|
|
|
|
parentgroup = GST_EDITOR_ELEMENT(element->parent)->group;
|
|
|
|
element->group = GNOME_CANVAS_GROUP(gnome_canvas_item_new(parentgroup,
|
|
|
|
gnome_canvas_group_get_type(),
|
|
|
|
"x",element->x - (element->width / 2.0),
|
|
|
|
"y",element->y - (element->height / 2.0),NULL));
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("origin of group is %.2fx%.2f\n", */
|
|
|
|
/* element->x - (element->width / 2.0), */
|
|
|
|
/* element->y - (element->height / 2.0)); */
|
2000-01-30 10:44:33 +00:00
|
|
|
g_return_if_fail(element->group != NULL);
|
|
|
|
GST_EDITOR_SET_OBJECT(element->group,element);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(element->group),"event",
|
|
|
|
GTK_SIGNAL_FUNC(gst_editor_element_group_event),element);
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* calculate the inter-group coords (x1,y1,x2,y2 are convenience vars) */
|
2000-01-30 10:44:33 +00:00
|
|
|
x1 = 0.0;y1 = 0.0;
|
|
|
|
x2 = element->width;y2 = element->height;
|
|
|
|
|
|
|
|
/* create bordering box */
|
|
|
|
element->border = gnome_canvas_item_new(element->group,
|
|
|
|
gnome_canvas_rect_get_type(),
|
2000-12-25 01:33:06 +00:00
|
|
|
"width_units",1.0,"fill_color","white","outline_color","black",
|
2000-01-30 10:44:33 +00:00
|
|
|
"x1",x1,"y1",y1,"x2",x2,"y2",y2,NULL);
|
|
|
|
g_return_if_fail(element->border != NULL);
|
|
|
|
GST_EDITOR_SET_OBJECT(element->border,element);
|
|
|
|
|
|
|
|
/* create resizing box */
|
|
|
|
element->resizebox = gnome_canvas_item_new(element->group,
|
|
|
|
gnome_canvas_rect_get_type(),
|
|
|
|
"width_units",1.0,"fill_color","white","outline_color","black",
|
|
|
|
"x1",x2-4.0,"y1",y2-4.0,"x2",x2,"y2",y2,NULL);
|
|
|
|
g_return_if_fail(element->resizebox != NULL);
|
|
|
|
GST_EDITOR_SET_OBJECT(element->resizebox,element);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(element->resizebox),"event",
|
|
|
|
GTK_SIGNAL_FUNC(gst_editor_element_resizebox_event),element);
|
|
|
|
|
|
|
|
/* create the title */
|
|
|
|
element->title = gnome_canvas_item_new(element->group,
|
|
|
|
gnome_canvas_text_get_type(),
|
2000-08-18 20:35:48 +00:00
|
|
|
"text",gst_element_get_name(GST_ELEMENT(element->element)),
|
2000-01-30 10:44:33 +00:00
|
|
|
"x",x1+1.0,"y",y1+1.0,"anchor",GTK_ANCHOR_NORTH_WEST,
|
|
|
|
"font_gdk",gtk_widget_get_default_style()->font,
|
|
|
|
NULL);
|
|
|
|
g_return_if_fail(element->title != NULL);
|
|
|
|
GST_EDITOR_SET_OBJECT(element->title,element);
|
|
|
|
|
|
|
|
/* create the state boxen */
|
|
|
|
for (i=0;i<4;i++) {
|
|
|
|
element->statebox[i] = gnome_canvas_item_new(element->group,
|
|
|
|
gnome_canvas_rect_get_type(),
|
|
|
|
"width_units",1.0,"fill_color","white","outline_color","black",
|
|
|
|
"x1",0.0,"y1",0.0,"x2",0.0,"y2",0.0,
|
|
|
|
NULL);
|
|
|
|
g_return_if_fail(element->statebox[i] != NULL);
|
2000-10-01 21:46:33 +00:00
|
|
|
|
2000-01-30 10:44:33 +00:00
|
|
|
GST_EDITOR_SET_OBJECT(element->statebox[i],element);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(element->statebox[i]),"event",
|
|
|
|
GTK_SIGNAL_FUNC(gst_editor_element_state_event),
|
|
|
|
GINT_TO_POINTER(i));
|
|
|
|
element->statetext[i] = gnome_canvas_item_new(element->group,
|
|
|
|
gnome_canvas_text_get_type(),
|
|
|
|
"text",_gst_editor_element_states[i],
|
|
|
|
"x",0.0,"y",0.0,"anchor",GTK_ANCHOR_NORTH_WEST,
|
|
|
|
"font","-*-*-*-*-*-*-6-*-*-*-*-*-*-*",
|
|
|
|
NULL);
|
|
|
|
g_return_if_fail(element->statetext[i] != NULL);
|
|
|
|
GST_EDITOR_SET_OBJECT(element->statetext[i],element);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(element->statetext[i]),"event",
|
|
|
|
GTK_SIGNAL_FUNC(gst_editor_element_state_event),
|
|
|
|
GINT_TO_POINTER(i));
|
|
|
|
}
|
2000-12-28 02:51:07 +00:00
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* get all the padtemplates */
|
2000-12-28 02:51:07 +00:00
|
|
|
pads = gst_element_get_padtemplate_list(element->element);
|
|
|
|
while (pads) {
|
|
|
|
GstPadTemplate *temp = (GstPadTemplate *) pads->data;
|
|
|
|
|
|
|
|
gst_editor_element_add_padtemplate (element,temp);
|
|
|
|
|
|
|
|
pads = g_list_next(pads);
|
|
|
|
}
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* get all the pads */
|
2000-01-30 10:44:33 +00:00
|
|
|
pads = gst_element_get_pad_list(element->element);
|
|
|
|
while (pads) {
|
2000-12-28 02:51:07 +00:00
|
|
|
GstPad *pad = GST_PAD(pads->data);
|
|
|
|
|
2000-01-30 10:44:33 +00:00
|
|
|
gst_editor_element_add_pad(element,pad);
|
2000-12-25 01:33:06 +00:00
|
|
|
|
2000-01-30 10:44:33 +00:00
|
|
|
pads = g_list_next(pads);
|
|
|
|
}
|
|
|
|
|
|
|
|
element->realized = TRUE;
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* force a resize */
|
2000-01-30 10:44:33 +00:00
|
|
|
element->resize = TRUE;
|
|
|
|
gst_editor_element_resize(element);
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* recenter things on the supposed center */
|
|
|
|
/* g_print("recentering element at %.2fx%.2f (%.2fx%.2f)\n", */
|
|
|
|
/* element->x,element->y,element->width,element->height); */
|
2000-01-30 10:44:33 +00:00
|
|
|
element->x -= (element->width / 2.0);
|
|
|
|
element->y -= (element->height / 2.0);
|
|
|
|
gnome_canvas_item_set(GNOME_CANVAS_ITEM(element->group),
|
|
|
|
"x",element->x,"y",element->y,NULL);
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("origin of group is %.2fx%.2f\n",element->x,element->y); */
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
gst_editor_element_repack(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void
|
|
|
|
gst_editor_element_resize (GstEditorElement *element)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
gdouble itemwidth,itemheight;
|
|
|
|
gdouble groupwidth,groupheight;
|
|
|
|
GList *pads;
|
|
|
|
GstEditorPad *editorpad;
|
2000-12-28 02:51:07 +00:00
|
|
|
GstEditorPadTemplate *editorpadtemplate;
|
2000-01-30 10:44:33 +00:00
|
|
|
gint i;
|
|
|
|
|
|
|
|
if (element->resize != TRUE) return;
|
|
|
|
element->resize = FALSE;
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("resizing element\n"); */
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
element->minwidth = element->insidewidth;
|
|
|
|
element->minheight = element->insideheight;
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* get the text size and add it into minsize */
|
2000-01-30 10:44:33 +00:00
|
|
|
g_return_if_fail(element->title != NULL);
|
|
|
|
itemwidth = gst_util_get_double_arg(GTK_OBJECT(element->title),
|
|
|
|
"text_width") + 2.0;
|
|
|
|
itemheight = gst_util_get_double_arg(GTK_OBJECT(element->title),
|
|
|
|
"text_height") + 2.0;
|
2000-10-01 21:46:33 +00:00
|
|
|
|
2000-01-30 10:44:33 +00:00
|
|
|
element->titlewidth = itemwidth;
|
|
|
|
element->titleheight = itemheight;
|
|
|
|
element->minwidth = MAX(element->minwidth,itemwidth);
|
|
|
|
element->minheight += itemheight;
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* now do the bottom bar */
|
|
|
|
/* find the biggest of the state chars */
|
2000-01-30 10:44:33 +00:00
|
|
|
element->statewidth = 0.0;element->stateheight = 0.0;
|
|
|
|
for (i=0;i<4;i++) {
|
|
|
|
g_return_if_fail(element->statetext[i] != NULL);
|
2000-10-01 21:46:33 +00:00
|
|
|
|
|
|
|
itemwidth = 16.0;
|
|
|
|
itemheight = 16.0;
|
|
|
|
|
2000-01-30 10:44:33 +00:00
|
|
|
element->statewidth = MAX(element->statewidth,itemwidth);
|
|
|
|
element->stateheight = MAX(element->stateheight,itemheight);
|
|
|
|
}
|
2001-12-14 21:34:56 +00:00
|
|
|
/* calculate the size of the primary group */
|
|
|
|
groupwidth = element->statewidth * 5; /* 4 states plus playstate */
|
2000-01-30 10:44:33 +00:00
|
|
|
groupheight = element->stateheight;
|
2001-12-14 21:34:56 +00:00
|
|
|
/* add in the resize box */
|
|
|
|
groupwidth += 7.0; /* 2.0 for buffer, 5.0 for actual size */
|
2000-01-30 10:44:33 +00:00
|
|
|
groupheight = MAX(groupheight,5.0);
|
2001-12-14 21:34:56 +00:00
|
|
|
/* update the minsize */
|
2000-01-30 10:44:33 +00:00
|
|
|
element->minwidth = MAX(element->minwidth,groupwidth);
|
|
|
|
element->minheight += groupheight;
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* now go and try to calculate necessary space for the pads */
|
2000-01-30 10:44:33 +00:00
|
|
|
element->sinkwidth = 10.0;element->sinkheight = 0.0;element->sinks = 0;
|
|
|
|
pads = element->sinkpads;
|
|
|
|
while (pads) {
|
|
|
|
editorpad = GST_EDITOR_PAD(pads->data);
|
|
|
|
element->sinkwidth = MAX(element->sinkwidth,editorpad->width);
|
|
|
|
element->sinkheight = MAX(element->sinkheight,editorpad->height);
|
|
|
|
element->sinks++;
|
|
|
|
pads = g_list_next(pads);
|
|
|
|
}
|
|
|
|
element->srcwidth = 10.0;element->srcheight = 0.0;element->srcs = 0;
|
|
|
|
pads = element->srcpads;
|
|
|
|
while (pads) {
|
|
|
|
editorpad = GST_EDITOR_PAD(pads->data);
|
|
|
|
element->srcwidth = MAX(element->srcwidth,editorpad->width);
|
|
|
|
element->srcheight = MAX(element->srcheight,editorpad->height);
|
|
|
|
element->srcs++;
|
|
|
|
pads = g_list_next(pads);
|
|
|
|
}
|
2000-12-28 02:51:07 +00:00
|
|
|
pads = element->sinkpadtemps;
|
|
|
|
while (pads) {
|
|
|
|
editorpadtemplate = GST_EDITOR_PADTEMPLATE(pads->data);
|
|
|
|
element->sinkwidth = MAX(element->sinkwidth,editorpadtemplate->width);
|
|
|
|
element->sinkheight = MAX(element->sinkheight,editorpadtemplate->height);
|
|
|
|
element->sinks++;
|
|
|
|
pads = g_list_next(pads);
|
|
|
|
}
|
|
|
|
pads = element->srcpadtemps;
|
|
|
|
while (pads) {
|
|
|
|
editorpadtemplate = GST_EDITOR_PADTEMPLATE(pads->data);
|
|
|
|
element->srcwidth = MAX(element->srcwidth,editorpadtemplate->width);
|
|
|
|
element->srcheight = MAX(element->srcheight,editorpadtemplate->height);
|
|
|
|
element->srcs++;
|
|
|
|
pads = g_list_next(pads);
|
|
|
|
}
|
2001-12-14 21:34:56 +00:00
|
|
|
/* add in the needed space */
|
2000-01-30 10:44:33 +00:00
|
|
|
element->minheight += MAX((element->sinkheight*element->sinks),
|
|
|
|
(element->srcheight*element->srcs)) + 4.0;
|
|
|
|
element->minwidth = MAX(element->minwidth,
|
2000-12-28 02:51:07 +00:00
|
|
|
((element->sinkwidth) +
|
|
|
|
(element->srcwidth) + 4.0));
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("have %d sinks (%.2fx%.2f) and %d srcs (%.2fx%.2f)\n", */
|
|
|
|
/* element->sinks,element->sinkwidth,element->sinkheight, */
|
|
|
|
/* element->srcs,element->srcwidth,element->srcheight); */
|
|
|
|
|
|
|
|
/* grow the element to hold all the stuff */
|
|
|
|
/* g_print("minsize is %.2fx%.2f, */
|
|
|
|
/*",element->minwidth,element->minheight); */
|
|
|
|
/* g_print("size was %.2fx%.2f, ",element->width,element->height); */
|
2000-01-30 10:44:33 +00:00
|
|
|
element->width = MAX(element->width,element->minwidth);
|
|
|
|
element->height = MAX(element->height,element->minheight);
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("is now %.2fx%.2f\n",element->width,element->height); */
|
2000-12-28 02:51:07 +00:00
|
|
|
|
|
|
|
gtk_signal_emit(GTK_OBJECT(element),gst_editor_element_signals[SIZE_CHANGED], element);
|
2000-01-30 10:44:33 +00:00
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
void
|
|
|
|
gst_editor_element_repack (GstEditorElement *element)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GList *pads;
|
|
|
|
GstEditorPad *editorpad;
|
2000-12-28 02:51:07 +00:00
|
|
|
GstEditorPadTemplate *editorpadtemplate;
|
2000-01-30 10:44:33 +00:00
|
|
|
gint sinks;
|
|
|
|
gint srcs;
|
|
|
|
gdouble x1,y1,x2,y2;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if (!element->realized) return;
|
|
|
|
|
|
|
|
gst_editor_element_resize(element);
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* still use x1,y1,x2,y2 so we can change around later */
|
2000-01-30 10:44:33 +00:00
|
|
|
x1 = 0.0;y1 = 0.0;
|
|
|
|
x2 = element->width;y2 = element->height;
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("repacking element at %.2fx%.2f + %.2fx%.2f\n", */
|
|
|
|
/* element->x,element->y,x2,y2); */
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* move the element group to match */
|
2000-01-30 10:44:33 +00:00
|
|
|
gnome_canvas_item_set(GNOME_CANVAS_ITEM(element->group),
|
|
|
|
"x",element->x,"y",element->y,NULL);
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* start by resizing the bordering box */
|
2000-01-30 10:44:33 +00:00
|
|
|
g_return_if_fail(element->border != NULL);
|
|
|
|
gtk_object_set(GTK_OBJECT(element->border),
|
|
|
|
"x1",x1,"y1",y1,"x2",x2,"y2",y2,NULL);
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* then move the text to the new top left */
|
2000-01-30 10:44:33 +00:00
|
|
|
g_return_if_fail(element->title != NULL);
|
|
|
|
gtk_object_set(GTK_OBJECT(element->title),
|
|
|
|
"x",x1+1.0,"y",y1+1.0,
|
|
|
|
"anchor",GTK_ANCHOR_NORTH_WEST,
|
|
|
|
NULL);
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* and move the resize box */
|
2000-01-30 10:44:33 +00:00
|
|
|
g_return_if_fail(element->resizebox != NULL);
|
|
|
|
gtk_object_set(GTK_OBJECT(element->resizebox),
|
|
|
|
"x1",x2-5.0,"y1",y2-5.0,"x2",x2,"y2",y2,NULL);
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* now place the state boxes */
|
2000-01-30 10:44:33 +00:00
|
|
|
for (i=0;i<4;i++) {
|
|
|
|
g_return_if_fail(element->statebox[i] != NULL);
|
|
|
|
gtk_object_set(GTK_OBJECT(element->statebox[i]),
|
|
|
|
"x1",x1+(element->statewidth*i),
|
|
|
|
"y1",y2-element->stateheight,
|
|
|
|
"x2",x1+(element->statewidth*(i+1)),"y2",y2,NULL);
|
2000-10-01 21:46:33 +00:00
|
|
|
g_return_if_fail(element->statetext[i] != NULL);
|
2000-01-30 10:44:33 +00:00
|
|
|
gtk_object_set(GTK_OBJECT(element->statetext[i]),
|
|
|
|
"x",x1+(element->statewidth*i)+2.0,
|
|
|
|
"y",y2-element->stateheight+1.0,
|
|
|
|
"anchor",GTK_ANCHOR_NORTH_WEST,NULL);
|
|
|
|
}
|
2000-10-01 21:46:33 +00:00
|
|
|
gst_editor_element_sync_state(element);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* now we try to place all the pads */
|
2000-01-30 10:44:33 +00:00
|
|
|
sinks = element->sinks;
|
|
|
|
pads = element->sinkpads;
|
|
|
|
while (pads) {
|
|
|
|
editorpad = GST_EDITOR_PAD(pads->data);
|
|
|
|
gtk_object_set(GTK_OBJECT(editorpad),
|
|
|
|
"x",x1,
|
|
|
|
"y",y2 - 2.0 - element->stateheight -
|
|
|
|
(element->sinkheight * sinks),
|
|
|
|
NULL);
|
|
|
|
gst_editor_pad_repack(editorpad);
|
|
|
|
sinks--;
|
|
|
|
pads = g_list_next(pads);
|
|
|
|
}
|
2000-12-28 02:51:07 +00:00
|
|
|
pads = element->sinkpadtemps;
|
|
|
|
while (pads) {
|
|
|
|
editorpadtemplate = GST_EDITOR_PADTEMPLATE(pads->data);
|
|
|
|
gtk_object_set(GTK_OBJECT(editorpadtemplate),
|
|
|
|
"x",x1,
|
|
|
|
"y",y2 - 2.0 - element->stateheight -
|
|
|
|
(element->sinkheight * sinks),
|
|
|
|
NULL);
|
|
|
|
gst_editor_padtemplate_repack(editorpadtemplate);
|
|
|
|
sinks--;
|
|
|
|
pads = g_list_next(pads);
|
|
|
|
}
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
srcs = element->srcs;
|
|
|
|
pads = element->srcpads;
|
|
|
|
while (pads) {
|
|
|
|
editorpad = GST_EDITOR_PAD(pads->data);
|
|
|
|
gtk_object_set(GTK_OBJECT(editorpad),
|
2000-12-28 02:51:07 +00:00
|
|
|
"x",x2 - editorpad->width,
|
2000-01-30 10:44:33 +00:00
|
|
|
"y",y2 - 2.0 - element->stateheight -
|
|
|
|
(element->srcheight * srcs),
|
|
|
|
NULL);
|
|
|
|
gst_editor_pad_repack(editorpad);
|
|
|
|
srcs--;
|
|
|
|
pads = g_list_next(pads);
|
|
|
|
}
|
2000-12-28 02:51:07 +00:00
|
|
|
pads = element->srcpadtemps;
|
|
|
|
while (pads) {
|
|
|
|
editorpadtemplate = GST_EDITOR_PADTEMPLATE(pads->data);
|
|
|
|
gtk_object_set(GTK_OBJECT(editorpadtemplate),
|
|
|
|
"x",x2 - editorpadtemplate->width,
|
|
|
|
"y",y2 - 2.0 - element->stateheight -
|
|
|
|
(element->srcheight * srcs),
|
|
|
|
NULL);
|
|
|
|
gst_editor_padtemplate_repack(editorpadtemplate);
|
|
|
|
srcs--;
|
|
|
|
pads = g_list_next(pads);
|
|
|
|
}
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2000-12-28 02:51:07 +00:00
|
|
|
gtk_signal_emit(GTK_OBJECT(element),gst_editor_element_signals[SIZE_CHANGED], element);
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("done resizing element\n"); */
|
2000-01-30 10:44:33 +00:00
|
|
|
}
|
|
|
|
|
2000-12-28 02:51:07 +00:00
|
|
|
static void
|
|
|
|
gst_editor_element_add_pad_wrapper (GstEditorElement *element,
|
|
|
|
GstPad *pad)
|
|
|
|
{
|
|
|
|
gdk_threads_enter ();
|
|
|
|
gst_editor_element_add_pad (element, pad);
|
|
|
|
element->resize = TRUE;
|
|
|
|
gst_editor_element_repack (element);
|
|
|
|
gdk_threads_leave ();
|
|
|
|
}
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2000-12-28 02:51:07 +00:00
|
|
|
static void
|
|
|
|
gst_editor_element_add_pad_func (GstEditorElement *element,
|
|
|
|
GstPad *pad)
|
2000-12-25 01:33:06 +00:00
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GstEditorPad *editorpad;
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
editorpad = gst_editor_pad_new (element, pad, NULL);
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* FIXME does this need to check for ghost/real? */
|
2001-01-19 09:37:32 +00:00
|
|
|
if (GST_PAD_DIRECTION(pad) == GST_PAD_SINK) {
|
2000-01-30 10:44:33 +00:00
|
|
|
element->sinkpads = g_list_prepend(element->sinkpads,editorpad);
|
|
|
|
element->sinks++;
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("added 'new' pad to sink list\n"); */
|
2001-01-19 09:37:32 +00:00
|
|
|
} else if (GST_PAD_DIRECTION(pad) == GST_PAD_SRC) {
|
2000-01-30 10:44:33 +00:00
|
|
|
element->srcpads = g_list_prepend(element->srcpads,editorpad);
|
|
|
|
element->srcs++;
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("added 'new' pad to src list\n"); */
|
2000-01-30 10:44:33 +00:00
|
|
|
} else
|
|
|
|
g_print("HUH?!? Don't know which direction this pad is...\n");
|
|
|
|
|
|
|
|
gst_editor_element_repack(element);
|
|
|
|
}
|
|
|
|
|
2000-12-28 02:51:07 +00:00
|
|
|
static void
|
|
|
|
gst_editor_element_add_pad (GstEditorElement *element,
|
|
|
|
GstPad *pad)
|
|
|
|
{
|
|
|
|
GstPadTemplate *temp;
|
|
|
|
|
|
|
|
temp = pad->padtemplate;
|
|
|
|
if (!temp) {
|
|
|
|
gst_editor_element_add_pad_func (element,pad);
|
|
|
|
}
|
|
|
|
else {
|
2001-12-14 21:34:56 +00:00
|
|
|
/* find the template */
|
2000-12-28 02:51:07 +00:00
|
|
|
GList *temppads;
|
|
|
|
|
|
|
|
temppads = element->sinkpadtemps;
|
|
|
|
while (temppads) {
|
|
|
|
GstEditorPadTemplate *editorpadtemp = (GstEditorPadTemplate *) temppads->data;
|
|
|
|
|
|
|
|
if (editorpadtemp->padtemplate == temp) {
|
|
|
|
gst_editor_padtemplate_add_pad (editorpadtemp, pad);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
temppads = g_list_next (temppads);
|
|
|
|
}
|
|
|
|
temppads = element->srcpadtemps;
|
|
|
|
while (temppads) {
|
|
|
|
GstEditorPadTemplate *editorpadtemp = (GstEditorPadTemplate *) temppads->data;
|
|
|
|
|
|
|
|
if (editorpadtemp->padtemplate == temp) {
|
|
|
|
gst_editor_padtemplate_add_pad (editorpadtemp, pad);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
temppads = g_list_next (temppads);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GstEditorPadTemplate*
|
|
|
|
gst_editor_element_add_padtemplate (GstEditorElement *element,
|
|
|
|
GstPadTemplate *pad)
|
|
|
|
{
|
|
|
|
GstEditorPadTemplate *editorpad;
|
|
|
|
|
|
|
|
g_print ("gsteditorelement: new padtemplate\n");
|
|
|
|
|
|
|
|
editorpad = gst_editor_padtemplate_new (element, pad, NULL);
|
|
|
|
|
|
|
|
if (pad->direction == GST_PAD_SINK) {
|
|
|
|
element->sinkpadtemps = g_list_prepend(element->sinkpadtemps,editorpad);
|
|
|
|
element->sinks++;
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("added 'new' pad to sink list\n"); */
|
2000-12-28 02:51:07 +00:00
|
|
|
} else if (pad->direction == GST_PAD_SRC) {
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("added 'new' pad to src list\n"); */
|
2000-12-28 02:51:07 +00:00
|
|
|
element->srcpadtemps = g_list_prepend(element->srcpadtemps,editorpad);
|
|
|
|
element->srcs++;
|
|
|
|
} else
|
|
|
|
g_print("HUH?!? Don't know which direction this pad is...\n");
|
|
|
|
|
|
|
|
gst_editor_element_repack(element);
|
|
|
|
return editorpad;
|
|
|
|
}
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static gint
|
|
|
|
gst_editor_element_group_event (GnomeCanvasItem *item,
|
|
|
|
GdkEvent *event,
|
|
|
|
GstEditorElement *element)
|
|
|
|
{
|
2000-10-01 21:46:33 +00:00
|
|
|
switch(event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
gst_editor_property_show(gst_editor_property_get(), element);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-01-30 10:44:33 +00:00
|
|
|
if (GST_EDITOR_ELEMENT_CLASS(GTK_OBJECT(element)->klass)->event)
|
|
|
|
return (GST_EDITOR_ELEMENT_CLASS(GTK_OBJECT(element)->klass)->event)(
|
|
|
|
item,event,element);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static gint
|
|
|
|
gst_editor_element_event(GnomeCanvasItem *item,
|
|
|
|
GdkEvent *event,
|
|
|
|
GstEditorElement *element)
|
|
|
|
{
|
2000-10-01 21:46:33 +00:00
|
|
|
gdouble dx,dy;
|
2000-01-30 10:44:33 +00:00
|
|
|
GdkCursor *fleur;
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("element in event, type %d\n",event->type); */
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
switch(event->type) {
|
|
|
|
case GDK_ENTER_NOTIFY:
|
2000-12-25 01:33:06 +00:00
|
|
|
return TRUE;
|
2000-01-30 10:44:33 +00:00
|
|
|
case GDK_LEAVE_NOTIFY:
|
2000-12-25 01:33:06 +00:00
|
|
|
return TRUE;
|
2000-01-30 10:44:33 +00:00
|
|
|
case GDK_BUTTON_PRESS:
|
2000-12-25 01:33:06 +00:00
|
|
|
{
|
|
|
|
if (event->button.button == 3) {
|
|
|
|
GtkMenu *menu;
|
|
|
|
|
|
|
|
menu = gst_editor_element_get_popup_menu (element);
|
|
|
|
|
|
|
|
gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
|
|
|
|
event->button.button, event->button.time);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else {
|
2001-12-14 21:34:56 +00:00
|
|
|
/* dragxy coords are world coords of button press */
|
2000-12-25 01:33:06 +00:00
|
|
|
element->dragx = event->button.x;
|
|
|
|
element->dragy = event->button.y;
|
2001-12-14 21:34:56 +00:00
|
|
|
/* set some flags */
|
2000-12-25 01:33:06 +00:00
|
|
|
element->dragging = TRUE;
|
|
|
|
element->moved = FALSE;
|
|
|
|
fleur = gdk_cursor_new (GDK_FLEUR);
|
|
|
|
gnome_canvas_item_grab(item,
|
2000-01-30 10:44:33 +00:00
|
|
|
GDK_POINTER_MOTION_MASK |
|
2001-12-14 21:34:56 +00:00
|
|
|
/* GDK_ENTER_NOTIFY_MASK | */
|
|
|
|
/* GDK_LEAVE_NOTIFY_MASK | */
|
2000-01-30 10:44:33 +00:00
|
|
|
GDK_BUTTON_RELEASE_MASK,
|
|
|
|
fleur,event->button.time);
|
2000-12-25 01:33:06 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
2000-01-30 10:44:33 +00:00
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
if (element->dragging) {
|
|
|
|
dx = event->button.x - element->dragx;
|
|
|
|
dy = event->button.y - element->dragy;
|
|
|
|
gst_editor_element_move(element,dx,dy);
|
|
|
|
element->dragx = event->button.x;
|
|
|
|
element->dragy = event->button.y;
|
|
|
|
element->moved = TRUE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
if (element->dragging) {
|
|
|
|
element->dragging = FALSE;
|
|
|
|
gnome_canvas_item_ungrab(item,event->button.time);
|
|
|
|
}
|
|
|
|
if (!element->moved) {
|
|
|
|
GstEditorElementClass *elementclass;
|
|
|
|
elementclass = GST_EDITOR_ELEMENT_CLASS(GTK_OBJECT(element)->klass);
|
|
|
|
if (elementclass->button_event)
|
|
|
|
(elementclass->button_event)(item,event,element);
|
|
|
|
}
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("in element group_event, setting inchild"); */
|
|
|
|
/* element->canvas->inchild = TRUE; */
|
2000-01-30 10:44:33 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static gint
|
|
|
|
gst_editor_element_resizebox_event (GnomeCanvasItem *item,
|
|
|
|
GdkEvent *event,
|
|
|
|
GstEditorElement *element)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GdkCursor *bottomright;
|
|
|
|
gdouble item_x,item_y;
|
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("in resizebox_event...\n"); */
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2001-12-14 21:34:56 +00:00
|
|
|
/* calculate coords relative to the group, not the box */
|
2000-01-30 10:44:33 +00:00
|
|
|
item_x = event->button.x;
|
|
|
|
item_y = event->button.y;
|
|
|
|
gnome_canvas_item_w2i(item->parent,&item_x,&item_y);
|
|
|
|
|
|
|
|
switch(event->type) {
|
|
|
|
case GDK_ENTER_NOTIFY:
|
2000-12-25 01:33:06 +00:00
|
|
|
gnome_canvas_item_set(GNOME_CANVAS_ITEM(element->resizebox),
|
|
|
|
"fill_color", "red" , NULL);
|
|
|
|
return TRUE;
|
2000-01-30 10:44:33 +00:00
|
|
|
break;
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
2000-12-25 01:33:06 +00:00
|
|
|
gnome_canvas_item_set(GNOME_CANVAS_ITEM(element->resizebox),
|
|
|
|
"fill_color", "white" , NULL);
|
2000-01-30 10:44:33 +00:00
|
|
|
element->hesitating = FALSE;
|
2000-12-25 01:33:06 +00:00
|
|
|
return TRUE;
|
2000-01-30 10:44:33 +00:00
|
|
|
break;
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
element->dragx = event->button.x;
|
|
|
|
element->dragy = event->button.y;
|
|
|
|
element->resizing = TRUE;
|
|
|
|
element->hesitating = TRUE;
|
|
|
|
bottomright = gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER);
|
|
|
|
gnome_canvas_item_grab(item,
|
|
|
|
GDK_POINTER_MOTION_MASK |
|
|
|
|
GDK_ENTER_NOTIFY_MASK |
|
|
|
|
GDK_LEAVE_NOTIFY_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK,
|
|
|
|
bottomright,event->button.time);
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
if (element->resizing) {
|
2001-12-14 21:34:56 +00:00
|
|
|
/* doing a set because the code is in the arg set code */
|
|
|
|
/* g_print("resizing to x2,y2 of %.2f,%.2f\n",item_x,item_y); */
|
2000-01-30 10:44:33 +00:00
|
|
|
gtk_object_set(GTK_OBJECT(element),"x2",item_x,"y2",item_y,NULL);
|
|
|
|
element->resize = TRUE;
|
|
|
|
gst_editor_element_repack(element);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
if (element->resizing) {
|
|
|
|
element->resizing = FALSE;
|
|
|
|
gnome_canvas_item_ungrab(item,event->button.time);
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("in element resizebox_event, setting inchild"); */
|
|
|
|
/* element->canvas->inchild = TRUE; */
|
2000-01-30 10:44:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static gint
|
|
|
|
gst_editor_element_state_event(GnomeCanvasItem *item,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GstEditorElement *element;
|
|
|
|
gint id = GPOINTER_TO_INT(data);
|
|
|
|
GdkCursor *uparrow;
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
element = GST_EDITOR_GET_OBJECT(item);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
switch (event->type) {
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
uparrow = gdk_cursor_new(GDK_SB_UP_ARROW);
|
|
|
|
gnome_canvas_item_grab(item,
|
|
|
|
GDK_POINTER_MOTION_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK |
|
|
|
|
GDK_LEAVE_NOTIFY_MASK,
|
|
|
|
uparrow,event->button.time);
|
|
|
|
/* NOTE: when grabbing canvas item, always get pointer_motion,
|
|
|
|
this will allow you to actually get all the other synth events */
|
|
|
|
break;
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
gnome_canvas_item_ungrab(item,event->button.time);
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_PRESS:
|
2000-12-25 01:33:06 +00:00
|
|
|
{
|
|
|
|
GdkEventButton *buttonevent = (GdkEventButton *)event;
|
|
|
|
|
|
|
|
if (buttonevent->button == 1)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-01-30 10:44:33 +00:00
|
|
|
case GDK_BUTTON_RELEASE:
|
2000-12-25 01:33:06 +00:00
|
|
|
{
|
|
|
|
GdkEventButton *buttonevent = (GdkEventButton *)event;
|
|
|
|
|
|
|
|
if (buttonevent->button != 1)
|
|
|
|
return FALSE;
|
|
|
|
|
2000-10-01 21:46:33 +00:00
|
|
|
if (id < 4) {
|
2000-12-28 02:51:07 +00:00
|
|
|
gdk_threads_leave ();
|
2000-01-30 10:44:33 +00:00
|
|
|
gst_editor_element_set_state(element,id,TRUE);
|
2000-12-28 02:51:07 +00:00
|
|
|
gdk_threads_enter ();
|
2000-01-30 10:44:33 +00:00
|
|
|
} else
|
|
|
|
g_warning("Uh, shouldn't have gotten here, unknown state\n");
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("in element statebox_event, setting inchild"); */
|
|
|
|
/* element->canvas->inchild = TRUE; */
|
2000-01-30 10:44:33 +00:00
|
|
|
return TRUE;
|
2000-12-25 01:33:06 +00:00
|
|
|
}
|
2000-01-30 10:44:33 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void
|
|
|
|
gst_editor_element_set_state(GstEditorElement *element,
|
|
|
|
gint id,gboolean set)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
gboolean stateset = TRUE; /* if we have no element, set anyway */
|
2001-12-14 21:34:56 +00:00
|
|
|
/* g_print("element set state %d\n", id); */
|
2000-10-01 21:46:33 +00:00
|
|
|
if (element->element)
|
|
|
|
stateset = gst_element_set_state(element->element,_gst_element_states[id]);
|
2000-01-30 10:44:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void
|
2000-12-28 02:51:07 +00:00
|
|
|
gst_editor_element_sync_state_wrapper (GstEditorElement *element)
|
2000-12-25 01:33:06 +00:00
|
|
|
{
|
2000-12-28 02:51:07 +00:00
|
|
|
gdk_threads_enter ();
|
|
|
|
gst_editor_element_sync_state (element);
|
|
|
|
gdk_threads_leave ();
|
2000-01-30 10:44:33 +00:00
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void
|
|
|
|
gst_editor_element_sync_state (GstEditorElement *element)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
gint id;
|
2000-10-01 21:46:33 +00:00
|
|
|
GstElementState state = GST_STATE(element->element);
|
|
|
|
|
|
|
|
for (id=0;id<4;id++) {
|
|
|
|
if (_gst_element_states[id] == state) {
|
|
|
|
gtk_object_set(GTK_OBJECT(element->statebox[id]),
|
|
|
|
"fill_color","black",NULL);
|
|
|
|
gtk_object_set(GTK_OBJECT(element->statetext[id]),
|
|
|
|
"fill_color","white",NULL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gtk_object_set(GTK_OBJECT(element->statebox[id]),
|
|
|
|
"fill_color","white",NULL);
|
|
|
|
gtk_object_set(GTK_OBJECT(element->statetext[id]),
|
|
|
|
"fill_color","black",NULL);
|
|
|
|
}
|
2000-01-30 10:44:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-28 02:51:07 +00:00
|
|
|
static void
|
|
|
|
gst_editor_element_position_changed (GstEditorElement *element,
|
|
|
|
GstEditorElement *parent)
|
|
|
|
{
|
|
|
|
if (element != parent)
|
|
|
|
gtk_signal_emit(GTK_OBJECT(element),gst_editor_element_signals[POSITION_CHANGED], element);
|
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void
|
|
|
|
gst_editor_element_move(GstEditorElement *element,
|
|
|
|
gdouble dx,gdouble dy)
|
|
|
|
{
|
2001-12-14 21:34:56 +00:00
|
|
|
/* this is a 'little' trick to keep from repacking the whole thing... */
|
2000-01-30 10:44:33 +00:00
|
|
|
element->x += dx;element->y += dy;
|
|
|
|
gnome_canvas_item_move(GNOME_CANVAS_ITEM(element->group),dx,dy);
|
|
|
|
|
2000-12-28 02:51:07 +00:00
|
|
|
gtk_signal_emit(GTK_OBJECT(element),gst_editor_element_signals[POSITION_CHANGED], element);
|
2000-01-30 10:44:33 +00:00
|
|
|
}
|