2007-11-28 Tomas Frydrych <tf@openedhand.com>

* clutter/clutter-actor.c:
        * clutter/clutter-actor.h:
	(clutter_actor_set_positionu):
	(clutter_actor_set_sizeu):
	(clutter_actor_get_widthu):
	(clutter_actor_get_heightu):
	(clutter_actor_set_widthu):
	(clutter_actor_set_heightu):
	(clutter_actor_get_xu):
	(clutter_actor_get_yu):
	(clutter_actor_set_xu):
	(clutter_actor_set_yu):
	Expanded ClutterActor API with new ClutterUnit-base functions.

        * clutter/clutter-stage.c:
        * clutter/clutter-stage.h:
	(clutter_stage_get_resolution):
	(clutter_stage_get_resolutionx):
	New function to query stage resolution (floating and fixed point
	versions).

        * clutter/clutter-units.h:
	(CLUTTER_UNITS_FROM_STAGE_WIDTH_PERCENTAGE):
	(CLUTTER_UNITS_FROM_STAGE_HEIGHT_PERCENTAGE):
	(CLUTTER_UNITS_FROM_PARENT_WIDTH_PERCENTAGE):
	(CLUTTER_UNITS_FROM_PARENT_HEIGHT_PERCENTAGE):
	(CLUTTER_UNITS_FROM_MM):
	(CLUTTER_UNITS_FROM_MMX):
	(CLUTTER_UNITS_FROM_POINTS):
	(CLUTTER_UNITS_FROM_POINTSX):
	New macros for conversions to ClutterUnits.

	* clutter.symbols:
	Added:
	        ClutterActor anchor_point functions,
                clutter_stage_get_resolution functions.

	Removed:
                clutter_actor_scale_with_gravity functions.
This commit is contained in:
Tomas Frydrych 2007-11-28 15:31:41 +00:00
parent be3f09d64c
commit 132296dcc3
9 changed files with 494 additions and 117 deletions

View File

@ -1,3 +1,45 @@
2007-11-28 Tomas Frydrych <tf@openedhand.com>
* clutter/clutter-actor.c:
* clutter/clutter-actor.h:
(clutter_actor_set_positionu):
(clutter_actor_set_sizeu):
(clutter_actor_get_widthu):
(clutter_actor_get_heightu):
(clutter_actor_set_widthu):
(clutter_actor_set_heightu):
(clutter_actor_get_xu):
(clutter_actor_get_yu):
(clutter_actor_set_xu):
(clutter_actor_set_yu):
Expanded ClutterActor API with new ClutterUnit-base functions.
* clutter/clutter-stage.c:
* clutter/clutter-stage.h:
(clutter_stage_get_resolution):
(clutter_stage_get_resolutionx):
New function to query stage resolution (floating and fixed point
versions).
* clutter/clutter-units.h:
(CLUTTER_UNITS_FROM_STAGE_WIDTH_PERCENTAGE):
(CLUTTER_UNITS_FROM_STAGE_HEIGHT_PERCENTAGE):
(CLUTTER_UNITS_FROM_PARENT_WIDTH_PERCENTAGE):
(CLUTTER_UNITS_FROM_PARENT_HEIGHT_PERCENTAGE):
(CLUTTER_UNITS_FROM_MM):
(CLUTTER_UNITS_FROM_MMX):
(CLUTTER_UNITS_FROM_POINTS):
(CLUTTER_UNITS_FROM_POINTSX):
New macros for conversions to ClutterUnits.
* clutter.symbols:
Added:
ClutterActor anchor_point functions,
clutter_stage_get_resolution functions.
Removed:
clutter_actor_scale_with_gravity functions.
2007-11-28 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-actor.[ch]: Documentation fixes.

View File

