Beispiel #1
0
ClutterActor *
gb_player_rounded_rect (GbPlayer *self,
						gint width,
						gint height,
						ClutterColor *bgcolor,
						gint round_radius)
{
	/* Mostly code of this function was got from Tweet,  */
	/* thanks to Emanuelle Bassi. (http://live.gnome.org/Tweet) */
	ClutterActor *actor;
	cairo_t *cr;
	
	actor = clutter_cairo_new (width, height);
	cr = clutter_cairo_create (CLUTTER_CAIRO (actor));
	cairo_move_to (cr, round_radius, 0);
	cairo_line_to (cr, width - round_radius, 0);
	cairo_curve_to (cr, width, 0, width, 0, width, round_radius);
	cairo_line_to (cr, width, height - round_radius);
	cairo_curve_to (cr, width, height, width, height, width - round_radius, height);
	cairo_line_to (cr, round_radius, height);
	cairo_curve_to (cr, 0, height, 0, height, 0, height - round_radius);
	cairo_line_to (cr, 0, round_radius);
	cairo_curve_to (cr, 0, 0, 0, 0, round_radius, 0);
	cairo_close_path (cr);
	
	clutter_cairo_set_source_color (cr, bgcolor);
	cairo_fill_preserve (cr);
	cairo_destroy (cr);
	return actor;
}
Beispiel #2
0
/* ClutterActor methods */
static void
tweet_overlay_request_coords (ClutterActor    *actor,
                              ClutterActorBox *box)
{
  TweetOverlayPrivate *priv = TWEET_OVERLAY (actor)->priv;
  guint width, height;

  CLUTTER_ACTOR_CLASS (tweet_overlay_parent_class)->request_coords (actor, box);

  if (G_LIKELY (priv->base))
    {
      width = CLUTTER_UNITS_TO_DEVICE (box->x2 - box->x1);
      height = CLUTTER_UNITS_TO_DEVICE (box->y2 - box->y1);

      clutter_actor_set_size (priv->base, width, height);
      clutter_cairo_surface_resize (CLUTTER_CAIRO (priv->base),
                                    width, height);

      draw_background (TWEET_OVERLAY (actor));
   }
}
Beispiel #3
0
static inline void
draw_background (TweetOverlay *overlay)
{
  TweetOverlayPrivate *priv = overlay->priv;
  cairo_t *cr;
  gint width, height;

  g_assert (CLUTTER_IS_CAIRO (priv->base));

  cr = clutter_cairo_create (CLUTTER_CAIRO (priv->base));
  g_assert (cr != NULL);

  width = height = 0;
  g_object_get (G_OBJECT (priv->base),
                "surface-width", &width,
                "surface-height", &height,
                NULL);

  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
  cairo_paint (cr);

  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
  cairo_move_to (cr, BG_ROUND_RADIUS, 0);
  cairo_line_to (cr, width - BG_ROUND_RADIUS, 0);
  cairo_curve_to (cr, width, 0, width, 0, width, BG_ROUND_RADIUS);
  cairo_line_to (cr, width, height - BG_ROUND_RADIUS);
  cairo_curve_to (cr, width, height, width, height, width - BG_ROUND_RADIUS, height);
  cairo_line_to (cr, BG_ROUND_RADIUS, height);
  cairo_curve_to (cr, 0, height, 0, height, 0, height - BG_ROUND_RADIUS);
  cairo_line_to (cr, 0, BG_ROUND_RADIUS);
  cairo_curve_to (cr, 0, 0, 0, 0, BG_ROUND_RADIUS, 0);

  cairo_close_path (cr);

  clutter_cairo_set_source_color (cr, &priv->base_color);
  cairo_fill_preserve (cr);

  cairo_destroy (cr);
}