static void clutter_group_init (ClutterGroup *self) { ClutterActor *actor = CLUTTER_ACTOR (self); self->priv = clutter_group_get_instance_private (self); /* turn on some optimization * * XXX - these so-called "optimizations" are insane and should have never * been used. they introduce some weird behaviour that breaks invariants * and have to be explicitly worked around. * * this flag was set by the ClutterFixedLayout, but since that layout * manager is now the default for ClutterActor, we set the flag explicitly * here, to avoid breaking perfectly working actors overriding the * allocate() virtual function. * * also, we keep this flag here so that it can die once we get rid of * ClutterGroup. */ clutter_actor_set_flags (actor, CLUTTER_ACTOR_NO_LAYOUT); self->priv->layout = clutter_fixed_layout_new (); g_object_ref_sink (self->priv->layout); clutter_actor_set_layout_manager (actor, self->priv->layout); }
static void clutter_group_init (ClutterGroup *self) { self->priv = CLUTTER_GROUP_GET_PRIVATE (self); self->priv->layout = clutter_fixed_layout_new (); g_object_ref_sink (self->priv->layout); clutter_layout_manager_set_container (self->priv->layout, CLUTTER_CONTAINER (self)); }
static void champlain_group_init (ChamplainGroup *self) { self->priv = GET_PRIVATE (self); self->priv->layout = clutter_fixed_layout_new (); g_object_ref_sink (self->priv->layout); self->priv->children = NULL; self->priv->children_end = NULL; clutter_layout_manager_set_container (self->priv->layout, CLUTTER_CONTAINER (self)); }
int main (int argc, char **argv) { ClutterActor *stage = stage; ClutterActor *side_box; ClutterActor *button_box; ClutterActor *box; ClutterAnimation *anim; MashLightSet *light_set; MxStyle *style; GError *error = NULL; Data data; int i; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; style = mx_style_get_default (); if (!mx_style_load_from_file (style, "lights.css", &error)) { g_warning ("Error setting style: %s", error->message); g_clear_error (&error); } stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 800, 600); side_box = mx_table_new (); clutter_actor_set_name (side_box, "side-box"); clutter_container_add_actor (CLUTTER_CONTAINER (stage), side_box); clutter_actor_set_size (side_box, 300, clutter_actor_get_height (stage)); clutter_actor_set_x (side_box, clutter_actor_get_width (stage) - clutter_actor_get_width (side_box)); button_box = mx_table_new (); mx_table_add_actor (MX_TABLE (side_box), button_box, 0, 0); data.notebook = mx_notebook_new (); mx_table_add_actor (MX_TABLE (side_box), data.notebook, 1, 0); data.model = mash_model_new_from_file (MASH_DATA_NONE, argc > 1 ? argv[1] : "suzanne.ply", &error); if (data.model == NULL) { g_warning ("Error loading model: %s", error->message); g_clear_error (&error); return 1; } light_set = mash_light_set_new (); box = clutter_box_new (clutter_fixed_layout_new ()); clutter_actor_set_size (data.model, 400, 400); clutter_actor_set_position (data.model, 50.0, 100.0); clutter_container_add_actor (CLUTTER_CONTAINER (box), data.model); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); g_signal_connect_swapped (box, "paint", G_CALLBACK (cogl_set_depth_test_enabled), GINT_TO_POINTER (TRUE)); g_signal_connect_data (box, "paint", G_CALLBACK (cogl_set_depth_test_enabled), GINT_TO_POINTER (FALSE), NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED); data.light_marker_material = cogl_material_new (); { CoglColor color; cogl_color_set_from_4ub (&color, 255, 0, 0, 255); /* Use the layer state to ignore the vertex color from the shader so that the light marker won't itself be lit */ cogl_material_set_layer_combine_constant (data.light_marker_material, 0, &color); cogl_material_set_layer_combine (data.light_marker_material, 0, "RGBA = REPLACE(CONSTANT)", NULL); } clutter_actor_set_rotation (data.model, CLUTTER_Y_AXIS, 0.0f, clutter_actor_get_width (data.model) / 2.0f, 0.0f, 0.0f); anim = clutter_actor_animate (data.model, CLUTTER_LINEAR, 3000, "rotation-angle-y", 360.0f, NULL); clutter_animation_set_loop (anim, TRUE); for (i = 0; i < N_LIGHTS; i++) { ClutterActor *table = mx_table_new (); ClutterActor *button; static ClutterActor *(* constructors[N_LIGHTS]) (void) = { mash_directional_light_new, mash_point_light_new, mash_spot_light_new }; static const ClutterColor black = { 0, 0, 0, 255 }; data.lights[i] = constructors[i] (); button = mx_button_new_with_label (G_OBJECT_TYPE_NAME (data.lights[i])); mx_table_add_actor (MX_TABLE (button_box), button, i, 0); /* Default to disable all of the lights */ g_object_set (data.lights[i], "ambient", &black, "diffuse", &black, "specular", &black, NULL); data.notebook_buttons[i] = button; clutter_container_add_actor (CLUTTER_CONTAINER (box), data.lights[i]); mash_light_set_add_light (light_set, MASH_LIGHT (data.lights[i])); add_color_prop (table, "ambient light", G_OBJECT (data.lights[i]), "ambient"); add_color_prop (table, "diffuse light", G_OBJECT (data.lights[i]), "diffuse"); add_color_prop (table, "specular light", G_OBJECT (data.lights[i]), "specular"); if (MASH_IS_POINT_LIGHT (data.lights[i])) { add_float_prop (table, "constant attenuation", G_OBJECT (data.lights[i]), "constant-attenuation", 0.0f, 10.0f); add_float_prop (table, "linear attenuation", G_OBJECT (data.lights[i]), "linear-attenuation", 0.0f, 10.0f); add_float_prop (table, "quadratic attenuation", G_OBJECT (data.lights[i]), "quadratic-attenuation", 0.0f, 10.0f); } if (MASH_IS_SPOT_LIGHT (data.lights[i])) { clutter_actor_set_x (data.lights[i], 250); add_float_prop (table, "spot cutoff", G_OBJECT (data.lights[i]), "spot-cutoff", 0.0f, 90.0f); add_float_prop (table, "spot exponent", G_OBJECT (data.lights[i]), "spot-exponent", 0.0f, 128.0f); } clutter_container_add_actor (CLUTTER_CONTAINER (data.notebook), table); data.notebook_pages[i] = table; } { ClutterActor *button; ClutterActor *table; CoglHandle material; float maximum_shininess; material = mash_model_get_pipeline (MASH_MODEL (data.model)); /* Before version 1.3.10 on the 1.3 branch and 1.2.14 on the 1.2 branch Cogl would remap the shininess property to the range [0,1]. After this it is just a value greater or equal to zero (but GL imposes a limit of 128.0) */ if (clutter_check_version (1, 3, 9) || (clutter_major_version == 1 && clutter_minor_version == 2 && clutter_micro_version >= 13)) maximum_shininess = 128.0f; else maximum_shininess = 1.0f; cogl_material_set_shininess (material, maximum_shininess); button = mx_button_new_with_label ("Material"); data.notebook_buttons[i] = button; mx_table_add_actor (MX_TABLE (button_box), button, i, 0); table = mx_table_new (); data.notebook_pages[i] = table; clutter_container_add_actor (CLUTTER_CONTAINER (data.notebook), table); add_material_color_prop (table, "emission", material, cogl_material_set_emission, cogl_material_get_emission); add_material_color_prop (table, "diffuse", material, cogl_material_set_diffuse, cogl_material_get_diffuse); add_material_color_prop (table, "ambient", material, cogl_material_set_ambient, cogl_material_get_ambient); add_material_color_prop (table, "specular", material, cogl_material_set_specular, cogl_material_get_specular); add_material_float_prop (table, "shininess", material, 0.0f, maximum_shininess, cogl_material_set_shininess, cogl_material_get_shininess); } mash_model_set_light_set (MASH_MODEL (data.model), light_set); g_object_unref (light_set); for (i = 0; i < N_PAGES; i++) { g_signal_connect (data.notebook_buttons[i], "notify::toggled", G_CALLBACK (notebook_button_cb), &data); mx_button_set_is_toggle (MX_BUTTON (data.notebook_buttons[i]), TRUE); } mx_button_set_toggled (MX_BUTTON (data.notebook_buttons[0]), TRUE); g_signal_connect (stage, "motion-event", G_CALLBACK (motion_event_cb), &data); clutter_actor_show (stage); clutter_main (); cogl_handle_unref (data.light_marker_material); return 0; }
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_fixed_layout_initialize (VALUE self) { rbclt_initialize_unowned (self, clutter_fixed_layout_new ()); return Qnil; }