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