actor: Add [xy]-align
Allow an actor to define how it should occupy the extra space given to by its parent during the allocation.
This commit is contained in:
parent
4453ee7266
commit
c8659b6ca5
3 changed files with 135 additions and 0 deletions
|
@ -525,6 +525,8 @@ struct _ClutterActorPrivate
|
||||||
guint is_dirty : 1;
|
guint is_dirty : 1;
|
||||||
guint x_expand : 1;
|
guint x_expand : 1;
|
||||||
guint y_expand : 1;
|
guint y_expand : 1;
|
||||||
|
guint x_align : 4;
|
||||||
|
guint y_align : 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -617,6 +619,8 @@ enum
|
||||||
|
|
||||||
PROP_X_EXPAND,
|
PROP_X_EXPAND,
|
||||||
PROP_Y_EXPAND,
|
PROP_Y_EXPAND,
|
||||||
|
PROP_X_ALIGN,
|
||||||
|
PROP_Y_ALIGN,
|
||||||
|
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
|
@ -3549,6 +3553,14 @@ clutter_actor_set_property (GObject *object,
|
||||||
clutter_actor_set_y_expand (actor, g_value_get_boolean (value));
|
clutter_actor_set_y_expand (actor, g_value_get_boolean (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_X_ALIGN:
|
||||||
|
clutter_actor_set_x_align (actor, g_value_get_enum (value));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_Y_ALIGN:
|
||||||
|
clutter_actor_set_y_align (actor, g_value_get_enum (value));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -3826,6 +3838,14 @@ clutter_actor_get_property (GObject *object,
|
||||||
g_value_set_boolean (value, priv->y_expand);
|
g_value_set_boolean (value, priv->y_expand);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_X_ALIGN:
|
||||||
|
g_value_set_enum (value, priv->x_align);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_Y_ALIGN:
|
||||||
|
g_value_set_enum (value, priv->y_align);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -4894,6 +4914,26 @@ clutter_actor_class_init (ClutterActorClass *klass)
|
||||||
g_object_class_install_property (object_class, PROP_Y_EXPAND,
|
g_object_class_install_property (object_class, PROP_Y_EXPAND,
|
||||||
obj_props[PROP_Y_EXPAND]);
|
obj_props[PROP_Y_EXPAND]);
|
||||||
|
|
||||||
|
obj_props[PROP_X_ALIGN] =
|
||||||
|
g_param_spec_enum ("x-align",
|
||||||
|
P_("X Alignment"),
|
||||||
|
P_("The alignment of the actor on the X axis within its allocation"),
|
||||||
|
CLUTTER_TYPE_ACTOR_ALIGN,
|
||||||
|
CLUTTER_ACTOR_ALIGN_FILL,
|
||||||
|
CLUTTER_PARAM_READWRITE);
|
||||||
|
g_object_class_install_property (object_class, PROP_X_ALIGN,
|
||||||
|
obj_props[PROP_X_ALIGN]);
|
||||||
|
|
||||||
|
obj_props[PROP_Y_ALIGN] =
|
||||||
|
g_param_spec_enum ("y-align",
|
||||||
|
P_("Y Alignment"),
|
||||||
|
P_("The alignment of the actor on the Y axis within its allocation"),
|
||||||
|
CLUTTER_TYPE_ACTOR_ALIGN,
|
||||||
|
CLUTTER_ACTOR_ALIGN_FILL,
|
||||||
|
CLUTTER_PARAM_READWRITE);
|
||||||
|
g_object_class_install_property (object_class, PROP_Y_ALIGN,
|
||||||
|
obj_props[PROP_Y_ALIGN]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterActor::destroy:
|
* ClutterActor::destroy:
|
||||||
* @actor: the #ClutterActor which emitted the signal
|
* @actor: the #ClutterActor which emitted the signal
|
||||||
|
@ -5482,6 +5522,11 @@ clutter_actor_init (ClutterActor *self)
|
||||||
priv->cached_width_age = 1;
|
priv->cached_width_age = 1;
|
||||||
priv->cached_height_age = 1;
|
priv->cached_height_age = 1;
|
||||||
|
|
||||||
|
priv->x_expand = FALSE;
|
||||||
|
priv->y_expand = FALSE;
|
||||||
|
priv->x_align = CLUTTER_ACTOR_ALIGN_FILL;
|
||||||
|
priv->y_align = CLUTTER_ACTOR_ALIGN_FILL;
|
||||||
|
|
||||||
priv->opacity_override = -1;
|
priv->opacity_override = -1;
|
||||||
priv->enable_model_view_transform = TRUE;
|
priv->enable_model_view_transform = TRUE;
|
||||||
|
|
||||||
|
@ -13162,3 +13207,59 @@ clutter_actor_get_y_expand (ClutterActor *self)
|
||||||
|
|
||||||
return self->priv->y_expand;
|
return self->priv->y_expand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
clutter_actor_set_x_align (ClutterActor *self,
|
||||||
|
ClutterActorAlign x_align)
|
||||||
|
{
|
||||||
|
ClutterActorPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
|
|
||||||
|
priv = self->priv;
|
||||||
|
|
||||||
|
if (priv->x_align != x_align)
|
||||||
|
{
|
||||||
|
priv->x_align = x_align;
|
||||||
|
|
||||||
|
clutter_actor_queue_relayout (self);
|
||||||
|
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_X_ALIGN]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClutterActorAlign
|
||||||
|
clutter_actor_get_x_align (ClutterActor *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), CLUTTER_ACTOR_ALIGN_FILL);
|
||||||
|
|
||||||
|
return self->priv->x_align;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
clutter_actor_set_y_align (ClutterActor *self,
|
||||||
|
ClutterActorAlign y_align)
|
||||||
|
{
|
||||||
|
ClutterActorPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
|
|
||||||
|
priv = self->priv;
|
||||||
|
|
||||||
|
if (priv->y_align != y_align)
|
||||||
|
{
|
||||||
|
priv->y_align = y_align;
|
||||||
|
|
||||||
|
clutter_actor_queue_relayout (self);
|
||||||
|
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_Y_ALIGN]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClutterActorAlign
|
||||||
|
clutter_actor_get_y_align (ClutterActor *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), CLUTTER_ACTOR_ALIGN_FILL);
|
||||||
|
|
||||||
|
return self->priv->y_align;
|
||||||
|
}
|
||||||
|
|
|
@ -374,6 +374,13 @@ void clutter_actor_set_y_expand (ClutterActor
|
||||||
gboolean y_expand);
|
gboolean y_expand);
|
||||||
gboolean clutter_actor_get_y_expand (ClutterActor *self);
|
gboolean clutter_actor_get_y_expand (ClutterActor *self);
|
||||||
|
|
||||||
|
void clutter_actor_set_x_align (ClutterActor *self,
|
||||||
|
ClutterActorAlign x_align);
|
||||||
|
ClutterActorAlign clutter_actor_get_x_align (ClutterActor *self);
|
||||||
|
void clutter_actor_set_y_align (ClutterActor *self,
|
||||||
|
ClutterActorAlign y_align);
|
||||||
|
ClutterActorAlign clutter_actor_get_y_align (ClutterActor *self);
|
||||||
|
|
||||||
void clutter_actor_set_rotation (ClutterActor *self,
|
void clutter_actor_set_rotation (ClutterActor *self,
|
||||||
ClutterRotateAxis axis,
|
ClutterRotateAxis axis,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
|
|
|
@ -1056,6 +1056,33 @@ typedef enum {
|
||||||
CLUTTER_PATH_REL_CURVE_TO = CLUTTER_PATH_CURVE_TO | CLUTTER_PATH_RELATIVE
|
CLUTTER_PATH_REL_CURVE_TO = CLUTTER_PATH_CURVE_TO | CLUTTER_PATH_RELATIVE
|
||||||
} ClutterPathNodeType;
|
} ClutterPathNodeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClutterActorAlign:
|
||||||
|
* @CLUTTER_ACTOR_ALIGN_FILL: Stretch to cover the whole allocated space
|
||||||
|
* @CLUTTER_ACTOR_ALIGN_START: Snap to left or top side, leaving space
|
||||||
|
* to the right or bottom. For horizontal layouts, in right-to-left
|
||||||
|
* locales this should be reversed.
|
||||||
|
* @CLUTTER_ACTOR_ALIGN_CENTER: Center the actor inside the allocation
|
||||||
|
* @CLUTTER_ACTOR_ALIGN_END: Snap to right or bottom side, leaving space
|
||||||
|
* to the left or top. For horizontal layouts, in right-to-left locales
|
||||||
|
* this should be reversed.
|
||||||
|
*
|
||||||
|
* Controls how a #ClutterActor should align itself inside the extra space
|
||||||
|
* assigned to it during the allocation.
|
||||||
|
*
|
||||||
|
* Alignment only matters if the allocated space given to an actor is
|
||||||
|
* bigger than its natural size; for example, when the #ClutterActor:x-expand
|
||||||
|
* or the #ClutterActor:y-expand properties of #ClutterActor are set to %TRUE.
|
||||||
|
*
|
||||||
|
* Since: 1.10
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
CLUTTER_ACTOR_ALIGN_FILL,
|
||||||
|
CLUTTER_ACTOR_ALIGN_START,
|
||||||
|
CLUTTER_ACTOR_ALIGN_CENTER,
|
||||||
|
CLUTTER_ACTOR_ALIGN_END
|
||||||
|
} ClutterActorAlign;
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __CLUTTER_ENUMS_H__ */
|
#endif /* __CLUTTER_ENUMS_H__ */
|
||||||
|
|
Loading…
Add table
Reference in a new issue