static void
draw_shadow (BixiMarker *marker,
   gint radius)
{
  BixiMarkerPrivate *priv = marker->priv;
  ClutterActor *shadow = NULL;
  cairo_t *cr;

  shadow = clutter_cairo_texture_new (radius * 2, radius * 2);
  cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (shadow));

  draw_box (cr, radius);

  cairo_set_source_rgba (cr, 0, 0, 0, 0.25);
  cairo_fill (cr);

  cairo_destroy (cr);

  clutter_actor_set_position (shadow, 3, 3);

  clutter_container_add_actor (CLUTTER_CONTAINER (marker), shadow);

  if (priv->shadow != NULL)
    {
      clutter_container_remove_actor (CLUTTER_CONTAINER (marker),
          priv->shadow);
      g_object_unref (priv->shadow);
    }

  priv->shadow = g_object_ref (shadow);
}
Exemple #2
0
static void ease_pdf_actor_draw_page (EasePdfActor* self) {
#line 415 "ease-pdf-actor.c"
	PopplerPage* page;
	double width;
	double height;
	cairo_t* cr;
	GError * _inner_error_ = NULL;
#line 58 "ease-pdf-actor.vala"
	g_return_if_fail (self != NULL);
#line 61 "ease-pdf-actor.vala"
	page = _g_object_ref0 (poppler_document_get_page (self->priv->doc, self->priv->current_page));
#line 62 "ease-pdf-actor.vala"
	width = (double) 0;
#line 62 "ease-pdf-actor.vala"
	height = (double) 0;
#line 63 "ease-pdf-actor.vala"
	poppler_page_get_size (page, &width, &height);
#line 66 "ease-pdf-actor.vala"
	if (self->priv->texture == NULL) {
#line 433 "ease-pdf-actor.c"
		ClutterCairoTexture* _tmp0_;
		ClutterActor* _tmp1_;
#line 68 "ease-pdf-actor.vala"
		self->priv->texture = (_tmp0_ = g_object_ref_sink ((ClutterCairoTexture*) clutter_cairo_texture_new ((guint) ((gint) width), (guint) ((gint) height))), _g_object_unref0 (self->priv->texture), _tmp0_);
#line 69 "ease-pdf-actor.vala"
		clutter_container_add_actor ((ClutterContainer*) (_tmp1_ = ((EaseActor*) self)->contents, CLUTTER_IS_GROUP (_tmp1_) ? ((ClutterGroup*) _tmp1_) : NULL), (ClutterActor*) self->priv->texture);
#line 71 "ease-pdf-actor.vala"
		clutter_actor_set_width ((ClutterActor*) self->priv->texture, clutter_actor_get_width (((EaseActor*) self)->contents));
#line 72 "ease-pdf-actor.vala"
		clutter_actor_set_height ((ClutterActor*) self->priv->texture, clutter_actor_get_height (((EaseActor*) self)->contents));
#line 74 "ease-pdf-actor.vala"
		g_signal_connect_object ((GObject*) ((EaseActor*) self)->contents, "notify::width", (GCallback) __lambda53__g_object_notify, self, 0);
#line 78 "ease-pdf-actor.vala"
		g_signal_connect_object ((GObject*) ((EaseActor*) self)->contents, "notify::height", (GCallback) __lambda54__g_object_notify, self, 0);
#line 448 "ease-pdf-actor.c"
	} else {
#line 86 "ease-pdf-actor.vala"
		clutter_cairo_texture_set_surface_size (self->priv->texture, (guint) ((gint) width), (guint) ((gint) height));
#line 452 "ease-pdf-actor.c"
	}
#line 90 "ease-pdf-actor.vala"
	clutter_cairo_texture_clear (self->priv->texture);
#line 91 "ease-pdf-actor.vala"
	cr = clutter_cairo_texture_create (self->priv->texture);
#line 92 "ease-pdf-actor.vala"
	ease_background_cairo_render (self->priv->pdf_element->background, cr, (gint) width, (gint) height, ease_document_get_path (ease_slide_get_parent (ease_element_get_parent (((EaseActor*) self)->element))), &_inner_error_);
#line 460 "ease-pdf-actor.c"
	if (_inner_error_ != NULL) {
		_cairo_destroy0 (cr);
		_g_object_unref0 (page);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
#line 94 "ease-pdf-actor.vala"
	poppler_page_render (page, cr);
#line 470 "ease-pdf-actor.c"
	_cairo_destroy0 (cr);
	_g_object_unref0 (page);
}
static void
draw_background (BixiMarker *marker,
    gint radius)
{
  BixiMarkerPrivate *priv = marker->priv;
  ClutterActor *bg = NULL;
  ClutterColor color;
  ClutterColor darker_color;
  gboolean highlighted = FALSE;
  guint line_width = 1;
  cairo_t *cr;

  bg = clutter_cairo_texture_new (radius * 2, radius * 2);
  cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (bg));
  color = *champlain_marker_get_color (CHAMPLAIN_MARKER (marker));

  if (priv->value == 0)
    color.alpha = 128;

  g_object_get (marker, "highlighted", &highlighted, NULL);
  if (highlighted)
    {
#if CHAMPLAIN_CHECK_VERSION(0, 4, 1)
      color = *champlain_marker_get_highlight_color ();
#else
      line_width *= 3;
#endif
    }

  clutter_color_darken (&color, &darker_color);
  draw_box (cr, radius);

  cairo_set_source_rgba (cr,
      color.red / 255.0,
      color.green / 255.0,
      color.blue / 255.0,
      color.alpha / 255.0);
  cairo_fill_preserve (cr);

  cairo_set_line_width (cr, line_width);
  cairo_set_source_rgba (cr,
      darker_color.red / 255.0,
      darker_color.green / 255.0,
      darker_color.blue / 255.0,
      darker_color.alpha / 255.0);
  cairo_stroke (cr);
  cairo_destroy (cr);

  clutter_container_add_actor (CLUTTER_CONTAINER (marker), bg);

  if (priv->background != NULL)
    {
      clutter_container_remove_actor (CLUTTER_CONTAINER (marker),
          priv->background);
      g_object_unref (priv->background);
    }

  priv->background = g_object_ref (bg);
}
static void
shell_drawing_area_init (ShellDrawingArea *area)
{
  area->priv = G_TYPE_INSTANCE_GET_PRIVATE (area, SHELL_TYPE_DRAWING_AREA,
                                            ShellDrawingAreaPrivate);
  area->priv->texture = CLUTTER_CAIRO_TEXTURE (clutter_cairo_texture_new (1, 1));
  clutter_container_add_actor (CLUTTER_CONTAINER (area), CLUTTER_ACTOR (area->priv->texture));
}
/**
 * nemo_preview_create_rounded_background:
 *
 * Returns: (transfer none): a #ClutterActor
 */
