static void st_box_layout_init (StBoxLayout *self) { ClutterLayoutManager *layout; self->priv = BOX_LAYOUT_PRIVATE (self); layout = clutter_box_layout_new (); g_signal_connect_swapped (layout, "layout-changed", G_CALLBACK (clutter_actor_queue_relayout), self); g_signal_connect (layout, "notify", G_CALLBACK (layout_notify), self); clutter_actor_set_layout_manager (CLUTTER_ACTOR (self), layout); }
/* Object initialization * Create private structure and set up default values */ static void xfdashboard_view_selector_init(XfdashboardViewSelector *self) { XfdashboardViewSelectorPrivate *priv; priv=self->priv=XFDASHBOARD_VIEW_SELECTOR_GET_PRIVATE(self); /* Set up default values */ priv->viewpad=NULL; priv->spacing=0.0f; priv->orientation=CLUTTER_ORIENTATION_HORIZONTAL; priv->layout=clutter_box_layout_new(); clutter_box_layout_set_orientation(CLUTTER_BOX_LAYOUT(priv->layout), priv->orientation); /* Set up actor */ clutter_actor_set_reactive(CLUTTER_ACTOR(self), TRUE); clutter_actor_set_layout_manager(CLUTTER_ACTOR(self), priv->layout); }
static void meta_switcher_init(MetaSwitcher *self) { MetaSwitcherPrivate* priv = self->priv = meta_switcher_get_instance_private(self); priv->selected_id = -1; priv->top = clutter_actor_new(); ClutterLayoutManager* box = clutter_box_layout_new(); clutter_box_layout_set_use_animations(CLUTTER_BOX_LAYOUT(box), TRUE); clutter_box_layout_set_easing_duration(CLUTTER_BOX_LAYOUT(box), 200); clutter_box_layout_set_easing_mode(CLUTTER_BOX_LAYOUT(box), CLUTTER_LINEAR); g_object_set(box, "spacing", 10, NULL); clutter_actor_set_layout_manager(priv->top, box); g_object_connect(G_OBJECT(priv->top), "signal::destroy", _emit_destroy, self, NULL); g_object_connect(priv->top, "signal::button-press-event", on_button_press, self, "signal::key-press-event", on_key_press, self, "signal::key-release-event", on_key_release, self, "signal::captured-event", on_captured_event, self, NULL); clutter_actor_hide(priv->top); }
int main(int argc, char *argv[]) { ClutterActor *stage; WebKitWebView *web_view; ClutterConstraint *width_binding; ClutterConstraint *height_binding; ClutterConstraint *web_view_height_binding; gfloat stageWidth, stageHeight; ClutterActorBox stageAllocation; ClutterLayoutManager *mainLayout; ClutterActor *mainLayoutContainer; ClutterLayoutManager *toolbarLayout; ClutterActor *toolbarContainer; ClutterLayoutManager *toolbarBinLayout; ClutterActor *toolbarBinContainer; ClutterActor *toolbarBgr; ClutterActor *statusBar; ClutterActor *backFwdBtns; ClutterActor *backBtn; ClutterActor *fwdBtn; ClutterActor *uriGroup; ClutterActor *uriBgr; ClutterActor *uriText; ClutterActor *spacer; GError *error = NULL; ClutterColor whiteColor = { 255, 255, 255, 255 }; ClutterColor blackColor = { 0, 0, 0, 255 }; ClutterColor grayColor = { 200, 200, 200, 255 }; ClutterColor transparentColor = { 0, 0, 0, 0 }; gchar *toolbarBgrPath = clutter_launcher_file_path("toolbar_bgr.png"); gchar *backBtnPath = clutter_launcher_file_path("back_btn.png"); gchar *fwdBtnPath = clutter_launcher_file_path("fwd_btn.png"); g_thread_init(NULL); clutter_threads_init(); clutter_init(&argc, &argv); stage = clutter_stage_get_default(); clutter_actor_set_size(stage, 1024, 768); clutter_stage_set_color(CLUTTER_STAGE(stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK(clutter_main_quit), NULL); /* make the stage resizable */ clutter_stage_set_user_resizable(CLUTTER_STAGE(stage), TRUE); clutter_actor_show(stage); mainLayout = clutter_box_layout_new(); clutter_box_layout_set_vertical(CLUTTER_BOX_LAYOUT(mainLayout), TRUE); clutter_actor_get_allocation_box(stage, &stageAllocation); stageWidth = stageAllocation.x2 - stageAllocation.x1; stageHeight = stageAllocation.y2 - stageAllocation.y1; web_view = WEBKIT_WEB_VIEW(webkit_web_view_new((guint)stageWidth, (guint)stageHeight - (toolbarHeight + statusBarHeight))); g_object_set(web_view, "reactive", TRUE, NULL); mainLayoutContainer = clutter_box_new(mainLayout); clutter_actor_set_size(mainLayoutContainer, stageWidth, stageHeight); width_binding = clutter_bind_constraint_new(stage, CLUTTER_BIND_WIDTH, 0); height_binding = clutter_bind_constraint_new(stage, CLUTTER_BIND_HEIGHT, 0); /* web_view_height_binding = clutter_bind_constraint_new(stage, CLUTTER_BIND_HEIGHT, -(toolbarHeight + statusBarHeight)); */ clutter_actor_add_constraint(mainLayoutContainer, width_binding); clutter_actor_add_constraint(mainLayoutContainer, height_binding); /* clutter_actor_add_constraint(CLUTTER_ACTOR(web_view), web_view_height_binding); */ toolbarBinLayout = clutter_bin_layout_new(CLUTTER_BIN_ALIGNMENT_FILL, CLUTTER_BIN_ALIGNMENT_CENTER); toolbarBinContainer = clutter_box_new(toolbarBinLayout); toolbarBgr = clutter_texture_new_from_file(toolbarBgrPath, &error); if (toolbarBgr == NULL) { fprintf(stderr, "Can't load file: %s. Aborting...\n", toolbarBgrPath); exit(1); } clutter_actor_set_height(toolbarBgr, toolbarHeight); clutter_texture_set_repeat(CLUTTER_TEXTURE(toolbarBgr), TRUE, FALSE); clutter_box_pack(CLUTTER_BOX(toolbarBinContainer), toolbarBgr, NULL, NULL); toolbarLayout = clutter_box_layout_new(); clutter_box_layout_set_vertical(CLUTTER_BOX_LAYOUT(toolbarLayout), FALSE); clutter_box_layout_set_spacing(CLUTTER_BOX_LAYOUT(toolbarLayout), 16); toolbarContainer = clutter_box_new(toolbarLayout); spacer = clutter_rectangle_new_with_color(&transparentColor); clutter_actor_set_size(spacer, 1, 1); clutter_box_pack(CLUTTER_BOX(toolbarContainer), spacer, NULL, NULL); backFwdBtns = clutter_group_new(); backBtn = clutter_texture_new_from_file(backBtnPath, &error); if (backBtn == NULL) { fprintf(stderr, "Can't load file: %s. Aborting...\n", backBtnPath); exit(1); } clutter_actor_set_reactive(backBtn, TRUE); /* connect the release event */ g_signal_connect (backBtn, "button-release-event", G_CALLBACK (on_back_release_cb), web_view); fwdBtn = clutter_texture_new_from_file(fwdBtnPath, &error); if (fwdBtn == NULL) { fprintf(stderr, "Can't load file: %s. Aborting...\n", fwdBtnPath); exit(1); } clutter_actor_set_reactive(fwdBtn, TRUE); /* connect the release event */ g_signal_connect (fwdBtn, "button-release-event", G_CALLBACK (on_fwd_release_cb), web_view); clutter_actor_set_position(fwdBtn, clutter_actor_get_width(backBtn), 0); clutter_container_add(CLUTTER_CONTAINER(backFwdBtns), backBtn, fwdBtn, NULL); clutter_box_pack(CLUTTER_BOX(toolbarContainer), backFwdBtns, NULL, NULL); uriGroup = clutter_group_new(); uriBgr = clutter_rectangle_new_with_color(&whiteColor); clutter_rectangle_set_border_color(CLUTTER_RECTANGLE(uriBgr), &blackColor); clutter_rectangle_set_border_width(CLUTTER_RECTANGLE(uriBgr), 1); clutter_actor_set_size(uriBgr, 400, 25); uriText = clutter_text_new_full("Helvetica 11px", "http://www.google.com", &blackColor); clutter_text_set_editable(CLUTTER_TEXT(uriText), TRUE); clutter_text_set_single_line_mode(CLUTTER_TEXT(uriText), TRUE); clutter_actor_set_position(uriText, 5, 7); clutter_actor_set_size(uriText, 390, 17); clutter_actor_set_reactive(uriText, TRUE); g_signal_connect(uriText, "activate", G_CALLBACK(on_uri_activate_cb), web_view); clutter_container_add(CLUTTER_CONTAINER(uriGroup), uriBgr, uriText, NULL); clutter_box_pack(CLUTTER_BOX(toolbarContainer), uriGroup, NULL, NULL); clutter_box_pack(CLUTTER_BOX(toolbarBinContainer), toolbarContainer, NULL, NULL); clutter_box_pack(CLUTTER_BOX(mainLayoutContainer), toolbarBinContainer, "y-align", CLUTTER_BOX_ALIGNMENT_START, NULL); clutter_box_layout_set_expand(CLUTTER_BOX_LAYOUT(mainLayout), toolbarBinContainer, TRUE); clutter_box_layout_set_fill(CLUTTER_BOX_LAYOUT(mainLayout), toolbarBinContainer, TRUE, FALSE); statusBar = clutter_rectangle_new_with_color(&grayColor); clutter_actor_set_height(statusBar, statusBarHeight); clutter_box_pack(CLUTTER_BOX(mainLayoutContainer), statusBar, "y-align", CLUTTER_BOX_ALIGNMENT_END, NULL); clutter_box_layout_set_expand(CLUTTER_BOX_LAYOUT(mainLayout), statusBar, TRUE); clutter_box_layout_set_fill(CLUTTER_BOX_LAYOUT(mainLayout), statusBar, TRUE, FALSE); clutter_box_pack_after(CLUTTER_BOX(mainLayoutContainer), CLUTTER_ACTOR(web_view), toolbarBinContainer, "y-align", CLUTTER_BOX_ALIGNMENT_START, NULL); clutter_box_layout_set_expand(CLUTTER_BOX_LAYOUT(mainLayout), CLUTTER_ACTOR(web_view), TRUE); clutter_box_layout_set_fill(CLUTTER_BOX_LAYOUT(mainLayout), CLUTTER_ACTOR(web_view), TRUE, TRUE); clutter_container_add(CLUTTER_CONTAINER(stage), mainLayoutContainer, NULL); g_signal_connect(web_view, "webkit-load-finished", G_CALLBACK(load_finished_cb), web_view); g_signal_connect(web_view, "notify::progress", G_CALLBACK (notify_progress_cb), web_view); /* g_signal_connect(stage, "delete-event", G_CALLBACK(delete_cb), web_view);*/ g_signal_connect(web_view, "notify::uri", G_CALLBACK(notify_uri_cb), uriText); gchar *uri = (gchar*) (argc > 1 ? argv[1] : "http://www.google.com/"); gchar *fileURL = filenameToURL(uri); webkit_web_view_load_uri(web_view, fileURL ? fileURL : uri); printf("%s\n", fileURL ? fileURL : uri); g_free(fileURL); g_timeout_add_full(G_PRIORITY_DEFAULT, 3000, timeout_cb, web_view, 0); clutter_threads_enter (); clutter_main(); clutter_threads_leave (); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { ClutterActor *stage, *box, *bg, *bg2, *inset, *labelContainer, *contentContainer, *labelbg, *fixed, *upper, *lower, *lowerInner; ClutterLayoutManager *layout, *labelContainer_l, *layoutFixed; ClutterTimeline *timeline; ClutterContent *canvas, *canvas1; ClutterColor color_with_trans = {0,0,0,0}; clutter_x11_set_use_argb_visual (TRUE); if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return (1); /* prepare the stage */ stage = clutter_stage_new (); clutter_stage_set_use_alpha (CLUTTER_STAGE (stage), TRUE); clutter_stage_set_color (CLUTTER_STAGE (stage), &color_with_trans); clutter_stage_set_title (CLUTTER_STAGE (stage), "IPLocation Database"); clutter_actor_set_background_color (stage, CLUTTER_COLOR_WHITE); clutter_actor_set_size (stage, 648, 246); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); clutter_actor_show (stage); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); box = clutter_actor_new (); clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0.0)); clutter_actor_set_background_color (box, CLUTTER_COLOR_WHITE); clutter_actor_set_layout_manager (box, layout); clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 1)); clutter_actor_set_name (box, "box"); clutter_actor_add_child (stage, box); bg = clutter_actor_new (); //clutter_actor_set_background_color (bg, clutter_color_new (50, 50, 50, 255)); clutter_actor_set_name (bg, "background"); clutter_actor_set_reactive (bg, TRUE); //clutter_actor_set_x_expand (bg, TRUE); //clutter_actor_set_y_expand (bg, TRUE); clutter_actor_set_x_align (bg, CLUTTER_ACTOR_ALIGN_END); clutter_actor_set_y_align (bg, CLUTTER_ACTOR_ALIGN_FILL); canvas1 = clutter_canvas_new (); clutter_canvas_set_size (CLUTTER_CANVAS (canvas1), 300, 300); clutter_actor_set_content (bg, canvas1); /*clutter_actor_set_content_scaling_filters (bg2, CLUTTER_SCALING_FILTER_TRILINEAR, CLUTTER_SCALING_FILTER_LINEAR);*/ g_object_unref (canvas1); clutter_actor_add_child (box, bg); bg2 = clutter_actor_new (); //clutter_actor_set_background_color (bg2, clutter_color_new (0, 100, 100, 255*.5)); clutter_actor_set_name (bg2, "background"); clutter_actor_set_reactive (bg2, TRUE); clutter_actor_set_size (bg2, 0, 0); //clutter_actor_set_x_expand (bg2, TRUE); //clutter_actor_set_y_expand (bg2, TRUE); clutter_actor_set_x_align (bg2, CLUTTER_ACTOR_ALIGN_END); clutter_actor_set_y_align (bg2, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_clip_to_allocation(bg2, TRUE); clutter_actor_add_child (box, bg2); clutter_actor_set_layout_manager (bg2, clutter_box_layout_new ()); canvas = clutter_canvas_new (); clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 300, 300); clutter_actor_set_content (bg2, canvas); /*clutter_actor_set_content_scaling_filters (bg2, CLUTTER_SCALING_FILTER_TRILINEAR, CLUTTER_SCALING_FILTER_LINEAR);*/ g_object_unref (canvas); inset = clutter_actor_new (); //clutter_actor_set_background_color (inset, clutter_color_new (255, 0, 0, 255)); clutter_actor_set_name (inset, "inset"); clutter_actor_set_reactive (inset, TRUE); clutter_actor_set_margin_top (inset, 18); clutter_actor_set_margin_right (inset, 18); clutter_actor_set_margin_bottom (inset, 18); clutter_actor_set_margin_left (inset, 48); //clutter_actor_set_x_expand (inset, TRUE); //clutter_actor_set_y_expand (inset, TRUE); clutter_actor_set_x_align (inset, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_y_align (inset, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_clip_to_allocation(inset, TRUE); clutter_actor_add_child (bg2, inset); layout = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (layout), TRUE); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (layout), 5); clutter_actor_set_layout_manager (inset, layout); labelContainer = clutter_actor_new (); clutter_actor_set_size (labelContainer, 0, 35); //clutter_actor_set_background_color (labelContainer, clutter_color_new (34, 134, 158, 255)); clutter_actor_set_name (labelContainer, "labelContainer"); clutter_actor_set_reactive (labelContainer, TRUE); //clutter_actor_set_x_expand (labelContainer, TRUE); //clutter_actor_set_y_expand (labelContainer, TRUE); clutter_actor_add_child (inset, labelContainer); labelContainer_l = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); clutter_actor_set_layout_manager (labelContainer, labelContainer_l); labelbg = clutter_actor_new (); clutter_actor_set_background_color (labelbg, clutter_color_new (34, 134, 158, 255)); clutter_actor_set_name (labelbg, "labelbg"); //clutter_actor_set_x_expand (labelbg, TRUE); clutter_actor_set_size (labelbg, 0, 35); clutter_actor_set_x_align (labelbg, CLUTTER_ACTOR_ALIGN_START); clutter_actor_set_y_align (labelbg, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_add_child (labelContainer, labelbg); contentContainer = clutter_actor_new (); clutter_actor_set_size (contentContainer, 0, 0); clutter_actor_set_background_color (contentContainer, clutter_color_new (0.290196*255, 0.427451*255, 0.462745*255, 255)); clutter_actor_set_name (contentContainer, "labelContainer"); //clutter_actor_set_x_expand (contentContainer, TRUE); //clutter_actor_set_y_expand (contentContainer, TRUE); clutter_actor_set_layout_manager (contentContainer, clutter_fixed_layout_new ()); clutter_actor_add_child (inset, contentContainer); fixed = clutter_actor_new (); clutter_actor_set_background_color (fixed, clutter_color_new (9, 53, 71, 255)); clutter_actor_set_name (fixed, "fixed"); clutter_actor_set_size (fixed, 582, 210-40); clutter_actor_set_position (fixed, 582, 0); layoutFixed = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (layoutFixed), TRUE); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (layoutFixed), 8); clutter_actor_set_layout_manager (fixed, layoutFixed); clutter_actor_add_child (contentContainer, fixed); //------------------------------------------------------------------------// lower = clutter_actor_new (); clutter_actor_set_size (lower, 0, 0); clutter_actor_set_name (lower, "lower"); //clutter_actor_set_x_expand (lower, TRUE); //clutter_actor_set_y_expand (lower, TRUE); clutter_actor_set_margin_right (lower, 8); clutter_actor_set_margin_top (lower, 8); clutter_actor_set_margin_left (lower, 8); clutter_actor_set_layout_manager (lower, clutter_fixed_layout_new ()); clutter_actor_set_clip_to_allocation(lower, TRUE); clutter_actor_add_child (fixed, lower); lowerInner = clutter_actor_new (); clutter_actor_set_background_color (lowerInner, clutter_color_new (255, 255, 255, 30)); clutter_actor_set_name (lowerInner, "fixed"); clutter_actor_set_size (lowerInner, 566, 113); clutter_actor_set_position (lowerInner, 566, 0); clutter_actor_add_child (lower, lowerInner); upper = clutter_actor_new (); clutter_actor_set_size (upper, 0, 33); clutter_actor_set_name (upper, "upper"); clutter_actor_set_x_expand (upper, TRUE); //clutter_actor_set_y_expand (upper, TRUE); clutter_actor_set_margin_bottom (upper, 8); clutter_actor_set_margin_right (upper, 8); clutter_actor_set_margin_left (upper, 8); //clutter_actor_set_layout_manager (upper, clutter_fixed_layout_new ()); clutter_actor_add_child (fixed, upper); timeline = clutter_timeline_new (57/24.*1000); clutter_timeline_add_marker_at_time(timeline, "first", (40-35)/24.*1000); clutter_timeline_add_marker_at_time(timeline, "second", (46-35)/24.*1000); clutter_timeline_add_marker_at_time(timeline, "third", (51-35)/24.*1000); clutter_timeline_add_marker_at_time(timeline, "fourth", (52-35)/24.*1000); clutter_timeline_add_marker_at_time(timeline, "fifth", (58-35)/24.*1000); g_signal_connect (timeline, "marker-reached::first", G_CALLBACK (plate1anim), bg); g_signal_connect (timeline, "marker-reached::second", G_CALLBACK (plate2anim), bg2); g_signal_connect (timeline, "marker-reached::third", G_CALLBACK (plate3anim), labelbg); g_signal_connect (timeline, "marker-reached::fourth", G_CALLBACK (plate4anim), fixed); g_signal_connect (timeline, "marker-reached::fifth", G_CALLBACK (plate5anim), lowerInner); g_signal_connect (canvas1, "draw", G_CALLBACK (draw_1), NULL); g_signal_connect (bg, "paint", G_CALLBACK (on_actor_resize), canvas); g_signal_connect (canvas, "draw", G_CALLBACK (draw), NULL); g_signal_connect (bg2, "paint", G_CALLBACK (on_actor_resize), canvas); clutter_content_invalidate (canvas); clutter_timeline_start (timeline); clutter_main (); return (EXIT_SUCCESS); }
static VALUE rbclt_box_layout_initialize (VALUE self) { rbclt_initialize_unowned (self, clutter_box_layout_new ()); return Qnil; }
static void load_controls (UserInterface * ui) { // Check icon files exist gchar *vid_panel_png; gchar *icon_files[6]; gchar *duration_str; gint c; ClutterColor control_color1 = { 0x12, 0x12, 0x12, 0xff }; ClutterColor control_color2 = { 0xcc, 0xcc, 0xcc, 0xff }; ClutterLayoutManager *controls_layout; ClutterLayoutManager *main_box_layout; ClutterLayoutManager *info_box_layout; ClutterLayoutManager *bottom_box_layout; ClutterLayoutManager *volume_box_layout; ClutterLayoutManager *seek_box_layout; ClutterLayoutManager *vol_int_box_layout; ClutterActor *seek_box; ClutterActor *bottom_box; ClutterActor *vol_int_box; GError *error = NULL; vid_panel_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR, "/vid-panel.png"); ui->play_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR, "/media-actions-start.png"); ui->pause_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR, "/media-actions-pause.png"); ui->volume_low_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR, "/audio-volume-low.png"); ui->volume_high_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR, "/audio-volume-high.png"); ui->segment_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR, "/media-actions-segment-point.png"); icon_files[0] = vid_panel_png; icon_files[1] = ui->play_png; icon_files[2] = ui->pause_png; icon_files[3] = ui->volume_low_png; icon_files[4] = ui->volume_high_png; icon_files[5] = ui->segment_png; for (c = 0; c < 6; c++) { if (!g_file_test (icon_files[c], G_FILE_TEST_EXISTS)) { g_print ("Icon file doesn't exist, are you sure you have " " installed snappy correctly?\nThis file needed is: %s\n", icon_files[c]); } } // Controls layout management controls_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED, CLUTTER_BIN_ALIGNMENT_FIXED); ui->control_box = clutter_box_new (controls_layout); // Controls background ui->control_bg = clutter_texture_new_from_file (vid_panel_png, &error); if (!ui->control_bg && error) g_debug ("Clutter error: %s\n", error->message); if (error) { g_error_free (error); error = NULL; } g_free (vid_panel_png); clutter_container_add_actor (CLUTTER_CONTAINER (ui->control_box), ui->control_bg); // Controls play toggle main_box_layout = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (main_box_layout), FALSE); ui->main_box = clutter_box_new (main_box_layout); ui->control_play_toggle = clutter_texture_new_from_file (ui->pause_png, &error); if (!ui->control_play_toggle && error) g_debug ("Clutter error: %s\n", error->message); if (error) { g_error_free (error); error = NULL; } clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (main_box_layout), ui->control_play_toggle, FALSE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_START, /* x-align */ CLUTTER_BOX_ALIGNMENT_CENTER); /* y-align */ clutter_container_add_actor (CLUTTER_CONTAINER (ui->control_box), ui->main_box); g_assert (ui->control_bg && ui->control_play_toggle); // Controls title info_box_layout = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (info_box_layout), TRUE); ui->info_box = clutter_box_new (info_box_layout); ui->control_title = clutter_text_new_full ("Sans 32px", cut_long_filename (ui->filename, ui->title_length), &control_color1); clutter_text_set_max_length (CLUTTER_TEXT (ui->control_title), ui->title_length); clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (info_box_layout), ui->control_title, TRUE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_CENTER, /* x-align */ CLUTTER_BOX_ALIGNMENT_START); /* y-align */ // Controls seek seek_box_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED, CLUTTER_BIN_ALIGNMENT_FIXED); seek_box = clutter_box_new (seek_box_layout); // In point ui->in_point = clutter_texture_new_from_file (ui->segment_png, &error); if (!ui->in_point && error) g_debug ("Clutter error: %s\n", error->message); if (error) { g_error_free (error); error = NULL; } clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->in_point); // background box rectangle shows as the border ui->control_seek1 = clutter_rectangle_new_with_color (&control_color1); clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->control_seek1); // smaller background rectangle inside seek1 to create a border ui->control_seek2 = clutter_rectangle_new_with_color (&control_color2); clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->control_seek2); // progress rectangle ui->control_seekbar = clutter_rectangle_new_with_color (&control_color1); clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->control_seekbar); clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (info_box_layout), seek_box, TRUE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_CENTER, /* x-align */ CLUTTER_BOX_ALIGNMENT_CENTER); /* y-align */ // Out point ui->out_point = clutter_texture_new_from_file (ui->segment_png, &error); if (!ui->out_point && error) g_debug ("Clutter error: %s\n", error->message); if (error) { g_error_free (error); error = NULL; } clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->out_point); // Controls bottom box bottom_box_layout = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (bottom_box_layout), FALSE); bottom_box = clutter_box_new (bottom_box_layout); // Controls volume box volume_box_layout = clutter_box_layout_new (); clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (volume_box_layout), FALSE); clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (volume_box_layout), 0); ui->volume_box = clutter_box_new (volume_box_layout); clutter_box_pack (CLUTTER_BOX (bottom_box), ui->volume_box, "x-align", CLUTTER_BOX_ALIGNMENT_START, "expand", TRUE, NULL); // Controls volume low ui->volume_low = clutter_texture_new_from_file (ui->volume_low_png, &error); if (!ui->volume_low && error) g_debug ("Clutter error: %s\n", error->message); if (error) { g_error_free (error); error = NULL; } clutter_box_pack (CLUTTER_BOX (ui->volume_box), ui->volume_low, "x-align", CLUTTER_BOX_ALIGNMENT_START, NULL); // Controls volume intensity vol_int_box_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED, CLUTTER_BIN_ALIGNMENT_FIXED); vol_int_box = clutter_box_new (vol_int_box_layout); ui->vol_int_bg = clutter_rectangle_new_with_color (&control_color1); clutter_container_add_actor (CLUTTER_CONTAINER (vol_int_box), ui->vol_int_bg); ui->vol_int = clutter_rectangle_new_with_color (&control_color1); clutter_container_add_actor (CLUTTER_CONTAINER (vol_int_box), ui->vol_int); clutter_box_pack (CLUTTER_BOX (ui->volume_box), vol_int_box, "x-fill", FALSE, "y-fill", FALSE, "y-align", CLUTTER_BOX_ALIGNMENT_CENTER, NULL); // Controls volume high ui->volume_high = clutter_texture_new_from_file (ui->volume_high_png, &error); if (!ui->volume_high && error) g_debug ("Clutter error: %s\n", error->message); if (error) { g_error_free (error); error = NULL; } clutter_box_pack (CLUTTER_BOX (ui->volume_box), ui->volume_high, "x-align", CLUTTER_BOX_ALIGNMENT_END, NULL); // Controls position text duration_str = g_strdup_printf (" 0:00:00/%s", ui->duration_str); ui->control_pos = clutter_text_new_full ("Sans 22px", duration_str, &control_color1); clutter_box_pack (CLUTTER_BOX (bottom_box), ui->control_pos, "x-align", CLUTTER_BOX_ALIGNMENT_END, "expand", TRUE, NULL); clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (info_box_layout), bottom_box, TRUE, /* expand */ FALSE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_CENTER, /* x-align */ CLUTTER_BOX_ALIGNMENT_END); /* y-align */ clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (main_box_layout), ui->info_box, FALSE, /* expand */ TRUE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_END, /* x-align */ CLUTTER_BOX_ALIGNMENT_CENTER); /* y-align */ clutter_actor_lower_bottom (ui->control_bg); size_change (CLUTTER_STAGE (ui->stage), ui); }
int main (int argc, char *argv[]) { ClutterActor *stage, *box, *instructions; ClutterLayoutManager *stage_layout, *grid_layout; GError *error = NULL; if (clutter_init_with_args (&argc, &argv, NULL, entries, NULL, &error) != CLUTTER_INIT_SUCCESS) { g_print ("Unable to run grid-layout: %s", error->message); g_error_free (error); return EXIT_FAILURE; } stage = clutter_stage_new (); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); stage_layout = clutter_box_layout_new (); clutter_box_layout_set_orientation (CLUTTER_BOX_LAYOUT (stage_layout), CLUTTER_ORIENTATION_VERTICAL); clutter_actor_set_layout_manager (stage, stage_layout); grid_layout = clutter_grid_layout_new (); if (is_vertical) clutter_grid_layout_set_orientation (CLUTTER_GRID_LAYOUT (grid_layout), CLUTTER_ORIENTATION_VERTICAL); box = clutter_actor_new (); clutter_actor_set_background_color (box, CLUTTER_COLOR_LightGray); clutter_actor_set_x_expand (box, TRUE); clutter_actor_set_y_expand (box, TRUE); clutter_actor_set_layout_manager (box, grid_layout); clutter_actor_add_child (stage, box); clutter_actor_set_x_align (box, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_y_align (box, CLUTTER_ACTOR_ALIGN_FILL); add_actor (box, 0, 0, 1, 1); add_actor (box, 1, 0, 1, 1); add_actor (box, 2, 0, 1, 1); add_actor (box, 0, 1, 1, 1); add_actor (box, 1, 1, 2, 1); add_actor (box, 0, 2, 3, 1); add_actor (box, 0, 3, 2, 2); add_actor (box, 2, 3, 1, 1); add_actor (box, 2, 4, 1, 1); instructions = clutter_text_new_with_text ("Sans 12px", INSTRUCTIONS); clutter_actor_set_margin_top (instructions, 4); clutter_actor_set_margin_left (instructions, 4); clutter_actor_set_margin_bottom (instructions, 4); clutter_actor_add_child (stage, instructions); clutter_actor_set_x_align (instructions, CLUTTER_ACTOR_ALIGN_FILL); clutter_actor_set_y_align (instructions, CLUTTER_ACTOR_ALIGN_CENTER); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); g_signal_connect (stage, "key-release-event", G_CALLBACK (key_release_cb), box); clutter_actor_show (stage); clutter_main (); return 0; }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterLayoutManager *box_layout; ClutterActor *box; ClutterActor *yellow; ClutterActor *red; ClutterActor *blue; 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); /* create a ClutterBoxLayout */ box_layout = clutter_box_layout_new (); /* configure it to lay out actors vertically */ clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (box_layout), TRUE); /* put 5px of spacing between actors */ clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (box_layout), 5); /* actors are packed into this actor; we set its width, but * allow its height to be determined by the children it contains */ box = clutter_actor_new (); clutter_actor_set_layout_manager (box, box_layout); clutter_actor_set_background_color (box, CLUTTER_COLOR_White); clutter_actor_set_position (box, 100, 50); clutter_actor_set_width (box, 200); /* pack an actor into the layout and set all layout properties on it * at the same time */ yellow = clutter_actor_new (); clutter_actor_set_background_color (yellow, CLUTTER_COLOR_Yellow); clutter_actor_set_size (yellow, 100, 100); clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (box_layout), yellow, FALSE, /* expand */ TRUE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_START, /* x-align */ CLUTTER_BOX_ALIGNMENT_START); /* y-align */ /* add an actor to the box as a container and set layout properties * afterwards; the latter is useful if you want to change properties on * actors already inside a layout, but note that you have to * pass the function both the layout AND the container */ red = clutter_actor_new (); clutter_actor_set_background_color (red, CLUTTER_COLOR_Red); clutter_actor_set_size (red, 100, 100); clutter_actor_add_child (box, red); clutter_layout_manager_child_set (box_layout, CLUTTER_CONTAINER (box), red, "x-fill", TRUE, NULL); blue = clutter_actor_new (); clutter_actor_set_background_color (blue, CLUTTER_COLOR_Blue); clutter_actor_set_size (blue, 100, 100); clutter_actor_add_child (box, blue); clutter_layout_manager_child_set (box_layout, CLUTTER_CONTAINER (box), blue, "x-fill", TRUE, NULL); /* put the box on the stage */ clutter_actor_add_child (stage, box); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
WindowPanel::WindowPanel() : auto_hide_(false) { ClutterLayoutManager * main_layout = clutter_bin_layout_new(CLUTTER_BIN_ALIGNMENT_FIXED, CLUTTER_BIN_ALIGNMENT_FIXED); actor_ = clutter_box_new(main_layout); ClutterActor * menu = clutter_cairo_texture_new(110, 22); clutter_actor_set_position(menu, 10.0f, 0.0f); cairo_t * context = clutter_cairo_texture_create(CLUTTER_CAIRO_TEXTURE(menu)); cairo_move_to(context, 0.0, 0.0); cairo_line_to(context, 0.0, 19.0); cairo_curve_to(context, 1.0, 21.0, 2.0, 22.0, 3.0, 22.0); cairo_line_to(context, 107.0, 22.0); cairo_curve_to(context, 108.0, 22.0, 109.0, 21.0, 110.0, 19.0); cairo_line_to(context, 110.0, 0.0); cairo_close_path(context); cairo_set_source_rgb(context, 0.8, 0.8, 0.8); cairo_fill_preserve(context); cairo_set_line_width(context, 1.0); cairo_set_source_rgb(context, 0.0, 0.0, 0.0); cairo_stroke(context); cairo_select_font_face(context, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size(context, 12.0); cairo_text_extents_t extents; cairo_text_extents(context, DISPLAY_NAME, &extents); cairo_move_to(context, 55.0 - ((extents.width / 2.0) + extents.x_bearing), 11.0 - ((extents.height / 2.0) + extents.y_bearing)); cairo_text_path(context, DISPLAY_NAME); cairo_set_source_rgb(context, 0.0, 0.0, 0.0); cairo_fill(context); cairo_destroy(context); clutter_box_pack(CLUTTER_BOX(actor_), menu, NULL, NULL); ClutterLayoutManager * controls_layout = clutter_box_layout_new(); clutter_box_layout_set_spacing(CLUTTER_BOX_LAYOUT(controls_layout), 10u); ClutterActor * controls = clutter_box_new(controls_layout); clutter_actor_add_constraint(controls, clutter_align_constraint_new(clutter_stage_get_default(), CLUTTER_ALIGN_X_AXIS, 0.95f)); clutter_actor_add_constraint(controls, clutter_bind_constraint_new(clutter_stage_get_default(), CLUTTER_BIND_Y, 5.0f)); fullscreen_button_ = clutter_cairo_texture_new(18, 16); clutter_actor_set_reactive(fullscreen_button_, TRUE); g_signal_connect(fullscreen_button_, "button-press-event", G_CALLBACK(fullscreen_clicked_cb), this); g_signal_connect(fullscreen_button_, "enter-event", G_CALLBACK(actor_highlight_on_cb), fullscreen_button_); g_signal_connect(fullscreen_button_, "leave-event", G_CALLBACK(actor_highlight_off_cb), fullscreen_button_); clutter_box_pack(CLUTTER_BOX(controls), fullscreen_button_, NULL, NULL); close_button_ = clutter_cairo_texture_new(15, 15); context = clutter_cairo_texture_create(CLUTTER_CAIRO_TEXTURE(close_button_)); cairo_move_to(context, 1.0, 3.0); cairo_line_to(context, 3.0, 1.0); cairo_line_to(context, 8.0, 6.0); cairo_line_to(context, 13.0, 1.0); cairo_line_to(context, 15.0, 3.0); cairo_line_to(context, 10.0, 8.0); cairo_line_to(context, 15.0, 13.0); cairo_line_to(context, 13.0, 15.0); cairo_line_to(context, 8.0, 10.0); cairo_line_to(context, 3.0, 15.0); cairo_line_to(context, 1.0, 13.0); cairo_line_to(context, 6.0, 8.0); cairo_close_path(context); cairo_set_source_rgb(context, 1.0, 1.0, 1.0); cairo_fill_preserve(context); cairo_set_line_width(context, 1.0); cairo_set_source_rgb(context, 0.0, 0.0, 0.0); cairo_stroke(context); cairo_destroy(context); clutter_actor_set_reactive(close_button_, TRUE); g_signal_connect(close_button_, "button-press-event", G_CALLBACK(close_clicked_cb), NULL); g_signal_connect(close_button_, "enter-event", G_CALLBACK(actor_highlight_on_cb), close_button_); g_signal_connect(close_button_, "leave-event", G_CALLBACK(actor_highlight_off_cb), close_button_); clutter_box_pack(CLUTTER_BOX(controls), close_button_, NULL, NULL); draw_window_controls(); clutter_box_pack(CLUTTER_BOX(actor_), controls, NULL, NULL); g_signal_connect(clutter_stage_get_default(), "fullscreen", G_CALLBACK(fullscreen_status_changed_cb), this); g_signal_connect(clutter_stage_get_default(), "unfullscreen", G_CALLBACK(fullscreen_status_changed_cb), this); g_signal_connect(clutter_stage_get_default(), "motion-event", G_CALLBACK(show_panel_cb), this); }