static void mex_content_box_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width, gfloat *pref_width) { MexContentBoxPrivate *priv = MEX_CONTENT_BOX (actor)->priv; gfloat list_w; clutter_actor_get_preferred_width (priv->tile, for_height, min_width, pref_width); if (!priv->extras_visible) return; if (pref_width) { clutter_actor_get_preferred_width (priv->action_list, for_height, NULL, &list_w); if (clutter_timeline_is_playing (priv->timeline)) *pref_width = *pref_width + (list_w * clutter_alpha_get_alpha (priv->alpha)); else *pref_width = *pref_width + list_w; } }
static void mex_content_box_get_preferred_height (ClutterActor *actor, gfloat for_width, gfloat *min_height, gfloat *pref_height) { MexContentBoxPrivate *priv = MEX_CONTENT_BOX (actor)->priv; gfloat info_h; clutter_actor_get_preferred_height (priv->tile, for_width, min_height, pref_height); if (!priv->extras_visible) return; if (pref_height) { clutter_actor_get_preferred_height (priv->info_panel, for_width, NULL, &info_h); if (clutter_timeline_is_playing (priv->timeline)) *pref_height = *pref_height + (info_h * clutter_alpha_get_alpha (priv->alpha)); else *pref_height = *pref_height + info_h; } }
static void mex_tile_get_preferred_height (ClutterActor *actor, gfloat for_width, gfloat *min_height_p, gfloat *nat_height_p) { MxPadding padding; gfloat box_height, label_h, icon1_h, icon2_h; MexTilePrivate *priv = MEX_TILE (actor)->priv; CLUTTER_ACTOR_CLASS (mex_tile_parent_class)-> get_preferred_height (actor, for_width, NULL, nat_height_p); mx_widget_get_padding (MX_WIDGET (actor), &padding); for_width -= padding.left + padding.right; /* Header */ clutter_actor_get_preferred_height (priv->box_layout, for_width, NULL, &label_h); if (priv->icon1) clutter_actor_get_preferred_height (priv->icon1, for_width, NULL, &icon1_h); else icon1_h = 0; if (priv->icon2) clutter_actor_get_preferred_height (priv->icon2, for_width, NULL, &icon2_h); else icon2_h = 0; box_height = MAX (label_h, MAX (icon1_h, icon2_h)) + ((priv->header_padding) ? priv->header_padding->top + priv->header_padding->bottom : 0); /* Override the minimum height with the height of the box */ if (min_height_p) *min_height_p = box_height; if (nat_height_p) { gdouble progress; /* When the timeline is at 0.5, the actor isn't visible - this is * the time where we switch sizes between the natural height and the * box height. */ if (clutter_alpha_get_alpha (priv->important_alpha) < 0.5) progress = 0.0; else progress = 1.0; if (*nat_height_p < box_height) *nat_height_p = box_height; else if (progress == 0.0) *nat_height_p = box_height; else if (progress < 1.0) *nat_height_p = (box_height * (1.0 - progress)) + (*nat_height_p * progress); } }
static void notify_cb (GObject *object, GParamSpec *param_spec, ClutterBehaviour *behave) { ClutterBehaviourClass *klass; klass = CLUTTER_BEHAVIOUR_GET_CLASS (behave); CLUTTER_NOTE (BEHAVIOUR, "notify::alpha"); /* no actors, we can stop right here */ if (behave->priv->actors == NULL) return; if (klass->alpha_notify) { gdouble alpha_value = clutter_alpha_get_alpha (behave->priv->alpha); CLUTTER_NOTE (BEHAVIOUR, "calling %s::alpha_notify (%p, %.4f)", g_type_name (G_TYPE_FROM_CLASS (klass)), behave, alpha_value); klass->alpha_notify (behave, alpha_value); } }
static void mex_grid_view_allocate (ClutterActor *actor, const ClutterActorBox *box, ClutterAllocationFlags flags) { MexGridViewPrivate *priv = MEX_GRID_VIEW (actor)->priv; gfloat menu_min_width, menu_width, grid_width; ClutterActorBox child_box; CLUTTER_ACTOR_CLASS (mex_grid_view_parent_class)->allocate (actor, box, flags); /* menu */ clutter_actor_get_preferred_width (priv->menu_layout, -1, &menu_min_width, &menu_width); mx_widget_get_available_area (MX_WIDGET (actor), box, &child_box); child_box.x2 = child_box.x1 + MAX (MENU_MIN_WIDTH, menu_width); if (priv->state == STATE_CLOSING_STAGE2) clutter_actor_box_interpolate (&child_box, &priv->target_box, clutter_alpha_get_alpha (priv->alpha), &child_box); clutter_actor_allocate (priv->menu_layout, &child_box, flags); /* grid */ mx_widget_get_available_area (MX_WIDGET (actor), box, &child_box); child_box.y1 += GRID_TOP_PADDING; child_box.x1 = child_box.x1 + MENU_MIN_WIDTH; grid_width = child_box.x2 - child_box.x1; if (priv->state == STATE_OPENING) child_box.x2 = child_box.x1 + grid_width * clutter_alpha_get_alpha (priv->alpha); else if (priv->state == STATE_CLOSING_STAGE1) child_box.x2 = child_box.x1 + grid_width * (1 - clutter_alpha_get_alpha (priv->alpha)); else if (priv->state == STATE_CLOSED || priv->state == STATE_CLOSING_STAGE2) child_box.x2 = child_box.x1; clutter_actor_allocate (priv->grid_layout, &child_box, flags); }
static gdouble layout_manager_real_get_animation_progress (ClutterLayoutManager *manager) { ClutterAlpha *alpha; alpha = g_object_get_qdata (G_OBJECT (manager), quark_layout_alpha); if (alpha == NULL) return 1.0; return clutter_alpha_get_alpha (alpha); }
static void timeline_new_frame_cb (ClutterTimeline *timeline, guint msecs, ClutterAlpha *alpha) { ClutterAlphaPrivate *priv = alpha->priv; /* Update alpha value and notify */ priv->alpha = clutter_alpha_get_alpha (alpha); g_object_notify_by_pspec (G_OBJECT (alpha), obj_props[PROP_ALPHA]); }
static void mx_toggle_update_position (ClutterTimeline *timeline, gint msecs, MxToggle *toggle) { MxTogglePrivate *priv = toggle->priv; priv->position = clutter_alpha_get_alpha (priv->alpha); clutter_actor_queue_relayout (CLUTTER_ACTOR (toggle)); }
static void new_frame (ClutterTimeline *timeline, gint frame_num, ClutterActor *expander) { MxExpanderPrivate *priv = MX_EXPANDER (expander)->priv; priv->progress = clutter_alpha_get_alpha (priv->alpha); clutter_actor_queue_relayout (expander); }
void st_theme_node_transition_paint (StThemeNodeTransition *transition, ClutterActorBox *allocation, guint8 paint_opacity) { StThemeNodeTransitionPrivate *priv = transition->priv; CoglColor constant; float tex_coords[] = { 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, }; g_return_if_fail (ST_IS_THEME_NODE (priv->old_theme_node)); g_return_if_fail (ST_IS_THEME_NODE (priv->new_theme_node)); if (!clutter_actor_box_equal (allocation, &priv->last_allocation)) priv->needs_setup = TRUE; if (priv->needs_setup) { priv->last_allocation = *allocation; calculate_offscreen_box (transition, allocation); priv->needs_setup = !setup_framebuffers (transition, allocation); if (priv->needs_setup) /* setting up framebuffers failed */ return; } cogl_color_set_from_4f (&constant, 0., 0., 0., clutter_alpha_get_alpha (priv->alpha)); cogl_material_set_layer_combine_constant (priv->material, 1, &constant); cogl_material_set_color4ub (priv->material, paint_opacity, paint_opacity, paint_opacity, paint_opacity); cogl_set_source (priv->material); cogl_rectangle_with_multitexture_coords (priv->offscreen_box.x1, priv->offscreen_box.y1, priv->offscreen_box.x2, priv->offscreen_box.y2, tex_coords, 8); }
static void mex_tile_important_new_frame_cb (ClutterTimeline *timeline, gint frame_num, MexTile *tile) { MexTilePrivate *priv = tile->priv; if (priv->child) { gdouble opacity = clutter_alpha_get_alpha (priv->important_alpha); if (opacity < 0.5) opacity = 1.0 - (opacity * 2.0); else opacity = (opacity - 0.5) * 2.0; clutter_actor_set_opacity (priv->child, opacity * 255); } clutter_actor_queue_relayout (CLUTTER_ACTOR (tile)); }
static void mx_label_fade_new_frame_cb (ClutterTimeline *timeline, gint msecs, MxLabel *self) { guint8 a; ClutterColor color; MxLabelPrivate *priv = self->priv; a = (1.0 - clutter_alpha_get_alpha (priv->fade_alpha)) * 255; color.red = a; color.green = a; color.blue = a; color.alpha = a; mx_fade_effect_set_color (MX_FADE_EFFECT (priv->fade_effect), &color); clutter_actor_queue_redraw (CLUTTER_ACTOR (self)); }
static void mex_grid_view_timeline_cb (ClutterTimeline *timeline, gint msecs, MexGridView *view) { MexGridViewPrivate *priv = MEX_GRID_VIEW (view)->priv; clutter_actor_queue_relayout (CLUTTER_ACTOR (view)); if (priv->state == STATE_CLOSING_STAGE2) { gfloat progress = clutter_alpha_get_alpha (priv->alpha); gfloat target_width = clutter_actor_box_get_width (&priv->target_box); clutter_actor_set_width (priv->menu, MENU_MIN_WIDTH * (1 - progress) + target_width * progress); } else { clutter_actor_set_width (priv->menu, MENU_MIN_WIDTH); } }
static void interpolation_new_frame_cb (ClutterTimeline *timeline, guint msecs, MxAdjustment *adjustment) { gdouble new_value; MxAdjustmentPrivate *priv = adjustment->priv; priv->interpolation = NULL; new_value = priv->old_position + (priv->new_position - priv->old_position) * clutter_alpha_get_alpha (priv->interpolate_alpha); mx_adjustment_set_value (adjustment, new_value); priv->interpolation = timeline; /* Stop the interpolation if we've reached the end of the adjustment */ if (!priv->elastic && priv->clamp_value && ((new_value < priv->lower) || (new_value > (priv->upper - priv->page_size)))) stop_interpolation (adjustment); }
static void mex_tile_allocate (ClutterActor *actor, const ClutterActorBox *box, ClutterAllocationFlags flags) { MxPadding padding; ClutterActorBox child_box; gfloat available_width, available_height; ClutterEffect *fade; MexTilePrivate *priv = MEX_TILE (actor)->priv; CLUTTER_ACTOR_CLASS (mex_tile_parent_class)->allocate (actor, box, flags); mx_widget_get_padding (MX_WIDGET (actor), &padding); available_width = box->x2 - box->x1 - padding.left - padding.right; available_height = box->y2 - box->y1 - padding.top - padding.bottom; if (priv->child) { gfloat child_width, full_width, full_height; clutter_actor_get_preferred_size (priv->child, NULL, NULL, &full_width, &full_height); child_box.y1 = padding.top; if (clutter_alpha_get_alpha (priv->important_alpha) < 0.5) { child_width = full_width * (available_height / full_height); if (child_width > available_width) child_width = available_width; child_box.y2 = child_box.y1 + available_height; /* When we're in unimportant state, make sure the label * doesn't overlap the image. */ if (available_height < full_height) available_width -= child_width * ((0.5 - clutter_alpha_get_alpha (priv->important_alpha)) * 2); } else { child_width = available_width; clutter_actor_set_clip_to_allocation ( actor, (full_height > available_height)); child_box.y2 = child_box.y1 + full_height; } child_box.x2 = box->x2 - box->x1 - padding.right; child_box.x1 = child_box.x2 - child_width; mx_allocate_align_fill (priv->child, &child_box, MX_ALIGN_MIDDLE, MX_ALIGN_MIDDLE, FALSE, FALSE); clutter_actor_allocate (priv->child, &child_box, flags); } /* Allocate Header */ if (priv->header_visible) { gfloat icon1_w, icon1_h, icon2_w, icon2_h, label_h, label_w, header_h; gfloat middle_w; if (priv->header_padding) { padding.top += priv->header_padding->top; padding.right += priv->header_padding->right; padding.bottom += priv->header_padding->bottom; padding.left += priv->header_padding->left; } clutter_actor_get_preferred_size (priv->box_layout, NULL, NULL, &label_w, &label_h); if (priv->icon1) clutter_actor_get_preferred_size (priv->icon1, NULL, NULL, &icon1_w, &icon1_h); else icon1_h = icon1_w = 0; if (priv->icon2) clutter_actor_get_preferred_size (priv->icon2, NULL, NULL, &icon2_w, &icon2_h); else icon2_h = icon2_w = 0; header_h = MAX (icon1_h, MAX (icon2_h, label_h)); /* primary icon */ if (priv->icon1) { child_box.y1 = padding.top + (header_h / 2.0) - (icon1_h / 2.0); child_box.x1 = padding.left; child_box.y2 = child_box.y1 + icon1_h; child_box.x2 = child_box.x1 + icon1_w; clutter_actor_allocate (priv->icon1, &child_box, flags); child_box.x1 += icon1_w + 8; } else child_box.x1 = padding.left; /* label */ child_box.x2 = child_box.x1 + label_w; child_box.y1 = (int) (padding.top + (header_h / 2.0) - (label_h / 2.0)); child_box.y2 = child_box.y1 + label_h; fade = clutter_actor_get_effect (priv->box_layout, "fade"); middle_w = available_width - icon1_w - icon2_w; if (priv->header_padding) middle_w -= priv->header_padding->left + priv->header_padding->right; clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (fade), !(middle_w > label_w)); mx_fade_effect_set_bounds (MX_FADE_EFFECT (fade), 0, 0, middle_w, 0); clutter_actor_allocate (priv->box_layout, &child_box, flags); /* secondary icon */ if (priv->icon2) { child_box.x2 = (box->x2 - box->x1) - padding.right; child_box.x1 = child_box.x2 - icon2_w; child_box.y1 = padding.top + (header_h / 2.0) - (icon2_h / 2.0); child_box.y2 = child_box.y1 + icon2_h; clutter_actor_allocate (priv->icon2, &child_box, flags); } priv->header_height = header_h; if (priv->header_padding) priv->header_height += priv->header_padding->top + priv->header_padding->bottom; } }