From: Julien M. <do...@us...> - 2003-02-03 14:09:37
|
CVS Root: /cvsroot/gstreamer Module: gst-player Changes by: dolphy Date: Mon Feb 03 2003 06:09:35 PST Log message: Xinerama aware stuff 0.1 alpha :). Modified files: libs/gst/player : gstmediaplay.c gstvideowidget.c gstvideowidget.h Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstmediaplay.c.diff?r1=1.93&r2=1.94 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstvideowidget.c.diff?r1=1.14&r2=1.15 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstvideowidget.h.diff?r1=1.8&r2=1.9 ====Begin Diffs==== Index: gstmediaplay.c =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstmediaplay.c,v retrieving revision 1.93 retrieving revision 1.94 diff -u -d -r1.93 -r1.94 --- gstmediaplay.c 2 Feb 2003 15:46:41 -0000 1.93 +++ gstmediaplay.c 3 Feb 2003 14:09:22 -0000 1.94 @@ -889,12 +889,13 @@ gst_play_need_new_video_window ( mplay->play); /* get a short filename if we can */ - if (GNOME_VFS_OK != gnome_vfs_get_file_info(location, &info, GNOME_VFS_FILE_INFO_DEFAULT)){ + if (GNOME_VFS_OK != gnome_vfs_get_file_info( location, + &info, + GNOME_VFS_FILE_INFO_DEFAULT) + ) mplay->location_short = location; - } - else { + else mplay->location_short = info.name; - } g_signal_emit ( mplay, gst_media_play_signals [CURRENT_LOCATION], @@ -999,13 +1000,37 @@ TRUE); break; case GDK_Up: + /* gst_media_play_set_volume (mplay, - gst_media_play_get_volume (mplay) + 0.1); + gst_media_play_get_volume (mplay) + 0.1); */ + gst_video_widget_set_y_align ( + GST_VIDEO_WIDGET(mplay->video_widget), + gst_video_widget_get_y_align ( + GST_VIDEO_WIDGET(mplay->video_widget)) - 0.1); handled = TRUE; break; case GDK_Down: + /* gst_media_play_set_volume (mplay, - gst_media_play_get_volume (mplay) - 0.1); + gst_media_play_get_volume (mplay) - 0.1); */ + gst_video_widget_set_y_align ( + GST_VIDEO_WIDGET(mplay->video_widget), + gst_video_widget_get_y_align ( + GST_VIDEO_WIDGET(mplay->video_widget)) + 0.1); + handled = TRUE; + break; + case GDK_Left: + gst_video_widget_set_x_align ( + GST_VIDEO_WIDGET(mplay->video_widget), + gst_video_widget_get_x_align ( + GST_VIDEO_WIDGET(mplay->video_widget)) - 0.1); + handled = TRUE; + break; + case GDK_Right: + gst_video_widget_set_x_align ( + GST_VIDEO_WIDGET(mplay->video_widget), + gst_video_widget_get_x_align ( + GST_VIDEO_WIDGET(mplay->video_widget)) + 0.1); handled = TRUE; break; case GDK_space: Index: gstvideowidget.c =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstvideowidget.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- gstvideowidget.c 2 Feb 2003 12:05:14 -0000 1.14 +++ gstvideowidget.c 3 Feb 2003 14:09:22 -0000 1.15 @@ -54,6 +54,8 @@ enum { ARG_0, ARG_SCALE_FACTOR, + ARG_X_ALIGN, + ARG_Y_ALIGN, ARG_VISIBLE_CURSOR, ARG_LOGO_FOCUSED, ARG_EVENT_CATCHER, @@ -112,6 +114,24 @@ "scale factor", "size the video should be scaled to", 0, G_MAXFLOAT / G_MAXINT, 1, G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, + ARG_X_ALIGN, + g_param_spec_float ( + "x_align", + "x alignment", + "x alignment factor", + 0, G_MAXFLOAT / G_MAXINT, 1, G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, + ARG_Y_ALIGN, + g_param_spec_float ( + "y_align", + "y alignment", + "y alignment factor", + 0, G_MAXFLOAT / G_MAXINT, 1, G_PARAM_READWRITE)); g_object_class_install_property ( gobject_class, @@ -194,6 +214,8 @@ vw->source_width = 0; vw->source_height = 0; + vw->x_align = 0.5; + vw->y_align = 0.5; vw->scale_factor = 1.0; vw->scale_override = FALSE; vw->cursor_visible = TRUE; @@ -361,8 +383,15 @@ else width_ratio = height_ratio = 1.0; - logo_x = (alloc_width / 2) - ( width * width_ratio / 2); - logo_y = (alloc_height / 2) - ( height * height_ratio / 2); + logo_x = vw->x_align * ( alloc_width - (width * width_ratio)); + logo_y = vw->y_align * ( alloc_height - (height * height_ratio)); + + if (logo_x < 0) logo_x = 0; + if (logo_y < 0) logo_y = 0; + if (logo_x > ( alloc_width - (width * width_ratio) ) ) + logo_x = alloc_width - (width * width_ratio); + if (logo_y > ( alloc_height - (height * height_ratio) ) ) + logo_y = alloc_height - (height * height_ratio); /* Scaling to available space */ @@ -508,14 +537,27 @@ 0, allocation->width, allocation->height); - - if (GDK_IS_WINDOW(vw->video_window)) + + if (GDK_IS_WINDOW(vw->video_window)) { + gint video_x, video_y; + + video_x = vw->x_align * ( allocation->width - width); + video_y = vw->y_align * ( allocation->height - height); + + if (video_x < 0) video_x = 0; + if (video_y < 0) video_y = 0; + if (video_x > ( allocation->width - width)) + video_x = allocation->width - width; + if (video_y > ( allocation->height - height)) + video_y = allocation->height - height; + gdk_window_move_resize ( vw->video_window, - (allocation->width - width) / 2, - (allocation->height - height) / 2, + video_x, + video_y, width, height); + } } } @@ -569,6 +611,7 @@ gdk_threads_leave (); } + /** * gst_video_widget_get_xembed_xid: * @vw: a #GstVideoWidget @@ -822,6 +865,88 @@ return vw->scale_factor; } +/** + * gst_video_widget_set_x_align: + * @vw: a #GstVideoWidget + * @x_align: a #gfloat indicating x alignment that will be used by @vw. + * + * Set a x alignment value for a #GstVideoWidget. + * + * Remember you can set this flag trough the "x_align" property. + * + * Return value: a #gboolean indicating wether the call succeeded or not. + **/ +gboolean +gst_video_widget_set_x_align (GstVideoWidget *vw, gfloat x_align) +{ + g_return_val_if_fail(vw != NULL, FALSE); + g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE); + if (x_align > 1) x_align = 1; + if (x_align < 0) x_align = 0; + vw->x_align = x_align; + gtk_widget_queue_resize (GTK_WIDGET(vw)); + return TRUE; +} + +/** + * gst_video_widget_get_x_align: + * @vw: a #GstVideoWidget + * + * Get used x alignment for a #GstVideoWidget. + * + * Remember you can get this value trough "x_align" property. + * + * Return value: a #gfloat indicating used x alignment. + **/ +gfloat +gst_video_widget_get_x_align (GstVideoWidget *vw) +{ + g_return_val_if_fail(vw != NULL, FALSE); + g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE); + return vw->x_align; +} + +/** + * gst_video_widget_set_y_align: + * @vw: a #GstVideoWidget + * @y_align: a #gfloat indicating y alignment that will be used by @vw. + * + * Set a y alignment value for a #GstVideoWidget. + * + * Remember you can set this flag trough the "y_align" property. + * + * Return value: a #gboolean indicating wether the call succeeded or not. + **/ +gboolean +gst_video_widget_set_y_align (GstVideoWidget *vw, gfloat y_align) +{ + g_return_val_if_fail(vw != NULL, FALSE); + g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE); + if (y_align > 1) y_align = 1; + if (y_align < 0) y_align = 0; + vw->y_align = y_align; + gtk_widget_queue_resize (GTK_WIDGET(vw)); + return TRUE; +} + +/** + * gst_video_widget_get_y_align: + * @vw: a #GstVideoWidget + * + * Get used y alignment for a #GstVideoWidget. + * + * Remember you can get this value trough "y_align" property. + * + * Return value: a #gfloat indicating used y alignment. + **/ +gfloat +gst_video_widget_get_y_align (GstVideoWidget *vw) +{ + g_return_val_if_fail(vw != NULL, FALSE); + g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE); + return vw->y_align; +} + /** * gst_video_widget_set_logo: * @vw: a #GstVideoWidget. @@ -879,6 +1004,14 @@ vw->scale_override = TRUE; gtk_widget_queue_resize (GTK_WIDGET(vw)); break; + case ARG_X_ALIGN: + vw->x_align = g_value_get_float (value); + gtk_widget_queue_resize (GTK_WIDGET(vw)); + break; + case ARG_Y_ALIGN: + vw->y_align = g_value_get_float (value); + gtk_widget_queue_resize (GTK_WIDGET(vw)); + break; case ARG_VISIBLE_CURSOR: vw->cursor_visible = g_value_get_boolean (value); gst_video_widget_update_cursor (vw); @@ -929,6 +1062,12 @@ switch (prop_id) { case ARG_SCALE_FACTOR: g_value_set_float (value, vw->scale_factor); + break; + case ARG_X_ALIGN: + g_value_set_float (value, vw->x_align); + break; + case ARG_Y_ALIGN: + g_value_set_float (value, vw->y_align); break; case ARG_VISIBLE_CURSOR: g_value_set_boolean (value, vw->cursor_visible); Index: gstvideowidget.h =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstvideowidget.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- gstvideowidget.h 29 Jan 2003 14:49:41 -0000 1.8 +++ gstvideowidget.h 3 Feb 2003 14:09:22 -0000 1.9 @@ -54,6 +54,9 @@ gint source_width; gint source_height; + gfloat x_align; + gfloat y_align; + gboolean cursor_visible; gboolean event_catcher; gboolean logo_focused; @@ -103,6 +106,13 @@ gboolean gst_video_widget_set_scale (GstVideoWidget *vw, gfloat scale); gfloat gst_video_widget_get_scale (GstVideoWidget *vw); + +/* Set/Get x,y alignment used by the widget */ + +gboolean gst_video_widget_set_x_align (GstVideoWidget *vw, gfloat x_align); +gfloat gst_video_widget_get_x_align (GstVideoWidget *vw); +gboolean gst_video_widget_set_y_align (GstVideoWidget *vw, gfloat y_align); +gfloat gst_video_widget_get_y_align (GstVideoWidget *vw); /* Set/Get the XID of the Xwindow to be embedded */ |