Remove usage of Units and macros
The ClutterUnit and relative macros should not be used when dealing with pixels -- which is to say, all the time when inside Clutter.
This commit is contained in:
parent
26f07abc65
commit
046e571bae
@ -103,11 +103,11 @@ clutter_backend_dispose (GObject *gobject)
|
|||||||
G_OBJECT_CLASS (clutter_backend_parent_class)->dispose (gobject);
|
G_OBJECT_CLASS (clutter_backend_parent_class)->dispose (gobject);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ClutterUnit
|
static gfloat
|
||||||
get_units_per_em (ClutterBackend *backend,
|
get_units_per_em (ClutterBackend *backend,
|
||||||
PangoFontDescription *font_desc)
|
PangoFontDescription *font_desc)
|
||||||
{
|
{
|
||||||
ClutterUnit units_per_em = -1.0;
|
gfloat units_per_em = -1.0;
|
||||||
gboolean free_font_desc = FALSE;
|
gboolean free_font_desc = FALSE;
|
||||||
gdouble dpi;
|
gdouble dpi;
|
||||||
|
|
||||||
|
@ -95,20 +95,7 @@ clutter_interval_real_validate (ClutterInterval *interval,
|
|||||||
GType pspec_gtype = G_PARAM_SPEC_VALUE_TYPE (pspec);
|
GType pspec_gtype = G_PARAM_SPEC_VALUE_TYPE (pspec);
|
||||||
|
|
||||||
/* check the GTypes we provide first */
|
/* check the GTypes we provide first */
|
||||||
if (pspec_gtype == CLUTTER_TYPE_UNIT)
|
if (pspec_gtype == COGL_TYPE_FIXED)
|
||||||
{
|
|
||||||
ClutterParamSpecUnit *pspec_unit = CLUTTER_PARAM_SPEC_UNIT (pspec);
|
|
||||||
ClutterUnit a, b;
|
|
||||||
|
|
||||||
a = b = 0;
|
|
||||||
clutter_interval_get_interval (interval, &a, &b);
|
|
||||||
if ((a >= pspec_unit->minimum && a <= pspec_unit->maximum) &&
|
|
||||||
(b >= pspec_unit->minimum && b <= pspec_unit->maximum))
|
|
||||||
return TRUE;
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else if (pspec_gtype == COGL_TYPE_FIXED)
|
|
||||||
{
|
{
|
||||||
ClutterParamSpecFixed *pspec_fixed = CLUTTER_PARAM_SPEC_FIXED (pspec);
|
ClutterParamSpecFixed *pspec_fixed = CLUTTER_PARAM_SPEC_FIXED (pspec);
|
||||||
CoglFixed a, b;
|
CoglFixed a, b;
|
||||||
|
@ -322,7 +322,7 @@ clutter_text_create_layout_no_cache (ClutterText *text,
|
|||||||
gint width;
|
gint width;
|
||||||
|
|
||||||
width = allocation_width > 0
|
width = allocation_width > 0
|
||||||
? CLUTTER_UNITS_TO_PANGO_UNIT (allocation_width)
|
? (allocation_width * 1024)
|
||||||
: -1;
|
: -1;
|
||||||
|
|
||||||
pango_layout_set_width (layout, width);
|
pango_layout_set_width (layout, width);
|
||||||
@ -345,7 +345,7 @@ clutter_text_create_layout_no_cache (ClutterText *text,
|
|||||||
gint height;
|
gint height;
|
||||||
|
|
||||||
height = allocation_height > 0
|
height = allocation_height > 0
|
||||||
? CLUTTER_UNITS_TO_PANGO_UNIT (allocation_height)
|
? (allocation_height * 1024)
|
||||||
: -1;
|
: -1;
|
||||||
|
|
||||||
pango_layout_set_height (layout, height);
|
pango_layout_set_height (layout, height);
|
||||||
@ -456,16 +456,17 @@ clutter_text_create_layout (ClutterText *text,
|
|||||||
|
|
||||||
static gint
|
static gint
|
||||||
clutter_text_coords_to_position (ClutterText *text,
|
clutter_text_coords_to_position (ClutterText *text,
|
||||||
gint x,
|
gfloat x,
|
||||||
gint y)
|
gfloat y)
|
||||||
{
|
{
|
||||||
|
ClutterTextPrivate *priv = text->priv;
|
||||||
gint index_;
|
gint index_;
|
||||||
gint px, py;
|
gint px, py;
|
||||||
gint trailing;
|
gint trailing;
|
||||||
|
|
||||||
/* Take any offset due to scrolling into account */
|
/* Take any offset due to scrolling into account */
|
||||||
if (text->priv->single_line_mode)
|
if (priv->single_line_mode)
|
||||||
x += text->priv->text_x * -1;
|
x += priv->text_x * -1;
|
||||||
|
|
||||||
px = x * PANGO_SCALE;
|
px = x * PANGO_SCALE;
|
||||||
py = y * PANGO_SCALE;
|
py = y * PANGO_SCALE;
|
||||||
@ -537,7 +538,7 @@ clutter_text_position_to_coords (ClutterText *self,
|
|||||||
|
|
||||||
if (x)
|
if (x)
|
||||||
{
|
{
|
||||||
*x = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.x);
|
*x = (gfloat) rect.x / 1024.0f;
|
||||||
|
|
||||||
/* Take any offset due to scrolling into account */
|
/* Take any offset due to scrolling into account */
|
||||||
if (priv->single_line_mode)
|
if (priv->single_line_mode)
|
||||||
@ -545,10 +546,10 @@ clutter_text_position_to_coords (ClutterText *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (y)
|
if (y)
|
||||||
*y = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.y);
|
*y = (gfloat) rect.y / 1024.0f;
|
||||||
|
|
||||||
if (line_height)
|
if (line_height)
|
||||||
*line_height = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.height);
|
*line_height = (gfloat) rect.height / 1024.0f;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -982,8 +983,7 @@ cursor_paint (ClutterText *self)
|
|||||||
gint range_x;
|
gint range_x;
|
||||||
gint range_width;
|
gint range_width;
|
||||||
|
|
||||||
range_x = ranges[i * 2]
|
range_x = ranges[i * 2] / PANGO_SCALE;
|
||||||
/ PANGO_SCALE;
|
|
||||||
|
|
||||||
/* Account for any scrolling in single line mode */
|
/* Account for any scrolling in single line mode */
|
||||||
if (priv->single_line_mode)
|
if (priv->single_line_mode)
|
||||||
@ -994,10 +994,9 @@ cursor_paint (ClutterText *self)
|
|||||||
/ PANGO_SCALE;
|
/ PANGO_SCALE;
|
||||||
|
|
||||||
cogl_rectangle (range_x,
|
cogl_rectangle (range_x,
|
||||||
CLUTTER_UNITS_TO_DEVICE (y),
|
y,
|
||||||
range_x + range_width,
|
range_x + range_width,
|
||||||
CLUTTER_UNITS_TO_DEVICE (y)
|
y + height);
|
||||||
+ CLUTTER_UNITS_TO_DEVICE (height));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (ranges);
|
g_free (ranges);
|
||||||
@ -1182,18 +1181,15 @@ clutter_text_button_press (ClutterActor *actor,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
x = CLUTTER_UNITS_FROM_INT (event->x);
|
res = clutter_actor_transform_stage_point (actor,
|
||||||
y = CLUTTER_UNITS_FROM_INT (event->y);
|
event->x,
|
||||||
|
event->y,
|
||||||
res = clutter_actor_transform_stage_point (actor, x, y, &x, &y);
|
&x, &y);
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
gint offset;
|
gint offset;
|
||||||
|
|
||||||
index_ = clutter_text_coords_to_position (self,
|
index_ = clutter_text_coords_to_position (self, x, y);
|
||||||
CLUTTER_UNITS_TO_INT (x),
|
|
||||||
CLUTTER_UNITS_TO_INT (y));
|
|
||||||
|
|
||||||
offset = bytes_to_offset (priv->text, index_);
|
offset = bytes_to_offset (priv->text, index_);
|
||||||
|
|
||||||
/* what we select depends on the number of button clicks we
|
/* what we select depends on the number of button clicks we
|
||||||
@ -1229,32 +1225,30 @@ static gboolean
|
|||||||
clutter_text_motion (ClutterActor *actor,
|
clutter_text_motion (ClutterActor *actor,
|
||||||
ClutterMotionEvent *mev)
|
ClutterMotionEvent *mev)
|
||||||
{
|
{
|
||||||
ClutterText *ttext = CLUTTER_TEXT (actor);
|
ClutterText *self = CLUTTER_TEXT (actor);
|
||||||
ClutterTextPrivate *priv = ttext->priv;
|
ClutterTextPrivate *priv = self->priv;
|
||||||
gfloat x, y;
|
gfloat x, y;
|
||||||
gint index_;
|
gint index_, offset;
|
||||||
const gchar *text;
|
gboolean res;
|
||||||
|
|
||||||
if (!priv->in_select_drag)
|
if (!priv->in_select_drag)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
text = clutter_text_get_text (ttext);
|
res = clutter_actor_transform_stage_point (actor,
|
||||||
|
mev->x, mev->y,
|
||||||
|
&x, &y);
|
||||||
|
if (!res)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
x = CLUTTER_UNITS_FROM_INT (mev->x);
|
index_ = clutter_text_coords_to_position (self, x, y);
|
||||||
y = CLUTTER_UNITS_FROM_INT (mev->y);
|
offset = bytes_to_offset (priv->text, index_);
|
||||||
|
|
||||||
clutter_actor_transform_stage_point (actor, x, y, &x, &y);
|
|
||||||
|
|
||||||
index_ = clutter_text_coords_to_position (ttext,
|
|
||||||
CLUTTER_UNITS_TO_INT (x),
|
|
||||||
CLUTTER_UNITS_TO_INT (y));
|
|
||||||
|
|
||||||
if (priv->selectable)
|
if (priv->selectable)
|
||||||
clutter_text_set_cursor_position (ttext, bytes_to_offset (text, index_));
|
clutter_text_set_cursor_position (self, offset);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
clutter_text_set_cursor_position (ttext, bytes_to_offset (text, index_));
|
clutter_text_set_cursor_position (self, offset);
|
||||||
clutter_text_set_selection_bound (ttext, bytes_to_offset (text, index_));
|
clutter_text_set_selection_bound (self, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1264,8 +1258,8 @@ static gboolean
|
|||||||
clutter_text_button_release (ClutterActor *actor,
|
clutter_text_button_release (ClutterActor *actor,
|
||||||
ClutterButtonEvent *bev)
|
ClutterButtonEvent *bev)
|
||||||
{
|
{
|
||||||
ClutterText *ttext = CLUTTER_TEXT (actor);
|
ClutterText *self = CLUTTER_TEXT (actor);
|
||||||
ClutterTextPrivate *priv = ttext->priv;
|
ClutterTextPrivate *priv = self->priv;
|
||||||
|
|
||||||
if (priv->in_select_drag)
|
if (priv->in_select_drag)
|
||||||
{
|
{
|
||||||
@ -1380,11 +1374,11 @@ clutter_text_paint (ClutterActor *self)
|
|||||||
pango_layout_get_extents (layout, NULL, &logical_rect);
|
pango_layout_get_extents (layout, NULL, &logical_rect);
|
||||||
|
|
||||||
cogl_clip_push (0, 0,
|
cogl_clip_push (0, 0,
|
||||||
CLUTTER_UNITS_TO_FLOAT (alloc.x2 - alloc.x1),
|
(alloc.x2 - alloc.x1),
|
||||||
CLUTTER_UNITS_TO_FLOAT (alloc.y2 - alloc.y1));
|
(alloc.y2 - alloc.y1));
|
||||||
clip_set = TRUE;
|
clip_set = TRUE;
|
||||||
|
|
||||||
actor_width = (CLUTTER_UNITS_TO_DEVICE (alloc.x2 - alloc.x1))
|
actor_width = (alloc.x2 - alloc.x1)
|
||||||
- 2 * TEXT_PADDING;
|
- 2 * TEXT_PADDING;
|
||||||
text_width = logical_rect.width / PANGO_SCALE;
|
text_width = logical_rect.width / PANGO_SCALE;
|
||||||
|
|
||||||
@ -1471,7 +1465,7 @@ clutter_text_get_preferred_width (ClutterActor *self,
|
|||||||
logical_width = logical_rect.x + logical_rect.width;
|
logical_width = logical_rect.x + logical_rect.width;
|
||||||
|
|
||||||
layout_width = logical_width > 0
|
layout_width = logical_width > 0
|
||||||
? CLUTTER_UNITS_FROM_PANGO_UNIT (logical_width)
|
? (logical_width * 1024)
|
||||||
: 1;
|
: 1;
|
||||||
|
|
||||||
if (min_width_p)
|
if (min_width_p)
|
||||||
@ -1524,7 +1518,7 @@ clutter_text_get_preferred_height (ClutterActor *self,
|
|||||||
* the height accordingly
|
* the height accordingly
|
||||||
*/
|
*/
|
||||||
logical_height = logical_rect.y + logical_rect.height;
|
logical_height = logical_rect.y + logical_rect.height;
|
||||||
layout_height = CLUTTER_UNITS_FROM_PANGO_UNIT (logical_height);
|
layout_height = (gfloat) logical_height / 1024.0f;
|
||||||
|
|
||||||
if (min_height_p)
|
if (min_height_p)
|
||||||
{
|
{
|
||||||
@ -1534,13 +1528,13 @@ clutter_text_get_preferred_height (ClutterActor *self,
|
|||||||
if (priv->ellipsize && priv->wrap)
|
if (priv->ellipsize && priv->wrap)
|
||||||
{
|
{
|
||||||
PangoLayoutLine *line;
|
PangoLayoutLine *line;
|
||||||
ClutterUnit line_height;
|
gfloat line_height;
|
||||||
|
|
||||||
line = pango_layout_get_line_readonly (layout, 0);
|
line = pango_layout_get_line_readonly (layout, 0);
|
||||||
pango_layout_line_get_extents (line, NULL, &logical_rect);
|
pango_layout_line_get_extents (line, NULL, &logical_rect);
|
||||||
|
|
||||||
logical_height = logical_rect.y + logical_rect.height;
|
logical_height = logical_rect.y + logical_rect.height;
|
||||||
line_height = CLUTTER_UNITS_FROM_PANGO_UNIT (logical_height);
|
line_height = (gfloat) logical_height / 1024.0f;
|
||||||
|
|
||||||
*min_height_p = line_height;
|
*min_height_p = line_height;
|
||||||
}
|
}
|
||||||
|
@ -111,8 +111,8 @@ clutter_stage_x11_fix_window_size (ClutterStageX11 *stage_x11)
|
|||||||
restrictions on the window size */
|
restrictions on the window size */
|
||||||
if (!stage_x11->fullscreen_on_map)
|
if (!stage_x11->fullscreen_on_map)
|
||||||
{
|
{
|
||||||
size_hints->min_width = CLUTTER_UNITS_TO_DEVICE (min_width);
|
size_hints->min_width = (int) min_width;
|
||||||
size_hints->min_height = CLUTTER_UNITS_TO_DEVICE (min_height);
|
size_hints->min_height = (int) min_height;
|
||||||
size_hints->flags = PMinSize;
|
size_hints->flags = PMinSize;
|
||||||
|
|
||||||
if (!resize)
|
if (!resize)
|
||||||
@ -186,10 +186,10 @@ clutter_stage_x11_get_preferred_width (ClutterActor *self,
|
|||||||
width = DisplayWidth (stage_x11->xdpy, stage_x11->xscreen);
|
width = DisplayWidth (stage_x11->xdpy, stage_x11->xscreen);
|
||||||
|
|
||||||
if (min_width_p)
|
if (min_width_p)
|
||||||
*min_width_p = CLUTTER_UNITS_FROM_DEVICE (width);
|
*min_width_p = width;
|
||||||
|
|
||||||
if (natural_width_p)
|
if (natural_width_p)
|
||||||
*natural_width_p = CLUTTER_UNITS_FROM_DEVICE (width);
|
*natural_width_p = width;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -198,15 +198,14 @@ clutter_stage_x11_get_preferred_width (ClutterActor *self,
|
|||||||
|
|
||||||
if (min_width_p)
|
if (min_width_p)
|
||||||
{
|
{
|
||||||
/* FIXME need API to set this */
|
|
||||||
if (resize)
|
if (resize)
|
||||||
*min_width_p = CLUTTER_UNITS_FROM_DEVICE (1);
|
*min_width_p = 1; /* FIXME need API to set this */
|
||||||
else
|
else
|
||||||
*min_width_p = CLUTTER_UNITS_FROM_DEVICE (stage_x11->xwin_width);
|
*min_width_p = stage_x11->xwin_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (natural_width_p)
|
if (natural_width_p)
|
||||||
*natural_width_p = CLUTTER_UNITS_FROM_DEVICE (stage_x11->xwin_width);
|
*natural_width_p = stage_x11->xwin_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -225,10 +224,10 @@ clutter_stage_x11_get_preferred_height (ClutterActor *self,
|
|||||||
height = DisplayHeight (stage_x11->xdpy, stage_x11->xscreen);
|
height = DisplayHeight (stage_x11->xdpy, stage_x11->xscreen);
|
||||||
|
|
||||||
if (min_height_p)
|
if (min_height_p)
|
||||||
*min_height_p = CLUTTER_UNITS_FROM_DEVICE (height);
|
*min_height_p = height;
|
||||||
|
|
||||||
if (natural_height_p)
|
if (natural_height_p)
|
||||||
*natural_height_p = CLUTTER_UNITS_FROM_DEVICE (height);
|
*natural_height_p = height;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -238,15 +237,13 @@ clutter_stage_x11_get_preferred_height (ClutterActor *self,
|
|||||||
if (min_height_p)
|
if (min_height_p)
|
||||||
{
|
{
|
||||||
if (resize)
|
if (resize)
|
||||||
*min_height_p = CLUTTER_UNITS_FROM_DEVICE (1); /* FIXME need API
|
*min_height_p = 1; /* FIXME need API to set this */
|
||||||
* to set this
|
|
||||||
*/
|
|
||||||
else
|
else
|
||||||
*min_height_p = CLUTTER_UNITS_FROM_DEVICE (stage_x11->xwin_height);
|
*min_height_p = stage_x11->xwin_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (natural_height_p)
|
if (natural_height_p)
|
||||||
*natural_height_p = CLUTTER_UNITS_FROM_DEVICE (stage_x11->xwin_height);
|
*natural_height_p = stage_x11->xwin_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -258,8 +255,8 @@ clutter_stage_x11_allocate (ClutterActor *self,
|
|||||||
ClutterActorClass *parent_class;
|
ClutterActorClass *parent_class;
|
||||||
gint new_width, new_height;
|
gint new_width, new_height;
|
||||||
|
|
||||||
new_width = ABS (CLUTTER_UNITS_TO_INT (box->x2 - box->x1));
|
new_width = ABS ((int) (box->x2 - box->x1));
|
||||||
new_height = ABS (CLUTTER_UNITS_TO_INT (box->y2 - box->y1));
|
new_height = ABS ((int) (box->y2 - box->y1));
|
||||||
|
|
||||||
if (new_width == 0 || new_height == 0)
|
if (new_width == 0 || new_height == 0)
|
||||||
{
|
{
|
||||||
|
@ -102,19 +102,18 @@ notify_cb (GObject *object, GParamSpec *pspec, TestState *state)
|
|||||||
ClutterVertex verts[4]; \
|
ClutterVertex verts[4]; \
|
||||||
clutter_actor_get_abs_allocation_vertices ((state)->rect, verts); \
|
clutter_actor_get_abs_allocation_vertices ((state)->rect, verts); \
|
||||||
check_coords ((state), (x_1), (y_1), (x_2), (y_2), verts); \
|
check_coords ((state), (x_1), (y_1), (x_2), (y_2), verts); \
|
||||||
g_assert (approx_equal ((x_1), CLUTTER_UNITS_TO_DEVICE (verts[0].x)));\
|
g_assert (approx_equal ((x_1), verts[0].x)); \
|
||||||
g_assert (approx_equal ((y_1), CLUTTER_UNITS_TO_DEVICE (verts[0].y)));\
|
g_assert (approx_equal ((y_1), verts[0].y)); \
|
||||||
g_assert (approx_equal ((x_2), CLUTTER_UNITS_TO_DEVICE (verts[3].x)));\
|
g_assert (approx_equal ((x_2), verts[3].x)); \
|
||||||
g_assert (approx_equal ((y_2), CLUTTER_UNITS_TO_DEVICE (verts[3].y)));\
|
g_assert (approx_equal ((y_2), verts[3].y)); } G_STMT_END
|
||||||
} G_STMT_END
|
|
||||||
|
|
||||||
#define assert_position(state, x, y) \
|
#define assert_position(state, x, y) \
|
||||||
assert_coords((state), (x), (y), (x) + RECT_WIDTH, (y) + RECT_HEIGHT)
|
assert_coords((state), (x), (y), (x) + RECT_WIDTH, (y) + RECT_HEIGHT)
|
||||||
|
|
||||||
#define assert_vertex_and_free(v, xc, yc, zc) G_STMT_START { \
|
#define assert_vertex_and_free(v, xc, yc, zc) G_STMT_START { \
|
||||||
g_assert (approx_equal (CLUTTER_UNITS_TO_DEVICE (v->x), xc) && \
|
g_assert (approx_equal (v->x, xc) && \
|
||||||
approx_equal (CLUTTER_UNITS_TO_DEVICE (v->y), yc) && \
|
approx_equal (v->y, yc) && \
|
||||||
approx_equal (CLUTTER_UNITS_TO_DEVICE (v->z), zc)); \
|
approx_equal (v->z, zc)); \
|
||||||
g_boxed_free (CLUTTER_TYPE_VERTEX, v); } G_STMT_END
|
g_boxed_free (CLUTTER_TYPE_VERTEX, v); } G_STMT_END
|
||||||
|
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
@ -134,15 +133,15 @@ check_coords (TestState *state,
|
|||||||
if (g_test_verbose ())
|
if (g_test_verbose ())
|
||||||
g_print ("checking that (%i,%i,%i,%i) \xe2\x89\x88 (%i,%i,%i,%i): %s\n",
|
g_print ("checking that (%i,%i,%i,%i) \xe2\x89\x88 (%i,%i,%i,%i): %s\n",
|
||||||
x_1, y_1, x_2, y_2,
|
x_1, y_1, x_2, y_2,
|
||||||
CLUTTER_UNITS_TO_DEVICE (verts[0].x),
|
(int) (verts[0].x),
|
||||||
CLUTTER_UNITS_TO_DEVICE (verts[0].y),
|
(int) (verts[0].y),
|
||||||
CLUTTER_UNITS_TO_DEVICE (verts[3].x),
|
(int) (verts[3].x),
|
||||||
CLUTTER_UNITS_TO_DEVICE (verts[3].y),
|
(int) (verts[3].y),
|
||||||
approx_equal (x_1, CLUTTER_UNITS_TO_DEVICE (verts[0].x))
|
approx_equal (x_1, verts[0].x) &&
|
||||||
&& approx_equal (y_1, CLUTTER_UNITS_TO_DEVICE (verts[0].y))
|
approx_equal (y_1, verts[0].y) &&
|
||||||
&& approx_equal (x_2, CLUTTER_UNITS_TO_DEVICE (verts[3].x))
|
approx_equal (x_2, verts[3].x) &&
|
||||||
&& approx_equal (y_2, CLUTTER_UNITS_TO_DEVICE (verts[3].y))
|
approx_equal (y_2, verts[3].y) ? "yes"
|
||||||
? "yes" : "NO");
|
: "NO");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -494,16 +493,14 @@ test_rotate_center (TestState *state)
|
|||||||
if (i == CLUTTER_X_AXIS)
|
if (i == CLUTTER_X_AXIS)
|
||||||
{
|
{
|
||||||
g_assert (angle_x == 90.0);
|
g_assert (angle_x == 90.0);
|
||||||
assert_coords (state, rect_x, rect_y,
|
assert_coords (state, rect_x, rect_y, verts[3].x, rect_y);
|
||||||
CLUTTER_UNITS_TO_DEVICE (verts[3].x), rect_y);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g_assert (angle_x == 0.0);
|
g_assert (angle_x == 0.0);
|
||||||
if (i == CLUTTER_Y_AXIS)
|
if (i == CLUTTER_Y_AXIS)
|
||||||
{
|
{
|
||||||
g_assert (angle_y == 90.0);
|
g_assert (angle_y == 90.0);
|
||||||
assert_coords (state, rect_x, rect_y,
|
assert_coords (state, rect_x, rect_y, rect_x, verts[3].y);
|
||||||
rect_x, CLUTTER_UNITS_TO_DEVICE (verts[3].y));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g_assert (angle_y == 0.0);
|
g_assert (angle_y == 0.0);
|
||||||
@ -511,7 +508,8 @@ test_rotate_center (TestState *state)
|
|||||||
{
|
{
|
||||||
g_assert (angle_z == 90.0);
|
g_assert (angle_z == 90.0);
|
||||||
assert_coords (state, rect_x, rect_y,
|
assert_coords (state, rect_x, rect_y,
|
||||||
rect_x - RECT_HEIGHT, rect_y + RECT_WIDTH);
|
rect_x - RECT_HEIGHT,
|
||||||
|
rect_y + RECT_WIDTH);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g_assert (angle_z == 0.0);
|
g_assert (angle_z == 0.0);
|
||||||
@ -557,8 +555,8 @@ test_rotate_center (TestState *state)
|
|||||||
{
|
{
|
||||||
g_assert (angle_x == 90.0);
|
g_assert (angle_x == 90.0);
|
||||||
assert_coords (state,
|
assert_coords (state,
|
||||||
CLUTTER_UNITS_TO_DEVICE (verts[0].x), rect_y + 20,
|
verts[0].x, rect_y + 20,
|
||||||
CLUTTER_UNITS_TO_DEVICE (verts[3].x), rect_y + 20);
|
verts[3].x, rect_y + 20);
|
||||||
assert_vertex_and_free (center_x, 10, 20, 0);
|
assert_vertex_and_free (center_x, 10, 20, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -570,8 +568,8 @@ test_rotate_center (TestState *state)
|
|||||||
{
|
{
|
||||||
g_assert (angle_y == 90.0);
|
g_assert (angle_y == 90.0);
|
||||||
assert_coords (state,
|
assert_coords (state,
|
||||||
rect_x + 10, CLUTTER_UNITS_TO_DEVICE (verts[0].y),
|
rect_x + 10, verts[0].y,
|
||||||
rect_x + 10, CLUTTER_UNITS_TO_DEVICE (verts[3].y));
|
rect_x + 10, verts[3].y);
|
||||||
assert_vertex_and_free (center_y, 10, 20, 0);
|
assert_vertex_and_free (center_y, 10, 20, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -154,19 +154,15 @@ key_group_paint (ClutterActor *actor)
|
|||||||
|
|
||||||
clutter_actor_get_allocation_box (child, &box);
|
clutter_actor_get_allocation_box (child, &box);
|
||||||
|
|
||||||
box.x1 -= CLUTTER_UNITS_FROM_DEVICE (2);
|
box.x1 -= 2;
|
||||||
box.y1 -= CLUTTER_UNITS_FROM_DEVICE (2);
|
box.y1 -= 2;
|
||||||
box.x2 += CLUTTER_UNITS_FROM_DEVICE (2);
|
box.x2 += 2;
|
||||||
box.y2 += CLUTTER_UNITS_FROM_DEVICE (2);
|
box.y2 += 2;
|
||||||
|
|
||||||
cogl_set_source_color4ub (255, 255, 0, 224);
|
cogl_set_source_color4ub (255, 255, 0, 224);
|
||||||
cogl_rectangle (CLUTTER_UNITS_TO_DEVICE (box.x1),
|
cogl_rectangle (box.x1, box.y1, box.x2, box.y2);
|
||||||
CLUTTER_UNITS_TO_DEVICE (box.y1),
|
|
||||||
CLUTTER_UNITS_TO_DEVICE (box.x2),
|
|
||||||
CLUTTER_UNITS_TO_DEVICE (box.y2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CLUTTER_ACTOR_IS_VISIBLE (child))
|
|
||||||
clutter_actor_paint (child);
|
clutter_actor_paint (child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,8 +60,9 @@ on_button_press (ClutterActor *actor,
|
|||||||
new_color.alpha = 0x88;
|
new_color.alpha = 0x88;
|
||||||
}
|
}
|
||||||
|
|
||||||
vertex.x = CLUTTER_UNITS_FROM_FLOAT ((float) new_width / 2);
|
vertex.x = new_width / 2;
|
||||||
vertex.y = CLUTTER_UNITS_FROM_FLOAT ((float) new_height / 2);
|
vertex.y = new_height / 2;
|
||||||
|
vertex.z = 0.0;
|
||||||
|
|
||||||
animation =
|
animation =
|
||||||
clutter_actor_animate (actor, CLUTTER_EASE_IN_EXPO, 2000,
|
clutter_actor_animate (actor, CLUTTER_EASE_IN_EXPO, 2000,
|
||||||
|
@ -161,19 +161,15 @@ key_group_paint (ClutterActor *actor)
|
|||||||
|
|
||||||
clutter_actor_get_allocation_box (child, &box);
|
clutter_actor_get_allocation_box (child, &box);
|
||||||
|
|
||||||
box.x1 -= CLUTTER_UNITS_FROM_DEVICE (2);
|
box.x1 -= 2;
|
||||||
box.y1 -= CLUTTER_UNITS_FROM_DEVICE (2);
|
box.y1 -= 2;
|
||||||
box.x2 += CLUTTER_UNITS_FROM_DEVICE (2);
|
box.x2 += 2;
|
||||||
box.y2 += CLUTTER_UNITS_FROM_DEVICE (2);
|
box.y2 += 2;
|
||||||
|
|
||||||
cogl_set_source_color4ub (255, 255, 0, 224);
|
cogl_set_source_color4ub (255, 255, 0, 224);
|
||||||
cogl_rectangle (CLUTTER_UNITS_TO_DEVICE (box.x1),
|
cogl_rectangle (box.x1, box.y1, box.x2, box.y2);
|
||||||
CLUTTER_UNITS_TO_DEVICE (box.y1),
|
|
||||||
CLUTTER_UNITS_TO_DEVICE (box.x2),
|
|
||||||
CLUTTER_UNITS_TO_DEVICE (box.y2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CLUTTER_ACTOR_IS_VISIBLE (child))
|
|
||||||
clutter_actor_paint (child);
|
clutter_actor_paint (child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ struct _MyThingPrivate
|
|||||||
{
|
{
|
||||||
GList *children;
|
GList *children;
|
||||||
|
|
||||||
ClutterUnit spacing;
|
gfloat spacing;
|
||||||
ClutterUnit padding;
|
gfloat padding;
|
||||||
|
|
||||||
guint use_transformed_box : 1;
|
guint use_transformed_box : 1;
|
||||||
};
|
};
|
||||||
@ -139,11 +139,11 @@ my_thing_set_property (GObject *gobject,
|
|||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_SPACING:
|
case PROP_SPACING:
|
||||||
priv->spacing = clutter_value_get_unit (value);
|
priv->spacing = g_value_get_float (value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_PADDING:
|
case PROP_PADDING:
|
||||||
priv->padding = clutter_value_get_unit (value);
|
priv->padding = g_value_get_float (value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_USE_TRANSFORMED_BOX:
|
case PROP_USE_TRANSFORMED_BOX:
|
||||||
@ -174,11 +174,11 @@ my_thing_get_property (GObject *gobject,
|
|||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_SPACING:
|
case PROP_SPACING:
|
||||||
clutter_value_set_unit (value, priv->spacing);
|
g_value_set_float (value, priv->spacing);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_PADDING:
|
case PROP_PADDING:
|
||||||
clutter_value_set_unit (value, priv->padding);
|
g_value_set_float (value, priv->padding);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_USE_TRANSFORMED_BOX:
|
case PROP_USE_TRANSFORMED_BOX:
|
||||||
@ -214,14 +214,14 @@ my_thing_dispose (GObject *gobject)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
my_thing_get_preferred_width (ClutterActor *self,
|
my_thing_get_preferred_width (ClutterActor *self,
|
||||||
ClutterUnit for_height,
|
gfloat for_height,
|
||||||
ClutterUnit *min_width_p,
|
gfloat *min_width_p,
|
||||||
ClutterUnit *natural_width_p)
|
gfloat *natural_width_p)
|
||||||
{
|
{
|
||||||
MyThingPrivate *priv;
|
MyThingPrivate *priv;
|
||||||
GList *l;
|
GList *l;
|
||||||
ClutterUnit min_left, min_right;
|
gfloat min_left, min_right;
|
||||||
ClutterUnit natural_left, natural_right;
|
gfloat natural_left, natural_right;
|
||||||
|
|
||||||
priv = MY_THING (self)->priv;
|
priv = MY_THING (self)->priv;
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ my_thing_get_preferred_width (ClutterActor *self,
|
|||||||
for (l = priv->children; l != NULL; l = l->next)
|
for (l = priv->children; l != NULL; l = l->next)
|
||||||
{
|
{
|
||||||
ClutterActor *child;
|
ClutterActor *child;
|
||||||
ClutterUnit child_x, child_min, child_natural;
|
gfloat child_x, child_min, child_natural;
|
||||||
|
|
||||||
child = l->data;
|
child = l->data;
|
||||||
|
|
||||||
@ -292,14 +292,14 @@ my_thing_get_preferred_width (ClutterActor *self,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
my_thing_get_preferred_height (ClutterActor *self,
|
my_thing_get_preferred_height (ClutterActor *self,
|
||||||
ClutterUnit for_width,
|
gfloat for_width,
|
||||||
ClutterUnit *min_height_p,
|
gfloat *min_height_p,
|
||||||
ClutterUnit *natural_height_p)
|
gfloat *natural_height_p)
|
||||||
{
|
{
|
||||||
MyThingPrivate *priv;
|
MyThingPrivate *priv;
|
||||||
GList *l;
|
GList *l;
|
||||||
ClutterUnit min_top, min_bottom;
|
gfloat min_top, min_bottom;
|
||||||
ClutterUnit natural_top, natural_bottom;
|
gfloat natural_top, natural_bottom;
|
||||||
|
|
||||||
priv = MY_THING (self)->priv;
|
priv = MY_THING (self)->priv;
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ my_thing_get_preferred_height (ClutterActor *self,
|
|||||||
for (l = priv->children; l != NULL; l = l->next)
|
for (l = priv->children; l != NULL; l = l->next)
|
||||||
{
|
{
|
||||||
ClutterActor *child;
|
ClutterActor *child;
|
||||||
ClutterUnit child_y, child_min, child_natural;
|
gfloat child_y, child_min, child_natural;
|
||||||
|
|
||||||
child = l->data;
|
child = l->data;
|
||||||
|
|
||||||
@ -374,7 +374,7 @@ my_thing_allocate (ClutterActor *self,
|
|||||||
gboolean origin_changed)
|
gboolean origin_changed)
|
||||||
{
|
{
|
||||||
MyThingPrivate *priv;
|
MyThingPrivate *priv;
|
||||||
ClutterUnit current_x, current_y, max_row_height;
|
gfloat current_x, current_y, max_row_height;
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
/* chain up to set actor->allocation */
|
/* chain up to set actor->allocation */
|
||||||
@ -394,7 +394,7 @@ my_thing_allocate (ClutterActor *self,
|
|||||||
for (l = priv->children; l != NULL; l = l->next)
|
for (l = priv->children; l != NULL; l = l->next)
|
||||||
{
|
{
|
||||||
ClutterActor *child;
|
ClutterActor *child;
|
||||||
ClutterUnit natural_width, natural_height;
|
gfloat natural_width, natural_height;
|
||||||
ClutterActorBox child_box;
|
ClutterActorBox child_box;
|
||||||
|
|
||||||
child = l->data;
|
child = l->data;
|
||||||
@ -517,19 +517,19 @@ my_thing_class_init (MyThingClass *klass)
|
|||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_SPACING,
|
PROP_SPACING,
|
||||||
clutter_param_spec_unit ("spacing",
|
g_param_spec_float ("spacing",
|
||||||
"Spacing",
|
"Spacing",
|
||||||
"Spacing of the thing",
|
"Spacing of the thing",
|
||||||
0, CLUTTER_MAXUNIT,
|
0, G_MAXFLOAT,
|
||||||
0,
|
0,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_PADDING,
|
PROP_PADDING,
|
||||||
clutter_param_spec_unit ("padding",
|
g_param_spec_float ("padding",
|
||||||
"Padding",
|
"Padding",
|
||||||
"Padding around the thing",
|
"Padding around the thing",
|
||||||
0, CLUTTER_MAXUNIT,
|
0, G_MAXFLOAT,
|
||||||
0,
|
0,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
@ -118,10 +118,10 @@ on_event (ClutterStage *stage,
|
|||||||
{
|
{
|
||||||
if (dragging)
|
if (dragging)
|
||||||
{
|
{
|
||||||
gfloat x, y;
|
|
||||||
gint i;
|
|
||||||
ClutterActorBox box1, box2;
|
ClutterActorBox box1, box2;
|
||||||
ClutterUnit xp, yp;
|
gfloat x, y;
|
||||||
|
gfloat xp, yp;
|
||||||
|
gint i;
|
||||||
|
|
||||||
i = find_handle_index (dragging);
|
i = find_handle_index (dragging);
|
||||||
|
|
||||||
@ -133,23 +133,17 @@ on_event (ClutterStage *stage,
|
|||||||
clutter_actor_get_allocation_box (dragging, &box1);
|
clutter_actor_get_allocation_box (dragging, &box1);
|
||||||
clutter_actor_get_allocation_box (rect, &box2);
|
clutter_actor_get_allocation_box (rect, &box2);
|
||||||
|
|
||||||
xp = CLUTTER_UNITS_FROM_DEVICE (x - 3) - box1.x1;
|
xp = (x - 3) - box1.x1;
|
||||||
yp = CLUTTER_UNITS_FROM_DEVICE (y - 3) - box1.y1;
|
yp = (y - 3) - box1.y1;
|
||||||
|
|
||||||
if (i == 4)
|
if (i == 4)
|
||||||
{
|
{
|
||||||
g_debug ("moving box by %f, %f",
|
g_debug ("moving box by %f, %f", xp, yp);
|
||||||
CLUTTER_UNITS_TO_FLOAT (xp),
|
|
||||||
CLUTTER_UNITS_TO_FLOAT (yp));
|
|
||||||
|
|
||||||
clutter_actor_move_by (rect, xp, yp);
|
clutter_actor_move_by (rect, xp, yp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_debug ("adjusting box by %f, %f, handle %d",
|
g_debug ("adjusting box by %f, %f, handle %d", xp, yp, i);
|
||||||
CLUTTER_UNITS_TO_FLOAT (xp),
|
|
||||||
CLUTTER_UNITS_TO_FLOAT (yp),
|
|
||||||
i);
|
|
||||||
|
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
|
@ -9,18 +9,14 @@ on_entry_paint (ClutterActor *actor,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
ClutterActorBox allocation = { 0, };
|
ClutterActorBox allocation = { 0, };
|
||||||
ClutterUnit width, height;
|
gfloat width, height;
|
||||||
|
|
||||||
clutter_actor_get_allocation_box (actor, &allocation);
|
clutter_actor_get_allocation_box (actor, &allocation);
|
||||||
width = allocation.x2 - allocation.x1;
|
width = allocation.x2 - allocation.x1;
|
||||||
height = allocation.y2 - allocation.y1;
|
height = allocation.y2 - allocation.y1;
|
||||||
|
|
||||||
cogl_set_source_color4ub (255, 255, 255, 255);
|
cogl_set_source_color4ub (255, 255, 255, 255);
|
||||||
cogl_path_round_rectangle (0, 0,
|
cogl_path_round_rectangle (0, 0, width, height, 4.0, 1.0);
|
||||||
CLUTTER_UNITS_TO_FLOAT (width),
|
|
||||||
CLUTTER_UNITS_TO_FLOAT (height),
|
|
||||||
4.0,
|
|
||||||
COGL_ANGLE_FROM_DEG (1.0));
|
|
||||||
cogl_path_stroke ();
|
cogl_path_stroke ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user