mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
Merge branch 'generic-actor-clone'
* generic-actor-clone: Remove CloneTexture from the API [tests] Clean up the Clone interactive test Rename ActorClone to Clone/2 Rename ActorClone to Clone/1 Improves the unit test to verify more awkward scaling and some corresponding fixes Implements a generic ClutterActorClone that doesn't need fbos.
This commit is contained in:
commit
3cfc7fb1ca
@ -61,7 +61,7 @@ source_h = \
|
||||
$(srcdir)/clutter-binding-pool.h \
|
||||
$(srcdir)/clutter-cairo-texture.h \
|
||||
$(srcdir)/clutter-child-meta.h \
|
||||
$(srcdir)/clutter-clone-texture.h \
|
||||
$(srcdir)/clutter-clone.h \
|
||||
$(srcdir)/clutter-color.h \
|
||||
$(srcdir)/clutter-container.h \
|
||||
$(srcdir)/clutter-deprecated.h \
|
||||
@ -152,7 +152,7 @@ source_c = \
|
||||
clutter-binding-pool.c \
|
||||
clutter-cairo-texture.c \
|
||||
clutter-child-meta.c \
|
||||
clutter-clone-texture.c \
|
||||
clutter-clone.c \
|
||||
clutter-color.c \
|
||||
clutter-container.c \
|
||||
clutter-enum-types.c \
|
||||
|
@ -263,6 +263,9 @@ struct _ClutterActorPrivate
|
||||
ShaderData *shader_data;
|
||||
|
||||
PangoContext *pango_context;
|
||||
|
||||
ClutterActor *opacity_parent;
|
||||
gboolean enable_model_view_transform;
|
||||
};
|
||||
|
||||
enum
|
||||
@ -1497,7 +1500,8 @@ clutter_actor_paint (ClutterActor *self)
|
||||
|
||||
cogl_push_matrix();
|
||||
|
||||
_clutter_actor_apply_modelview_transform (self);
|
||||
if (priv->enable_model_view_transform)
|
||||
_clutter_actor_apply_modelview_transform (self);
|
||||
|
||||
if (priv->has_clip)
|
||||
{
|
||||
@ -3072,6 +3076,9 @@ clutter_actor_init (ClutterActor *self)
|
||||
priv->needs_height_request = TRUE;
|
||||
priv->needs_allocation = TRUE;
|
||||
|
||||
priv->opacity_parent = NULL;
|
||||
priv->enable_model_view_transform = TRUE;
|
||||
|
||||
memset (priv->clip, 0, sizeof (ClutterUnit) * 4);
|
||||
}
|
||||
|
||||
@ -5071,7 +5078,10 @@ clutter_actor_get_paint_opacity (ClutterActor *self)
|
||||
|
||||
priv = self->priv;
|
||||
|
||||
parent = priv->parent_actor;
|
||||
if (priv->opacity_parent)
|
||||
parent = priv->opacity_parent;
|
||||
else
|
||||
parent = priv->parent_actor;
|
||||
|
||||
/* Factor in the actual actors opacity with parents */
|
||||
if (G_LIKELY (parent))
|
||||
@ -7787,3 +7797,26 @@ clutter_actor_create_pango_context (ClutterActor *self)
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Allows overriding the parent traversed when querying an actors paint
|
||||
* opacity. Used by ClutterClone. */
|
||||
void
|
||||
_clutter_actor_set_opacity_parent (ClutterActor *self,
|
||||
ClutterActor *parent)
|
||||
{
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||
|
||||
self->priv->opacity_parent = parent;
|
||||
}
|
||||
|
||||
/* Allows you to disable applying the actors model view transform during
|
||||
* a paint. Used by ClutterClone. */
|
||||
void
|
||||
_clutter_actor_set_enable_model_view_transform (ClutterActor *self,
|
||||
gboolean enable)
|
||||
{
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||
|
||||
self->priv->enable_model_view_transform = enable;
|
||||
}
|
||||
|
||||
|
@ -1,460 +0,0 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2006 OpenedHand
|
||||
*
|
||||
* 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, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:clutter-clone-texture
|
||||
* @short_description: Actor for cloning existing textures in an
|
||||
* efficient way.
|
||||
*
|
||||
* #ClutterCloneTexture allows the cloning of existing #ClutterTexture based
|
||||
* actors whilst saving underlying graphics resources.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "clutter-clone-texture.h"
|
||||
#include "clutter-main.h"
|
||||
#include "clutter-feature.h"
|
||||
#include "clutter-actor.h"
|
||||
#include "clutter-util.h"
|
||||
#include "clutter-enum-types.h"
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-debug.h"
|
||||
|
||||
#include "cogl/cogl.h"
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_PARENT_TEXTURE,
|
||||
PROP_REPEAT_Y,
|
||||
PROP_REPEAT_X
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ClutterCloneTexture,
|
||||
clutter_clone_texture,
|
||||
CLUTTER_TYPE_ACTOR);
|
||||
|
||||
#define CLUTTER_CLONE_TEXTURE_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_CLONE_TEXTURE, ClutterCloneTexturePrivate))
|
||||
|
||||
|
||||
struct _ClutterCloneTexturePrivate
|
||||
{
|
||||
ClutterTexture *parent_texture;
|
||||
CoglHandle material;
|
||||
guint repeat_x : 1;
|
||||
guint repeat_y : 1;
|
||||
};
|
||||
|
||||
static void
|
||||
clutter_clone_texture_get_preferred_width (ClutterActor *self,
|
||||
ClutterUnit for_height,
|
||||
ClutterUnit *min_width_p,
|
||||
ClutterUnit *natural_width_p)
|
||||
{
|
||||
ClutterCloneTexturePrivate *priv = CLUTTER_CLONE_TEXTURE (self)->priv;
|
||||
ClutterActor *parent_texture;
|
||||
ClutterActorClass *parent_texture_class;
|
||||
|
||||
/* Note that by calling the get_width_request virtual method directly
|
||||
* and skipping the clutter_actor_get_preferred_width() wrapper, we
|
||||
* are ignoring any size request override set on the parent texture
|
||||
* and just getting the normal size of the parent texture.
|
||||
*/
|
||||
parent_texture = CLUTTER_ACTOR (priv->parent_texture);
|
||||
if (!parent_texture)
|
||||
{
|
||||
if (min_width_p)
|
||||
*min_width_p = 0;
|
||||
|
||||
if (natural_width_p)
|
||||
*natural_width_p = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent_texture_class = CLUTTER_ACTOR_GET_CLASS (parent_texture);
|
||||
parent_texture_class->get_preferred_width (parent_texture,
|
||||
for_height,
|
||||
min_width_p,
|
||||
natural_width_p);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_texture_get_preferred_height (ClutterActor *self,
|
||||
ClutterUnit for_width,
|
||||
ClutterUnit *min_height_p,
|
||||
ClutterUnit *natural_height_p)
|
||||
{
|
||||
ClutterCloneTexturePrivate *priv = CLUTTER_CLONE_TEXTURE (self)->priv;
|
||||
ClutterActor *parent_texture;
|
||||
ClutterActorClass *parent_texture_class;
|
||||
|
||||
/* Note that by calling the get_height_request virtual method directly
|
||||
* and skipping the clutter_actor_get_preferred_height() wrapper, we
|
||||
* are ignoring any size request override set on the parent texture and
|
||||
* just getting the normal size of the parent texture.
|
||||
*/
|
||||
parent_texture = CLUTTER_ACTOR (priv->parent_texture);
|
||||
if (!parent_texture)
|
||||
{
|
||||
if (min_height_p)
|
||||
*min_height_p = 0;
|
||||
|
||||
if (natural_height_p)
|
||||
*natural_height_p = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent_texture_class = CLUTTER_ACTOR_GET_CLASS (parent_texture);
|
||||
parent_texture_class->get_preferred_height (parent_texture,
|
||||
for_width,
|
||||
min_height_p,
|
||||
natural_height_p);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_texture_paint (ClutterActor *self)
|
||||
{
|
||||
ClutterCloneTexturePrivate *priv;
|
||||
ClutterActor *parent_texture;
|
||||
gint x_1, y_1, x_2, y_2;
|
||||
CoglHandle cogl_texture;
|
||||
ClutterFixed t_w, t_h;
|
||||
guint tex_width, tex_height;
|
||||
|
||||
priv = CLUTTER_CLONE_TEXTURE (self)->priv;
|
||||
|
||||
/* no need to paint stuff if we don't have a texture to clone */
|
||||
if (!priv->parent_texture)
|
||||
return;
|
||||
|
||||
CLUTTER_NOTE (PAINT,
|
||||
"painting clone texture '%s'",
|
||||
clutter_actor_get_name (self) ? clutter_actor_get_name (self)
|
||||
: "unknown");
|
||||
|
||||
/* parent texture may have been hidden, there for need to make sure its
|
||||
* realised with resources available.
|
||||
*/
|
||||
parent_texture = CLUTTER_ACTOR (priv->parent_texture);
|
||||
if (!CLUTTER_ACTOR_IS_REALIZED (parent_texture))
|
||||
clutter_actor_realize (parent_texture);
|
||||
|
||||
/* If 'parent' texture isn't visible we run its paint to be sure it
|
||||
* updates. Needed for TFP and likely FBOs.
|
||||
* Potentially could cause issues
|
||||
*/
|
||||
if (!clutter_actor_get_paint_visibility (parent_texture))
|
||||
{
|
||||
CLUTTER_SET_PRIVATE_FLAGS(parent_texture,
|
||||
CLUTTER_TEXTURE_IN_CLONE_PAINT);
|
||||
g_signal_emit_by_name (priv->parent_texture, "paint", NULL);
|
||||
CLUTTER_UNSET_PRIVATE_FLAGS(parent_texture,
|
||||
CLUTTER_TEXTURE_IN_CLONE_PAINT);
|
||||
}
|
||||
|
||||
cogl_material_set_color4ub (priv->material, 0xff, 0xff, 0xff,
|
||||
clutter_actor_get_paint_opacity (self));
|
||||
|
||||
clutter_actor_get_allocation_coords (self, &x_1, &y_1, &x_2, &y_2);
|
||||
|
||||
CLUTTER_NOTE (PAINT, "paint to x1: %i, y1: %i x2: %i, y2: %i "
|
||||
"opacity: %i",
|
||||
x_1, y_1, x_2, y_2,
|
||||
clutter_actor_get_opacity (self));
|
||||
|
||||
cogl_texture = clutter_texture_get_cogl_texture (priv->parent_texture);
|
||||
|
||||
if (cogl_texture == COGL_INVALID_HANDLE)
|
||||
return;
|
||||
|
||||
tex_width = cogl_texture_get_width (cogl_texture);
|
||||
tex_height = cogl_texture_get_height (cogl_texture);
|
||||
|
||||
if (priv->repeat_x && tex_width > 0)
|
||||
t_w = CLUTTER_FIXED_DIV ((float)(x_2 - x_1),
|
||||
(float)(tex_width));
|
||||
else
|
||||
t_w = 1.0;
|
||||
if (priv->repeat_y && tex_height > 0)
|
||||
t_h = CLUTTER_FIXED_DIV ((float)(y_2 - y_1),
|
||||
(float)(tex_height));
|
||||
else
|
||||
t_h = 1.0;
|
||||
|
||||
cogl_material_set_layer (priv->material, 0, cogl_texture);
|
||||
cogl_set_source (priv->material);
|
||||
/* Parent paint translated us into position */
|
||||
cogl_rectangle_with_texture_coords (0, 0,
|
||||
(float) (x_2 - x_1),
|
||||
(float) (y_2 - y_1),
|
||||
0, 0, t_w, t_h);
|
||||
}
|
||||
|
||||
static void
|
||||
set_parent_texture (ClutterCloneTexture *ctexture,
|
||||
ClutterTexture *texture)
|
||||
{
|
||||
ClutterCloneTexturePrivate *priv = ctexture->priv;
|
||||
ClutterActor *actor = CLUTTER_ACTOR (ctexture);
|
||||
gboolean was_visible = CLUTTER_ACTOR_IS_VISIBLE (ctexture);
|
||||
|
||||
if (priv->parent_texture == texture)
|
||||
return;
|
||||
|
||||
if (priv->parent_texture)
|
||||
{
|
||||
g_object_unref (priv->parent_texture);
|
||||
priv->parent_texture = NULL;
|
||||
|
||||
if (was_visible)
|
||||
clutter_actor_hide (actor);
|
||||
}
|
||||
|
||||
if (texture)
|
||||
{
|
||||
priv->parent_texture = g_object_ref (texture);
|
||||
|
||||
/* queue a redraw if the cloned texture is already visible */
|
||||
if (CLUTTER_ACTOR_IS_VISIBLE (priv->parent_texture) &&
|
||||
was_visible)
|
||||
{
|
||||
clutter_actor_show (actor);
|
||||
clutter_actor_queue_redraw (actor);
|
||||
}
|
||||
|
||||
clutter_actor_queue_relayout (actor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_texture_dispose (GObject *object)
|
||||
{
|
||||
ClutterCloneTexture *self = CLUTTER_CLONE_TEXTURE(object);
|
||||
ClutterCloneTexturePrivate *priv = self->priv;
|
||||
|
||||
if (priv->parent_texture)
|
||||
g_object_unref (priv->parent_texture);
|
||||
|
||||
priv->parent_texture = NULL;
|
||||
|
||||
G_OBJECT_CLASS (clutter_clone_texture_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_texture_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (clutter_clone_texture_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_texture_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterCloneTexture *ctexture = CLUTTER_CLONE_TEXTURE (object);
|
||||
ClutterCloneTexturePrivate *priv;
|
||||
|
||||
priv = ctexture->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_PARENT_TEXTURE:
|
||||
set_parent_texture (ctexture, g_value_get_object (value));
|
||||
break;
|
||||
case PROP_REPEAT_X:
|
||||
if (priv->repeat_x != g_value_get_boolean (value))
|
||||
{
|
||||
priv->repeat_x = !priv->repeat_x;
|
||||
clutter_actor_queue_redraw (CLUTTER_ACTOR (ctexture));
|
||||
}
|
||||
break;
|
||||
case PROP_REPEAT_Y:
|
||||
if (priv->repeat_y != g_value_get_boolean (value))
|
||||
{
|
||||
priv->repeat_y = !priv->repeat_y;
|
||||
clutter_actor_queue_redraw (CLUTTER_ACTOR (ctexture));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_texture_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterCloneTexture *ctexture = CLUTTER_CLONE_TEXTURE (object);
|
||||
ClutterCloneTexturePrivate *priv;
|
||||
|
||||
priv = ctexture->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_PARENT_TEXTURE:
|
||||
g_value_set_object (value, ctexture->priv->parent_texture);
|
||||
break;
|
||||
case PROP_REPEAT_X:
|
||||
g_value_set_boolean (value, priv->repeat_x);
|
||||
break;
|
||||
case PROP_REPEAT_Y:
|
||||
g_value_set_boolean (value, priv->repeat_y);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_texture_class_init (ClutterCloneTextureClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
|
||||
actor_class->paint =
|
||||
clutter_clone_texture_paint;
|
||||
actor_class->get_preferred_width =
|
||||
clutter_clone_texture_get_preferred_width;
|
||||
actor_class->get_preferred_height =
|
||||
clutter_clone_texture_get_preferred_height;
|
||||
|
||||
gobject_class->finalize = clutter_clone_texture_finalize;
|
||||
gobject_class->dispose = clutter_clone_texture_dispose;
|
||||
gobject_class->set_property = clutter_clone_texture_set_property;
|
||||
gobject_class->get_property = clutter_clone_texture_get_property;
|
||||
|
||||
g_object_class_install_property
|
||||
(gobject_class, PROP_PARENT_TEXTURE,
|
||||
g_param_spec_object ("parent-texture",
|
||||
"Parent Texture",
|
||||
"The parent texture to clone",
|
||||
CLUTTER_TYPE_TEXTURE,
|
||||
CLUTTER_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property
|
||||
(gobject_class, PROP_REPEAT_X,
|
||||
g_param_spec_boolean ("repeat-x",
|
||||
"Tile underlying pixbuf in x direction",
|
||||
"Reapeat underlying pixbuf rather than scale "
|
||||
"in x direction.",
|
||||
FALSE,
|
||||
CLUTTER_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property
|
||||
(gobject_class, PROP_REPEAT_Y,
|
||||
g_param_spec_boolean ("repeat-y",
|
||||
"Tile underlying pixbuf in y direction",
|
||||
"Reapeat underlying pixbuf rather than scale "
|
||||
"in y direction.",
|
||||
FALSE,
|
||||
CLUTTER_PARAM_READWRITE));
|
||||
|
||||
g_type_class_add_private (gobject_class, sizeof (ClutterCloneTexturePrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_texture_init (ClutterCloneTexture *self)
|
||||
{
|
||||
ClutterCloneTexturePrivate *priv;
|
||||
|
||||
self->priv = priv = CLUTTER_CLONE_TEXTURE_GET_PRIVATE (self);
|
||||
priv->parent_texture = NULL;
|
||||
priv->material = cogl_material_new ();
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_clone_texture_new:
|
||||
* @texture: a #ClutterTexture, or %NULL
|
||||
*
|
||||
* Creates an efficient 'clone' of a pre-existing texture with which it
|
||||
* shares the underlying pixbuf data.
|
||||
*
|
||||
* You can use clutter_clone_texture_set_parent_texture() to change the
|
||||
* cloned texture.
|
||||
*
|
||||
* Return value: the newly created #ClutterCloneTexture
|
||||
*/
|
||||
ClutterActor *
|
||||
clutter_clone_texture_new (ClutterTexture *texture)
|
||||
{
|
||||
g_return_val_if_fail (texture == NULL || CLUTTER_IS_TEXTURE (texture), NULL);
|
||||
|
||||
return g_object_new (CLUTTER_TYPE_CLONE_TEXTURE,
|
||||
"parent-texture", texture,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_clone_texture_get_parent_texture:
|
||||
* @clone: a #ClutterCloneTexture
|
||||
*
|
||||
* Retrieves the parent #ClutterTexture used by @clone.
|
||||
*
|
||||
* Return value: a #ClutterTexture actor, or %NULL
|
||||
*
|
||||
* Since: 0.2
|
||||
*/
|
||||
ClutterTexture *
|
||||
clutter_clone_texture_get_parent_texture (ClutterCloneTexture *clone)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_CLONE_TEXTURE (clone), NULL);
|
||||
|
||||
return clone->priv->parent_texture;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_clone_texture_set_parent_texture:
|
||||
* @clone: a #ClutterCloneTexture
|
||||
* @texture: a #ClutterTexture or %NULL
|
||||
*
|
||||
* Sets the parent texture cloned by the #ClutterCloneTexture.
|
||||
*
|
||||
* Since: 0.2
|
||||
*/
|
||||
void
|
||||
clutter_clone_texture_set_parent_texture (ClutterCloneTexture *clone,
|
||||
ClutterTexture *texture)
|
||||
{
|
||||
g_return_if_fail (CLUTTER_IS_CLONE_TEXTURE (clone));
|
||||
g_return_if_fail (texture == NULL || CLUTTER_IS_TEXTURE (texture));
|
||||
|
||||
g_object_ref (clone);
|
||||
|
||||
set_parent_texture (clone, texture);
|
||||
|
||||
g_object_notify (G_OBJECT (clone), "parent-texture");
|
||||
g_object_unref (clone);
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2006 OpenedHand
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
#error "Only <clutter/clutter.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __CLUTTER_CLONE_TEXTURE_H__
|
||||
#define __CLUTTER_CLONE_TEXTURE_H__
|
||||
|
||||
#include <clutter/clutter-actor.h>
|
||||
#include <clutter/clutter-texture.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_CLONE_TEXTURE (clutter_clone_texture_get_type ())
|
||||
#define CLUTTER_CLONE_TEXTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_CLONE_TEXTURE, ClutterCloneTexture))
|
||||
#define CLUTTER_CLONE_TEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_CLONE_TEXTURE, ClutterCloneTextureClass))
|
||||
#define CLUTTER_IS_CLONE_TEXTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_CLONE_TEXTURE))
|
||||
#define CLUTTER_IS_CLONE_TEXTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_CLONE_TEXTURE))
|
||||
#define CLUTTER_CLONE_TEXTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_CLONE_TEXTURE, ClutterCloneTextureClass))
|
||||
|
||||
typedef struct _ClutterCloneTexture ClutterCloneTexture;
|
||||
typedef struct _ClutterCloneTexturePrivate ClutterCloneTexturePrivate;
|
||||
typedef struct _ClutterCloneTextureClass ClutterCloneTextureClass;
|
||||
|
||||
struct _ClutterCloneTexture
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterActor parent;
|
||||
|
||||
ClutterCloneTexturePrivate *priv;
|
||||
};
|
||||
|
||||
struct _ClutterCloneTextureClass
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterActorClass parent_class;
|
||||
|
||||
/* padding for future expansion */
|
||||
void (*_clutter_clone_1) (void);
|
||||
void (*_clutter_clone_2) (void);
|
||||
void (*_clutter_clone_3) (void);
|
||||
void (*_clutter_clone_4) (void);
|
||||
};
|
||||
|
||||
GType clutter_clone_texture_get_type (void) G_GNUC_CONST;
|
||||
|
||||
ClutterActor * clutter_clone_texture_new (ClutterTexture *texture);
|
||||
ClutterTexture *clutter_clone_texture_get_parent_texture (ClutterCloneTexture *clone);
|
||||
void clutter_clone_texture_set_parent_texture (ClutterCloneTexture *clone,
|
||||
ClutterTexture *texture);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_CLONE_TEXTURE_H__ */
|
325
clutter/clutter-clone.c
Normal file
325
clutter/clutter-clone.c
Normal file
@ -0,0 +1,325 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2008 Intel Corporation.
|
||||
*
|
||||
* Authored By: Robert Bragg <robert@linux.intel.com>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:clutterclone
|
||||
* @short_description: An actor that displays a clone of a source actor
|
||||
*
|
||||
* #ClutterClone is a #ClutterActor which draws with the paint
|
||||
* function of another actor, scaled to fit its own allocation.
|
||||
*
|
||||
* #ClutterClone can be used to efficiently clone any other actor.
|
||||
*
|
||||
* <note><para>This is different from clutter_texture_new_from_actor()
|
||||
* which requires support for FBOs in the underlying GL
|
||||
* implementation.</para></note>
|
||||
*
|
||||
* #ClutterClone is available since Clutter 1.0
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "clutter-color.h"
|
||||
#include "clutter-clone.h"
|
||||
#include "clutter-debug.h"
|
||||
#include "clutter-main.h"
|
||||
#include "clutter-private.h"
|
||||
|
||||
#include "cogl/cogl.h"
|
||||
|
||||
G_DEFINE_TYPE (ClutterClone, clutter_clone, CLUTTER_TYPE_ACTOR);
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_SOURCE
|
||||
};
|
||||
|
||||
#define CLUTTER_CLONE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_CLONE, ClutterClonePrivate))
|
||||
|
||||
struct _ClutterClonePrivate
|
||||
{
|
||||
ClutterActor *clone_source;
|
||||
};
|
||||
|
||||
static void
|
||||
clutter_clone_get_preferred_width (ClutterActor *self,
|
||||
ClutterUnit for_height,
|
||||
ClutterUnit *min_width_p,
|
||||
ClutterUnit *natural_width_p)
|
||||
{
|
||||
ClutterClonePrivate *priv = CLUTTER_CLONE (self)->priv;
|
||||
ClutterActor *clone_source = priv->clone_source;
|
||||
|
||||
if (G_UNLIKELY (clone_source == NULL))
|
||||
{
|
||||
if (min_width_p)
|
||||
*min_width_p = 0;
|
||||
|
||||
if (natural_width_p)
|
||||
*natural_width_p = 0;
|
||||
}
|
||||
else
|
||||
clutter_actor_get_preferred_width (clone_source,
|
||||
for_height,
|
||||
min_width_p,
|
||||
natural_width_p);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_get_preferred_height (ClutterActor *self,
|
||||
ClutterUnit for_width,
|
||||
ClutterUnit *min_height_p,
|
||||
ClutterUnit *natural_height_p)
|
||||
{
|
||||
ClutterClonePrivate *priv = CLUTTER_CLONE (self)->priv;
|
||||
ClutterActor *clone_source = priv->clone_source;
|
||||
|
||||
if (G_UNLIKELY (clone_source == NULL))
|
||||
{
|
||||
if (min_height_p)
|
||||
*min_height_p = 0;
|
||||
|
||||
if (natural_height_p)
|
||||
*natural_height_p = 0;
|
||||
}
|
||||
else
|
||||
clutter_actor_get_preferred_height (clone_source,
|
||||
for_width,
|
||||
min_height_p,
|
||||
natural_height_p);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_paint (ClutterActor *self)
|
||||
{
|
||||
ClutterClone *clone = CLUTTER_CLONE (self);
|
||||
ClutterClonePrivate *priv = clone->priv;
|
||||
ClutterGeometry geom;
|
||||
ClutterGeometry clone_source_geom;
|
||||
gfloat x_scale, y_scale;
|
||||
|
||||
if (G_UNLIKELY (priv->clone_source == NULL))
|
||||
return;
|
||||
|
||||
CLUTTER_NOTE (PAINT,
|
||||
"painting clone actor '%s'",
|
||||
clutter_actor_get_name (self) ? clutter_actor_get_name (self)
|
||||
: "unknown");
|
||||
|
||||
clutter_actor_get_allocation_geometry (self, &geom);
|
||||
clutter_actor_get_allocation_geometry (priv->clone_source,
|
||||
&clone_source_geom);
|
||||
|
||||
/* We need to scale what the clone-source actor paints to fill our own
|
||||
* allocation... */
|
||||
|
||||
x_scale = (gfloat) geom.width / clone_source_geom.width;
|
||||
y_scale = (gfloat) geom.height / clone_source_geom.height;
|
||||
|
||||
cogl_scale (x_scale, y_scale, 1.0);
|
||||
|
||||
/* The final bits of magic:
|
||||
* - We need to make sure that when the clone-source actor's paint method
|
||||
* calls clutter_actor_get_paint_opacity, it traverses our parent not it's
|
||||
* real parent.
|
||||
* - We need to stop clutter_actor_paint applying the model view matrix of
|
||||
* the clone source actor.
|
||||
*/
|
||||
_clutter_actor_set_opacity_parent (priv->clone_source,
|
||||
clutter_actor_get_parent (self));
|
||||
_clutter_actor_set_enable_model_view_transform (priv->clone_source, FALSE);
|
||||
|
||||
clutter_actor_paint (priv->clone_source);
|
||||
|
||||
_clutter_actor_set_enable_model_view_transform (priv->clone_source, TRUE);
|
||||
_clutter_actor_set_opacity_parent (priv->clone_source, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_set_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterClone *clone = CLUTTER_CLONE (gobject);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SOURCE:
|
||||
clutter_clone_set_source (clone, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterClonePrivate *priv = CLUTTER_CLONE (gobject)->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SOURCE:
|
||||
g_value_set_object (value, priv->clone_source);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_dispose (GObject *gobject)
|
||||
{
|
||||
ClutterClonePrivate *priv = CLUTTER_CLONE (gobject)->priv;
|
||||
|
||||
if (priv->clone_source)
|
||||
{
|
||||
g_object_unref (priv->clone_source);
|
||||
priv->clone_source = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (clutter_clone_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_class_init (ClutterCloneClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||
GParamSpec *pspec = NULL;
|
||||
|
||||
g_type_class_add_private (gobject_class, sizeof (ClutterClonePrivate));
|
||||
|
||||
actor_class->paint = clutter_clone_paint;
|
||||
actor_class->get_preferred_width = clutter_clone_get_preferred_width;
|
||||
actor_class->get_preferred_height = clutter_clone_get_preferred_height;
|
||||
|
||||
gobject_class->dispose = clutter_clone_dispose;
|
||||
gobject_class->set_property = clutter_clone_set_property;
|
||||
gobject_class->get_property = clutter_clone_get_property;
|
||||
|
||||
/**
|
||||
* ClutterClone:source:
|
||||
*
|
||||
* This property specifies the source actor being cloned.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
pspec = g_param_spec_object ("source",
|
||||
"Source",
|
||||
"Specifies the actor to be cloned",
|
||||
CLUTTER_TYPE_ACTOR,
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
CLUTTER_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_SOURCE, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_clone_init (ClutterClone *self)
|
||||
{
|
||||
ClutterClonePrivate *priv;
|
||||
|
||||
self->priv = priv = CLUTTER_CLONE_GET_PRIVATE (self);
|
||||
|
||||
priv->clone_source = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_clone_new:
|
||||
* @source: a #ClutterActor, or %NULL
|
||||
*
|
||||
* Creates a new #ClutterActor which clones @source/
|
||||
*
|
||||
* Return value: the newly created #ClutterClone
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
ClutterActor *
|
||||
clutter_clone_new (ClutterActor *source)
|
||||
{
|
||||
return g_object_new (CLUTTER_TYPE_CLONE, "source", source, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_clone_set_source:
|
||||
* @clone: a #ClutterClone
|
||||
* @source: a #ClutterActor, or %NULL
|
||||
*
|
||||
* Sets @source as the source actor to be cloned by @clone.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
void
|
||||
clutter_clone_set_source (ClutterClone *clone,
|
||||
ClutterActor *source)
|
||||
{
|
||||
ClutterClonePrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_CLONE (clone));
|
||||
g_return_if_fail (source == NULL || CLUTTER_IS_ACTOR (source));
|
||||
|
||||
priv = clone->priv;
|
||||
|
||||
if (priv->clone_source)
|
||||
{
|
||||
g_object_unref (priv->clone_source);
|
||||
priv->clone_source = NULL;
|
||||
}
|
||||
|
||||
if (source)
|
||||
priv->clone_source = g_object_ref (source);
|
||||
|
||||
g_object_notify (G_OBJECT (clone), "source");
|
||||
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (clone));
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_clone_get_source:
|
||||
* @clone: a #ClutterClone
|
||||
*
|
||||
* Retrieves the source #ClutterActor being cloned by @clone
|
||||
*
|
||||
* Return value: the actor source for the clone
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
ClutterActor *
|
||||
clutter_clone_get_clone_source (ClutterClone *clone)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_CLONE (clone), NULL);
|
||||
|
||||
return clone->priv->clone_source;
|
||||
}
|
75
clutter/clutter-clone.h
Normal file
75
clutter/clutter-clone.h
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2008 Intel Corporation.
|
||||
*
|
||||
* Authored By: Robert Bragg <robert@linux.intel.com>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
#error "Only <clutter/clutter.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __CLUTTER_CLONE_H__
|
||||
#define __CLUTTER_CLONE_H__
|
||||
|
||||
#include <clutter/clutter-actor.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_CLONE (clutter_clone_get_type())
|
||||
#define CLUTTER_CLONE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_CLONE, ClutterClone))
|
||||
#define CLUTTER_CLONE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_CLONE, ClutterCloneClass))
|
||||
#define CLUTTER_IS_CLONE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_CLONE))
|
||||
#define CLUTTER_IS_CLONE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_CLONE))
|
||||
#define CLUTTER_CLONE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_CLONE, ClutterCloneClass))
|
||||
|
||||
typedef struct _ClutterClone ClutterClone;
|
||||
typedef struct _ClutterCloneClass ClutterCloneClass;
|
||||
typedef struct _ClutterClonePrivate ClutterClonePrivate;
|
||||
|
||||
struct _ClutterClone
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterActor parent_instance;
|
||||
|
||||
ClutterClonePrivate *priv;
|
||||
};
|
||||
|
||||
struct _ClutterCloneClass
|
||||
{
|
||||
/*< private >*/
|
||||
ClutterActorClass parent_class;
|
||||
|
||||
/* padding for future expansion */
|
||||
void (*_clutter_actor_clone1) (void);
|
||||
void (*_clutter_actor_clone2) (void);
|
||||
void (*_clutter_actor_clone3) (void);
|
||||
void (*_clutter_actor_clone4) (void);
|
||||
};
|
||||
|
||||
GType clutter_clone_get_type (void) G_GNUC_CONST;
|
||||
|
||||
ClutterActor *clutter_clone_new (ClutterActor *source);
|
||||
void clutter_clone_set_source (ClutterClone *clone,
|
||||
ClutterActor *source);
|
||||
ClutterActor *clutter_clone_get_source (ClutterClone *clone);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_CLONE_H__ */
|
@ -224,6 +224,12 @@ gboolean _clutter_boolean_handled_accumulator (GSignalInvocationHint *ihint,
|
||||
void _clutter_actor_apply_modelview_transform_recursive (ClutterActor *self,
|
||||
ClutterActor *ancestor);
|
||||
|
||||
void _clutter_actor_set_opacity_parent (ClutterActor *self,
|
||||
ClutterActor *parent);
|
||||
|
||||
void _clutter_actor_set_enable_model_view_transform (ClutterActor *self,
|
||||
gboolean enable);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _HAVE_CLUTTER_PRIVATE_H */
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "clutter-binding-pool.h"
|
||||
#include "clutter-cairo-texture.h"
|
||||
#include "clutter-child-meta.h"
|
||||
#include "clutter-clone-texture.h"
|
||||
#include "clutter-clone.h"
|
||||
#include "clutter-color.h"
|
||||
#include "clutter-container.h"
|
||||
#include "clutter-deprecated.h"
|
||||
|
@ -10,10 +10,15 @@
|
||||
<releaseinfo>Version &version;</releaseinfo>
|
||||
|
||||
<copyright>
|
||||
<year>2008</year>
|
||||
<year>2006,2007,2008</year>
|
||||
<holder>OpenedHand LTD</holder>
|
||||
</copyright>
|
||||
|
||||
<copyright>
|
||||
<year>2009</year>
|
||||
<holder>Intel Corporation</holder>
|
||||
</copyright>
|
||||
|
||||
<legalnotice>
|
||||
<para>
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
@ -56,7 +61,7 @@
|
||||
<title>Base actors</title>
|
||||
<xi:include href="xml/clutter-rectangle.xml"/>
|
||||
<xi:include href="xml/clutter-texture.xml"/>
|
||||
<xi:include href="xml/clutter-clone-texture.xml"/>
|
||||
<xi:include href="xml/clutter-clone.xml"/>
|
||||
<xi:include href="xml/clutter-text.xml"/>
|
||||
<xi:include href="xml/clutter-cairo-texture.xml"/>
|
||||
</chapter>
|
||||
|
@ -130,23 +130,23 @@ clutter_alpha_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>clutter-clone-texture</FILE>
|
||||
<TITLE>ClutterCloneTexture</TITLE>
|
||||
ClutterCloneTexture
|
||||
ClutterCloneTextureClass
|
||||
clutter_clone_texture_new
|
||||
clutter_clone_texture_get_parent_texture
|
||||
clutter_clone_texture_set_parent_texture
|
||||
<FILE>clutter-clone</FILE>
|
||||
<TITLE>ClutterClone</TITLE>
|
||||
ClutterClone
|
||||
ClutterCloneClass
|
||||
clutter_clone_new
|
||||
clutter_clone_set_source
|
||||
clutter_clone_get_source
|
||||
<SUBSECTION Standard>
|
||||
CLUTTER_CLONE_TEXTURE
|
||||
CLUTTER_IS_CLONE_TEXTURE
|
||||
CLUTTER_TYPE_CLONE_TEXTURE
|
||||
CLUTTER_CLONE_TEXTURE_CLASS
|
||||
CLUTTER_IS_CLONE_TEXTURE_CLASS
|
||||
CLUTTER_CLONE_TEXTURE_GET_CLASS
|
||||
CLUTTER_CLONE
|
||||
CLUTTER_IS_CLONE
|
||||
CLUTTER_TYPE_CLONE
|
||||
CLUTTER_CLONE_CLASS
|
||||
CLUTTER_IS_CLONE_CLASS
|
||||
CLUTTER_CLONE_GET_CLASS
|
||||
<SUBSECTION Private>
|
||||
ClutterCloneTexturePrivate
|
||||
clutter_clone_texture_get_type
|
||||
ClutterClonePrivate
|
||||
clutter_clone_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
|
@ -5,6 +5,7 @@ UNIT_TESTS = \
|
||||
test-offscreen.c \
|
||||
test-scale.c \
|
||||
test-actors.c \
|
||||
test-actor-clone.c \
|
||||
test-behave.c \
|
||||
test-project.c \
|
||||
test-perspective.c \
|
||||
|
288
tests/interactive/test-actor-clone.c
Normal file
288
tests/interactive/test-actor-clone.c
Normal file
@ -0,0 +1,288 @@
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#define NHANDS 6
|
||||
|
||||
typedef struct SuperOH
|
||||
{
|
||||
ClutterActor **hand, *bgtex;
|
||||
ClutterActor *real_hand;
|
||||
ClutterActor *group;
|
||||
ClutterActor *stage;
|
||||
|
||||
gint stage_width;
|
||||
gint stage_height;
|
||||
gfloat radius;
|
||||
|
||||
ClutterBehaviour *scaler_1;
|
||||
ClutterBehaviour *scaler_2;
|
||||
ClutterTimeline *timeline;
|
||||
} SuperOH;
|
||||
|
||||
static gint n_hands = NHANDS;
|
||||
|
||||
static GOptionEntry super_oh_entries[] = {
|
||||
{
|
||||
"num-hands", 'n',
|
||||
0,
|
||||
G_OPTION_ARG_INT, &n_hands,
|
||||
"Number of hands", "HANDS"
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/* input handler */
|
||||
static gboolean
|
||||
input_cb (ClutterActor *stage,
|
||||
ClutterEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
SuperOH *oh = data;
|
||||
|
||||
if (event->type == CLUTTER_BUTTON_PRESS)
|
||||
{
|
||||
ClutterButtonEvent *button_event;
|
||||
ClutterActor *e;
|
||||
gint x, y;
|
||||
|
||||
clutter_event_get_coords (event, &x, &y);
|
||||
|
||||
button_event = (ClutterButtonEvent *) event;
|
||||
g_print ("*** button press event (button:%d) at %d, %d ***\n",
|
||||
button_event->button,
|
||||
x, y);
|
||||
|
||||
e = clutter_stage_get_actor_at_pos (CLUTTER_STAGE (stage), x, y);
|
||||
|
||||
/* only allow hiding the clones */
|
||||
if (e && CLUTTER_IS_CLONE (e))
|
||||
{
|
||||
clutter_actor_hide (e);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (event->type == CLUTTER_KEY_RELEASE)
|
||||
{
|
||||
ClutterKeyEvent *kev = (ClutterKeyEvent *) event;
|
||||
|
||||
g_print ("*** key press event (key:%c) ***\n",
|
||||
clutter_key_event_symbol (kev));
|
||||
|
||||
if (clutter_key_event_symbol (kev) == CLUTTER_q)
|
||||
{
|
||||
clutter_main_quit ();
|
||||
return TRUE;
|
||||
}
|
||||
else if (clutter_key_event_symbol (kev) == CLUTTER_r)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n_hands; i++)
|
||||
clutter_actor_show (oh->hand[i]);
|
||||
|
||||
clutter_actor_show (oh->real_hand);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* Timeline handler */
|
||||
static void
|
||||
frame_cb (ClutterTimeline *timeline,
|
||||
gint frame_num,
|
||||
gpointer data)
|
||||
{
|
||||
SuperOH *oh = data;
|
||||
gint i;
|
||||
|
||||
/* Rotate everything clockwise about stage center*/
|
||||
|
||||
clutter_actor_set_rotation (oh->group,
|
||||
CLUTTER_Z_AXIS,
|
||||
frame_num,
|
||||
oh->stage_width / 2,
|
||||
oh->stage_height / 2,
|
||||
0);
|
||||
|
||||
for (i = 0; i < n_hands; i++)
|
||||
{
|
||||
gdouble scale_x, scale_y;
|
||||
|
||||
clutter_actor_get_scale (oh->hand[i], &scale_x, &scale_y);
|
||||
|
||||
/* Rotate each hand around there centers - to get this we need
|
||||
* to take into account any scaling.
|
||||
*/
|
||||
clutter_actor_set_rotation (oh->hand[i],
|
||||
CLUTTER_Z_AXIS,
|
||||
-6.0 * frame_num,
|
||||
0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static gdouble
|
||||
my_sine_wave (ClutterAlpha *alpha,
|
||||
gpointer dummy G_GNUC_UNUSED)
|
||||
{
|
||||
ClutterTimeline *timeline = clutter_alpha_get_timeline (alpha);
|
||||
gdouble progress = clutter_timeline_get_progress (timeline);
|
||||
|
||||
return sin (progress * G_PI);
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT int
|
||||
test_actor_clone_main (int argc, char *argv[])
|
||||
{
|
||||
ClutterAlpha *alpha;
|
||||
ClutterActor *stage;
|
||||
ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
|
||||
SuperOH *oh;
|
||||
gint i;
|
||||
GError *error;
|
||||
ClutterActor *real_hand, *tmp;
|
||||
ClutterColor clr = { 0xff, 0xff, 0x00, 0xff };
|
||||
|
||||
error = NULL;
|
||||
|
||||
clutter_init_with_args (&argc, &argv,
|
||||
NULL,
|
||||
super_oh_entries,
|
||||
NULL,
|
||||
&error);
|
||||
if (error)
|
||||
{
|
||||
g_warning ("Unable to initialise Clutter:\n%s",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
stage = clutter_stage_get_default ();
|
||||
clutter_actor_set_size (stage, 800, 600);
|
||||
|
||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "Clone Test");
|
||||
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
|
||||
|
||||
oh = g_new (SuperOH, 1);
|
||||
|
||||
/* Create a timeline to manage animation */
|
||||
oh->timeline = clutter_timeline_new (360, 60);
|
||||
clutter_timeline_set_loop (oh->timeline, TRUE);
|
||||
|
||||
/* fire a callback for frame change */
|
||||
g_signal_connect (oh->timeline, "new-frame", G_CALLBACK (frame_cb), oh);
|
||||
|
||||
/* Set up some behaviours to handle scaling */
|
||||
alpha = clutter_alpha_new_with_func (oh->timeline, my_sine_wave, NULL, NULL);
|
||||
|
||||
oh->scaler_1 = clutter_behaviour_scale_new (alpha, 0.5, 0.5, 1.0, 1.0);
|
||||
oh->scaler_2 = clutter_behaviour_scale_new (alpha, 1.0, 1.0, 0.5, 0.5);
|
||||
|
||||
tmp = clutter_texture_new_from_file ("redhand.png", &error);
|
||||
if (tmp == NULL)
|
||||
{
|
||||
g_error ("image load failed: %s", error->message);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
clutter_actor_set_size (tmp, 300, 500);
|
||||
|
||||
real_hand = clutter_group_new ();
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (real_hand), tmp);
|
||||
tmp = clutter_rectangle_new_with_color (&clr);
|
||||
clutter_actor_set_size (tmp, 100, 100);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (real_hand), tmp);
|
||||
clutter_actor_set_scale (real_hand, 0.5, 0.5);
|
||||
oh->real_hand = real_hand;
|
||||
|
||||
/* Now stick the group we want to clone into another group with a custom
|
||||
* opacity to verify that the clones don't traverse this parent when
|
||||
* calculating their opacity. */
|
||||
tmp = clutter_group_new ();
|
||||
clutter_actor_set_opacity (tmp, 0x80);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (tmp), real_hand);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), tmp);
|
||||
|
||||
/* create a new group to hold multiple actors in a group */
|
||||
oh->group = clutter_group_new();
|
||||
|
||||
oh->hand = g_new (ClutterActor*, n_hands);
|
||||
|
||||
oh->stage_width = clutter_actor_get_width (stage);
|
||||
oh->stage_height = clutter_actor_get_height (stage);
|
||||
oh->radius = (oh->stage_width + oh->stage_height)
|
||||
/ n_hands;
|
||||
|
||||
for (i = 0; i < n_hands; i++)
|
||||
{
|
||||
gint x, y, w, h;
|
||||
|
||||
/* Create a texture from file, then clone in to same resources */
|
||||
oh->hand[i] = clutter_clone_new (real_hand);
|
||||
clutter_actor_set_size (oh->hand[i], 200, 213);
|
||||
|
||||
/* Place around a circle */
|
||||
w = clutter_actor_get_width (oh->hand[0]);
|
||||
h = clutter_actor_get_height (oh->hand[0]);
|
||||
|
||||
x = oh->stage_width / 2
|
||||
+ oh->radius
|
||||
* cos (i * G_PI / (n_hands / 2))
|
||||
- w / 2;
|
||||
|
||||
y = oh->stage_height / 2
|
||||
+ oh->radius
|
||||
* sin (i * G_PI / (n_hands / 2))
|
||||
- h / 2;
|
||||
|
||||
clutter_actor_set_position (oh->hand[i], x, y);
|
||||
|
||||
clutter_actor_move_anchor_point_from_gravity (oh->hand[i],
|
||||
CLUTTER_GRAVITY_CENTER);
|
||||
|
||||
/* Add to our group group */
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (oh->group), oh->hand[i]);
|
||||
|
||||
if (i % 2)
|
||||
clutter_behaviour_apply (oh->scaler_1, oh->hand[i]);
|
||||
else
|
||||
clutter_behaviour_apply (oh->scaler_2, oh->hand[i]);
|
||||
}
|
||||
|
||||
/* Add the group to the stage */
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), oh->group);
|
||||
|
||||
/* Show everying */
|
||||
clutter_actor_show (stage);
|
||||
|
||||
g_signal_connect (stage, "button-press-event",
|
||||
G_CALLBACK (input_cb),
|
||||
oh);
|
||||
g_signal_connect (stage, "key-release-event",
|
||||
G_CALLBACK (input_cb),
|
||||
oh);
|
||||
|
||||
/* and start it */
|
||||
clutter_timeline_start (oh->timeline);
|
||||
|
||||
clutter_main ();
|
||||
|
||||
/* clean up */
|
||||
g_object_unref (oh->scaler_1);
|
||||
g_object_unref (oh->scaler_2);
|
||||
g_object_unref (oh->timeline);
|
||||
g_free (oh->hand);
|
||||
g_free (oh);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -1,24 +1,27 @@
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#if defined (_MSC_VER) && !defined (_USE_MATH_DEFINES)
|
||||
#define _USE_MATH_DEFINES
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#define TRAILS 0
|
||||
#define NHANDS 6
|
||||
#define RADIUS ((CLUTTER_STAGE_WIDTH()+CLUTTER_STAGE_HEIGHT())/NHANDS)
|
||||
|
||||
typedef struct SuperOH
|
||||
{
|
||||
ClutterActor **hand, *bgtex;
|
||||
ClutterActor *group;
|
||||
ClutterActor **hand, *bgtex;
|
||||
ClutterActor *real_hand;
|
||||
ClutterActor *group;
|
||||
ClutterActor *stage;
|
||||
|
||||
gint stage_width;
|
||||
gint stage_height;
|
||||
gfloat radius;
|
||||
|
||||
ClutterBehaviour *scaler_1;
|
||||
ClutterBehaviour *scaler_2;
|
||||
ClutterTimeline *timeline;
|
||||
} SuperOH;
|
||||
|
||||
static gint n_hands = NHANDS;
|
||||
@ -50,12 +53,14 @@ input_cb (ClutterActor *stage,
|
||||
clutter_event_get_coords (event, &x, &y);
|
||||
|
||||
button_event = (ClutterButtonEvent *) event;
|
||||
g_print ("*** button press event (button:%d) ***\n",
|
||||
button_event->button);
|
||||
g_print ("*** button press event (button:%d) at %d, %d ***\n",
|
||||
button_event->button,
|
||||
x, y);
|
||||
|
||||
e = clutter_stage_get_actor_at_pos (CLUTTER_STAGE (stage), x, y);
|
||||
|
||||
if (e && (CLUTTER_IS_TEXTURE (e) || CLUTTER_IS_CLONE_TEXTURE (e)))
|
||||
/* only allow hiding the clones */
|
||||
if (e && (CLUTTER_IS_TEXTURE (e) || CLUTTER_IS_CLONE (e)))
|
||||
{
|
||||
clutter_actor_hide (e);
|
||||
return TRUE;
|
||||
@ -95,31 +100,26 @@ frame_cb (ClutterTimeline *timeline,
|
||||
gpointer data)
|
||||
{
|
||||
SuperOH *oh = data;
|
||||
gint i;
|
||||
gint i;
|
||||
|
||||
/* Rotate everything clockwise about stage center*/
|
||||
|
||||
clutter_actor_set_rotation (CLUTTER_ACTOR (oh->group),
|
||||
clutter_actor_set_rotation (oh->group,
|
||||
CLUTTER_Z_AXIS,
|
||||
frame_num,
|
||||
CLUTTER_STAGE_WIDTH () / 2,
|
||||
CLUTTER_STAGE_HEIGHT () / 2,
|
||||
oh->stage_width / 2,
|
||||
oh->stage_height / 2,
|
||||
0);
|
||||
|
||||
for (i = 0; i < n_hands; i++)
|
||||
{
|
||||
gdouble scale_x, scale_y;
|
||||
|
||||
clutter_actor_get_scale (oh->hand[i], &scale_x, &scale_y);
|
||||
|
||||
/* Rotate each hand around there centers - to get this we need
|
||||
* to take into account any scaling.
|
||||
*
|
||||
* FIXME: scaling causes drift so disabled for now. Need rotation
|
||||
* unit based functions to fix.
|
||||
*/
|
||||
clutter_actor_set_rotation (oh->hand[i], CLUTTER_Z_AXIS,
|
||||
- 6.0 * frame_num, 0, 0, 0);
|
||||
clutter_actor_set_rotation (oh->hand[i],
|
||||
CLUTTER_Z_AXIS,
|
||||
-6.0 * frame_num,
|
||||
0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,14 +136,13 @@ my_sine_wave (ClutterAlpha *alpha,
|
||||
G_MODULE_EXPORT int
|
||||
test_actors_main (int argc, char *argv[])
|
||||
{
|
||||
ClutterTimeline *timeline;
|
||||
ClutterAlpha *alpha;
|
||||
ClutterBehaviour *scaler_1, *scaler_2;
|
||||
ClutterActor *stage;
|
||||
ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
|
||||
SuperOH *oh;
|
||||
gint i;
|
||||
GError *error;
|
||||
ClutterAlpha *alpha;
|
||||
ClutterActor *stage;
|
||||
ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
|
||||
SuperOH *oh;
|
||||
gint i;
|
||||
GError *error;
|
||||
ClutterActor *real_hand;
|
||||
|
||||
error = NULL;
|
||||
|
||||
@ -158,69 +157,71 @@ test_actors_main (int argc, char *argv[])
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
exit (1);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
stage = clutter_stage_get_default ();
|
||||
clutter_actor_set_size (stage, 800, 600);
|
||||
|
||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "Actors Test");
|
||||
clutter_stage_set_color (CLUTTER_STAGE (stage),
|
||||
&stage_color);
|
||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "Clone Test");
|
||||
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
|
||||
|
||||
oh = g_new(SuperOH, 1);
|
||||
oh = g_new (SuperOH, 1);
|
||||
oh->stage = stage;
|
||||
|
||||
/* Create a timeline to manage animation */
|
||||
timeline = clutter_timeline_new (360, 60); /* num frames, fps */
|
||||
g_object_set (timeline, "loop", TRUE, NULL); /* have it loop */
|
||||
oh->timeline = clutter_timeline_new (360, 60);
|
||||
clutter_timeline_set_loop (oh->timeline, TRUE);
|
||||
|
||||
/* fire a callback for frame change */
|
||||
g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), oh);
|
||||
g_signal_connect (oh->timeline, "new-frame", G_CALLBACK (frame_cb), oh);
|
||||
|
||||
/* Set up some behaviours to handle scaling */
|
||||
alpha = clutter_alpha_new_with_func (timeline, my_sine_wave, NULL, NULL);
|
||||
alpha = clutter_alpha_new_with_func (oh->timeline, my_sine_wave, NULL, NULL);
|
||||
|
||||
scaler_1 = clutter_behaviour_scale_new (alpha,
|
||||
0.5, 0.5,
|
||||
1.0, 1.0);
|
||||
oh->scaler_1 = clutter_behaviour_scale_new (alpha, 0.5, 0.5, 1.0, 1.0);
|
||||
oh->scaler_2 = clutter_behaviour_scale_new (alpha, 1.0, 1.0, 0.5, 0.5);
|
||||
|
||||
scaler_2 = clutter_behaviour_scale_new (alpha,
|
||||
1.0, 1.0,
|
||||
0.5, 0.5);
|
||||
real_hand = clutter_texture_new_from_file ("redhand.png", &error);
|
||||
if (real_hand == NULL)
|
||||
{
|
||||
g_error ("image load failed: %s", error->message);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* create a new group to hold multiple actors in a group */
|
||||
oh->group = clutter_group_new();
|
||||
|
||||
oh->hand = g_new (ClutterActor*, n_hands);
|
||||
|
||||
oh->stage_width = clutter_actor_get_width (stage);
|
||||
oh->stage_height = clutter_actor_get_height (stage);
|
||||
oh->radius = (oh->stage_width + oh->stage_height)
|
||||
/ n_hands;
|
||||
|
||||
for (i = 0; i < n_hands; i++)
|
||||
{
|
||||
gint x, y, w, h;
|
||||
|
||||
/* Create a texture from file, then clone in to same resources */
|
||||
if (i == 0)
|
||||
{
|
||||
if ((oh->hand[i] = clutter_texture_new_from_file ("redhand.png",
|
||||
&error)) == NULL)
|
||||
{
|
||||
g_error ("image load failed: %s", error->message);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
oh->hand[i] = real_hand;
|
||||
else
|
||||
oh->hand[i] = clutter_clone_texture_new (CLUTTER_TEXTURE(oh->hand[0]));
|
||||
oh->hand[i] = clutter_clone_new (real_hand);
|
||||
|
||||
clutter_actor_set_size (oh->hand[i], 200, 213);
|
||||
|
||||
/* Place around a circle */
|
||||
w = clutter_actor_get_width (oh->hand[0]);
|
||||
h = clutter_actor_get_height (oh->hand[0]);
|
||||
w = clutter_actor_get_width (oh->hand[i]);
|
||||
h = clutter_actor_get_height (oh->hand[i]);
|
||||
|
||||
x = CLUTTER_STAGE_WIDTH () / 2
|
||||
+ RADIUS
|
||||
* cos (i * M_PI / (n_hands / 2))
|
||||
x = oh->stage_width / 2
|
||||
+ oh->radius
|
||||
* cos (i * G_PI / (n_hands / 2))
|
||||
- w / 2;
|
||||
|
||||
y = CLUTTER_STAGE_HEIGHT () / 2
|
||||
+ RADIUS
|
||||
* sin (i * M_PI / (n_hands / 2))
|
||||
y = oh->stage_height / 2
|
||||
+ oh->radius
|
||||
* sin (i * G_PI / (n_hands / 2))
|
||||
- h / 2;
|
||||
|
||||
clutter_actor_set_position (oh->hand[i], x, y);
|
||||
@ -231,22 +232,18 @@ test_actors_main (int argc, char *argv[])
|
||||
/* Add to our group group */
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (oh->group), oh->hand[i]);
|
||||
|
||||
#if 1 /* FIXME: disabled as causes drift? - see comment above */
|
||||
if (i % 2)
|
||||
clutter_behaviour_apply (scaler_1, oh->hand[i]);
|
||||
clutter_behaviour_apply (oh->scaler_1, oh->hand[i]);
|
||||
else
|
||||
clutter_behaviour_apply (scaler_2, oh->hand[i]);
|
||||
#endif
|
||||
clutter_behaviour_apply (oh->scaler_2, oh->hand[i]);
|
||||
}
|
||||
|
||||
/* Add the group to the stage */
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage),
|
||||
CLUTTER_ACTOR (oh->group));
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), oh->group);
|
||||
|
||||
/* Show everying ( and map window ) */
|
||||
/* Show everying */
|
||||
clutter_actor_show (stage);
|
||||
|
||||
|
||||
g_signal_connect (stage, "button-press-event",
|
||||
G_CALLBACK (input_cb),
|
||||
oh);
|
||||
@ -255,12 +252,16 @@ test_actors_main (int argc, char *argv[])
|
||||
oh);
|
||||
|
||||
/* and start it */
|
||||
clutter_timeline_start (timeline);
|
||||
clutter_timeline_start (oh->timeline);
|
||||
|
||||
clutter_main ();
|
||||
|
||||
/* clean up */
|
||||
g_object_unref (oh->scaler_1);
|
||||
g_object_unref (oh->scaler_2);
|
||||
g_object_unref (oh->timeline);
|
||||
g_free (oh->hand);
|
||||
g_free (oh);
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -24,43 +24,43 @@ raise_top (gpointer ignored)
|
||||
}
|
||||
|
||||
static ClutterActor *
|
||||
clone_box (ClutterTexture *original)
|
||||
clone_box (ClutterActor *original)
|
||||
{
|
||||
guint width, height;
|
||||
ClutterActor *group;
|
||||
ClutterActor *clone;
|
||||
|
||||
clutter_actor_get_size (CLUTTER_ACTOR (original), &width, &height);
|
||||
clutter_actor_get_size (original, &width, &height);
|
||||
|
||||
group = clutter_group_new ();
|
||||
clone = clutter_clone_texture_new (original);
|
||||
clone = clutter_clone_new (original);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (group), clone);
|
||||
clutter_actor_set_depth (clone, width/2);
|
||||
|
||||
clone = clutter_clone_texture_new (original);
|
||||
clone = clutter_clone_new (original);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (group), clone);
|
||||
clutter_actor_set_rotation (clone, CLUTTER_Y_AXIS, 180, width/2, 0, 0);
|
||||
clutter_actor_set_depth (clone, -(gint)width/2);
|
||||
|
||||
clone = clutter_clone_texture_new (original);
|
||||
clone = clutter_clone_new (original);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (group), clone);
|
||||
clutter_actor_set_rotation (clone, CLUTTER_Y_AXIS, 90, 0, 0, 0);
|
||||
clutter_actor_set_depth (clone, width/2);
|
||||
clutter_actor_set_position (clone, 0, 0);
|
||||
|
||||
clone = clutter_clone_texture_new (original);
|
||||
clone = clutter_clone_new (original);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (group), clone);
|
||||
clutter_actor_set_rotation (clone, CLUTTER_Y_AXIS, 90, 0, 0, 0);
|
||||
clutter_actor_set_depth (clone, width/2);
|
||||
clutter_actor_set_position (clone, width, 0);
|
||||
|
||||
clone = clutter_clone_texture_new (original);
|
||||
clone = clutter_clone_new (original);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (group), clone);
|
||||
clutter_actor_set_rotation (clone, CLUTTER_X_AXIS, 90, 0, 0, 0);
|
||||
clutter_actor_set_depth (clone, -(gint)width/2);
|
||||
clutter_actor_set_position (clone, 0, height);
|
||||
|
||||
clone = clutter_clone_texture_new (original);
|
||||
clone = clutter_clone_new (original);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (group), clone);
|
||||
clutter_actor_set_rotation (clone, CLUTTER_X_AXIS, 90, 0, 0, 0);
|
||||
clutter_actor_set_depth (clone, -(gint)width/2);
|
||||
@ -178,9 +178,8 @@ test_depth_main (int argc, char *argv[])
|
||||
0, 360);
|
||||
clutter_behaviour_apply (r_behave, janus);
|
||||
|
||||
|
||||
/* add hand box */
|
||||
box = clone_box (CLUTTER_TEXTURE (hand));
|
||||
box = clone_box (hand);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
|
||||
clutter_actor_set_position (box, 200, 250);
|
||||
clutter_actor_set_scale (box, 0.5, 0.5);
|
||||
|
@ -149,7 +149,7 @@ test_fbo_main (gint argc, gchar *argv[])
|
||||
1.0f / clutter_util_next_p2 (fbo_height));
|
||||
|
||||
/* Third from cloning the fbo texture */
|
||||
clone = clutter_clone_texture_new (CLUTTER_TEXTURE(fbo));
|
||||
clone = clutter_clone_new (fbo);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), clone);
|
||||
clutter_actor_set_position (clone, padx*2, 0);
|
||||
|
||||
|
@ -625,8 +625,7 @@ decrease_property_value (ClutterActor *actor,
|
||||
static ClutterActor *
|
||||
create_item (void)
|
||||
{
|
||||
ClutterActor *clone =
|
||||
clutter_clone_texture_new (CLUTTER_TEXTURE (icon));
|
||||
ClutterActor *clone = clutter_clone_new (icon);
|
||||
|
||||
gint32 size = g_random_int_range (MIN_SIZE, MAX_SIZE);
|
||||
|
||||
|
@ -61,7 +61,7 @@ input_cb (ClutterStage *stage,
|
||||
|
||||
e = clutter_stage_get_actor_at_pos (stage, x, y);
|
||||
|
||||
if (e && (CLUTTER_IS_TEXTURE (e) || CLUTTER_IS_CLONE_TEXTURE (e)))
|
||||
if (e && (CLUTTER_IS_TEXTURE (e) || CLUTTER_IS_CLONE (e)))
|
||||
{
|
||||
clutter_actor_hide (e);
|
||||
return TRUE;
|
||||
@ -245,7 +245,7 @@ test_paint_wrapper_main (int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
else
|
||||
oh->hand[i] = clutter_clone_texture_new (CLUTTER_TEXTURE(oh->hand[0]));
|
||||
oh->hand[i] = clutter_clone_new (oh->hand[0]);
|
||||
|
||||
/* paint something before each hand */
|
||||
g_signal_connect (oh->hand[i],
|
||||
|
Loading…
Reference in New Issue
Block a user