Пример #1
0
static void
tick (ClutterTimeline *timeline,
      gint             msecs,
      gpointer         data)
{
    Flower **flowers = data;
    gint i = 0;

    for (i = 0; i < N_FLOWERS; i++)
    {
        flowers[i]->y   += flowers[i]->v;
        flowers[i]->rot += flowers[i]->rv;

        if (flowers[i]->y > (gint) clutter_actor_get_height (stage))
            flowers[i]->y = -clutter_actor_get_height (flowers[i]->ctex);

        clutter_actor_set_position (flowers[i]->ctex,
                                    flowers[i]->x, flowers[i]->y);

        clutter_actor_set_rotation (flowers[i]->ctex,
                                    CLUTTER_Z_AXIS,
                                    flowers[i]->rot,
                                    clutter_actor_get_width (flowers[i]->ctex)/2,
                                    clutter_actor_get_height (flowers[i]->ctex)/2,
                                    0);
    }
}
Пример #2
0
void Platform::windowSizeChanged (ClutterStage * stage, gpointer data)
{
    Platform* pThis = static_cast<Platform*>(data);
    gfloat stageWidth = clutter_actor_get_width (pThis->m_stage);
    gfloat stageHeight = clutter_actor_get_height (pThis->m_stage);
    gfloat videoTextureWidth = clutter_actor_get_width (pThis->m_videoTexture);
    gfloat videoTextureHeight = clutter_actor_get_height (pThis->m_videoTexture);

    gfloat width = stageWidth;
    gfloat height = stageHeight;
    gfloat stageAspectRatio = stageWidth / stageHeight;
    gfloat videoTextureAspectRatio = videoTextureWidth / videoTextureHeight;

    if(videoTextureAspectRatio > stageAspectRatio) {
        height = stageWidth / videoTextureAspectRatio;
    }
    else {
        width = stageHeight * videoTextureAspectRatio;
    }

    g_print("stage: %f, %f\n", stageWidth, stageHeight);
    g_print("video texture: %f, %f\n", videoTextureWidth, videoTextureHeight);
    clutter_actor_set_size (pThis->m_videoTexture, width, height);
//		clutter_actor_set_position (pThis->m_videoTexture, w / 2,h / 2);

    videoTextureWidth = clutter_actor_get_width (pThis->m_videoTexture);
    videoTextureHeight = clutter_actor_get_height (pThis->m_videoTexture);
    g_print("stage: %f, %f\n", stageWidth, stageHeight);
    g_print("video texture: %f, %f\n", videoTextureWidth, videoTextureHeight);
}
static void
show_helper_text_title (CalibArea *area)
{
  ClutterTransition *transition;

  gfloat height = clutter_actor_get_height (area->helper_text_title);
  clutter_actor_set_y (area->helper_text_title,
                       - clutter_actor_get_height (area->helper_text_title));
  clutter_actor_show (area->helper_text_title);

  transition = clutter_property_transition_new ("y");
  clutter_timeline_set_progress_mode (CLUTTER_TIMELINE (transition),
                                      CLUTTER_EASE_OUT);
  clutter_timeline_set_duration (CLUTTER_TIMELINE (transition),
                                 HELP_TEXT_ANIMATION_DURATION);
  clutter_transition_set_animatable (transition,
                                     CLUTTER_ANIMATABLE (area->helper_text_title));
  clutter_transition_set_from (transition, G_TYPE_FLOAT, -height);
  clutter_transition_set_to (transition, G_TYPE_FLOAT, 0.0);

  g_signal_connect (CLUTTER_TIMELINE (transition),
                    "completed",
                    G_CALLBACK (on_helper_text_title_shown),
                    area);

  clutter_timeline_start (CLUTTER_TIMELINE (transition));

  g_clear_object (&area->helper_msg_timeline);
  area->helper_msg_timeline = transition;
}
Пример #4
0
G_MODULE_EXPORT gint
test_texture_quality_main (int argc, char *argv[])
{
  ClutterTimeline  *timeline;
  ClutterAlpha     *alpha;
  ClutterBehaviour *depth_behavior;
  ClutterActor     *stage;
  ClutterActor     *image;
  ClutterColor      stage_color = { 0x12, 0x34, 0x56, 0xff };
  ClutterFog        stage_fog = { 10.0, -50.0 };
  GError           *error;

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  clutter_stage_set_use_fog (CLUTTER_STAGE (stage), TRUE);
  clutter_stage_set_fog (CLUTTER_STAGE (stage), &stage_fog);

  g_signal_connect (stage,
                    "button-press-event", G_CALLBACK (clutter_main_quit),
                    NULL);

  error = NULL;
  image = clutter_texture_new_from_file (argv[1]?argv[1]:"redhand.png", &error);
  if (error)
    g_error ("Unable to load image: %s", error->message);

  if (!argv[1])
    g_print ("Hint: the redhand.png isn't a good test image for this test.\n"
             "This test can take any clutter loadable image as an argument\n");

  /* center the image */
  clutter_actor_set_position (image, 
    (clutter_actor_get_width (stage) - clutter_actor_get_width (image))/2,
    (clutter_actor_get_height (stage) - clutter_actor_get_height (image))/2);
  clutter_container_add (CLUTTER_CONTAINER (stage), image, NULL);

  timeline = clutter_timeline_new (5000);
  g_signal_connect (timeline,
                    "completed", G_CALLBACK (timeline_completed),
                    NULL);

  alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);
  depth_behavior = clutter_behaviour_depth_new (alpha, -2500, 400);
  clutter_behaviour_apply (depth_behavior, image);

  clutter_actor_show (stage);
  clutter_timeline_start (timeline);

  g_timeout_add (10000, change_filter, image);

  clutter_main ();

  g_object_unref (depth_behavior);
  g_object_unref (timeline);

  return EXIT_SUCCESS;
}
Пример #5
0
G_MODULE_EXPORT int
test_clip_main (int argc, char **argv)
{
  CallbackData data;
  ClutterActor *stub_actor, *label;
  gchar *file;

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

  data.current_clip.type = CLIP_NONE;
  data.clips = NULL;

  data.stage = clutter_stage_new ();
  clutter_stage_set_title (CLUTTER_STAGE (data.stage), "Clipping");
  g_signal_connect (data.stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  stub_actor = clutter_rectangle_new ();
  clutter_container_add (CLUTTER_CONTAINER (data.stage), stub_actor, NULL);

  file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
  data.hand = cogl_texture_new_from_file (file,
                                          COGL_TEXTURE_NONE,
                                          COGL_PIXEL_FORMAT_ANY,
                                          NULL);
  g_free (file);

  label = clutter_text_new_with_text ("Sans 12px", instructions);
  clutter_text_set_line_wrap (CLUTTER_TEXT (label), TRUE);
  clutter_actor_set_width (label, clutter_actor_get_width (data.stage) - 310);
  clutter_actor_set_y (label,
                       clutter_actor_get_height (data.stage)
                       - clutter_actor_get_height (label));
  clutter_container_add (CLUTTER_CONTAINER (data.stage), label, NULL);

  g_signal_connect (stub_actor, "paint", G_CALLBACK (on_paint), &data);

  g_signal_connect (data.stage, "button-press-event",
                    G_CALLBACK (on_button_press), &data);
  g_signal_connect (data.stage, "button-release-event",
                    G_CALLBACK (on_button_release), &data);
  g_signal_connect (data.stage, "motion-event",
                    G_CALLBACK (on_motion), &data);
  g_signal_connect (data.stage, "key-press-event",
                    G_CALLBACK (on_key_press), &data);

  clutter_actor_show (data.stage);

  clutter_main ();

  cogl_handle_unref (data.hand);

  free_clips (&data);

  return 0;
}
Пример #6
0
static void
size_change (ClutterStage * stage, UserInterface * ui)
{
  gfloat stage_width, stage_height;
  gfloat new_width, new_height;
  gfloat media_width, media_height;
  gfloat stage_ar, media_ar;

  media_width = clutter_actor_get_width (ui->texture);
  media_height = clutter_actor_get_height (ui->texture);

  stage_width = clutter_actor_get_width (ui->stage);
  stage_height = clutter_actor_get_height (ui->stage);

  ui->stage_width = stage_width;
  ui->stage_height = stage_height;

  stage_ar = stage_width / stage_height;

  new_width = stage_width;
  new_height = stage_height;

  if (media_height > 0.0f && media_width > 0.0f) {
    /* if we're rotated, the media_width and media_height are swapped */
    if (ui->rotated) {
      media_ar = media_height / media_width;
    } else {
      media_ar = media_width / media_height;
    }

    /* calculate new width and height
     * note: when we're done, new_width/new_height should equal media_ar */
    if (media_ar > stage_ar) {
      /* media has wider aspect than stage so use new width as stage width and
       * scale down height */
      new_height = stage_width / media_ar;
    } else {
      new_width = stage_height * media_ar;
    }
  } else {
    g_debug ("Warning: not considering texture dimensions %fx%f\n", media_width,
        media_height);
  }

  clutter_actor_set_size (CLUTTER_ACTOR (ui->texture), new_width, new_height);
  clutter_actor_set_position (CLUTTER_ACTOR (ui->texture), stage_width / 2,
      stage_height / 2);

  update_controls_size (ui);
  center_controls (ui);
  progress_timing (ui);
}
Пример #7
0
static void _lambda46_ (GObject* _self_, GParamSpec* pspec, EaseSelectionRectangle* self) {
#line 58 "ease-selection-rectangle.vala"
	g_return_if_fail (_self_ != NULL);
#line 58 "ease-selection-rectangle.vala"
	g_return_if_fail (pspec != NULL);
#line 59 "ease-selection-rectangle.vala"
	clutter_actor_set_height ((ClutterActor*) self->priv->left, clutter_actor_get_height ((ClutterActor*) self));
#line 60 "ease-selection-rectangle.vala"
	clutter_actor_set_height ((ClutterActor*) self->priv->right, clutter_actor_get_height ((ClutterActor*) self));
#line 61 "ease-selection-rectangle.vala"
	clutter_actor_set_y ((ClutterActor*) self->priv->bottom, clutter_actor_get_height ((ClutterActor*) self));
#line 115 "ease-selection-rectangle.c"
}
Пример #8
0
/* rotation */
void
on_new_frame (ClutterTimeline * timeline, gint frame_num, gpointer data)
{
  ClutterActor *rect_actor = CLUTTER_ACTOR (data);
  ClutterActor *texture_actor =
      g_object_get_data (G_OBJECT (timeline), "texture_actor");

  clutter_actor_set_rotation (rect_actor, CLUTTER_Z_AXIS, (gdouble) frame_num,
      clutter_actor_get_width (rect_actor) / 2,
      clutter_actor_get_height (rect_actor) / 2, 0);

  clutter_actor_set_rotation (texture_actor, CLUTTER_Z_AXIS,
      (gdouble) frame_num, clutter_actor_get_width (texture_actor) / 6,
      clutter_actor_get_height (texture_actor) / 6, 0);
}
Пример #9
0
/* MexScrollableContainerInterface */
static void
mex_column_get_allocation (MexScrollableContainer *self,
                           ClutterActor           *child,
                           ClutterActorBox        *box)
{
  MexColumnPrivate *priv = MEX_COLUMN (self)->priv;
  gfloat width, height;
  gfloat child_height;
  gint i;

  box->y1 = 0;

  if (!priv->children)
    return;

  child_height = clutter_actor_get_height (priv->children->data);
  i = g_list_index (priv->children, child);

  if (i >= 0)
    box->y1 += child_height * i;

  clutter_actor_get_size (child, &width, &height);

  box->x1 = 0;
  box->x2 = width;
  box->y2 = box->y1 + height;
}
Пример #10
0
void clarity_cover_set_album_item (ClarityCover *self, AlbumItem *item) {
    g_return_if_fail(CLARITY_IS_COVER(self));

    ClarityCoverPrivate *priv = CLARITY_COVER_GET_PRIVATE (self);
    g_return_if_fail(priv);

    GError *error = NULL;
    gint y_offset;

    if (!priv->texture) {
        priv->texture = gtk_clutter_texture_new();
        clutter_container_add_actor(CLUTTER_CONTAINER(self), priv->texture);
    }

    // Set cover artwork
    gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE(priv->texture), item->albumart, &error);
    if (error) {
        g_warning("%s", error->message);
        g_error_free(error);
        return;
    }

    // Add reflection
    if (! priv->reflection) {
        y_offset = clutter_actor_get_height (priv->texture) + V_PADDING;

        priv->reflection = clutter_clone_new (priv->texture);
        clutter_actor_add_constraint (priv->reflection, clutter_bind_constraint_new (priv->texture, CLUTTER_BIND_X, 0.0));
        clutter_actor_add_constraint (priv->reflection, clutter_bind_constraint_new (priv->texture, CLUTTER_BIND_Y, y_offset));
        clutter_actor_add_constraint (priv->reflection, clutter_bind_constraint_new (priv->texture, CLUTTER_BIND_WIDTH, 0.0));
        clutter_actor_add_constraint (priv->reflection, clutter_bind_constraint_new (priv->texture, CLUTTER_BIND_HEIGHT, 0.0));
        g_signal_connect (priv->reflection,
                       "paint",
                       G_CALLBACK (_clone_paint_cb),
                       NULL);

        clutter_container_add_actor(CLUTTER_CONTAINER(self), priv->reflection);
    }

    ClutterActorBox box;
    gfloat w, h;
    clutter_actor_get_allocation_box (priv->texture, &box);
    clutter_actor_box_get_size (&box, &w, &h);

    if( h > DEFAULT_IMG_SIZE) {
        gfloat temp = w * DEFAULT_IMG_SIZE / h;
        clutter_actor_set_size(priv->texture, temp, DEFAULT_IMG_SIZE);
    }

    // Add title / artist data
    if (priv->title)
        g_free(priv->title);

    priv->title = g_strdup(item->albumname);

    if (priv->artist)
            g_free(priv->artist);

    priv->artist = g_strdup(item->artist);
}
Пример #11
0
/* Get preferred width/height */
static void _xfdashboard_stage_interface_get_preferred_height(ClutterActor *inActor,
																gfloat inForWidth,
																gfloat *outMinHeight,
																gfloat *outNaturalHeight)
{
	XfdashboardStageInterface			*self=XFDASHBOARD_STAGE_INTERFACE(inActor);
	XfdashboardStageInterfacePrivate	*priv=self->priv;
	gfloat								minHeight, naturalHeight;
	gint								h;
	ClutterActor						 *stage;

	/* Set up default values */
	minHeight=naturalHeight=0.0f;

	/* Get monitor size if available otherwise get stage size */
	if(priv->monitor)
	{
		xfdashboard_window_tracker_monitor_get_geometry(priv->monitor, NULL, NULL, NULL, &h);
		minHeight=naturalHeight=h;
	}
		else
		{
			stage=clutter_actor_get_stage(inActor);
			minHeight=naturalHeight=clutter_actor_get_height(stage);
		}

	/* Store sizes computed */
	if(outMinHeight) *outMinHeight=minHeight;
	if(outNaturalHeight) *outNaturalHeight=naturalHeight;
}
Пример #12
0
ClutterActor *
make_source (void)
{
  ClutterActor *source, *actor;
  GError *error = NULL;
  gchar *file;

  ClutterColor  yellow = {0xff, 0xff, 0x00, 0xff};

  source  = clutter_group_new ();

  file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
  actor = clutter_texture_new_from_file (file, &error);
  if (!actor)
    g_error("pixbuf load failed: %s", error ? error->message : "Unknown");

  g_free (file);

  clutter_group_add (source, actor);

  actor = clutter_text_new_with_text ("Sans Bold 50px", "Clutter");

  clutter_text_set_color (CLUTTER_TEXT (actor), &yellow);
  clutter_actor_set_y (actor, clutter_actor_get_height(source) + 5);
  clutter_group_add (source, actor);

  return source;
}
Пример #13
0
G_MODULE_EXPORT int
test_fullscreen_main (int argc, char *argv[])
{
  ClutterActor *stage;

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  g_signal_connect (stage,
                    "fullscreen", G_CALLBACK (on_fullscreen),
                    NULL);
  g_signal_connect (stage,
                    "unfullscreen", G_CALLBACK (on_unfullscreen),
                    NULL);

  clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), TRUE);
  clutter_actor_show (stage);

  g_debug ("stage size: %.2fx%.2f, mapped: %s",
           clutter_actor_get_width (stage),
           clutter_actor_get_height (stage),
           CLUTTER_ACTOR_IS_MAPPED (stage) ? "true" : "false");

  g_timeout_add (1000, toggle_fullscreen, NULL);

  clutter_main ();

  return EXIT_SUCCESS;
}
Пример #14
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);
}
Пример #15
0
static void
_resize_alpha (ClutterBehaviour *behave, 
               guint32           alpha,
               AstroContactRow  *row)
{
  AstroContactRowPrivate *priv;
  gfloat factor;
  gint dest_height = ROW_HEIGHT;
  gint current_height, diff_height;

  g_return_if_fail (ASTRO_IS_CONTACT_ROW (row));
  priv = row->priv;

  factor = (gfloat)alpha/CLUTTER_ALPHA_MAX_ALPHA;

  if (priv->active)
    dest_height = (ROW_HEIGHT * 2) + PADDING;

  current_height = clutter_actor_get_height (priv->bg);

  if (current_height > dest_height)
    diff_height = (current_height - dest_height) * -1;
  else
    diff_height = dest_height - current_height;

  clutter_actor_set_height (priv->bg, 
            current_height + ((diff_height * alpha)/CLUTTER_ALPHA_MAX_ALPHA));
} 
Пример #16
0
void
opt_show_add_slide (OptShow *self, OptSlide *slide)
{
  ClutterActor   *bg, *stage;

  self->priv->slides = g_list_append(self->priv->slides, slide);
  self->priv->num_slides++;

  stage = clutter_stage_get_default();

  bg = CLUTTER_ACTOR(opt_slide_get_background_texture (slide));

  if (bg == NULL)
    bg = clutter_clone_new(self->priv->bg);

  clutter_actor_set_size (bg, 
                          clutter_actor_get_width (stage),
                          clutter_actor_get_height (stage));
  

  clutter_group_add (CLUTTER_GROUP(slide), bg);

  clutter_actor_lower_bottom(bg);
  clutter_actor_show(bg);

  opt_menu_add_slide (self->priv->menu, slide);
}
Пример #17
0
static void
art_cb (RBExtDBKey *key, const char *filename, GValue *data, MxFrame *frame)
{
    ClutterActor *image;
    GdkPixbuf *pixbuf;

    if (data == NULL || G_VALUE_HOLDS (data, GDK_TYPE_PIXBUF) == FALSE) {
        return;
    }

    clutter_threads_enter ();

    image = gtk_clutter_texture_new ();
    pixbuf = GDK_PIXBUF (g_value_get_object (data));
    gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (image), pixbuf, NULL);
    if (clutter_actor_get_height (image) > MAX_IMAGE_HEIGHT) {
        clutter_actor_set_height (image, MAX_IMAGE_HEIGHT);
        clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (image), TRUE);
    }
    if (clutter_actor_get_width (image) > MAX_IMAGE_HEIGHT) {
        clutter_actor_set_width (image, MAX_IMAGE_HEIGHT);
    }
    mx_bin_set_child (MX_BIN (frame), image);
    clutter_actor_show_all (CLUTTER_ACTOR (frame));

    clutter_threads_leave ();
}
static gboolean
on_fullscreen (GtkWindow           *window,
               GdkEventWindowState *event,
               CalibArea           *area)
{
  ClutterRect rect;

  if ((event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) == 0)
    return FALSE;

  /* Protect against window state multiple changes*/
  if (CLUTTER_ACTOR_IS_VISIBLE (area->action_layer))
    return FALSE;

  clutter_actor_show (area->action_layer);
  clutter_actor_show (area->clock);

  rect.origin.x = 0;
  rect.origin.y = 0;
  clutter_actor_get_size (area->helper_text_title,
                          &rect.size.width,
                          &rect.size.height);
  g_object_set (area->text_title_holder, "clip-rect", &rect, NULL);

  clutter_actor_get_size (area->helper_text_body,
                          &rect.size.width,
                          &rect.size.height);
  g_object_set (area->text_body_holder, "clip-rect", &rect, NULL);
  clutter_actor_set_y (area->helper_text_body,
                       - clutter_actor_get_height (area->helper_text_body));

  show_helper_text_title (area);
  return FALSE;
}
Пример #19
0
/* Dump actors */
static void _xfdashboard_dump_actor_internal(ClutterActor *inActor, gint inLevel)
{
	ClutterActorIter	iter;
	ClutterActor		*child;
	gint				i;

	g_return_if_fail(CLUTTER_IS_ACTOR(inActor));
	g_return_if_fail(inLevel>=0);

	clutter_actor_iter_init(&iter, CLUTTER_ACTOR(inActor));
	while(clutter_actor_iter_next(&iter, &child))
	{
		for(i=0; i<inLevel; i++) g_print("  ");
		g_print("+- %s@%p - name: %s - geometry: %.2f,%.2f [%.2fx%.2f], mapped: %s, visible: %s, children: %d\n",
					G_OBJECT_TYPE_NAME(child), child,
					clutter_actor_get_name(child),
					clutter_actor_get_x(child),
					clutter_actor_get_y(child),
					clutter_actor_get_width(child),
					clutter_actor_get_height(child),
					clutter_actor_is_mapped(child) ? "yes" : "no",
					clutter_actor_is_visible(child) ? "yes" : "no",
					clutter_actor_get_n_children(child));
		if(clutter_actor_get_n_children(child)>0) _xfdashboard_dump_actor_internal(child, inLevel+1);
	}
}
/* Timeline handler */
void
frame_cb (ClutterTimeline *timeline, 
	  gint             msecs,
	  gpointer         data)
{
  SuperOH        *oh = (SuperOH *)data;
  gint            i;
  guint           rotation = clutter_timeline_get_progress (timeline) * 360.0f;

  /* Rotate everything clockwise about stage center*/
  clutter_actor_set_rotation (CLUTTER_ACTOR (oh->group),
                              CLUTTER_Z_AXIS,
                              rotation,
                              WINWIDTH / 2, WINHEIGHT / 2, 0);

  for (i = 0; i < NHANDS; i++)
    {
      /* rotate each hand around there centers */
      clutter_actor_set_rotation (oh->hand[i],
                                  CLUTTER_Z_AXIS,
                                  - 6.0 * rotation,
                                  clutter_actor_get_width (oh->hand[i]) / 2,
                                  clutter_actor_get_height (oh->hand[i]) / 2,
                                  0);
      if (fade == TRUE)
        clutter_actor_set_opacity (oh->hand[i], (255 - (rotation % 255)));
    }
}
Пример #21
0
G_MODULE_EXPORT int
test_animation_main (int argc, char *argv[])
{
  ClutterActor *stage, *rect;
  ClutterColor stage_color = { 0x66, 0x66, 0xdd, 0xff };
  ClutterColor rect_color = { 0x44, 0xdd, 0x44, 0xff };
  ClutterAction *action;

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

  stage = clutter_stage_get_default ();
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

  rect = clutter_rectangle_new_with_color (&rect_color);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect);
  clutter_actor_set_size (rect, 50, 50);
  clutter_actor_set_anchor_point (rect, 25, 25);
  clutter_actor_set_position (rect,
                              clutter_actor_get_width (stage) / 2,
                              clutter_actor_get_height (stage) / 2);
  clutter_actor_set_opacity (rect, 0x88);
  clutter_actor_set_reactive (rect, TRUE);

  action = clutter_click_action_new ();
  g_signal_connect (action, "clicked", G_CALLBACK (on_clicked), NULL);
  clutter_actor_add_action_with_name (rect, "click", action);

  clutter_actor_show (stage);

  clutter_main ();

  return EXIT_SUCCESS;
}
static void
mpl_panel_background_get_preferred_height (ClutterActor *self,
                                           gfloat        for_width,
                                           gfloat       *min_height_p,
                                           gfloat       *natural_height_p)
{
  MplPanelBackgroundPrivate *priv = MPL_PANEL_BACKGROUND (self)->priv;
  ClutterActor              *stage = clutter_actor_get_stage (self);
  gfloat                     height = 0.0;

  /*
   * This is as good place to hook the ClutterStage::allocation callback as any.
   */
  if (!priv->stage_alloc_cb)
    {
      priv->stage = stage;

      priv->stage_alloc_cb =
        g_signal_connect (stage, "notify::allocation",
                          G_CALLBACK (mpl_panel_background_stage_allocation_cb),
                          self);
    }

  height = clutter_actor_get_height (stage);

  if (min_height_p)
    *min_height_p = height;

  if (natural_height_p)
    *natural_height_p = height;
}
Пример #23
0
/* GObject stuff */
static void
astro_applet_paint (ClutterActor *applet)
{
  AstroAppletPrivate *priv;
  GList *c;
  gint width = 0;

  g_return_if_fail (ASTRO_IS_APPLET (applet));
  priv = ASTRO_APPLET (applet)->priv;
  
  c = clutter_container_get_children (CLUTTER_CONTAINER (applet));
  
  for (c = c; c; c = c->next)
    {
      gint total = clutter_actor_get_y (c->data) + 
                   clutter_actor_get_width (c->data);
      if (total > width && c->data != priv->texture)
        width = total;
    }
  
  clutter_actor_set_size (priv->texture,
                          width,
                          clutter_actor_get_height (applet));

   c = clutter_container_get_children (CLUTTER_CONTAINER (applet));
   for (c = c; c; c = c->next)
    clutter_actor_paint (c->data);
    
}
Пример #24
0
void
clutter_input_device_evdev_translate_coordinates (ClutterInputDevice *device,
                                                  ClutterStage       *stage,
                                                  gfloat             *x,
                                                  gfloat             *y)
{
  ClutterInputDeviceEvdev *device_evdev = CLUTTER_INPUT_DEVICE_EVDEV (device);
  double min_x = 0, min_y = 0, max_x = 1, max_y = 1;
  gdouble stage_width, stage_height;
  double x_d, y_d;

  stage_width = clutter_actor_get_width (CLUTTER_ACTOR (stage));
  stage_height = clutter_actor_get_height (CLUTTER_ACTOR (stage));
  x_d = *x / stage_width;
  y_d = *y / stage_height;

  /* Apply aspect ratio */
  if (device_evdev->output_ratio > 0 &&
      device_evdev->device_aspect_ratio > 0)
    {
      gdouble ratio = device_evdev->device_aspect_ratio / device_evdev->output_ratio;

      if (ratio > 1)
        x_d *= ratio;
      else if (ratio < 1)
        y_d *= 1 / ratio;
    }

  cairo_matrix_transform_point (&device_evdev->device_matrix, &min_x, &min_y);
  cairo_matrix_transform_point (&device_evdev->device_matrix, &max_x, &max_y);
  cairo_matrix_transform_point (&device_evdev->device_matrix, &x_d, &y_d);

  *x = CLAMP (x_d, MIN (min_x, max_x), MAX (min_x, max_x)) * stage_width;
  *y = CLAMP (y_d, MIN (min_y, max_y), MAX (min_y, max_y)) * stage_height;
}
Пример #25
0
static gboolean
mex_player_set_controls_visible (MexPlayer *player,
                                 gboolean   visible)
{
  MexPlayerPrivate *priv = player->priv;
  gfloat pos;
  ClutterStage *stage;
  MxFocusManager *fmanager;

  stage = (ClutterStage*) clutter_actor_get_stage (CLUTTER_ACTOR (player));
  fmanager = mx_focus_manager_get_for_stage (stage);

  pos = clutter_actor_get_height (priv->controls);
  if (visible)
    {
      priv->controls_prev_visible = FALSE;
      priv->controls_visible = TRUE;

      mx_widget_set_disabled (MX_WIDGET (priv->controls), FALSE);

      clutter_actor_animate (priv->controls, CLUTTER_EASE_IN_SINE, 250,
                             "opacity", 0xff,
                             "anchor-y", 0.0,
                             NULL);

      mex_player_restart_timer (player);

      if (priv->related_tile)
        {
          mx_focus_manager_push_focus_with_hint (fmanager,
                                                 MX_FOCUSABLE (priv->related_tile),
                                                 MX_FOCUS_HINT_PRIOR);

          g_object_unref (priv->related_tile);
          priv->related_tile = NULL;
        }
      else
        {
          mx_focus_manager_push_focus (fmanager, MX_FOCUSABLE (priv->controls));
        }
    }

  if (!visible)
    {
      priv->controls_visible = FALSE;
      clutter_actor_animate (priv->controls, CLUTTER_EASE_IN_SINE, 250,
                             "opacity", 0x00,
                             "anchor-y", -pos,
                             NULL);

      if (priv->hide_controls_source)
        {
          g_source_remove (priv->hide_controls_source);
          priv->hide_controls_source = 0;
        }
    }

  return TRUE;
}
Пример #26
0
G_MODULE_EXPORT int
test_fbo_main (int argc, char *argv[])
{
  ClutterColor      blue   = {0x33, 0x44, 0x55, 0xff};

  ClutterActor     *fbo;
  ClutterActor     *onscreen_source;
  ClutterActor     *stage;
  ClutterAnimation *animation;
  int               x_pos = 200;
  int               y_pos = 100;

  clutter_init (&argc, &argv);

  if (clutter_feature_available (CLUTTER_FEATURE_OFFSCREEN) == FALSE)
    g_error("This test requires CLUTTER_FEATURE_OFFSCREEN");

  stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &blue);

  /* Create the first source */
  onscreen_source = make_source();
  clutter_actor_show_all (onscreen_source);
  clutter_group_add (stage, onscreen_source);

  y_pos = (STAGE_HEIGHT/2.0) -
          (clutter_actor_get_height (onscreen_source)/2.0);
  clutter_actor_set_position (onscreen_source, x_pos, y_pos);
  x_pos += clutter_actor_get_width (onscreen_source);

  animation = clutter_actor_animate (onscreen_source,
                                     CLUTTER_LINEAR,
                                     5000, /* 1 second duration */
                                     "rotation-angle-y", 360.0f,
                                     NULL);
  clutter_animation_set_loop (animation, TRUE);

  /* Second hand = actor from onscreen_source */
  if ((fbo = clutter_texture_new_from_actor (onscreen_source)) == NULL)
    g_error("onscreen fbo creation failed");

  clutter_actor_set_position (fbo, x_pos, y_pos);
  x_pos += clutter_actor_get_width (fbo);
  clutter_group_add (stage, fbo);

  /* Third hand = actor from Second hand */
  if ((fbo = clutter_texture_new_from_actor (fbo)) == NULL)
    g_error("fbo from fbo creation failed");

  clutter_actor_set_position (fbo, x_pos, y_pos);
  x_pos += clutter_actor_get_width (fbo);
  clutter_group_add (stage, fbo);

  clutter_actor_show_all (stage);
  clutter_main ();

  return 0;
}
Пример #27
0
static void
on_unfullscreen (ClutterStage *stage)
{
  g_debug ("fullscreen unset, size: %.2fx%.2f, mapped: %s",
           clutter_actor_get_width (CLUTTER_ACTOR (stage)),
           clutter_actor_get_height (CLUTTER_ACTOR (stage)),
           CLUTTER_ACTOR_IS_MAPPED (stage) ? "true" : "false");
}
Пример #28
0
static void
move_slider (StScrollBar *bar,
             gfloat       x,
             gfloat       y)
{
  StScrollBarPrivate *priv = bar->priv;
  gdouble position, lower, upper, page_size;
  gfloat ux, uy, pos, size;

  if (!priv->adjustment)
    return;

  if (!clutter_actor_transform_stage_point (priv->trough, x, y, &ux, &uy))
    return;

  if (priv->vertical)
    size = clutter_actor_get_height (priv->trough)
           - clutter_actor_get_height (priv->handle);
  else
    size = clutter_actor_get_width (priv->trough)
           - clutter_actor_get_width (priv->handle);

  if (size == 0)
    return;

  if (priv->vertical)
    pos = uy - priv->y_origin;
  else
    pos = ux - priv->x_origin;
  pos = CLAMP (pos, 0, size);

  st_adjustment_get_values (priv->adjustment,
                            NULL,
                            &lower,
                            &upper,
                            NULL,
                            NULL,
                            &page_size);

  position = ((pos / size)
              * (upper - lower - page_size))
             + lower;

  st_adjustment_set_value (priv->adjustment, position);
}
Пример #29
0
static void
paint_circle (ClutterActor *actor)
{
  gfloat radius = MIN (clutter_actor_get_width (actor),
                       clutter_actor_get_height (actor)) / 2.f;
  cogl_set_source_color4ub (0xff, 0xff, 0xff, 0xff);
  cogl_path_arc (radius, radius, radius, radius, 0, 360);
  cogl_path_fill ();
}
Пример #30
0
static void overview_animated_destroy(MosesOverview* self, MosesOverviewQuitReason reason, gboolean animate)
{
    MosesOverviewPrivate* priv = self->priv;

    gboolean just_destroy = !animate;
    if (reason == MOSES_OV_REASON_ACTIVATE_WINDOW && !priv->selected_actor) {
        just_destroy = TRUE;
    } else if (reason == MOSES_OV_REASON_ACTIVATE_WORKSPACE && !priv->selected_workspace) {
        just_destroy = TRUE;
    } else if (reason == MOSES_OV_REASON_NORMAL) {
        just_destroy = TRUE;
    }

    if (just_destroy) {
        clutter_actor_destroy(CLUTTER_ACTOR(self));
        return;
    }

    gfloat x, y, w, h;
    ClutterActor* target = NULL;

    if (reason == MOSES_OV_REASON_ACTIVATE_WINDOW) {
        target = self->priv->selected_actor;

        ClutterActor* orig = clutter_clone_get_source(CLUTTER_CLONE(target));
        clutter_actor_get_position(orig, &x, &y);
        clutter_actor_get_size(orig, &w, &h);
        g_signal_handlers_disconnect_by_func(target, on_effect_complete, self);

    } else if (reason == MOSES_OV_REASON_ACTIVATE_WORKSPACE) {
        g_assert(priv->selected_actor == NULL);

        MetaScreen* screen = meta_plugin_get_screen(priv->plugin);
        target = overview_head_get_actor_for_workspace(priv->ov_head, priv->selected_workspace);

        MetaRectangle geom;
        int focused_monitor = meta_screen_get_current_monitor(screen);
        meta_screen_get_monitor_geometry(screen, focused_monitor, &geom);
        x = geom.x, y = geom.y, w = geom.width, h = geom.height;
    }

    if (target) {
        clutter_actor_remove_all_transitions(target);
        clutter_actor_set_child_above_sibling(clutter_actor_get_parent(target), target, NULL);

        clutter_actor_save_easing_state(target);
        clutter_actor_set_easing_mode(target, CLUTTER_LINEAR);
        clutter_actor_set_easing_duration(target, 150);

        clutter_actor_set_position(target, x, y);
        clutter_actor_set_scale(target, w / clutter_actor_get_width(target),
                h / clutter_actor_get_height(target));
        clutter_actor_restore_easing_state(target);
        g_object_connect(target, "signal::transitions-completed",
                G_CALLBACK(on_restore_position_effect_complete), self, NULL);
    }
}