Drop ClutterRectangle

And the correcponding CallyRectangle class.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
This commit is contained in:
Georges Basile Stavracas Neto 2020-06-26 17:54:09 -03:00 committed by Robert Mader
parent e884ba7f39
commit 2e086c74e7
12 changed files with 9 additions and 1003 deletions

View File

@ -1,98 +0,0 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:cally-rectangle
* @short_description: Implementation of the ATK interfaces for a #ClutterRectangle
* @see_also: #ClutterRectangle
*
* #CallyRectangle implements the required ATK interfaces of #ClutterRectangle
*
* In particular it sets a proper role for the rectangle.
*/
#include "clutter-build-config.h"
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include "cally-rectangle.h"
#include "cally-actor-private.h"
#include "clutter-color.h"
#include "deprecated/clutter-rectangle.h"
/* AtkObject */
static void cally_rectangle_real_initialize (AtkObject *obj,
gpointer data);
G_DEFINE_TYPE (CallyRectangle, cally_rectangle, CALLY_TYPE_ACTOR)
static void
cally_rectangle_class_init (CallyRectangleClass *klass)
{
/* GObjectClass *gobject_class = G_OBJECT_CLASS (klass); */
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->initialize = cally_rectangle_real_initialize;
}
static void
cally_rectangle_init (CallyRectangle *rectangle)
{
/* nothing to do yet */
}
/**
* cally_rectangle_new:
* @actor: a #ClutterActor
*
* Creates a new #CallyRectangle for the given @actor. @actor must be
* a #ClutterRectangle.
*
* Return value: the newly created #AtkObject
*
* Since: 1.4
*/
AtkObject*
cally_rectangle_new (ClutterActor *actor)
{
GObject *object = NULL;
AtkObject *accessible = NULL;
g_return_val_if_fail (CLUTTER_IS_RECTANGLE (actor), NULL);
object = g_object_new (CALLY_TYPE_RECTANGLE, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, actor);
return accessible;
}
static void
cally_rectangle_real_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (cally_rectangle_parent_class)->initialize (obj, data);
obj->role = ATK_ROLE_IMAGE;
}

View File

@ -1,84 +0,0 @@
/* CALLY - The Clutter Accessibility Implementation Library
*
* Copyright (C) 2009 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.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/>.
*/
#ifndef __CALLY_RECTANGLE_H__
#define __CALLY_RECTANGLE_H__
#if !defined(__CALLY_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <cally/cally.h> can be included directly."
#endif
#include <cally/cally-actor.h>
#include <clutter/clutter.h>
G_BEGIN_DECLS
#define CALLY_TYPE_RECTANGLE (cally_rectangle_get_type ())
#define CALLY_RECTANGLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALLY_TYPE_RECTANGLE, CallyRectangle))
#define CALLY_RECTANGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALLY_TYPE_RECTANGLE, CallyRectangleClass))
#define CALLY_IS_RECTANGLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALLY_TYPE_RECTANGLE))
#define CALLY_IS_RECTANGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALLY_TYPE_RECTANGLE))
#define CALLY_RECTANGLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALLY_TYPE_RECTANGLE, CallyRectangleClass))
typedef struct _CallyRectangle CallyRectangle;
typedef struct _CallyRectangleClass CallyRectangleClass;
typedef struct _CallyRectanglePrivate CallyRectanglePrivate;
/**
* CallyRectangle:
*
* The <structname>CallyRectangle</structname> structure contains only private
* data and should be accessed using the provided API
*
* Since: 1.4
*/
struct _CallyRectangle
{
/*< private >*/
CallyActor parent;
CallyRectanglePrivate *priv;
};
/**
* CallyRectangleClass:
*
* The <structname>CallyRectangleClass</structname> structure contains
* only private data
*
* Since: 1.4
*/
struct _CallyRectangleClass
{
/*< private >*/
CallyActorClass parent_class;
/* padding for future expansion */
gpointer _padding_dummy[8];
};
CLUTTER_EXPORT
GType cally_rectangle_get_type (void) G_GNUC_CONST;
CLUTTER_EXPORT
AtkObject* cally_rectangle_new (ClutterActor *actor);
G_END_DECLS
#endif /* __CALLY_RECTANGLE_H__ */

