2006-05-29 08:59:36 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2006-06-21 22:34:25 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2007-10-12 08:17:00 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2007-09-27 22:20:30 +00:00
|
|
|
#include "config.h"
|
2007-10-12 08:17:00 +00:00
|
|
|
#endif
|
2006-06-21 22:34:25 +00:00
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
#include "clutter-clone-texture.h"
|
|
|
|
#include "clutter-main.h"
|
2006-07-24 21:15:19 +00:00
|
|
|
#include "clutter-feature.h"
|
2006-12-12 20:20:04 +00:00
|
|
|
#include "clutter-actor.h"
|
2006-05-29 08:59:36 +00:00
|
|
|
#include "clutter-util.h"
|
|
|
|
#include "clutter-enum-types.h"
|
2006-11-21 Emmanuele Bassi <ebassi@openedhand.com>
* configure.ac: Enable debug messages also when
--enable-debug is set to "minimum".
* clutter/Makefile.am:
* clutter/clutter-debug.h: Move all debugging macros inside
this private header; make all debug macros depend on the
CLUTTER_ENABLE_DEBUG compile time define, controlled by
the --enable-debug configure switch; add G_LOG_DOMAIN define.
* clutter/clutter-main.c: Clean up the debug stuff; add
command line argument parsing using GOption; the debug
messages now are triggered like this:
CLUTTER_DEBUG=section:section:... clutter-app
or like this:
clutter-app --clutter-debug=section:section:...
where "section" is one of the sections listed in clutter-main.c,
or "all", for all sections; each section is bound to a flag,
which can be used to define a domain when adding a debug note
using the CLUTTER_NOTE() macro; the old CLUTTER_DBG() macro is
just a wrapper around that, under the CLUTTER_DEBUG_MISC domain;
CLUTTER_NOTE() is used like this:
CLUTTER_NOTE (DOMAIN, log-function);
where log function is g_printerr(), g_message(), g_warning(),
g_critical() or directly g_log() - for instance:
CLUTTER_NOTE (PANGO, g_warning ("Cache miss: %d", glyph));
will print the warning only if the "pango" flag has been
set to the CLUTTER_DEBUG envvar or passed to the --clutter-debug
command line argument.
similar to CLUTTER_SHOW_FPS, there's also the --clutter-show-fps
command line switch; also, the --display and --screen command
line switches have been added: the first overrides the DISPLAY
envvar and the second controls the X screen used by Clutter to
get the root window on the display.
* clutter/clutter-main.h:
* clutter/clutter-main.c: Add extended support for GOption
in Clutter; use clutter_init_with_args() to let Clutter
parse your own command line arguments; use instead
clutter_get_option_group() to get the GOptionGroup used by
Clutter if you want to do the parsing yourself with
g_option_context_parse(). The init sequence has been verified,
updated and moved into common functions where possible.
* clutter/pango/pangoclutter-render.c:
* clutter/*.c: Include "clutter-debug.h" where needed; use
CLUTTER_NOTE() instead of CLUTTER_DBG().
* examples/super-oh.c: Use the new clutter_init_with_args()
function, and add a --num-hands command line switch to
the SuperOH example code controlling the number of hands at
runtime.
2006-11-21 21:27:53 +00:00
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-debug.h"
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
#include "cogl/cogl.h"
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2008-04-25 13:37:36 +00:00
|
|
|
PROP_PARENT_TEXTURE,
|
|
|
|
PROP_REPEAT_Y,
|
|
|
|
PROP_REPEAT_X
|
2006-05-29 08:59:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (ClutterCloneTexture,
|
|
|
|
clutter_clone_texture,
|
2006-06-13 13:17:45 +00:00
|
|
|
CLUTTER_TYPE_ACTOR);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
#define CLUTTER_CLONE_TEXTURE_GET_PRIVATE(obj) \
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_CLONE_TEXTURE, ClutterCloneTexturePrivate))
|
|
|
|
|
|
|
|
struct _ClutterCloneTexturePrivate
|
|
|
|
{
|
|
|
|
ClutterTexture *parent_texture;
|
2008-04-25 13:37:36 +00:00
|
|
|
guint repeat_x : 1;
|
|
|
|
guint repeat_y : 1;
|
2006-05-29 08:59:36 +00:00
|
|
|
};
|
|
|
|
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
static void
|
2006-06-13 13:17:45 +00:00
|
|
|
clutter_clone_texture_paint (ClutterActor *self)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
|
|
|
ClutterCloneTexturePrivate *priv;
|
2006-07-24 21:15:19 +00:00
|
|
|
ClutterActor *parent_texture;
|
2007-07-26 11:04:04 +00:00
|
|
|
gint x_1, y_1, x_2, y_2;
|
2008-10-30 16:50:07 +00:00
|
|
|
CoglColor col;
|
2008-04-25 13:37:36 +00:00
|
|
|
CoglHandle cogl_texture;
|
|
|
|
ClutterFixed t_w, t_h;
|
|
|
|
guint tex_width, tex_height;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
priv = CLUTTER_CLONE_TEXTURE (self)->priv;
|
|
|
|
|
2006-12-12 20:20:04 +00:00
|
|
|
/* no need to paint stuff if we don't have a texture to clone */
|
|
|
|
if (!priv->parent_texture)
|
|
|
|
return;
|
2006-07-24 21:15:19 +00:00
|
|
|
|
2007-04-27 21:13:06 +00:00
|
|
|
CLUTTER_NOTE (PAINT,
|
|
|
|
"painting clone texture '%s'",
|
|
|
|
clutter_actor_get_name (self) ? clutter_actor_get_name (self)
|
|
|
|
: "unknown");
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
/* parent texture may have been hidden, there for need to make sure its
|
|
|
|
* realised with resources available.
|
|
|
|
*/
|
2006-06-13 13:17:45 +00:00
|
|
|
parent_texture = CLUTTER_ACTOR (priv->parent_texture);
|
|
|
|
if (!CLUTTER_ACTOR_IS_REALIZED (parent_texture))
|
|
|
|
clutter_actor_realize (parent_texture);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-10-30 16:50:07 +00:00
|
|
|
cogl_color_set_from_4ub (&col, 255, 255, 255,
|
|
|
|
clutter_actor_get_paint_opacity (self));
|
2007-04-27 21:13:06 +00:00
|
|
|
cogl_color (&col);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
clutter_actor_get_allocation_coords (self, &x_1, &y_1, &x_2, &y_2);
|
2006-06-06 20:40:40 +00:00
|
|
|
|
2006-11-22 20:52:27 +00:00
|
|
|
CLUTTER_NOTE (PAINT, "paint to x1: %i, y1: %i x2: %i, y2: %i "
|
|
|
|
"opacity: %i",
|
2007-07-26 11:04:04 +00:00
|
|
|
x_1, y_1, x_2, y_2,
|
2006-11-22 20:52:27 +00:00
|
|
|
clutter_actor_get_opacity (self));
|
2006-06-06 20:40:40 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
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)
|
2008-10-30 16:37:55 +00:00
|
|
|
t_w = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (x_2 - x_1),
|
|
|
|
COGL_FIXED_FROM_INT (tex_width));
|
2008-04-25 13:37:36 +00:00
|
|
|
else
|
2008-10-30 16:37:55 +00:00
|
|
|
t_w = COGL_FIXED_1;
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->repeat_y && tex_height > 0)
|
2008-10-30 16:37:55 +00:00
|
|
|
t_h = COGL_FIXED_DIV (COGL_FIXED_FROM_INT (y_2 - y_1),
|
|
|
|
COGL_FIXED_FROM_INT (tex_height));
|
2008-04-25 13:37:36 +00:00
|
|
|
else
|
2008-10-30 16:37:55 +00:00
|
|
|
t_h = COGL_FIXED_1;
|
2008-04-25 13:37:36 +00:00
|
|
|
|
2006-09-20 18:38:08 +00:00
|
|
|
/* Parent paint translated us into position */
|
2008-04-25 13:37:36 +00:00
|
|
|
cogl_texture_rectangle (cogl_texture, 0, 0,
|
2008-10-30 16:37:55 +00:00
|
|
|
COGL_FIXED_FROM_INT (x_2 - x_1),
|
|
|
|
COGL_FIXED_FROM_INT (y_2 - y_1),
|
2008-04-25 13:37:36 +00:00
|
|
|
0, 0, t_w, t_h);
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_parent_texture (ClutterCloneTexture *ctexture,
|
|
|
|
ClutterTexture *texture)
|
|
|
|
{
|
|
|
|
ClutterCloneTexturePrivate *priv = ctexture->priv;
|
2006-12-12 20:20:04 +00:00
|
|
|
ClutterActor *actor = CLUTTER_ACTOR (ctexture);
|
2007-11-14 13:36:31 +00:00
|
|
|
gboolean was_visible = CLUTTER_ACTOR_IS_VISIBLE (ctexture);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
if (priv->parent_texture)
|
|
|
|
{
|
|
|
|
g_object_unref (priv->parent_texture);
|
|
|
|
priv->parent_texture = NULL;
|
|
|
|
|
2007-11-14 13:36:31 +00:00
|
|
|
if (was_visible)
|
|
|
|
clutter_actor_hide (actor);
|
|
|
|
}
|
2006-12-12 20:20:04 +00:00
|
|
|
|
2006-06-06 20:40:40 +00:00
|
|
|
if (texture)
|
|
|
|
{
|
|
|
|
priv->parent_texture = g_object_ref (texture);
|
|
|
|
|
2006-12-12 20:20:04 +00:00
|
|
|
/* queue a redraw if the cloned texture is already visible */
|
2007-11-14 13:36:31 +00:00
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (priv->parent_texture) &&
|
|
|
|
was_visible)
|
|
|
|
{
|
|
|
|
clutter_actor_show (actor);
|
|
|
|
clutter_actor_queue_redraw (actor);
|
|
|
|
}
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
|
|
|
clutter_actor_queue_relayout (actor);
|
2006-06-06 20:40:40 +00:00
|
|
|
}
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
ClutterCloneTexture *ctexture = CLUTTER_CLONE_TEXTURE (object);
|
|
|
|
ClutterCloneTexturePrivate *priv;
|
|
|
|
|
|
|
|
priv = ctexture->priv;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_PARENT_TEXTURE:
|
|
|
|
set_parent_texture (ctexture, g_value_get_object (value));
|
|
|
|
break;
|
2008-04-25 13:37:36 +00:00
|
|
|
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;
|
2006-05-29 08:59:36 +00:00
|
|
|
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);
|
2008-04-25 13:37:36 +00:00
|
|
|
ClutterCloneTexturePrivate *priv;
|
|
|
|
|
|
|
|
priv = ctexture->priv;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_PARENT_TEXTURE:
|
|
|
|
g_value_set_object (value, ctexture->priv->parent_texture);
|
|
|
|
break;
|
2008-04-25 13:37:36 +00:00
|
|
|
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;
|
2006-05-29 08:59:36 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_clone_texture_class_init (ClutterCloneTextureClass *klass)
|
|
|
|
{
|
2006-12-12 20:20:04 +00:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2006-06-13 13:17:45 +00:00
|
|
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
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;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
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));
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_clone_texture_new:
|
2008-02-15 15:49:44 +00:00
|
|
|
* @texture: a #ClutterTexture, or %NULL
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-02-15 15:49:44 +00:00
|
|
|
* Creates an efficient 'clone' of a pre-existing texture with which it
|
2006-12-12 20:20:04 +00:00
|
|
|
* shares the underlying pixbuf data.
|
|
|
|
*
|
|
|
|
* You can use clutter_clone_texture_set_parent_texture() to change the
|
2008-02-15 15:49:44 +00:00
|
|
|
* cloned texture.
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
|
|
|
* Return value: the newly created #ClutterCloneTexture
|
|
|
|
*/
|
2006-06-13 13:17:45 +00:00
|
|
|
ClutterActor *
|
2006-05-29 08:59:36 +00:00
|
|
|
clutter_clone_texture_new (ClutterTexture *texture)
|
|
|
|
{
|
2006-12-12 20:20:04 +00:00
|
|
|
g_return_val_if_fail (texture == NULL || CLUTTER_IS_TEXTURE (texture), NULL);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
return g_object_new (CLUTTER_TYPE_CLONE_TEXTURE,
|
|
|
|
"parent-texture", texture,
|
|
|
|
NULL);
|
|
|
|
}
|
2006-12-12 20:20:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
2006-12-13 18:12:09 +00:00
|
|
|
* @texture: a #ClutterTexture or %NULL
|
2006-12-12 20:20:04 +00:00
|
|
|
*
|
|
|
|
* 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);
|
|
|
|
}
|