aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-08-09 00:54:50 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-08-15 19:14:54 +0800
commit6526ece345726300c7ab0c2b3c46c4bd2795a6ed (patch)
treedcb9adbca0f1a416ebd483e22f469ba08f38e1b1 /src
parente5658d67a38612c727091d7e91f9477333047870 (diff)
downloadgsoc2013-empathy-6526ece345726300c7ab0c2b3c46c4bd2795a6ed.tar
gsoc2013-empathy-6526ece345726300c7ab0c2b3c46c4bd2795a6ed.tar.gz
gsoc2013-empathy-6526ece345726300c7ab0c2b3c46c4bd2795a6ed.tar.bz2
gsoc2013-empathy-6526ece345726300c7ab0c2b3c46c4bd2795a6ed.tar.lz
gsoc2013-empathy-6526ece345726300c7ab0c2b3c46c4bd2795a6ed.tar.xz
gsoc2013-empathy-6526ece345726300c7ab0c2b3c46c4bd2795a6ed.tar.zst
gsoc2013-empathy-6526ece345726300c7ab0c2b3c46c4bd2795a6ed.zip
CallWindow: allow to move the video preview
https://bugzilla.gnome.org/show_bug.cgi?id=656268
Diffstat (limited to 'src')
-rw-r--r--src/empathy-call-window.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index a734b5b5a..e57858797 100644
--- a/src/empathy-call-window.c
+++ b/src/empathy-call-window.c
@@ -79,6 +79,8 @@
#define FLOATING_TOOLBAR_HEIGHT 36
#define FLOATING_TOOLBAR_SPACING 20
+#define SELF_VIDEO_MARGIN 10
+
/* The avatar's default width and height are set to the same value because we
want a square icon. */
#define REMOTE_CONTACT_AVATAR_DEFAULT_WIDTH EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT
@@ -112,6 +114,14 @@ typedef enum {
CAMERA_STATE_ON,
} CameraState;
+typedef enum {
+ PREVIEW_POS_NONE,
+ PREVIEW_POS_TOP_LEFT,
+ PREVIEW_POS_TOP_RIGHT,
+ PREVIEW_POS_BOTTOM_LEFT,
+ PREVIEW_POS_BOTTOM_RIGHT,
+} PreviewPosition;
+
struct _EmpathyCallWindowPriv
{
gboolean dispose_has_run;
@@ -523,6 +533,91 @@ empathy_call_window_preview_hidden_button_clicked_cb (GtkButton *button,
}
static void
+empathy_call_window_move_video_preview (EmpathyCallWindow *self,
+ PreviewPosition pos)
+{
+ ClutterBinLayout *layout = CLUTTER_BIN_LAYOUT (self->priv->video_layout);
+
+ DEBUG ("moving the video preview to %d", pos);
+
+ switch (pos)
+ {
+ case PREVIEW_POS_TOP_LEFT:
+ clutter_bin_layout_set_alignment (layout,
+ self->priv->video_preview,
+ CLUTTER_BIN_ALIGNMENT_START,
+ CLUTTER_BIN_ALIGNMENT_START);
+ break;
+ case PREVIEW_POS_TOP_RIGHT:
+ clutter_bin_layout_set_alignment (layout,
+ self->priv->video_preview,
+ CLUTTER_BIN_ALIGNMENT_END,
+ CLUTTER_BIN_ALIGNMENT_START);
+ break;
+ case PREVIEW_POS_BOTTOM_LEFT:
+ clutter_bin_layout_set_alignment (layout,
+ self->priv->video_preview,
+ CLUTTER_BIN_ALIGNMENT_START,
+ CLUTTER_BIN_ALIGNMENT_END);
+ break;
+ case PREVIEW_POS_BOTTOM_RIGHT:
+ clutter_bin_layout_set_alignment (layout,
+ self->priv->video_preview,
+ CLUTTER_BIN_ALIGNMENT_END,
+ CLUTTER_BIN_ALIGNMENT_END);
+ break;
+ default:
+ g_warn_if_reached ();
+ }
+}
+
+static void
+empathy_call_window_preview_on_drag_end_cb (ClutterDragAction *action,
+ ClutterActor *actor,
+ gfloat event_x,
+ gfloat event_y,
+ ClutterModifierType modifiers,
+ EmpathyCallWindow *self)
+{
+ ClutterGeometry box;
+ PreviewPosition pos = PREVIEW_POS_NONE;
+
+ clutter_actor_get_geometry (self->priv->video_box, &box);
+
+ if (0 + SELF_VIDEO_MARGIN <= event_x &&
+ event_x <= (0 + SELF_VIDEO_MARGIN + (gint) SELF_VIDEO_SECTION_WIDTH) &&
+ 0 + SELF_VIDEO_MARGIN <= event_y &&
+ event_y <= (0 + SELF_VIDEO_MARGIN + (gint) SELF_VIDEO_SECTION_HEIGTH))
+ {
+ pos = PREVIEW_POS_TOP_LEFT;
+ }
+ else if (box.width - SELF_VIDEO_MARGIN >= event_x &&
+ event_x >= (box.width - SELF_VIDEO_MARGIN - (gint) SELF_VIDEO_SECTION_WIDTH) &&
+ 0 + SELF_VIDEO_MARGIN <= event_y &&
+ event_y <= (0 + SELF_VIDEO_MARGIN + (gint) SELF_VIDEO_SECTION_HEIGTH))
+ {
+ pos = PREVIEW_POS_TOP_RIGHT;
+ }
+ else if (0 + SELF_VIDEO_MARGIN <= event_x &&
+ event_x <= (0 + SELF_VIDEO_MARGIN + (gint) SELF_VIDEO_SECTION_WIDTH) &&
+ box.height - SELF_VIDEO_MARGIN >= event_y &&
+ event_y >= (box.height - SELF_VIDEO_MARGIN - (gint) SELF_VIDEO_SECTION_HEIGTH))
+ {
+ pos = PREVIEW_POS_BOTTOM_LEFT;
+ }
+ else if (box.width - SELF_VIDEO_MARGIN >= event_x &&
+ event_x >= (box.width - SELF_VIDEO_MARGIN - (gint) SELF_VIDEO_SECTION_WIDTH) &&
+ box.height - SELF_VIDEO_MARGIN >= event_y &&
+ event_y >= (box.height - SELF_VIDEO_MARGIN - (gint) SELF_VIDEO_SECTION_HEIGTH))
+ {
+ pos = PREVIEW_POS_BOTTOM_RIGHT;
+ }
+
+ if (pos != PREVIEW_POS_NONE)
+ empathy_call_window_move_video_preview (self, pos);
+}
+
+static void
create_video_preview (EmpathyCallWindow *self)
{
EmpathyCallWindowPriv *priv = GET_PRIV (self);
@@ -530,6 +625,7 @@ create_video_preview (EmpathyCallWindow *self)
ClutterActor *preview;
ClutterActor *box;
ClutterActor *b;
+ ClutterAction *action;
GtkWidget *button;
g_assert (priv->video_preview == NULL);
@@ -606,6 +702,13 @@ create_video_preview (EmpathyCallWindow *self)
priv->video_preview,
CLUTTER_BIN_ALIGNMENT_START,
CLUTTER_BIN_ALIGNMENT_END);
+
+ action = clutter_drag_action_new ();
+ g_signal_connect (action, "drag-end",
+ G_CALLBACK (empathy_call_window_preview_on_drag_end_cb), self);
+
+ clutter_actor_add_action (preview, action);
+ clutter_actor_set_reactive (preview, TRUE);
}
static void