View File

@ -38,7 +38,6 @@
#include "cally-actor.h" #include "cally-actor.h"
#include "cally-stage.h" #include "cally-stage.h"
#include "cally-text.h" #include "cally-text.h"
#include "cally-rectangle.h"
#include "cally-clone.h" #include "cally-clone.h"
#include "cally-factory.h" #include "cally-factory.h"
@ -53,7 +52,6 @@
CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_ACTOR, cally_actor, cally_actor_new) CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_ACTOR, cally_actor, cally_actor_new)
CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_STAGE, cally_stage, cally_stage_new) CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_STAGE, cally_stage, cally_stage_new)
CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_TEXT, cally_text, cally_text_new) CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_TEXT, cally_text, cally_text_new)
CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_RECTANGLE, cally_rectangle, cally_rectangle_new)
CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_CLONE, cally_clone, cally_clone_new) CALLY_ACCESSIBLE_FACTORY (CALLY_TYPE_CLONE, cally_clone, cally_clone_new)
/** /**
@ -73,7 +71,6 @@ cally_accessibility_init (void)
CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_ACTOR, cally_actor); CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_ACTOR, cally_actor);
CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_STAGE, cally_stage); CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_STAGE, cally_stage);
CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_TEXT, cally_text); CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_TEXT, cally_text);
CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_RECTANGLE, cally_rectangle);
CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_CLONE, cally_clone); CALLY_ACTOR_SET_FACTORY (CLUTTER_TYPE_CLONE, cally_clone);
/* Initialize the CallyUtility class */ /* Initialize the CallyUtility class */

View File

@ -27,7 +27,6 @@
#include "cally-clone.h" #include "cally-clone.h"
#include "cally-factory.h" #include "cally-factory.h"
#include "cally-main.h" #include "cally-main.h"
#include "cally-rectangle.h"
#include "cally-root.h" #include "cally-root.h"
#include "cally-stage.h" #include "cally-stage.h"
#include "cally-text.h" #include "cally-text.h"

View File