ClutterActor *
nemo_preview_create_rounded_background (void)
{
  ClutterActor *retval;

  retval = clutter_cairo_texture_new (1, 1);
  clutter_cairo_texture_set_auto_resize (CLUTTER_CAIRO_TEXTURE (retval), TRUE);

  g_signal_connect (retval, "draw",
                    G_CALLBACK (rounded_background_draw_cb), NULL);

  return retval;
}
static void
glide_theme_preview_actor_init (GlideThemePreviewActor *preview)
{
    preview->priv = GLIDE_THEME_PREVIEW_ACTOR_GET_PRIVATE (preview);

    preview->priv->preview_texture = clutter_cairo_texture_new (160, 120);

    clutter_container_add_actor (CLUTTER_CONTAINER (preview), preview->priv->preview_texture);
    clutter_actor_set_position (preview->priv->preview_texture, 0, 0);

    glide_theme_preview_actor_add_border (preview);

    clutter_actor_set_reactive (CLUTTER_ACTOR (preview), TRUE);
}
Exemple #7
0
static ClutterActor *
make_bouncer (const ClutterColor *base_color,
              gfloat              width,
              gfloat              height)
{
  ClutterActor *retval;
  cairo_t *cr;
  cairo_pattern_t *pattern;
  gfloat radius = MAX (width, height);

  retval = clutter_cairo_texture_new (width, height);

  cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (retval));

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

  cairo_arc (cr, radius / 2, radius / 2, radius / 2, 0.0, 2.0 * G_PI);

  pattern = cairo_pattern_create_radial (radius / 2, radius / 2, 0,
                                         radius, radius, radius);
  cairo_pattern_add_color_stop_rgba (pattern,
                                     0,
                                     base_color->red / 255.0,
                                     base_color->green / 255.0,
                                     base_color->blue / 255.0,
                                     base_color->alpha / 255.0);
  cairo_pattern_add_color_stop_rgba (pattern,
                                     0.9,
                                     base_color->red / 255.0,
                                     base_color->green / 255.0,
                                     base_color->blue / 255.0,
                                     0.1);

  cairo_set_source (cr, pattern);
  cairo_fill_preserve (cr);

  cairo_pattern_destroy (pattern);
  cairo_destroy (cr);

  clutter_actor_set_name (retval, "bouncer");
  clutter_actor_set_size (retval, width, height);
  clutter_actor_set_anchor_point (retval, width / 2, height / 2);
  clutter_actor_set_reactive (retval, TRUE);

  return retval;
}
Exemple #8
0
static void
pkg_graph_2d_init (PkgGraph2d *graph)
{
	graph->priv = G_TYPE_INSTANCE_GET_PRIVATE(graph,
	                                          PKG_TYPE_GRAPH_2D,
	                                          PkgGraph2dPrivate);

	graph->priv->texture = clutter_cairo_texture_new(1, 1);
	clutter_container_add_actor(CLUTTER_CONTAINER(graph),
	                            graph->priv->texture);
	clutter_actor_show(graph->priv->texture);

	graph->priv->x_scale = g_object_ref_sink(pkg_scale_linear_new());
	graph->priv->y_scale = g_object_ref_sink(pkg_scale_linear_new());
	graph->priv->x_padding = 25.;
	graph->priv->y_padding = 25.;

	g_signal_connect(graph,
	                 "allocation-changed",
	                 G_CALLBACK(pkg_graph_2d_allocation_changed),
	                 NULL);
}
static void
create_stage (guint width, guint height)
{
  ClutterActor *stage, *instructions;
  GError *error = NULL;

  stage = clutter_stage_get_default ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Depth File Viewer");
  clutter_actor_set_size (stage, width, height + 100);
  clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);

  g_signal_connect (stage, "destroy", G_CALLBACK (on_destroy), NULL);

  depth_tex = clutter_cairo_texture_new (width, height);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), depth_tex);

  info_text = clutter_text_new ();
  clutter_actor_set_position (info_text, 50, height + 20);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), info_text);

  clutter_actor_show_all (stage);
}
Exemple #10
0
/**
 * shell_global_create_horizontal_gradient:
 * @left: the color on the left
 * @right: the color on the right
 *
 * Creates a horizontal gradient actor.
 *
 * Return value: (transfer none): a #ClutterCairoTexture actor with the
 *               gradient. The texture actor is floating, hence (transfer none).
 */
