Merge branch 'master' into my-overlay-design

This commit is contained in:
Marina Zhurakhinskaya 2009-06-08 18:02:31 -04:00
commit a9fedcce76
15 changed files with 210 additions and 201 deletions

View File

@ -289,6 +289,10 @@ Chrome.prototype = {
let [x, y] = actorData.actor.get_transformed_position();
let [w, h] = actorData.actor.get_transformed_size();
x = Math.round(x);
y = Math.round(y);
w = Math.round(w);
h = Math.round(h);
let rect = new Meta.Rectangle({ x: x, y: y, width: w, height: h});
if (actorData.inputRegion && actorData.actor.get_paint_visibility())

View File

@ -122,7 +122,9 @@ _Draggable.prototype = {
// Because we want to find out what other actor is located at the current position of this._dragActor,
// we have to temporarily hide this._dragActor.
this._dragActor.hide();
let target = actor.get_stage().get_actor_at_pos(stageX + this._dragOffsetX, stageY + this._dragOffsetY);
let target = actor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL,
stageX + this._dragOffsetX,
stageY + this._dragOffsetY);
this._dragActor.show();
while (target) {
if (target._delegate && target._delegate.handleDragOver) {
@ -156,7 +158,8 @@ _Draggable.prototype = {
// Find a drop target
actor.hide();
let [dropX, dropY] = event.get_coords();
let target = actor.get_stage().get_actor_at_pos(dropX, dropY);
let target = actor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL,
dropX, dropY);
actor.show();
while (target) {
if (target._delegate && target._delegate.acceptDrop) {

View File

@ -648,7 +648,8 @@ GenericDisplay.prototype = {
// Check if the pointer is over one of the items and display the preview pop-up if it is.
let [child, x, y, mask] = Gdk.Screen.get_default().get_root_window().get_pointer();
let global = Shell.Global.get();
let actor = global.stage.get_actor_at_pos(x, y);
let actor = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE,
x, y);
if (actor != null) {
let item = this._findDisplayedByActor(actor.get_parent());
if (item != null) {

View File

@ -204,10 +204,9 @@ ClutterFrameTicker.prototype = {
_init : function() {
// We don't have a finite duration; tweener will tell us to stop
// when we need to stop, so use 1000 seconds as "infinity"
this._timeline = new Clutter.Timeline({ fps: this.FRAME_RATE,
duration: 1000*1000 });
this._currentTime = 0;
this._frame = 0;
this._timeline = new Clutter.Timeline({ duration: 1000*1000 });
this._startTime = -1;
this._currentTime = -1;
let me = this;
this._timeline.connect('new-frame',
@ -220,20 +219,13 @@ ClutterFrameTicker.prototype = {
// If there is a lot of setup to start the animation, then
// first frame number we get from clutter might be a long ways
// into the animation (or the animation might even be done).
// That looks bad, so we always start one frame into the
// That looks bad, so we always start at the first frame of the
// animation then only do frame dropping from there.
let delta;
if (this._frame == 0)
delta = 1;
else
delta = frame - this._frame;
if (delta == 0) // protect against divide-by-0 if we get a frame twice
delta = 1;
if (this._startTime < 0)
this._startTime = this._timeline.get_elapsed_time();
// currentTime is in milliseconds
this._currentTime += (1000 * delta) / this.FRAME_RATE;
this._frame = frame;
this._currentTime = this._timeline.get_elapsed_time() - this._startTime;
this.emit('prepare-frame');
},
@ -247,8 +239,8 @@ ClutterFrameTicker.prototype = {
stop : function() {
this._timeline.stop();
this._frame = 0;
this._currentTime = 0;
this._startTime = -1;
this._currentTime = -1;
}
};

View File

@ -290,6 +290,23 @@ big_box_real_foreach (ClutterContainer *container,
}
}
static void
big_box_real_foreach_with_internals (ClutterContainer *container,
ClutterCallback callback,
gpointer user_data)
{
BigBox *group = BIG_BOX (container);
BigBoxPrivate *priv = group->priv;
big_box_real_foreach (container, callback, user_data);
if (priv->background_texture)
(* callback) (priv->background_texture, user_data);
if (priv->background_rectangle)
(* callback) (priv->background_rectangle, user_data);
}
static void
big_box_real_raise (ClutterContainer *container,
ClutterActor *child,
@ -439,6 +456,7 @@ clutter_container_iface_init (ClutterContainerIface *iface)
iface->add = big_box_real_add;
iface->remove = big_box_real_remove;
iface->foreach = big_box_real_foreach;
iface->foreach_with_internals = big_box_real_foreach_with_internals;
iface->raise = big_box_real_raise;
iface->lower = big_box_real_lower;
iface->sort_depth_order = big_box_real_sort_depth_order;
@ -1086,8 +1104,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 +1326,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 +1420,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 +1464,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 +1477,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 +1623,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 +1737,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 +1752,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 +1802,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 +1882,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)
big_box_layout (ClutterActor *self,
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 +1938,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 +1967,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 +1990,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 +2004,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 +2029,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 +2051,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 +2102,7 @@ big_box_allocate (ClutterActor *self,
}
clutter_actor_allocate (priv->background_texture, &bg_box,
absolute_origin_changed);
flags);
}
if (priv->background_rectangle)
@ -2102,7 +2116,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 +2137,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 +2199,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

View File

@ -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:

View File

@ -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:

View File

@ -693,6 +693,8 @@ static void
save_to_file (ShellAppMonitor *monitor)
{
GHashTableIter iter;
gpointer key;
gpointer value;
int activity;
GSList *popularity;
AppPopularity *app_popularity;
@ -721,9 +723,11 @@ save_to_file (ShellAppMonitor *monitor)
g_object_unref (output);
g_hash_table_iter_init (&iter, monitor->popularities);
while (g_hash_table_iter_next (&iter, (gpointer *) &activity, (gpointer *) &popularity)
&& popularity)
while (g_hash_table_iter_next (&iter, &key, &value) && value)
{
activity = GPOINTER_TO_INT (key);
popularity = value;
line = g_strdup_printf ("%i\n", activity);
g_data_output_stream_put_string (data_output, "--\n", NULL, NULL);
g_data_output_stream_put_string (data_output, line, NULL, NULL);

View File

@ -44,7 +44,7 @@ struct _ShellGlobal {
const char *configdir;
/* Displays the root window; see shell_global_create_root_pixmap_actor() */
ClutterGLXTexturePixmap *root_pixmap;
ClutterActor *root_pixmap;
};
enum {
@ -1002,23 +1002,27 @@ ClutterActor *
shell_global_create_root_pixmap_actor (ShellGlobal *global)
{
GdkWindow *window;
gboolean created_new_pixmap = FALSE;
ClutterActor *clone;
ClutterActor *stage;
/* The actor created is actually a ClutterClone of global->root_pixmap. */
if (global->root_pixmap == NULL)
{
global->root_pixmap = CLUTTER_GLX_TEXTURE_PIXMAP (clutter_glx_texture_pixmap_new ());
global->root_pixmap = clutter_glx_texture_pixmap_new ();
/* The low and medium quality filters give nearest-neighbor resizing. */
clutter_texture_set_filter_quality (CLUTTER_TEXTURE (global->root_pixmap),
CLUTTER_TEXTURE_QUALITY_HIGH);
/* The pixmap actor is only referenced by its clones. */
g_object_ref_sink (global->root_pixmap);
/* We can only clone an actor within a stage, so we hide the source
* texture then add it to the stage */
clutter_actor_hide (global->root_pixmap);
stage = mutter_plugin_get_stage (global->plugin);
clutter_container_add_actor (CLUTTER_CONTAINER (stage),
global->root_pixmap);
g_signal_connect (G_OBJECT (global->root_pixmap), "destroy",
/* This really should never happen; but just in case... */
g_signal_connect (global->root_pixmap, "destroy",
G_CALLBACK (root_pixmap_destroy), global);
/* Metacity handles changes to some root window properties in its global
@ -1034,16 +1038,9 @@ shell_global_create_root_pixmap_actor (ShellGlobal *global)
gdk_window_add_filter (window, root_window_filter, global);
update_root_window_pixmap (global);
created_new_pixmap = TRUE;
}
clone = clutter_clone_new (CLUTTER_ACTOR (global->root_pixmap));
if (created_new_pixmap)
g_object_unref(global->root_pixmap);
return clone;
return clutter_clone_new (global->root_pixmap);
}
void

View File

@ -147,9 +147,9 @@ shell_gtk_embed_get_property (GObject *object,
static void
shell_gtk_embed_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)
{
ShellGtkEmbed *embed = SHELL_GTK_EMBED (actor);
@ -166,9 +166,9 @@ shell_gtk_embed_get_preferred_width (ClutterActor *actor,
static void
shell_gtk_embed_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)
{
ShellGtkEmbed *embed = SHELL_GTK_EMBED (actor);
@ -186,13 +186,13 @@ shell_gtk_embed_get_preferred_height (ClutterActor *actor,
static void
shell_gtk_embed_allocate (ClutterActor *actor,
const ClutterActorBox *box,
gboolean absolute_origin_changed)
ClutterAllocationFlags flags)
{
ShellGtkEmbed *embed = SHELL_GTK_EMBED (actor);
int wx = 0, wy = 0, x, y, ax, ay;
float wx = 0.0, wy = 0.0, x, y, ax, ay;
CLUTTER_ACTOR_CLASS (shell_gtk_embed_parent_class)->
allocate (actor, box, absolute_origin_changed);
allocate (actor, box, flags);
/* Find the actor's new coordinates in terms of the stage (which is
* priv->window's parent window.
@ -209,7 +209,7 @@ shell_gtk_embed_allocate (ClutterActor *actor,
}
_shell_embedded_window_allocate (embed->priv->window,
wx, wy,
(int)(0.5 + wx), (int)(0.5 + wy),
box->x2 - box->x1,
box->y2 - box->y1);
}

View File

@ -188,7 +188,7 @@ create_recording_icon (void)
cairo_destroy (cr);
texture = cogl_texture_new_from_data (32, 32, 63,
texture = cogl_texture_new_from_data (32, 32,
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_BGRA_8888,
COGL_PIXEL_FORMAT_ANY,
@ -576,11 +576,11 @@ static void
recorder_queue_redraw (ShellRecorder *recorder)
{
/* If we just queue a redraw on every mouse motion (for example), we
* starve ClutterTimeline, which operates at a very low priority. So
* starve Clutter, which operates at a very low priority. So
* we need to queue a "low priority redraw" after timeline updates
*/
if (recorder->state == RECORDER_STATE_RECORDING && recorder->redraw_idle == 0)
recorder->redraw_idle = g_idle_add_full (CLUTTER_PRIORITY_TIMELINE + 1,
recorder->redraw_idle = g_idle_add_full (CLUTTER_PRIORITY_REDRAW + 1,
recorder_idle_redraw, recorder, NULL);
}

View File

@ -598,12 +598,12 @@ static void
position_menu (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
{
ShellStatusMenu *status = SHELL_STATUS_MENU (user_data);
int src_x, src_y;
float src_x, src_y;
clutter_actor_get_transformed_position (CLUTTER_ACTOR (status), &src_x, &src_y);
*x = src_x;
*y = src_y;
*x = (gint)(0.5 + src_x);
*y = (gint)(0.5 + src_y);
}
void

View File

@ -434,8 +434,7 @@ pixbuf_to_cogl_handle (GdkPixbuf *pixbuf)
{
return cogl_texture_new_from_data (gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
63, /* taken from clutter-texture.c default */
COGL_TEXTURE_AUTO_MIPMAP,
COGL_TEXTURE_NONE,
gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888,
COGL_PIXEL_FORMAT_ANY,
gdk_pixbuf_get_rowstride (pixbuf),

View File

@ -76,19 +76,19 @@ static void tidy_grid_pick (ClutterActor *actor,
static void
tidy_grid_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);
static void
tidy_grid_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);
static void tidy_grid_allocate (ClutterActor *self,
const ClutterActorBox *box,
gboolean absolute_origin_changed);
static void tidy_grid_allocate (ClutterActor *self,
const ClutterActorBox *box,
ClutterAllocationFlags flags);
G_DEFINE_TYPE_WITH_CODE (TidyGrid, tidy_grid,
CLUTTER_TYPE_ACTOR,
@ -101,26 +101,25 @@ G_DEFINE_TYPE_WITH_CODE (TidyGrid, tidy_grid,
struct _TidyGridPrivate
{
ClutterUnit for_height, for_width;
ClutterUnit pref_width, pref_height;
ClutterUnit alloc_width, alloc_height;
gfloat for_height, for_width;
gfloat pref_width, pref_height;
gfloat alloc_width, alloc_height;
gboolean absolute_origin_changed;
GHashTable *hash_table;
GList *list;
gboolean homogenous_rows;
gboolean homogenous_columns;
gboolean end_align;
ClutterUnit column_gap, row_gap;
gfloat column_gap, row_gap;
gdouble valign, halign;
gboolean column_major;
gboolean first_of_batch;
ClutterUnit a_current_sum, a_wrap;
ClutterUnit max_extent_a;
ClutterUnit max_extent_b;
gfloat a_current_sum, a_wrap;
gfloat max_extent_a;
gfloat max_extent_b;
};
enum
@ -139,8 +138,8 @@ enum
struct _TidyGridActorData
{
gboolean xpos_set, ypos_set;
ClutterUnit xpos, ypos;
ClutterUnit pref_width, pref_height;
gfloat xpos, ypos;
gfloat pref_width, pref_height;
};
static void
@ -167,22 +166,22 @@ tidy_grid_class_init (TidyGridClass *klass)
g_object_class_install_property
(gobject_class,
PROP_ROW_GAP,
clutter_param_spec_unit ("row-gap",
"Row gap",
"gap between rows in the layout",
0, CLUTTER_MAXUNIT,
0,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
g_param_spec_float ("row-gap",
"Row gap",
"gap between rows in the layout",
0.0, G_MAXFLOAT,
0.0,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
g_object_class_install_property
(gobject_class,
PROP_COLUMN_GAP,
clutter_param_spec_unit ("column-gap",
"Column gap",
"gap between columns in the layout",
0, CLUTTER_MAXUNIT,
0,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
g_param_spec_float ("column-gap",
"Column gap",
"gap between columns in the layout",
0.0, G_MAXFLOAT,
0.0,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
g_object_class_install_property
@ -367,14 +366,14 @@ tidy_grid_get_column_major (TidyGrid *self)
void
tidy_grid_set_column_gap (TidyGrid *self,
ClutterUnit value)
gfloat value)
{
TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self);
priv->column_gap = value;
clutter_actor_queue_relayout (CLUTTER_ACTOR (self));
}
ClutterUnit
gfloat
tidy_grid_get_column_gap (TidyGrid *self)
{
TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self);
@ -385,14 +384,14 @@ tidy_grid_get_column_gap (TidyGrid *self)
void
tidy_grid_set_row_gap (TidyGrid *self,
ClutterUnit value)
gfloat value)
{
TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self);
priv->row_gap = value;
clutter_actor_queue_relayout (CLUTTER_ACTOR (self));
}
ClutterUnit
gfloat
tidy_grid_get_row_gap (TidyGrid *self)
{
TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self);
@ -463,10 +462,10 @@ tidy_grid_set_property (GObject *object,
tidy_grid_set_column_major (grid, g_value_get_boolean (value));
break;
case PROP_COLUMN_GAP:
tidy_grid_set_column_gap (grid, clutter_value_get_unit (value));
tidy_grid_set_column_gap (grid, g_value_get_float (value));
break;
case PROP_ROW_GAP:
tidy_grid_set_row_gap (grid, clutter_value_get_unit (value));
tidy_grid_set_row_gap (grid, g_value_get_float (value));
break;
case PROP_VALIGN:
tidy_grid_set_valign (grid, g_value_get_double (value));
@ -507,10 +506,10 @@ tidy_grid_get_property (GObject *object,
g_value_set_boolean (value, tidy_grid_get_column_major (grid));
break;
case PROP_COLUMN_GAP:
clutter_value_set_unit (value, tidy_grid_get_column_gap (grid));
g_value_set_float (value, tidy_grid_get_column_gap (grid));
break;
case PROP_ROW_GAP:
clutter_value_set_unit (value, tidy_grid_get_row_gap (grid));
g_value_set_float (value, tidy_grid_get_row_gap (grid));
break;
case PROP_VALIGN:
g_value_set_double (value, tidy_grid_get_valign (grid));
@ -661,15 +660,15 @@ tidy_grid_pick (ClutterActor *actor,
static void
tidy_grid_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)
{
TidyGrid *layout = (TidyGrid *) self;
TidyGridPrivate *priv = layout->priv;
ClutterUnit natural_width;
gfloat natural_width;
natural_width = CLUTTER_UNITS_FROM_INT (200);
natural_width = 200.0;
if (min_width_p)
*min_width_p = natural_width;
if (natural_width_p)
@ -680,15 +679,15 @@ tidy_grid_get_preferred_width (ClutterActor *self,
static void
tidy_grid_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)
{
TidyGrid *layout = (TidyGrid *) self;
TidyGridPrivate *priv = layout->priv;
ClutterUnit natural_height;
gfloat natural_height;
natural_height = CLUTTER_UNITS_FROM_INT (200);
natural_height = 200.0;
priv->for_width = for_width;
priv->pref_height = natural_height;
@ -699,17 +698,17 @@ tidy_grid_get_preferred_height (ClutterActor *self,
*natural_height_p = natural_height;
}
static ClutterUnit
static gfloat
compute_row_height (GList *siblings,
ClutterUnit best_yet,
ClutterUnit current_a,
gfloat best_yet,
gfloat current_a,
TidyGridPrivate *priv)
{
GList *l;
gboolean homogenous_a;
gboolean homogenous_b;
ClutterUnit gap;
gfloat gap;
if (priv->column_major)
{
@ -727,7 +726,7 @@ compute_row_height (GList *siblings,
for (l = siblings; l != NULL; l = l->next)
{
ClutterActor *child = l->data;
ClutterUnit natural_width, natural_height;
gfloat natural_width, natural_height;
/* each child will get as much space as they require */
clutter_actor_get_preferred_size (CLUTTER_ACTOR (child),
@ -736,7 +735,7 @@ compute_row_height (GList *siblings,
if (priv->column_major)
{
ClutterUnit temp = natural_height;
gfloat temp = natural_height;
natural_height = natural_width;
natural_width = temp;
}
@ -762,17 +761,17 @@ compute_row_height (GList *siblings,
static ClutterUnit
static gfloat
compute_row_start (GList *siblings,
ClutterUnit start_x,
gfloat start_x,
TidyGridPrivate *priv)
{
ClutterUnit current_a = start_x;
gfloat current_a = start_x;
GList *l;
gboolean homogenous_a;
gboolean homogenous_b;
ClutterUnit gap;
gfloat gap;
if (priv->column_major)
{
@ -790,7 +789,7 @@ compute_row_start (GList *siblings,
for (l = siblings; l != NULL; l = l->next)
{
ClutterActor *child = l->data;
ClutterUnit natural_width, natural_height;
gfloat natural_width, natural_height;
/* each child will get as much space as they require */
clutter_actor_get_preferred_size (CLUTTER_ACTOR (child),
@ -819,17 +818,17 @@ compute_row_start (GList *siblings,
static void
tidy_grid_allocate (ClutterActor *self,
const ClutterActorBox *box,
gboolean absolute_origin_changed)
const ClutterActorBox *box,
ClutterAllocationFlags flags)
{
TidyGrid *layout = (TidyGrid *) self;
TidyGridPrivate *priv = layout->priv;
ClutterUnit current_a;
ClutterUnit current_b;
ClutterUnit next_b;
ClutterUnit agap;
ClutterUnit bgap;
gfloat current_a;
gfloat current_b;
gfloat next_b;
gfloat agap;
gfloat bgap;
gboolean homogenous_a;
gboolean homogenous_b;
@ -842,11 +841,10 @@ tidy_grid_allocate (ClutterActor *self,
/* chain up to set actor->allocation */
CLUTTER_ACTOR_CLASS (tidy_grid_parent_class)
->allocate (self, box, absolute_origin_changed);
->allocate (self, box, flags);
priv->alloc_width = box->x2 - box->x1;
priv->alloc_height = box->y2 - box->y1;
priv->absolute_origin_changed = absolute_origin_changed;
/* Make sure we have calculated the preferred size */
/* what does this do? */
@ -885,8 +883,8 @@ tidy_grid_allocate (ClutterActor *self,
for (iter = priv->list; iter; iter = iter->next)
{
ClutterActor *child = iter->data;
ClutterUnit natural_width;
ClutterUnit natural_height;
gfloat natural_width;
gfloat natural_height;
/* each child will get as much space as they require */
clutter_actor_get_preferred_size (CLUTTER_ACTOR (child),
@ -901,7 +899,7 @@ tidy_grid_allocate (ClutterActor *self,
if (priv->column_major)
{
ClutterUnit temp = priv->max_extent_a;
gfloat temp = priv->max_extent_a;
priv->max_extent_a = priv->max_extent_b;
priv->max_extent_b = temp;
}
@ -909,8 +907,8 @@ tidy_grid_allocate (ClutterActor *self,
for (iter = priv->list; iter; iter=iter->next)
{
ClutterActor *child = iter->data;
ClutterUnit natural_a;
ClutterUnit natural_b;
gfloat natural_a;
gfloat natural_b;
/* each child will get as much space as they require */
clutter_actor_get_preferred_size (CLUTTER_ACTOR (child),
@ -919,7 +917,7 @@ tidy_grid_allocate (ClutterActor *self,
if (priv->column_major) /* swap axes around if column is major */
{
ClutterUnit temp = natural_a;
gfloat temp = natural_a;
natural_a = natural_b;
natural_b = temp;
}
@ -945,7 +943,7 @@ tidy_grid_allocate (ClutterActor *self,
next_b = current_b + natural_b;
{
ClutterUnit row_height;
gfloat row_height;
ClutterActorBox child_box;
if (homogenous_b)
@ -976,7 +974,7 @@ tidy_grid_allocate (ClutterActor *self,
if (priv->column_major)
{
ClutterUnit temp = child_box.x1;
gfloat temp = child_box.x1;
child_box.x1 = child_box.y1;
child_box.y1 = temp;
@ -988,7 +986,7 @@ tidy_grid_allocate (ClutterActor *self,
/* update the allocation */
clutter_actor_allocate (CLUTTER_ACTOR (child),
&child_box,
absolute_origin_changed);
flags);
if (homogenous_a)
{

View File

@ -82,11 +82,11 @@ void tidy_grid_set_column_major (TidyGrid *self,
gboolean value);
gboolean tidy_grid_get_column_major (TidyGrid *self);
void tidy_grid_set_row_gap (TidyGrid *self,
ClutterUnit value);
ClutterUnit tidy_grid_get_row_gap (TidyGrid *self);
gfloat value);
gfloat tidy_grid_get_row_gap (TidyGrid *self);
void tidy_grid_set_column_gap (TidyGrid *self,
ClutterUnit value);
ClutterUnit tidy_grid_get_column_gap (TidyGrid *self);
gfloat value);
gfloat tidy_grid_get_column_gap (TidyGrid *self);
void tidy_grid_set_valign (TidyGrid *self,
gdouble value);
gdouble tidy_grid_get_valign (TidyGrid *self);