style: Simplified layout styling
Layout background is styled in the same place as button background, and obtains the path "layout".
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
.keyboard {
|
||||
layout {
|
||||
background-color: rgba(0, 0, 0, 255);
|
||||
color: #ffffff;
|
||||
font-family: cantarell, sans-serif;
|
||||
|
||||
@ -52,8 +52,6 @@ typedef struct _EekGtkKeyboardPrivate
|
||||
{
|
||||
EekRenderer *renderer;
|
||||
LevelKeyboard *keyboard;
|
||||
GtkCssProvider *css_provider;
|
||||
GtkStyleContext *scontext;
|
||||
|
||||
GdkEventSequence *sequence; // unowned reference
|
||||
} EekGtkKeyboardPrivate;
|
||||
@ -98,7 +96,7 @@ eek_gtk_keyboard_real_draw (GtkWidget *self,
|
||||
if (!priv->renderer) {
|
||||
PangoContext *pcontext = gtk_widget_get_pango_context (self);
|
||||
|
||||
priv->renderer = eek_renderer_new (priv->keyboard, pcontext, priv->scontext);
|
||||
priv->renderer = eek_renderer_new (priv->keyboard, pcontext);
|
||||
|
||||
eek_renderer_set_allocation_size (priv->renderer,
|
||||
allocation.width,
|
||||
@ -383,22 +381,7 @@ eek_gtk_keyboard_class_init (EekGtkKeyboardClass *klass)
|
||||
|
||||
static void
|
||||
eek_gtk_keyboard_init (EekGtkKeyboard *self)
|
||||
{
|
||||
EekGtkKeyboardPrivate *priv = eek_gtk_keyboard_get_instance_private (self);
|
||||
|
||||
/* Create a default CSS provider and load a style sheet */
|
||||
priv->css_provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_resource (priv->css_provider,
|
||||
"/sm/puri/squeekboard/style.css");
|
||||
|
||||
/* Apply the style to the widget */
|
||||
priv->scontext = gtk_widget_get_style_context (GTK_WIDGET(self));
|
||||
gtk_style_context_add_class (priv->scontext, "keyboard");
|
||||
gtk_style_context_add_provider (priv->scontext,
|
||||
GTK_STYLE_PROVIDER(priv->css_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
gtk_style_context_set_state (priv->scontext, GTK_STATE_FLAG_NORMAL);
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
* eek_gtk_keyboard_new:
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_PCONTEXT,
|
||||
PROP_STYLE_CONTEXT,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
@ -38,7 +37,7 @@ typedef struct _EekRendererPrivate
|
||||
LevelKeyboard *keyboard;
|
||||
PangoContext *pcontext;
|
||||
GtkCssProvider *css_provider;
|
||||
GtkStyleContext *scontext;
|
||||
GtkStyleContext *layout_context;
|
||||
GtkStyleContext *button_context;
|
||||
|
||||
EekColor default_foreground_color;
|
||||
@ -140,7 +139,7 @@ render_keyboard_surface (EekRenderer *renderer, struct squeek_view *view)
|
||||
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
|
||||
EekColor foreground;
|
||||
|
||||
eek_renderer_get_foreground_color (renderer, priv->scontext, &foreground);
|
||||
eek_renderer_get_foreground_color (renderer, priv->layout_context, &foreground);
|
||||
|
||||
EekBounds bounds = squeek_view_get_bounds (level_keyboard_current(priv->keyboard));
|
||||
|
||||
@ -151,11 +150,11 @@ render_keyboard_surface (EekRenderer *renderer, struct squeek_view *view)
|
||||
};
|
||||
|
||||
/* Paint the background covering the entire widget area */
|
||||
gtk_render_background (priv->scontext,
|
||||
gtk_render_background (priv->layout_context,
|
||||
data.cr,
|
||||
0, 0,
|
||||
priv->allocation_width, priv->allocation_height);
|
||||
gtk_render_frame (priv->scontext,
|
||||
gtk_render_frame (priv->layout_context,
|
||||
data.cr,
|
||||
0, 0,
|
||||
priv->allocation_width, priv->allocation_height);
|
||||
@ -496,10 +495,6 @@ eek_renderer_set_property (GObject *object,
|
||||
priv->pcontext = g_value_get_object (value);
|
||||
g_object_ref (priv->pcontext);
|
||||
break;
|
||||
case PROP_STYLE_CONTEXT:
|
||||
priv->scontext = g_value_get_object (value);
|
||||
g_object_ref (priv->scontext);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -576,15 +571,6 @@ eek_renderer_class_init (EekRendererClass *klass)
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_PCONTEXT,
|
||||
pspec);
|
||||
|
||||
pspec = g_param_spec_object ("style-context",
|
||||
"GTK Style Context",
|
||||
"GTK Style Context",
|
||||
GTK_TYPE_STYLE_CONTEXT,
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_STYLE_CONTEXT,
|
||||
pspec);
|
||||
}
|
||||
|
||||
|
||||
@ -657,6 +643,13 @@ eek_renderer_init (EekRenderer *self)
|
||||
/* Create a style context for keys */
|
||||
GtkWidgetPath *path = gtk_widget_path_new();
|
||||
gtk_widget_path_append_type(path, layout_type());
|
||||
|
||||
priv->layout_context = gtk_style_context_new();
|
||||
gtk_style_context_set_path(priv->layout_context, path);
|
||||
gtk_style_context_add_provider (priv->layout_context,
|
||||
GTK_STYLE_PROVIDER(priv->css_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
gtk_widget_path_append_type(path, button_type());
|
||||
priv->button_context = gtk_style_context_new ();
|
||||
gtk_style_context_set_path(priv->button_context, path);
|
||||
@ -686,12 +679,10 @@ invalidate (EekRenderer *renderer)
|
||||
|
||||
EekRenderer *
|
||||
eek_renderer_new (LevelKeyboard *keyboard,
|
||||
PangoContext *pcontext,
|
||||
GtkStyleContext *scontext)
|
||||
PangoContext *pcontext)
|
||||
{
|
||||
EekRenderer *renderer = g_object_new (EEK_TYPE_RENDERER,
|
||||
"pango-context", pcontext,
|
||||
"style-context", scontext,
|
||||
NULL);
|
||||
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
|
||||
priv->keyboard = keyboard;
|
||||
@ -785,7 +776,7 @@ eek_renderer_get_button_bounds (EekRenderer *renderer,
|
||||
|
||||
min = points[2];
|
||||
max = points[0];
|
||||
for (uint i = 0; i < G_N_ELEMENTS(points); i++) {
|
||||
for (unsigned i = 0; i < G_N_ELEMENTS(points); i++) {
|
||||
eek_point_rotate (&points[i], angle);
|
||||
if (points[i].x < min.x)
|
||||
min.x = points[i].x;
|
||||
@ -953,7 +944,7 @@ eek_are_bounds_inside (EekBounds bounds, EekPoint point, EekPoint origin, int32_
|
||||
points[3].x = points[0].x;
|
||||
points[3].y = points[2].y;
|
||||
|
||||
for (uint i = 0; i < G_N_ELEMENTS(points); i++) {
|
||||
for (unsigned i = 0; i < G_N_ELEMENTS(points); i++) {
|
||||
eek_point_rotate (&points[i], angle);
|
||||
points[i].x += origin.x;
|
||||
points[i].y += origin.y;
|
||||
|
||||
@ -57,8 +57,7 @@ struct _EekRendererClass
|
||||
|
||||
GType eek_renderer_get_type (void) G_GNUC_CONST;
|
||||
EekRenderer *eek_renderer_new (LevelKeyboard *keyboard,
|
||||
PangoContext *pcontext,
|
||||
GtkStyleContext *scontext);
|
||||
PangoContext *pcontext);
|
||||
void eek_renderer_set_allocation_size
|
||||
(EekRenderer *renderer,
|
||||
gdouble width,
|
||||
|
||||
Reference in New Issue
Block a user