constraint: Add a private header

And move the only private ClutterConstraint method to it.

This commit also sneaks in a change that makes sense for the debugging
of the update_allocation() method, which checks if the allocation was
effectively changed.
This commit is contained in:
Emmanuele Bassi 2014-12-14 14:20:53 +00:00
parent 768b5b89e2
commit 82fffaedb6
7 changed files with 102 additions and 27 deletions

View File

@ -221,6 +221,7 @@ source_h_priv = \
clutter-actor-private.h \ clutter-actor-private.h \
clutter-backend-private.h \ clutter-backend-private.h \
clutter-bezier.h \ clutter-bezier.h \
clutter-constraint-private.h \
clutter-content-private.h \ clutter-content-private.h \
clutter-debug.h \ clutter-debug.h \
clutter-device-manager-private.h \ clutter-device-manager-private.h \

View File

@ -611,7 +611,7 @@
#include "clutter-animatable.h" #include "clutter-animatable.h"
#include "clutter-color-static.h" #include "clutter-color-static.h"
#include "clutter-color.h" #include "clutter-color.h"
#include "clutter-constraint.h" #include "clutter-constraint-private.h"
#include "clutter-container.h" #include "clutter-container.h"
#include "clutter-content-private.h" #include "clutter-content-private.h"
#include "clutter-debug.h" #include "clutter-debug.h"
@ -9650,19 +9650,21 @@ clutter_actor_update_constraints (ClutterActor *self,
if (clutter_actor_meta_get_enabled (meta)) if (clutter_actor_meta_get_enabled (meta))
{ {
_clutter_constraint_update_allocation (constraint, gboolean changed =
clutter_constraint_update_allocation (constraint,
self, self,
allocation); allocation);
CLUTTER_NOTE (LAYOUT, CLUTTER_NOTE (LAYOUT,
"Allocation of '%s' after constraint '%s': " "Allocation of '%s' after constraint '%s': "
"{ %.2f, %.2f, %.2f, %.2f }", "{ %.2f, %.2f, %.2f, %.2f } (changed:%s)",
_clutter_actor_get_debug_name (self), _clutter_actor_get_debug_name (self),
_clutter_actor_meta_get_debug_name (meta), _clutter_actor_meta_get_debug_name (meta),
allocation->x1, allocation->x1,
allocation->y1, allocation->y1,
allocation->x2, allocation->x2,
allocation->y2); allocation->y2,
changed ? "yes" : "no");
} }
} }
} }

View File

@ -0,0 +1,35 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 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/>.
*/
#ifndef __CLUTTER_CONSTRAINT_PRIVATE_H__
#define __CLUTTER_CONSTRAINT_PRIVATE_H__
#include "clutter-constraint.h"
G_BEGIN_DECLS
gboolean clutter_constraint_update_allocation (ClutterConstraint *constraint,
ClutterActor *actor,
ClutterActorBox *allocation);
G_END_DECLS
#endif /* __CLUTTER_CONSTRAINT_PRIVATE_H__ */

View File

@ -1,3 +1,27 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 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>
*/
/** /**
* SECTION:clutter-constraint * SECTION:clutter-constraint
* @Title: ClutterConstraint * @Title: ClutterConstraint
@ -110,7 +134,7 @@
#include <string.h> #include <string.h>
#include "clutter-constraint.h" #include "clutter-constraint-private.h"
#include "clutter-actor.h" #include "clutter-actor.h"
#include "clutter-actor-meta-private.h" #include "clutter-actor-meta-private.h"
@ -159,16 +183,32 @@ clutter_constraint_init (ClutterConstraint *self)
{ {
} }
void /*< private >
_clutter_constraint_update_allocation (ClutterConstraint *constraint, * clutter_constraint_update_allocation:
* @constraint: a #ClutterConstraint
* @actor: a #ClutterActor
* @allocation: (inout): the allocation to modify
*
* Asks the @constraint to update the @allocation of a #ClutterActor.
*
* Returns: %TRUE if the allocation was updated
*/
gboolean
clutter_constraint_update_allocation (ClutterConstraint *constraint,
ClutterActor *actor, ClutterActor *actor,
ClutterActorBox *allocation) ClutterActorBox *allocation)
{ {
g_return_if_fail (CLUTTER_IS_CONSTRAINT (constraint)); ClutterActorBox old_alloc;
g_return_if_fail (CLUTTER_IS_ACTOR (actor));
g_return_if_fail (allocation != NULL); g_return_val_if_fail (CLUTTER_IS_CONSTRAINT (constraint), FALSE);
g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), FALSE);
g_return_val_if_fail (allocation != NULL, FALSE);
old_alloc = *allocation;
CLUTTER_CONSTRAINT_GET_CLASS (constraint)->update_allocation (constraint, CLUTTER_CONSTRAINT_GET_CLASS (constraint)->update_allocation (constraint,
actor, actor,
allocation); allocation);
return clutter_actor_box_equal (allocation, &old_alloc);
} }

View File

@ -245,10 +245,6 @@ gboolean _clutter_boolean_continue_accumulator (GSignalInvocationHint *ihint,
void _clutter_run_repaint_functions (ClutterRepaintFlags flags); void _clutter_run_repaint_functions (ClutterRepaintFlags flags);
void _clutter_constraint_update_allocation (ClutterConstraint *constraint,
ClutterActor *actor,
ClutterActorBox *allocation);
GType _clutter_layout_manager_get_child_meta_type (ClutterLayoutManager *manager); GType _clutter_layout_manager_get_child_meta_type (ClutterLayoutManager *manager);
void _clutter_util_fully_transform_vertices (const CoglMatrix *modelview, void _clutter_util_fully_transform_vertices (const CoglMatrix *modelview,

View File

@ -72,6 +72,7 @@ IGNORE_HFILES = \
clutter-cogl-compat.h \ clutter-cogl-compat.h \
clutter-color-static.h \ clutter-color-static.h \
clutter-config.h \ clutter-config.h \
clutter-constraint-private.h \
clutter-debug.h \ clutter-debug.h \
clutter-deprecated.h \ clutter-deprecated.h \
clutter-device-manager-private.h \ clutter-device-manager-private.h \