diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-call-window.c | 35 | ||||
-rw-r--r-- | src/empathy-rounded-actor.c | 11 | ||||
-rw-r--r-- | src/empathy-rounded-actor.h | 5 | ||||
-rw-r--r-- | src/empathy-rounded-rectangle.c | 29 | ||||
-rw-r--r-- | src/empathy-rounded-rectangle.h | 5 |
5 files changed, 44 insertions, 41 deletions
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c index 8eaf2cc33..ada107c3c 100644 --- a/src/empathy-call-window.c +++ b/src/empathy-call-window.c @@ -79,7 +79,8 @@ #define SELF_VIDEO_SECTION_WIDTH 120 #define SELF_VIDEO_SECTION_HEIGHT 90 -#define SELF_VIDEO_SECTION_MARGIN 10 +#define SELF_VIDEO_SECTION_MARGIN 2 +#define SELF_VIDEO_SECTION_BORDER SELF_VIDEO_SECTION_MARGIN*2 #define FLOATING_TOOLBAR_OPACITY 192 #define FLOATING_TOOLBAR_WIDTH 280 @@ -100,6 +101,9 @@ /* The time interval in milliseconds between 2 outgoing rings */ #define MS_BETWEEN_RING 500 +/* The roundedness of preview box and placeholders */ +#define PREVIEW_ROUND_FACTOR 16 + G_DEFINE_TYPE(EmpathyCallWindow, empathy_call_window, GTK_TYPE_WINDOW) enum { @@ -630,7 +634,7 @@ empathy_call_window_create_preview_rectangle (EmpathyCallWindow *self, ClutterBinAlignment y) { ClutterLayoutManager *layout1, *layout2; - ClutterActor *rectangle; + EmpathyRoundedRectangle *rectangle; ClutterActor *box1, *box2; layout1 = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, @@ -641,8 +645,9 @@ empathy_call_window_create_preview_rectangle (EmpathyCallWindow *self, *box = box1; rectangle = empathy_rounded_rectangle_new ( - SELF_VIDEO_SECTION_WIDTH + 5, - SELF_VIDEO_SECTION_HEIGHT + 5); + SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN, + SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN, + PREVIEW_ROUND_FACTOR); clutter_actor_set_size (box1, SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN, @@ -662,14 +667,14 @@ empathy_call_window_create_preview_rectangle (EmpathyCallWindow *self, SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN); clutter_container_add_actor (CLUTTER_CONTAINER (box1), box2); - clutter_container_add_actor (CLUTTER_CONTAINER (box2), rectangle); + clutter_container_add_actor (CLUTTER_CONTAINER (box2), CLUTTER_ACTOR (rectangle)); clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (self->priv->video_layout), box1, x, y); - clutter_actor_hide (rectangle); + clutter_actor_hide (CLUTTER_ACTOR (rectangle)); - return rectangle; + return CLUTTER_ACTOR (rectangle); } static void @@ -788,7 +793,7 @@ empathy_call_window_get_preview_position (EmpathyCallWindow *self, } else if (box.width - SELF_VIDEO_SECTION_MARGIN >= event_x && event_x >= (box.width - SELF_VIDEO_SECTION_MARGIN - (gint) SELF_VIDEO_SECTION_WIDTH) && - box.height - SELF_VIDEO_SECTION_MARGIN - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING >= event_y && + box.height - 2 * SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING >= event_y && event_y >= (box.height - SELF_VIDEO_SECTION_MARGIN - FLOATING_TOOLBAR_HEIGHT - FLOATING_TOOLBAR_SPACING - (gint) SELF_VIDEO_SECTION_HEIGHT)) { pos = PREVIEW_POS_BOTTOM_RIGHT; @@ -876,7 +881,7 @@ empathy_call_window_highlight_preview_rectangle (EmpathyCallWindow *self, rectangle = empathy_call_window_get_preview_rectangle (self, pos); empathy_rounded_rectangle_set_border_width ( - EMPATHY_ROUNDED_RECTANGLE (rectangle), 3); + EMPATHY_ROUNDED_RECTANGLE (rectangle), 2 * SELF_VIDEO_SECTION_MARGIN); empathy_rounded_rectangle_set_border_color ( EMPATHY_ROUNDED_RECTANGLE (rectangle), CLUTTER_COLOR_Red); } @@ -1091,9 +1096,7 @@ create_video_preview (EmpathyCallWindow *self) /* Spinner for when changing the camera device */ priv->preview_spinner_widget = gtk_spinner_new (); - priv->preview_spinner_actor = empathy_rounded_actor_new (); - empathy_rounded_actor_set_round_factor ( - EMPATHY_ROUNDED_ACTOR (priv->preview_spinner_actor), 16); + priv->preview_spinner_actor = empathy_rounded_actor_new (PREVIEW_ROUND_FACTOR); g_object_set (priv->preview_spinner_widget, "expand", TRUE, NULL); gtk_widget_override_background_color ( @@ -1134,7 +1137,7 @@ create_video_preview (EmpathyCallWindow *self) /* Translators: this is an "Info" label. It should be as short * as possible. */ button = gtk_button_new_with_label (_("i")); - priv->preview_shown_button = b = empathy_rounded_actor_new (); + priv->preview_shown_button = b = empathy_rounded_actor_new (2); gtk_container_add ( GTK_CONTAINER (gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (b))), button); @@ -1145,7 +1148,7 @@ create_video_preview (EmpathyCallWindow *self) box = clutter_box_new (layout_end); clutter_actor_set_size (box, SELF_VIDEO_SECTION_WIDTH, - SELF_VIDEO_SECTION_HEIGHT + SELF_VIDEO_SECTION_MARGIN); + SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN); clutter_container_add_actor (CLUTTER_CONTAINER (box), b); clutter_container_add_actor (CLUTTER_CONTAINER (priv->video_preview), box); @@ -1157,7 +1160,7 @@ create_video_preview (EmpathyCallWindow *self) /* Translators: this is an "Info" label. It should be as short * as possible. */ button = gtk_button_new_with_label (_("i")); - b = empathy_rounded_actor_new (); + b = empathy_rounded_actor_new (2); gtk_container_add ( GTK_CONTAINER (gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (b))), button); @@ -1726,7 +1729,7 @@ empathy_call_window_init (EmpathyCallWindow *self) create_audio_input (self); create_video_input (self); - priv->floating_toolbar = empathy_rounded_actor_new (); + priv->floating_toolbar = empathy_rounded_actor_new (2); gtk_widget_reparent (priv->bottom_toolbar, gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (priv->floating_toolbar))); diff --git a/src/empathy-rounded-actor.c b/src/empathy-rounded-actor.c index 045f08de7..646682fb5 100644 --- a/src/empathy-rounded-actor.c +++ b/src/empathy-rounded-actor.c @@ -75,15 +75,12 @@ empathy_rounded_actor_class_init (EmpathyRoundedActorClass *klass) } ClutterActor * -empathy_rounded_actor_new (void) +empathy_rounded_actor_new (guint round_factor) { - return CLUTTER_ACTOR ( + EmpathyRoundedActor *self = EMPATHY_ROUNDED_ACTOR ( g_object_new (EMPATHY_TYPE_ROUNDED_ACTOR, NULL)); -} -void -empathy_rounded_actor_set_round_factor (EmpathyRoundedActor *self, - guint round_factor) -{ self->priv->round_factor = round_factor; + + return CLUTTER_ACTOR (self); } diff --git a/src/empathy-rounded-actor.h b/src/empathy-rounded-actor.h index 4287cf389..49fc03fd3 100644 --- a/src/empathy-rounded-actor.h +++ b/src/empathy-rounded-actor.h @@ -59,10 +59,7 @@ GType empathy_rounded_actor_get_type (void); (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ROUNDED_ACTOR, \ EmpathyRoundedActorClass)) -ClutterActor *empathy_rounded_actor_new (void); - -void empathy_rounded_actor_set_round_factor (EmpathyRoundedActor *self, - guint round_factor); +ClutterActor *empathy_rounded_actor_new (guint round_factor); G_END_DECLS diff --git a/src/empathy-rounded-rectangle.c b/src/empathy-rounded-rectangle.c index 60246151b..7b8951f80 100644 --- a/src/empathy-rounded-rectangle.c +++ b/src/empathy-rounded-rectangle.c @@ -35,6 +35,7 @@ struct _EmpathyRoundedRectanglePriv guint width, height; ClutterColor border_color; guint border_width; + guint round_factor; }; static gboolean @@ -43,12 +44,14 @@ draw_cb (ClutterCairoTexture *canvas, { EmpathyRoundedRectangle *self = EMPATHY_ROUNDED_RECTANGLE (canvas); guint width, height; + guint border_width; guint tmp_alpha; - -#define RADIUS (height / 8.) + gdouble radius; width = self->priv->width; height = self->priv->height; + radius = self->priv->height / self->priv->round_factor; + border_width = self->priv->border_width; /* compute the composited opacity of the actor taking into * account the opacity of the color set by the user */ @@ -62,29 +65,28 @@ draw_cb (ClutterCairoTexture *canvas, self->priv->border_color.blue, tmp_alpha); - cairo_set_line_width (cr, self->priv->border_width); + cairo_set_line_width (cr, border_width); cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); cairo_paint (cr); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); /* make room for the portion of the border drawn on the outside */ - cairo_translate (cr, self->priv->border_width/2.0, self->priv->border_width/2.0); + cairo_translate (cr, border_width/2.0, border_width/2.0); cairo_new_sub_path (cr); - cairo_arc (cr, width - RADIUS, RADIUS, RADIUS, + cairo_arc (cr, width - radius, radius, radius, -M_PI/2.0, 0); - cairo_arc (cr, width - RADIUS, height - RADIUS, RADIUS, + cairo_arc (cr, width - radius, height - radius, radius, 0, M_PI/2.0); - cairo_arc (cr, RADIUS, height - RADIUS, RADIUS, + cairo_arc (cr, radius, height - radius, radius, M_PI/2.0, M_PI); - cairo_arc (cr, RADIUS, RADIUS, RADIUS, + cairo_arc (cr, radius, radius, radius, M_PI, -M_PI/2.0); cairo_close_path (cr); cairo_stroke (cr); -#undef RADIUS return TRUE; } @@ -95,6 +97,7 @@ empathy_rounded_rectangle_init (EmpathyRoundedRectangle *self) EMPATHY_TYPE_ROUNDED_RECTANGLE, EmpathyRoundedRectanglePriv); self->priv->border_width = 1; + self->priv->round_factor = 2; } static void @@ -121,9 +124,10 @@ empathy_rounded_rectangle_update_surface_size (EmpathyRoundedRectangle *self) self->priv->height + self->priv->border_width); } -ClutterActor * +EmpathyRoundedRectangle * empathy_rounded_rectangle_new (guint width, - guint height) + guint height, + guint round_factor) { EmpathyRoundedRectangle *self; @@ -131,13 +135,14 @@ empathy_rounded_rectangle_new (guint width, self->priv->width = width; self->priv->height = height; + self->priv->round_factor = round_factor; g_signal_connect (self, "draw", G_CALLBACK (draw_cb), NULL); empathy_rounded_rectangle_update_surface_size (self); clutter_cairo_texture_invalidate (CLUTTER_CAIRO_TEXTURE (self)); - return CLUTTER_ACTOR (self); + return self; } void diff --git a/src/empathy-rounded-rectangle.h b/src/empathy-rounded-rectangle.h index 38d396f39..e4bf72c6e 100644 --- a/src/empathy-rounded-rectangle.h +++ b/src/empathy-rounded-rectangle.h @@ -59,8 +59,9 @@ GType empathy_rounded_rectangle_get_type (void); (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ROUNDED_RECTANGLE, \ EmpathyRoundedRectangleClass)) -ClutterActor *empathy_rounded_rectangle_new (guint width, - guint height); +EmpathyRoundedRectangle *empathy_rounded_rectangle_new (guint width, + guint height, + guint round_factor); void empathy_rounded_rectangle_set_border_width (EmpathyRoundedRectangle *self, |