void gnibbles_board_resize (GnibblesBoard *board, gint newtile) { int i; int x_pos; int y_pos; int count; ClutterActor *tmp; ClutterActor *stage = gnibbles_board_get_stage (board); clutter_actor_set_size (stage, BOARDWIDTH * newtile, BOARDHEIGHT * newtile); clutter_actor_set_size (board->surface, BOARDWIDTH * newtile, BOARDHEIGHT * newtile); if (!board->level) return; count = clutter_group_get_n_children (CLUTTER_GROUP (board->level)); for (i = 0; i < count; i++) { tmp = clutter_group_get_nth_child (CLUTTER_GROUP (board->level), i); clutter_actor_get_position (tmp, &x_pos, &y_pos); clutter_actor_set_position (tmp, (x_pos / properties->tilesize) * newtile, (y_pos / properties->tilesize) * newtile); clutter_actor_set_size (tmp ,newtile, newtile); } }
void gnibbles_board_rescale (GnibblesBoard *board, gint tilesize) { gint i, count; gfloat x_pos, y_pos; ClutterActor *tmp; if (!board->level) return; if (!board->surface) return; board->width = BOARDWIDTH * tilesize; board->height = BOARDHEIGHT * tilesize; clutter_actor_set_size (CLUTTER_ACTOR (board->surface), board->width, board->height); count = clutter_group_get_n_children (CLUTTER_GROUP (board->level)); for (i = 0; i < count; i++) { tmp = clutter_group_get_nth_child (CLUTTER_GROUP (board->level), i); clutter_actor_get_position (CLUTTER_ACTOR (tmp), &x_pos, &y_pos); clutter_actor_set_position (CLUTTER_ACTOR (tmp), (x_pos / properties->tilesize) * tilesize, (y_pos / properties->tilesize) * tilesize); clutter_actor_set_size (CLUTTER_ACTOR (tmp), tilesize, tilesize); } }
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[]) { 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 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; }
G_MODULE_EXPORT int test_drag_main (int argc, char *argv[]) { ClutterActor *stage, *handle; ClutterAction *action; GError *error; error = NULL; clutter_init_with_args (&argc, &argv, "test-drag", entries, NULL, &error); if (error != NULL) { g_print ("Unable to run test-drag: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Drag Test"); clutter_actor_set_size (stage, 800, 600); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); handle = clutter_rectangle_new (); clutter_rectangle_set_color (CLUTTER_RECTANGLE (handle), CLUTTER_COLOR_SkyBlue); clutter_actor_set_size (handle, 128, 128); clutter_actor_set_position (handle, (800 - 128) / 2, (600 - 128) / 2); clutter_actor_set_reactive (handle, TRUE); clutter_container_add_actor (CLUTTER_CONTAINER (stage), handle); g_signal_connect (handle, "enter-event", G_CALLBACK (on_enter), NULL); g_signal_connect (handle, "leave-event", G_CALLBACK (on_leave), NULL); action = clutter_drag_action_new (); clutter_drag_action_set_drag_threshold (CLUTTER_DRAG_ACTION (action), x_drag_threshold, y_drag_threshold); clutter_drag_action_set_drag_axis (CLUTTER_DRAG_ACTION (action), get_drag_axis (drag_axis)); g_signal_connect (action, "drag-begin", G_CALLBACK (on_drag_begin), NULL); g_signal_connect (action, "drag-end", G_CALLBACK (on_drag_end), NULL); clutter_actor_add_action (handle, action); clutter_actor_add_effect_with_name (handle, "disable", clutter_desaturate_effect_new (0.0)); clutter_actor_add_effect_with_name (handle, "curl", clutter_page_turn_effect_new (0.0, 45.0, 12.0)); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
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; }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterAction *action1; ClutterAction *action2; ClutterActor *actor1; ClutterActor *actor2; 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); actor1 = clutter_actor_new (); clutter_actor_set_name (actor1, "Red Button"); clutter_actor_set_background_color (actor1, CLUTTER_COLOR_Red); clutter_actor_set_size (actor1, 100, 100); clutter_actor_set_reactive (actor1, TRUE); clutter_actor_set_position (actor1, 50, 150); clutter_actor_add_child (stage, actor1); actor2 = clutter_actor_new (); clutter_actor_set_name (actor2, "Blue Button"); clutter_actor_set_background_color (actor2, CLUTTER_COLOR_Blue); clutter_actor_set_size (actor2, 100, 100); clutter_actor_set_position (actor2, 250, 150); clutter_actor_set_reactive (actor2, TRUE); clutter_actor_add_child (stage, actor2); action1 = clutter_click_action_new (); clutter_actor_add_action (actor1, action1); action2 = clutter_click_action_new (); clutter_actor_add_action (actor2, action2); g_signal_connect (action1, "clicked", G_CALLBACK (clicked_cb), NULL); g_signal_connect (action2, "clicked", G_CALLBACK (clicked_cb), NULL); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
static void mpl_application_view_init (MplApplicationView *self) { MplApplicationViewPrivate *priv; ClutterActor *actor = CLUTTER_ACTOR (self); priv = self->priv = APPLICATION_VIEW_PRIVATE (self); /* tile */ clutter_actor_set_reactive (actor, TRUE); mx_stylable_set_style_class (MX_STYLABLE (actor), "switcherTile"); clutter_actor_set_size (actor, TILE_WIDTH, TILE_HEIGHT); g_signal_connect (self, "button-release-event", G_CALLBACK (activate_clicked), NULL); priv->title_box = mx_box_layout_new_with_orientation (MX_ORIENTATION_VERTICAL); clutter_actor_set_parent (priv->title_box, actor); /* title */ priv->title = mx_label_new (); mx_label_set_y_align (MX_LABEL (priv->title), MX_ALIGN_MIDDLE); mx_stylable_set_style_class (MX_STYLABLE (priv->title), "appTitle"); mx_box_layout_add_actor (MX_BOX_LAYOUT (priv->title_box), priv->title, 0); mx_box_layout_child_set_expand (MX_BOX_LAYOUT (priv->title_box), priv->title, TRUE); /* subtitle */ priv->subtitle = mx_label_new (); mx_label_set_y_align (MX_LABEL (priv->subtitle), MX_ALIGN_MIDDLE); mx_stylable_set_style_class (MX_STYLABLE (priv->subtitle), "appSubTitle"); mx_box_layout_add_actor (MX_BOX_LAYOUT (priv->title_box), priv->subtitle, 1); mx_box_layout_child_set_expand (MX_BOX_LAYOUT (priv->title_box), priv->subtitle, FALSE); /* close button */ priv->close_button = mx_button_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->close_button), "appCloseButton"); clutter_actor_set_parent (priv->close_button, actor); g_signal_connect (priv->close_button, "clicked", G_CALLBACK (close_btn_clicked), self); /* frame */ priv->app_frame = mx_frame_new (); clutter_actor_set_size (priv->app_frame, 250, 100); mx_stylable_set_style_class (MX_STYLABLE (priv->app_frame), "appBackground"); clutter_actor_set_parent (priv->app_frame, actor); /* shadow */ priv->shadow = mx_frame_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->shadow), "appShadow"); mx_bin_set_child (MX_BIN (priv->app_frame), priv->shadow); mx_bin_set_fill (MX_BIN (priv->app_frame), FALSE, FALSE); clutter_actor_show_all (actor); }
static gboolean invalidate_canvas (ChamplainPathLayer *layer) { ChamplainPathLayerPrivate *priv = layer->priv; gfloat view_width, view_height; gint map_width, map_height; gint viewport_x, viewport_y; gint anchor_x, anchor_y; gfloat right_actor_width, right_actor_height; gfloat left_actor_width, left_actor_height; right_actor_width = 256; right_actor_height = 256; left_actor_width = 0; left_actor_height = 0; map_width = 256; map_height = 256; if (priv->view != NULL) { get_map_size (priv->view, &map_width, &map_height); clutter_actor_get_size (CLUTTER_ACTOR (priv->view), &view_width, &view_height); champlain_view_get_viewport_origin (priv->view, &viewport_x, &viewport_y); champlain_view_get_viewport_anchor (priv->view, &anchor_x, &anchor_y); right_actor_width = MIN (map_width - (viewport_x + anchor_x), (gint)view_width); right_actor_height = MIN (map_height - (viewport_y + anchor_y), (gint)view_height); left_actor_width = MIN (view_width - right_actor_width, map_width - right_actor_width); left_actor_height = right_actor_height; /* Ensure sizes are positive */ right_actor_width = MAX (0, right_actor_width); right_actor_height = MAX (0, right_actor_height); left_actor_width = MAX (0, left_actor_width); left_actor_height = MAX (0, left_actor_height); } clutter_actor_set_size (priv->path_actor, map_width, map_height); clutter_actor_set_size (priv->right_actor, right_actor_width, right_actor_height); clutter_canvas_set_size (CLUTTER_CANVAS (priv->right_canvas), right_actor_width, right_actor_height); clutter_content_invalidate (priv->right_canvas); if (left_actor_width != 0) { clutter_actor_set_size (priv->left_actor, left_actor_width, left_actor_height); clutter_canvas_set_size (CLUTTER_CANVAS (priv->left_canvas), left_actor_width, left_actor_height); clutter_content_invalidate (priv->left_canvas); } priv->redraw_scheduled = FALSE; return FALSE; }
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; }
static ClutterActor * factory_func (PengeModelBridge *bridge, ClutterContainer *container, ClutterModel *model, ClutterModelIter *iter) { ClutterActor *actor; SwItem *item; clutter_model_iter_get (iter, 0, &item, -1); actor = g_object_new (PENGE_TYPE_PEOPLE_TILE, "item", item, NULL); clutter_actor_set_size (actor, 140, 95); clutter_container_add_actor (container, actor); if (g_str_equal (item->service, "twitter")) { clutter_layout_manager_child_set (layout, container, actor, "col-span", 2, NULL); } return actor; }
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_drag_begin (ClutterDragAction *action, ClutterActor *actor, gfloat event_x, gfloat event_y, ClutterModifierType modifiers) { gboolean is_copy = (modifiers & CLUTTER_SHIFT_MASK) ? TRUE : FALSE; ClutterActor *drag_handle = NULL; if (is_copy) { ClutterActor *stage = clutter_actor_get_stage (actor); drag_handle = clutter_rectangle_new (); clutter_actor_set_size (drag_handle, 48, 48); clutter_rectangle_set_color (CLUTTER_RECTANGLE (drag_handle), CLUTTER_COLOR_DarkSkyBlue); clutter_container_add_actor (CLUTTER_CONTAINER (stage), drag_handle); clutter_actor_set_position (drag_handle, event_x, event_y); } else drag_handle = actor; clutter_drag_action_set_drag_handle (action, drag_handle); /* fully desaturate the actor */ clutter_actor_animate (actor, CLUTTER_LINEAR, 150, "@effects.disable.factor", 1.0, NULL); }
GnibblesBoard * gnibbles_board_new (void) { gchar *filename; const char *dirname; GValue val = {0,}; GnibblesBoard *board = g_new (GnibblesBoard, 1); board->width = BOARDWIDTH; board->height = BOARDHEIGHT; board->level = NULL; board->surface = NULL; dirname = games_runtime_get_directory (GAMES_RUNTIME_GAME_PIXMAP_DIRECTORY); filename = g_build_filename (dirname, "wall-small-empty.svg", NULL); board->surface = clutter_texture_new_from_file (filename, NULL); clutter_actor_set_opacity (CLUTTER_ACTOR (board->surface), 100); g_value_init (&val, G_TYPE_BOOLEAN); g_value_set_boolean ( &val, TRUE); g_object_set_property (G_OBJECT (board->surface), "repeat-y", &val); g_object_set_property (G_OBJECT (board->surface), "repeat-x", &val); clutter_actor_set_position (CLUTTER_ACTOR (board->surface), 0, 0); clutter_actor_set_size (CLUTTER_ACTOR (board->surface), properties->tilesize * BOARDWIDTH, properties->tilesize * BOARDHEIGHT); clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (board->surface)); clutter_actor_show (CLUTTER_ACTOR (board->surface)); return board; }
static void am_ready_cb (GObject *source_object, GAsyncResult *result, gpointer userdata) { TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object); AnerleyFeed *feed; ClutterActor *stage; ClutterActor *scroll_view; ClutterActor *icon_view; ClutterModel *model; GError *error = NULL; if (!tp_account_manager_prepare_finish (account_manager, result, &error)) { g_warning ("Failed to make account manager ready: %s", error->message); g_error_free (error); return; } feed = ANERLEY_FEED (anerley_aggregate_tp_feed_new ()); model = CLUTTER_MODEL (anerley_feed_model_new (feed)); stage = clutter_stage_get_default (); icon_view = anerley_tile_view_new (ANERLEY_FEED_MODEL (model)); scroll_view = mx_scroll_view_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (scroll_view)); clutter_container_add_actor (CLUTTER_CONTAINER (scroll_view), CLUTTER_ACTOR (icon_view)); clutter_actor_set_size (CLUTTER_ACTOR (scroll_view), 640, 480); clutter_actor_show_all (stage); }
static void mpl_panel_clutter_set_size (MplPanelClient *self, guint width, guint height) { MplPanelClutterPrivate *priv = MPL_PANEL_CLUTTER (self)->priv; Display *xdpy = clutter_x11_get_default_display (); XSizeHints hints; MplPanelClientClass *p_class; p_class = MPL_PANEL_CLIENT_CLASS (mpl_panel_clutter_parent_class); clutter_actor_set_size (priv->stage, width, height); mpl_panel_clutter_ensure_window ((MplPanelClutter*)self); hints.min_width = width; hints.min_height = height; hints.flags = PMinSize; MPL_X_ERROR_TRAP (); XSetWMNormalHints (xdpy, priv->xwindow, &hints); XResizeWindow (xdpy, priv->xwindow, width, height); MPL_X_ERROR_UNTRAP (); clutter_stage_ensure_viewport (CLUTTER_STAGE (priv->stage)); if (p_class->set_size) p_class->set_size (self, width, height); }
static ClutterActor * make_button (char *text) { ClutterActor *button, *button_bg, *button_text; ClutterColor white = { 0xff, 0xff, 0xff, 0xff }; ClutterColor black = { 0x00, 0x00, 0x00, 0xff }; gfloat width, height; button = clutter_actor_new (); button_bg = clutter_actor_new (); clutter_actor_set_background_color (button_bg, &white); clutter_actor_add_child (button, button_bg); clutter_actor_set_opacity (button_bg, 0xcc); button_text = clutter_text_new_full ("Sans 10", text, &black); clutter_actor_add_child (button, button_text); clutter_actor_get_size (button_text, &width, &height); clutter_actor_set_size (button_bg, width + PADDING * 2, height + PADDING * 2); clutter_actor_set_position (button_bg, 0, 0); clutter_actor_set_position (button_text, PADDING, PADDING); return button; }
/* Setup the video texture once its size is known */ void size_change (ClutterActor *texture, gint width, gint height, gpointer user_data) { ClutterActor *stage; gfloat new_x, new_y, new_width, new_height; gfloat stage_width, stage_height; ClutterAnimation *animation = NULL; stage = clutter_actor_get_stage (texture); if (stage == NULL) return; clutter_actor_get_size (stage, &stage_width, &stage_height); /* Center video on window and calculate new size preserving aspect ratio */ new_height = (height * stage_width) / width; if (new_height <= stage_height) { new_width = stage_width; new_x = 0; new_y = (stage_height - new_height) / 2; } else { new_width = (width * stage_height) / height; new_height = stage_height; new_x = (stage_width - new_width) / 2; new_y = 0; } clutter_actor_set_position (texture, new_x, new_y); clutter_actor_set_size (texture, new_width, new_height); clutter_actor_set_rotation (texture, CLUTTER_Y_AXIS, 0.0, stage_width / 2, 0, 0); /* Animate it */ animation = clutter_actor_animate (texture, CLUTTER_LINEAR, 10000, "rotation-angle-y", 360.0, NULL); clutter_animation_set_loop (animation, TRUE); }
void on_texture_size_change (ClutterTexture *texture, gint width, gint height, gpointer user_data) { ClutterActor *stage; gfloat new_x, new_y, new_width, new_height; gfloat stage_width, stage_height; stage = clutter_actor_get_stage (CLUTTER_ACTOR (texture)); if (stage == NULL) return; clutter_actor_get_size (stage, &stage_width, &stage_height); new_height = (height * stage_width) / width; if (new_height <= stage_height) { new_width = stage_width; new_x = 0; new_y = (stage_height - new_height) / 2; } else { new_width = (width * stage_height) / height; new_height = stage_height; new_x = (stage_width - new_width) / 2; new_y = 0; } clutter_actor_set_position (CLUTTER_ACTOR (texture), new_x, new_y); clutter_actor_set_size (CLUTTER_ACTOR (texture), new_width, new_height); }
static void on_drag_begin (ClutterDragAction *action, ClutterActor *actor, gfloat event_x, gfloat event_y, ClutterModifierType modifiers) { ClutterActor *handle; gfloat x_pos, y_pos; clutter_actor_get_position (actor, &x_pos, &y_pos); handle = clutter_actor_new (); clutter_actor_set_background_color (handle, CLUTTER_COLOR_DarkSkyBlue); clutter_actor_set_size (handle, 128, 128); clutter_actor_set_position (handle, event_x - x_pos, event_y - y_pos); clutter_actor_add_child (stage, handle); clutter_drag_action_set_drag_handle (action, handle); clutter_actor_save_easing_state (actor); clutter_actor_set_easing_mode (actor, CLUTTER_LINEAR); clutter_actor_set_opacity (actor, 128); clutter_actor_restore_easing_state (actor); drop_successful = FALSE; }
IO_METHOD(IoClutterActor, setSize) { float width = IoMessage_locals_floatArgAt_(m, locals, 0), height = IoMessage_locals_floatArgAt_(m, locals, 1); clutter_actor_set_size(IOCACTOR(self), width, height); return self; }
int main(int argc, char *argv[]) { clutter_init(&argc, &argv); ClutterActor *stage = NULL; ClutterColor black = { 0x00, 0x00, 0x00, 0xff }; stage = clutter_stage_get_default(); clutter_stage_set_title(CLUTTER_STAGE(stage), "Mx test"); clutter_stage_set_color(CLUTTER_STAGE(stage), &black); clutter_actor_set_size(stage, WIN_W, WIN_H); Assistant *assistant = g_new0(Assistant, 1); assistant->script = require_script(GUI_SCRIPT); assistant->stage = stage; ClutterActor *root = CLUTTER_ACTOR(require_object_from_script(assistant->script, "root")); assistant->slider = CLUTTER_ACTOR(require_object_from_script(assistant->script, "slider")); assistant->combo_box = CLUTTER_ACTOR(require_object_from_script(assistant->script, "combo_box")); clutter_container_add_actor(CLUTTER_CONTAINER(stage), root); // Combo box contents: MxComboBox *combo_box = MX_COMBO_BOX(assistant->combo_box); mx_combo_box_append_text(combo_box, "Foo"); mx_combo_box_append_text(combo_box, "Spam"); mx_combo_box_append_text(combo_box, "Lorem ipsum"); mx_combo_box_set_index(combo_box, 0); // DONE g_signal_connect(stage, "key-press-event", G_CALLBACK(key_event_cb), assistant); clutter_script_connect_signals(assistant->script, assistant); assistant->ready_ = TRUE; clutter_actor_show(stage); clutter_main(); return 0; }
static ClutterActor * _make_notification_actor (MexNotification *notification) { ClutterActor *box; ClutterActor *label, *icon; box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_HORIZONTAL); if (notification->icon) { icon = mx_icon_new (); clutter_actor_set_size (icon, 26, 26); mx_icon_set_icon_name (MX_ICON (icon), notification->icon); clutter_container_add_actor (CLUTTER_CONTAINER (box), icon); mx_box_layout_child_set_y_align (MX_BOX_LAYOUT (box), icon, MX_ALIGN_MIDDLE); } label = mx_label_new_with_text (notification->message); mx_label_set_y_align (MX_LABEL (label), MX_ALIGN_MIDDLE); clutter_container_add_actor (CLUTTER_CONTAINER (box), label); return box; }
IO_METHOD(IoClutterActor, setPosition) { float x = IoMessage_locals_floatArgAt_(m, locals, 0), y = IoMessage_locals_floatArgAt_(m, locals, 1); clutter_actor_set_size(IOCACTOR(self), x, y); return self; }
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); }
void gnibbles_worm_reduce_tail (GnibblesWorm *worm, gint erasesize) { gint i; gfloat x,y; ClutterActor *tmp = NULL; ClutterActor *group = clutter_group_new (); if (erasesize) { if (g_list_length (worm->list) <= erasesize) { gnibbles_worm_reset (worm); return; } for (i = 0; i < erasesize; i++) { tmp = gtk_clutter_texture_new_from_pixbuf ( worm_pixmaps[properties->wormprops[worm->number]->color - 12]); clutter_actor_get_position (CLUTTER_ACTOR (g_list_last (worm->list)->data), &x, &y); clutter_actor_set_position (CLUTTER_ACTOR (tmp), x, y); clutter_actor_set_size (CLUTTER_ACTOR (tmp), properties->tilesize, properties->tilesize); clutter_container_add_actor (CLUTTER_CONTAINER (group), tmp); gnibbles_worm_move_tail_pointer (worm); } worm->length -= erasesize; clutter_container_add_actor (CLUTTER_CONTAINER (stage), group); clutter_actor_animate (group, CLUTTER_EASE_OUT_ELASTIC, 850, "opacity", 0, NULL); } }
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); }
/** * cinnamon_startup_sequence_create_icon: * @sequence: * @size: Size in pixels of icon * * Returns: (transfer none): A new #ClutterTexture containing an icon for the sequence */ ClutterActor * cinnamon_startup_sequence_create_icon (CinnamonStartupSequence *sequence, guint size) { GIcon *themed; const char *icon_name; ClutterActor *texture; icon_name = sn_startup_sequence_get_icon_name ((SnStartupSequence*)sequence); if (!icon_name) { gint scale; CinnamonGlobal *global; StThemeContext *context; texture = clutter_texture_new (); global = cinnamon_global_get (); context = st_theme_context_get_for_stage (cinnamon_global_get_stage (global)); g_object_get (context, "scale-factor", &scale, NULL); clutter_actor_set_size (texture, size * scale, size * scale); return texture; } themed = g_themed_icon_new (icon_name); texture = g_object_new (ST_TYPE_ICON, "gicon", themed, "icon-size", size, NULL); g_object_unref (G_OBJECT (themed)); return texture; }