[gtk-theme-engine-clearlooks] Render sliders in GtkScales as per the mockups.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-theme-engine-clearlooks] Render sliders in GtkScales as per the mockups.
- Date: Wed, 19 Jan 2011 03:48:05 +0000 (UTC)
commit 53b4ed6bccdd122bc71594eb3dc8c58c8e4c48b3
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jan 19 04:27:48 2011 +0100
Render sliders in GtkScales as per the mockups.
src/adwaita_engine.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 82 insertions(+), 0 deletions(-)
---
diff --git a/src/adwaita_engine.c b/src/adwaita_engine.c
index c1e0154..1323457 100644
--- a/src/adwaita_engine.c
+++ b/src/adwaita_engine.c
@@ -521,6 +521,87 @@ adwaita_engine_render_activity (GtkThemingEngine *engine,
}
static void
+adwaita_engine_render_slider (GtkThemingEngine *engine,
+ cairo_t *cr,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ GtkOrientation orientation)
+{
+ const GtkWidgetPath *path;
+
+ path = gtk_theming_engine_get_path (engine);
+ cairo_save (cr);
+
+ if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE))
+ {
+ cairo_pattern_t *pattern;
+ cairo_matrix_t matrix;
+ GtkStateFlags state;
+ GdkRGBA color;
+
+ state = gtk_theming_engine_get_state (engine);
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ cairo_move_to (cr, x + width / 2, y);
+ cairo_line_to (cr, x, y + height / 2);
+ cairo_line_to (cr, x, y + height);
+ cairo_line_to (cr, x + width, y + height);
+ cairo_line_to (cr, x + width, y + height / 2);
+ cairo_line_to (cr, x + width / 2, y);
+ }
+ else if (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_RTL)
+ {
+ cairo_move_to (cr, x, y + height / 2);
+ cairo_line_to (cr, x + width / 2, y);
+ cairo_line_to (cr, x + width, y);
+ cairo_line_to (cr, x + width, y + height);
+ cairo_line_to (cr, x + width / 2, y + height);
+ cairo_line_to (cr, x, y + height / 2);
+ }
+ else
+ {
+ cairo_move_to (cr, x + width, y + height / 2);
+ cairo_line_to (cr, x + width / 2, y);
+ cairo_line_to (cr, x, y);
+ cairo_line_to (cr, x, y + height);
+ cairo_line_to (cr, x + width / 2, y + height);
+ cairo_line_to (cr, x + width, y + height / 2);
+ }
+ cairo_close_path (cr);
+
+ cairo_set_line_width (cr, 1);
+
+ gtk_theming_engine_get (engine, state,
+ "background-image", &pattern,
+ NULL);
+
+ cairo_matrix_init_scale (&matrix, 1 / width, 1 / height);
+ cairo_matrix_translate (&matrix, -x, -y);
+ cairo_pattern_set_matrix (pattern, &matrix);
+
+ cairo_set_source (cr, pattern);
+ cairo_fill_preserve (cr);
+
+ gtk_theming_engine_get_border_color (engine, state, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
+ cairo_stroke (cr);
+
+ cairo_pattern_destroy (pattern);
+ }
+ else
+ {
+ GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_slider (engine, cr,
+ x, y, width, height,
+ orientation);
+ }
+
+ cairo_restore (cr);
+}
+
+static void
adwaita_engine_class_init (AdwaitaEngineClass *klass)
{
GtkThemingEngineClass *engine_class = GTK_THEMING_ENGINE_CLASS (klass);
@@ -533,6 +614,7 @@ adwaita_engine_class_init (AdwaitaEngineClass *klass)
engine_class->render_frame = adwaita_engine_render_frame;
engine_class->render_expander = adwaita_engine_render_expander;
engine_class->render_activity = adwaita_engine_render_activity;
+ engine_class->render_slider = adwaita_engine_render_slider;
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
g_param_spec_boxed ("focus-border-color",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]