mirror of
https://github.com/brl/mutter.git
synced 2024-11-09 15:37:00 -05:00
clutter/actor-box: Allow marking boxes as uninitialized
Add support for an artificial UNINITIALIZED marking for ClutterActorBox, done by setting the boxes origin to Infinity and its size to -Infinity. That is a value that's considered an invalid allocation by Clutter and which can never be set by sane code. This will allow setting the allocation of ClutterActors to an UNINITIALIZED box when creating actors or when removing them from the scenegraph and makes it possible to explicitely detect uninitialized allocations, which is useful in a few cases. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1290
This commit is contained in:
parent
932340a989
commit
0bfb995bff
@ -615,6 +615,32 @@ clutter_actor_box_scale (ClutterActorBox *box,
|
||||
box->y2 *= scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_actor_box_is_initialized:
|
||||
* @box: a #ClutterActorBox
|
||||
*
|
||||
* Checks if @box has been initialized, a #ClutterActorBox is uninitialized
|
||||
* if it has a size of -1 at an origin of 0, 0.
|
||||
*
|
||||
* Returns: %TRUE if the box is uninitialized, %FALSE if it isn't
|
||||
*/
|
||||
gboolean
|
||||
clutter_actor_box_is_initialized (ClutterActorBox *box)
|
||||
{
|
||||
gboolean x1_uninitialized, x2_uninitialized;
|
||||
gboolean y1_uninitialized, y2_uninitialized;
|
||||
|
||||
g_return_val_if_fail (box != NULL, TRUE);
|
||||
|
||||
x1_uninitialized = isinf (box->x1);
|
||||
x2_uninitialized = isinf (box->x2) && signbit (box->x2);
|
||||
y1_uninitialized = isinf (box->y1);
|
||||
y2_uninitialized = isinf (box->y2) && signbit (box->y2);
|
||||
|
||||
return !x1_uninitialized || !x2_uninitialized ||
|
||||
!y1_uninitialized || !y2_uninitialized;
|
||||
}
|
||||
|
||||
G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterActorBox, clutter_actor_box,
|
||||
clutter_actor_box_copy,
|
||||
clutter_actor_box_free,
|
||||
|
@ -174,6 +174,20 @@ struct _ClutterActorBox
|
||||
*/
|
||||
#define CLUTTER_ACTOR_BOX_INIT_ZERO CLUTTER_ACTOR_BOX_INIT (0.f, 0.f, 0.f, 0.f)
|
||||
|
||||
/**
|
||||
* CLUTTER_ACTOR_BOX_UNINITIALIZED:
|
||||
*
|
||||
* A simple macro for creating a #ClutterActorBox with a size of -1 when
|
||||
* declaring it, e.g.:
|
||||
*
|
||||
* |[
|
||||
* ClutterActorBox box = CLUTTER_ACTOR_BOX_UNINITIALIZED;
|
||||
* ]|
|
||||
*/
|
||||
|
||||
|
||||
#define CLUTTER_ACTOR_BOX_UNINITIALIZED { .x1 = INFINITY, .y1 = INFINITY, .x2 = -INFINITY, .y2 = -INFINITY }
|
||||
|
||||
CLUTTER_EXPORT
|
||||
GType clutter_actor_box_get_type (void) G_GNUC_CONST;
|
||||
CLUTTER_EXPORT
|
||||
@ -252,6 +266,9 @@ CLUTTER_EXPORT
|
||||
void clutter_actor_box_scale (ClutterActorBox *box,
|
||||
gfloat scale);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
gboolean clutter_actor_box_is_initialized (ClutterActorBox *box);
|
||||
|
||||
/**
|
||||
* ClutterKnot:
|
||||
* @x: X coordinate of the knot
|
||||
|
Loading…
Reference in New Issue
Block a user