G_OBJECT_CLASS (clutter_backend_parent_class)->dispose (gobject);
}
-static ClutterUnit
+static gfloat
get_units_per_em (ClutterBackend *backend,
PangoFontDescription *font_desc)
{
- ClutterUnit units_per_em = -1.0;
+ gfloat units_per_em = -1.0;
gboolean free_font_desc = FALSE;
gdouble dpi;
GType pspec_gtype = G_PARAM_SPEC_VALUE_TYPE (pspec);
/* check the GTypes we provide first */
- if (pspec_gtype == CLUTTER_TYPE_UNIT)
- {
- 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)
+ if (pspec_gtype == COGL_TYPE_FIXED)
{
ClutterParamSpecFixed *pspec_fixed = CLUTTER_PARAM_SPEC_FIXED (pspec);
CoglFixed a, b;
gint width;
width = allocation_width > 0
- ? CLUTTER_UNITS_TO_PANGO_UNIT (allocation_width)
+ ? (allocation_width * 1024)
: -1;
pango_layout_set_width (layout, width);
gint height;
height = allocation_height > 0
- ? CLUTTER_UNITS_TO_PANGO_UNIT (allocation_height)
+ ? (allocation_height * 1024)
: -1;
pango_layout_set_height (layout, height);
static gint
clutter_text_coords_to_position (ClutterText *text,
- gint x,
- gint y)
+ gfloat x,
+ gfloat y)
{
+ ClutterTextPrivate *priv = text->priv;
gint index_;
gint px, py;
gint trailing;
/* Take any offset due to scrolling into account */
- if (text->priv->single_line_mode)
- x += text->priv->text_x * -1;
+ if (priv->single_line_mode)
+ x += priv->text_x * -1;
px = x * PANGO_SCALE;
py = y * PANGO_SCALE;
if (x)
{
- *x = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.x);
+ *x = (gfloat) rect.x / 1024.0f;
/* Take any offset due to scrolling into account */
if (priv->single_line_mode)
}
if (y)
- *y = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.y);
+ *y = (gfloat) rect.y / 1024.0f;
if (line_height)
- *line_height = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.height);
+ *line_height = (gfloat) rect.height / 1024.0f;
return TRUE;
}
gint range_x;
gint range_width;
- range_x = ranges[i * 2]
- / PANGO_SCALE;
+ range_x = ranges[i * 2] / PANGO_SCALE;
/* Account for any scrolling in single line mode */
if (priv->single_line_mode)
- range_x += priv->text_x;
+ range_x += priv->text_x;
range_width = (ranges[i * 2 + 1] - ranges[i * 2])
/ PANGO_SCALE;
cogl_rectangle (range_x,
- CLUTTER_UNITS_TO_DEVICE (y),
+ y,
range_x + range_width,
- CLUTTER_UNITS_TO_DEVICE (y)
- + CLUTTER_UNITS_TO_DEVICE (height));
+ y + height);
}
g_free (ranges);
return TRUE;
}
- x = CLUTTER_UNITS_FROM_INT (event->x);
- y = CLUTTER_UNITS_FROM_INT (event->y);
-
- res = clutter_actor_transform_stage_point (actor, x, y, &x, &y);
+ res = clutter_actor_transform_stage_point (actor,
+ event->x,
+ event->y,
+ &x, &y);
if (res)
{
gint offset;
- index_ = clutter_text_coords_to_position (self,
- CLUTTER_UNITS_TO_INT (x),
- CLUTTER_UNITS_TO_INT (y));
-
+ index_ = clutter_text_coords_to_position (self, x, y);
offset = bytes_to_offset (priv->text, index_);
/* what we select depends on the number of button clicks we
clutter_text_motion (ClutterActor *actor,
ClutterMotionEvent *mev)
{
- ClutterText *ttext = CLUTTER_TEXT (actor);
- ClutterTextPrivate *priv = ttext->priv;
+ ClutterText *self = CLUTTER_TEXT (actor);
+ ClutterTextPrivate *priv = self->priv;
gfloat x, y;
- gint index_;
- const gchar *text;
+ gint index_, offset;
+ gboolean res;
if (!priv->in_select_drag)
return FALSE;
- text = clutter_text_get_text (ttext);
-
- x = CLUTTER_UNITS_FROM_INT (mev->x);
- y = CLUTTER_UNITS_FROM_INT (mev->y);
-
- clutter_actor_transform_stage_point (actor, x, y, &x, &y);
+ res = clutter_actor_transform_stage_point (actor,
+ mev->x, mev->y,
+ &x, &y);
+ if (!res)
+ return FALSE;
- index_ = clutter_text_coords_to_position (ttext,
- CLUTTER_UNITS_TO_INT (x),
- CLUTTER_UNITS_TO_INT (y));
+ index_ = clutter_text_coords_to_position (self, x, y);
+ offset = bytes_to_offset (priv->text, index_);
if (priv->selectable)
- clutter_text_set_cursor_position (ttext, bytes_to_offset (text, index_));
+ clutter_text_set_cursor_position (self, offset);
else
{
- clutter_text_set_cursor_position (ttext, bytes_to_offset (text, index_));
- clutter_text_set_selection_bound (ttext, bytes_to_offset (text, index_));
+ clutter_text_set_cursor_position (self, offset);
+ clutter_text_set_selection_bound (self, offset);
}
return TRUE;
clutter_text_button_release (ClutterActor *actor,
ClutterButtonEvent *bev)
{
- ClutterText *ttext = CLUTTER_TEXT (actor);
- ClutterTextPrivate *priv = ttext->priv;
+ ClutterText *self = CLUTTER_TEXT (actor);
+ ClutterTextPrivate *priv = self->priv;
if (priv->in_select_drag)
{
pango_layout_get_extents (layout, NULL, &logical_rect);
cogl_clip_push (0, 0,
- CLUTTER_UNITS_TO_FLOAT (alloc.x2 - alloc.x1),
- CLUTTER_UNITS_TO_FLOAT (alloc.y2 - alloc.y1));
+ (alloc.x2 - alloc.x1),
+ (alloc.y2 - alloc.y1));
clip_set = TRUE;
- actor_width = (CLUTTER_UNITS_TO_DEVICE (alloc.x2 - alloc.x1))
+ actor_width = (alloc.x2 - alloc.x1)
- 2 * TEXT_PADDING;
text_width = logical_rect.width / PANGO_SCALE;
logical_width = logical_rect.x + logical_rect.width;
layout_width = logical_width > 0
- ? CLUTTER_UNITS_FROM_PANGO_UNIT (logical_width)
+ ? (logical_width * 1024)
: 1;
if (min_width_p)
* the height accordingly
*/
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 (priv->ellipsize && priv->wrap)
{
PangoLayoutLine *line;
- ClutterUnit line_height;
+ gfloat line_height;
line = pango_layout_get_line_readonly (layout, 0);
pango_layout_line_get_extents (line, NULL, &logical_rect);
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;
}
restrictions on the window size */
if (!stage_x11->fullscreen_on_map)
{
- size_hints->min_width = CLUTTER_UNITS_TO_DEVICE (min_width);
- size_hints->min_height = CLUTTER_UNITS_TO_DEVICE (min_height);
+ size_hints->min_width = (int) min_width;
+ size_hints->min_height = (int) min_height;
size_hints->flags = PMinSize;
if (!resize)
width = DisplayWidth (stage_x11->xdpy, stage_x11->xscreen);
if (min_width_p)
- *min_width_p = CLUTTER_UNITS_FROM_DEVICE (width);
+ *min_width_p = width;
if (natural_width_p)
- *natural_width_p = CLUTTER_UNITS_FROM_DEVICE (width);
+ *natural_width_p = width;
return;
}
if (min_width_p)
{
- /* FIXME need API to set this */
if (resize)
- *min_width_p = CLUTTER_UNITS_FROM_DEVICE (1);
+ *min_width_p = 1; /* FIXME need API to set this */
else
- *min_width_p = CLUTTER_UNITS_FROM_DEVICE (stage_x11->xwin_width);
+ *min_width_p = stage_x11->xwin_width;
}
if (natural_width_p)
- *natural_width_p = CLUTTER_UNITS_FROM_DEVICE (stage_x11->xwin_width);
+ *natural_width_p = stage_x11->xwin_width;
}
static void
height = DisplayHeight (stage_x11->xdpy, stage_x11->xscreen);
if (min_height_p)
- *min_height_p = CLUTTER_UNITS_FROM_DEVICE (height);
+ *min_height_p = height;
if (natural_height_p)
- *natural_height_p = CLUTTER_UNITS_FROM_DEVICE (height);
+ *natural_height_p = height;
return;
}
if (min_height_p)
{
if (resize)
- *min_height_p = CLUTTER_UNITS_FROM_DEVICE (1); /* FIXME need API
- * to set this
- */
+ *min_height_p = 1; /* FIXME need API to set this */
else
- *min_height_p = CLUTTER_UNITS_FROM_DEVICE (stage_x11->xwin_height);
+ *min_height_p = stage_x11->xwin_height;
}
if (natural_height_p)
- *natural_height_p = CLUTTER_UNITS_FROM_DEVICE (stage_x11->xwin_height);
+ *natural_height_p = stage_x11->xwin_height;
}
static void
ClutterActorClass *parent_class;
gint new_width, new_height;
- new_width = ABS (CLUTTER_UNITS_TO_INT (box->x2 - box->x1));
- new_height = ABS (CLUTTER_UNITS_TO_INT (box->y2 - box->y1));
+ new_width = ABS ((int) (box->x2 - box->x1));
+ new_height = ABS ((int) (box->y2 - box->y1));
if (new_width == 0 || new_height == 0)
{
ClutterVertex verts[4]; \
clutter_actor_get_abs_allocation_vertices ((state)->rect, 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 ((y_1), CLUTTER_UNITS_TO_DEVICE (verts[0].y)));\
- g_assert (approx_equal ((x_2), CLUTTER_UNITS_TO_DEVICE (verts[3].x)));\
- g_assert (approx_equal ((y_2), CLUTTER_UNITS_TO_DEVICE (verts[3].y)));\
- } G_STMT_END
+ g_assert (approx_equal ((x_1), verts[0].x)); \
+ g_assert (approx_equal ((y_1), verts[0].y)); \
+ g_assert (approx_equal ((x_2), verts[3].x)); \
+ g_assert (approx_equal ((y_2), verts[3].y)); } G_STMT_END
#define assert_position(state, x, y) \
assert_coords((state), (x), (y), (x) + RECT_WIDTH, (y) + RECT_HEIGHT)
-#define assert_vertex_and_free(v, xc, yc, zc) G_STMT_START { \
- g_assert (approx_equal (CLUTTER_UNITS_TO_DEVICE (v->x), xc) && \
- approx_equal (CLUTTER_UNITS_TO_DEVICE (v->y), yc) && \
- approx_equal (CLUTTER_UNITS_TO_DEVICE (v->z), zc)); \
- g_boxed_free (CLUTTER_TYPE_VERTEX, v); } G_STMT_END
+#define assert_vertex_and_free(v, xc, yc, zc) G_STMT_START { \
+ g_assert (approx_equal (v->x, xc) && \
+ approx_equal (v->y, yc) && \
+ approx_equal (v->z, zc)); \
+ g_boxed_free (CLUTTER_TYPE_VERTEX, v); } G_STMT_END
static inline gboolean
approx_equal (int a, int b)
if (g_test_verbose ())
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,
- CLUTTER_UNITS_TO_DEVICE (verts[0].x),
- CLUTTER_UNITS_TO_DEVICE (verts[0].y),
- CLUTTER_UNITS_TO_DEVICE (verts[3].x),
- CLUTTER_UNITS_TO_DEVICE (verts[3].y),
- approx_equal (x_1, CLUTTER_UNITS_TO_DEVICE (verts[0].x))
- && approx_equal (y_1, CLUTTER_UNITS_TO_DEVICE (verts[0].y))
- && approx_equal (x_2, CLUTTER_UNITS_TO_DEVICE (verts[3].x))
- && approx_equal (y_2, CLUTTER_UNITS_TO_DEVICE (verts[3].y))
- ? "yes" : "NO");
+ (int) (verts[0].x),
+ (int) (verts[0].y),
+ (int) (verts[3].x),
+ (int) (verts[3].y),
+ approx_equal (x_1, verts[0].x) &&
+ approx_equal (y_1, verts[0].y) &&
+ approx_equal (x_2, verts[3].x) &&
+ approx_equal (y_2, verts[3].y) ? "yes"
+ : "NO");
}
static void
if (i == CLUTTER_X_AXIS)
{
g_assert (angle_x == 90.0);
- assert_coords (state, rect_x, rect_y,
- CLUTTER_UNITS_TO_DEVICE (verts[3].x), rect_y);
+ assert_coords (state, rect_x, rect_y, verts[3].x, rect_y);
}
else
g_assert (angle_x == 0.0);
if (i == CLUTTER_Y_AXIS)
{
g_assert (angle_y == 90.0);
- assert_coords (state, rect_x, rect_y,
- rect_x, CLUTTER_UNITS_TO_DEVICE (verts[3].y));
+ assert_coords (state, rect_x, rect_y, rect_x, verts[3].y);
}
else
g_assert (angle_y == 0.0);
{
g_assert (angle_z == 90.0);
assert_coords (state, rect_x, rect_y,
- rect_x - RECT_HEIGHT, rect_y + RECT_WIDTH);
+ rect_x - RECT_HEIGHT,
+ rect_y + RECT_WIDTH);
}
else
g_assert (angle_z == 0.0);
{
g_assert (angle_x == 90.0);
assert_coords (state,
- CLUTTER_UNITS_TO_DEVICE (verts[0].x), rect_y + 20,
- CLUTTER_UNITS_TO_DEVICE (verts[3].x), rect_y + 20);
+ verts[0].x, rect_y + 20,
+ verts[3].x, rect_y + 20);
assert_vertex_and_free (center_x, 10, 20, 0);
}
else
{
g_assert (angle_y == 90.0);
assert_coords (state,
- rect_x + 10, CLUTTER_UNITS_TO_DEVICE (verts[0].y),
- rect_x + 10, CLUTTER_UNITS_TO_DEVICE (verts[3].y));
+ rect_x + 10, verts[0].y,
+ rect_x + 10, verts[3].y);
assert_vertex_and_free (center_y, 10, 20, 0);
}
else
clutter_actor_get_allocation_box (child, &box);
- box.x1 -= CLUTTER_UNITS_FROM_DEVICE (2);
- box.y1 -= CLUTTER_UNITS_FROM_DEVICE (2);
- box.x2 += CLUTTER_UNITS_FROM_DEVICE (2);
- box.y2 += CLUTTER_UNITS_FROM_DEVICE (2);
+ box.x1 -= 2;
+ box.y1 -= 2;
+ box.x2 += 2;
+ box.y2 += 2;
cogl_set_source_color4ub (255, 255, 0, 224);
- cogl_rectangle (CLUTTER_UNITS_TO_DEVICE (box.x1),
- CLUTTER_UNITS_TO_DEVICE (box.y1),
- CLUTTER_UNITS_TO_DEVICE (box.x2),
- CLUTTER_UNITS_TO_DEVICE (box.y2));
+ cogl_rectangle (box.x1, box.y1, box.x2, box.y2);
}
- if (CLUTTER_ACTOR_IS_VISIBLE (child))
- clutter_actor_paint (child);
+ clutter_actor_paint (child);
}
g_list_free (children);
new_color.alpha = 0x88;
}
- vertex.x = CLUTTER_UNITS_FROM_FLOAT ((float) new_width / 2);
- vertex.y = CLUTTER_UNITS_FROM_FLOAT ((float) new_height / 2);
+ vertex.x = new_width / 2;
+ vertex.y = new_height / 2;
+ vertex.z = 0.0;
animation =
clutter_actor_animate (actor, CLUTTER_EASE_IN_EXPO, 2000,
clutter_actor_get_allocation_box (child, &box);
- box.x1 -= CLUTTER_UNITS_FROM_DEVICE (2);
- box.y1 -= CLUTTER_UNITS_FROM_DEVICE (2);
- box.x2 += CLUTTER_UNITS_FROM_DEVICE (2);
- box.y2 += CLUTTER_UNITS_FROM_DEVICE (2);
+ box.x1 -= 2;
+ box.y1 -= 2;
+ box.x2 += 2;
+ box.y2 += 2;
cogl_set_source_color4ub (255, 255, 0, 224);
- cogl_rectangle (CLUTTER_UNITS_TO_DEVICE (box.x1),
- CLUTTER_UNITS_TO_DEVICE (box.y1),
- CLUTTER_UNITS_TO_DEVICE (box.x2),
- CLUTTER_UNITS_TO_DEVICE (box.y2));
+ cogl_rectangle (box.x1, box.y1, box.x2, box.y2);
}
- if (CLUTTER_ACTOR_IS_VISIBLE (child))
- clutter_actor_paint (child);
+ clutter_actor_paint (child);
}
g_list_free (children);
struct _MyThingPrivate
{
- GList *children;
+ GList *children;
- ClutterUnit spacing;
- ClutterUnit padding;
+ gfloat spacing;
+ gfloat padding;
- guint use_transformed_box : 1;
+ guint use_transformed_box : 1;
};
/* Add, remove, foreach, copied from ClutterGroup code. */
switch (prop_id)
{
case PROP_SPACING:
- priv->spacing = clutter_value_get_unit (value);
+ priv->spacing = g_value_get_float (value);
break;
case PROP_PADDING:
- priv->padding = clutter_value_get_unit (value);
+ priv->padding = g_value_get_float (value);
break;
case PROP_USE_TRANSFORMED_BOX:
switch (prop_id)
{
case PROP_SPACING:
- clutter_value_set_unit (value, priv->spacing);
+ g_value_set_float (value, priv->spacing);
break;
case PROP_PADDING:
- clutter_value_set_unit (value, priv->padding);
+ g_value_set_float (value, priv->padding);
break;
case PROP_USE_TRANSFORMED_BOX:
static void
my_thing_get_preferred_width (ClutterActor *self,
- ClutterUnit for_height,
- ClutterUnit *min_width_p,
- ClutterUnit *natural_width_p)
+ gfloat for_height,
+ gfloat *min_width_p,
+ gfloat *natural_width_p)
{
MyThingPrivate *priv;
GList *l;
- ClutterUnit min_left, min_right;
- ClutterUnit natural_left, natural_right;
+ gfloat min_left, min_right;
+ gfloat natural_left, natural_right;
priv = MY_THING (self)->priv;
for (l = priv->children; l != NULL; l = l->next)
{
ClutterActor *child;
- ClutterUnit child_x, child_min, child_natural;
+ gfloat child_x, child_min, child_natural;
child = l->data;
static void
my_thing_get_preferred_height (ClutterActor *self,
- ClutterUnit for_width,
- ClutterUnit *min_height_p,
- ClutterUnit *natural_height_p)
+ gfloat for_width,
+ gfloat *min_height_p,
+ gfloat *natural_height_p)
{
MyThingPrivate *priv;
GList *l;
- ClutterUnit min_top, min_bottom;
- ClutterUnit natural_top, natural_bottom;
+ gfloat min_top, min_bottom;
+ gfloat natural_top, natural_bottom;
priv = MY_THING (self)->priv;
for (l = priv->children; l != NULL; l = l->next)
{
ClutterActor *child;
- ClutterUnit child_y, child_min, child_natural;
+ gfloat child_y, child_min, child_natural;
child = l->data;
gboolean origin_changed)
{
MyThingPrivate *priv;
- ClutterUnit current_x, current_y, max_row_height;
+ gfloat current_x, current_y, max_row_height;
GList *l;
/* chain up to set actor->allocation */
for (l = priv->children; l != NULL; l = l->next)
{
ClutterActor *child;
- ClutterUnit natural_width, natural_height;
+ gfloat natural_width, natural_height;
ClutterActorBox child_box;
child = l->data;
g_object_class_install_property (gobject_class,
PROP_SPACING,
- clutter_param_spec_unit ("spacing",
- "Spacing",
- "Spacing of the thing",
- 0, CLUTTER_MAXUNIT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_float ("spacing",
+ "Spacing",
+ "Spacing of the thing",
+ 0, G_MAXFLOAT,
+ 0,
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_PADDING,
- clutter_param_spec_unit ("padding",
- "Padding",
- "Padding around the thing",
- 0, CLUTTER_MAXUNIT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_float ("padding",
+ "Padding",
+ "Padding around the thing",
+ 0, G_MAXFLOAT,
+ 0,
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_USE_TRANSFORMED_BOX,
{
if (dragging)
{
+ ClutterActorBox box1, box2;
gfloat x, y;
+ gfloat xp, yp;
gint i;
- ClutterActorBox box1, box2;
- ClutterUnit xp, yp;
i = find_handle_index (dragging);
clutter_actor_get_allocation_box (dragging, &box1);
clutter_actor_get_allocation_box (rect, &box2);
- xp = CLUTTER_UNITS_FROM_DEVICE (x - 3) - box1.x1;
- yp = CLUTTER_UNITS_FROM_DEVICE (y - 3) - box1.y1;
+ xp = (x - 3) - box1.x1;
+ yp = (y - 3) - box1.y1;
if (i == 4)
{
- g_debug ("moving box by %f, %f",
- CLUTTER_UNITS_TO_FLOAT (xp),
- CLUTTER_UNITS_TO_FLOAT (yp));
-
+ g_debug ("moving box by %f, %f", xp, yp);
clutter_actor_move_by (rect, xp, yp);
}
else
{
- g_debug ("adjusting box by %f, %f, handle %d",
- CLUTTER_UNITS_TO_FLOAT (xp),
- CLUTTER_UNITS_TO_FLOAT (yp),
- i);
+ g_debug ("adjusting box by %f, %f, handle %d", xp, yp, i);
switch (i)
{
gpointer data)
{
ClutterActorBox allocation = { 0, };
- ClutterUnit width, height;
+ gfloat width, height;
clutter_actor_get_allocation_box (actor, &allocation);
width = allocation.x2 - allocation.x1;
height = allocation.y2 - allocation.y1;
cogl_set_source_color4ub (255, 255, 255, 255);
- cogl_path_round_rectangle (0, 0,
- CLUTTER_UNITS_TO_FLOAT (width),
- CLUTTER_UNITS_TO_FLOAT (height),
- 4.0,
- COGL_ANGLE_FROM_DEG (1.0));
+ cogl_path_round_rectangle (0, 0, width, height, 4.0, 1.0);
cogl_path_stroke ();
}