}
/**
- * gtk_theming_engine_register_property:
+ * gtk_theming_engine_register_property: (skip)
* @name_space: namespace for the property name
* @parse_func: parsing function to use, or %NULL
* @pspec: the #GParamSpec for the new property
* gtk_theming_engine_get_style_property:
* @engine: a #GtkThemingEngine
* @property_name: the name of the widget style property
- * @value: (out) (transfer full): Return location for the property value, free with
+ * @value: Return location for the property value, free with
* g_value_unset() after use.
*
* Gets the value for a widget style property.
* gtk_theming_engine_lookup_color:
* @engine: a #GtkThemingEngine
* @color_name: color name to lookup
- * @color: (out) (transfer full): Return location for the looked up color
+ * @color: (out): Return location for the looked up color
*
* Looks up and resolves a color name in the current style's color map.
- * The returned color must be freed with gdk_rgba_free().
*
* Returns: %TRUE if @color_name was found and resolved, %FALSE otherwise
**/
gboolean
-gtk_theming_engine_lookup_color (GtkThemingEngine *engine,
- const gchar *color_name,
- GdkRGBA **color)
+gtk_theming_engine_lookup_color (GtkThemingEngine *engine,
+ const gchar *color_name,
+ GdkRGBA *color)
{
GtkThemingEnginePrivate *priv;
return gtk_style_context_get_junction_sides (priv->context);
}
+/**
+ * gtk_theming_engine_get_color:
+ * @engine: a #GtkThemingEngine
+ * @state: state to retrieve the color for
+ * @color: (out): return value for the foreground color
+ *
+ * Gets the foreground color for a given state.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_theming_engine_get_color (GtkThemingEngine *engine,
+ GtkStateFlags state,
+ GdkRGBA *color)
+{
+ GtkThemingEnginePrivate *priv;
+
+ g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
+
+ priv = engine->priv;
+ gtk_style_context_get_color (priv->context, state, color);
+}
+
+/**
+ * gtk_theming_engine_get_background_color:
+ * @engine: a #GtkThemingEngine
+ * @state: state to retrieve the color for
+ * @color: (out): return value for the background color
+ *
+ * Gets the background color for a given state.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_theming_engine_get_background_color (GtkThemingEngine *engine,
+ GtkStateFlags state,
+ GdkRGBA *color)
+{
+ GtkThemingEnginePrivate *priv;
+
+ g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
+
+ priv = engine->priv;
+ gtk_style_context_get_background_color (priv->context, state, color);
+}
+
+/**
+ * gtk_theming_engine_get_border_color:
+ * @engine: a #GtkThemingEngine
+ * @state: state to retrieve the color for
+ * @color: (out): return value for the border color
+ *
+ * Gets the border color for a given state.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_theming_engine_get_border_color (GtkThemingEngine *engine,
+ GtkStateFlags state,
+ GdkRGBA *color)
+{
+ GtkThemingEnginePrivate *priv;
+
+ g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
+
+ priv = engine->priv;
+ gtk_style_context_get_border_color (priv->context, state, color);
+}
+
+/**
+ * gtk_theming_engine_get_border:
+ * @engine: a #GtkthemingEngine
+ * @state: state to retrieve the border for
+ * @border: (out): return value for the border settings
+ *
+ * Gets the border for a given state as a #GtkBorder.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_theming_engine_get_border (GtkThemingEngine *engine,
+ GtkStateFlags state,
+ GtkBorder *border)
+{
+ GtkThemingEnginePrivate *priv;
+
+ g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
+
+ priv = engine->priv;
+ gtk_style_context_get_border (priv->context, state, border);
+}
+
+/**
+ * gtk_theming_engine_get_padding:
+ * @engine: a #GtkthemingEngine
+ * @state: state to retrieve the padding for
+ * @padding: (out): return value for the padding settings
+ *
+ * Gets the padding for a given state as a #GtkBorder.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_theming_engine_get_padding (GtkThemingEngine *engine,
+ GtkStateFlags state,
+ GtkBorder *padding)
+{
+ GtkThemingEnginePrivate *priv;
+
+ g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
+
+ priv = engine->priv;
+ gtk_style_context_get_padding (priv->context, state, padding);
+}
+
+/**
+ * gtk_theming_engine_get_margin:
+ * @engine: a #GtkThemingEngine
+ * @state: state to retrieve the border for
+ * @margin: (out): return value for the margin settings
+ *
+ * Gets the margin for a given state as a #GtkBorder.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_theming_engine_get_margin (GtkThemingEngine *engine,
+ GtkStateFlags state,
+ GtkBorder *margin)
+{
+ GtkThemingEnginePrivate *priv;
+
+ g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
+
+ priv = engine->priv;
+ gtk_style_context_get_margin (priv->context, state, margin);
+}
+
+/**
+ * gtk_theming_engine_get_font:
+ * @engine: a #GtkThemingEngine
+ * @state: state to retrieve the font for
+ *
+ * Returns the font description for a given state.
+ *
+ * Returns: (transfer none): the #PangoFontDescription for the given
+ * state. This object is owned by GTK+ and should not be
+ * freed.
+ *
+ * Since: 3.0
+ **/
+const PangoFontDescription *
+gtk_theming_engine_get_font (GtkThemingEngine *engine,
+ GtkStateFlags state)
+{
+ GtkThemingEnginePrivate *priv;
+
+ g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
+
+ priv = engine->priv;
+ return gtk_style_context_get_font (priv->context, state);
+}
+
/* GtkThemingModule */
static gboolean
module_path = _gtk_find_module (name, "theming-engines");
if (!module_path)
- {
- g_warning (_("Unable to locate theme engine in module path: \"%s\","), name);
- return FALSE;
- }
+ return FALSE;
module = g_module_open (module_path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
g_free (module_path);
if (!module)
- {
- g_warning ("%s", g_module_error ());
- return FALSE;
- }
+ return FALSE;
if (!g_module_symbol (module, "theme_init",
(gpointer *) &theming_module->init) ||
!g_module_symbol (module, "create_engine",
(gpointer *) &theming_module->create_engine))
{
- g_warning ("%s", g_module_error ());
g_module_close (module);
return FALSE;
*
* Returns the #GdkScreen to which @engine currently rendering to.
*
- * Returns: a #GdkScreen, or %NULL.
+ * Returns: (transfer none): a #GdkScreen, or %NULL.
**/
GdkScreen *
gtk_theming_engine_get_screen (GtkThemingEngine *engine)
gint exterior_size, interior_size, pad, thickness, border_width;
GtkBorderStyle border_style;
GtkBorder *border;
- gdouble radius;
flags = gtk_theming_engine_get_state (engine);
- radius = MIN (width, height) / 2 - 0.5;
cairo_save (cr);
if (border_style == GTK_BORDER_STYLE_SOLID)
{
cairo_set_line_width (cr, border_width);
+
+ cairo_new_sub_path (cr);
cairo_arc (cr,
- x + exterior_size / 2.,
- y + exterior_size / 2.,
- (exterior_size - 1) / 2.,
- 0, 2 * G_PI);
+ x + exterior_size / 2.,
+ y + exterior_size / 2.,
+ (exterior_size - 1) / 2.,
+ 0, 2 * G_PI);
gdk_cairo_set_source_rgba (cr, bg_color);
cairo_fill_preserve (cr);
line_thickness = MAX (1, (3 + interior_size * 2) / 7);
cairo_rectangle (cr,
- x + pad,
- y + pad + (interior_size - line_thickness) / 2.,
- interior_size,
- line_thickness);
+ x + pad,
+ y + pad + (interior_size - line_thickness) / 2.,
+ interior_size,
+ line_thickness);
cairo_fill (cr);
}
if (flags & GTK_STATE_FLAG_ACTIVE)
interior_size = MAX (1, exterior_size - 2 * pad);
if (interior_size < 5)
- {
- interior_size = 7;
- pad = MAX (0, (exterior_size - interior_size) / 2);
- }
+ {
+ interior_size = 7;
+ pad = MAX (0, (exterior_size - interior_size) / 2);
+ }
+ cairo_new_sub_path (cr);
cairo_arc (cr,
- x + pad + interior_size / 2.,
- y + pad + interior_size / 2.,
- interior_size / 2.,
- 0, 2 * G_PI);
+ x + pad + interior_size / 2.,
+ y + pad + interior_size / 2.,
+ interior_size / 2.,
+ 0, 2 * G_PI);
cairo_fill (cr);
}
}
}
+/* Set the appropriate matrix for
+ * patterns coming from the style context
+ */
+static void
+style_pattern_set_matrix (cairo_pattern_t *pattern,
+ gdouble width,
+ gdouble height)
+{
+ cairo_matrix_t matrix;
+ gint w, h;
+
+ if (cairo_pattern_get_type (pattern) == CAIRO_PATTERN_TYPE_SURFACE)
+ {
+ cairo_surface_t *surface;
+
+ cairo_pattern_get_surface (pattern, &surface);
+ w = cairo_image_surface_get_width (surface);
+ h = cairo_image_surface_get_height (surface);
+ }
+ else
+ w = h = 1;
+
+ cairo_matrix_init_scale (&matrix, (gdouble) w / width, (gdouble) h / height);
+ cairo_pattern_set_matrix (pattern, &matrix);
+}
+
static void
render_background_internal (GtkThemingEngine *engine,
cairo_t *cr,
GtkStateFlags flags;
gboolean running;
gdouble progress, alpha = 1;
- gint radius, border_width;
GtkBorder *border;
+ gint radius, border_width;
+ GtkBorderStyle border_style;
+ gdouble mat_w, mat_h;
+ cairo_matrix_t identity;
+
+ /* Use unmodified size for pattern scaling */
+ mat_w = width;
+ mat_h = height;
flags = gtk_theming_engine_get_state (engine);
- cairo_save (cr);
+
+ cairo_matrix_init_identity (&identity);
gtk_theming_engine_get (engine, flags,
"background-image", &pattern,
"background-color", &bg_color,
- "border-width", &border,
"border-radius", &radius,
+ "border-width", &border,
+ "border-style", &border_style,
NULL);
- running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress);
border_width = MIN (MIN (border->top, border->bottom),
MIN (border->left, border->right));
- _cairo_round_rectangle_sides (cr, (gdouble) radius,
- x, y, width, height,
- SIDE_ALL, junction);
- cairo_clip (cr);
+ if (border_width > 1 &&
+ border_style == GTK_BORDER_STYLE_NONE)
+ {
+ cairo_set_line_width (cr, border_width);
+
+ x += (gdouble) border_width / 2;
+ y += (gdouble) border_width / 2;
+ width -= border_width;
+ height -= border_width;
+ }
+ else
+ {
+ x += border->left;
+ y += border->top;
+ width -= border->left + border->right;
+ height -= border->top + border->bottom;
+ }
+
+ if (width <= 0 || height <= 0)
+ return;
+
+ cairo_save (cr);
+ cairo_translate (cr, x, y);
+
+ running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress);
if (gtk_theming_engine_has_class (engine, "background"))
{
cairo_paint (cr);
}
- cairo_translate (cr, x, y);
- cairo_scale (cr, width, height);
-
if (running)
{
cairo_pattern_t *other_pattern;
/* Different pattern types, or different color
* stop counts, alpha blend both patterns.
*/
- cairo_rectangle (cr, 0, 0, 1, 1);
+ _cairo_round_rectangle_sides (cr, (gdouble) radius,
+ 0, 0, width, height,
+ SIDE_ALL, junction);
+
+ style_pattern_set_matrix (other_pattern, mat_w, mat_h);
cairo_set_source (cr, other_pattern);
cairo_fill_preserve (cr);
+ cairo_pattern_set_matrix (other_pattern, &identity);
+
/* Set alpha for posterior drawing
* of the target pattern
*/
gdk_rgba_free (other_bg);
}
- cairo_rectangle (cr, 0, 0, 1, 1);
-
+ _cairo_round_rectangle_sides (cr, (gdouble) radius,
+ 0, 0, width, height,
+ SIDE_ALL, junction);
if (pattern)
{
+ style_pattern_set_matrix (pattern, mat_w, mat_h);
cairo_set_source (cr, pattern);
- cairo_pattern_destroy (pattern);
}
else
gdk_cairo_set_source_rgba (cr, bg_color);
if (alpha == 1)
- cairo_fill (cr);
+ {
+ if (border_width > 1 &&
+ border_style != GTK_BORDER_STYLE_NONE)
+ {
+ /* stroke with the same source, so the background
+ * has exactly the shape than the frame, this
+ * is important so gtk_render_background() and
+ * gtk_render_frame() fit perfectly with round
+ * borders.
+ */
+ cairo_fill_preserve (cr);
+ cairo_stroke (cr);
+ }
+ else
+ cairo_fill (cr);
+ }
else
{
- cairo_pattern_t *mask;
+ cairo_save (cr);
+ _cairo_round_rectangle_sides (cr, (gdouble) radius,
+ 0, 0, width, height,
+ SIDE_ALL, junction);
+ cairo_clip (cr);
- mask = cairo_pattern_create_rgba (1, 1, 1, alpha);
- cairo_mask (cr, mask);
- cairo_pattern_destroy (mask);
+ cairo_paint_with_alpha (cr, alpha);
+
+ cairo_restore (cr);
+ }
+
+ if (pattern)
+ {
+ cairo_pattern_set_matrix (pattern, &identity);
+ cairo_pattern_destroy (pattern);
}
cairo_restore (cr);
gdouble height)
{
GtkJunctionSides junction;
- GtkStateFlags flags;
- GtkBorder *border;
junction = gtk_theming_engine_get_junction_sides (engine);
- if (gtk_theming_engine_has_class (engine, "spinbutton") &&
- gtk_theming_engine_has_class (engine, "button"))
- {
- x += 2;
- y += 2;
- width -= 4;
- height -= 4;
- }
-
- flags = gtk_theming_engine_get_state (engine);
- gtk_theming_engine_get (engine, flags,
- "border-width", &border,
- NULL);
-
- x += border->left;
- y += border->top;
- width -= border->left + border->right;
- height -= border->top + border->bottom;
-
render_background_internal (engine, cr,
x, y, width, height,
junction);
-
- gtk_border_free (border);
}
/* Renders the small triangle on corners so
if (slice)
{
- gtk_9slice_render (slice, cr, x, y, width, height);
- gtk_9slice_unref (slice);
+ _gtk_9slice_render (slice, cr, x, y, width, height);
+ _gtk_9slice_unref (slice);
}
else if (border_style != GTK_BORDER_STYLE_NONE)
render_frame_internal (engine, cr,
double x_double, y_double;
gdouble angle;
gint line_width;
+ gboolean running, is_rtl;
+ gdouble progress;
cairo_save (cr);
flags = gtk_theming_engine_get_state (engine);
gtk_theming_engine_get (engine, flags,
"color", &fg_color,
NULL);
- gtk_theming_engine_get (engine, 0,
- "color", &outline_color,
+ gtk_theming_engine_get (engine, flags,
+ "border-color", &outline_color,
NULL);
+ running = gtk_theming_engine_state_is_running (engine, GTK_STATE_ACTIVE, &progress);
+ is_rtl = (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_RTL);
line_width = 1;
- /* FIXME: LTR/RTL */
- if (flags & GTK_STATE_FLAG_ACTIVE)
+ if (!running)
+ progress = (flags & GTK_STATE_FLAG_ACTIVE) ? 1 : 0;
+
+ if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_HORIZONTAL))
{
- angle = G_PI / 2;
- interp = 1.0;
+ if (is_rtl)
+ angle = (G_PI) - ((G_PI / 2) * progress);
+ else
+ angle = (G_PI / 2) * progress;
}
else
{
- angle = 0;
- interp = 0;
+ if (is_rtl)
+ angle = (G_PI / 2) + ((G_PI / 2) * progress);
+ else
+ angle = (G_PI / 2) - ((G_PI / 2) * progress);
}
+ interp = progress;
+
/* Compute distance that the stroke extends beyonds the end
* of the triangle we draw.
*/
const PangoMatrix *matrix;
GdkRGBA *fg_color;
GtkStateFlags flags;
- GdkScreen *screen;
gdouble progress;
gboolean running;
"color", &fg_color,
NULL);
- screen = gtk_theming_engine_get_screen (engine);
matrix = pango_context_get_matrix (pango_layout_get_context (layout));
running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress);
"color", &other_fg,
NULL);
- fg_color->red = CLAMP (fg_color->red + ((other_fg->red - fg_color->red) * progress), 0, 1);
- fg_color->green = CLAMP (fg_color->green + ((other_fg->green - fg_color->green) * progress), 0, 1);
- fg_color->blue = CLAMP (fg_color->blue + ((other_fg->blue - fg_color->blue) * progress), 0, 1);
- fg_color->alpha = CLAMP (fg_color->alpha + ((other_fg->alpha - fg_color->alpha) * progress), 0, 1);
+ if (fg_color && other_fg)
+ {
+ fg_color->red = CLAMP (fg_color->red + ((other_fg->red - fg_color->red) * progress), 0, 1);
+ fg_color->green = CLAMP (fg_color->green + ((other_fg->green - fg_color->green) * progress), 0, 1);
+ fg_color->blue = CLAMP (fg_color->blue + ((other_fg->blue - fg_color->blue) * progress), 0, 1);
+ fg_color->alpha = CLAMP (fg_color->alpha + ((other_fg->alpha - fg_color->alpha) * progress), 0, 1);
+ }
- gdk_rgba_free (other_fg);
+ if (other_fg)
+ gdk_rgba_free (other_fg);
}
if (matrix)
{
cairo_matrix_t cairo_matrix;
- PangoMatrix tmp_matrix;
PangoRectangle rect;
cairo_matrix_init (&cairo_matrix,
pango_matrix_transform_rectangle (matrix, &rect);
pango_extents_to_pixels (&rect, NULL);
- tmp_matrix = *matrix;
cairo_matrix.x0 += x - rect.x;
cairo_matrix.y0 += y - rect.y;
cairo_set_matrix (cr, &cairo_matrix);
}
else
- cairo_translate (cr, x, y);
+ cairo_move_to (cr, x, y);
if (flags & GTK_STATE_FLAG_INSENSITIVE)
{
+ GdkRGBA bg;
+
+ gtk_theming_engine_get_background_color (engine, flags, &bg);
+
cairo_save (cr);
- cairo_set_source_rgb (cr, 1, 1, 1);
- cairo_move_to (cr, 1, 1);
+
+ gdk_cairo_set_source_rgba (cr, &bg);
+
+ cairo_move_to (cr, x + 1, y + 1);
_gtk_pango_fill_layout (cr, layout);
cairo_restore (cr);
}
gap_side == GTK_POS_BOTTOM)
render_background_internal (engine, cr,
0, 0, width, height,
- junction);
+ GTK_JUNCTION_BOTTOM);
else
render_background_internal (engine, cr,
0, 0, height, width,
- junction);
-
+ GTK_JUNCTION_BOTTOM);
cairo_restore (cr);
cairo_save (cr);
GtkStateFlags flags;
GdkRGBA *bg_color;
GdkRGBA lighter, darker;
+ GtkJunctionSides sides;
gint xx, yy;
cairo_save (cr);
flags = gtk_theming_engine_get_state (engine);
- cairo_set_line_width (cr, 1);
+ cairo_set_line_width (cr, 1.0);
+ sides = gtk_theming_engine_get_junction_sides (engine);
gtk_theming_engine_get (engine, flags,
"background-color", &bg_color,
color_shade (bg_color, 0.7, &darker);
color_shade (bg_color, 1.3, &lighter);
- gdk_cairo_set_source_rgba (cr, bg_color);
- cairo_rectangle (cr, x, y, width, height);
- cairo_fill (cr);
+ render_background_internal (engine, cr, x, y, width, height, sides);
- if (gtk_theming_engine_has_class (engine, "grip"))
+ if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP))
{
- GtkJunctionSides sides;
- gint skip = -1;
-
- cairo_save (cr);
-
- cairo_set_line_width (cr, 1.0);
- sides = gtk_theming_engine_get_junction_sides (engine);
-
/* reduce confusing values to a meaningful state */
if ((sides & (GTK_JUNCTION_CORNER_TOPLEFT | GTK_JUNCTION_CORNER_BOTTOMRIGHT)) == (GTK_JUNCTION_CORNER_TOPLEFT | GTK_JUNCTION_CORNER_BOTTOMRIGHT))
sides &= ~GTK_JUNCTION_CORNER_TOPLEFT;
height = width;
else if (height < width)
width = height;
-
- skip = 2;
}
else if (sides == GTK_JUNCTION_CORNER_BOTTOMLEFT)
{
}
else if (height < width)
width = height;
-
- skip = 1;
}
else if (sides == GTK_JUNCTION_RIGHT)
{
x += (width - height);
width = height;
}
-
- skip = 3;
}
else if (sides == GTK_JUNCTION_CORNER_BOTTOMRIGHT)
{
x += (width - height);
width = height;
}
-
- skip = 0;
}
else if (sides == GTK_JUNCTION_TOP)
{
gdk_cairo_set_source_rgba (cr, &darker);
add_path_line (cr, x, yi, x + width, yi);
cairo_stroke (cr);
- yi+= 2;
+ yi += 2;
}
}
else if (sides == GTK_JUNCTION_CORNER_TOPLEFT)
yi += 3;
}
}
-
- cairo_restore (cr);
}
- else if (gtk_theming_engine_has_class (engine, "paned"))
+ else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PANE_SEPARATOR))
{
if (width > height)
for (xx = x + width / 2 - 15; xx <= x + width / 2 + 15; xx += 5)
else
{
for (yy = y; yy < y + height; yy += 3)
- for (xx = x; xx < x + width; xx += 6)
- {
- render_dot (cr, &lighter, &darker, xx, yy, 2);
- render_dot (cr, &lighter, &darker, xx + 3, yy + 1, 2);
- }
+ for (xx = x; xx < x + width; xx += 6)
+ {
+ render_dot (cr, &lighter, &darker, xx, yy, 2);
+ render_dot (cr, &lighter, &darker, xx + 3, yy + 1, 2);
+ }
}
cairo_restore (cr);
GtkStateFlags state;
guint num_steps, step;
GdkRGBA *color;
- gdouble dx, dy;
gdouble progress;
gdouble radius;
gdouble half;
gint i;
- num_steps = 0;
-
- gtk_theming_engine_get_style (engine,
- "num-steps", &num_steps,
- NULL);
+ num_steps = 12;
state = gtk_theming_engine_get_state (engine);
gtk_theming_engine_get (engine, state,
"color", &color,
NULL);
- if (num_steps == 0)
- num_steps = 12;
if (gtk_theming_engine_state_is_running (engine, GTK_STATE_ACTIVE, &progress))
step = (guint) (progress * num_steps);
cairo_save (cr);
- cairo_translate (cr, x, y);
-
- /* draw clip region */
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_set_line_width (cr, 2.0);
+ cairo_translate (cr, x + width / 2, y + height / 2);
- dx = width / 2;
- dy = height / 2;
radius = MIN (width / 2, height / 2);
half = num_steps / 2;
gint inset = 0.7 * radius;
/* transparency is a function of time and intial value */
- gdouble t = (gdouble) ((i + num_steps - step)
- % num_steps) / num_steps;
-
- cairo_save (cr);
+ gdouble t = 1.0 - (gdouble) ((i + step) % num_steps) / num_steps;
+ gdouble xscale = - sin (i * G_PI / half);
+ gdouble yscale = - cos (i * G_PI / half);
cairo_set_source_rgba (cr,
color->red,
color->blue,
color->alpha * t);
- cairo_set_line_width (cr, 2.0);
cairo_move_to (cr,
- dx + (radius - inset) * cos (i * G_PI / half),
- dy + (radius - inset) * sin (i * G_PI / half));
+ (radius - inset) * xscale,
+ (radius - inset) * yscale);
cairo_line_to (cr,
- dx + radius * cos (i * G_PI / half),
- dy + radius * sin (i * G_PI / half));
+ radius * xscale,
+ radius * yscale);
cairo_stroke (cr);
-
- cairo_restore (cr);
}
cairo_restore (cr);
return gtk_icon_size_lookup_for_settings (settings, size, width, height);
}
+/* Kudos to the gnome-panel guys. */
+static void
+colorshift_pixbuf (GdkPixbuf *src,
+ GdkPixbuf *dest,
+ gint shift)
+{
+ gint i, j;
+ gint width, height, has_alpha, src_rowstride, dest_rowstride;
+ guchar *target_pixels;
+ guchar *original_pixels;
+ guchar *pix_src;
+ guchar *pix_dest;
+ int val;
+ guchar r, g, b;
+
+ has_alpha = gdk_pixbuf_get_has_alpha (src);
+ width = gdk_pixbuf_get_width (src);
+ height = gdk_pixbuf_get_height (src);
+ src_rowstride = gdk_pixbuf_get_rowstride (src);
+ dest_rowstride = gdk_pixbuf_get_rowstride (dest);
+ original_pixels = gdk_pixbuf_get_pixels (src);
+ target_pixels = gdk_pixbuf_get_pixels (dest);
+
+ for (i = 0; i < height; i++)
+ {
+ pix_dest = target_pixels + i * dest_rowstride;
+ pix_src = original_pixels + i * src_rowstride;
+
+ for (j = 0; j < width; j++)
+ {
+ r = *(pix_src++);
+ g = *(pix_src++);
+ b = *(pix_src++);
+
+ val = r + shift;
+ *(pix_dest++) = CLAMP (val, 0, 255);
+
+ val = g + shift;
+ *(pix_dest++) = CLAMP (val, 0, 255);
+
+ val = b + shift;
+ *(pix_dest++) = CLAMP (val, 0, 255);
+
+ if (has_alpha)
+ *(pix_dest++) = *(pix_src++);
+ }
+ }
+}
+
static GdkPixbuf *
gtk_theming_engine_render_icon_pixbuf (GtkThemingEngine *engine,
const GtkIconSource *source,
else if (state & GTK_STATE_FLAG_PRELIGHT)
{
stated = gdk_pixbuf_copy (scaled);
- gdk_pixbuf_saturate_and_pixelate (scaled, stated,
- 1.2, FALSE);
+ colorshift_pixbuf (scaled, stated, 30);
g_object_unref (scaled);
}
else