Fix build against 2.91.5.
This commit is contained in:
@ -166,7 +166,7 @@ Eek_0_1_gir_LIBS = libeek.la
|
|||||||
Eek_0_1_gir_FILES = $(libeek_la_SOURCES)
|
Eek_0_1_gir_FILES = $(libeek_la_SOURCES)
|
||||||
|
|
||||||
EekGtk-0.1.gir: libeek-gtk.la Eek-0.1.gir
|
EekGtk-0.1.gir: libeek-gtk.la Eek-0.1.gir
|
||||||
EekGtk_0_1_gir_INCLUDES = GObject-2.0 Gtk-2.0 Eek-0.1
|
EekGtk_0_1_gir_INCLUDES = GObject-2.0 Gtk-3.0 Eek-0.1
|
||||||
EekGtk_0_1_gir_CFLAGS = $(libeek_gtk_la_CFLAGS)
|
EekGtk_0_1_gir_CFLAGS = $(libeek_gtk_la_CFLAGS)
|
||||||
EekGtk_0_1_gir_LIBS = libeek-gtk.la
|
EekGtk_0_1_gir_LIBS = libeek-gtk.la
|
||||||
EekGtk_0_1_gir_FILES = $(libeek_gtk_la_SOURCES)
|
EekGtk_0_1_gir_FILES = $(libeek_gtk_la_SOURCES)
|
||||||
|
|||||||
@ -41,20 +41,23 @@ G_DEFINE_TYPE (EekGtkKeyboard, eek_gtk_keyboard, EEK_TYPE_KEYBOARD);
|
|||||||
#define EEK_GTK_KEYBOARD_GET_PRIVATE(obj) \
|
#define EEK_GTK_KEYBOARD_GET_PRIVATE(obj) \
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEK_TYPE_GTK_KEYBOARD, EekGtkKeyboardPrivate))
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEK_TYPE_GTK_KEYBOARD, EekGtkKeyboardPrivate))
|
||||||
|
|
||||||
#define SCALE 1.5
|
enum {
|
||||||
|
KEY_SURFACE_NORMAL = 0,
|
||||||
|
KEY_SURFACE_LARGE,
|
||||||
|
KEY_SURFACE_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
static const gdouble key_surface_scale[KEY_SURFACE_LAST] = {
|
||||||
|
1.0,
|
||||||
|
1.5
|
||||||
|
};
|
||||||
|
|
||||||
struct _EekGtkKeyboardPrivate
|
struct _EekGtkKeyboardPrivate
|
||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
|
||||||
/* pixmap of entire keyboard (for expose event) */
|
cairo_surface_t *keyboard_surface;
|
||||||
GdkPixmap *pixmap;
|
GHashTable *key_surfaces;
|
||||||
|
|
||||||
/* mapping from outline pointer to pixmap */
|
|
||||||
GHashTable *outline_textures;
|
|
||||||
|
|
||||||
/* mapping from outline pointer to large pixmap */
|
|
||||||
GHashTable *large_outline_textures;
|
|
||||||
|
|
||||||
PangoFontDescription *fonts[EEK_KEYSYM_CATEGORY_LAST];
|
PangoFontDescription *fonts[EEK_KEYSYM_CATEGORY_LAST];
|
||||||
|
|
||||||
@ -63,7 +66,7 @@ struct _EekGtkKeyboardPrivate
|
|||||||
EekKey *key;
|
EekKey *key;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void prepare_keyboard_pixmap (EekGtkKeyboard *keyboard);
|
static void prepare_keyboard_surface (EekGtkKeyboard *keyboard);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eek_gtk_keyboard_real_set_keysym_index (EekKeyboard *self,
|
eek_gtk_keyboard_real_set_keysym_index (EekKeyboard *self,
|
||||||
@ -79,21 +82,26 @@ eek_gtk_keyboard_real_set_keysym_index (EekKeyboard *self,
|
|||||||
EekGtkKeyboard *keyboard = EEK_GTK_KEYBOARD(self);
|
EekGtkKeyboard *keyboard = EEK_GTK_KEYBOARD(self);
|
||||||
EekGtkKeyboardPrivate *priv =
|
EekGtkKeyboardPrivate *priv =
|
||||||
EEK_GTK_KEYBOARD_GET_PRIVATE(keyboard);
|
EEK_GTK_KEYBOARD_GET_PRIVATE(keyboard);
|
||||||
|
GtkStyle *style;
|
||||||
GtkStateType state;
|
GtkStateType state;
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
if (!priv->widget || !gtk_widget_get_realized (priv->widget))
|
if (!priv->widget || !gtk_widget_get_realized (priv->widget))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
prepare_keyboard_pixmap (keyboard);
|
prepare_keyboard_surface (keyboard);
|
||||||
state = gtk_widget_get_state (GTK_WIDGET (priv->widget));
|
gtk_widget_get_allocation (priv->widget, &allocation);
|
||||||
gtk_widget_get_allocation (GTK_WIDGET (priv->widget), &allocation);
|
|
||||||
gdk_draw_drawable (gtk_widget_get_window (priv->widget),
|
cr = gdk_cairo_create (GDK_DRAWABLE (gtk_widget_get_window (priv->widget)));
|
||||||
gtk_widget_get_style (priv->widget)->fg_gc[state],
|
style = gtk_widget_get_style (priv->widget);
|
||||||
priv->pixmap,
|
state = gtk_widget_get_state (priv->widget);
|
||||||
0, 0,
|
gdk_cairo_set_source_color (cr, &style->fg[state]);
|
||||||
0, 0,
|
|
||||||
allocation.width, allocation.height);
|
cairo_set_source_surface (cr, priv->keyboard_surface, 0, 0);
|
||||||
|
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
|
||||||
|
cairo_fill (cr);
|
||||||
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +123,7 @@ eek_gtk_keyboard_finalize (GObject *object)
|
|||||||
EekGtkKeyboardPrivate *priv = EEK_GTK_KEYBOARD_GET_PRIVATE(object);
|
EekGtkKeyboardPrivate *priv = EEK_GTK_KEYBOARD_GET_PRIVATE(object);
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
g_hash_table_unref (priv->outline_textures);
|
g_hash_table_unref (priv->key_surfaces);
|
||||||
g_hash_table_unref (priv->large_outline_textures);
|
|
||||||
|
|
||||||
for (i = 0; i < EEK_KEYSYM_CATEGORY_LAST; i++)
|
for (i = 0; i < EEK_KEYSYM_CATEGORY_LAST; i++)
|
||||||
pango_font_description_free (priv->fonts[i]);
|
pango_font_description_free (priv->fonts[i]);
|
||||||
@ -137,6 +144,17 @@ eek_gtk_keyboard_class_init (EekGtkKeyboardClass *klass)
|
|||||||
gobject_class->finalize = eek_gtk_keyboard_finalize;
|
gobject_class->finalize = eek_gtk_keyboard_finalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
key_surface_free (gpointer user_data)
|
||||||
|
{
|
||||||
|
cairo_surface_t **key_surfaces = user_data;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
for (i = 0; i < KEY_SURFACE_LAST; i++)
|
||||||
|
cairo_surface_destroy (key_surfaces[i]);
|
||||||
|
g_slice_free1 (sizeof (cairo_surface_t *) * KEY_SURFACE_LAST, key_surfaces);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eek_gtk_keyboard_init (EekGtkKeyboard *self)
|
eek_gtk_keyboard_init (EekGtkKeyboard *self)
|
||||||
{
|
{
|
||||||
@ -144,17 +162,12 @@ eek_gtk_keyboard_init (EekGtkKeyboard *self)
|
|||||||
|
|
||||||
priv = self->priv = EEK_GTK_KEYBOARD_GET_PRIVATE(self);
|
priv = self->priv = EEK_GTK_KEYBOARD_GET_PRIVATE(self);
|
||||||
priv->widget = NULL;
|
priv->widget = NULL;
|
||||||
priv->pixmap = NULL;
|
priv->keyboard_surface = NULL;
|
||||||
priv->outline_textures =
|
priv->key_surfaces =
|
||||||
g_hash_table_new_full (g_direct_hash,
|
g_hash_table_new_full (g_direct_hash,
|
||||||
g_direct_equal,
|
g_direct_equal,
|
||||||
NULL,
|
NULL,
|
||||||
g_object_unref);
|
key_surface_free);
|
||||||
priv->large_outline_textures =
|
|
||||||
g_hash_table_new_full (g_direct_hash,
|
|
||||||
g_direct_equal,
|
|
||||||
NULL,
|
|
||||||
g_object_unref);
|
|
||||||
memset (priv->fonts, 0, sizeof priv->fonts);
|
memset (priv->fonts, 0, sizeof priv->fonts);
|
||||||
priv->scale = 1.0;
|
priv->scale = 1.0;
|
||||||
priv->key = NULL;
|
priv->key = NULL;
|
||||||
@ -192,7 +205,7 @@ prepare_keyboard_pixmap_key_callback (EekElement *element,
|
|||||||
EekKey *key = EEK_KEY(element);
|
EekKey *key = EEK_KEY(element);
|
||||||
EekBounds bounds;
|
EekBounds bounds;
|
||||||
EekOutline *outline;
|
EekOutline *outline;
|
||||||
GdkPixmap *texture;
|
cairo_surface_t **key_surfaces;
|
||||||
|
|
||||||
eek_element_get_bounds (element, &bounds);
|
eek_element_get_bounds (element, &bounds);
|
||||||
|
|
||||||
@ -202,26 +215,34 @@ prepare_keyboard_pixmap_key_callback (EekElement *element,
|
|||||||
context->keyboard);
|
context->keyboard);
|
||||||
|
|
||||||
outline = eek_key_get_outline (key);
|
outline = eek_key_get_outline (key);
|
||||||
texture = g_hash_table_lookup (priv->outline_textures, outline);
|
key_surfaces = g_hash_table_lookup (priv->key_surfaces, outline);
|
||||||
if (!texture) {
|
if (!key_surfaces) {
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
gint i;
|
||||||
|
|
||||||
texture =
|
key_surfaces = g_slice_alloc (sizeof (cairo_surface_t *) *
|
||||||
gdk_pixmap_new (gtk_widget_get_window (GTK_WIDGET (priv->widget)),
|
KEY_SURFACE_LAST);
|
||||||
bounds.width, bounds.height, -1);
|
for (i = 0; i < KEY_SURFACE_LAST; i++) {
|
||||||
cr = gdk_cairo_create (GDK_DRAWABLE (texture));
|
gdouble scale = key_surface_scale[i];
|
||||||
|
key_surfaces[i] = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||||
|
bounds.width * scale,
|
||||||
|
bounds.height * scale);
|
||||||
|
cr = cairo_create (key_surfaces[i]);
|
||||||
|
cairo_scale (cr, priv->scale * scale, priv->scale * scale);
|
||||||
gdk_cairo_set_source_color (cr, context->bg);
|
gdk_cairo_set_source_color (cr, context->bg);
|
||||||
cairo_rectangle (cr, 0, 0, bounds.width, bounds.height);
|
cairo_rectangle (cr, 0, 0, bounds.width, bounds.height);
|
||||||
gdk_cairo_set_source_color (cr, context->fg);
|
gdk_cairo_set_source_color (cr, context->fg);
|
||||||
eek_draw_outline (cr, outline);
|
eek_draw_outline (cr, outline);
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
g_hash_table_insert (priv->outline_textures, outline, texture);
|
}
|
||||||
|
|
||||||
|
g_hash_table_insert (priv->key_surfaces, outline, key_surfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_save (context->cr);
|
cairo_save (context->cr);
|
||||||
cairo_translate (context->cr, bounds.x, bounds.y);
|
|
||||||
|
|
||||||
gdk_cairo_set_source_pixmap (context->cr, texture, 0, 0);
|
cairo_translate (context->cr, bounds.x, bounds.y);
|
||||||
|
cairo_set_source_surface (context->cr, key_surfaces[0], 0, 0);
|
||||||
cairo_rectangle (context->cr, 0, 0, bounds.width, bounds.height);
|
cairo_rectangle (context->cr, 0, 0, bounds.width, bounds.height);
|
||||||
cairo_fill (context->cr);
|
cairo_fill (context->cr);
|
||||||
|
|
||||||
@ -254,172 +275,167 @@ prepare_keyboard_pixmap_section_callback (EekElement *element,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drawing_context_init (DrawingContext *context, EekGtkKeyboard *keyboard)
|
drawing_context_init (DrawingContext *context,
|
||||||
|
cairo_t *cr,
|
||||||
|
EekGtkKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
EekGtkKeyboardPrivate *priv = keyboard->priv;
|
EekGtkKeyboardPrivate *priv = keyboard->priv;
|
||||||
|
GtkStyle *style;
|
||||||
GtkStateType state;
|
GtkStateType state;
|
||||||
|
|
||||||
state = gtk_widget_get_state (GTK_WIDGET (priv->widget));
|
context->cr = cr;
|
||||||
context->keyboard = keyboard;
|
context->keyboard = keyboard;
|
||||||
context->fg = >k_widget_get_style (GTK_WIDGET (priv->widget))->fg[state];
|
|
||||||
context->bg = >k_widget_get_style (GTK_WIDGET (priv->widget))->bg[state];
|
style = gtk_widget_get_style (priv->widget);
|
||||||
|
state = gtk_widget_get_state (priv->widget);
|
||||||
|
context->fg = &style->fg[state];
|
||||||
|
context->bg = &style->bg[state];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
prepare_keyboard_pixmap (EekGtkKeyboard *keyboard)
|
prepare_keyboard_surface (EekGtkKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
EekGtkKeyboardPrivate *priv = keyboard->priv;
|
EekGtkKeyboardPrivate *priv = keyboard->priv;
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
|
GtkStyle *style;
|
||||||
GtkStateType state;
|
GtkStateType state;
|
||||||
DrawingContext context;
|
DrawingContext context;
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
gtk_widget_get_allocation (GTK_WIDGET (priv->widget), &allocation);
|
gtk_widget_get_allocation (priv->widget, &allocation);
|
||||||
priv->pixmap =
|
priv->keyboard_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||||
gdk_pixmap_new (gtk_widget_get_window (GTK_WIDGET (priv->widget)),
|
allocation.width,
|
||||||
allocation.width, allocation.height, -1);
|
allocation.height);
|
||||||
|
|
||||||
/* blank background */
|
/* blank background */
|
||||||
state = gtk_widget_get_state (GTK_WIDGET (priv->widget));
|
cr = cairo_create (priv->keyboard_surface);
|
||||||
gdk_draw_rectangle
|
cairo_scale (cr, priv->scale, priv->scale);
|
||||||
(priv->pixmap,
|
|
||||||
gtk_widget_get_style (GTK_WIDGET(priv->widget))->base_gc[state],
|
style = gtk_widget_get_style (priv->widget);
|
||||||
TRUE,
|
state = gtk_widget_get_state (priv->widget);
|
||||||
0, 0, allocation.width, allocation.height);
|
gdk_cairo_set_source_color (cr, &style->base[state]);
|
||||||
|
|
||||||
|
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
|
||||||
|
cairo_fill (cr);
|
||||||
|
|
||||||
/* draw sections on the canvas */
|
/* draw sections on the canvas */
|
||||||
drawing_context_init (&context, keyboard);
|
drawing_context_init (&context, cr, keyboard);
|
||||||
context.cr = gdk_cairo_create (GDK_DRAWABLE (priv->pixmap));
|
|
||||||
cairo_scale (context.cr, priv->scale, priv->scale);
|
|
||||||
eek_container_foreach_child (EEK_CONTAINER(keyboard),
|
eek_container_foreach_child (EEK_CONTAINER(keyboard),
|
||||||
prepare_keyboard_pixmap_section_callback,
|
prepare_keyboard_pixmap_section_callback,
|
||||||
&context);
|
&context);
|
||||||
cairo_destroy (context.cr);
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
on_expose_event (GtkWidget *widget,
|
on_draw (GtkWidget *widget,
|
||||||
GdkEventExpose *event,
|
cairo_t *cr,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
EekGtkKeyboard *keyboard = user_data;
|
EekGtkKeyboard *keyboard = user_data;
|
||||||
EekGtkKeyboardPrivate *priv =
|
EekGtkKeyboardPrivate *priv =
|
||||||
EEK_GTK_KEYBOARD_GET_PRIVATE(keyboard);
|
EEK_GTK_KEYBOARD_GET_PRIVATE(keyboard);
|
||||||
GtkStateType state = gtk_widget_get_state (widget);
|
GtkStyle *style;
|
||||||
|
GtkStateType state;
|
||||||
|
GtkAllocation allocation;
|
||||||
|
|
||||||
if (!priv->pixmap) {
|
g_return_val_if_fail (widget == priv->widget, FALSE);
|
||||||
/* compute font sizes which fit in each key shape */
|
|
||||||
|
style = gtk_widget_get_style (widget);
|
||||||
|
state = gtk_widget_get_state (widget);
|
||||||
|
|
||||||
|
if (!priv->keyboard_surface) {
|
||||||
PangoFontDescription *base_font;
|
PangoFontDescription *base_font;
|
||||||
PangoContext *context;
|
PangoContext *context;
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
|
|
||||||
context = gtk_widget_get_pango_context (priv->widget);
|
/* compute font sizes which fit in each key shape */
|
||||||
|
context = gtk_widget_get_pango_context (widget);
|
||||||
layout = pango_layout_new (context);
|
layout = pango_layout_new (context);
|
||||||
base_font = gtk_widget_get_style (priv->widget)->font_desc;
|
base_font = style->font_desc;
|
||||||
pango_layout_set_font_description (layout, base_font);
|
pango_layout_set_font_description (layout, base_font);
|
||||||
eek_get_fonts (EEK_KEYBOARD(keyboard), layout, priv->fonts);
|
eek_get_fonts (EEK_KEYBOARD(keyboard), layout, priv->fonts);
|
||||||
g_object_unref (layout);
|
g_object_unref (layout);
|
||||||
|
|
||||||
prepare_keyboard_pixmap (keyboard);
|
prepare_keyboard_surface (keyboard);
|
||||||
}
|
}
|
||||||
g_return_val_if_fail (priv->pixmap, FALSE);
|
g_return_val_if_fail (priv->keyboard_surface, FALSE);
|
||||||
|
|
||||||
|
gdk_cairo_set_source_color (cr, &style->fg[state]);
|
||||||
|
|
||||||
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
cairo_set_source_surface (cr,
|
||||||
|
priv->keyboard_surface,
|
||||||
|
0, 0);
|
||||||
|
cairo_rectangle (cr,
|
||||||
|
0, 0,
|
||||||
|
allocation.width, allocation.height);
|
||||||
|
cairo_fill (cr);
|
||||||
|
|
||||||
gdk_draw_drawable (gtk_widget_get_window (widget),
|
|
||||||
gtk_widget_get_style (widget)->fg_gc[state],
|
|
||||||
priv->pixmap,
|
|
||||||
event->area.x, event->area.y,
|
|
||||||
event->area.x, event->area.y,
|
|
||||||
event->area.width, event->area.height);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
key_enlarge (EekGtkKeyboard *keyboard, EekKey *key)
|
redraw_key (EekGtkKeyboard *keyboard,
|
||||||
|
EekKey *key,
|
||||||
|
gint key_surface_type)
|
||||||
{
|
{
|
||||||
EekGtkKeyboardPrivate *priv =
|
EekGtkKeyboardPrivate *priv =
|
||||||
EEK_GTK_KEYBOARD_GET_PRIVATE(keyboard);
|
EEK_GTK_KEYBOARD_GET_PRIVATE(keyboard);
|
||||||
EekBounds bounds;
|
EekBounds bounds;
|
||||||
EekOutline *outline;
|
EekOutline *outline;
|
||||||
gdouble ax, ay;
|
gdouble x, y;
|
||||||
GdkPixmap *pixmap, *texture;
|
int width, height;
|
||||||
DrawingContext context;
|
GtkStyle *style;
|
||||||
GtkStateType state;
|
GtkStateType state;
|
||||||
|
cairo_surface_t **key_surfaces, *large_surface;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
drawing_context_init (&context, keyboard);
|
g_return_if_fail (priv->keyboard_surface);
|
||||||
|
|
||||||
eek_element_get_bounds (EEK_ELEMENT(key), &bounds);
|
|
||||||
eek_element_get_absolute_position (EEK_ELEMENT(key), &ax, &ay);
|
|
||||||
|
|
||||||
outline = eek_key_get_outline (key);
|
outline = eek_key_get_outline (key);
|
||||||
texture = g_hash_table_lookup (priv->large_outline_textures, outline);
|
key_surfaces = g_hash_table_lookup (priv->key_surfaces, outline);
|
||||||
if (!texture) {
|
g_return_if_fail (key_surfaces);
|
||||||
texture =
|
|
||||||
gdk_pixmap_new (gtk_widget_get_window (GTK_WIDGET (priv->widget)),
|
|
||||||
bounds.width * SCALE, bounds.height * SCALE, -1);
|
|
||||||
cr = gdk_cairo_create (GDK_DRAWABLE (texture));
|
|
||||||
cairo_scale (cr, SCALE, SCALE);
|
|
||||||
gdk_cairo_set_source_color (cr, context.bg);
|
|
||||||
cairo_rectangle (cr, 0, 0, bounds.width, bounds.height);
|
|
||||||
gdk_cairo_set_source_color (cr, context.fg);
|
|
||||||
eek_draw_outline (cr, outline);
|
|
||||||
cairo_destroy (cr);
|
|
||||||
g_hash_table_insert (priv->large_outline_textures, outline, texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
pixmap =
|
large_surface = key_surfaces[KEY_SURFACE_LARGE];
|
||||||
gdk_pixmap_new (gtk_widget_get_window (GTK_WIDGET (priv->widget)),
|
width = cairo_image_surface_get_width (large_surface);
|
||||||
bounds.width * SCALE * priv->scale,
|
height = cairo_image_surface_get_height (large_surface);
|
||||||
bounds.height * SCALE * priv->scale, -1);
|
|
||||||
cr = gdk_cairo_create (GDK_DRAWABLE (pixmap));
|
eek_element_get_bounds (EEK_ELEMENT(key), &bounds);
|
||||||
|
eek_element_get_absolute_position (EEK_ELEMENT(key), &x, &y);
|
||||||
|
|
||||||
|
x -= (width - bounds.width) / 2;
|
||||||
|
y -= (height - bounds.height) / 2;
|
||||||
|
|
||||||
|
cr = gdk_cairo_create (GDK_DRAWABLE (gtk_widget_get_window (priv->widget)));
|
||||||
|
|
||||||
|
style = gtk_widget_get_style (priv->widget);
|
||||||
|
state = gtk_widget_get_state (priv->widget);
|
||||||
|
gdk_cairo_set_source_color (cr, &style->fg[state]);
|
||||||
|
|
||||||
|
switch (key_surface_type) {
|
||||||
|
case KEY_SURFACE_NORMAL:
|
||||||
|
cairo_set_source_surface (cr, priv->keyboard_surface, 0, 0);
|
||||||
cairo_scale (cr, priv->scale, priv->scale);
|
cairo_scale (cr, priv->scale, priv->scale);
|
||||||
gdk_cairo_set_source_pixmap (cr, texture, 0, 0);
|
cairo_rectangle (cr, x, y, width, height);
|
||||||
cairo_rectangle (cr, 0, 0, bounds.width * SCALE, bounds.height * SCALE);
|
cairo_fill (cr);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEY_SURFACE_LARGE:
|
||||||
|
cairo_scale (cr, priv->scale, priv->scale);
|
||||||
|
cairo_set_source_surface (cr, large_surface, x, y);
|
||||||
|
cairo_rectangle (cr, x, y, width, height);
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
|
|
||||||
cairo_move_to (cr, 0, 0);
|
cairo_move_to (cr, x, y);
|
||||||
cairo_scale (cr, SCALE, SCALE);
|
gdk_cairo_set_source_color (cr, &style->fg[state]);
|
||||||
gdk_cairo_set_source_color (cr, context.fg);
|
|
||||||
|
cairo_scale (cr,
|
||||||
|
key_surface_scale[KEY_SURFACE_LARGE],
|
||||||
|
key_surface_scale[KEY_SURFACE_LARGE]);
|
||||||
eek_draw_key_label (cr, key, priv->fonts);
|
eek_draw_key_label (cr, key, priv->fonts);
|
||||||
cairo_destroy (cr);
|
break;
|
||||||
|
|
||||||
state = gtk_widget_get_state (GTK_WIDGET (priv->widget));
|
|
||||||
gdk_draw_drawable (gtk_widget_get_window (priv->widget),
|
|
||||||
gtk_widget_get_style (priv->widget)->fg_gc[state],
|
|
||||||
pixmap,
|
|
||||||
0, 0,
|
|
||||||
(ax - (bounds.width * SCALE - bounds.width) / 2) *
|
|
||||||
priv->scale,
|
|
||||||
(ay - (bounds.height * SCALE - bounds.height) / 2) *
|
|
||||||
priv->scale,
|
|
||||||
bounds.width * SCALE * priv->scale,
|
|
||||||
bounds.height * SCALE * priv->scale);
|
|
||||||
g_object_unref (pixmap);
|
|
||||||
}
|
}
|
||||||
|
cairo_destroy (cr);
|
||||||
static void
|
|
||||||
key_shrink (EekGtkKeyboard *keyboard, EekKey *key)
|
|
||||||
{
|
|
||||||
EekGtkKeyboardPrivate *priv =
|
|
||||||
EEK_GTK_KEYBOARD_GET_PRIVATE(keyboard);
|
|
||||||
EekBounds bounds;
|
|
||||||
gdouble ax, ay;
|
|
||||||
GtkStateType state;
|
|
||||||
|
|
||||||
g_return_if_fail (priv->pixmap);
|
|
||||||
eek_element_get_bounds (EEK_ELEMENT(key), &bounds);
|
|
||||||
eek_element_get_absolute_position (EEK_ELEMENT(key), &ax, &ay);
|
|
||||||
state = gtk_widget_get_state (GTK_WIDGET (priv->widget));
|
|
||||||
|
|
||||||
ax -= (bounds.width * SCALE - bounds.width) / 2;
|
|
||||||
ay -= (bounds.height * SCALE - bounds.height) / 2;
|
|
||||||
|
|
||||||
gdk_draw_drawable (gtk_widget_get_window (priv->widget),
|
|
||||||
gtk_widget_get_style (priv->widget)->fg_gc[state],
|
|
||||||
priv->pixmap,
|
|
||||||
ax * priv->scale, ay * priv->scale,
|
|
||||||
ax * priv->scale, ay * priv->scale,
|
|
||||||
bounds.width * SCALE * priv->scale,
|
|
||||||
bounds.height * SCALE * priv->scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -428,7 +444,7 @@ on_key_pressed (EekKey *key, gpointer user_data)
|
|||||||
EekGtkKeyboard *keyboard = user_data;
|
EekGtkKeyboard *keyboard = user_data;
|
||||||
EekGtkKeyboardPrivate *priv = EEK_GTK_KEYBOARD_GET_PRIVATE(keyboard);
|
EekGtkKeyboardPrivate *priv = EEK_GTK_KEYBOARD_GET_PRIVATE(keyboard);
|
||||||
|
|
||||||
key_enlarge (EEK_GTK_KEYBOARD(keyboard), key);
|
redraw_key (EEK_GTK_KEYBOARD(keyboard), key, KEY_SURFACE_LARGE);
|
||||||
priv->key = key;
|
priv->key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,10 +455,10 @@ on_key_released (EekKey *key, gpointer user_data)
|
|||||||
EekGtkKeyboardPrivate *priv = EEK_GTK_KEYBOARD_GET_PRIVATE(keyboard);
|
EekGtkKeyboardPrivate *priv = EEK_GTK_KEYBOARD_GET_PRIVATE(keyboard);
|
||||||
|
|
||||||
if (priv->key) {
|
if (priv->key) {
|
||||||
key_shrink (EEK_GTK_KEYBOARD(keyboard), EEK_KEY(priv->key));
|
redraw_key (EEK_GTK_KEYBOARD(keyboard), priv->key, KEY_SURFACE_NORMAL);
|
||||||
priv->key = NULL;
|
priv->key = NULL;
|
||||||
}
|
}
|
||||||
key_shrink (EEK_GTK_KEYBOARD(keyboard), key);
|
redraw_key (EEK_GTK_KEYBOARD(keyboard), key, KEY_SURFACE_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -522,12 +538,10 @@ on_size_allocate (GtkWidget *widget,
|
|||||||
EekGtkKeyboardPrivate *priv =
|
EekGtkKeyboardPrivate *priv =
|
||||||
EEK_GTK_KEYBOARD_GET_PRIVATE(keyboard);
|
EEK_GTK_KEYBOARD_GET_PRIVATE(keyboard);
|
||||||
EekBounds bounds;
|
EekBounds bounds;
|
||||||
GdkPixmap *pixmap;
|
|
||||||
|
|
||||||
if (priv->pixmap) {
|
if (priv->keyboard_surface) {
|
||||||
pixmap = priv->pixmap;
|
cairo_surface_destroy (priv->keyboard_surface);
|
||||||
priv->pixmap = NULL;
|
priv->keyboard_surface = NULL;
|
||||||
g_object_unref (pixmap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
eek_element_get_bounds (EEK_ELEMENT(keyboard), &bounds);
|
eek_element_get_bounds (EEK_ELEMENT(keyboard), &bounds);
|
||||||
@ -553,8 +567,8 @@ eek_gtk_keyboard_get_widget (EekGtkKeyboard *keyboard)
|
|||||||
GDK_KEY_RELEASE_MASK |
|
GDK_KEY_RELEASE_MASK |
|
||||||
GDK_BUTTON_PRESS_MASK |
|
GDK_BUTTON_PRESS_MASK |
|
||||||
GDK_BUTTON_RELEASE_MASK);
|
GDK_BUTTON_RELEASE_MASK);
|
||||||
g_signal_connect (priv->widget, "expose_event",
|
g_signal_connect (priv->widget, "draw",
|
||||||
G_CALLBACK (on_expose_event), keyboard);
|
G_CALLBACK (on_draw), keyboard);
|
||||||
g_signal_connect (priv->widget, "size-allocate",
|
g_signal_connect (priv->widget, "size-allocate",
|
||||||
G_CALLBACK (on_size_allocate), keyboard);
|
G_CALLBACK (on_size_allocate), keyboard);
|
||||||
g_signal_connect (priv->widget, "key-press-event",
|
g_signal_connect (priv->widget, "key-press-event",
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
#ifndef EEK_GTK_KEYBOARD_H
|
#ifndef EEK_GTK_KEYBOARD_H
|
||||||
#define EEK_GTK_KEYBOARD_H 1
|
#define EEK_GTK_KEYBOARD_H 1
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "eek-keyboard.h"
|
#include "eek-keyboard.h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user