ClutterCairoTexture *
shell_global_create_horizontal_gradient (ClutterColor *left,
                                         ClutterColor *right)
{
  ClutterCairoTexture *texture;
  cairo_t *cr;
  cairo_pattern_t *pattern;

  /* Draw the gradient on an 8x1 pixel texture. Because the gradient is drawn
   * from the left to the right column, after stretching 1/16 of the
   * texture width has the left side color and 1/16 has the right side color. 
   * There is no reason to use the 8 pixel height that would be similar to the
   * reason we are using the 8 pixel width for the vertical gradient, so we
   * are just using the 1 pixel height instead.
   */
  texture = CLUTTER_CAIRO_TEXTURE (clutter_cairo_texture_new (8, 1));
  cr = clutter_cairo_texture_create (texture);

  pattern = cairo_pattern_create_linear (0, 0, 8, 0);
  cairo_pattern_add_color_stop_rgba (pattern, 0,
                                     left->red / 255.,
                                     left->green / 255.,
                                     left->blue / 255.,
                                     left->alpha / 255.);
  cairo_pattern_add_color_stop_rgba (pattern, 1,
                                     right->red / 255.,
                                     right->green / 255.,
                                     right->blue / 255.,
                                     right->alpha / 255.);

  cairo_set_source (cr, pattern);
  cairo_paint (cr);

  cairo_pattern_destroy (pattern);
  cairo_destroy (cr);

  return texture;
}
Exemple #11
0
/**
 * shell_global_create_vertical_gradient:
 * @top: the color at the top
 * @bottom: the color at the bottom
 *
 * Creates a vertical gradient actor.
 *
 * Return value: (transfer none): a #ClutterCairoTexture actor with the
 *               gradient. The texture actor is floating, hence (transfer none).
 */
ClutterCairoTexture *
shell_global_create_vertical_gradient (ClutterColor *top,
                                       ClutterColor *bottom)
{
  ClutterCairoTexture *texture;
  cairo_t *cr;
  cairo_pattern_t *pattern;

  /* Draw the gradient on an 8x8 pixel texture. Because the gradient is drawn
   * from the uppermost to the lowermost row, after stretching 1/16 of the
   * texture height has the top color and 1/16 has the bottom color. The 8
   * pixel width is chosen for reasons related to graphics hardware internals.
   */
  texture = CLUTTER_CAIRO_TEXTURE (clutter_cairo_texture_new (8, 8));
  cr = clutter_cairo_texture_create (texture);

  pattern = cairo_pattern_create_linear (0, 0, 0, 8);
  cairo_pattern_add_color_stop_rgba (pattern, 0,
                                     top->red / 255.,
                                     top->green / 255.,
                                     top->blue / 255.,
                                     top->alpha / 255.);
  cairo_pattern_add_color_stop_rgba (pattern, 1,
                                     bottom->red / 255.,
                                     bottom->green / 255.,
                                     bottom->blue / 255.,
                                     bottom->alpha / 255.);

  cairo_set_source (cr, pattern);
  cairo_paint (cr);

  cairo_pattern_destroy (pattern);
  cairo_destroy (cr);

  return texture;
}
/* The marker is drawn with cairo.  It is composed of 1 static filled circle
 * and 1 stroked circle animated as an echo.
 */