@ -16,7 +16,9 @@ clutter_actor_set_geometry
clutter_actor_get_geometry
clutter_actor_get_coords
clutter_actor_set_size
clutter_actor_set_sizeu
clutter_actor_set_position
clutter_actor_set_positionu
clutter_actor_get_abs_position
clutter_actor_get_width
clutter_actor_get_height
@ -26,6 +28,14 @@ clutter_actor_get_x
clutter_actor_set_x
clutter_actor_get_y
clutter_actor_set_y
clutter_actor_get_widthu
clutter_actor_get_heightu
clutter_actor_set_widthu
clutter_actor_set_heightu
clutter_actor_get_xu
clutter_actor_set_xu
clutter_actor_get_yu
clutter_actor_set_yu
clutter_actor_set_rotation
clutter_actor_set_rotationx
clutter_actor_get_rotation
@ -53,8 +63,11 @@ clutter_actor_set_scalex
clutter_actor_set_scale
clutter_actor_get_scalex
clutter_actor_get_scale
clutter_actor_set_scale_with_gravityx
clutter_actor_set_scale_with_gravity
clutter_actor_set_anchor_point
clutter_actor_get_anchor_point
clutter_actor_set_anchor_pointu
clutter_actor_get_anchor_pointu
clutter_actor_set_anchor_point_from_gravity
clutter_actor_get_abs_size
clutter_actor_get_size
clutter_actor_move_by
@ -410,6 +423,8 @@ clutter_stage_set_fog
clutter_stage_get_fog
clutter_stage_set_fogx
clutter_stage_get_fogx
clutter_stage_get_resolution
clutter_stage_get_resolutionx
clutter_texture_error_quark
clutter_texture_get_type
clutter_texture_new

View File

