mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -95,20 +95,7 @@ clutter_interval_real_validate (ClutterInterval *interval,
|
||||
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;
|
||||
|
@ -322,7 +322,7 @@ clutter_text_create_layout_no_cache (ClutterText *text,
|
||||
gint width;
|
||||
|
||||
width = allocation_width > 0
|
||||
? CLUTTER_UNITS_TO_PANGO_UNIT (allocation_width)
|
||||
? (allocation_width * 1024)
|
||||
: -1;
|
||||
|
||||
pango_layout_set_width (layout, width);
|
||||
@ -345,7 +345,7 @@ clutter_text_create_layout_no_cache (ClutterText *text,
|
||||
gint height;
|
||||
|
||||
height = allocation_height > 0
|
||||
? CLUTTER_UNITS_TO_PANGO_UNIT (allocation_height)
|
||||
? (allocation_height * 1024)
|
||||
: -1;
|
||||
|
||||
pango_layout_set_height (layout, height);
|
||||
@ -456,16 +456,17 @@ clutter_text_create_layout (ClutterText *text,
|
||||
|
||||
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;
|
||||
@ -537,7 +538,7 @@ clutter_text_position_to_coords (ClutterText *self,
|
||||
|
||||
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)
|
||||
@ -545,10 +546,10 @@ clutter_text_position_to_coords (ClutterText *self,
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@ -982,22 +983,20 @@ cursor_paint (ClutterText *self)
|
||||
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);
|
||||
@ -1182,18 +1181,15 @@ clutter_text_button_press (ClutterActor *actor,
|
||||
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
|
||||
@ -1229,32 +1225,30 @@ static gboolean
|
||||
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);
|
||||
res = clutter_actor_transform_stage_point (actor,
|
||||
mev->x, mev->y,
|
||||
&x, &y);
|
||||
if (!res)
|
||||
return FALSE;
|
||||
|
||||
x = CLUTTER_UNITS_FROM_INT (mev->x);
|
||||
y = CLUTTER_UNITS_FROM_INT (mev->y);
|
||||
|
||||
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));
|
||||
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;
|
||||
@ -1264,8 +1258,8 @@ static gboolean
|
||||
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)
|
||||
{
|
||||
@ -1380,11 +1374,11 @@ clutter_text_paint (ClutterActor *self)
|
||||
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;
|
||||
|
||||
@ -1471,7 +1465,7 @@ clutter_text_get_preferred_width (ClutterActor *self,
|
||||
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)
|
||||
@ -1524,7 +1518,7 @@ clutter_text_get_preferred_height (ClutterActor *self,
|
||||
* 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)
|
||||
{
|
||||
@ -1534,13 +1528,13 @@ clutter_text_get_preferred_height (ClutterActor *self,
|
||||
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;
|
||||
}
|
||||
|
@ -111,8 +111,8 @@ clutter_stage_x11_fix_window_size (ClutterStageX11 *stage_x11)
|
||||
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)
|
||||
@ -186,10 +186,10 @@ clutter_stage_x11_get_preferred_width (ClutterActor *self,
|
||||
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;
|
||||
}
|
||||
@ -198,15 +198,14 @@ clutter_stage_x11_get_preferred_width (ClutterActor *self,
|
||||
|
||||
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
|
||||
@ -225,10 +224,10 @@ clutter_stage_x11_get_preferred_height (ClutterActor *self,
|
||||
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;
|
||||
}
|
||||
@ -238,15 +237,13 @@ clutter_stage_x11_get_preferred_height (ClutterActor *self,
|
||||
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
|
||||
@ -258,8 +255,8 @@ clutter_stage_x11_allocate (ClutterActor *self,
|
||||
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)
|
||||
{
|
||||
|
@ -102,20 +102,19 @@ notify_cb (GObject *object, GParamSpec *pspec, TestState *state)
|
||||
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)
|
||||
@ -134,15 +133,15 @@ check_coords (TestState *state,
|
||||
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
|
||||
@ -494,16 +493,14 @@ test_rotate_center (TestState *state)
|
||||
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);
|
||||
@ -511,7 +508,8 @@ test_rotate_center (TestState *state)
|
||||
{
|
||||
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);
|
||||
@ -557,8 +555,8 @@ test_rotate_center (TestState *state)
|
||||
{
|
||||
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
|
||||
@ -570,8 +568,8 @@ test_rotate_center (TestState *state)
|
||||
{
|
||||
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
|
||||
|
@ -154,20 +154,16 @@ key_group_paint (ClutterActor *actor)
|
||||
|
||||
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);
|
||||
|
@ -60,8 +60,9 @@ on_button_press (ClutterActor *actor,
|
||||
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,
|
||||
|
@ -161,20 +161,16 @@ key_group_paint (ClutterActor *actor)
|
||||
|
||||
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);
|
||||
|
@ -52,12 +52,12 @@ G_DEFINE_TYPE_WITH_CODE (MyThing,
|
||||
|
||||
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. */
|
||||
@ -139,11 +139,11 @@ my_thing_set_property (GObject *gobject,
|
||||
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:
|
||||
@ -174,11 +174,11 @@ my_thing_get_property (GObject *gobject,
|
||||
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:
|
||||
@ -214,14 +214,14 @@ my_thing_dispose (GObject *gobject)
|
||||
|
||||
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;
|
||||
|
||||
@ -233,7 +233,7 @@ my_thing_get_preferred_width (ClutterActor *self,
|
||||
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;
|
||||
|
||||
@ -292,14 +292,14 @@ my_thing_get_preferred_width (ClutterActor *self,
|
||||
|
||||
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;
|
||||
|
||||
@ -311,7 +311,7 @@ my_thing_get_preferred_height (ClutterActor *self,
|
||||
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;
|
||||
|
||||
@ -374,7 +374,7 @@ my_thing_allocate (ClutterActor *self,
|
||||
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 */
|
||||
@ -394,7 +394,7 @@ my_thing_allocate (ClutterActor *self,
|
||||
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;
|
||||
@ -517,21 +517,21 @@ my_thing_class_init (MyThingClass *klass)
|
||||
|
||||
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,
|
||||
|
@ -118,10 +118,10 @@ on_event (ClutterStage *stage,
|
||||
{
|
||||
if (dragging)
|
||||
{
|
||||
gfloat x, y;
|
||||
gint i;
|
||||
ClutterActorBox box1, box2;
|
||||
ClutterUnit xp, yp;
|
||||
gfloat x, y;
|
||||
gfloat xp, yp;
|
||||
gint i;
|
||||
|
||||
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 (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)
|
||||
{
|
||||
|
@ -9,18 +9,14 @@ on_entry_paint (ClutterActor *actor,
|
||||
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 ();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user