/** * mx_label_get_use_markup: * @label: a #MxLabel * * Determines whether the text of the label is being treated as Pango markup. * * Returns: %TRUE if the text of the label is treated as Pango markup, * %FALSE otherwise. * * Since: 1.2 */ gboolean mx_label_get_use_markup (MxLabel *label) { g_return_val_if_fail (MX_IS_LABEL (label), FALSE); return clutter_text_get_use_markup (CLUTTER_TEXT (label->priv->label)); }
G_MODULE_EXPORT int test_scale_main (int argc, char *argv[]) { ClutterActor *stage, *rect; ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; ClutterColor rect_color = { 0xff, 0xff, 0xff, 0x99 }; ClutterColor white_color = { 0xff, 0xff, 0xff, 0xFF }; ClutterTimeline *timeline; ClutterAlpha *alpha; ClutterBehaviour *behave; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_set_size (stage, 300, 300); rect = clutter_rectangle_new_with_color (&rect_color); clutter_actor_set_size (rect, 100, 100); clutter_actor_set_position (rect, 100, 100); clutter_group_add (CLUTTER_GROUP (stage), rect); label = clutter_text_new_with_text ("Sans 20px", ""); clutter_text_set_color (CLUTTER_TEXT (label), &white_color); clutter_actor_set_position (label, clutter_actor_get_x (rect), clutter_actor_get_y (rect) + clutter_actor_get_height (rect)); clutter_group_add (CLUTTER_GROUP (stage), label); rect_color.alpha = 0xff; rect = clutter_rectangle_new_with_color (&rect_color); clutter_actor_set_position (rect, 100, 100); clutter_actor_set_size (rect, 100, 100); set_next_gravity (rect); clutter_group_add (CLUTTER_GROUP (stage), rect); timeline = clutter_timeline_new (750); alpha = clutter_alpha_new_with_func (timeline, my_ramp_func, NULL, NULL); behave = clutter_behaviour_scale_new (alpha, 0.0, 0.0, /* scale start */ 1.0, 1.0); /* scale end */ clutter_behaviour_apply (behave, rect); clutter_timeline_set_loop (timeline, TRUE); g_signal_connect_swapped (timeline, "completed", G_CALLBACK (set_next_gravity), rect); clutter_timeline_start (timeline); clutter_actor_show_all (stage); clutter_main(); g_object_unref (timeline); g_object_unref (behave); return EXIT_SUCCESS; }
static void mx_label_allocate (ClutterActor *actor, const ClutterActorBox *box, ClutterAllocationFlags flags) { MxLabelPrivate *priv = MX_LABEL (actor)->priv; gboolean label_did_fade = priv->label_should_fade; ClutterActorClass *parent_class; ClutterActorBox child_box; gboolean x_fill, y_fill; gfloat avail_width; parent_class = CLUTTER_ACTOR_CLASS (mx_label_parent_class); parent_class->allocate (actor, box, flags); mx_widget_get_available_area (MX_WIDGET (actor), box, &child_box); avail_width = child_box.x2 - child_box.x1; /* The default behaviour of ClutterText is to align to the * top-left when it gets more space than is needed. Because * of this behaviour, if we're aligning to the left, we can * assign all our horizontal space to the label without * measuring it (i.e. x-fill), and the same applies for * aligning to the top and vertical space. */ x_fill = (priv->x_align == MX_ALIGN_START) ? TRUE : FALSE; y_fill = (priv->y_align == MX_ALIGN_START) ? TRUE : FALSE; mx_allocate_align_fill (priv->label, &child_box, priv->x_align, priv->y_align, x_fill, y_fill); priv->label_should_fade = FALSE; if (priv->fade_out) { /* If we're fading out, make sure the label has its full width * allocated. This ensures that the offscreen effect has the full * label inside its texture. */ gfloat label_width; clutter_actor_get_preferred_width (priv->label, -1, NULL, &label_width); if (label_width > avail_width) { priv->label_should_fade = TRUE; child_box.x2 = child_box.x1 + label_width; } mx_fade_effect_set_bounds (MX_FADE_EFFECT (priv->fade_effect), 0, 0, MIN (label_width, avail_width), 0); } /* Allocate the label */ clutter_actor_allocate (priv->label, &child_box, flags); if (priv->show_tooltip) { PangoLayout *layout; const gchar *text; layout = clutter_text_get_layout (CLUTTER_TEXT (priv->label)); if (pango_layout_is_ellipsized (layout)) text = clutter_text_get_text (CLUTTER_TEXT (priv->label)); else text = NULL; mx_widget_set_tooltip_text (MX_WIDGET (actor), text); } /* Animate in/out the faded end of the label */ if (label_did_fade != priv->label_should_fade) { /* Begin/reverse the fading timeline when necessary */ if (priv->label_should_fade) clutter_timeline_set_direction (priv->fade_timeline, CLUTTER_TIMELINE_FORWARD); else clutter_timeline_set_direction (priv->fade_timeline, CLUTTER_TIMELINE_BACKWARD); if (!clutter_timeline_is_playing (priv->fade_timeline)) clutter_timeline_rewind (priv->fade_timeline); clutter_timeline_start (priv->fade_timeline); } }
static void penge_event_tile_update (PengeEventTile *tile) { PengeEventTilePrivate *priv = GET_PRIVATE (tile); gchar *time_str; gchar *summary_str; JanaTime *t; gchar *p; if (!priv->event) return; if (priv->time) { t = jana_event_get_start (priv->event); /* Translate this time into local time */ jana_time_set_offset (t, jana_time_get_offset (priv->time)); if (jana_time_get_day (priv->time) != jana_time_get_day (t)) { gchar *tmp_str; gchar *day_str; ClutterActor *tmp_text; tmp_str = jana_utils_strftime (t, "%a"); day_str = g_utf8_strup (tmp_str, -1); g_free (tmp_str); time_str = jana_utils_strftime (t, "%H:%M"); tmp_str = g_strdup_printf ("%s <span size=\"xx-small\">%s</span>", time_str, day_str); g_free (time_str); g_free (day_str); tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->time_label)); clutter_text_set_markup (CLUTTER_TEXT (tmp_text), tmp_str); g_free (tmp_str); } else { time_str = jana_utils_strftime (t, "%H:%M"); mx_label_set_text (MX_LABEL (priv->time_label), time_str); g_free (time_str); } if (jana_time_get_day (priv->time) != jana_time_get_day (t)) { mx_stylable_set_style_pseudo_class (MX_STYLABLE (priv->time_label), "past"); } else { mx_stylable_set_style_pseudo_class (MX_STYLABLE (priv->time_label), NULL); } g_object_unref (t); } summary_str = jana_event_get_summary (priv->event); if (summary_str) { /* this hack is courtesy of Chris Lord, we look for a new line character * and if we find it replace it with \0. We need this because otherwise * new lines in our labels look funn */ p = strchr (summary_str, '\n'); if (p) *p = '\0'; mx_label_set_text (MX_LABEL (priv->summary_label), summary_str); g_free (summary_str); } else { mx_label_set_text (MX_LABEL (priv->summary_label), ""); } }
static void add_actor (ClutterActor *box, gint left, gint top, gint width, gint height) { ClutterLayoutManager *layout; ClutterActor *rect, *text; ClutterColor color; clutter_color_from_hls (&color, g_random_double_range (0.0, 360.0), 0.5, 0.5); color.alpha = 255; rect = clutter_actor_new (); clutter_actor_set_layout_manager (rect, clutter_bin_layout_new ()); clutter_actor_set_background_color (rect, &color); clutter_actor_set_reactive (rect, TRUE); if (random_size) clutter_actor_set_size (rect, g_random_int_range (40, 80), g_random_int_range (40, 80)); else clutter_actor_set_size (rect, 60, 60); clutter_actor_set_x_expand (rect, default_expand); clutter_actor_set_y_expand (rect, default_expand); if (!default_expand) { clutter_actor_set_x_align (rect, CLUTTER_ACTOR_ALIGN_CENTER); clutter_actor_set_y_align (rect, CLUTTER_ACTOR_ALIGN_CENTER); } if (random_align) { clutter_actor_set_x_align (rect, g_random_int_range (0, 3)); clutter_actor_set_y_align (rect, g_random_int_range (0, 3)); } text = clutter_text_new_with_text ("Sans 8px", NULL); clutter_text_set_line_alignment (CLUTTER_TEXT (text), PANGO_ALIGN_CENTER); clutter_actor_add_child (rect, text); g_signal_connect (rect, "button-release-event", G_CALLBACK (button_release_cb), NULL); g_signal_connect (rect, "notify::x-expand", G_CALLBACK (changed_cb), text); g_signal_connect (rect, "notify::y-expand", G_CALLBACK (changed_cb), text); g_signal_connect (rect, "notify::x-align", G_CALLBACK (changed_cb), text); g_signal_connect (rect, "notify::y-align", G_CALLBACK (changed_cb), text); layout = clutter_actor_get_layout_manager (box); if (use_box) clutter_actor_add_child (box, rect); else clutter_grid_layout_attach (CLUTTER_GRID_LAYOUT (layout), rect, left, top, width, height); changed_cb (rect, NULL, text); }
static gboolean do_tests (CallbackData *data) { PangoFontDescription *fd; static const ClutterColor red = { 0xff, 0x00, 0x00, 0xff }; PangoAttrList *attr_list, *attr_list_copy; PangoAttribute *attr; /* TEST 1: change the text */ clutter_text_set_text (CLUTTER_TEXT (data->label), "Counter 0"); pango_layout_set_text (data->test_layout, "Counter 0", -1); g_assert (check_result (data, "Change text", TRUE) == FALSE); /* TEST 2: change a single character */ clutter_text_set_text (CLUTTER_TEXT (data->label), "Counter 1"); pango_layout_set_text (data->test_layout, "Counter 1", -1); g_assert (check_result (data, "Change a single character", TRUE) == FALSE); /* TEST 3: move the label */ clutter_actor_set_position (data->label, 10, 0); g_assert (check_result (data, "Move the label", FALSE) == FALSE); /* TEST 4: change the font */ clutter_text_set_font_name (CLUTTER_TEXT (data->label), "Serif 15"); fd = pango_font_description_from_string ("Serif 15"); pango_layout_set_font_description (data->test_layout, fd); pango_font_description_free (fd); g_assert (check_result (data, "Change the font", TRUE) == FALSE); /* TEST 5: change the color */ clutter_text_set_color (CLUTTER_TEXT (data->label), &red); g_assert (check_result (data, "Change the color", FALSE) == FALSE); /* TEST 6: change the attributes */ attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD); attr->start_index = 0; attr->end_index = 2; attr_list = pango_attr_list_new (); pango_attr_list_insert (attr_list, attr); attr_list_copy = pango_attr_list_copy (attr_list); clutter_text_set_attributes (CLUTTER_TEXT (data->label), attr_list); pango_layout_set_attributes (data->test_layout, attr_list_copy); pango_attr_list_unref (attr_list_copy); pango_attr_list_unref (attr_list); g_assert (check_result (data, "Change the attributes", TRUE) == FALSE); /* TEST 7: change the text again */ clutter_text_set_attributes (CLUTTER_TEXT (data->label), NULL); clutter_text_set_text (CLUTTER_TEXT (data->label), long_text); pango_layout_set_attributes (data->test_layout, NULL); pango_layout_set_text (data->test_layout, long_text, -1); g_assert (check_result (data, "Change the text again", TRUE) == FALSE); /* TEST 8: enable markup */ clutter_text_set_use_markup (CLUTTER_TEXT (data->label), TRUE); pango_layout_set_markup (data->test_layout, long_text, -1); g_assert (check_result (data, "Enable markup", TRUE) == FALSE); /* This part can't be a test because Clutter won't restrict the width if wrapping and ellipsizing is disabled so the extents will be different, but we still want to do it for the later tests */ clutter_actor_set_width (data->label, 200); pango_layout_set_width (data->test_layout, 200 * PANGO_SCALE); /* Force a redraw so that changing the width won't affect the results */ force_redraw (data); /* TEST 9: enable ellipsize */ clutter_text_set_ellipsize (CLUTTER_TEXT (data->label), PANGO_ELLIPSIZE_END); pango_layout_set_ellipsize (data->test_layout, PANGO_ELLIPSIZE_END); g_assert (check_result (data, "Enable ellipsize", TRUE) == FALSE); clutter_text_set_ellipsize (CLUTTER_TEXT (data->label), PANGO_ELLIPSIZE_NONE); pango_layout_set_ellipsize (data->test_layout, PANGO_ELLIPSIZE_NONE); force_redraw (data); /* TEST 10: enable line wrap */ clutter_text_set_line_wrap (CLUTTER_TEXT (data->label), TRUE); pango_layout_set_wrap (data->test_layout, PANGO_WRAP_WORD); g_assert (check_result (data, "Enable line wrap", TRUE) == FALSE); /* TEST 11: change wrap mode * FIXME - broken */ clutter_text_set_line_wrap_mode (CLUTTER_TEXT (data->label), PANGO_WRAP_CHAR); pango_layout_set_wrap (data->test_layout, PANGO_WRAP_CHAR); g_assert (check_result (data, "Change wrap mode", TRUE) == FALSE); /* TEST 12: enable justify */ clutter_text_set_justify (CLUTTER_TEXT (data->label), TRUE); pango_layout_set_justify (data->test_layout, TRUE); /* Pango appears to have a bug which means that you can't change the justification after setting the text but this fixes it. See http://bugzilla.gnome.org/show_bug.cgi?id=551865 */ pango_layout_context_changed (data->test_layout); g_assert (check_result (data, "Enable justify", TRUE) == FALSE); /* TEST 13: change alignment */ clutter_text_set_line_alignment (CLUTTER_TEXT (data->label), PANGO_ALIGN_RIGHT); pango_layout_set_alignment (data->test_layout, PANGO_ALIGN_RIGHT); g_assert (check_result (data, "Change alignment", TRUE) == FALSE); clutter_main_quit (); return FALSE; }
static void penge_event_tile_init (PengeEventTile *self) { PengeEventTilePrivate *priv = GET_PRIVATE_REAL (self); ClutterActor *tmp_text; ClutterActor *indicator_container, *indicator_overlay; GError *error = NULL; self->priv = priv; priv->inner_table = mx_table_new (); mx_bin_set_child (MX_BIN (self), (ClutterActor *)priv->inner_table); mx_bin_set_fill (MX_BIN (self), TRUE, TRUE); indicator_container = mx_stack_new (); clutter_actor_set_size (indicator_container, 20, 20); priv->calendar_indicator = clutter_cairo_texture_new (20, 20); clutter_actor_set_size (priv->calendar_indicator, 20, 20); indicator_overlay = clutter_texture_new_from_file (CALENDAR_INDICATOR_OVERLAY_MASK, &error); if (error != NULL) { g_critical (G_STRLOC ": Loading calendar colour overlay failed: %s", error->message); g_clear_error (&error); indicator_overlay = NULL; } else { clutter_actor_set_size (indicator_overlay, 20, 20); } clutter_container_add (CLUTTER_CONTAINER (indicator_container), priv->calendar_indicator, indicator_overlay, NULL); priv->time_label = mx_label_new (); tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->time_label)); clutter_text_set_ellipsize (CLUTTER_TEXT (tmp_text), PANGO_ELLIPSIZE_NONE); mx_stylable_set_style_class (MX_STYLABLE (priv->time_label), "PengeEventTimeLabel"); priv->summary_label = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->summary_label), "PengeEventSummary"); tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->summary_label)); clutter_text_set_ellipsize (CLUTTER_TEXT (tmp_text), PANGO_ELLIPSIZE_END); clutter_text_set_single_line_mode (CLUTTER_TEXT (tmp_text), TRUE); /* Populate the table */ mx_table_add_actor (MX_TABLE (priv->inner_table), indicator_container, 0, 0); mx_table_add_actor (MX_TABLE (priv->inner_table), priv->time_label, 0, 1); mx_table_add_actor (MX_TABLE (priv->inner_table), priv->summary_label, 0, 2); clutter_container_child_set (CLUTTER_CONTAINER (priv->inner_table), indicator_container, "x-expand", FALSE, "x-fill", FALSE, "y-expand", FALSE, "y-fill", FALSE, NULL); clutter_container_child_set (CLUTTER_CONTAINER (priv->inner_table), priv->time_label, "x-expand", FALSE, "x-fill", FALSE, "y-expand", FALSE, "y-fill", FALSE, NULL); clutter_container_child_set (CLUTTER_CONTAINER (priv->inner_table), priv->summary_label, "x-expand", TRUE, "x-fill", TRUE, "y-expand", FALSE, "y-fill", FALSE, NULL); /* Setup spacing and padding */ mx_table_set_column_spacing (MX_TABLE (priv->inner_table), 6); g_signal_connect (self, "clicked", (GCallback)_button_clicked_cb, self); clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE); }
static void mx_tooltip_style_changed (MxWidget *self) { ClutterColor *color = NULL; MxTooltipPrivate *priv; gchar *font_name; gchar *font_string; gint font_size; MxBorderImage *border_image; priv = MX_TOOLTIP (self)->priv; mx_stylable_get (MX_STYLABLE (self), "color", &color, "font-family", &font_name, "font-size", &font_size, "border-image", &border_image, NULL); if (color) { clutter_text_set_color (CLUTTER_TEXT (priv->label), color); clutter_color_free (color); } if (font_name || font_size) { if (font_name && font_size) { font_string = g_strdup_printf ("%s %dpx", font_name, font_size); g_free (font_name); } else if (font_size) font_string = g_strdup_printf ("%dpx", font_size); else font_string = font_name; clutter_text_set_font_name (CLUTTER_TEXT (priv->label), font_string); g_free (font_string); } /* remove existing border image */ if (priv->border_image) { g_boxed_free (MX_TYPE_BORDER_IMAGE, priv->border_image); priv->border_image = NULL; } if (priv->border_image_texture) { cogl_handle_unref (priv->border_image_texture); priv->border_image_texture = NULL; } if (border_image) { priv->border_image_texture = mx_texture_cache_get_cogl_texture (mx_texture_cache_get_default (), border_image->uri); priv->border_image = border_image; } clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); }
G_MODULE_EXPORT int test_bin_layout_main (int argc, char *argv[]) { ClutterActor *stage, *box, *rect; ClutterLayoutManager *layout; ClutterColor stage_color = { 0xe0, 0xf2, 0xfc, 0xff }; ClutterColor *color; ClutterAction *action; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_get_default (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Box test"); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_set_size (stage, 640, 480); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); box = clutter_box_new (layout); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); clutter_actor_set_anchor_point_from_gravity (box, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (box, 320, 240); clutter_actor_set_reactive (box, TRUE); clutter_actor_set_name (box, "box"); /* the contents of the texture are created every time the allocation * of the box changes, to keep the background's size the same as the * box's size */ rect = clutter_cairo_texture_new (100, 100); /* first method: use clutter_box_pack() */ clutter_box_pack (CLUTTER_BOX (box), rect, "x-align", CLUTTER_BIN_ALIGNMENT_FILL, "y-align", CLUTTER_BIN_ALIGNMENT_FILL, NULL); clutter_actor_lower_bottom (rect); clutter_actor_set_name (rect, "background"); g_signal_connect (box, "allocation-changed", G_CALLBACK (on_box_allocation_changed), rect); { ClutterActor *tex; GError *error; gchar *file; error = NULL; file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); tex = clutter_texture_new_from_file (file, &error); if (error) g_error ("Unable to create texture: %s", error->message); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (tex), TRUE); /* second method: use clutter_bin_layout_add() */ clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout), tex, CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); clutter_actor_raise (tex, rect); clutter_actor_set_width (tex, 175); clutter_actor_set_name (tex, "texture"); g_free (file); } color = clutter_color_new (g_random_int_range (0, 255), g_random_int_range (0, 255), g_random_int_range (0, 255), 224); rect = clutter_rectangle_new_with_color (color); /* third method: container_add() and set_alignment() */ clutter_container_add_actor (CLUTTER_CONTAINER (box), rect); clutter_bin_layout_set_alignment (CLUTTER_BIN_LAYOUT (layout), rect, CLUTTER_BIN_ALIGNMENT_END, CLUTTER_BIN_ALIGNMENT_END); clutter_actor_set_size (rect, 50, 50); clutter_actor_set_opacity (rect, 0); clutter_actor_set_reactive (rect, TRUE); clutter_actor_raise_top (rect); clutter_actor_set_name (rect, "emblem"); action = clutter_click_action_new (); clutter_actor_add_action (rect, action); g_signal_connect (action, "clicked", G_CALLBACK (on_rect_clicked), box); g_signal_connect (action, "long-press", G_CALLBACK (on_rect_long_press), box); g_signal_connect (box, "enter-event", G_CALLBACK (on_box_enter), rect); g_signal_connect (box, "leave-event", G_CALLBACK (on_box_leave), rect); rect = clutter_text_new (); clutter_text_set_text (CLUTTER_TEXT (rect), "A simple test"); clutter_container_add_actor (CLUTTER_CONTAINER (box), rect); clutter_bin_layout_set_alignment (CLUTTER_BIN_LAYOUT (layout), rect, CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_START); clutter_actor_raise_top (rect); clutter_actor_set_name (rect, "text"); clutter_actor_show_all (stage); clutter_main (); clutter_color_free (color); return EXIT_SUCCESS; }
static void mnb_people_panel_init (MnbPeoplePanel *self) { MnbPeoplePanelPrivate *priv = GET_PRIVATE (self); ClutterActor *label; ClutterActor *scroll_view, *bin, *tmp_text; AnerleyFeed *active_feed; ClutterActor *settings_launcher; mx_table_set_column_spacing (MX_TABLE (self), 6); mx_table_set_row_spacing (MX_TABLE (self), 6); /* Populate top level table */ priv->header_box = mx_table_new (); clutter_actor_set_name (priv->header_box, "people-panel-header-box"); mx_table_set_column_spacing (MX_TABLE (priv->header_box), 20); mx_table_add_actor_with_properties (MX_TABLE (self), CLUTTER_ACTOR (priv->header_box), 0, 0, "column-span", 2, "x-expand", TRUE, "y-expand", FALSE, "x-fill", TRUE, "y-fill", TRUE, "x-align", MX_ALIGN_START, "y-align", MX_ALIGN_START, NULL); priv->content_table = mx_table_new (); clutter_actor_set_name (priv->content_table, "people-panel-content-box"); mx_table_add_actor_with_properties (MX_TABLE (self), CLUTTER_ACTOR (priv->content_table), 1, 0, "x-expand", TRUE, "y-expand", TRUE, "x-fill", TRUE, "y-fill", TRUE, NULL); priv->side_table = mx_table_new (); clutter_actor_set_width (priv->side_table, 288); clutter_actor_set_name (priv->side_table, "people-panel-side-box"); mx_table_add_actor_with_properties (MX_TABLE (self), CLUTTER_ACTOR (priv->side_table), 1, 1, "x-expand", FALSE, "y-expand", TRUE, "x-fill", TRUE, "y-fill", TRUE, NULL); /* Populate header */ label = mx_label_new_with_text (_("People")); mx_table_add_actor_with_properties (MX_TABLE (priv->header_box), CLUTTER_ACTOR (label), 0, 0, "x-expand", FALSE, "y-expand", FALSE, "x-fill", FALSE, "y-fill", FALSE, "x-align", MX_ALIGN_START, "y-align", MX_ALIGN_MIDDLE, NULL); clutter_actor_set_name (label, "people-panel-header-label"); /* Main body table */ bin = mx_frame_new (); clutter_actor_set_name (bin, "people-panel-content-header"); label = mx_label_new_with_text (_("Me and my people")); clutter_actor_set_name (label, "people-panel-content-header-label"); mx_bin_set_child (MX_BIN (bin), label); mx_bin_set_alignment (MX_BIN (bin), MX_ALIGN_START, MX_ALIGN_MIDDLE); mx_table_add_actor_with_properties (MX_TABLE (priv->content_table), CLUTTER_ACTOR (bin), 0, 0, "x-expand", TRUE, "y-expand", FALSE, "x-fill", TRUE, "y-fill", FALSE, "x-align", MX_ALIGN_START, "y-align", MX_ALIGN_MIDDLE, NULL); /* Me table containing avatar, name and presence chooser */ priv->me_table = mx_table_new (); mx_table_set_column_spacing (MX_TABLE (priv->me_table), 16); mx_table_set_row_spacing (MX_TABLE (priv->me_table), 8); clutter_actor_set_name (priv->me_table, "people-panel-me-box"); priv->avatar = anerley_tp_user_avatar_new (); bin = mx_frame_new (); clutter_actor_set_name (bin, "people-panel-me-avatar-frame"); mx_bin_set_child (MX_BIN (bin), priv->avatar); clutter_actor_set_size (priv->avatar, 48, 48); mx_bin_set_fill (MX_BIN (bin), TRUE, TRUE); mx_table_add_actor_with_properties (MX_TABLE (priv->me_table), bin, 0, 0, "row-span", 2, "x-expand", FALSE, "y-expand", TRUE, "x-fill", FALSE, "y-fill", FALSE, NULL); label = mx_label_new_with_text (_("Me")); clutter_actor_set_name (label, "people-panel-me-label"); mx_table_add_actor_with_properties (MX_TABLE (priv->me_table), label, 0, 1, "x-expand", TRUE, "y-expand", FALSE, NULL); priv->presence_chooser = anerley_presence_chooser_new (); mx_table_add_actor_with_properties (MX_TABLE (priv->me_table), priv->presence_chooser, 1, 1, "x-expand", TRUE, "x-fill", FALSE, "x-align", MX_ALIGN_START, "y-expand", TRUE, "y-fill", TRUE, NULL); settings_launcher = _make_settings_launcher (self); mx_table_add_actor_with_properties (MX_TABLE (priv->me_table), settings_launcher, 0, 2, "x-expand", TRUE, "x-fill", FALSE, "x-align", MX_ALIGN_END, "y-expand", TRUE, "y-fill", FALSE, "row-span", 2, NULL); mx_table_add_actor_with_properties (MX_TABLE (priv->content_table), CLUTTER_ACTOR (priv->me_table), 1, 0, "x-expand", TRUE, "y-expand", FALSE, "x-fill", TRUE, "y-fill", FALSE, "x-align", MX_ALIGN_START, "y-align", MX_ALIGN_MIDDLE, NULL); priv->tp_feed = anerley_aggregate_tp_feed_new (); priv->model = (AnerleyFeedModel *)anerley_feed_model_new (priv->tp_feed); priv->tile_view = anerley_tile_view_new (priv->model); priv->main_scroll_view = mx_scroll_view_new (); clutter_container_add_actor (CLUTTER_CONTAINER (priv->main_scroll_view), priv->tile_view); mx_table_add_actor (MX_TABLE (priv->content_table), priv->main_scroll_view, 2, 0); /* No people && no accounts enabled */ priv->no_people_tile = _make_empty_people_tile (self); clutter_actor_hide (priv->no_people_tile); mx_table_add_actor_with_properties (MX_TABLE (priv->content_table), priv->no_people_tile, 1, 0, "x-fill", TRUE, "x-expand", TRUE, "y-expand", TRUE, "y-fill", TRUE, NULL); /* No people && acounts are online */ priv->everybody_offline_tile = _make_everybody_offline_tile (self); clutter_actor_hide (priv->everybody_offline_tile); mx_table_add_actor_with_properties (MX_TABLE (priv->content_table), priv->everybody_offline_tile, 2, 0, "x-fill", TRUE, "x-expand", TRUE, "y-expand", FALSE, "y-fill", FALSE, "y-align", MX_ALIGN_START, "row-span", 1, NULL); priv->offline_banner = _make_offline_banner (self, clutter_actor_get_width (priv->main_scroll_view)); clutter_actor_hide (priv->offline_banner); mx_table_add_actor_with_properties (MX_TABLE (priv->content_table), priv->offline_banner, 2, 0, "x-fill", TRUE, "x-expand", TRUE, "y-expand", FALSE, "y-fill", FALSE, "y-align", MX_ALIGN_START, "row-span", 1, NULL); /* Side table */ label = mx_label_new_with_text (_("My conversations")); clutter_actor_set_name (label, "people-panel-side-box-header-label"); bin = mx_frame_new (); clutter_actor_set_name (bin, "people-panel-side-box-header"); mx_bin_set_child (MX_BIN (bin), label); mx_bin_set_alignment (MX_BIN (bin), MX_ALIGN_START, MX_ALIGN_MIDDLE); mx_table_add_actor_with_properties (MX_TABLE (priv->side_table), CLUTTER_ACTOR (bin), 0, 0, "x-expand", TRUE, "y-expand", FALSE, "x-fill", TRUE, "y-fill", FALSE, "x-align", MX_ALIGN_START, "y-align", MX_ALIGN_MIDDLE, NULL); mx_table_add_actor_with_properties (MX_TABLE (priv->side_table), _make_messenger_launcher_tile (self), 1, 0, "x-expand", TRUE, "y-expand", FALSE, "x-fill", TRUE, "y-fill", FALSE, NULL); active_feed = anerley_tp_monitor_feed_new ((AnerleyAggregateTpFeed *)priv->tp_feed, "MeegoPanelPeople"); priv->active_model = (AnerleyFeedModel *)anerley_feed_model_new (active_feed); priv->active_list_view = anerley_compact_tile_view_new (priv->active_model); scroll_view = mx_scroll_view_new (); clutter_container_add_actor (CLUTTER_CONTAINER (scroll_view), priv->active_list_view); /* active conversations */ priv->active_content_table = mx_table_new (); clutter_actor_set_name (priv->active_content_table, "people-panel-active-content-box"); bin = mx_frame_new (); clutter_actor_set_name (bin, "people-panel-active-content-header"); label = mx_label_new_with_text (_("You are chatting with:")); clutter_actor_set_name (label, "people-panel-active-content-header-label"); tmp_text = mx_label_get_clutter_text (MX_LABEL (label)); clutter_text_set_ellipsize (CLUTTER_TEXT(tmp_text), PANGO_ELLIPSIZE_NONE); mx_bin_set_child (MX_BIN (bin), label); mx_bin_set_alignment (MX_BIN (bin), MX_ALIGN_START, MX_ALIGN_MIDDLE); mx_bin_set_fill (MX_BIN (bin), TRUE, TRUE); mx_table_add_actor_with_properties (MX_TABLE (priv->active_content_table), bin, 0, 0, "y-expand", FALSE, NULL); mx_table_add_actor (MX_TABLE (priv->active_content_table), scroll_view, 1, 0); mx_table_add_actor_with_properties (MX_TABLE (priv->side_table), priv->active_content_table, 2, 0, "x-expand", TRUE, NULL); g_signal_connect (priv->tile_view, "item-activated", (GCallback)_tile_view_item_activated_cb, self); g_signal_connect (priv->active_list_view, "item-activated", (GCallback)_tile_view_item_activated_cb, self); g_signal_connect (priv->model, "bulk-change-end", (GCallback)_model_bulk_changed_end_cb, self); g_signal_connect (priv->active_model, "bulk-change-end", (GCallback)_active_model_bulk_change_end_cb, self); clutter_actor_hide ((ClutterActor *)priv->main_scroll_view); /* Placeholder changes based on onlineness or not */ _update_placeholder_state (self); g_signal_connect (priv->tp_feed, "notify::accounts-online", (GCallback)_tp_feed_online_notify_cb, self); g_signal_connect (priv->tp_feed, "notify::accounts-available", (GCallback)_tp_feed_available_notify_cb, self); sw_online_add_notify (_online_notify_cb, self); _update_online_state (self, sw_is_online ()); }
static ClutterActor * _make_empty_people_tile (MnbPeoplePanel *people_panel) { ClutterActor *tile; ClutterActor *frame; ClutterActor *label; ClutterActor *tmp_text; ClutterActor *settings_launcher; ClutterActor *picture; tile = mx_table_new (); mx_table_set_row_spacing (MX_TABLE (tile), 8); clutter_actor_set_name ((ClutterActor *)tile, "people-pane-no-people-tile"); /* title */ frame = mx_frame_new (); clutter_actor_set_name (frame, "people-no-people-message-bin"); label = mx_label_new_with_text (_("This is the People panel.")); clutter_actor_set_name (label, "people-no-people-message-title"); mx_bin_set_child (MX_BIN (frame), label); mx_table_insert_actor_with_properties (MX_TABLE (tile), frame, 0, 0, "x-expand", TRUE, "y-expand", FALSE, "x-fill", TRUE, "y-fill", FALSE, "x-align", MX_ALIGN_START, NULL); mx_bin_set_alignment (MX_BIN (frame), MX_ALIGN_START, MX_ALIGN_MIDDLE); /* message */ frame = mx_frame_new (); clutter_actor_set_name (frame, "people-no-people-message-bin"); label = mx_label_new_with_text (PLACEHOLDER_MESSAGE); clutter_actor_set_name (label, "people-no-people-message-label"); tmp_text = mx_label_get_clutter_text (MX_LABEL (label)); clutter_text_set_line_wrap (CLUTTER_TEXT (tmp_text), TRUE); clutter_text_set_line_wrap_mode (CLUTTER_TEXT (tmp_text), PANGO_WRAP_WORD_CHAR); clutter_text_set_ellipsize (CLUTTER_TEXT (tmp_text), PANGO_ELLIPSIZE_NONE); clutter_actor_set_width (label, 500); mx_bin_set_child (MX_BIN (frame), label); mx_table_insert_actor_with_properties (MX_TABLE (tile), frame, 1, 0, "x-expand", TRUE, "y-expand", TRUE, "x-fill", TRUE, "y-fill", TRUE, "x-align", MX_ALIGN_START, NULL); mx_bin_set_alignment (MX_BIN (frame), MX_ALIGN_START, MX_ALIGN_MIDDLE); settings_launcher = _make_settings_launcher (people_panel); clutter_actor_set_name (settings_launcher, "people-panel-settings-launcher-tile"); mx_table_insert_actor_with_properties (MX_TABLE (tile), settings_launcher, 2, 0, "x-expand", TRUE, "y-expand", FALSE, "x-fill", TRUE, "y-fill", FALSE, "x-align", MX_ALIGN_START, NULL); picture = clutter_texture_new_from_file (PLACEHOLDER_IMAGE, NULL); mx_table_insert_actor_with_properties (MX_TABLE (tile), picture, 3, 0, "x-expand", TRUE, "y-expand", TRUE, "x-fill", FALSE, "y-fill", FALSE, "x-align", MX_ALIGN_END, "y-align", MX_ALIGN_END, NULL); return tile; }
static void mnb_people_panel_init (MnbPeoplePanel *self) { MnbPeoplePanelPrivate *priv = GET_PRIVATE (self); ClutterActor *label; ClutterActor *scroll_view, *scroll_bin, *bin, *tmp_text; AnerleyFeed *active_feed; mx_table_set_column_spacing (MX_TABLE (self), 4); mx_table_set_row_spacing (MX_TABLE (self), 6); clutter_actor_set_name (CLUTTER_ACTOR (self), "people-vbox"); priv->header_box = mx_table_new (); clutter_actor_set_name (CLUTTER_ACTOR (priv->header_box), "people-search"); mx_table_set_column_spacing (MX_TABLE (priv->header_box), 20); mx_table_add_actor_with_properties (MX_TABLE (self), CLUTTER_ACTOR (priv->header_box), 0, 0, "row-span", 1, "x-expand", TRUE, "y-expand", FALSE, "x-fill", TRUE, "y-fill", TRUE, "x-align", MX_ALIGN_START, "y-align", MX_ALIGN_START, NULL); label = mx_label_new_with_text (_("People")); clutter_actor_set_name (CLUTTER_ACTOR (label), "people-search-label"); mx_table_add_actor_with_properties (MX_TABLE (priv->header_box), CLUTTER_ACTOR (label), 0, 0, "x-expand", FALSE, "y-expand", FALSE, "x-fill", FALSE, "y-fill", FALSE, "x-align", MX_ALIGN_START, "y-align", MX_ALIGN_MIDDLE, NULL); priv->entry = (ClutterActor *) mpl_entry_new (_("Search")); clutter_actor_set_name (CLUTTER_ACTOR (priv->entry), "people-search-entry"); clutter_actor_set_width (CLUTTER_ACTOR (priv->entry), 600); mx_table_add_actor_with_properties (MX_TABLE (priv->header_box), CLUTTER_ACTOR (priv->entry), 0, 1, "x-expand", FALSE, "y-expand", FALSE, "x-fill", FALSE, "y-fill", FALSE, "x-align", MX_ALIGN_START, "y-align", MX_ALIGN_MIDDLE, NULL); priv->presence_chooser = anerley_presence_chooser_new (); mx_table_add_actor_with_properties (MX_TABLE (priv->header_box), priv->presence_chooser, 0, 2, "x-expand", TRUE, "x-fill", FALSE, "x-align", MX_ALIGN_END, "y-expand", TRUE, "y-fill", TRUE, NULL); g_signal_connect (priv->entry, "text-changed", (GCallback)_entry_text_changed_cb, self); priv->tp_feed = anerley_aggregate_tp_feed_new (); priv->model = (AnerleyFeedModel *)anerley_feed_model_new (priv->tp_feed); priv->tile_view = anerley_tile_view_new (priv->model); active_feed = anerley_tp_monitor_feed_new ((AnerleyAggregateTpFeed *)priv->tp_feed, "MeegoPanelPeople"); priv->active_model = (AnerleyFeedModel *)anerley_feed_model_new (active_feed); priv->active_list_view = anerley_compact_tile_view_new (priv->active_model); scroll_view = mx_scroll_view_new (); clutter_container_add_actor (CLUTTER_CONTAINER (scroll_view), priv->active_list_view); priv->content_table = mx_table_new (); clutter_actor_set_name (priv->content_table, "content-table"); /* active conversations */ priv->active_content_table = mx_table_new (); clutter_actor_hide (priv->active_content_table); clutter_actor_set_name (priv->active_content_table, "active-content-table"); bin = mx_frame_new (); label = mx_label_new_with_text (_("You are chatting with:")); tmp_text = mx_label_get_clutter_text (MX_LABEL (label)); clutter_text_set_ellipsize (CLUTTER_TEXT(tmp_text), PANGO_ELLIPSIZE_NONE); clutter_actor_set_name (label, "active-content-header-label"); mx_bin_set_child (MX_BIN (bin), label); mx_bin_set_alignment (MX_BIN (bin), MX_ALIGN_START, MX_ALIGN_MIDDLE); mx_bin_set_fill (MX_BIN (bin), TRUE, TRUE); clutter_actor_set_name (bin, "active-content-header"); mx_table_add_actor_with_properties (MX_TABLE (priv->active_content_table), bin, 0, 0, "y-expand", FALSE, NULL); mx_table_add_actor (MX_TABLE (priv->active_content_table), scroll_view, 1, 0); mx_table_add_actor_with_properties (MX_TABLE (priv->content_table), priv->active_content_table, 0, 1, "x-expand", FALSE, NULL); /* main area */ scroll_view = mx_scroll_view_new (); clutter_container_add_actor (CLUTTER_CONTAINER (scroll_view), priv->tile_view); scroll_bin = mx_table_new (); mx_table_add_actor (MX_TABLE (scroll_bin), scroll_view, 0, 0); mx_table_add_actor (MX_TABLE (priv->content_table), scroll_bin, 0, 0); clutter_actor_set_name (scroll_bin, "people-scroll-bin"); /* No people && no accounts enabled */ priv->no_people_tile = _make_empty_people_tile (self); mx_table_add_actor_with_properties (MX_TABLE (self), priv->no_people_tile, 1, 0, "x-fill", TRUE, "x-expand", TRUE, "y-expand", FALSE, "y-fill", FALSE, "y-align", MX_ALIGN_START, "row-span", 1, NULL); /* No people && acounts are online */ priv->everybody_offline_tile = _make_everybody_offline_tile (self); clutter_actor_hide (priv->everybody_offline_tile); mx_table_add_actor_with_properties (MX_TABLE (self), priv->everybody_offline_tile, 1, 0, "x-fill", TRUE, "x-expand", TRUE, "y-expand", FALSE, "y-fill", FALSE, "y-align", MX_ALIGN_START, "row-span", 1, NULL); priv->offline_banner = _make_offline_banner (self, clutter_actor_get_width (scroll_view)); clutter_actor_hide (priv->offline_banner); mx_table_add_actor_with_properties (MX_TABLE (self), priv->offline_banner, 1, 0, "x-fill", TRUE, "x-expand", TRUE, "y-expand", FALSE, "y-fill", FALSE, "y-align", MX_ALIGN_START, "row-span", 1, NULL); /* Real content stuff */ mx_table_add_actor_with_properties (MX_TABLE (self), priv->content_table, 2, 0, "x-fill", TRUE, "x-expand", TRUE, "y-expand", TRUE, "y-fill", TRUE, "row-span", 1, NULL); g_signal_connect (priv->tile_view, "item-activated", (GCallback)_tile_view_item_activated_cb, self); g_signal_connect (priv->active_list_view, "item-activated", (GCallback)_tile_view_item_activated_cb, self); /* Put into the no people state */ clutter_actor_hide ((ClutterActor *)priv->content_table); g_signal_connect (priv->model, "bulk-change-end", (GCallback)_model_bulk_changed_end_cb, self); g_signal_connect (priv->active_model, "bulk-change-end", (GCallback)_active_model_bulk_change_end_cb, self); /* Placeholder changes based on onlineness or not */ _update_placeholder_state (self); g_signal_connect (priv->tp_feed, "notify::accounts-online", (GCallback)_tp_feed_online_notify_cb, self); g_signal_connect (priv->tp_feed, "notify::accounts-available", (GCallback)_tp_feed_available_notify_cb, self); sw_online_add_notify (_online_notify_cb, self); _update_online_state (self, sw_is_online ()); }
G_MODULE_EXPORT int test_shader_effects_main (int argc, char *argv[]) { ClutterTimeline *timeline; ClutterActor *stage, *hand, *label, *rect; gchar *file; clutter_init (&argc, &argv); /* Make a timeline */ timeline = clutter_timeline_new (7692); clutter_timeline_set_loop (timeline, TRUE); stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Rotations"); clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Aluminium3); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* Make a hand */ file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); hand = clutter_texture_new_from_file (file, NULL); if (!hand) g_error("Unable to load '%s'", file); g_free (file); clutter_actor_set_position (hand, 326, 265); clutter_actor_add_effect_with_name (hand, "desaturate", clutter_desaturate_effect_new (0.75)); clutter_actor_add_effect_with_name (hand, "blur", clutter_blur_effect_new ()); clutter_actor_animate_with_timeline (hand, CLUTTER_LINEAR, timeline, "@effects.desaturate.factor", 1.0, "rotation-angle-z", 360.0, "fixed::anchor-x", 86.0, "fixed::anchor-y", 125.0, "opacity", 128, NULL); rect = clutter_rectangle_new_with_color (CLUTTER_COLOR_DarkOrange); clutter_actor_add_effect_with_name (rect, "blur", clutter_blur_effect_new ()); clutter_actor_set_position (rect, 415, 215); clutter_actor_set_size (rect, 150, 150); clutter_actor_animate_with_timeline (rect, CLUTTER_LINEAR, timeline, "rotation-angle-z", 360.0, "fixed::anchor-x", 75.0, "fixed::anchor-y", 75.0, NULL); label = clutter_text_new_with_text ("Mono 16", "The Wonder\n" "of the\n" "Spinning Hand"); clutter_text_set_line_alignment (CLUTTER_TEXT (label), PANGO_ALIGN_CENTER); clutter_actor_set_position (label, 336, 275); clutter_actor_set_size (label, 500, 100); clutter_actor_animate_with_timeline (label, CLUTTER_LINEAR, timeline, "rotation-angle-z", 360.0, "fixed::anchor-x", 86.0, "fixed::anchor-y", 125.0, NULL); clutter_container_add (CLUTTER_CONTAINER (stage), rect, hand, label, NULL); /* start the timeline and thus the animations */ clutter_timeline_start (timeline); clutter_actor_show_all (stage); clutter_main(); g_object_unref (timeline); return 0; }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterLayoutManager *layout; ClutterActor *box; ClutterActor *rect; ClutterActor *text; ClutterState *transitions; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_stage_set_title (CLUTTER_STAGE (stage), "btn"); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FILL, CLUTTER_BIN_ALIGNMENT_FILL); box = clutter_box_new (layout); clutter_actor_set_position (box, 25, 25); clutter_actor_set_reactive (box, TRUE); clutter_actor_set_size (box, 100, 30); /* background for the button */ rect = clutter_rectangle_new_with_color (&yellow); clutter_container_add_actor (CLUTTER_CONTAINER (box), rect); /* text for the button */ text = clutter_text_new_full ("Sans 10pt", "Hover me", &white); clutter_text_set_line_alignment (CLUTTER_TEXT (text), PANGO_ALIGN_CENTER); /* * NB don't set the height, so the actor assumes the height of the text; * then when added to the bin layout, it gets centred on it; * also if you don't set the width, the layout goes gets really wide; * the 10pt text fits inside the 30px height of the rectangle */ clutter_actor_set_width (text, 100); clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout), text, CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); /* animations */ transitions = clutter_state_new (); clutter_state_set (transitions, NULL, "fade-out", box, "opacity", CLUTTER_LINEAR, 180, NULL); /* * NB you can't use an easing mode where alpha > 1.0 if you're * animating to a value of 255, as the value you're animating * to will possibly go > 255 */ clutter_state_set (transitions, NULL, "fade-in", box, "opacity", CLUTTER_LINEAR, 255, NULL); clutter_state_set_duration (transitions, NULL, NULL, 50); clutter_state_warp_to_state (transitions, "fade-out"); g_signal_connect (box, "enter-event", G_CALLBACK (_pointer_enter_cb), transitions); g_signal_connect (box, "leave-event", G_CALLBACK (_pointer_leave_cb), transitions); /* bind the stage size to the box size + 50px in each axis */ clutter_actor_add_constraint (stage, clutter_bind_constraint_new (box, CLUTTER_BIND_HEIGHT, 50.0)); clutter_actor_add_constraint (stage, clutter_bind_constraint_new (box, CLUTTER_BIND_WIDTH, 50.0)); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); clutter_actor_show (stage); clutter_main (); g_object_unref (transitions); return 0; }
static VALUE rbclt_text_layout (VALUE self) { ClutterText *text = CLUTTER_TEXT (RVAL2GOBJ (self)); return GOBJ2RVAL (clutter_text_get_layout (text)); }
void make_ui (App *app) { gint i, xpad, ypad, x ,y, xinit, xdpy, ydpy; ClutterActor *button_texture, *a; ClutterColor text_color = { 0xff, 0xff, 0xff, 0xff }, rect_color = { 0, 0, 0, 0x99 }, black_color = { 0, 0, 0, 0xff }; button_texture = clutter_texture_new_from_file ("button.png", NULL); xpad = (CSW-(3*clutter_actor_get_width(button_texture)))/4; x = xinit = xpad; ypad = xpad/2; y = (CSH - (4 * (ypad + clutter_actor_get_height(button_texture)))); /* * screen_dialpad (group) * +----dpy (group) * +---- (texture:display.png) * +----dpy_entry (text) * +----buttons[0:11]->actor (group) * +---- (texture:button.png) * +---- (text) */ app->screen_dialpad = clutter_group_new(); clutter_actor_set_size (app->screen_dialpad, CSW, CSH); clutter_actor_set_anchor_point_from_gravity (app->screen_dialpad, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (app->screen_dialpad, CSW/2, CSH/2); app->dpy = clutter_group_new(); a = clutter_texture_new_from_file ("display.png", NULL); clutter_group_add (CLUTTER_GROUP(app->dpy), a); app->dpyx = xdpy = x; app->dpyy = ydpy = (y - clutter_actor_get_height(app->dpy))/2; clutter_actor_set_position (app->dpy, xdpy, ydpy); clutter_group_add(CLUTTER_GROUP(app->screen_dialpad), app->dpy); app->dpy_entry = clutter_text_new_full ("Sans Bold 32px", "", &text_color); clutter_text_set_editable (CLUTTER_TEXT(app->dpy_entry), TRUE); clutter_actor_set_position (app->dpy_entry, 8, 8); clutter_actor_set_size (app->dpy_entry, clutter_actor_get_width (app->dpy) - 16, 32); clutter_group_add (CLUTTER_GROUP(app->dpy), app->dpy_entry); for (i=0; i<12; i++) { gchar buf[8]; gchar label[8]; app->buttons[i] = g_new0(Button, 1); app->buttons[i]->actor = clutter_group_new (); g_snprintf (label, 8, "%d", i+1); clutter_actor_set_name (app->buttons[i]->actor, label); clutter_actor_set_reactive (app->buttons[i]->actor, TRUE); clutter_actor_set_anchor_point_from_gravity (app->buttons[i]->actor, CLUTTER_GRAVITY_CENTER); if ( i == 0 ) a = button_texture; else a = clutter_clone_new(button_texture); clutter_group_add(CLUTTER_GROUP(app->buttons[i]->actor), a); switch (i) { case 9: g_snprintf(buf, 8, "#"); break; case 10: g_snprintf(buf, 8, "0"); break; case 11: g_snprintf(buf, 8, "*"); break; default: g_snprintf(buf, 8, "%i", i+1); break; } a = clutter_text_new_full("Sans Bold 32px", buf, &text_color); clutter_actor_set_position (a, (clutter_actor_get_width (button_texture) - clutter_actor_get_width (a))/2, (clutter_actor_get_height (button_texture) - clutter_actor_get_height (a))/2); clutter_group_add (CLUTTER_GROUP (app->buttons[i]->actor), a); clutter_group_add (CLUTTER_GROUP (app->screen_dialpad), app->buttons[i]->actor); /* need to remember positions for anim - sucky */ app->buttons[i]->sx = x + clutter_actor_get_width (app->buttons[i]->actor)/2; app->buttons[i]->sy = y + clutter_actor_get_height (app->buttons[i]->actor)/2; clutter_actor_set_position (app->buttons[i]->actor, app->buttons[i]->sx, app->buttons[i]->sy); /* Really we should use a Clutter*Box here.. */ if (i % 3 == 2) { x = xinit; y += (ypad + clutter_actor_get_height (button_texture)); } else x += (xpad + clutter_actor_get_width(button_texture)); app->buttons[i]->face = g_strdup (buf); } /* * screen_dial * +---- (rectangle:black) * +---- (texture:call-background.png) * +---- (rectangle:semi transparent) * +----dial_label (text:"Calling...") */ app->screen_dial = clutter_group_new(); clutter_actor_set_anchor_point_from_gravity (app->screen_dial, CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (app->screen_dial, CSW/2, CSH/2); a = clutter_rectangle_new_with_color (&black_color); clutter_actor_set_size (a, CSW, CSH); clutter_group_add (CLUTTER_GROUP(app->screen_dial), a); a = clutter_texture_new_from_file ("call-background.png", NULL); clutter_group_add (CLUTTER_GROUP(app->screen_dial), a); a = clutter_rectangle_new_with_color (&rect_color); clutter_actor_set_size (a, CSW, CSH/6); clutter_actor_set_position (a, 0, (CSH - (CSH/6))/2); clutter_group_add (CLUTTER_GROUP(app->screen_dial), a); app->dial_label = clutter_text_new_full ("Sans Bold 32px", "Calling...", &text_color); clutter_actor_set_position (app->dial_label, 10, (CSH - (CSH/6))/2 + 10); clutter_group_add (CLUTTER_GROUP (app->screen_dial), app->dial_label); }
void gmc_button_set_icon (GmcButton *self, const gchar *filename) { GmcButtonPrivate *priv; ClutterActor *icon; GError *error = NULL; priv = GMC_BUTTON_GET_PRIVATE (self); icon = clutter_texture_new_from_file (filename, &error); if (!icon) { g_critical ("%s - %s [%s] %s", G_STRFUNC, error->message, filename, clutter_text_get_text (CLUTTER_TEXT (priv->label))); return; } if (priv->icon) { g_object_unref (priv->icon); } priv->icon = icon; clutter_actor_set_size (priv->icon, 24, 24); clutter_actor_set_parent (priv->icon, CLUTTER_ACTOR (self)); }
G_MODULE_EXPORT gint test_text_main (gint argc, gchar **argv) { ClutterActor *stage; ClutterActor *text, *text2; ClutterColor text_color = { 0x33, 0xff, 0x33, 0xff }; ClutterColor cursor_color = { 0xff, 0x33, 0x33, 0xff }; ClutterTextBuffer *buffer; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Text Editing"); clutter_actor_set_background_color (stage, CLUTTER_COLOR_Black); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); buffer = clutter_text_buffer_new_with_text ("·", -1); text = clutter_text_new_with_buffer (buffer); clutter_text_set_font_name (CLUTTER_TEXT (text), FONT); clutter_text_set_color (CLUTTER_TEXT (text), &text_color); clutter_container_add (CLUTTER_CONTAINER (stage), text, NULL); clutter_actor_set_position (text, 40, 30); clutter_actor_set_width (text, 1024); clutter_text_set_line_wrap (CLUTTER_TEXT (text), TRUE); clutter_actor_set_reactive (text, TRUE); clutter_stage_set_key_focus (CLUTTER_STAGE (stage), text); clutter_text_set_editable (CLUTTER_TEXT (text), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (text), TRUE); clutter_text_set_cursor_color (CLUTTER_TEXT (text), &cursor_color); clutter_text_set_selected_text_color (CLUTTER_TEXT (text), CLUTTER_COLOR_Blue); text2 = clutter_text_new_with_buffer (buffer); clutter_text_set_color (CLUTTER_TEXT (text2), &text_color); clutter_container_add (CLUTTER_CONTAINER (stage), text2, NULL); clutter_actor_set_position (text2, 40, 300); clutter_actor_set_width (text2, 1024); clutter_text_set_line_wrap (CLUTTER_TEXT (text2), TRUE); clutter_actor_set_reactive (text2, TRUE); clutter_text_set_editable (CLUTTER_TEXT (text2), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (text2), TRUE); clutter_text_set_cursor_color (CLUTTER_TEXT (text2), &cursor_color); clutter_text_set_selected_text_color (CLUTTER_TEXT (text2), CLUTTER_COLOR_Green); if (argv[1]) { GError *error = NULL; gchar *utf8; g_file_get_contents (argv[1], &utf8, NULL, &error); if (error) { utf8 = g_strconcat ("Unable to open '", argv[1], "':\n", error->message, NULL); g_error_free (error); } clutter_text_set_text (CLUTTER_TEXT (text), utf8); } else clutter_text_set_text (CLUTTER_TEXT (text), runes); clutter_actor_set_size (stage, 1024, 768); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }