int main (int argc, char *argv[]) { ClutterActor *stage; ClutterActor *red; ClutterActor *green; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); red = clutter_rectangle_new_with_color (&red_color); clutter_actor_set_size (red, 100, 100); clutter_actor_set_position (red, 50, 150); clutter_actor_set_reactive (red, TRUE); green = clutter_rectangle_new_with_color (&green_color); clutter_actor_set_size (green, 100, 100); clutter_actor_set_position (green, 250, 150); clutter_actor_set_reactive (green, TRUE); g_signal_connect (red, "button-press-event", G_CALLBACK (button_event_cb), NULL); g_signal_connect (red, "button-release-event", G_CALLBACK (button_event_cb), NULL); g_signal_connect (green, "button-press-event", G_CALLBACK (button_event_cb), NULL); g_signal_connect (green, "button-release-event", G_CALLBACK (button_event_cb), NULL); clutter_container_add (CLUTTER_CONTAINER (stage), red, green, NULL); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
static gboolean action_add_triangle (ClutterActor *action, ClutterEvent *event, gpointer userdata) { const ClutterColor transparent = { 0x00, 0x00, 0x00, 0x01 }; ClutterActor *group = CLUTTER_ACTOR (userdata); ClutterVertex vertices[] = { { 0.5, 0.0, 0.0 }, { 1.0, 1.0, 0.0 }, { 0.0, 1.0, 0.0 } }; ClutterActor *box; box = clutter_rectangle_new_with_color (&transparent); clutter_actor_set_size (box, 50, 50); clutter_actor_set_position (box, event->button.x, event->button.y); clutter_group_add (CLUTTER_GROUP (group), box); /* Create a triangle vertex array */ clutter_box2d_child_set_outline (CLUTTER_BOX2D (group), box, vertices, 3); g_signal_connect (box, "paint", G_CALLBACK (paint_triangle), NULL); return FALSE; }
static void on_gesture_begin(ClutterGestureAction *action, ClutterActor *stage, gpointer data) { gfloat x, y; ClutterColor transp = {0, 0, 0, 0}; ClutterColor grey = {30, 30, 30, 128}; switch (tool){ case TOOL_RECTANGLE: clutter_gesture_action_get_press_coords(action, 0, &x, &y); tmpRect = clutter_rectangle_new_with_color(&transp); clutter_rectangle_set_border_width(CLUTTER_RECTANGLE(tmpRect), 1); clutter_rectangle_set_border_color(CLUTTER_RECTANGLE(tmpRect), &grey); clutter_actor_set_position(tmpRect, x, y); clutter_actor_set_size(tmpRect, 0, 0); clutter_actor_add_child(CLUTTER_ACTOR(stage), tmpRect); clutter_actor_show(tmpRect); x_0 = x; y_0 = y; break; default: break; } }
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 AstroWindow * get_window (AstroApplication *app) { AstroExamplePrivate *priv; ClutterColor color = { 0xff, 0xff, 0x22, 0x22 }; ClutterActor *window = NULL, *rect; g_return_val_if_fail (ASTRO_IS_EXAMPLE (app), NULL); priv = ASTRO_EXAMPLE (app)->priv; if (CLUTTER_IS_ACTOR (priv->window)) window = priv->window; else { window = astro_window_new (); rect = clutter_rectangle_new_with_color (&color); clutter_container_add_actor (CLUTTER_CONTAINER (window), rect); clutter_actor_set_size (rect, CSW (), CSH()-ASTRO_PANEL_HEIGHT()); clutter_actor_show (rect); } ASTRO_EXAMPLE (app)->priv->window = window; return ASTRO_WINDOW (window); }
int main(int argc, char *argv[]) { clutter_init(&argc, &argv); ClutterActor *stage = NULL; ClutterColor black = { 0x00, 0x00, 0x00, 0xff }; ClutterColor red = { 0xff, 0x00, 0x00, 0xff }; stage = clutter_stage_get_default(); clutter_stage_set_title(CLUTTER_STAGE(stage), "Key binder proto"); clutter_stage_set_color(CLUTTER_STAGE(stage), &black); clutter_actor_set_size(stage, WIN_W, WIN_H); App *self = g_new0(App, 1); create_stuff(); self->rectangle = clutter_rectangle_new_with_color(&red); clutter_actor_set_size(self->rectangle, 200, 200); clutter_container_add_actor(CLUTTER_CONTAINER(stage), self->rectangle); g_signal_connect(stage, "key-press-event", G_CALLBACK(key_event_cb), self); clutter_actor_show(stage); clutter_main(); g_free(self); return 0; }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterActor *r1, *r2, *r3; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_actor_set_size (stage, 300, 300); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); r1 = clutter_rectangle_new_with_color (&red); clutter_actor_set_size (r1, 150, 150); clutter_actor_add_constraint (r1, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.25)); clutter_actor_add_constraint (r1, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.25)); clutter_actor_set_reactive (r1, TRUE); clutter_actor_set_name (r1, "red"); r2 = clutter_rectangle_new_with_color (&green); clutter_actor_set_size (r2, 150, 150); clutter_actor_add_constraint (r2, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5)); clutter_actor_add_constraint (r2, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5)); clutter_actor_set_reactive (r2, TRUE); clutter_actor_set_depth (r2, -100); clutter_actor_set_name (r2, "green"); r3 = clutter_rectangle_new_with_color (&blue); clutter_actor_set_size (r3, 150, 150); clutter_actor_add_constraint (r3, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.75)); clutter_actor_add_constraint (r3, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.75)); clutter_actor_set_opacity (r3, 125); clutter_actor_set_name (r3, "blue"); clutter_container_add (CLUTTER_CONTAINER (stage), r1, r2, r3, NULL); g_signal_connect (r1, "motion-event", G_CALLBACK (_pointer_motion_cb), NULL); g_signal_connect (r2, "motion-event", G_CALLBACK (_pointer_motion_cb), NULL); clutter_actor_show (stage); clutter_main (); return 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; } }
static void make_ui (ClutterActor *stage) { ClutterActor *editable = NULL; ClutterActor *rectangle = NULL; ClutterActor *label = NULL; ClutterColor color_stage = { 0x00, 0x00, 0x00, 0xff }; ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff }; ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 }; ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff }; ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 }; ClutterGeometry editable_geom = {150, 50, 100, 75}; ClutterActor *full_entry = NULL; ClutterActor *cloned_entry = NULL; clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage); clutter_actor_set_size (stage, WIDTH, HEIGHT); label = clutter_text_new_full ("Sans Bold 32px", "Entry", &color_label); clutter_actor_set_position (label, 0, 50); /* editable */ editable = clutter_text_new_full ("Sans Bold 32px", "ddd", &color_text); clutter_actor_set_position (editable, 150, 50); clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_selection_color (CLUTTER_TEXT (editable), &color_sel); clutter_actor_grab_key_focus (editable); clutter_actor_set_reactive (editable, TRUE); /* rectangle: to create a entry "feeling" */ rectangle = clutter_rectangle_new_with_color (&color_rect); clutter_actor_set_geometry (rectangle, &editable_geom); full_entry = clutter_group_new (); clutter_actor_set_position (full_entry, 0, 50); clutter_actor_set_size (full_entry, 100, 75); clutter_group_add (CLUTTER_GROUP (full_entry), label); clutter_group_add (CLUTTER_GROUP (full_entry), editable); clutter_group_add (CLUTTER_GROUP (full_entry), rectangle); clutter_actor_show_all (full_entry); clutter_actor_set_scale (full_entry, 2, 1); clutter_group_add (CLUTTER_GROUP (stage), full_entry); /* Cloning! */ cloned_entry = clutter_clone_new (full_entry); clutter_actor_set_position (cloned_entry, 50, 200); clutter_actor_set_scale (cloned_entry, 1, 2); clutter_actor_show_all (cloned_entry); clutter_actor_set_reactive (cloned_entry, TRUE); clutter_group_add (CLUTTER_GROUP (stage), cloned_entry); }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterPath *path; ClutterConstraint *constraint; ClutterActor *rectangle; ClutterTimeline *timeline; const ClutterColor *stage_color = clutter_color_new (51, 51, 85, 255); const ClutterColor *red_color = clutter_color_new (255, 0, 0, 255); clutter_init (&argc, &argv); stage = clutter_stage_new (); clutter_actor_set_size (stage, 360, 300); clutter_stage_set_color (CLUTTER_STAGE (stage), stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* create the path */ path = clutter_path_new (); clutter_path_add_move_to (path, 30, 60); /* add a curve round to the top-right of the stage */ clutter_path_add_rel_curve_to (path, 120, 180, 180, 120, 240, 0); /* create a constraint based on the path */ constraint = clutter_path_constraint_new (path, 0.0); /* put a rectangle at the start of the path */ rectangle = clutter_rectangle_new_with_color (red_color); clutter_actor_set_size (rectangle, 60, 60); /* add the constraint to the rectangle */ clutter_actor_add_constraint_with_name (rectangle, "path", constraint); /* add the rectangle to the stage */ clutter_container_add_actor (CLUTTER_CONTAINER (stage), rectangle); /* set up the timeline */ timeline = clutter_timeline_new (1000); clutter_timeline_set_loop (timeline, TRUE); clutter_timeline_set_auto_reverse (timeline, TRUE); clutter_actor_animate_with_timeline (rectangle, CLUTTER_LINEAR, timeline, "@constraints.path.offset", 1.0, NULL); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
static void mex_content_box_init (MexContentBox *self) { MexContentBoxPrivate *priv = self->priv = CONTENT_BOX_PRIVATE (self); ClutterActor *hline, *box; priv->thumb_width = 426; priv->thumb_height = 240; /* Create description panel */ box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL); hline = clutter_rectangle_new_with_color (&hline_color); clutter_actor_set_height (hline, 1); priv->panel = mex_info_panel_new (MEX_INFO_PANEL_MODE_SIMPLE); clutter_container_add (CLUTTER_CONTAINER (box), hline, priv->panel, NULL); /* monitor key press events */ g_signal_connect (self, "key-press-event", G_CALLBACK (mex_content_box_key_press_event_cb), self); /* Create tile */ priv->tile = mex_content_tile_new (); g_object_set (G_OBJECT (priv->tile), "thumb-width", priv->thumb_width, "thumb-height", priv->thumb_height, NULL); mx_bin_set_fill (MX_BIN (priv->tile), TRUE, TRUE); clutter_actor_set_reactive (priv->tile, TRUE); g_signal_connect (priv->tile, "button-release-event", G_CALLBACK (mex_content_box_tile_clicked_cb), self); /* Create secondary box for tile/menu */ priv->box = mex_expander_box_new (); mex_expander_box_set_important (MEX_EXPANDER_BOX (priv->box), TRUE); mex_expander_box_set_grow_direction (MEX_EXPANDER_BOX (priv->box), MEX_EXPANDER_BOX_RIGHT); mex_expander_box_set_primary_child (MEX_EXPANDER_BOX (priv->box), priv->tile); /* Pack box and panel into self */ mex_expander_box_set_primary_child (MEX_EXPANDER_BOX (self), priv->box); mex_expander_box_set_secondary_child (MEX_EXPANDER_BOX (self), box); /* Create the action list */ priv->action_list = mex_action_list_new (); mex_expander_box_set_secondary_child (MEX_EXPANDER_BOX (priv->box), priv->action_list); /* Connect to the open notify signal */ g_signal_connect (self, "notify::open", G_CALLBACK (mex_content_box_notify_open_cb), NULL); }
static ClutterActor * create_circle (gfloat radius) { const ClutterColor transp = { 0, }; ClutterActor *circle = clutter_rectangle_new_with_color (&transp); clutter_actor_set_size (circle, radius * 2, radius * 2); g_signal_connect (circle, "paint", G_CALLBACK (paint_circle), NULL); return circle; }
/* use a 'missing image' image instead? */ static void set_blank_image (MxFrame *frame) { ClutterActor *blank; ClutterColor nothing = { 0, 0, 0, 0 }; blank = clutter_rectangle_new_with_color (¬hing); clutter_actor_set_height (blank, MAX_IMAGE_HEIGHT); clutter_actor_set_width (blank, MAX_IMAGE_HEIGHT); mx_bin_set_child (MX_BIN (frame), blank); }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterActor *actor; ClutterActor *overlay; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); actor = clutter_rectangle_new_with_color (&red); clutter_actor_set_size (actor, 100, 100); clutter_actor_set_position (actor, 150, 150); overlay = clutter_rectangle_new_with_color (&blue); g_signal_connect (actor, "allocation-changed", G_CALLBACK (allocation_changed_cb), overlay); clutter_container_add (CLUTTER_CONTAINER (stage), actor, overlay, NULL); clutter_actor_animate (actor, CLUTTER_LINEAR, 2000, "width", 300.0, "height", 300.0, "x", 50.0, "y", 50.0, NULL); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterActor *actor; ClutterState *transitions; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 300, 200); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); actor = clutter_rectangle_new_with_color (&red_color); clutter_actor_set_position (actor, 150, 50); clutter_actor_set_size (actor, 100, 100); transitions = clutter_state_new (); clutter_state_set_duration (transitions, NULL, NULL, 1000); clutter_state_set (transitions, NULL, "right", actor, "x", CLUTTER_LINEAR, 150.0, NULL); clutter_state_set (transitions, NULL, "left", actor, "x", CLUTTER_LINEAR, 50.0, NULL); clutter_state_warp_to_state (transitions, "right"); g_signal_connect (stage, "key-press-event", G_CALLBACK (key_pressed_cb), transitions); g_signal_connect (transitions, "completed", G_CALLBACK (next_state), NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor); clutter_actor_show (stage); clutter_main (); g_object_unref (transitions); return EXIT_SUCCESS; }
/* This creates an actor that has a specific size but that does not result * in any drawing so we can do our own drawing using Cogl... */ static ClutterActor * create_dummy_actor (guint width, guint height) { ClutterActor *group, *rect; ClutterColor clr = { 0xff, 0xff, 0xff, 0xff}; group = clutter_group_new (); rect = clutter_rectangle_new_with_color (&clr); clutter_actor_set_size (rect, width, height); clutter_actor_hide (rect); clutter_container_add_actor (CLUTTER_CONTAINER (group), rect); return group; }
static void make_ui (ClutterActor *stage) { gint i = 0; ClutterActor *editable = NULL; ClutterActor *rectangle = NULL; ClutterActor *label = NULL; ClutterColor color_stage = { 0x00, 0x00, 0x00, 0xff }; ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff }; ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 }; ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff }; ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 }; ClutterGeometry label_geom = {0, 50, -1, -1}; ClutterGeometry editable_geom = {150, 50, 500, 75}; clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage); clutter_actor_set_size (stage, WIDTH, HEIGHT); for (i = 0; i < NUM_ENTRIES; i++) { /* label */ label = clutter_text_new_full ("Sans Bold 32px", "Entry", &color_label); clutter_actor_set_geometry (label, &label_geom); /* editable */ editable = clutter_text_new_full ("Sans Bold 32px", "ddd", &color_text); clutter_actor_set_geometry (editable, &editable_geom); clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_selection_color (CLUTTER_TEXT (editable), &color_sel); clutter_actor_grab_key_focus (editable); clutter_actor_set_reactive (editable, TRUE); /* rectangle: to create a entry "feeling" */ rectangle = clutter_rectangle_new_with_color (&color_rect); clutter_actor_set_geometry (rectangle, &editable_geom); clutter_container_add_actor (CLUTTER_CONTAINER (stage), label); clutter_container_add_actor (CLUTTER_CONTAINER (stage), editable); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rectangle); label_geom.y += HEIGHT_STEP; editable_geom.y += HEIGHT_STEP; } }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterActor *actor; ClutterTimeline *timeline; ClutterAnimator *animator; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 300, 200); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); actor = clutter_rectangle_new_with_color (&red_color); clutter_actor_set_size (actor, 100, 100); clutter_actor_set_position (actor, 150, 50); timeline = clutter_timeline_new (2000); clutter_timeline_set_loop (timeline, TRUE); animator = clutter_animator_new (); clutter_animator_set_timeline (animator, timeline); clutter_animator_set (animator, actor, "x", CLUTTER_LINEAR, 0.0, 150.0, actor, "x", CLUTTER_LINEAR, 0.5, 50.0, actor, "x", CLUTTER_LINEAR, 1.0, 150.0, NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor); g_signal_connect (stage, "key-press-event", G_CALLBACK (key_pressed_cb), timeline); clutter_actor_show (stage); clutter_main (); g_object_unref (animator); return EXIT_SUCCESS; }
int main(int argc, char ** argv) { ClutterColor stage_color = {0x00, 0x00, 0x00, 0xFF}; // Black ClutterColor rect_color = {0x00, 0xFF, 0xFF, 0xFF}; // Purple clutter_init(&argc, &argv); ClutterActor * stage = clutter_stage_get_default(); clutter_actor_set_size(stage, 200, 200); clutter_stage_set_color(CLUTTER_STAGE(stage), &stage_color); rect = clutter_rectangle_new_with_color(&rect_color); clutter_actor_set_size(rect, 70, 70); clutter_actor_set_position(rect, 50, 100); clutter_container_add_actor(CLUTTER_CONTAINER(stage), rect); clutter_actor_show(rect); clutter_actor_show(stage); ClutterScore * score = clutter_score_new(); clutter_score_set_loop(score, TRUE); ClutterTimeline * rtimeline = clutter_timeline_new(10, //frames 120 //fps ); g_signal_connect(rtimeline, "new-frame", G_CALLBACK(on_timeline_rotation_new_frame), NULL); clutter_score_append(score, NULL, rtimeline); ClutterTimeline * mtimeline = clutter_timeline_new(10, //frames 120 //fps ); g_signal_connect(mtimeline, "new-frame", G_CALLBACK(on_timeline_move_new_frame), NULL); clutter_score_append(score, rtimeline, mtimeline); clutter_score_start(score); clutter_main(); g_object_unref(rtimeline); g_object_unref(mtimeline); g_object_unref(score); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff }; ClutterColor rect_color = { 0xff, 0xff, 0xff, 0x99 }; clutter_init (&argc, &argv); /* Get the stage and set its size and color: */ ClutterActor *stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 200, 200); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); /* Add a rectangle to the stage: */ rect = clutter_rectangle_new_with_color (&rect_color); clutter_actor_set_size (rect, 40, 40); clutter_actor_set_position (rect, 10, 10); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); clutter_actor_show (rect); /* Show the stage: */ clutter_actor_show (stage); ClutterTimeline *timeline = clutter_timeline_new(5000 /* milliseconds */); clutter_timeline_set_loop(timeline, TRUE); clutter_timeline_start(timeline); /* Create a clutter alpha for the animation */ ClutterAlpha* alpha = clutter_alpha_new_with_func (timeline, &on_alpha, NULL, NULL); g_object_unref (timeline); /* Create an animation to change the properties */ ClutterAnimation* animation = clutter_actor_animate_with_alpha (rect, alpha, "x", 150.0, "y", 150.0, "opacity", 0, NULL); /* Start the main loop, so we can respond to events: */ clutter_main (); g_object_unref (animation); return EXIT_SUCCESS; }
void test_pick (TestConformSimpleFixture *fixture, gconstpointer data) { int y, x; State state; state.pass = TRUE; state.stage = clutter_stage_get_default (); clutter_actor_set_size (state.stage, STAGE_WIDTH, STAGE_HEIGHT); state.actor_width = STAGE_WIDTH / ACTORS_X; state.actor_height = STAGE_HEIGHT / ACTORS_Y; for (y = 0; y < ACTORS_Y; y++) for (x = 0; x < ACTORS_X; x++) { ClutterColor color = { x * 255 / (ACTORS_X - 1), y * 255 / (ACTORS_Y - 1), 128, 255 }; ClutterGeometry geom = { x * state.actor_width, y * state.actor_height, state.actor_width, state.actor_height }; ClutterActor *rect = clutter_rectangle_new_with_color (&color); clutter_actor_set_geometry (rect, &geom); clutter_container_add (CLUTTER_CONTAINER (state.stage), rect, NULL); state.gids[y * ACTORS_X + x] = clutter_actor_get_gid (rect); } clutter_actor_show (state.stage); g_timeout_add (250, (GSourceFunc) on_timeout, &state); clutter_main (); if (g_test_verbose ()) g_print ("end result: %s\n", state.pass ? "pass" : "FAIL"); g_assert (state.pass); }
static ClutterActor *new_rect (gint r, gint g, gint b, gint a) { GError *error = NULL; ClutterColor *color = clutter_color_new (r, g, b, a); ClutterActor *rectangle = clutter_rectangle_new_with_color (color); gchar *file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); rectangle = clutter_texture_new_from_file (file, &error); if (rectangle == NULL) g_error ("image load failed: %s", error->message); g_free (file); clutter_actor_set_size (rectangle, 128, 128); clutter_color_free (color); return rectangle; }
static void ntf_overlay_constructed (GObject *object) { NtfOverlay *self = (NtfOverlay*) object; NtfOverlayPrivate *priv = self->priv; ClutterActor *actor = (ClutterActor*) object; ClutterColor low_clr = {0, 0, 0, 0x7f}; if (G_OBJECT_CLASS (ntf_overlay_parent_class)->constructed) G_OBJECT_CLASS (ntf_overlay_parent_class)->constructed (object); priv->tray_normal = ntf_tray_new (FALSE); clutter_actor_set_parent (CLUTTER_ACTOR (priv->tray_normal), actor); priv->tray_urgent = ntf_tray_new (TRUE); clutter_actor_set_parent (CLUTTER_ACTOR (priv->tray_urgent), actor); priv->lowlight = clutter_rectangle_new_with_color (&low_clr); clutter_actor_set_parent (CLUTTER_ACTOR (priv->lowlight), actor); mnb_input_manager_push_actor (priv->lowlight, MNB_INPUT_LAYER_TOP); clutter_actor_hide (priv->lowlight); /* * The urgent tray shows/hides itself when it contains something / is empty. * We need to show the lowlight any time it is visible. */ g_signal_connect (priv->tray_urgent, "show", G_CALLBACK (ntf_overlay_urgent_tray_show_cb), self); g_signal_connect (priv->tray_urgent, "hide", G_CALLBACK (ntf_overlay_urgent_tray_hide_cb), self); g_signal_connect (priv->lowlight, "button-press-event", G_CALLBACK (ntf_overlay_lowlight_button_event_cb), self); g_signal_connect (priv->lowlight, "button-release-event", G_CALLBACK (ntf_overlay_lowlight_button_event_cb), self); }
static ClutterActor* _create_button (const gchar *text) { ClutterActor *button = NULL; ClutterActor *rectangle = NULL; ClutterActor *label = NULL; button = clutter_group_new (); rectangle = clutter_rectangle_new_with_color (CLUTTER_COLOR_Magenta); clutter_actor_set_size (rectangle, 375, 35); label = clutter_text_new_full ("Sans Bold 32px", text, CLUTTER_COLOR_Black); clutter_container_add_actor (CLUTTER_CONTAINER (button), rectangle); clutter_container_add_actor (CLUTTER_CONTAINER (button), label); clutter_actor_set_reactive (button, TRUE); return button; }
static void actor_pick (void) { int y, x; State state; state.pass = TRUE; state.stage = clutter_test_get_stage (); state.actor_width = STAGE_WIDTH / ACTORS_X; state.actor_height = STAGE_HEIGHT / ACTORS_Y; for (y = 0; y < ACTORS_Y; y++) for (x = 0; x < ACTORS_X; x++) { ClutterColor color = { x * 255 / (ACTORS_X - 1), y * 255 / (ACTORS_Y - 1), 128, 255 }; ClutterActor *rect = clutter_rectangle_new_with_color (&color); clutter_actor_set_position (rect, x * state.actor_width, y * state.actor_height); clutter_actor_set_size (rect, state.actor_width, state.actor_height); clutter_actor_add_child (state.stage, rect); state.actors[y * ACTORS_X + x] = rect; } clutter_actor_show (state.stage); clutter_threads_add_idle (on_timeout, &state); clutter_main (); g_assert (state.pass); }
static ClutterActor* _create_button (const gchar *text) { ClutterActor *button = NULL; ClutterActor *rectangle = NULL; ClutterActor *label = NULL; ClutterColor color_rect = { 0x00, 0xff, 0xff, 0xff }; ClutterColor color_label = { 0x00, 0x00, 0x00, 0xff }; button = clutter_group_new (); rectangle = clutter_rectangle_new_with_color (&color_rect); clutter_actor_set_size (rectangle, 375, 35); label = clutter_text_new_full ("Sans Bold 32px", text, &color_label); clutter_group_add (CLUTTER_GROUP (button), rectangle); clutter_group_add (CLUTTER_GROUP (button), label); clutter_actor_set_reactive (button, TRUE); return button; }
gboolean cs_selected_lasso_start (ClutterActor *actor, ClutterEvent *event) { ClutterModifierType state = event->button.modifier_state; g_assert (lasso == NULL); { ClutterColor lassocolor = {0xff,0x0,0x0,0x11}; ClutterColor lassobordercolor = {0xff,0x0,0x0,0x88}; lasso = clutter_rectangle_new_with_color (&lassocolor); clutter_rectangle_set_border_color (CLUTTER_RECTANGLE (lasso), &lassobordercolor); clutter_rectangle_set_border_width (CLUTTER_RECTANGLE (lasso), LASSO_BORDER); clutter_container_add_actor (CLUTTER_CONTAINER (cs->parasite_root), lasso); } lx = event->button.x; ly = event->button.y; clutter_actor_set_position (lasso, lx-LASSO_BORDER, ly-LASSO_BORDER); clutter_actor_set_size (lasso, LASSO_BORDER*2, LASSO_BORDER*2); manipulate_x = event->button.x; manipulate_y = event->button.y; g_signal_connect (clutter_actor_get_stage (actor), "captured-event", G_CALLBACK (manipulate_lasso_capture), actor); undo = g_string_new (""); redo = g_string_new (""); SELECT_ACTION_PRE2(); if (!((state & CLUTTER_SHIFT_MASK) || (state & CLUTTER_CONTROL_MASK))) { cs_selected_clear (); } return TRUE; }
static void add_actor (ClutterContainer *container) { ClutterActor *rect; ClutterColor color = { 0xff, 0xff, 0xff, 255 }; static gboolean expand = TRUE; clutter_color_from_hls (&color, g_random_double_range (0.0, 360.0), 0.5, 0.5); rect = clutter_rectangle_new_with_color (&color); clutter_actor_set_size (rect, 32, 64); clutter_container_add_actor (container, rect); clutter_actor_set_reactive (rect, TRUE); g_signal_connect (rect, "enter-event", G_CALLBACK (enter_event), NULL); g_signal_connect (rect, "leave-event", G_CALLBACK (leave_event), NULL); g_signal_connect (rect, "button-release-event", G_CALLBACK (button_release_event), container); clutter_container_child_set (container, rect, "expand", expand, NULL); expand = !expand; }
static void manager_event_cursor_new(unsigned short type, void *userdata, void *data) { tuio_cursor_t *o = (tuio_cursor_t *)data; manager_cursor_t *el; ClutterActor *stage, *ac; uint wx, wy; assert( data != NULL ); el = malloc(sizeof(struct manager_cursor_s)); LIST_INSERT_HEAD(&manager_cursors_list, el, next); el->id = o->s_id; snprintf(el->label, sizeof(el->label), "%d", o->s_id); el->actor = clutter_group_new(); stage = clutter_stage_get_default(); clutter_actor_get_size(stage, &wx, &wy); /* create rectangle */ ac = clutter_rectangle_new_with_color(&obj_background); clutter_rectangle_set_border_color((ClutterRectangle *)ac, &obj_border); clutter_rectangle_set_border_width((ClutterRectangle *)ac, 2); clutter_actor_set_height(ac, 10); clutter_actor_set_width(ac, 10); clutter_container_add_actor(CLUTTER_CONTAINER(el->actor), ac); /* some position */ clutter_actor_set_position(el->actor, o->xpos * (float)wx, o->ypos * (float)wy); clutter_actor_show(el->actor); clutter_container_add_actor(CLUTTER_CONTAINER(stage), el->actor); }
static void make_window_content (MplPanelClutter *panel) { ClutterActor *stage = mpl_panel_clutter_get_stage (panel); ClutterActor *label; ClutterColor black = {0, 0, 0, 0xff}; ClutterColor red = {0xff, 0, 0, 0xff}; #if 0 label = clutter_text_new_with_text ("Sans 16pt", "This is a clutter panel"); clutter_text_set_color (CLUTTER_TEXT (label), &black); clutter_text_set_editable (CLUTTER_TEXT (label), TRUE); clutter_stage_set_key_focus (CLUTTER_STAGE (stage), label); #else label = clutter_rectangle_new_with_color (&black); clutter_actor_set_size (label, 50.0,50.0); clutter_actor_show (label); #endif mpl_panel_clutter_set_child (panel, label); clutter_stage_set_color (CLUTTER_STAGE (stage), &red); }