Port BigBox, BigRectangle, BigThemeImage to Clutter-1.0 API
- ClutterUnit is now replaced with float - allocate() now takes flags rather than absolute_origin_changed boolean - cogl_texture_new_from_data() signature changed http://bugzilla.gnome.org/show_bug.cgi?id=585007
This commit is contained in:
parent
ef3ac7a7f6
commit
9c859caf30
@ -1086,8 +1086,8 @@ big_box_get_content_width_request (ClutterActor *self,
|
||||
for (c = priv->children; c != NULL; c = c->next)
|
||||
{
|
||||
BigBoxChild *child = (BigBoxChild *) c->data;
|
||||
ClutterUnit min_width;
|
||||
ClutterUnit natural_width;
|
||||
float min_width;
|
||||
float natural_width;
|
||||
|
||||
if (!BOX_CHILD_IN_LAYOUT (child))
|
||||
continue;
|
||||
@ -1308,7 +1308,7 @@ big_box_get_content_area_vertical (ClutterActor *self,
|
||||
}
|
||||
static BigBoxAdjustInfo *
|
||||
big_box_adjust_infos_new (BigBox *box,
|
||||
ClutterUnit for_content_width)
|
||||
float for_content_width)
|
||||
{
|
||||
BigBoxPrivate *priv = box->priv;
|
||||
BigBoxAdjustInfo *adjusts = g_new0 (BigBoxAdjustInfo, g_list_length (priv->children));
|
||||
@ -1402,7 +1402,7 @@ big_box_adjust_up_to_natural_size (GList *children,
|
||||
((!child->if_fits && !if_fits) ||
|
||||
(child->if_fits && if_fits && !adjusts[i].does_not_fit)))
|
||||
{
|
||||
ClutterUnit needed_increase;
|
||||
float needed_increase;
|
||||
|
||||
g_assert (adjusts[i].adjustment >= 0);
|
||||
|
||||
@ -1446,7 +1446,7 @@ big_box_adjust_up_to_natural_size (GList *children,
|
||||
((!child->if_fits && !if_fits) ||
|
||||
(child->if_fits && if_fits && !adjusts[i].does_not_fit)))
|
||||
{
|
||||
ClutterUnit needed_increase;
|
||||
float needed_increase;
|
||||
|
||||
g_assert (adjusts[i].adjustment >= 0);
|
||||
|
||||
@ -1459,7 +1459,7 @@ big_box_adjust_up_to_natural_size (GList *children,
|
||||
|
||||
if (needed_increase > 0)
|
||||
{
|
||||
ClutterUnit extra;
|
||||
float extra;
|
||||
|
||||
extra = (space_to_distribute / n_needing_increase);
|
||||
|
||||
@ -1605,7 +1605,7 @@ big_box_adjust_for_expandable (GList *children,
|
||||
if (box_child_is_expandable (child, &(adjusts[i])) &&
|
||||
!adjusts[i].does_not_fit)
|
||||
{
|
||||
ClutterUnit extra;
|
||||
float extra;
|
||||
|
||||
extra = (expand_space / expand_count);
|
||||
|
||||
@ -1719,7 +1719,7 @@ big_box_get_hbox_height_request (ClutterActor *self,
|
||||
for (c = priv->children; c != NULL; c = c->next)
|
||||
{
|
||||
BigBoxChild *child = c->data;
|
||||
ClutterUnit min_height, natural_height;
|
||||
float min_height, natural_height;
|
||||
int req = 0;
|
||||
|
||||
if (!BOX_CHILD_IN_LAYOUT (child))
|
||||
@ -1734,10 +1734,8 @@ big_box_get_hbox_height_request (ClutterActor *self,
|
||||
&min_height, &natural_height);
|
||||
|
||||
if (priv->debug)
|
||||
g_debug ("H - Child %p min height %d natural %d",
|
||||
child->actor,
|
||||
CLUTTER_UNITS_TO_DEVICE (min_height),
|
||||
CLUTTER_UNITS_TO_DEVICE (natural_height));
|
||||
g_debug ("H - Child %p min height %g natural %g",
|
||||
child->actor, min_height, natural_height);
|
||||
|
||||
total_min = MAX (total_min, min_height);
|
||||
total_natural = MAX (total_natural, natural_height);
|
||||
@ -1786,10 +1784,8 @@ big_box_get_vbox_height_request (ClutterActor *self,
|
||||
&min_height, &natural_height);
|
||||
|
||||
if (priv->debug)
|
||||
g_debug ("V - Child %p min height %d natural %d",
|
||||
child->actor,
|
||||
CLUTTER_UNITS_TO_DEVICE (min_height),
|
||||
CLUTTER_UNITS_TO_DEVICE (natural_height));
|
||||
g_debug ("V - Child %p min height %g natural %g",
|
||||
child->actor, min_height, natural_height);
|
||||
|
||||
n_children_in_natural += 1;
|
||||
total_natural += natural_height;
|
||||
@ -1868,30 +1864,30 @@ big_box_get_preferred_height (ClutterActor *self,
|
||||
if (priv->debug)
|
||||
{
|
||||
if (min_height_p)
|
||||
g_debug ("Computed minimum height for width=%d as %d",
|
||||
CLUTTER_UNITS_TO_DEVICE (for_width), CLUTTER_UNITS_TO_DEVICE (*min_height_p));
|
||||
g_debug ("Computed minimum height for width=%g as %g",
|
||||
for_width, *min_height_p);
|
||||
if (natural_height_p)
|
||||
g_debug ("Computed natural height for width=%d as %d",
|
||||
CLUTTER_UNITS_TO_DEVICE (for_width), CLUTTER_UNITS_TO_DEVICE (*natural_height_p));
|
||||
g_debug ("Computed natural height for width=%g as %g",
|
||||
for_width, *natural_height_p);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
big_box_layout (ClutterActor *self,
|
||||
ClutterUnit content_x,
|
||||
ClutterUnit content_y,
|
||||
ClutterUnit allocated_content_width,
|
||||
ClutterUnit allocated_content_height,
|
||||
ClutterUnit requested_content_width,
|
||||
ClutterUnit requested_content_height,
|
||||
gboolean absolute_origin_changed)
|
||||
float content_x,
|
||||
float content_y,
|
||||
float allocated_content_width,
|
||||
float allocated_content_height,
|
||||
float requested_content_width,
|
||||
float requested_content_height,
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
BigBoxPrivate *priv;
|
||||
BigBoxAdjustInfo *adjusts;
|
||||
ClutterActorBox child_box;
|
||||
ClutterUnit allocated_size, requested_size;
|
||||
ClutterUnit start;
|
||||
ClutterUnit end;
|
||||
float allocated_size, requested_size;
|
||||
float start;
|
||||
float end;
|
||||
GList *c;
|
||||
gint i;
|
||||
|
||||
@ -1924,7 +1920,7 @@ big_box_layout (ClutterActor *self,
|
||||
for (c = priv->children; c != NULL; c = c->next)
|
||||
{
|
||||
BigBoxChild *child = (BigBoxChild *) c->data;
|
||||
ClutterUnit req;
|
||||
float req;
|
||||
|
||||
if (!BOX_CHILD_IN_LAYOUT (child))
|
||||
{
|
||||
@ -1953,7 +1949,7 @@ big_box_layout (ClutterActor *self,
|
||||
child_box.y2 - child_box.y1);
|
||||
|
||||
clutter_actor_allocate (child->actor, &child_box,
|
||||
absolute_origin_changed);
|
||||
flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1976,7 +1972,7 @@ big_box_layout (ClutterActor *self,
|
||||
child_box.y2 - child_box.y1);
|
||||
|
||||
clutter_actor_allocate (child->actor, &child_box,
|
||||
absolute_origin_changed);
|
||||
flags);
|
||||
}
|
||||
|
||||
if (req <= 0)
|
||||
@ -1990,7 +1986,7 @@ big_box_layout (ClutterActor *self,
|
||||
child_box.y2 = 0;
|
||||
|
||||
clutter_actor_allocate (child->actor, &child_box,
|
||||
absolute_origin_changed);
|
||||
flags);
|
||||
}
|
||||
|
||||
/* Children with req == 0 still get spacing unless they are IF_FITS.
|
||||
@ -2015,7 +2011,7 @@ big_box_layout (ClutterActor *self,
|
||||
static void
|
||||
big_box_allocate (ClutterActor *self,
|
||||
const ClutterActorBox *box,
|
||||
gboolean absolute_origin_changed)
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
BigBoxPrivate *priv;
|
||||
int requested_content_width;
|
||||
@ -2037,7 +2033,7 @@ big_box_allocate (ClutterActor *self,
|
||||
box->x2,
|
||||
box->y2);
|
||||
|
||||
CLUTTER_ACTOR_CLASS (big_box_parent_class)->allocate (self, box, absolute_origin_changed);
|
||||
CLUTTER_ACTOR_CLASS (big_box_parent_class)->allocate (self, box, flags);
|
||||
|
||||
big_box_get_content_width_request (self,
|
||||
&requested_content_width,
|
||||
@ -2088,7 +2084,7 @@ big_box_allocate (ClutterActor *self,
|
||||
}
|
||||
|
||||
clutter_actor_allocate (priv->background_texture, &bg_box,
|
||||
absolute_origin_changed);
|
||||
flags);
|
||||
}
|
||||
|
||||
if (priv->background_rectangle)
|
||||
@ -2102,7 +2098,7 @@ big_box_allocate (ClutterActor *self,
|
||||
|
||||
clutter_actor_allocate (priv->background_rectangle,
|
||||
&rectangle_box,
|
||||
absolute_origin_changed);
|
||||
flags);
|
||||
}
|
||||
|
||||
for (c = priv->children; c != NULL; c = c->next)
|
||||
@ -2123,7 +2119,7 @@ big_box_allocate (ClutterActor *self,
|
||||
{
|
||||
float x, y, width, height;
|
||||
|
||||
clutter_actor_get_positionu (child->actor, &x, &y);
|
||||
clutter_actor_get_position (child->actor, &x, &y);
|
||||
clutter_actor_get_preferred_width(child->actor, -1, NULL, &width);
|
||||
clutter_actor_get_preferred_height(child->actor, width, NULL, &height);
|
||||
|
||||
@ -2185,14 +2181,14 @@ big_box_allocate (ClutterActor *self,
|
||||
child_box.y2);
|
||||
|
||||
clutter_actor_allocate(child->actor, &child_box,
|
||||
absolute_origin_changed);
|
||||
flags);
|
||||
}
|
||||
}
|
||||
|
||||
big_box_layout (self, content_x, content_y,
|
||||
allocated_content_width, allocated_content_height,
|
||||
requested_content_width, requested_content_height,
|
||||
absolute_origin_changed);
|
||||
flags);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -43,7 +43,7 @@ typedef struct {
|
||||
|
||||
struct BigRectangle {
|
||||
ClutterRectangle parent_instance;
|
||||
ClutterUnit radius;
|
||||
float radius;
|
||||
Corner *corner;
|
||||
CoglHandle corner_material;
|
||||
CoglHandle border_material;
|
||||
@ -210,8 +210,7 @@ create_corner_texture(Corner *src)
|
||||
g_free(data);
|
||||
|
||||
texture = cogl_texture_new_from_data(size, size,
|
||||
0,
|
||||
FALSE,
|
||||
COGL_TEXTURE_NONE,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888,
|
||||
COGL_PIXEL_FORMAT_ANY,
|
||||
rowstride,
|
||||
@ -287,7 +286,7 @@ big_rectangle_update_corners(BigRectangle *rectangle)
|
||||
"color", &color,
|
||||
NULL);
|
||||
|
||||
corner = corner_get(CLUTTER_UNITS_TO_DEVICE(rectangle->radius),
|
||||
corner = corner_get(rectangle->radius,
|
||||
color,
|
||||
border_width,
|
||||
border_color);
|
||||
@ -485,7 +484,7 @@ big_rectangle_set_property(GObject *object,
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_CORNER_RADIUS:
|
||||
rectangle->radius = CLUTTER_UNITS_FROM_DEVICE(g_value_get_uint(value));
|
||||
rectangle->radius = g_value_get_uint(value);
|
||||
rectangle->corners_dirty = TRUE;
|
||||
break;
|
||||
|
||||
@ -508,7 +507,7 @@ big_rectangle_get_property(GObject *object,
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_CORNER_RADIUS:
|
||||
g_value_set_uint(value, CLUTTER_UNITS_TO_DEVICE(rectangle->radius));
|
||||
g_value_set_uint(value, rectangle->radius);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -279,7 +279,7 @@ big_theme_image_paint(ClutterActor *actor)
|
||||
static void
|
||||
big_theme_image_allocate(ClutterActor *actor,
|
||||
const ClutterActorBox *box,
|
||||
gboolean absolute_origin_changed)
|
||||
ClutterAllocationFlags flags)
|
||||
{
|
||||
BigThemeImage *image;
|
||||
guint old_width;
|
||||
@ -289,8 +289,8 @@ big_theme_image_allocate(ClutterActor *actor,
|
||||
|
||||
image = BIG_THEME_IMAGE(actor);
|
||||
|
||||
width = ABS(CLUTTER_UNITS_TO_DEVICE(box->x2 - box->x1));
|
||||
height = ABS(CLUTTER_UNITS_TO_DEVICE(box->y2 - box->y1));
|
||||
width = ABS(box->x2 - box->x1);
|
||||
height = ABS(box->y2 - box->y1);
|
||||
|
||||
g_object_get(actor,
|
||||
"surface-width", &old_width,
|
||||
@ -307,14 +307,14 @@ big_theme_image_allocate(ClutterActor *actor,
|
||||
if (CLUTTER_ACTOR_CLASS(big_theme_image_parent_class))
|
||||
CLUTTER_ACTOR_CLASS(big_theme_image_parent_class)->allocate(actor,
|
||||
box,
|
||||
absolute_origin_changed);
|
||||
flags);
|
||||
}
|
||||
|
||||
static void
|
||||
big_theme_image_get_preferred_height(ClutterActor *actor,
|
||||
ClutterUnit for_width,
|
||||
ClutterUnit *min_height_p,
|
||||
ClutterUnit *natural_height_p)
|
||||
float for_width,
|
||||
float *min_height_p,
|
||||
float *natural_height_p)
|
||||
{
|
||||
BigThemeImage *image;
|
||||
|
||||
@ -333,8 +333,7 @@ big_theme_image_get_preferred_height(ClutterActor *actor,
|
||||
if (!image->u.surface)
|
||||
break;
|
||||
|
||||
*natural_height_p = CLUTTER_UNITS_FROM_DEVICE(
|
||||
cairo_image_surface_get_height(image->u.surface));
|
||||
*natural_height_p = cairo_image_surface_get_height(image->u.surface);
|
||||
break;
|
||||
case BIG_THEME_IMAGE_SVG:
|
||||
{
|
||||
@ -344,8 +343,7 @@ big_theme_image_get_preferred_height(ClutterActor *actor,
|
||||
return;
|
||||
|
||||
rsvg_handle_get_dimensions(image->u.svg_handle, &dimensions);
|
||||
*natural_height_p =
|
||||
CLUTTER_UNITS_FROM_DEVICE(dimensions.height);
|
||||
*natural_height_p = dimensions.height;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -355,9 +353,9 @@ big_theme_image_get_preferred_height(ClutterActor *actor,
|
||||
|
||||
static void
|
||||
big_theme_image_get_preferred_width(ClutterActor *actor,
|
||||
ClutterUnit for_height,
|
||||
ClutterUnit *min_width_p,
|
||||
ClutterUnit *natural_width_p)
|
||||
float for_height,
|
||||
float *min_width_p,
|
||||
float *natural_width_p)
|
||||
{
|
||||
BigThemeImage *image;
|
||||
|
||||
@ -376,7 +374,7 @@ big_theme_image_get_preferred_width(ClutterActor *actor,
|
||||
if (!image->u.surface)
|
||||
break;
|
||||
|
||||
*natural_width_p = CLUTTER_UNITS_FROM_DEVICE(cairo_image_surface_get_width(image->u.surface));
|
||||
*natural_width_p = cairo_image_surface_get_width(image->u.surface);
|
||||
break;
|
||||
case BIG_THEME_IMAGE_SVG:
|
||||
{
|
||||
@ -386,7 +384,7 @@ big_theme_image_get_preferred_width(ClutterActor *actor,
|
||||
return;
|
||||
|
||||
rsvg_handle_get_dimensions(image->u.svg_handle, &dimensions);
|
||||
*natural_width_p = CLUTTER_UNITS_FROM_DEVICE(dimensions.width);
|
||||
*natural_width_p = dimensions.width;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user