static ClutterActor *
create_marker ()
{
  ClutterActor *marker;
  ClutterActor *bg;
  ClutterTimeline *timeline;
  cairo_t *cr;

  /* Create the marker */
  marker = champlain_custom_marker_new ();

  /* Static filled circle ----------------------------------------------- */
  bg = clutter_cairo_texture_new (MARKER_SIZE, MARKER_SIZE);
  cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (bg));

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

  /* Draw the circle */
  cairo_set_source_rgb (cr, 0, 0, 0);
  cairo_arc (cr, MARKER_SIZE / 2.0, MARKER_SIZE / 2.0, MARKER_SIZE / 2.0, 0, 2 * M_PI);
  cairo_close_path (cr);

  /* Fill the circle */
  cairo_set_source_rgba (cr, 0.1, 0.1, 0.9, 1.0);
  cairo_fill (cr);

  cairo_destroy (cr);

  /* Add the circle to the marker */
  clutter_container_add_actor (CLUTTER_CONTAINER (marker), bg);
  clutter_actor_set_anchor_point_from_gravity (bg, CLUTTER_GRAVITY_CENTER);
  clutter_actor_set_position (bg, 0, 0);

  /* Echo circle -------------------------------------------------------- */
  bg = clutter_cairo_texture_new (2 * MARKER_SIZE, 2 * MARKER_SIZE);
  cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (bg));

  /* Draw the circle */
  cairo_set_source_rgb (cr, 0, 0, 0);
  cairo_arc (cr, MARKER_SIZE, MARKER_SIZE, 0.9 * MARKER_SIZE, 0, 2 * M_PI);
  cairo_close_path (cr);

  /* Stroke the circle */
  cairo_set_line_width (cr, 2.0);
  cairo_set_source_rgba (cr, 0.1, 0.1, 0.7, 1.0);
  cairo_stroke (cr);

  cairo_destroy (cr);

  /* Add the circle to the marker */
  clutter_container_add_actor (CLUTTER_CONTAINER (marker), bg);
  clutter_actor_lower_bottom (bg); /* Ensure it is under the previous circle */
  clutter_actor_set_position (bg, 0, 0);
  clutter_actor_set_anchor_point_from_gravity (bg, CLUTTER_GRAVITY_CENTER);

  /* Animate the echo circle */
  timeline = clutter_timeline_new (1000);
  clutter_timeline_set_loop (timeline, TRUE);
  clutter_actor_set_opacity (CLUTTER_ACTOR (bg), 255);
  clutter_actor_set_scale (CLUTTER_ACTOR (bg), 0.5, 0.5);
  clutter_actor_animate_with_timeline (CLUTTER_ACTOR (bg),
      CLUTTER_EASE_OUT_SINE, 
      timeline, 
      "opacity", 0, 
      "scale-x", 2.0, 
      "scale-y", 2.0, 
      NULL);

  clutter_timeline_start (timeline);

  return marker;
}
Exemple #13
0
static void
on_new_kinect_device (GObject      *obj,
                      GAsyncResult *res,
                      gpointer      user_data)
{
  ClutterActor *stage, *instructions;
  GError *error = NULL;
  gint width = 640;
  gint height = 480;

  kinect = gfreenect_device_new_finish (res, &error);
  if (kinect == NULL)
    {
      g_debug ("Failed to created kinect device: %s", error->message);
      g_error_free (error);
      clutter_main_quit ();
      return;
    }

  g_debug ("Kinect device created!");

  stage = clutter_stage_get_default ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Kinect Test");
  clutter_actor_set_size (stage, width * 2, height + 200);
  clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);

  g_signal_connect (stage, "destroy", G_CALLBACK (on_destroy), kinect);
  g_signal_connect (stage,
                    "key-release-event",
                    G_CALLBACK (on_key_release),
                    kinect);

  depth_tex = clutter_cairo_texture_new (width, height);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), depth_tex);

  video_tex = clutter_cairo_texture_new (width, height);
  clutter_actor_set_position (video_tex, width, 0.0);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), video_tex);

  info_text = clutter_text_new ();
  set_info_text ();
  clutter_actor_set_position (info_text, 50, height + 20);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), info_text);

  instructions = create_instructions ();
  clutter_actor_set_position (instructions, 50, height + 70);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), instructions);

  clutter_actor_show_all (stage);

  skeleton = SKELTRACK_SKELETON (skeltrack_skeleton_new ());

  g_signal_connect (kinect,
                    "depth-frame",
                    G_CALLBACK (on_depth_frame),
                    NULL);

  g_signal_connect (kinect,
                    "video-frame",
                    G_CALLBACK (on_video_frame),
                    NULL);

  g_signal_connect (depth_tex,
                    "draw",
                    G_CALLBACK (on_texture_draw),
                    NULL);

  gfreenect_device_set_tilt_angle (kinect, 0, NULL, NULL, NULL);

  gfreenect_device_start_depth_stream (kinect,
                                       GFREENECT_DEPTH_FORMAT_MM,
                                       NULL);

  gfreenect_device_start_video_stream (kinect,
                                       GFREENECT_RESOLUTION_MEDIUM,
                                       GFREENECT_VIDEO_FORMAT_RGB, NULL);
}
G_MODULE_EXPORT int
test_bin_layout_main (int argc, char *argv[])
{
  ClutterActor *stage, *box, *rect;
  ClutterLayoutManager *layout;
  ClutterColor stage_color = { 0xe0, 0xf2, 0xfc, 0xff };
  ClutterColor *color;
  ClutterAction *action;

  if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    return 1;

  stage = clutter_stage_get_default ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Box test");
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  clutter_actor_set_size (stage, 640, 480);

  layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
                                   CLUTTER_BIN_ALIGNMENT_CENTER);

  box = clutter_box_new (layout);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
  clutter_actor_set_anchor_point_from_gravity (box, CLUTTER_GRAVITY_CENTER);
  clutter_actor_set_position (box, 320, 240);
  clutter_actor_set_reactive (box, TRUE);
  clutter_actor_set_name (box, "box");

  /* the contents of the texture are created every time the allocation
   * of the box changes, to keep the background's size the same as the
   * box's size
   */
  rect = clutter_cairo_texture_new (100, 100);

  /* first method: use clutter_box_pack() */
  clutter_box_pack (CLUTTER_BOX (box), rect,
                    "x-align", CLUTTER_BIN_ALIGNMENT_FILL,
                    "y-align", CLUTTER_BIN_ALIGNMENT_FILL,
                    NULL);

  clutter_actor_lower_bottom (rect);
  clutter_actor_set_name (rect, "background");
  g_signal_connect (box, "allocation-changed",
                    G_CALLBACK (on_box_allocation_changed),
                    rect);

  {
    ClutterActor *tex;
    GError *error;
    gchar *file;

    error = NULL;
    file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
    tex = clutter_texture_new_from_file (file, &error);
    if (error)
      g_error ("Unable to create texture: %s", error->message);

    clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (tex), TRUE);

    /* second method: use clutter_bin_layout_add() */
    clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout), tex,
                            CLUTTER_BIN_ALIGNMENT_CENTER,
                            CLUTTER_BIN_ALIGNMENT_CENTER);

    clutter_actor_raise (tex, rect);
    clutter_actor_set_width (tex, 175);
    clutter_actor_set_name (tex, "texture");

    g_free (file);
  }

  color = clutter_color_new (g_random_int_range (0, 255),
                             g_random_int_range (0, 255),
                             g_random_int_range (0, 255),
                             224);

  rect = clutter_rectangle_new_with_color (color);

  /* third method: container_add() and set_alignment() */
  clutter_container_add_actor (CLUTTER_CONTAINER (box), rect);
  clutter_bin_layout_set_alignment (CLUTTER_BIN_LAYOUT (layout), rect,
                                    CLUTTER_BIN_ALIGNMENT_END,
                                    CLUTTER_BIN_ALIGNMENT_END);

  clutter_actor_set_size (rect, 50, 50);
  clutter_actor_set_opacity (rect, 0);
  clutter_actor_set_reactive (rect, TRUE);
  clutter_actor_raise_top (rect);
  clutter_actor_set_name (rect, "emblem");

  action = clutter_click_action_new ();
  clutter_actor_add_action (rect, action);
  g_signal_connect (action, "clicked", G_CALLBACK (on_rect_clicked), box);
  g_signal_connect (action, "long-press", G_CALLBACK (on_rect_long_press), box);
  g_signal_connect (box,
                    "enter-event", G_CALLBACK (on_box_enter),
                    rect);
  g_signal_connect (box,
                    "leave-event", G_CALLBACK (on_box_leave),
                    rect);

  rect = clutter_text_new ();
  clutter_text_set_text (CLUTTER_TEXT (rect), "A simple test");
  clutter_container_add_actor (CLUTTER_CONTAINER (box), rect);
  clutter_bin_layout_set_alignment (CLUTTER_BIN_LAYOUT (layout), rect,
                                    CLUTTER_BIN_ALIGNMENT_CENTER,
                                    CLUTTER_BIN_ALIGNMENT_START);
  clutter_actor_raise_top (rect);
  clutter_actor_set_name (rect, "text");

  clutter_actor_show_all (stage);

  clutter_main ();

  clutter_color_free (color);

  return EXIT_SUCCESS;
}
Exemple #15
0
static ClutterActor *
make_background (const ClutterColor *color,
                 gfloat              width,
                 gfloat              height)
{
  ClutterActor *tex = clutter_cairo_texture_new (width, height);
  cairo_t *cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (tex));
  cairo_pattern_t *pat;
  gfloat x, y;

