build
clutter
cogl
eglnative
eglx
fruity
glx
json
osx
sdl
win32
x11
Makefile.am
clutter-actor.c
clutter-actor.h
clutter-alpha.c
clutter-alpha.h
clutter-animatable.c
clutter-animatable.h
clutter-animation.c
clutter-animation.h
clutter-backend.c
clutter-backend.h
clutter-behaviour-depth.c
clutter-behaviour-depth.h
clutter-behaviour-ellipse.c
clutter-behaviour-ellipse.h
clutter-behaviour-opacity.c
clutter-behaviour-opacity.h
clutter-behaviour-path.c
clutter-behaviour-path.h
clutter-behaviour-rotate.c
clutter-behaviour-rotate.h
clutter-behaviour-scale.c
clutter-behaviour-scale.h
clutter-behaviour.c
clutter-behaviour.h
clutter-bezier.c
clutter-bezier.h
clutter-bin-layout.c
clutter-bin-layout.h
clutter-binding-pool.c
clutter-binding-pool.h
clutter-box-layout.c
clutter-box-layout.h
clutter-box.c
clutter-box.h
clutter-cairo-texture.c
clutter-cairo-texture.h
clutter-child-meta.c
clutter-child-meta.h
clutter-clone.c
clutter-clone.h
clutter-color.c
clutter-color.h
clutter-container.c
clutter-container.h
clutter-debug.h
clutter-deprecated.h
clutter-enum-types.c.in
clutter-enum-types.h.in
clutter-event.c
clutter-event.h
clutter-feature.c
clutter-feature.h
clutter-fixed-layout.c
clutter-fixed-layout.h
clutter-fixed.c
clutter-fixed.h
clutter-flow-layout.c
clutter-flow-layout.h
clutter-frame-source.c
clutter-frame-source.h
clutter-group.c
clutter-group.h
clutter-id-pool.c
clutter-id-pool.h
clutter-interval.c
clutter-interval.h
clutter-json.h.in
clutter-keysyms-table.h
clutter-keysyms.h
clutter-layout-manager.c
clutter-layout-manager.h
clutter-layout-meta.c
clutter-layout-meta.h
clutter-list-model.c
clutter-list-model.h
clutter-main.c
clutter-main.h
clutter-marshal.list
clutter-master-clock.c
clutter-master-clock.h
clutter-media.c
clutter-media.h
clutter-model-private.h
clutter-model.c
clutter-model.h
clutter-path.c
clutter-path.h
clutter-private.h
clutter-profile.c
clutter-profile.h
clutter-rectangle.c
clutter-rectangle.h
clutter-score.c
clutter-score.h
clutter-script-parser.c
clutter-script-private.h
clutter-script.c
clutter-script.h
clutter-scriptable.c
clutter-scriptable.h
clutter-shader-types.c
clutter-shader-types.h
clutter-shader.c
clutter-shader.h
clutter-stage-manager.c
clutter-stage-manager.h
clutter-stage-window.c
clutter-stage-window.h
clutter-stage.c
clutter-stage.h
clutter-text.c
clutter-text.h
clutter-texture.c
clutter-texture.h
clutter-timeline.c
clutter-timeline.h
clutter-timeout-interval.c
clutter-timeout-interval.h
clutter-timeout-pool.c
clutter-timeout-pool.h
clutter-types.h
clutter-units.c
clutter-units.h
clutter-util.c
clutter-util.h
clutter-version.h.in
clutter.h
doc
po
tests
.gitignore
AUTHORS
COPYING
ChangeLog.pre-git-import
Makefile.am
NEWS
README
TODO
autogen.sh
clutter.doap
clutter.pc.in
configure.ac

