Commit 420b8014 authored by Daiki Ueno's avatar Daiki Ueno

Revive Clutter support.

parent 9e5fa977
......@@ -147,7 +147,7 @@ AC_MSG_CHECKING([whether you enable Clutter])
AC_ARG_ENABLE(clutter,
AS_HELP_STRING([--enable-clutter=no/yes],
[Enable Clutter user interface default=yes]),,
enable_clutter=yes)
enable_clutter=no)
AC_MSG_RESULT($enable_clutter)
if test x$enable_clutter = xyes; then
......@@ -164,8 +164,7 @@ if test x$enable_clutter = xyes; then
AC_DEFINE_UNQUOTED([NEED_SWAP_EVENT_WORKAROUND], $need_swap_event_workaround,
[Define if GLX_INTEL_swap_event work around is needed])
fi
dnl AM_CONDITIONAL(HAVE_CLUTTER, [test x$enable_clutter = xyes])
AM_CONDITIONAL(HAVE_CLUTTER, [false])
AM_CONDITIONAL(HAVE_CLUTTER, [test x$enable_clutter = xyes])
GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
......
......@@ -88,12 +88,14 @@ libeek_clutter_public_headers = \
libeek_clutter_private_headers = \
$(srcdir)/eek-clutter-section.h \
$(srcdir)/eek-clutter-key.h
$(srcdir)/eek-clutter-key.h \
$(srcdir)/eek-clutter-renderer.h
libeek_clutter_sources = \
$(srcdir)/eek-clutter-keyboard.c \
$(srcdir)/eek-clutter-section.c \
$(srcdir)/eek-clutter-key.c
$(srcdir)/eek-clutter-key.c \
$(srcdir)/eek-clutter-renderer.c
libeek_clutter_la_SOURCES = $(libeek_clutter_sources)
libeek_clutter_la_CFLAGS = $(CLUTTER_CFLAGS)
......
/*
* Copyright (C) 2010 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010 Red Hat, Inc.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include <string.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "eek-clutter-drawing-context.h"
G_DEFINE_TYPE (EekClutterDrawingContext, eek_clutter_drawing_context,
G_TYPE_INITIALLY_UNOWNED);
#define EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEK_TYPE_CLUTTER_DRAWING_CONTEXT, EekClutterDrawingContextPrivate))
struct _EekClutterDrawingContextPrivate
{
/* outline pointer -> ClutterTexture */
GHashTable *outline_textures;
/* keysym category -> PangoFontDescription * */
PangoFontDescription *category_fonts[EEK_KEYSYM_CATEGORY_LAST];
};
static void
eek_clutter_drawing_context_dispose (GObject *object)
{
EekClutterDrawingContextPrivate *priv =
EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(object);
if (priv->outline_textures) {
g_hash_table_unref (priv->outline_textures);
priv->outline_textures = NULL;
}
}
static void
eek_clutter_drawing_context_finalize (GObject *object)
{
EekClutterDrawingContextPrivate *priv =
EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(object);
gint i;
for (i = 0; i < EEK_KEYSYM_CATEGORY_LAST; i++)
pango_font_description_free (priv->category_fonts[i]);
}
static void
eek_clutter_drawing_context_class_init (EekClutterDrawingContextClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (gobject_class,
sizeof (EekClutterDrawingContextPrivate));
gobject_class->finalize = eek_clutter_drawing_context_finalize;
gobject_class->dispose = eek_clutter_drawing_context_dispose;
}
static void
eek_clutter_drawing_context_init (EekClutterDrawingContext *self)
{
EekClutterDrawingContextPrivate *priv;
priv = self->priv = EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(self);
priv->outline_textures = g_hash_table_new (g_direct_hash, g_direct_equal);
memset (priv->category_fonts, 0, sizeof *priv->category_fonts);
}
void
eek_clutter_drawing_context_set_outline_texture
(EekClutterDrawingContext *context,
EekOutline *outline,
ClutterActor *texture)
{
EekClutterDrawingContextPrivate *priv =
EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(context);
g_return_if_fail (priv);
g_hash_table_insert (context->priv->outline_textures, outline, texture);
}
ClutterActor *
eek_clutter_drawing_context_get_outline_texture
(EekClutterDrawingContext *context,
EekOutline *outline)
{
EekClutterDrawingContextPrivate *priv =
EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(context);
g_return_val_if_fail (priv, NULL);
return g_hash_table_lookup (context->priv->outline_textures, outline);
}
void
eek_clutter_drawing_context_set_category_font
(EekClutterDrawingContext *context,
EekKeysymCategory category,
PangoFontDescription *font)
{
EekClutterDrawingContextPrivate *priv =
EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(context);
g_return_if_fail (priv);
priv->category_fonts[category] = pango_font_description_copy (font);
}
PangoFontDescription *
eek_clutter_drawing_context_get_category_font
(EekClutterDrawingContext *context,
EekKeysymCategory category)
{
EekClutterDrawingContextPrivate *priv =
EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(context);
g_return_val_if_fail (priv, NULL);
return priv->category_fonts[category];
}
EekClutterDrawingContext *
eek_clutter_drawing_context_new (void)
{
return g_object_new (EEK_TYPE_CLUTTER_DRAWING_CONTEXT, NULL);
}
/*
* Copyright (C) 2010 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010 Red Hat, Inc.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef EEK_CLUTTER_DRAWING_CONTEXT_H
#define EEK_CLUTTER_DRAWING_CONTEXT_H 1
#include <clutter/clutter.h>
#include <pango/pango.h>
#include "eek-keysym.h"
#include "eek-types.h"
G_BEGIN_DECLS
#define EEK_TYPE_CLUTTER_DRAWING_CONTEXT (eek_clutter_drawing_context_get_type())
#define EEK_CLUTTER_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEK_TYPE_CLUTTER_DRAWING_CONTEXT, EekClutterDrawingContext))
#define EEK_CLUTTER_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEK_TYPE_CLUTTER_DRAWING_CONTEXT, EekClutterDrawingContextClass))
#define EEK_IS_CLUTTER_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEK_TYPE_CLUTTER_DRAWING_CONTEXT))
#define EEK_IS_CLUTTER_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEK_TYPE_CLUTTER_DRAWING_CONTEXT))
#define EEK_CLUTTER_DRAWING_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEK_TYPE_CLUTTER_DRAWING_CONTEXT, EekClutterDrawingContextClass))
typedef struct _EekClutterDrawingContext EekClutterDrawingContext;
typedef struct _EekClutterDrawingContextClass EekClutterDrawingContextClass;
typedef struct _EekClutterDrawingContextPrivate EekClutterDrawingContextPrivate;
struct _EekClutterDrawingContext
{
/*< private >*/
GInitiallyUnowned parent;
/*< private >*/
EekClutterDrawingContextPrivate *priv;
};
struct _EekClutterDrawingContextClass
{
/*< private >*/
GInitiallyUnownedClass parent_class;
/*< private >*/
/* padding */
gpointer pdummy[24];
};
GType eek_clutter_drawing_context_get_type
(void) G_GNUC_CONST;
EekClutterDrawingContext *eek_clutter_drawing_context_new
(void);
void eek_clutter_drawing_context_set_outline_texture
(EekClutterDrawingContext *context,
EekOutline *outline,
ClutterActor *texture);
ClutterActor *eek_clutter_drawing_context_get_outline_texture
(EekClutterDrawingContext *context,
EekOutline *outline);
void eek_clutter_drawing_context_set_category_font
(EekClutterDrawingContext *context,
EekKeysymCategory category,
PangoFontDescription *fonts);
PangoFontDescription *eek_clutter_drawing_context_get_category_font
(EekClutterDrawingContext *context,
EekKeysymCategory category);
G_END_DECLS
#endif /* EEK_CLUTTER_DRAWING_CONTEXT_H */
This diff is collapsed.
/*
* Copyright (C) 2010 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010 Red Hat, Inc.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef EEK_CLUTTER_KEY_ACTOR_H
#define EEK_CLUTTER_KEY_ACTOR_H 1
#include <clutter/clutter.h>
#include "eek-clutter-drawing-context.h"
#include "eek-key.h"
G_BEGIN_DECLS
#define EEK_TYPE_CLUTTER_KEY_ACTOR (eek_clutter_key_actor_get_type())
#define EEK_CLUTTER_KEY_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEK_TYPE_CLUTTER_KEY_ACTOR, EekClutterKeyActor))
#define EEK_CLUTTER_KEY_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEK_TYPE_CLUTTER_KEY_ACTOR, EekClutterKeyActorClass))
#define EEK_IS_CLUTTER_KEY_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEK_TYPE_CLUTTER_KEY_ACTOR))
#define EEK_IS_CLUTTER_KEY_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEK_TYPE_CLUTTER_KEY_ACTOR))
#define EEK_CLUTTER_KEY_ACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEK_TYPE_CLUTTER_KEY_ACTOR, EekClutterKeyActorClass))
typedef struct _EekClutterKeyActor EekClutterKeyActor;
typedef struct _EekClutterKeyActorClass EekClutterKeyActorClass;
typedef struct _EekClutterKeyActorPrivate EekClutterKeyActorPrivate;
struct _EekClutterKeyActor
{
/*< private >*/
ClutterGroup parent;
/*< private >*/
EekClutterKeyActorPrivate *priv;
};
struct _EekClutterKeyActorClass
{
/*< private >*/
ClutterGroupClass parent_class;
/* signals */
void (* pressed) (EekClutterKeyActor *self);
void (* released) (EekClutterKeyActor *self);
/*< private >*/
/* padding */
gpointer pdummy[24];
};
GType eek_clutter_key_actor_get_type
(void) G_GNUC_CONST;
ClutterActor *eek_clutter_key_actor_new (EekClutterDrawingContext *context,
EekKey *key);
G_END_DECLS
#endif /* EEK_CLUTTER_KEY_ACTOR_H */
......@@ -23,98 +23,144 @@
#endif /* HAVE_CONFIG_H */
#include "eek-clutter-key.h"
#include "eek-clutter-key-actor.h"
G_DEFINE_TYPE (EekClutterKey, eek_clutter_key, EEK_TYPE_KEY);
G_DEFINE_TYPE (EekClutterKey, eek_clutter_key, CLUTTER_TYPE_ACTOR);
#define EEK_CLUTTER_KEY_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEK_TYPE_CLUTTER_KEY, EekClutterKeyPrivate))
struct _EekClutterKeyPrivate
{
EekClutterDrawingContext *context;
ClutterActor *actor;
EekKey *key;
EekClutterRenderer *renderer;
};
static void
eek_clutter_key_real_set_name (EekElement *self,
const gchar *name)
eek_clutter_key_dispose (GObject *object)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(object);
EEK_ELEMENT_CLASS (eek_clutter_key_parent_class)->
set_name (self, name);
if (priv->renderer) {
g_object_unref (priv->renderer);
priv->renderer = NULL;
}
if (priv->key && g_object_is_floating (priv->key)) {
g_object_unref (priv->key);
priv->key = NULL;
}
if (priv->actor)
clutter_actor_set_name (CLUTTER_ACTOR(priv->actor), name);
G_OBJECT_CLASS (eek_clutter_key_parent_class)->dispose (object);
}
static void
eek_clutter_key_real_set_bounds (EekElement *self,
EekBounds *bounds)
eek_clutter_key_real_paint (ClutterActor *self)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
EEK_ELEMENT_CLASS (eek_clutter_key_parent_class)->
set_bounds (self, bounds);
if (priv->actor) {
clutter_actor_set_position (priv->actor, bounds->x, bounds->y);
clutter_actor_set_size (priv->actor, bounds->width, bounds->height);
}
eek_clutter_renderer_render_key (priv->renderer, self, priv->key);
}
static void
eek_clutter_key_real_pressed (EekKey *key)
eek_clutter_key_real_get_preferred_width (ClutterActor *self,
gfloat for_height,
gfloat *min_width_p,
gfloat *natural_width_p)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(key);
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
EekBounds bounds;
gdouble scale;
if (priv->actor)
g_signal_emit_by_name (priv->actor, "pressed");
scale = eek_renderer_get_scale (EEK_RENDERER(priv->renderer));
eek_element_get_bounds (EEK_ELEMENT(priv->key), &bounds);
*min_width_p = 0.0f;
*natural_width_p = bounds.width * scale;
}
static void
eek_clutter_key_real_released (EekKey *key)
eek_clutter_key_real_get_preferred_height (ClutterActor *self,
gfloat for_width,
gfloat *min_height_p,
gfloat *natural_height_p)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(key);
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
EekBounds bounds;
gdouble scale;
if (priv->actor)
g_signal_emit_by_name (priv->actor, "released");
scale = eek_renderer_get_scale (EEK_RENDERER(priv->renderer));
eek_element_get_bounds (EEK_ELEMENT(priv->key), &bounds);
*min_height_p = 0.0f;
*natural_height_p = bounds.height * scale;
}
static void
eek_clutter_key_dispose (GObject *object)
eek_clutter_key_real_allocate (ClutterActor *self,
const ClutterActorBox *box,
ClutterAllocationFlags flags)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(object);
CLUTTER_ACTOR_CLASS (eek_clutter_key_parent_class)->
allocate (self, box, flags);
}
if (priv->context) {
g_object_unref (priv->context);
priv->context = NULL;
}
if (priv->actor) {
g_object_unref (priv->actor);
priv->actor = NULL;
}
G_OBJECT_CLASS (eek_clutter_key_parent_class)->dispose (object);
static gboolean
eek_clutter_key_real_button_press_event (ClutterActor *self,
ClutterButtonEvent *event)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
g_signal_emit_by_name (priv->key, "pressed");
return TRUE;
}
static gboolean
eek_clutter_key_real_button_release_event (ClutterActor *self,
ClutterButtonEvent *event)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
g_signal_emit_by_name (priv->key, "released");
return TRUE;
}
static gboolean
eek_clutter_key_real_leave_event (ClutterActor *self,
ClutterCrossingEvent *event)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
if (eek_key_is_pressed (priv->key))
g_signal_emit_by_name (priv->key, "released");
return TRUE;
}
static void
eek_clutter_key_class_init (EekClutterKeyClass *klass)
{
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
EekElementClass *element_class = EEK_ELEMENT_CLASS (klass);
EekKeyClass *key_class = EEK_KEY_CLASS (klass);
g_type_class_add_private (gobject_class,
sizeof (EekClutterKeyPrivate));
element_class->set_name = eek_clutter_key_real_set_name;
element_class->set_bounds = eek_clutter_key_real_set_bounds;
gobject_class->dispose = eek_clutter_key_dispose;
actor_class->paint = eek_clutter_key_real_paint;
actor_class->get_preferred_width =
eek_clutter_key_real_get_preferred_width;
actor_class->get_preferred_height =
eek_clutter_key_real_get_preferred_height;
actor_class->allocate = eek_clutter_key_real_allocate;
/* signals */
key_class->pressed = eek_clutter_key_real_pressed;
key_class->released = eek_clutter_key_real_released;
actor_class->button_press_event =
eek_clutter_key_real_button_press_event;
actor_class->button_release_event =
eek_clutter_key_real_button_release_event;
actor_class->leave_event =
eek_clutter_key_real_leave_event;
gobject_class->dispose = eek_clutter_key_dispose;
}
static void
......@@ -122,33 +168,73 @@ eek_clutter_key_init (EekClutterKey *self)
{
EekClutterKeyPrivate *priv;
priv = self->priv = EEK_CLUTTER_KEY_GET_PRIVATE (self);
priv->actor = NULL;
priv->key = NULL;
priv->renderer = NULL;
}
ClutterActor *
eek_clutter_key_get_actor (EekClutterKey *key)
static void
on_pressed (EekKey *key, gpointer user_data)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(key);
ClutterActor *actor = user_data, *parent;
parent = clutter_actor_get_parent (actor);
clutter_actor_raise_top (parent);
clutter_actor_raise_top (actor);
clutter_actor_set_scale_with_gravity (actor,
1.0,
1.0,
CLUTTER_GRAVITY_CENTER);
clutter_actor_animate (actor, CLUTTER_EASE_IN_SINE, 150,
"scale-x", 1.5,
"scale-y", 1.5,
NULL);
}
if (!priv->actor) {
g_return_val_if_fail (priv->context, NULL);
priv->actor = eek_clutter_key_actor_new (priv->context, EEK_KEY(key));
g_object_ref_sink (priv->actor);
}
return priv->actor;
static void
on_released (EekKey *key, gpointer user_data)
{
ClutterActor *actor = user_data, *parent;
parent = clutter_actor_get_parent (actor);
clutter_actor_raise_top (parent);
clutter_actor_raise_top (actor);
clutter_actor_set_scale_with_gravity (actor,
1.5,
1.5,
CLUTTER_GRAVITY_CENTER);
clutter_actor_animate (actor, CLUTTER_EASE_OUT_SINE, 150,
"scale-x", 1.0,
"scale-y", 1.0,
NULL);
}
EekKey *
eek_clutter_key_new (EekClutterDrawingContext *context, gint column, gint row)
ClutterActor *
eek_clutter_key_new (EekKey *key, EekClutterRenderer *renderer)
{
EekClutterKey *key;
g_return_val_if_fail (context, NULL);
key = g_object_new (EEK_TYPE_CLUTTER_KEY,
"column", column,
"row", row,
NULL);
key->priv->context = context;
g_object_ref_sink (key->priv->context);
return EEK_KEY(key);
ClutterActor *actor;
EekClutterKeyPrivate *priv;
EekBounds bounds;
gdouble scale;
actor = g_object_new (EEK_TYPE_CLUTTER_KEY, NULL);
priv = EEK_CLUTTER_KEY_GET_PRIVATE(actor);
priv->key = g_object_ref_sink (key);
priv->renderer = g_object_ref (renderer);
eek_element_get_bounds (EEK_ELEMENT(key), &bounds);
scale = eek_renderer_get_scale (EEK_RENDERER(priv->renderer));
clutter_actor_set_position (actor,
bounds.x * scale,
bounds.y * scale);
clutter_actor_set_reactive (actor, TRUE);
g_signal_connect (priv->key, "pressed",
G_CALLBACK(on_pressed), actor);
g_signal_connect (priv->key, "released",
G_CALLBACK(on_released), actor);
return actor;
}
......@@ -21,8 +21,8 @@
#define EEK_CLUTTER_KEY_H 1
#include <clutter/clutter.h>
#include "eek-clutter-drawing-context.h"
#include "eek-key.h"
#include "eek-clutter-renderer.h"
G_BEGIN_DECLS
#define EEK_TYPE_CLUTTER_KEY (eek_clutter_key_get_type())
......@@ -39,7 +39,7 @@ typedef struct _EekClutterKeyPrivate EekClutterKeyPrivate;
struct _EekClutterKey
{
/*< private >*/
EekKey parent;
ClutterActor parent;
/*< private >*/
EekClutterKeyPrivate *priv;
......@@ -48,18 +48,16 @@ struct _EekClutterKey
struct _EekClutterKeyClass
{
/*< private >*/
EekKeyClass parent_class;
ClutterActorClass parent_class;
/*< private >*/
/* padding */
gpointer pdummy[24];
};
GType eek_clutter_key_get_type (void) G_GNUC_CONST;
EekKey * eek_clutter_key_new (EekClutterDrawingContext *context,
gint column,
gint row);
ClutterActor *eek_clutter_key_get_actor (EekClutterKey *key);
GType eek_clutter_key_get_type (void) G_GNUC_CONST;
ClutterActor *eek_clutter_key_new (EekKey *key,
EekClutterRenderer *renderer);
G_END_DECLS
#endif /* EEK_CLUTTER_KEY_H */
This diff is collapsed.
......@@ -20,7 +20,7 @@
#ifndef EEK_CLUTTER_KEYBOARD_H
#define EEK_CLUTTER_KEYBOARD_H 1
#include "eek-clutter-section.h"
#include <clutter/clutter.h>
#include "eek-keyboard.h"
G_BEGIN_DECLS
......@@ -38,7 +38,7 @@ typedef struct _EekClutterKeyboardPrivate EekClutterKeyboardPrivate;
struct _EekClutterKeyboard
{
/*< private >*/
EekKeyboard parent;
ClutterGroup parent;
EekClutterKeyboardPrivate *priv;
};
......@@ -46,7 +46,7 @@ struct _EekClutterKeyboard
struct _EekClutterKeyboardClass
{
/*< private >*/
EekKeyboardClass parent_class;
ClutterGroupClass parent_class;
/*< private >*/
/* padding */
......@@ -54,8 +54,7 @@ struct _EekClutterKeyboardClass
};
GType eek_clutter_keyboard_get_type (void) G_GNUC_CONST;
EekKeyboard *eek_clutter_keyboard_new (void);
ClutterActor *eek_clutter_keyboard_get_actor (EekClutterKeyboard *keyboard);
ClutterActor *eek_clutter_keyboard_new (EekKeyboard *keyboard);
G_END_DECLS
#endif /* EEK_CLUTTER_KEYBOARD_H */
#include <string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <cogl/cogl.h>
#include <cogl/cogl-pango.h>
#include <clutter/clutter.h>
#include "eek-clutter-renderer.h"
#include "eek-key.h"
G_DEFINE_TYPE (EekClutterRenderer, eek_clutter_renderer, EEK_TYPE_RENDERER);
#define EEK_CLUTTER_RENDERER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEK_TYPE_CLUTTER_RENDERER, EekClutterRendererPrivate))
struct _EekClutterRendererPrivate
{
GHashTable *outline_texture_cache;
};
/* This routine is copied from librsvg:
Copyright © 2005 Dom Lachowicz <cinamod@hotmail.com>
Copyright © 2005 Caleb Moore <c.moore@student.unsw.edu.au>
Copyright © 2005 Red Hat, Inc.
*/
static void
cairo_pixels_to_pixbuf (guint8 *pixels,
int rowstride,
int height)
{
int row;
/* un-premultiply data */
for (row = 0; row < height; row++) {
guint8 *row_data = (pixels + (row * rowstride));
int i;
for (i = 0; i < rowstride; i += 4) {
guint8 *b = &row_data[i];
guint32 pixel;
guint8 alpha;
memcpy (&pixel, b, sizeof (guint32));
alpha = (pixel & 0xff000000) >> 24;
if (alpha == 0) {
b[0] = b[1] = b[2] = b[3] = 0;
} else {
b[0] = (((pixel & 0xff0000) >> 16) * 255 + alpha / 2) / alpha;
b[1] = (((pixel & 0x00ff00) >> 8) * 255 + alpha / 2) / alpha;