@ -1903,6 +1903,37 @@ clutter_actor_set_position (ClutterActor *self,
clutter_actor_request_coords (self, &box);
}
/**
* clutter_actor_set_positionu
* @self: A #ClutterActor
* @x: New left position of actor in #ClutterUnit
* @y: New top position of actor in #ClutterUnit
*
* Sets the actors position in #ClutterUnit relative to any
* parent actor.
*
* Since: 0.6
*/
void
clutter_actor_set_positionu (ClutterActor *self,
ClutterUnit x,
ClutterUnit y)
{
ClutterActorBox box;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_query_coords (self, &box);
box.x2 += (x - box.x1);
box.y2 += (y - box.y1);
box.x1 = x;
box.y1 = y;
clutter_actor_request_coords (self, &box);
}
/**
* clutter_actor_move_by
* @self: A #ClutterActor
@ -1957,6 +1988,28 @@ clutter_actor_set_size_internal (ClutterActor *self,
clutter_actor_request_coords (self, &box);
}
/* local inline unit version, without type checking to be used by
* set_width() and set_height(). if one of the dimensions is < 0
* it will not be changed
*/
static inline void
clutter_actor_set_size_internalu (ClutterActor *self,
ClutterUnit width,
ClutterUnit height)
{
ClutterActorBox box;
clutter_actor_query_coords (self, &box);
if (width > 0)
box.x2 = box.x1 + width;
if (height > 0)
box.y2 = box.y1 + height;
clutter_actor_request_coords (self, &box);
}
/**
* clutter_actor_set_size
* @self: A #ClutterActor
@ -1976,6 +2029,27 @@ clutter_actor_set_size (ClutterActor *self,
clutter_actor_set_size_internal (self, width, height);
}
/**
* clutter_actor_set_sizeu
* @self: A #ClutterActor
* @width: New width of actor in #ClutterUnit, or -1
* @height: New height of actor in #ClutterUnit, or -1
*
* Sets the actors size in #ClutterUnit. If @width and/or @height are -1 the
* actor will assume the same size of its bounding box.
*
* Since: 0.6
*/
void
clutter_actor_set_sizeu (ClutterActor *self,
ClutterUnit width,
ClutterUnit height)
{
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_set_size_internalu (self, width, height);
}
/**
* clutter_actor_get_size:
* @self: A #ClutterActor
@ -2185,6 +2259,28 @@ clutter_actor_get_width (ClutterActor *self)
return CLUTTER_UNITS_TO_INT (box.x2 - box.x1);
}
/**
* clutter_actor_get_widthu
* @self: A #ClutterActor
*
* Retrieves the actors width ignoring any scaling factors.
*
* Return value: The actor width in #ClutterUnit
*
* since: 0.6
**/
ClutterUnit
clutter_actor_get_widthu (ClutterActor *self)
{
ClutterActorBox box;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
clutter_actor_query_coords (self, &box);
return box.x2 - box.x1;
}
/**
* clutter_actor_get_height
* @self: A #ClutterActor
@ -2205,6 +2301,28 @@ clutter_actor_get_height (ClutterActor *self)
return CLUTTER_UNITS_TO_INT (box.y2 - box.y1);
}
/**
* clutter_actor_get_heightu
* @self: A #ClutterActor
*
* Retrieves the actors height ignoring any scaling factors.
*
* Return value: The actor height in #ClutterUnit
*
* since: 0.6
**/
ClutterUnit
clutter_actor_get_heightu (ClutterActor *self)
{
ClutterActorBox box;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
clutter_actor_query_coords (self, &box);
return box.y2 - box.y1;
}
/**
* clutter_actor_set_width
* @self: A #ClutterActor
@ -2212,7 +2330,7 @@ clutter_actor_get_height (ClutterActor *self)
*
* Requests a new width for actor
*
* since: 2.0
* since: 0.2
**/
void
clutter_actor_set_width (ClutterActor *self,
@ -2223,6 +2341,24 @@ clutter_actor_set_width (ClutterActor *self,
clutter_actor_set_size_internal (self, width, -1);
}
/**
* clutter_actor_set_widthu
* @self: A #ClutterActor
* @width: Requested new width for actor in #ClutterUnit
*
* Requests a new width for actor
*
* since: 0.6
**/
void
clutter_actor_set_widthu (ClutterActor *self,
ClutterUnit width)
{
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_set_size_internalu (self, width, -1);
}
/**
* clutter_actor_set_height
* @self: A #ClutterActor
@ -2230,7 +2366,7 @@ clutter_actor_set_width (ClutterActor *self,
*
* Requests a new height for actor
*
* since: 2.0
* since: 0.2
**/
void
clutter_actor_set_height (ClutterActor *self,
@ -2241,6 +2377,24 @@ clutter_actor_set_height (ClutterActor *self,
clutter_actor_set_size_internal (self, -1, height);
}
/**
* clutter_actor_set_heightu
* @self: A #ClutterActor
* @height: Requested new height for actor in #ClutterUnit
*
* Requests a new height for actor
*
* since: 0.6
**/
void
clutter_actor_set_heightu (ClutterActor *self,
ClutterUnit height)
{
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_set_size_internalu (self, -1, height);
}
/**
* clutter_actor_set_x:
* @self: a #ClutterActor
@ -2261,6 +2415,26 @@ clutter_actor_set_x (ClutterActor *self,
clutter_actor_get_y (self));
}
/**
* clutter_actor_set_xu:
* @self: a #ClutterActor
* @x: the actors position on the X axis in #ClutterUnit
*
* Sets the actor's x position relative to its parent.
*
* Since: 0.6
*/
void
clutter_actor_set_xu (ClutterActor *self,
ClutterUnit x)
{
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_set_positionu (self,
x,
clutter_actor_get_yu (self));
}
/**
* clutter_actor_set_y:
* @self: a #ClutterActor
@ -2281,6 +2455,26 @@ clutter_actor_set_y (ClutterActor *self,
y);
}
/**
* clutter_actor_set_yu:
* @self: a #ClutterActor
* @y: the actors position on the Y axis in #ClutterUnit
*
* Sets the actor's y position relative to its parent.
*
* Since: 0.6
*/
void
clutter_actor_set_yu (ClutterActor *self,
ClutterUnit y)
{
g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_actor_set_positionu (self,
clutter_actor_get_xu (self),
y);
}
/**
* clutter_actor_get_x
* @self: A #ClutterActor
@ -2302,6 +2496,29 @@ clutter_actor_get_x (ClutterActor *self)
return CLUTTER_UNITS_TO_INT (box.x1);
}
/**
* clutter_actor_get_xu
* @self: A #ClutterActor
*
* Retrieves the actors x position relative to any parent, in #ClutterUnit
*
* Return value: The actor x position in #ClutterUnit ignoring any tranforms
* (i.e scaling, rotation).
*
* Since: 0.6
**/
ClutterUnit
clutter_actor_get_xu (ClutterActor *self)
{
ClutterActorBox box;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
clutter_actor_query_coords (self, &box);
return box.x1;
}
/**
* clutter_actor_get_y:
* @self: A #ClutterActor
@ -2323,6 +2540,27 @@ clutter_actor_get_y (ClutterActor *self)
return CLUTTER_UNITS_TO_INT (box.y1);
}
/**
* clutter_actor_get_yu:
* @self: A #ClutterActor
*
* Retrieves the actors y position relative to any parent, in #ClutterUnit
*
* Return value: The actor y position in #ClutterUnit ignoring any tranforms
* (i.e scaling, rotation).
**/
ClutterUnit
clutter_actor_get_yu (ClutterActor *self)
{
ClutterActorBox box;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
clutter_actor_query_coords (self, &box);
return box.y1;
}
/**
* clutter_actor_set_scalex:
* @self: A #ClutterActor

View File

@ -251,9 +251,15 @@ void clutter_actor_get_coords (ClutterActor *sel
void clutter_actor_set_size (ClutterActor *self,
gint width,
gint height);
void clutter_actor_set_sizeu (ClutterActor *self,
ClutterUnit width,
ClutterUnit height);
void clutter_actor_set_position (ClutterActor *self,
gint x,
gint y);
void clutter_actor_set_positionu (ClutterActor *self,
ClutterUnit x,
ClutterUnit y);
void clutter_actor_get_position (ClutterActor *self,
gint *x,
gint *y);
@ -261,17 +267,29 @@ void clutter_actor_get_abs_position (ClutterActor *sel
gint *x,
gint *y);
guint clutter_actor_get_width (ClutterActor *self);
ClutterUnit clutter_actor_get_widthu (ClutterActor *self);
guint clutter_actor_get_height (ClutterActor *self);
ClutterUnit clutter_actor_get_heightu (ClutterActor *self);
void clutter_actor_set_width (ClutterActor *self,
guint width);
void clutter_actor_set_widthu (ClutterActor *self,
ClutterUnit width);
void clutter_actor_set_height (ClutterActor *self,
guint height);
void clutter_actor_set_heightu (ClutterActor *self,
ClutterUnit height);
gint clutter_actor_get_x (ClutterActor *self);
ClutterUnit clutter_actor_get_xu (ClutterActor *self);
gint clutter_actor_get_y (ClutterActor *self);
ClutterUnit clutter_actor_get_yu (ClutterActor *self);
void clutter_actor_set_x (ClutterActor *self,
gint x);
void clutter_actor_set_xu (ClutterActor *self,
ClutterUnit x);
void clutter_actor_set_y (ClutterActor *self,
gint y);
void clutter_actor_set_yu (ClutterActor *self,
ClutterUnit y);
void clutter_actor_set_rotation (ClutterActor *self,
ClutterRotateAxis axis,
gdouble angle,

View File

@ -1216,6 +1216,31 @@ clutter_stage_get_fogx (ClutterStage *stage,
*fog = stage->priv->fog;
}
gdouble
clutter_stage_get_resolution (ClutterStage *stage)
{
ClutterMainContext *context;
context = clutter_context_get_default ();
g_assert (context != NULL);
return clutter_backend_get_resolution (context->backend);
}
ClutterFixed
clutter_stage_get_resolutionx (ClutterStage *stage)
{
ClutterFixed res;
ClutterMainContext *context;
context = clutter_context_get_default ();
g_assert (context != NULL);
res = clutter_backend_get_resolution (context->backend);
return CLUTTER_FLOAT_TO_FIXED (res);
}
/*** Perspective boxed type ******/
static ClutterPerspective *

View File

@ -211,6 +211,8 @@ void clutter_stage_set_fogx (ClutterStage *stage,
ClutterFog *fog);
void clutter_stage_get_fogx (ClutterStage *stage,
ClutterFog *fog);
gdouble clutter_stage_get_resolution (ClutterStage *stage);
ClutterFixed clutter_stage_get_resolutionx (ClutterStage *stage);
/* New experiental calls */
void clutter_stage_set_key_focus (ClutterStage *stage,

View File

@ -66,6 +66,7 @@ typedef gint32 ClutterUnit;
* _FROM_FIXED and _TO_FIXED macros should always be used in case that we
* decide to change this relationship in the future.
*/
#define CLUTTER_UNITS_FROM_DEVICE(x) CLUTTER_UNITS_FROM_INT (x)
#define CLUTTER_UNITS_TO_DEVICE(x) CLUTTER_UNITS_TO_INT (x)
@ -84,6 +85,30 @@ typedef gint32 ClutterUnit;
#define CLUTTER_UNITS_FROM_PANGO_UNIT(x) ((x) << 6)
#define CLUTTER_UNITS_TO_PANGO_UNIT(x) ((x) >> 6)
#define CLUTTER_UNITS_FROM_STAGE_WIDTH_PERCENTAGE(x) \
((clutter_actor_get_widthu (clutter_stage_get_default ()) * x)/100)
#define CLUTTER_UNITS_FROM_STAGE_HEIGHT_PERCENTAGE(x) \
((clutter_actor_get_heightu (clutter_stage_get_default ()) * x)/100)
#define CLUTTER_UNITS_FROM_PARENT_WIDTH_PERCENTAGE(a, x) \
((clutter_actor_get_widthu (clutter_actor_get_parent (a)) * x)/100)
#define CLUTTER_UNITS_FROM_PARENT_HEIGHT_PERCENTAGE(a, x) \
((clutter_actor_get_heightu (clutter_actor_get_parent (a)) * x)/100)
#define CLUTTER_UNITS_FROM_MM(x) \
CLUTTER_UNITS_FROM_FLOAT(((x*clutter_stage_get_resolution (clutter_stage_get_default ())) / 25.4))
#define CLUTTER_UNITS_FROM_MMX(x) \
CFX_DIV(CFX_MUL(x,clutter_stage_get_resolutionx(clutter_stage_get_default())),0x196666)
#define CLUTTER_UNITS_FROM_POINTS(x) \
CLUTTER_UNITS_FROM_FLOAT(((x*clutter_stage_get_resolution(clutter_stage_get_default()))/72.0))
#define CLUTTER_UNITS_FROM_POINTSX(x) \
(CFX_MUL(x,clutter_stage_get_resolutionx(clutter_stage_get_default()))/72)
G_END_DECLS
#endif /* _HAVE_CLUTTER_UNITS_H */

View File

@ -1,3 +1,7 @@
2007-11-28 Tomas Frydrych <tf@openedhand.com>
* clutter-sections.txt: added new CLUTTER_UNITS_FROM_* macros.
2007-11-28 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-sections.txt: Documentation fixes.

View File

@ -40,6 +40,14 @@ CLUTTER_UNITS_FROM_PANGO_UNIT
CLUTTER_UNITS_TO_PANGO_UNIT
CLUTTER_UNITS_TMP_FROM_DEVICE
CLUTTER_UNITS_TMP_TO_DEVICE
CLUTTER_UNITS_FROM_STAGE_WIDTH_PERCENTAGE
CLUTTER_UNITS_FROM_STAGE_HEIGHT_PERCENTAGE
CLUTTER_UNITS_FROM_PARENT_WIDTH_PERCENTAGE
CLUTTER_UNITS_FROM_PARENT_HEIGHT_PERCENTAGE
CLUTTER_UNITS_FROM_MM
CLUTTER_UNITS_FROM_MMX
CLUTTER_UNITS_FROM_POINTS
CLUTTER_UNITS_FROM_POINTSX
</SECTION>
<SECTION>