#define BG_ROUND_RADIUS         12

  x = y = 0;

  cairo_move_to (cr, BG_ROUND_RADIUS, y);
  cairo_line_to (cr, width - BG_ROUND_RADIUS, y);
  cairo_curve_to (cr, width, y, width, y, 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, x, height, x, height, x, height - BG_ROUND_RADIUS);
  cairo_line_to (cr, x, BG_ROUND_RADIUS);
  cairo_curve_to (cr, x, y, x, y, BG_ROUND_RADIUS, y);

  cairo_close_path (cr);

  clutter_cairo_set_source_color (cr, color);
  cairo_stroke (cr);

  x += 4;
  y += 4;
  width -= 4;
  height -= 4;

  cairo_move_to (cr, BG_ROUND_RADIUS, y);
  cairo_line_to (cr, width - BG_ROUND_RADIUS, y);
  cairo_curve_to (cr, width, y, width, y, 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, x, height, x, height, x, height - BG_ROUND_RADIUS);
  cairo_line_to (cr, x, BG_ROUND_RADIUS);
  cairo_curve_to (cr, x, y, x, y, BG_ROUND_RADIUS, y);

  cairo_close_path (cr);

  pat = cairo_pattern_create_linear (0, 0, 0, height);
  cairo_pattern_add_color_stop_rgba (pat, 1, .85, .85, .85, 1);
  cairo_pattern_add_color_stop_rgba (pat, .95, 1, 1, 1, 1);
  cairo_pattern_add_color_stop_rgba (pat, .05, 1, 1, 1, 1);
  cairo_pattern_add_color_stop_rgba (pat, 0, .85, .85, .85, 1);

  cairo_set_source (cr, pat);
  cairo_fill (cr);

  cairo_pattern_destroy (pat);
  cairo_destroy (cr);

#undef BG_ROUND_RADIUS

  return tex;
}
Exemple #16
0
EaseWelcomeActor* ease_welcome_actor_construct (GType object_type, EaseTheme* t) {
#line 152 "ease-welcome-actor.c"
	EaseWelcomeActor * self;
	ClutterRectangle* _tmp0_;
	ClutterColor _tmp1_;
	ClutterColor _tmp2_;
	ClutterRectangle* _tmp3_;
	ClutterColor _tmp4_ = {0};
	ClutterColor _tmp5_;
	ClutterColor _tmp6_;
	ClutterText* _tmp7_;
	ClutterCairoTexture* _tmp8_;
#line 94 "ease-welcome-actor.vala"
	g_return_val_if_fail (t != NULL, NULL);
#line 165 "ease-welcome-actor.c"
	self = g_object_newv (object_type, 0, NULL);
#line 96 "ease-welcome-actor.vala"
	ease_welcome_actor_set_theme (self, t);
#line 97 "ease-welcome-actor.vala"
	clutter_actor_set_reactive ((ClutterActor*) self, TRUE);
#line 100 "ease-welcome-actor.vala"
	self->priv->rect = (_tmp0_ = g_object_ref_sink ((ClutterRectangle*) clutter_rectangle_new ()), _g_object_unref0 (self->priv->rect), _tmp0_);
#line 101 "ease-welcome-actor.vala"
	clutter_rectangle_set_color (self->priv->rect, (_tmp1_ = EASE_WELCOME_ACTOR_RECT_BG, &_tmp1_));
#line 102 "ease-welcome-actor.vala"
	clutter_rectangle_set_border_color (self->priv->rect, (_tmp2_ = EASE_WELCOME_ACTOR_RECT_B_C, &_tmp2_));
#line 103 "ease-welcome-actor.vala"
	clutter_rectangle_set_border_width (self->priv->rect, (guint) EASE_WELCOME_ACTOR_RECT_B_W);
#line 104 "ease-welcome-actor.vala"
	clutter_actor_set_x ((ClutterActor*) self->priv->rect, (float) (-EASE_WELCOME_ACTOR_RECT_B_W));
#line 105 "ease-welcome-actor.vala"
	clutter_actor_set_y ((ClutterActor*) self->priv->rect, (float) (-EASE_WELCOME_ACTOR_RECT_B_W));
#line 106 "ease-welcome-actor.vala"
	clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->rect);