@ -38,12 +38,14 @@
* *
* |[<!-- language="C" --> * |[<!-- language="C" -->
* // source * // source
* rect[0] = clutter_rectangle_new_with_color (&red_color); * rect[0] = clutter_actor_new ();
* clutter_actor_set_background_color (rect[0], &red_color);
* clutter_actor_set_position (rect[0], x_pos, y_pos); * clutter_actor_set_position (rect[0], x_pos, y_pos);
* clutter_actor_set_size (rect[0], 100, 100); * clutter_actor_set_size (rect[0], 100, 100);
* *
* // second rectangle * // second rectangle
* rect[1] = clutter_rectangle_new_with_color (&green_color); * rect[1] = clutter_actor_new ();
* clutter_actor_set_background_color (rect[1], &green_color);
* clutter_actor_set_size (rect[1], 100, 100); * clutter_actor_set_size (rect[1], 100, 100);
* clutter_actor_set_opacity (rect[1], 0); * clutter_actor_set_opacity (rect[1], 0);
* *
@ -53,7 +55,8 @@
* clutter_actor_add_constraint_with_name (rect[1], "green-y", constraint); * clutter_actor_add_constraint_with_name (rect[1], "green-y", constraint);
* *
* // third rectangle * // third rectangle
* rect[2] = clutter_rectangle_new_with_color (&blue_color); * rect[2] = clutter_actor_new ();
* clutter_actor_set_background_color (rect[2], &blue_color);
* clutter_actor_set_size (rect[2], 100, 100); * clutter_actor_set_size (rect[2], 100, 100);
* clutter_actor_set_opacity (rect[2], 0); * clutter_actor_set_opacity (rect[2], 0);
* *

View File

@ -5,7 +5,6 @@
#include "deprecated/clutter-actor.h" #include "deprecated/clutter-actor.h"
#include "deprecated/clutter-container.h" #include "deprecated/clutter-container.h"
#include "deprecated/clutter-rectangle.h"
#undef __CLUTTER_DEPRECATED_H_INSIDE__ #undef __CLUTTER_DEPRECATED_H_INSIDE__

View File

@ -50,14 +50,14 @@
* <informalexample><programlisting><![CDATA[ * <informalexample><programlisting><![CDATA[
* { * {
* "id" : "red-button", * "id" : "red-button",
* "type" : "ClutterRectangle", * "type" : "ClutterActor",
* "width" : 100, * "width" : 100,
* "height" : 100, * "height" : 100,
* "color" : "&num;ff0000ff" * "background-color" : "&num;ff0000ff"
* } * }
* ]]></programlisting></informalexample> * ]]></programlisting></informalexample>
* *
* This will produce a red #ClutterRectangle, 100x100 pixels wide, and * This will produce a red #ClutterActor, 100x100 pixels wide, and
* with a ClutterScript id of "red-button"; it can be retrieved by calling: * with a ClutterScript id of "red-button"; it can be retrieved by calling:
* *
* |[ * |[

View File

@ -1,626 +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/>.
*
*
*/
/**
* SECTION:clutter-rectangle
* @short_description: An actor that displays a simple rectangle.
*
* #ClutterRectangle is a #ClutterActor which draws a simple filled rectangle.
*
* #ClutterRectangle is deprecated since Clutter 1.10. If you want an actor
* painting a solid color, you can replace it with #ClutterActor and set the
* #ClutterActor:background-color property to the desired #ClutterColor. If
* you are drawing more complex shapes, use #ClutterCanvas to draw using the
* Cairo 2D API instead.
*/
#include "clutter-build-config.h"
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include "deprecated/clutter-rectangle.h"
#include "deprecated/clutter-actor.h"
#include "clutter-actor-private.h"
#include "clutter-color.h"
#include "clutter-debug.h"
#include "clutter-main.h"
#include "clutter-private.h"
#include "cogl/cogl.h"
struct _ClutterRectanglePrivate
{
ClutterColor color;
ClutterColor border_color;
guint border_width;
guint has_border : 1;
};
enum
{
PROP_0,
PROP_COLOR,
PROP_BORDER_COLOR,
PROP_BORDER_WIDTH,
PROP_HAS_BORDER
/* FIXME: Add gradient, rounded corner props etc */
};
static const ClutterColor default_color = { 255, 255, 255, 255 };
static const ClutterColor default_border_color = { 0, 0, 0, 255 };
G_DEFINE_TYPE_WITH_PRIVATE (ClutterRectangle, clutter_rectangle, CLUTTER_TYPE_ACTOR)
static void
clutter_rectangle_paint (ClutterActor *self,
ClutterPaintContext *paint_context)
{
ClutterRectanglePrivate *priv = CLUTTER_RECTANGLE (self)->priv;
CoglFramebuffer *framebuffer =
clutter_paint_context_get_framebuffer (paint_context);
static CoglPipeline *default_color_pipeline = NULL;
CoglPipeline *content_pipeline;
ClutterActorBox alloc;
CoglColor color;
guint8 tmp_alpha;
CLUTTER_NOTE (PAINT,
"painting rect '%s'",
clutter_actor_get_name (self) ? clutter_actor_get_name (self)
: "unknown");
clutter_actor_get_allocation_box (self, &alloc);
if (G_UNLIKELY (default_color_pipeline == NULL))
{
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
default_color_pipeline = cogl_pipeline_new (ctx);
}
g_assert (default_color_pipeline != NULL);
content_pipeline = cogl_pipeline_copy (default_color_pipeline);
/* compute the composited opacity of the actor taking into
* account the opacity of the color set by the user
*/
tmp_alpha = clutter_actor_get_paint_opacity (self)
* priv->color.alpha
/ 255;
cogl_color_init_from_4ub (&color,
priv->color.red,
priv->color.green,
priv->color.blue,
tmp_alpha);
cogl_color_premultiply (&color);
cogl_pipeline_set_color (content_pipeline, &color);
if (priv->has_border)
{
CoglPipeline *border_pipeline;
border_pipeline = cogl_pipeline_copy (default_color_pipeline);
tmp_alpha = clutter_actor_get_paint_opacity (self)
* priv->border_color.alpha
/ 255;
cogl_color_init_from_4ub (&color,
priv->border_color.red,
priv->border_color.green,
priv->border_color.blue,
tmp_alpha);
cogl_color_premultiply (&color);
cogl_pipeline_set_color (border_pipeline, &color);
/* We paint the border and the content only if the rectangle
* is big enough to show them
*/
if ((priv->border_width * 2) < clutter_actor_box_get_width (&alloc) &&
(priv->border_width * 2) < clutter_actor_box_get_height (&alloc))
{
/* paint the border. this sucks, but it's the only way to make a border */
cogl_framebuffer_draw_rectangle (framebuffer,
border_pipeline,
priv->border_width, 0,
clutter_actor_box_get_width (&alloc),
priv->border_width);
cogl_framebuffer_draw_rectangle (framebuffer,
border_pipeline,
clutter_actor_box_get_width (&alloc) - priv->border_width,
priv->border_width,
clutter_actor_box_get_width (&alloc),
clutter_actor_box_get_height (&alloc));
cogl_framebuffer_draw_rectangle (framebuffer,
border_pipeline,
0, clutter_actor_box_get_height (&alloc) - priv->border_width,
clutter_actor_box_get_width (&alloc) - priv->border_width,
clutter_actor_box_get_height (&alloc));
cogl_framebuffer_draw_rectangle (framebuffer,
border_pipeline,
0, 0,
priv->border_width,
clutter_actor_box_get_height (&alloc) - priv->border_width);
/* now paint the rectangle */
cogl_framebuffer_draw_rectangle (framebuffer,
content_pipeline,
priv->border_width, priv->border_width,
clutter_actor_box_get_width (&alloc) - priv->border_width,
clutter_actor_box_get_height (&alloc) - priv->border_width);
}
else
{
/* Otherwise, we draw a rectangle with the same color
* as the border, since we can only fit that into the
* allocation.
*/
cogl_framebuffer_draw_rectangle (framebuffer,
border_pipeline,
0, 0,
clutter_actor_box_get_width (&alloc),
clutter_actor_box_get_height (&alloc));
}
cogl_object_unref (border_pipeline);
}
else
{
cogl_framebuffer_draw_rectangle (framebuffer,
content_pipeline,
0, 0,
clutter_actor_box_get_width (&alloc),
clutter_actor_box_get_height (&alloc));
}
cogl_object_unref (content_pipeline);
}
static gboolean
clutter_rectangle_get_paint_volume (ClutterActor *self,
ClutterPaintVolume *volume)
{
return _clutter_actor_set_default_paint_volume (self,
CLUTTER_TYPE_RECTANGLE,
volume);
}
static gboolean
clutter_rectangle_has_overlaps (ClutterActor *self)
{
/* Rectangles never need an offscreen redirect because there are
never any overlapping primitives */
return FALSE;
}
static void
clutter_rectangle_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ClutterRectangle *rectangle = CLUTTER_RECTANGLE(object);
switch (prop_id)
{
case PROP_COLOR:
clutter_rectangle_set_color (rectangle, clutter_value_get_color (value));
break;
case PROP_BORDER_COLOR:
clutter_rectangle_set_border_color (rectangle,
clutter_value_get_color (value));
break;
case PROP_BORDER_WIDTH:
clutter_rectangle_set_border_width (rectangle,
g_value_get_uint (value));
break;
case PROP_HAS_BORDER:
rectangle->priv->has_border = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clutter_rectangle_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterRectanglePrivate *priv = CLUTTER_RECTANGLE(object)->priv;
switch (prop_id)
{
case PROP_COLOR:
clutter_value_set_color (value, &priv->color);
break;
case PROP_BORDER_COLOR:
clutter_value_set_color (value, &priv->border_color);
break;
case PROP_BORDER_WIDTH:
g_value_set_uint (value, priv->border_width);
break;
case PROP_HAS_BORDER:
g_value_set_boolean (value, priv->has_border);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clutter_rectangle_finalize (GObject *object)
{
G_OBJECT_CLASS (clutter_rectangle_parent_class)->finalize (object);
}
static void
clutter_rectangle_dispose (GObject *object)
{
G_OBJECT_CLASS (clutter_rectangle_parent_class)->dispose (object);
}
static void
clutter_rectangle_class_init (ClutterRectangleClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GParamSpec *pspec;
actor_class->paint = clutter_rectangle_paint;
actor_class->get_paint_volume = clutter_rectangle_get_paint_volume;
actor_class->has_overlaps = clutter_rectangle_has_overlaps;
gobject_class->finalize = clutter_rectangle_finalize;
gobject_class->dispose = clutter_rectangle_dispose;
gobject_class->set_property = clutter_rectangle_set_property;
gobject_class->get_property = clutter_rectangle_get_property;
/**
* ClutterRectangle:color:
*
* The color of the rectangle.
*/
pspec = clutter_param_spec_color ("color",
P_("Color"),
P_("The color of the rectangle"),
&default_color,
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_COLOR, pspec);
/**
* ClutterRectangle:border-color:
*
* The color of the border of the rectangle.
*
* Since: 0.2
*/
pspec = clutter_param_spec_color ("border-color",
P_("Border Color"),
P_("The color of the border of the rectangle"),
&default_border_color,
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_BORDER_COLOR, pspec);
/**
* ClutterRectangle:border-width:
*
* The width of the border of the rectangle, in pixels.
*
* Since: 0.2
*/
g_object_class_install_property (gobject_class,
PROP_BORDER_WIDTH,
g_param_spec_uint ("border-width",
P_("Border Width"),
P_("The width of the border of the rectangle"),
0, G_MAXUINT,
0,
CLUTTER_PARAM_READWRITE));
/**
* ClutterRectangle:has-border:
*
* Whether the #ClutterRectangle should be displayed with a border.
*
* Since: 0.2
*/
g_object_class_install_property (gobject_class,
PROP_HAS_BORDER,
g_param_spec_boolean ("has-border",
P_("Has Border"),
P_("Whether the rectangle should have a border"),
FALSE,
CLUTTER_PARAM_READWRITE));
}
static void
clutter_rectangle_init (ClutterRectangle *self)
{
ClutterRectanglePrivate *priv;
self->priv = priv = clutter_rectangle_get_instance_private (self);
priv->color = default_color;
priv->border_color = default_border_color;
priv->border_width = 0;
priv->has_border = FALSE;
}
/**
* clutter_rectangle_new:
*
* Creates a new #ClutterActor with a rectangular shape.
*
* Return value: a new #ClutterRectangle
*
* Deprecated: 1.10: Use clutter_actor_new() instead
*/
ClutterActor*
clutter_rectangle_new (void)
{
return g_object_new (CLUTTER_TYPE_RECTANGLE, NULL);
}
/**
* clutter_rectangle_new_with_color:
* @color: a #ClutterColor
*
* Creates a new #ClutterActor with a rectangular shape
* and of the given @color.
*
* Return value: a new #ClutterRectangle
*
* Deprecated: 1.10: Use clutter_actor_new() and
* clutter_actor_set_background_color() instead
*/
ClutterActor *
clutter_rectangle_new_with_color (const ClutterColor *color)
{
return g_object_new (CLUTTER_TYPE_RECTANGLE,
"color", color,
NULL);
}
/**
* clutter_rectangle_get_color:
* @rectangle: a #ClutterRectangle
* @color: (out caller-allocates): return location for a #ClutterColor
*
* Retrieves the color of @rectangle.
*
* Deprecated: 1.10: Use #ClutterActor and clutter_actor_get_background_color()
* instead
*/
void
clutter_rectangle_get_color (ClutterRectangle *rectangle,
ClutterColor *color)
{
ClutterRectanglePrivate *priv;
g_return_if_fail (CLUTTER_IS_RECTANGLE (rectangle));
g_return_if_fail (color != NULL);
priv = rectangle->priv;
color->red = priv->color.red;
color->green = priv->color.green;
color->blue = priv->color.blue;
color->alpha = priv->color.alpha;
}
/**
* clutter_rectangle_set_color:
* @rectangle: a #ClutterRectangle
* @color: a #ClutterColor
*
* Sets the color of @rectangle.
*
* Deprecated: 1.10: Use #ClutterActor and clutter_actor_set_background_color()
* instead
*/
void
clutter_rectangle_set_color (ClutterRectangle *rectangle,
const ClutterColor *color)
{
ClutterRectanglePrivate *priv;
g_return_if_fail (CLUTTER_IS_RECTANGLE (rectangle));
g_return_if_fail (color != NULL);
g_object_ref (rectangle);
priv = rectangle->priv;
priv->color.red = color->red;
priv->color.green = color->green;
priv->color.blue = color->blue;
priv->color.alpha = color->alpha;
#if 0
/* FIXME - appears to be causing border to always get drawn */
if (clutter_color_equal (&priv->color, &priv->border_color))
priv->has_border = FALSE;
else
priv->has_border = TRUE;
#endif
clutter_actor_queue_redraw (CLUTTER_ACTOR (rectangle));
g_object_notify (G_OBJECT (rectangle), "color");
g_object_notify (G_OBJECT (rectangle), "has-border");
g_object_unref (rectangle);
}
/**
* clutter_rectangle_get_border_width:
* @rectangle: a #ClutterRectangle
*
* Gets the width (in pixels) of the border used by @rectangle
*
* Return value: the border's width
*
* Since: 0.2
*
* Deprecated: 1.10: Use #ClutterActor and a #ClutterCanvas content
* to draw the border using Cairo
*/
guint
clutter_rectangle_get_border_width (ClutterRectangle *rectangle)
{
g_return_val_if_fail (CLUTTER_IS_RECTANGLE (rectangle), 0);
return rectangle->priv->border_width;
}
/**
* clutter_rectangle_set_border_width:
* @rectangle: a #ClutterRectangle
* @width: the width of the border
*
* Sets the width (in pixel) of the border used by @rectangle.
* A @width of 0 will unset the border.
*
* Since: 0.2
*
* Deprecated: 1.10: Use #ClutterActor and a #ClutterCanvas content
* to draw the border using Cairo
*/
void
clutter_rectangle_set_border_width (ClutterRectangle *rectangle,
guint width)
{
ClutterRectanglePrivate *priv;
g_return_if_fail (CLUTTER_IS_RECTANGLE (rectangle));
priv = rectangle->priv;
if (priv->border_width != width)
{
g_object_ref (rectangle);
priv->border_width = width;
if (priv->border_width != 0)
priv->has_border = TRUE;
else
priv->has_border = FALSE;
clutter_actor_queue_redraw (CLUTTER_ACTOR (rectangle));
g_object_notify (G_OBJECT (rectangle), "border-width");
g_object_notify (G_OBJECT (rectangle), "has-border");
g_object_unref (rectangle);
}
}
/**
* clutter_rectangle_get_border_color:
* @rectangle: a #ClutterRectangle
* @color: (out caller-allocates): return location for a #ClutterColor
*
* Gets the color of the border used by @rectangle and places
* it into @color.
*
* Since: 0.2
*
* Deprecated: 1.10: Use #ClutterActor and a #ClutterCanvas to draw
* the border with Cairo
*/
void
clutter_rectangle_get_border_color (ClutterRectangle *rectangle,
ClutterColor *color)
{
ClutterRectanglePrivate *priv;
g_return_if_fail (CLUTTER_IS_RECTANGLE (rectangle));
g_return_if_fail (color != NULL);
priv = rectangle->priv;
color->red = priv->border_color.red;
color->green = priv->border_color.green;
color->blue = priv->border_color.blue;
color->alpha = priv->border_color.alpha;
}
/**
* clutter_rectangle_set_border_color:
* @rectangle: a #ClutterRectangle
* @color: the color of the border
*
* Sets the color of the border used by @rectangle using @color
*
* Deprecated: 1.10: Use #ClutterActor and a #ClutterCanvas to draw
* the border with Cairo
*/
void
clutter_rectangle_set_border_color (ClutterRectangle *rectangle,
const ClutterColor *color)
{
ClutterRectanglePrivate *priv;
g_return_if_fail (CLUTTER_IS_RECTANGLE (rectangle));
g_return_if_fail (color != NULL);
priv = rectangle->priv;
if (priv->border_color.red != color->red ||
priv->border_color.green != color->green ||
priv->border_color.blue != color->blue ||
priv->border_color.alpha != color->alpha)
{
g_object_ref (rectangle);
priv->border_color.red = color->red;
priv->border_color.green = color->green;
priv->border_color.blue = color->blue;
priv->border_color.alpha = color->alpha;
if (clutter_color_equal (&priv->color, &priv->border_color))
priv->has_border = FALSE;
else
priv->has_border = TRUE;
clutter_actor_queue_redraw (CLUTTER_ACTOR (rectangle));
g_object_notify (G_OBJECT (rectangle), "border-color");
g_object_notify (G_OBJECT (rectangle), "has-border");
g_object_unref (rectangle);
}
}

View File

@ -1,117 +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_RECTANGLE_H__
#define __CLUTTER_RECTANGLE_H__
#include <glib-object.h>
#include <clutter/clutter-actor.h>
#include <clutter/clutter-color.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_RECTANGLE (clutter_rectangle_get_type())
#define CLUTTER_RECTANGLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_RECTANGLE, ClutterRectangle))
#define CLUTTER_RECTANGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_RECTANGLE, ClutterRectangleClass))
#define CLUTTER_IS_RECTANGLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_RECTANGLE))
#define CLUTTER_IS_RECTANGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_RECTANGLE))
#define CLUTTER_RECTANGLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_RECTANGLE, ClutterRectangleClass))
typedef struct _ClutterRectangle ClutterRectangle;
typedef struct _ClutterRectangleClass ClutterRectangleClass;
typedef struct _ClutterRectanglePrivate ClutterRectanglePrivate;
/**
* ClutterRectangle:
*
* The #ClutterRectangle structure contains only private data
* and should be accessed using the provided API
*
* Since: 0.2
*/
struct _ClutterRectangle
{
/*< private >*/
ClutterActor parent;
ClutterRectanglePrivate *priv;
};
/**
* ClutterRectangleClass:
*
* The #ClutterRectangleClass structure contains only private data
*
* Since: 0.2
*/
struct _ClutterRectangleClass
{
/*< private >*/
ClutterActorClass parent_class;
/* padding for future expansion */
void (*_clutter_rectangle1) (void);
void (*_clutter_rectangle2) (void);
void (*_clutter_rectangle3) (void);
void (*_clutter_rectangle4) (void);
};
CLUTTER_DEPRECATED
GType clutter_rectangle_get_type (void) G_GNUC_CONST;
CLUTTER_DEPRECATED_FOR(clutter_actor_new)
ClutterActor *clutter_rectangle_new (void);
CLUTTER_DEPRECATED_FOR(clutter_actor_new)
ClutterActor *clutter_rectangle_new_with_color (const ClutterColor *color);
CLUTTER_DEPRECATED_FOR(clutter_actor_get_background_color)
void clutter_rectangle_get_color (ClutterRectangle *rectangle,
ClutterColor *color);
CLUTTER_DEPRECATED_FOR(clutter_actor_set_background_color)
void clutter_rectangle_set_color (ClutterRectangle *rectangle,
const ClutterColor *color);
CLUTTER_DEPRECATED
guint clutter_rectangle_get_border_width (ClutterRectangle *rectangle);
CLUTTER_DEPRECATED
void clutter_rectangle_set_border_width (ClutterRectangle *rectangle,
guint width);
CLUTTER_DEPRECATED
void clutter_rectangle_get_border_color (ClutterRectangle *rectangle,
ClutterColor *color);
CLUTTER_DEPRECATED
void clutter_rectangle_set_border_color (ClutterRectangle *rectangle,
const ClutterColor *color);
G_END_DECLS
#endif /* __CLUTTER_RECTANGLE_H__ */

View File

@ -221,11 +221,6 @@ clutter_nonintrospected_sources = [
clutter_deprecated_headers = [ clutter_deprecated_headers = [
'deprecated/clutter-actor.h', 'deprecated/clutter-actor.h',
'deprecated/clutter-container.h', 'deprecated/clutter-container.h',
'deprecated/clutter-rectangle.h',
]
clutter_deprecated_sources = [
'deprecated/clutter-rectangle.c',
] ]
clutter_backend_sources = [] clutter_backend_sources = []
@ -283,7 +278,6 @@ cally_headers = [
'cally/cally-factory.h', 'cally/cally-factory.h',
'cally/cally.h', 'cally/cally.h',
'cally/cally-main.h', 'cally/cally-main.h',
'cally/cally-rectangle.h',
'cally/cally-root.h', 'cally/cally-root.h',
'cally/cally-stage.h', 'cally/cally-stage.h',
'cally/cally-text.h', 'cally/cally-text.h',
@ -294,7 +288,6 @@ cally_sources = [
'cally/cally-actor.c', 'cally/cally-actor.c',
'cally/cally.c', 'cally/cally.c',
'cally/cally-clone.c', 'cally/cally-clone.c',
'cally/cally-rectangle.c',
'cally/cally-root.c', 'cally/cally-root.c',
'cally/cally-stage.c', 'cally/cally-stage.c',
'cally/cally-text.c', 'cally/cally-text.c',
@ -376,7 +369,6 @@ libmutter_clutter = shared_library(libmutter_clutter_name,
clutter_headers, clutter_headers,
clutter_private_headers, clutter_private_headers,
clutter_nonintrospected_sources, clutter_nonintrospected_sources,
clutter_deprecated_sources,
clutter_deprecated_headers, clutter_deprecated_headers,
clutter_backend_sources, clutter_backend_sources,
clutter_backend_nonintrospected_sources, clutter_backend_nonintrospected_sources,
@ -422,7 +414,6 @@ if have_introspection
clutter_built_headers, clutter_built_headers,
clutter_sources, clutter_sources,
clutter_headers, clutter_headers,
clutter_deprecated_sources,
clutter_deprecated_headers, clutter_deprecated_headers,
], ],
nsversion: libmutter_api_version, nsversion: libmutter_api_version,

View File

@ -40,15 +40,10 @@ clutter_conform_tests_general_tests = [
'units', 'units',
] ]
clutter_conform_tests_deprecated_tests = [
'rectangle',
]
clutter_conform_tests = [] clutter_conform_tests = []
clutter_conform_tests += clutter_conform_tests_actor_tests clutter_conform_tests += clutter_conform_tests_actor_tests
clutter_conform_tests += clutter_conform_tests_classes_tests clutter_conform_tests += clutter_conform_tests_classes_tests
clutter_conform_tests += clutter_conform_tests_general_tests clutter_conform_tests += clutter_conform_tests_general_tests
clutter_conform_tests += clutter_conform_tests_deprecated_tests
test_env = environment() test_env = environment()
test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) test_env.set('G_TEST_SRCDIR', meson.current_source_dir())

View File

@ -1,53 +0,0 @@
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include <clutter/clutter.h>
#include "tests/clutter-test-utils.h"
static void
rectangle_set_size (void)
{
ClutterActor *rect = clutter_rectangle_new ();
/* initial positioning */
g_assert_cmpint (clutter_actor_get_x (rect), ==, 0);
g_assert_cmpint (clutter_actor_get_y (rect), ==, 0);
clutter_actor_set_size (rect, 100, 100);
/* make sure that changing the size does not affect the
* rest of the bounding box
*/
g_assert_cmpint (clutter_actor_get_x (rect), ==, 0);
g_assert_cmpint (clutter_actor_get_y (rect), ==, 0);
g_assert_cmpint (clutter_actor_get_width (rect), ==, 100);
g_assert_cmpint (clutter_actor_get_height (rect), ==, 100);
clutter_actor_destroy (rect);
}
static void
rectangle_set_color (void)
{
ClutterActor *rect = clutter_rectangle_new ();
ClutterColor white = { 255, 255, 255, 255 };
ClutterColor black = { 0, 0, 0, 255 };
ClutterColor check = { 0, };
clutter_rectangle_set_color (CLUTTER_RECTANGLE (rect), &black);
clutter_rectangle_get_color (CLUTTER_RECTANGLE (rect), &check);
g_assert_cmpint (check.blue, ==, black.blue);
clutter_rectangle_set_color (CLUTTER_RECTANGLE (rect), &white);
clutter_rectangle_get_color (CLUTTER_RECTANGLE (rect), &check);
g_assert_cmpint (check.green, ==, white.green);
g_assert_cmpint (clutter_actor_get_opacity (rect), ==, white.alpha);
clutter_actor_destroy (rect);
}
CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/rectangle/set-size", rectangle_set_size)
CLUTTER_TEST_UNIT ("/rectangle/set-color", rectangle_set_color)
)