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)); }
/* Public Functions */ void astro_appview_set_app_list (AstroAppview *view, GList *apps) { AstroAppviewPrivate *priv; GList *l; gint offset = 0; g_return_if_fail (ASTRO_IS_APPVIEW (view)); priv = view->priv; priv->apps = apps; priv->active = 0; /* Add all the icons */ for (l = apps; l; l = l->next) { AstroApplication *app = l->data; ClutterActor *icon = astro_appicon_new (app); clutter_container_add_actor (CLUTTER_CONTAINER (view), icon); clutter_actor_set_size (icon, ASTRO_APPICON_SIZE (),ASTRO_APPICON_SIZE()); clutter_actor_set_anchor_point_from_gravity (icon,CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (icon, offset, CSH ()/2); clutter_actor_show (icon); g_signal_connect (icon, "clicked", G_CALLBACK (on_appicon_clicked), view); offset += ASTRO_APPICON_SPACING (); } astro_appview_advance (view, 0); }
void App::createPalette() { ClutterColor white = { 255, 255, 255, 255 }; selection_rect_ = clutter_rectangle_new_with_color(&white); clutter_actor_set_size(selection_rect_, 55.0f, 55.0f); clutter_actor_set_anchor_point_from_gravity(selection_rect_, CLUTTER_GRAVITY_CENTER); clutter_container_add_actor(CLUTTER_CONTAINER(stage_), selection_rect_); std::vector<std::string> colors; colors.push_back(std::string("#c33")); // red colors.push_back(std::string("#cc3")); colors.push_back(std::string("#3c3")); // green colors.push_back(std::string("#3cc")); colors.push_back(std::string("#33c")); // blue colors.push_back(std::string("#c3c")); colors.push_back(std::string("#333")); // black colors.push_back(std::string("#999")); colors.push_back(std::string("#ccc")); // initial color: ClutterColor chosen; clutter_color_from_string(&chosen, (*colors.begin()).c_str()); setColor(chosen.red, chosen.green, chosen.blue); int i = 0; std::vector<std::string>::iterator iter; for (iter = colors.begin(); iter != colors.end(); ++iter) { ClutterColor color; clutter_color_from_string(&color, (*iter).c_str()); ClutterActor *rect = clutter_rectangle_new_with_color(&color); clutter_actor_set_size(rect, 50.0f, 50.0f); clutter_actor_set_anchor_point_from_gravity(rect, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position(rect, 35.0f, i * 60.0f + 30.0f); clutter_actor_set_reactive(rect, TRUE); clutter_container_add_actor(CLUTTER_CONTAINER(stage_), rect); g_signal_connect(rect, "button-press-event", G_CALLBACK(button_press_color_cb), this); if (i == 0) { float x = clutter_actor_get_x(rect); float y = clutter_actor_get_y(rect); setSelectionPosition(x, y); } ++i; } }
int main (int argc, char **argv) { ClutterActor *stage; ClutterActor *text; ClutterAnimation *animation; ClutterColor red, green, blue; g_thread_init (NULL); gst_init (&argc, &argv); if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; clutter_color_from_string (&red, "red"); clutter_color_from_string (&green, "green"); clutter_color_from_string (&blue, "blue"); stage = clutter_stage_get_default (); text = g_object_new (CLUTTER_TYPE_TEXT, "text", "Red", "font-name", "Sans 40px", "color", &red, NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), text); animation = clutter_actor_animate (text, CLUTTER_EASE_IN_OUT_QUAD, 3000, "x", 320, "y", 240, NULL); g_signal_connect (animation, "completed", G_CALLBACK (on_animation_completed), NULL); text = g_object_new (CLUTTER_TYPE_TEXT, "text", "Blue", "font-name", "Sans 40px", "color", &blue, "x", 640, "y", 0, NULL); clutter_actor_set_anchor_point_from_gravity (text, CLUTTER_GRAVITY_NORTH_EAST); clutter_container_add_actor (CLUTTER_CONTAINER (stage), text); animation = clutter_actor_animate (text, CLUTTER_EASE_IN_OUT_QUAD, 3000, "x", 320, "y", 240, NULL); text = g_object_new (CLUTTER_TYPE_TEXT, "text", "Green", "font-name", "Sans 40px", "color", &green, "x", 0, "y", 480, NULL); clutter_actor_set_anchor_point_from_gravity (text, CLUTTER_GRAVITY_SOUTH_WEST); clutter_container_add_actor (CLUTTER_CONTAINER (stage), text); animation = clutter_actor_animate (text, CLUTTER_EASE_IN_OUT_QUAD, 3000, "x", 320, "y", 240, NULL); recorder = shell_recorder_new (CLUTTER_STAGE (stage)); shell_recorder_set_filename (recorder, "test-recorder.ogg"); clutter_actor_show (stage); shell_recorder_record (recorder); clutter_main (); return 0; }
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 bg_color = { 0xcc, 0xcc, 0xcc, 0x99 }; ClutterColor *color; clutter_init (&argc, &argv); 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"); rect = make_background (&bg_color, 200, 200); /* 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"); { 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_raise_top (rect); clutter_actor_set_name (rect, "emblem"); g_signal_connect (box, "enter-event", G_CALLBACK (on_box_enter), rect); g_signal_connect (box, "leave-event", G_CALLBACK (on_box_leave), rect); clutter_actor_show_all (stage); clutter_main (); clutter_color_free (color); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { ClutterActor *stage, *actor; ClutterContainer *container; ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff }; ClutterColor rect_color = { 0, 0, 0, 0xdd }; clutter_init (&argc, &argv); timeline = clutter_timeline_new_for_duration (5000); clutter_timeline_set_loop (timeline, TRUE); tmpl = clutter_effect_template_new (timeline, CLUTTER_ALPHA_RAMP_INC); stage = clutter_stage_get_default (); container = CLUTTER_CONTAINER (stage); g_signal_connect (stage, "button-press-event", G_CALLBACK (clutter_main_quit), NULL); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_stage_set_use_fog (CLUTTER_STAGE (stage), TRUE); clutter_actor_set_size (stage, 800, 600); clutter_actor_show_all (stage); actor = clutter_rectangle_new_with_color (&rect_color); clutter_container_add_actor (container, actor); clutter_actor_set_size (actor, 50, 50); clutter_actor_set_position (actor, 50, 10); clutter_effect_fade (tmpl, actor, 0x22, NULL, NULL); clutter_actor_show (actor); actor = clutter_rectangle_new_with_color (&rect_color); clutter_container_add_actor (container, actor); clutter_actor_set_size (actor, 50, 50); clutter_actor_set_position (actor, 750, 70); clutter_effect_depth (tmpl, actor, -500, NULL, NULL); clutter_actor_show (actor); actor = clutter_rectangle_new_with_color (&rect_color); clutter_container_add_actor (container, actor); clutter_actor_set_size (actor, 50, 50); clutter_actor_set_position (actor, 50, 140); clutter_effect_move (tmpl, actor, 750, 140, NULL, NULL); clutter_actor_show (actor); actor = clutter_rectangle_new_with_color (&rect_color); clutter_container_add_actor (container, actor); clutter_actor_set_size (actor, 50, 50); clutter_actor_set_position (actor, 750, 210); { ClutterKnot knots[2]; knots[0].x = 750; knots[0].y = 210; knots[1].x = 350; knots[1].y = 210; clutter_effect_path (tmpl, actor, knots, 2, NULL, NULL); } clutter_actor_show (actor); actor = clutter_rectangle_new_with_color (&rect_color); clutter_container_add_actor (container, actor); clutter_actor_set_size (actor, 50, 50); clutter_actor_set_position (actor, 50, 280); clutter_actor_set_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_CENTER); clutter_effect_scale (tmpl, actor, 2.0, 2.0, NULL, NULL); clutter_actor_show (actor); actor = clutter_rectangle_new_with_color (&rect_color); clutter_container_add_actor (container, actor); clutter_actor_set_size (actor, 50, 50); clutter_actor_set_position (actor, 750, 350); clutter_effect_rotate (tmpl, actor, CLUTTER_Z_AXIS, 180.0, 25, 25, 0, CLUTTER_ROTATE_CW, NULL, NULL); clutter_actor_show (actor); clutter_main (); g_object_unref (tmpl); g_object_unref (timeline); return EXIT_SUCCESS; }
int main (int argc, char **argv) { glong i; gdouble angle; ClutterColor color = { 0x00, 0x00, 0x00, 0xff }; ClutterActor *stage, *rect; clutter_perf_fps_init (); if (CLUTTER_INIT_SUCCESS != clutter_init_with_args (&argc, &argv, NULL, entries, NULL, NULL)) { g_warning ("Failed to initialize clutter"); return -1; } stage = clutter_stage_new (); clutter_actor_set_size (stage, 512, 512); clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black); clutter_stage_set_title (CLUTTER_STAGE (stage), "Picking Performance"); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); printf ("Picking performance test with " "%d actors and %d events per frame\n", n_actors, n_events); for (i = n_actors - 1; i >= 0; i--) { angle = ((2.0 * G_PI) / (gdouble) n_actors) * i; color.red = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0, i))) / (gdouble)(n_actors/4.0) - 1.0)) * 255.0; color.green = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0, fmod (i + (n_actors/3.0)*2, n_actors)))) / (gdouble)(n_actors/4) - 1.0)) * 255.0; color.blue = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0, fmod ((i + (n_actors/3.0)), n_actors)))) / (gdouble)(n_actors/4.0) - 1.0)) * 255.0; rect = clutter_rectangle_new_with_color (&color); clutter_actor_set_size (rect, 100, 100); clutter_actor_set_anchor_point_from_gravity (rect, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (rect, 256 + 206 * cos (angle), 256 + 206 * sin (angle)); clutter_actor_set_reactive (rect, TRUE); g_signal_connect (rect, "motion-event", G_CALLBACK (motion_event_cb), NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); } clutter_actor_show (stage); clutter_perf_fps_start (CLUTTER_STAGE (stage)); clutter_threads_add_idle (queue_redraw, stage); clutter_main (); clutter_perf_fps_report ("test-picking"); return 0; }
int main (int argc, char **argv) { ClutterActor *stage; ClutterActor *text; ClutterAnimation *animation; ClutterColor red, green, blue; gtk_init (&argc, &argv); gst_init (&argc, &argv); if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; clutter_color_from_string (&red, "red"); clutter_color_from_string (&green, "green"); clutter_color_from_string (&blue, "blue"); stage = clutter_stage_new (); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); text = g_object_new (CLUTTER_TYPE_TEXT, "text", "Red", "font-name", "Sans 40px", "color", &red, NULL); clutter_actor_add_child (stage, text); animation = clutter_actor_animate (text, CLUTTER_EASE_IN_OUT_QUAD, 3000, "x", 320.0, "y", 240.0, NULL); g_signal_connect (animation, "completed", G_CALLBACK (on_animation_completed), stage); text = g_object_new (CLUTTER_TYPE_TEXT, "text", "Blue", "font-name", "Sans 40px", "color", &blue, "x", 640.0, "y", 0.0, NULL); clutter_actor_set_anchor_point_from_gravity (text, CLUTTER_GRAVITY_NORTH_EAST); clutter_actor_add_child (stage, text); animation = clutter_actor_animate (text, CLUTTER_EASE_IN_OUT_QUAD, 3000, "x", 320.0, "y", 240.0, NULL); text = g_object_new (CLUTTER_TYPE_TEXT, "text", "Green", "font-name", "Sans 40px", "color", &green, "x", 0.0, "y", 480.0, NULL); clutter_actor_set_anchor_point_from_gravity (text, CLUTTER_GRAVITY_SOUTH_WEST); clutter_actor_add_child (stage, text); animation = clutter_actor_animate (text, CLUTTER_EASE_IN_OUT_QUAD, 3000, "x", 320.0, "y", 240.0, NULL); g_signal_connect_after (stage, "realize", G_CALLBACK (on_stage_realized), NULL); clutter_actor_show (stage); clutter_main (); return 0; }
void interface_start (UserInterface * ui, gchar * uri) { ClutterColor stage_color = { 0x00, 0x00, 0x00, 0x00 }; g_print ("Loading ui!\n"); // Init UserInterface structure variables ui->fileuri = uri; ui->filename = g_path_get_basename (ui->fileuri); ui->media_width = ui->engine->media_width; ui->media_height = ui->engine->media_height; ui->stage_width = ui->engine->media_width; ui->stage_height = ui->engine->media_height; ui->stage = clutter_stage_get_default (); ui->controls_showing = FALSE; ui->keep_showing_controls = FALSE; ui->penalty_box_active = FALSE; ui->controls_timeout = -1; ui->seek_width = ui->stage_width / SEEK_WIDTH_RATIO; ui->seek_height = ui->stage_height / SEEK_HEIGHT_RATIO; ui->progress_id = -1; ui->title_length = TITLE_LENGTH; ui->duration_str = position_ns_to_str (ui->engine->media_duration); ui->rotated = FALSE; clutter_stage_set_color (CLUTTER_STAGE (ui->stage), &stage_color); clutter_stage_set_minimum_size (CLUTTER_STAGE (ui->stage), ui->stage_width, ui->stage_height); clutter_stage_set_title (CLUTTER_STAGE (ui->stage), ui->filename); clutter_actor_set_size (CLUTTER_ACTOR (ui->stage), ui->stage_width, ui->stage_height); if (ui->fullscreen) { clutter_stage_set_fullscreen (CLUTTER_STAGE (ui->stage), TRUE); } // Controls load_controls (ui); // Add video texture and control UI to stage clutter_container_add (CLUTTER_CONTAINER (ui->stage), ui->texture, ui->control_box, NULL); clutter_stage_hide_cursor (CLUTTER_STAGE (ui->stage)); clutter_actor_animate (ui->control_box, CLUTTER_EASE_OUT_QUINT, SECOND, "opacity", 0, NULL); g_signal_connect (CLUTTER_STAGE (ui->stage), "fullscreen", G_CALLBACK (size_change), ui); g_signal_connect (CLUTTER_STAGE (ui->stage), "unfullscreen", G_CALLBACK (size_change), ui); g_signal_connect (ui->stage, "event", G_CALLBACK (event_cb), ui); clutter_actor_set_anchor_point_from_gravity (CLUTTER_ACTOR (ui->texture), CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (CLUTTER_ACTOR (ui->texture), ui->stage_width / 2, ui->stage_height / 2); center_controls (ui); progress_timing (ui); ui->screensaver = screensaver_new (CLUTTER_STAGE (ui->stage)); screensaver_enable (ui->screensaver, FALSE); g_timeout_add (SECOND, progress_update_text, ui); clutter_actor_show (ui->stage); }
int main (int argc, char **argv) { glong i; gdouble angle; const ClutterColor black = { 0x00, 0x00, 0x00, 0xff }; ClutterColor color = { 0x00, 0x00, 0x00, 0xff }; ClutterActor *stage, *rect; g_setenv ("CLUTTER_VBLANK", "none", FALSE); g_setenv ("CLUTTER_DEFAULT_FPS", "1000", FALSE); g_setenv ("CLUTTER_SHOW_FPS", "1", FALSE); clutter_init_with_args (&argc, &argv, NULL, entries, NULL, NULL); stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 512, 512); clutter_stage_set_color (CLUTTER_STAGE (stage), &black); printf ("Picking performance test with " "%d actors and %d events per frame\n", n_actors, n_events); for (i = n_actors - 1; i >= 0; i--) { angle = ((2.0 * M_PI) / (gdouble) n_actors) * i; color.red = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0, i))) / (gdouble)(n_actors/4.0) - 1.0)) * 255.0; color.green = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0, fmod (i + (n_actors/3.0)*2, n_actors)))) / (gdouble)(n_actors/4) - 1.0)) * 255.0; color.blue = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0, fmod ((i + (n_actors/3.0)), n_actors)))) / (gdouble)(n_actors/4.0) - 1.0)) * 255.0; rect = clutter_rectangle_new_with_color (&color); clutter_actor_set_size (rect, 100, 100); clutter_actor_set_anchor_point_from_gravity (rect, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (rect, 256 + 206 * cos (angle), 256 + 206 * sin (angle)); clutter_actor_set_reactive (rect, TRUE); g_signal_connect (rect, "motion-event", G_CALLBACK (motion_event_cb), NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); } clutter_actor_show (stage); g_idle_add (queue_redraw, stage); g_signal_connect (stage, "paint", G_CALLBACK (on_paint), NULL); clutter_main (); return 0; }
void make_ui (App *app) { gint i, xpad, ypad, x ,y, xinit, xdpy, ydpy; ClutterActor *button_texture, *a; ClutterColor text_color = { 0xff, 0xff, 0xff, 0xff }, rect_color = { 0, 0, 0, 0x99 }, black_color = { 0, 0, 0, 0xff }; button_texture = clutter_texture_new_from_file ("button.png", NULL); xpad = (CSW-(3*clutter_actor_get_width(button_texture)))/4; x = xinit = xpad; ypad = xpad/2; y = (CSH - (4 * (ypad + clutter_actor_get_height(button_texture)))); /* * screen_dialpad (group) * +----dpy (group) * +---- (texture:display.png) * +----dpy_entry (text) * +----buttons[0:11]->actor (group) * +---- (texture:button.png) * +---- (text) */ app->screen_dialpad = clutter_group_new(); clutter_actor_set_size (app->screen_dialpad, CSW, CSH); clutter_actor_set_anchor_point_from_gravity (app->screen_dialpad, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (app->screen_dialpad, CSW/2, CSH/2); app->dpy = clutter_group_new(); a = clutter_texture_new_from_file ("display.png", NULL); clutter_group_add (CLUTTER_GROUP(app->dpy), a); app->dpyx = xdpy = x; app->dpyy = ydpy = (y - clutter_actor_get_height(app->dpy))/2; clutter_actor_set_position (app->dpy, xdpy, ydpy); clutter_group_add(CLUTTER_GROUP(app->screen_dialpad), app->dpy); app->dpy_entry = clutter_text_new_full ("Sans Bold 32px", "", &text_color); clutter_text_set_editable (CLUTTER_TEXT(app->dpy_entry), TRUE); clutter_actor_set_position (app->dpy_entry, 8, 8); clutter_actor_set_size (app->dpy_entry, clutter_actor_get_width (app->dpy) - 16, 32); clutter_group_add (CLUTTER_GROUP(app->dpy), app->dpy_entry); for (i=0; i<12; i++) { gchar buf[8]; gchar label[8]; app->buttons[i] = g_new0(Button, 1); app->buttons[i]->actor = clutter_group_new (); g_snprintf (label, 8, "%d", i+1); clutter_actor_set_name (app->buttons[i]->actor, label); clutter_actor_set_reactive (app->buttons[i]->actor, TRUE); clutter_actor_set_anchor_point_from_gravity (app->buttons[i]->actor, CLUTTER_GRAVITY_CENTER); if ( i == 0 ) a = button_texture; else a = clutter_clone_new(button_texture); clutter_group_add(CLUTTER_GROUP(app->buttons[i]->actor), a); switch (i) { case 9: g_snprintf(buf, 8, "#"); break; case 10: g_snprintf(buf, 8, "0"); break; case 11: g_snprintf(buf, 8, "*"); break; default: g_snprintf(buf, 8, "%i", i+1); break; } a = clutter_text_new_full("Sans Bold 32px", buf, &text_color); clutter_actor_set_position (a, (clutter_actor_get_width (button_texture) - clutter_actor_get_width (a))/2, (clutter_actor_get_height (button_texture) - clutter_actor_get_height (a))/2); clutter_group_add (CLUTTER_GROUP (app->buttons[i]->actor), a); clutter_group_add (CLUTTER_GROUP (app->screen_dialpad), app->buttons[i]->actor); /* need to remember positions for anim - sucky */ app->buttons[i]->sx = x + clutter_actor_get_width (app->buttons[i]->actor)/2; app->buttons[i]->sy = y + clutter_actor_get_height (app->buttons[i]->actor)/2; clutter_actor_set_position (app->buttons[i]->actor, app->buttons[i]->sx, app->buttons[i]->sy); /* Really we should use a Clutter*Box here.. */ if (i % 3 == 2) { x = xinit; y += (ypad + clutter_actor_get_height (button_texture)); } else x += (xpad + clutter_actor_get_width(button_texture)); app->buttons[i]->face = g_strdup (buf); } /* * screen_dial * +---- (rectangle:black) * +---- (texture:call-background.png) * +---- (rectangle:semi transparent) * +----dial_label (text:"Calling...") */ app->screen_dial = clutter_group_new(); clutter_actor_set_anchor_point_from_gravity (app->screen_dial, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (app->screen_dial, CSW/2, CSH/2); a = clutter_rectangle_new_with_color (&black_color); clutter_actor_set_size (a, CSW, CSH); clutter_group_add (CLUTTER_GROUP(app->screen_dial), a); a = clutter_texture_new_from_file ("call-background.png", NULL); clutter_group_add (CLUTTER_GROUP(app->screen_dial), a); a = clutter_rectangle_new_with_color (&rect_color); clutter_actor_set_size (a, CSW, CSH/6); clutter_actor_set_position (a, 0, (CSH - (CSH/6))/2); clutter_group_add (CLUTTER_GROUP(app->screen_dial), a); app->dial_label = clutter_text_new_full ("Sans Bold 32px", "Calling...", &text_color); clutter_actor_set_position (app->dial_label, 10, (CSH - (CSH/6))/2 + 10); clutter_group_add (CLUTTER_GROUP (app->screen_dial), app->dial_label); }
/* 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; }