The behaviour of ClutterGroup has been fixed with regards to the preferred size request; the fixed layout manager should use the same behaviour.
187 lines
5.1 KiB
C
187 lines
5.1 KiB
C
/*
|
|
* Clutter.
|
|
*
|
|
* An OpenGL based 'interactive canvas' library.
|
|
*
|
|
* Copyright (C) 2009 Intel Corporation.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* Author:
|
|
* Emmanuele Bassi <ebassi@linux.intel.com>
|
|
*
|
|
* Based on the fixed layout code inside clutter-group.c
|
|
*/
|
|
|
|
/**
|
|
* SECTION:clutter-fixed-layout
|
|
* @short_description: A fixed layout manager
|
|
*
|
|
* #ClutterFixedLayout is a layout manager implementing the same
|
|
* layout policies as #ClutterGroup.
|
|
*
|
|
* #ClutterFixedLayout is available since Clutter 1.2
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include "clutter-debug.h"
|
|
#include "clutter-fixed-layout.h"
|
|
#include "clutter-private.h"
|
|
|
|
G_DEFINE_TYPE (ClutterFixedLayout,
|
|
clutter_fixed_layout,
|
|
CLUTTER_TYPE_LAYOUT_MANAGER);
|
|
|
|
static void
|
|
clutter_fixed_layout_get_preferred_width (ClutterLayoutManager *manager,
|
|
ClutterContainer *container,
|
|
gfloat for_height,
|
|
gfloat *min_width_p,
|
|
gfloat *nat_width_p)
|
|
{
|
|
GList *children, *l;
|
|
gdouble min_right;
|
|
gdouble natural_right;
|
|
|
|
min_right = 0;
|
|
natural_right = 0;
|
|
|
|
children = clutter_container_get_children (container);
|
|
|
|
for (l = children; l != NULL; l = l->next)
|
|
{
|
|
ClutterActor *child = l->data;
|
|
gfloat child_x, child_min, child_natural;
|
|
|
|
child_x = clutter_actor_get_x (child);
|
|
|
|
clutter_actor_get_preferred_size (child,
|
|
&child_min, NULL,
|
|
&child_natural, NULL);
|
|
|
|
if (child_x + child_min > min_right)
|
|
min_right = child_x + child_min;
|
|
|
|
if (child_x + child_natural > natural_right)
|
|
natural_right = child_x + child_natural;
|
|
}
|
|
|
|
g_list_free (children);
|
|
|
|
if (min_width_p)
|
|
*min_width_p = min_right;
|
|
|
|
if (nat_width_p)
|
|
*nat_width_p = natural_right;
|
|
}
|
|
|
|
static void
|
|
clutter_fixed_layout_get_preferred_height (ClutterLayoutManager *manager,
|
|
ClutterContainer *container,
|
|
gfloat for_width,
|
|
gfloat *min_height_p,
|
|
gfloat *nat_height_p)
|
|
{
|
|
GList *children, *l;
|
|
gdouble min_bottom;
|
|
gdouble natural_bottom;
|
|
|
|
min_bottom = 0;
|
|
natural_bottom = 0;
|
|
|
|
children = clutter_container_get_children (container);
|
|
|
|
for (l = children; l != NULL; l = l->next)
|
|
{
|
|
ClutterActor *child = l->data;
|
|
gfloat child_y, child_min, child_natural;
|
|
|
|
child_y = clutter_actor_get_y (child);
|
|
|
|
clutter_actor_get_preferred_size (child,
|
|
NULL, &child_min,
|
|
NULL, &child_natural);
|
|
|
|
if (child_y + child_min > min_bottom)
|
|
min_bottom = child_y + child_min;
|
|
|
|
if (child_y + child_natural > natural_bottom)
|
|
natural_bottom = child_y + child_natural;
|
|
}
|
|
|
|
g_list_free (children);
|
|
|
|
if (min_height_p)
|
|
*min_height_p = min_bottom;
|
|
|
|
if (nat_height_p)
|
|
*nat_height_p = natural_bottom;
|
|
}
|
|
|
|
static void
|
|
clutter_fixed_layout_allocate (ClutterLayoutManager *manager,
|
|
ClutterContainer *container,
|
|
const ClutterActorBox *allocation,
|
|
ClutterAllocationFlags flags)
|
|
{
|
|
GList *children, *l;
|
|
|
|
children = clutter_container_get_children (container);
|
|
|
|
for (l = children; l != NULL; l = l->next)
|
|
{
|
|
ClutterActor *child = l->data;
|
|
|
|
clutter_actor_allocate_preferred_size (child, flags);
|
|
}
|
|
|
|
g_list_free (children);
|
|
}
|
|
|
|
static void
|
|
clutter_fixed_layout_class_init (ClutterFixedLayoutClass *klass)
|
|
{
|
|
ClutterLayoutManagerClass *manager_class =
|
|
CLUTTER_LAYOUT_MANAGER_CLASS (klass);
|
|
|
|
manager_class->get_preferred_width =
|
|
clutter_fixed_layout_get_preferred_width;
|
|
manager_class->get_preferred_height =
|
|
clutter_fixed_layout_get_preferred_height;
|
|
manager_class->allocate = clutter_fixed_layout_allocate;
|
|
}
|
|
|
|
static void
|
|
clutter_fixed_layout_init (ClutterFixedLayout *self)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* clutter_fixed_layout_new:
|
|
*
|
|
* Creates a new #ClutterFixedLayout
|
|
*
|
|
* Return value: the newly created #ClutterFixedLayout
|
|
*
|
|
* Since: 1.2
|
|
*/
|
|
ClutterLayoutManager *
|
|
clutter_fixed_layout_new (void)
|
|
{
|
|
return g_object_new (CLUTTER_TYPE_FIXED_LAYOUT, NULL);
|
|
}
|