[gtk-theme-engine-clearlooks] Clearlooks: Implement render_layout().
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-theme-engine-clearlooks] Clearlooks: Implement render_layout().
- Date: Mon, 6 Dec 2010 21:20:46 +0000 (UTC)
commit 2574fe30449031efd2f0646a741ae2dbe3ead0ac
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Nov 16 00:37:36 2010 +0100
Clearlooks: Implement render_layout().
src/clearlooks_engine.c | 107 ++++++++++++++++++++++++++--------------------
src/clearlooks_types.h | 4 +-
src/general-support.h | 5 ++
3 files changed, 67 insertions(+), 49 deletions(-)
---
diff --git a/src/clearlooks_engine.c b/src/clearlooks_engine.c
index 3a18e05..1b8a897 100644
--- a/src/clearlooks_engine.c
+++ b/src/clearlooks_engine.c
@@ -56,28 +56,26 @@
G_DEFINE_DYNAMIC_TYPE (ClearlooksEngine, clearlooks_engine, GTK_TYPE_THEMING_ENGINE)
-#if 0
-
static void
-clearlooks_set_widget_parameters (const GtkWidget *widget,
- const GtkStyle *style,
- GtkStateType state_type,
- WidgetParameters *params)
+clearlooks_set_parameters (GtkThemingEngine *engine,
+ GtkStateFlags state,
+ WidgetParameters *params)
{
- params->style_functions = &(CLEARLOOKS_STYLE_GET_CLASS (style)->style_functions[CLEARLOOKS_STYLE (style)->style]);
- params->style_constants = &(CLEARLOOKS_STYLE_GET_CLASS (style)->style_constants[CLEARLOOKS_STYLE (style)->style]);
+ params->style_functions = &(CLEARLOOKS_ENGINE_GET_CLASS (engine)->style_functions[CLEARLOOKS_ENGINE (engine)->style]);
+ params->style_constants = &(CLEARLOOKS_ENGINE_GET_CLASS (engine)->style_constants[CLEARLOOKS_ENGINE (engine)->style]);
- params->active = (state_type == GTK_STATE_ACTIVE);
- params->prelight = (state_type == GTK_STATE_PRELIGHT);
- params->disabled = (state_type == GTK_STATE_INSENSITIVE);
- params->state_type = state_type;
+ params->active = (state & GTK_STATE_FLAG_ACTIVE) != 0;
+ params->prelight = (state & GTK_STATE_FLAG_PRELIGHT) != 0;
+ params->disabled = (state & GTK_STATE_FLAG_INSENSITIVE) != 0;
+ params->state_type = GTK_STATE_NORMAL;
params->corners = CR_CORNER_ALL;
- params->ltr = ge_widget_is_ltr ((GtkWidget*)widget);
- params->focus = !CLEARLOOKS_STYLE (style)->disable_focus && widget && gtk_widget_has_focus ((GtkWidget *) widget);
- params->is_default = widget && GE_WIDGET_HAS_DEFAULT ((GtkWidget *) widget);
+ params->ltr = (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_LTR);
+ params->focus = !CLEARLOOKS_ENGINE (engine)->disable_focus && (state & GTK_STATE_FLAG_FOCUSED);
+ params->is_default = gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_DEFAULT);
params->enable_shadow = FALSE;
- params->radius = CLEARLOOKS_STYLE (style)->radius;
+ params->radius = CLEARLOOKS_ENGINE (engine)->radius;
+#if 0
params->xthickness = style->xthickness;
params->ythickness = style->ythickness;
@@ -87,8 +85,11 @@ clearlooks_set_widget_parameters (const GtkWidget *widget,
* the background color of a notebook. */
params->parentbg = CLEARLOOKS_STYLE (style)->colors.bg[state_type];
clearlooks_get_parent_bg (widget, ¶ms->parentbg);
+#endif
}
+#if 0
+
static void
clearlooks_style_draw_flat_box (DRAW_ARGS)
{
@@ -1658,62 +1659,73 @@ scale_or_ref (GdkPixbuf *src,
}
}
-#if 0
static void
-clearlooks_style_draw_layout (GtkStyle * style,
- cairo_t *cr,
- GtkStateType state_type,
- gboolean use_text,
- GtkWidget * widget,
- const gchar * detail, gint x, gint y, PangoLayout * layout)
+clearlooks_engine_render_layout (GtkThemingEngine *engine,
+ cairo_t *cr,
+ gdouble x,
+ gdouble y,
+ PangoLayout *layout)
{
- CHECK_ARGS;
+ GtkStateFlags state;
+ GdkRGBA *color;
+
+ GE_CAIRO_INIT;
ge_cairo_transform_for_layout (cr, layout, x, y);
- gdk_cairo_set_source_color (cr, use_text ? &style->text[state_type] : &style->fg[state_type]);
+ state = gtk_theming_engine_get_state (engine);
+ gtk_theming_engine_get (engine, state,
+ "color", &color,
+ NULL);
- if (state_type == GTK_STATE_NORMAL && DETAIL("accellabel")) {
- ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
- ClearlooksColors *colors = &clearlooks_style->colors;
- CairoColor color;
+ gdk_cairo_set_source_rgba (cr, color);
- ge_mix_color (use_text ? &colors->base[state_type] : &colors->bg[state_type],
- use_text ? &colors->text[state_type] : &colors->fg[state_type],
- clearlooks_style->accel_label_shade,
- &color);
+ if (state == 0 &&
+ gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_ACCELERATOR)) {
+ ClearlooksEngine *clearlooks_engine = CLEARLOOKS_ENGINE (engine);
+ CairoColor *bg_color, *color, mix;
- ge_cairo_set_color (cr, &color);
- }
+ gtk_theming_engine_get (engine, state,
+ "background-color", &bg_color,
+ "color", &color,
+ NULL);
+ ge_mix_color (bg_color, color,
+ clearlooks_engine->accel_label_shade,
+ &mix);
- if (state_type == GTK_STATE_INSENSITIVE)
- {
- ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style);
- ClearlooksColors *colors = &clearlooks_style->colors;
+ ge_cairo_set_color (cr, &mix);
+ gdk_rgba_free ((GdkRGBA *) bg_color);
+ gdk_rgba_free ((GdkRGBA *) color);
+ }
+
+ if (state & GTK_STATE_FLAG_INSENSITIVE)
+ {
WidgetParameters params;
- CairoColor temp;
+ CairoColor *color, temp;
- clearlooks_set_widget_parameters (widget, style, state_type, ¶ms);
+ clearlooks_set_parameters (engine, state, ¶ms);
- if (gtk_widget_get_has_window (widget))
- ge_shade_color (¶ms.parentbg, 1.2, &temp);
- else
- ge_shade_color (&colors->bg[gtk_widget_get_state (widget)], 1.2, &temp);
+ gtk_theming_engine_get (engine, state,
+ "background-color", &color,
+ NULL);
+
+ ge_shade_color (color, 1.2, &temp);
cairo_save (cr);
- ge_cairo_set_color (cr, &temp);
+ ge_cairo_set_color (cr, &temp);
cairo_move_to (cr, 1, 1);
pango_cairo_show_layout (cr, layout);
cairo_restore (cr);
+
+ gdk_rgba_free ((GdkRGBA *) color);
}
pango_cairo_show_layout (cr, layout);
}
-#endif /* if 0 */
static GdkPixbuf *
clearlooks_engine_render_icon_pixbuf (GtkThemingEngine *engine,
@@ -1795,6 +1807,7 @@ clearlooks_engine_class_init (ClearlooksEngineClass * klass)
{
GtkThemingEngineClass *engine_class = GTK_THEMING_ENGINE_CLASS (klass);
+ engine_class->render_layout = clearlooks_engine_render_layout;
engine_class->render_icon_pixbuf = clearlooks_engine_render_icon_pixbuf;
#if 0
GtkStyleClass *style_class = GTK_STYLE_CLASS (klass);
diff --git a/src/clearlooks_types.h b/src/clearlooks_types.h
index e7091d0..ec7c024 100644
--- a/src/clearlooks_types.h
+++ b/src/clearlooks_types.h
@@ -190,9 +190,9 @@ typedef struct
boolean enable_shadow;
gfloat radius;
-
+
GtkStateType state_type;
-
+
uint8 corners;
uint8 xthickness;
uint8 ythickness;
diff --git a/src/general-support.h b/src/general-support.h
index 0ff5d3c..f885e7d 100644
--- a/src/general-support.h
+++ b/src/general-support.h
@@ -42,6 +42,11 @@
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); \
cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER); \
+#define GE_CAIRO_INIT \
+ cairo_set_line_width (cr, 1.0); \
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); \
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER); \
+
#define GE_EXPORT G_MODULE_EXPORT
#define GE_INTERNAL G_GNUC_INTERNAL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]