#line 109 "ease-welcome-actor.vala"
	self->priv->hilight_rect = (_tmp3_ = g_object_ref_sink ((ClutterRectangle*) clutter_rectangle_new ()), _g_object_unref0 (self->priv->hilight_rect), _tmp3_);
#line 110 "ease-welcome-actor.vala"
	clutter_rectangle_set_color (self->priv->hilight_rect, (_tmp5_ = (_tmp4_.red = (guchar) 0, _tmp4_.green = (guchar) 0, _tmp4_.blue = (guchar) 0, _tmp4_.alpha = (guchar) 255, _tmp4_), &_tmp5_));
#line 111 "ease-welcome-actor.vala"
	clutter_actor_set_opacity ((ClutterActor*) self->priv->hilight_rect, (guint) 0);
#line 112 "ease-welcome-actor.vala"
	clutter_rectangle_set_border_color (self->priv->hilight_rect, (_tmp6_ = EASE_WELCOME_ACTOR_HLRECT_C, &_tmp6_));
#line 113 "ease-welcome-actor.vala"
	clutter_rectangle_set_border_width (self->priv->hilight_rect, (guint) EASE_WELCOME_ACTOR_HLRECT_W);
#line 114 "ease-welcome-actor.vala"
	clutter_actor_set_x ((ClutterActor*) self->priv->hilight_rect, (float) (-EASE_WELCOME_ACTOR_HLRECT_W));
#line 115 "ease-welcome-actor.vala"
	clutter_actor_set_y ((ClutterActor*) self->priv->hilight_rect, (float) (-EASE_WELCOME_ACTOR_HLRECT_W));
#line 116 "ease-welcome-actor.vala"
	clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->hilight_rect);
#line 119 "ease-welcome-actor.vala"
	self->priv->text = (_tmp7_ = g_object_ref_sink ((ClutterText*) clutter_text_new_full (EASE_WELCOME_ACTOR_FONT_NAME, self->priv->_theme->title, &EASE_WELCOME_ACTOR_TEXT_COLOR)), _g_object_unref0 (self->priv->text), _tmp7_);
#line 120 "ease-welcome-actor.vala"
	clutter_actor_set_height ((ClutterActor*) self->priv->text, EASE_WELCOME_ACTOR_TEXT_HEIGHT);
#line 121 "ease-welcome-actor.vala"
	clutter_text_set_line_alignment (self->priv->text, PANGO_ALIGN_RIGHT);
#line 122 "ease-welcome-actor.vala"
	clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->text);
#line 125 "ease-welcome-actor.vala"
	self->priv->slide_actor = (_tmp8_ = g_object_ref_sink ((ClutterCairoTexture*) clutter_cairo_texture_new ((guint) 1024, (guint) 768)), _g_object_unref0 (self->priv->slide_actor), _tmp8_);
#line 126 "ease-welcome-actor.vala"
	clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->slide_actor);
#line 129 "ease-welcome-actor.vala"
	clutter_actor_set_opacity ((ClutterActor*) self, (guint) 0);
#line 130 "ease-welcome-actor.vala"
	clutter_actor_animate ((ClutterActor*) self, (gulong) EASE_WELCOME_ACTOR_FADE_EASE, (guint) EASE_WELCOME_ACTOR_FADE_INIT_TIME, "opacity", 255, NULL);
#line 133 "ease-welcome-actor.vala"
	g_signal_connect_object ((ClutterActor*) self, "button-press-event", (GCallback) __lambda55__clutter_actor_button_press_event, self, 0);
