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);
|
background-color: rgba(0, 0, 0, 255);
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
font-family: cantarell, sans-serif;
|
font-family: cantarell, sans-serif;
|
||||||
|
|||||||
@ -52,8 +52,6 @@ typedef struct _EekGtkKeyboardPrivate
|
|||||||
{
|
{
|
||||||
EekRenderer *renderer;
|
EekRenderer *renderer;
|
||||||
LevelKeyboard *keyboard;
|
LevelKeyboard *keyboard;
|
||||||
GtkCssProvider *css_provider;
|
|
||||||
GtkStyleContext *scontext;
|
|
||||||
|
|
||||||
GdkEventSequence *sequence; // unowned reference
|
GdkEventSequence *sequence; // unowned reference
|
||||||
} EekGtkKeyboardPrivate;
|
} EekGtkKeyboardPrivate;
|
||||||
@ -98,7 +96,7 @@ eek_gtk_keyboard_real_draw (GtkWidget *self,
|
|||||||
if (!priv->renderer) {
|
if (!priv->renderer) {
|
||||||
PangoContext *pcontext = gtk_widget_get_pango_context (self);
|
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,
|
eek_renderer_set_allocation_size (priv->renderer,
|
||||||
allocation.width,
|
allocation.width,
|
||||||
@ -383,22 +381,7 @@ eek_gtk_keyboard_class_init (EekGtkKeyboardClass *klass)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
eek_gtk_keyboard_init (EekGtkKeyboard *self)
|
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:
|
* eek_gtk_keyboard_new:
|
||||||
|
|||||||
@ -29,7 +29,6 @@
|
|||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_PCONTEXT,
|
PROP_PCONTEXT,
|
||||||
PROP_STYLE_CONTEXT,
|
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ typedef struct _EekRendererPrivate
|
|||||||
LevelKeyboard *keyboard;
|
LevelKeyboard *keyboard;
|
||||||
PangoContext *pcontext;
|
PangoContext *pcontext;
|
||||||
GtkCssProvider *css_provider;
|
GtkCssProvider *css_provider;
|
||||||
GtkStyleContext *scontext;
|
GtkStyleContext *layout_context;
|
||||||
GtkStyleContext *button_context;
|
GtkStyleContext *button_context;
|
||||||
|
|
||||||
EekColor default_foreground_color;
|
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);
|
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
|
||||||
EekColor foreground;
|
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));
|
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 */
|
/* Paint the background covering the entire widget area */
|
||||||
gtk_render_background (priv->scontext,
|
gtk_render_background (priv->layout_context,
|
||||||
data.cr,
|
data.cr,
|
||||||
0, 0,
|
0, 0,
|
||||||
priv->allocation_width, priv->allocation_height);
|
priv->allocation_width, priv->allocation_height);
|
||||||
gtk_render_frame (priv->scontext,
|
gtk_render_frame (priv->layout_context,
|
||||||
data.cr,
|
data.cr,
|
||||||
0, 0,
|
0, 0,
|
||||||
priv->allocation_width, priv->allocation_height);
|
priv->allocation_width, priv->allocation_height);
|
||||||
@ -496,10 +495,6 @@ eek_renderer_set_property (GObject *object,
|
|||||||
priv->pcontext = g_value_get_object (value);
|
priv->pcontext = g_value_get_object (value);
|
||||||
g_object_ref (priv->pcontext);
|
g_object_ref (priv->pcontext);
|
||||||
break;
|
break;
|
||||||
case PROP_STYLE_CONTEXT:
|
|
||||||
priv->scontext = g_value_get_object (value);
|
|
||||||
g_object_ref (priv->scontext);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -576,15 +571,6 @@ eek_renderer_class_init (EekRendererClass *klass)
|
|||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_PCONTEXT,
|
PROP_PCONTEXT,
|
||||||
pspec);
|
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 */
|
/* Create a style context for keys */
|
||||||
GtkWidgetPath *path = gtk_widget_path_new();
|
GtkWidgetPath *path = gtk_widget_path_new();
|
||||||
gtk_widget_path_append_type(path, layout_type());
|
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());
|
gtk_widget_path_append_type(path, button_type());
|
||||||
priv->button_context = gtk_style_context_new ();
|
priv->button_context = gtk_style_context_new ();
|
||||||
gtk_style_context_set_path(priv->button_context, path);
|
gtk_style_context_set_path(priv->button_context, path);
|
||||||
@ -686,12 +679,10 @@ invalidate (EekRenderer *renderer)
|
|||||||
|
|
||||||
EekRenderer *
|
EekRenderer *
|
||||||
eek_renderer_new (LevelKeyboard *keyboard,
|
eek_renderer_new (LevelKeyboard *keyboard,
|
||||||
PangoContext *pcontext,
|
PangoContext *pcontext)
|
||||||
GtkStyleContext *scontext)
|
|
||||||
{
|
{
|
||||||
EekRenderer *renderer = g_object_new (EEK_TYPE_RENDERER,
|
EekRenderer *renderer = g_object_new (EEK_TYPE_RENDERER,
|
||||||
"pango-context", pcontext,
|
"pango-context", pcontext,
|
||||||
"style-context", scontext,
|
|
||||||
NULL);
|
NULL);
|
||||||
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
|
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
|
||||||
priv->keyboard = keyboard;
|
priv->keyboard = keyboard;
|
||||||
@ -785,7 +776,7 @@ eek_renderer_get_button_bounds (EekRenderer *renderer,
|
|||||||
|
|
||||||
min = points[2];
|
min = points[2];
|
||||||
max = points[0];
|
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);
|
eek_point_rotate (&points[i], angle);
|
||||||
if (points[i].x < min.x)
|
if (points[i].x < min.x)
|
||||||
min.x = points[i].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].x = points[0].x;
|
||||||
points[3].y = points[2].y;
|
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);
|
eek_point_rotate (&points[i], angle);
|
||||||
points[i].x += origin.x;
|
points[i].x += origin.x;
|
||||||
points[i].y += origin.y;
|
points[i].y += origin.y;
|
||||||
|
|||||||
@ -57,8 +57,7 @@ struct _EekRendererClass
|
|||||||
|
|
||||||
GType eek_renderer_get_type (void) G_GNUC_CONST;
|
GType eek_renderer_get_type (void) G_GNUC_CONST;
|
||||||
EekRenderer *eek_renderer_new (LevelKeyboard *keyboard,
|
EekRenderer *eek_renderer_new (LevelKeyboard *keyboard,
|
||||||
PangoContext *pcontext,
|
PangoContext *pcontext);
|
||||||
GtkStyleContext *scontext);
|
|
||||||
void eek_renderer_set_allocation_size
|
void eek_renderer_set_allocation_size
|
||||||
(EekRenderer *renderer,
|
(EekRenderer *renderer,
|
||||||
gdouble width,
|
gdouble width,
|
||||||
|
|||||||
Reference in New Issue
Block a user