Clear allocation box when drawing keyboard.

This commit is contained in:
Daiki Ueno
2011-03-03 18:18:04 +09:00
parent c53b4d398e
commit 38b226b46f

View File

@ -49,7 +49,10 @@ struct _EekRendererPrivate
EekColor *background; EekColor *background;
gdouble border_width; gdouble border_width;
gdouble allocation_width;
gdouble allocation_height;
gdouble scale; gdouble scale;
PangoFontDescription *font; PangoFontDescription *font;
GHashTable *outline_surface_cache; GHashTable *outline_surface_cache;
cairo_surface_t *keyboard_surface; cairo_surface_t *keyboard_surface;
@ -533,9 +536,26 @@ eek_renderer_real_render_keyboard (EekRenderer *self,
{ {
EekRendererPrivate *priv = EEK_RENDERER_GET_PRIVATE(self); EekRendererPrivate *priv = EEK_RENDERER_GET_PRIVATE(self);
g_return_if_fail (priv->keyboard);
g_return_if_fail (priv->allocation_width > 0.0);
g_return_if_fail (priv->allocation_height > 0.0);
if (!priv->keyboard_surface) if (!priv->keyboard_surface)
priv->keyboard_surface = create_keyboard_surface (self); priv->keyboard_surface = create_keyboard_surface (self);
/* blank background */
cairo_set_source_rgba (cr,
priv->background->red,
priv->background->green,
priv->background->blue,
priv->background->alpha);
cairo_rectangle (cr,
0.0,
0.0,
priv->allocation_width,
priv->allocation_height);
cairo_fill (cr);
cairo_set_source_surface (cr, priv->keyboard_surface, 0.0, 0.0); cairo_set_source_surface (cr, priv->keyboard_surface, 0.0, 0.0);
cairo_paint (cr); cairo_paint (cr);
} }
@ -674,6 +694,8 @@ eek_renderer_init (EekRenderer *self)
priv->foreground = eek_color_new (0.3, 0.3, 0.3, 1.0); priv->foreground = eek_color_new (0.3, 0.3, 0.3, 1.0);
priv->background = eek_color_new (1.0, 1.0, 1.0, 1.0); priv->background = eek_color_new (1.0, 1.0, 1.0, 1.0);
priv->border_width = 1.0; priv->border_width = 1.0;
priv->allocation_width = 0.0;
priv->allocation_height = 0.0;
priv->scale = 1.0; priv->scale = 1.0;
priv->font = NULL; priv->font = NULL;
priv->outline_surface_cache = priv->outline_surface_cache =
@ -737,6 +759,9 @@ eek_renderer_set_allocation_size (EekRenderer *renderer,
priv = EEK_RENDERER_GET_PRIVATE(renderer); priv = EEK_RENDERER_GET_PRIVATE(renderer);
priv->allocation_width = width;
priv->allocation_height = height;
eek_element_get_bounds (EEK_ELEMENT(priv->keyboard), &bounds); eek_element_get_bounds (EEK_ELEMENT(priv->keyboard), &bounds);
scale = width > height ? height / bounds.height : scale = width > height ? height / bounds.height :
width / bounds.width; width / bounds.width;