#line 219 "ease-welcome-actor.c"
	return self;
}
static void
penge_event_tile_init (PengeEventTile *self)
{
  PengeEventTilePrivate *priv = GET_PRIVATE_REAL (self);
  ClutterActor *tmp_text;
  ClutterActor *indicator_container, *indicator_overlay;
  GError *error = NULL;

  self->priv = priv;

  priv->inner_table = mx_table_new ();
  mx_bin_set_child (MX_BIN (self), (ClutterActor *)priv->inner_table);
  mx_bin_set_fill (MX_BIN (self), TRUE, TRUE);

  indicator_container = mx_stack_new ();
  clutter_actor_set_size (indicator_container, 20, 20);

  priv->calendar_indicator = clutter_cairo_texture_new (20, 20);
  clutter_actor_set_size (priv->calendar_indicator, 20, 20);

  indicator_overlay = clutter_texture_new_from_file (CALENDAR_INDICATOR_OVERLAY_MASK, &error); 
  if (error != NULL)
    {
      g_critical (G_STRLOC ": Loading calendar colour overlay failed: %s",
                  error->message);
      g_clear_error (&error);
      indicator_overlay = NULL;
    }
  else
    {
      clutter_actor_set_size (indicator_overlay, 20, 20);
    }

  clutter_container_add (CLUTTER_CONTAINER (indicator_container),
      priv->calendar_indicator, indicator_overlay, NULL);

  priv->time_label = mx_label_new ();
  tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->time_label));
  clutter_text_set_ellipsize (CLUTTER_TEXT (tmp_text), PANGO_ELLIPSIZE_NONE);
  mx_stylable_set_style_class (MX_STYLABLE (priv->time_label),
                               "PengeEventTimeLabel");

  priv->summary_label = mx_label_new ();
  mx_stylable_set_style_class (MX_STYLABLE (priv->summary_label),
                               "PengeEventSummary");
  tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->summary_label));
  clutter_text_set_ellipsize (CLUTTER_TEXT (tmp_text), PANGO_ELLIPSIZE_END);
  clutter_text_set_single_line_mode (CLUTTER_TEXT (tmp_text), TRUE);

  /* Populate the table */
  mx_table_add_actor (MX_TABLE (priv->inner_table),
                      indicator_container,
                      0,
                      0);
  mx_table_add_actor (MX_TABLE (priv->inner_table),
                      priv->time_label,
                      0,
                      1);
  mx_table_add_actor (MX_TABLE (priv->inner_table),
                      priv->summary_label,
                      0,
                      2);

  clutter_container_child_set (CLUTTER_CONTAINER (priv->inner_table),
                               indicator_container,
                               "x-expand", FALSE,
                               "x-fill", FALSE,
                               "y-expand", FALSE,
                               "y-fill", FALSE,
                               NULL);
  clutter_container_child_set (CLUTTER_CONTAINER (priv->inner_table),
                               priv->time_label,
                               "x-expand", FALSE,
                               "x-fill", FALSE,
                               "y-expand", FALSE,
                               "y-fill", FALSE,
                               NULL);
  clutter_container_child_set (CLUTTER_CONTAINER (priv->inner_table),
                               priv->summary_label,
                               "x-expand", TRUE,
                               "x-fill", TRUE,
                               "y-expand", FALSE,
                               "y-fill", FALSE,
                               NULL);


  /* Setup spacing and padding */
  mx_table_set_column_spacing (MX_TABLE (priv->inner_table), 6);

  g_signal_connect (self,
                    "clicked",
                    (GCallback)_button_clicked_cb,
                    self);

  clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE);
}
Exemple #18
0
ClutterActor*
make_flower_actor (void)
{
  /* No science here, just a hack from toying */
  gint i, j;

  double colors[] = {
    0.71, 0.81, 0.83,
    1.0,  0.78, 0.57,
    0.64, 0.30, 0.35,
    0.73, 0.40, 0.39,
    0.91, 0.56, 0.64,
    0.70, 0.47, 0.45,
    0.92, 0.75, 0.60,
    0.82, 0.86, 0.85,
    0.51, 0.56, 0.67,
    1.0, 0.79, 0.58,

  };

  gint size;
  gint petal_size;
  gint n_groups;    /* Num groups of petals 1-3 */
  gint n_petals;    /* num of petals 4 - 8  */
  gint pm1, pm2;

  gint idx, last_idx = -1;

  ClutterActor *ctex;
  cairo_t      *cr;

  petal_size = PETAL_MIN + rand() % PETAL_VAR;
  size = petal_size * 8;

  n_groups = rand() % 3 + 1;

  ctex = clutter_cairo_texture_new (size, size);

  cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (ctex));

  cairo_set_tolerance (cr, 0.1);

  /* Clear */
  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
  cairo_paint(cr);
  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);

  cairo_translate(cr, size/2, size/2);

  for (i=0; i<n_groups; i++)
    {
      n_petals = rand() % 5 + 4;
      cairo_save (cr);

      cairo_rotate (cr, rand() % 6);

      do {
	idx = (rand() % (sizeof (colors) / sizeof (double) / 3)) * 3;
      } while (idx == last_idx);

      cairo_set_source_rgba (cr, colors[idx], colors[idx+1],
			     colors[idx+2], 0.5);

      last_idx = idx;

      /* some bezier randomness */
      pm1 = rand() % 20;
      pm2 = rand() % 4;

      for (j=1; j<n_petals+1; j++)
	{
	  cairo_save (cr);
	  cairo_rotate (cr, ((2*M_PI)/n_petals)*j);

	  /* Petals are made up beziers */
	  cairo_new_path (cr);
	  cairo_move_to (cr, 0, 0);
	  cairo_rel_curve_to (cr,
			      petal_size, petal_size,
			      (pm2+2)*petal_size, petal_size,
			      (2*petal_size) + pm1, 0);
	  cairo_rel_curve_to (cr,
			      0 + (pm2*petal_size), -petal_size,
			      -petal_size, -petal_size,
			      -((2*petal_size) + pm1), 0);
	  cairo_close_path (cr);
	  cairo_fill (cr);
	  cairo_restore (cr);
	}

      petal_size -= rand() % (size/8);

      cairo_restore (cr);
    }

  /* Finally draw flower center */
  do {
      idx = (rand() % (sizeof (colors) / sizeof (double) / 3)) * 3;
  } while (idx == last_idx);

  if (petal_size < 0)
    petal_size = rand() % 10;

  cairo_set_source_rgba (cr, colors[idx], colors[idx+1], colors[idx+2], 0.5);

  cairo_arc(cr, 0, 0, petal_size, 0, M_PI * 2);
  cairo_fill(cr);

  cairo_destroy(cr);

  return ctex;
}
	WindowPanel::WindowPanel()
		: auto_hide_(false) {
		ClutterLayoutManager * main_layout = clutter_bin_layout_new(CLUTTER_BIN_ALIGNMENT_FIXED,
		                                                            CLUTTER_BIN_ALIGNMENT_FIXED);
		actor_ = clutter_box_new(main_layout);

		ClutterActor * menu = clutter_cairo_texture_new(110, 22);
		clutter_actor_set_position(menu, 10.0f, 0.0f);

		cairo_t * context = clutter_cairo_texture_create(CLUTTER_CAIRO_TEXTURE(menu));

		cairo_move_to(context, 0.0, 0.0);
		cairo_line_to(context, 0.0, 19.0);
		cairo_curve_to(context, 1.0, 21.0, 2.0, 22.0, 3.0, 22.0);
		cairo_line_to(context, 107.0, 22.0);
		cairo_curve_to(context, 108.0, 22.0, 109.0, 21.0, 110.0, 19.0);
		cairo_line_to(context, 110.0, 0.0);
		cairo_close_path(context);
		cairo_set_source_rgb(context, 0.8, 0.8, 0.8);
		cairo_fill_preserve(context);
		cairo_set_line_width(context, 1.0);
		cairo_set_source_rgb(context, 0.0, 0.0, 0.0);
		cairo_stroke(context);

		cairo_select_font_face(context, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
		cairo_set_font_size(context, 12.0);

		cairo_text_extents_t extents;
		cairo_text_extents(context, DISPLAY_NAME, &extents);
		cairo_move_to(context, 55.0 - ((extents.width / 2.0) + extents.x_bearing),
		              11.0 - ((extents.height / 2.0) + extents.y_bearing));

		cairo_text_path(context, DISPLAY_NAME);
		cairo_set_source_rgb(context, 0.0, 0.0, 0.0);
		cairo_fill(context);

		cairo_destroy(context);

		clutter_box_pack(CLUTTER_BOX(actor_), menu, NULL, NULL);

		ClutterLayoutManager * controls_layout = clutter_box_layout_new();
		clutter_box_layout_set_spacing(CLUTTER_BOX_LAYOUT(controls_layout), 10u);
		ClutterActor * controls = clutter_box_new(controls_layout);
		clutter_actor_add_constraint(controls, clutter_align_constraint_new(clutter_stage_get_default(),
		                             CLUTTER_ALIGN_X_AXIS, 0.95f));
		clutter_actor_add_constraint(controls, clutter_bind_constraint_new(clutter_stage_get_default(),
		                             CLUTTER_BIND_Y, 5.0f));

		fullscreen_button_ = clutter_cairo_texture_new(18, 16);
		clutter_actor_set_reactive(fullscreen_button_, TRUE);
		g_signal_connect(fullscreen_button_, "button-press-event", G_CALLBACK(fullscreen_clicked_cb), this);
		g_signal_connect(fullscreen_button_, "enter-event", G_CALLBACK(actor_highlight_on_cb), fullscreen_button_);
		g_signal_connect(fullscreen_button_, "leave-event", G_CALLBACK(actor_highlight_off_cb), fullscreen_button_);
		clutter_box_pack(CLUTTER_BOX(controls), fullscreen_button_, NULL, NULL);

		close_button_ = clutter_cairo_texture_new(15, 15);

		context = clutter_cairo_texture_create(CLUTTER_CAIRO_TEXTURE(close_button_));

		cairo_move_to(context, 1.0, 3.0);
		cairo_line_to(context, 3.0, 1.0);
		cairo_line_to(context, 8.0, 6.0);
		cairo_line_to(context, 13.0, 1.0);
		cairo_line_to(context, 15.0, 3.0);
		cairo_line_to(context, 10.0, 8.0);
		cairo_line_to(context, 15.0, 13.0);
		cairo_line_to(context, 13.0, 15.0);
		cairo_line_to(context, 8.0, 10.0);
		cairo_line_to(context, 3.0, 15.0);
		cairo_line_to(context, 1.0, 13.0);
		cairo_line_to(context, 6.0, 8.0);
		cairo_close_path(context);
		cairo_set_source_rgb(context, 1.0, 1.0, 1.0);
		cairo_fill_preserve(context);
		cairo_set_line_width(context, 1.0);
		cairo_set_source_rgb(context, 0.0, 0.0, 0.0);
		cairo_stroke(context);

		cairo_destroy(context);

		clutter_actor_set_reactive(close_button_, TRUE);
		g_signal_connect(close_button_, "button-press-event", G_CALLBACK(close_clicked_cb), NULL);
		g_signal_connect(close_button_, "enter-event", G_CALLBACK(actor_highlight_on_cb), close_button_);
		g_signal_connect(close_button_, "leave-event", G_CALLBACK(actor_highlight_off_cb), close_button_);
		clutter_box_pack(CLUTTER_BOX(controls), close_button_, NULL, NULL);

		draw_window_controls();

		clutter_box_pack(CLUTTER_BOX(actor_), controls, NULL, NULL);

		g_signal_connect(clutter_stage_get_default(), "fullscreen", G_CALLBACK(fullscreen_status_changed_cb), this);
		g_signal_connect(clutter_stage_get_default(), "unfullscreen", G_CALLBACK(fullscreen_status_changed_cb), this);
		g_signal_connect(clutter_stage_get_default(), "motion-event", G_CALLBACK(show_panel_cb), this);
	}