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); }
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; }
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; }
static void meta_switcher_present_list(MetaSwitcher* self) { MetaSwitcherPrivate* priv = self->priv; MetaScreen* screen = meta_plugin_get_screen(priv->plugin); MetaDisplay* display = meta_screen_get_display(screen); // windows on all workspaces GList* ls = meta_display_get_tab_list(display, META_TAB_LIST_NORMAL, NULL); if (!ls) return; GList* ws_list = meta_screen_get_workspaces(screen); g_list_foreach(ws_list, (GFunc)hook_ws_event, self); if (!priv->apps) { priv->apps = g_ptr_array_new(); GList* orig = ls; while (ls) { g_ptr_array_add(priv->apps, ls->data); ls = ls->next; } g_list_free(orig); } clutter_actor_set_height(priv->top, APP_ACTOR_HEIGHT + 20); gint x = 0, y = 0; for (int i = 0; i < priv->apps->len; i++) { _add_app(self, g_ptr_array_index(priv->apps, i), &x, &y); } clutter_actor_set_margin_left(g_hash_table_lookup(priv->icons, g_ptr_array_index(priv->apps, 0)), 10); clutter_actor_set_margin_right(g_hash_table_lookup(priv->icons, g_ptr_array_index(priv->apps, priv->apps->len-1)), 10); gint screen_width = 0, screen_height = 0; meta_screen_get_size(screen, &screen_width, &screen_height); /* TODO: @sonald set top width when bigger than screen width */ if (clutter_actor_get_width(priv->top) > screen_width) clutter_actor_set_width(priv->top, screen_width); gfloat w = clutter_actor_get_width(priv->top), h = clutter_actor_get_height(priv->top), tx = (screen_width - w) / 2, ty = (screen_height - h) / 2; #if DEBUG g_message("%s, line %d, %f %f", __func__, __LINE__, w, tx); #endif clutter_actor_set_position(priv->top, tx, ty); ClutterContent* canvas = clutter_canvas_new(); clutter_canvas_set_size(CLUTTER_CANVAS(canvas), w, h); clutter_actor_set_content(priv->top, canvas); g_object_unref(canvas); g_signal_connect(canvas, "draw", G_CALLBACK(on_switcher_background_draw), self); clutter_content_invalidate(canvas); priv->selected_id = 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); }
static void _lambda45_ (GObject* _self_, GParamSpec* pspec, EaseSelectionRectangle* self) { #line 52 "ease-selection-rectangle.vala" g_return_if_fail (_self_ != NULL); #line 52 "ease-selection-rectangle.vala" g_return_if_fail (pspec != NULL); #line 53 "ease-selection-rectangle.vala" clutter_actor_set_width ((ClutterActor*) self->priv->top, clutter_actor_get_width ((ClutterActor*) self)); #line 54 "ease-selection-rectangle.vala" clutter_actor_set_width ((ClutterActor*) self->priv->bottom, clutter_actor_get_width ((ClutterActor*) self)); #line 55 "ease-selection-rectangle.vala" clutter_actor_set_x ((ClutterActor*) self->priv->right, clutter_actor_get_width ((ClutterActor*) self)); #line 92 "ease-selection-rectangle.c" }
static void astro_systray_init (AstroSystray *systray) { AstroSystrayPrivate *priv; GdkPixbuf *pixbuf; ClutterColor white = { 0xff, 0xff, 0xff, 0xff }; gint width; gchar *font; priv = systray->priv = ASTRO_SYSTRAY_GET_PRIVATE (systray); pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR"/icons/bt.png", NULL); if (pixbuf) { priv->bt = clutter_texture_new_from_pixbuf (pixbuf); clutter_container_add_actor (CLUTTER_CONTAINER (systray), priv->bt); clutter_actor_set_anchor_point_from_gravity (priv->bt, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (priv->bt, 0, ASTRO_PANEL_HEIGHT ()/2); } pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR"/icons/nm.png", NULL); if (pixbuf) { priv->nm = clutter_texture_new_from_pixbuf (pixbuf); clutter_container_add_actor (CLUTTER_CONTAINER (systray), priv->nm); clutter_actor_set_anchor_point_from_gravity (priv->nm, CLUTTER_GRAVITY_WEST); clutter_actor_set_position (priv->nm, clutter_actor_get_width (priv->bt) + PADDING, ASTRO_PANEL_HEIGHT () /2); } width = clutter_actor_get_width (CLUTTER_ACTOR (systray)); /* Time date */ font = g_strdup_printf ("Sans %d", (int)(ASTRO_PANEL_HEIGHT () * 0.2)); priv->time = clutter_label_new_full (font, " ", &white); clutter_label_set_line_wrap (CLUTTER_LABEL (priv->time), FALSE); clutter_container_add_actor (CLUTTER_CONTAINER (systray), priv->time); clutter_actor_set_anchor_point_from_gravity (priv->time,CLUTTER_GRAVITY_WEST); set_time (systray); clutter_actor_set_position (priv->time, width + PADDING, ASTRO_PANEL_HEIGHT ()/2); g_timeout_add (1000, (GSourceFunc)set_time, systray); g_free (font); clutter_actor_show_all (CLUTTER_ACTOR (systray)); }
/* 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); }
/* 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); } }
void clarity_cover_set_rotation_behaviour(ClarityCover *self, ClutterAlpha *alpha, int final_angle, ClutterRotateDirection direction) { g_return_if_fail(CLARITY_IS_COVER(self)); double current = clutter_actor_get_rotation(CLUTTER_ACTOR(self), CLUTTER_Y_AXIS, 0, 0, 0); if(current < 0) current += 360; else if(current > 360) current -= 360; if(current != final_angle) { self->priv->rotateBehaviour = clutter_behaviour_rotate_new ( alpha, CLUTTER_Y_AXIS, direction , current, final_angle); clutter_behaviour_rotate_set_center( CLUTTER_BEHAVIOUR_ROTATE(self->priv->rotateBehaviour), clutter_actor_get_width(CLUTTER_ACTOR(self)) / 2, 0, 0); clutter_behaviour_apply (self->priv->rotateBehaviour, CLUTTER_ACTOR(self)); } }
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); } }
static void astro_appview_show (ClutterActor *view) { AstroAppviewPrivate *priv; static ClutterTimeline *show_time = NULL; g_return_if_fail (ASTRO_IS_APPVIEW (view)); priv = ASTRO_APPVIEW (view)->priv; if (CLUTTER_IS_TIMELINE (show_time) &&clutter_timeline_is_playing (show_time)) { clutter_timeline_stop (show_time); g_object_unref (show_time); } clutter_actor_set_x (view, -1* clutter_actor_get_width (view)); CLUTTER_ACTOR_CLASS (astro_appview_parent_class)->show (view); show_time = clutter_effect_move (priv->show_temp, CLUTTER_ACTOR (view), (CSW()/2)- (priv->active * ASTRO_APPICON_SPACING()), clutter_actor_get_y (CLUTTER_ACTOR (view)), NULL, NULL); g_signal_connect (show_time, "new-frame", G_CALLBACK (on_move_timeline_new_frame), view); }
static void shader_paint (ClutterEffect *effect, ClutterEffectPaintFlags flags) { ClutterShaderEffect *shader = CLUTTER_SHADER_EFFECT (effect); float tex_width; ClutterActor *actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect)); if (g_test_verbose ()) g_debug ("shader_paint"); clutter_shader_effect_set_shader_source (shader, "uniform sampler2D tex;\n" "uniform float step;\n" "void main (void)\n" "{\n" " gl_FragColor = texture2D(tex, vec2 (gl_TexCoord[0].s + step,\n" " gl_TexCoord[0].t));\n" "}\n"); tex_width = clutter_actor_get_width (actor); clutter_shader_effect_set_uniform (shader, "tex", G_TYPE_INT, 1, 0); clutter_shader_effect_set_uniform (shader, "step", G_TYPE_FLOAT, 1, SHIFT_STEP / tex_width); CLUTTER_EFFECT_CLASS (shift_effect_parent_class)->paint (effect, flags); }
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 (); }
int main (int argc, char *argv[]) { gfloat height; ClutterActor *stage, *statusbar; MxStyle *style; if (!clutter_init (&argc, &argv)) return -1; style = mx_style_get_default (); mx_style_load_from_file (style, THEMEDIR "/mutter-dawati.css", NULL); mx_style_load_from_file (mx_style_get_default (), THEMEDIR "/shared/shared.css", NULL); stage = clutter_stage_new (); clutter_actor_set_size (stage, 1024, 768); clutter_actor_show (stage); statusbar = mnb_statusbar_new (NULL); clutter_actor_get_preferred_height (statusbar, -1, NULL, &height); clutter_actor_set_size (statusbar, clutter_actor_get_width (stage), height); clutter_container_add_actor (CLUTTER_CONTAINER (stage), statusbar); clutter_main (); return 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 astro_appview_hide (ClutterActor *view) { AstroAppviewPrivate *priv; static ClutterTimeline *hide_time = NULL; g_return_if_fail (ASTRO_IS_APPVIEW (view)); priv = ASTRO_APPVIEW (view)->priv; if (CLUTTER_IS_TIMELINE (hide_time) &&clutter_timeline_is_playing (hide_time)) { clutter_timeline_stop (hide_time); g_object_unref (hide_time); } hide_time = clutter_effect_move (priv->hide_temp, CLUTTER_ACTOR (view), -1 * clutter_actor_get_width (view), clutter_actor_get_y (CLUTTER_ACTOR (view)), NULL, NULL); g_signal_connect (hide_time, "new-frame", G_CALLBACK (on_move_timeline_new_frame), view); g_signal_connect (hide_time, "completed", G_CALLBACK (on_hide_timeline_completed), view); }
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; }
static void drag_handle (MxSlider *bar, gfloat x, gfloat y) { MxSliderPrivate *priv = bar->priv; gdouble value; gfloat ux, pos, handle_width_2, fill_size, offset; if (!clutter_actor_transform_stage_point (CLUTTER_ACTOR (bar), x, y, &ux, NULL)) { return; } fill_size = priv->handle_middle_end - priv->handle_middle_start; /* offset is the difference between the middle of the handle and where one * clicked on it */ handle_width_2 = clutter_actor_get_width (priv->handle) / 2; offset = handle_width_2 - priv->x_origin; pos = ux - priv->handle_middle_start + offset; pos = CLAMP (pos, 0, fill_size); value = pos / fill_size; mx_slider_set_value (bar, value); /* update the handle position */ mx_slider_allocate_fill_handle (bar, NULL, 0); clutter_actor_queue_redraw (CLUTTER_ACTOR (bar)); }
/* 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))); } }
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_width (ClutterActor *self, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { MplPanelBackgroundPrivate *priv = MPL_PANEL_BACKGROUND (self)->priv; ClutterActor *stage = clutter_actor_get_stage (self); gfloat width = 0.0; g_return_if_fail (stage); /* * 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); } width = clutter_actor_get_width (stage); if (min_width_p) *min_width_p = width; if (natural_width_p) *natural_width_p = width; }
static void _xfdashboard_stage_interface_get_preferred_width(ClutterActor *inActor, gfloat inForHeight, gfloat *outMinWidth, gfloat *outNaturalWidth) { XfdashboardStageInterface *self=XFDASHBOARD_STAGE_INTERFACE(inActor); XfdashboardStageInterfacePrivate *priv=self->priv; gfloat minWidth, naturalWidth; gint w; ClutterActor *stage; /* Set up default values */ minWidth=naturalWidth=0.0f; /* Get monitor size if available otherwise get stage size */ if(priv->monitor) { xfdashboard_window_tracker_monitor_get_geometry(priv->monitor, NULL, NULL, &w, NULL); minWidth=naturalWidth=w; } else { stage=clutter_actor_get_stage(inActor); minWidth=naturalWidth=clutter_actor_get_width(stage); } /* Store sizes computed */ if(outMinWidth) *outMinWidth=minWidth; if(outNaturalWidth) *outNaturalWidth=naturalWidth; }
/* 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); }
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); }
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; }
static void circle_paint_cb (ClutterActor *actor) { const CoglColor fill_color = { 0xff, 0xff, 0xff, 0x80 }; gint i; gdouble angle; guint radius = clutter_actor_get_width (actor) / 2; cogl_set_source_color (&fill_color); angle = *((gdouble *)g_object_get_data (G_OBJECT (actor), "angle")); for (i = 0; i < CIRCLE_S; i++, angle += (2.0 * G_PI) / (gdouble) CIRCLE_S) { gdouble angle2 = angle + ((2.0 * G_PI) / (gdouble)CIRCLE_S) / 2.0; cogl_path_move_to (((radius - CIRCLE_W) * cos (angle)) + radius, ((radius - CIRCLE_W) * sin (angle)) + radius); cogl_path_arc (radius, radius, radius, radius, CLUTTER_ANGLE_FROM_RAD (angle), CLUTTER_ANGLE_FROM_RAD (angle2)); cogl_path_line_to (((radius - CIRCLE_W) * cos (angle2)) + radius, ((radius - CIRCLE_W) * sin (angle2)) + radius); cogl_path_arc (radius, radius, radius - CIRCLE_W, radius - CIRCLE_W, CLUTTER_ANGLE_FROM_RAD (angle2), CLUTTER_ANGLE_FROM_RAD (angle)); cogl_path_close (); cogl_path_fill (); } }
static void mex_content_box_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { MexContentBoxPrivate *priv = MEX_CONTENT_BOX (object)->priv; gint int_value; switch (property_id) { case PROP_OPEN: g_value_set_boolean (value, MEX_CONTENT_BOX (object)->priv->is_open); break; case PROP_IMPORTANT: g_value_set_boolean (value, mex_content_box_get_important (MEX_CONTENT_BOX (object))); break; case PROP_THUMB_WIDTH: g_object_get (priv->tile, "thumb-width", &int_value, NULL); g_value_set_int (value, int_value); break; case PROP_ACTION_LIST_WIDTH: g_value_set_int (value, clutter_actor_get_width (priv->action_list)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
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"); }
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); }