Commit 6c6fad82 authored by Andy Hertzfeld's avatar Andy Hertzfeld

changed how selection emboldening works, also, clean-ups and bug fixes in


       changed how selection emboldening works,
       also, clean-ups and bug fixes in the graphic effects
parent f1fbd379
2000-03-27 Andy Hertzfeld <andy@eazel.com>
Changed how selection emboldening works. The problem was that using
a bold font changed the text layout, making words jump from line to
line when an icon was selected. The new approach doesn't use a bold
font; instead it just draws it an extra time, offset by a pixel
* libnautilus/nautilus-icon-canvas-item.c:
embolden by drawing twice instead of using a bold font; also, removed
the "hilight_font" stuff
* libnautilus/nautilus-icon-private.h:
removed the hilite_font field
* libnautilus/nautilus-icon-container.h:
removed the highlight font stuff
* libnautilus/nautilus-graphic-effects.c,h:
cleaned up by using a common routine to make the destination pixbuf;
fixed bug in create_darkened_pixbuf by using separate counts for source
and destination rowstride;
added a "create_colorized_pixbuf" routine
2000-03-26 Ramiro Estrugo <ramiro@eazel.com> 2000-03-26 Ramiro Estrugo <ramiro@eazel.com>
Removed the ETTORE user level easter egg and bullet proofed the Removed the ETTORE user level easter egg and bullet proofed the
......
...@@ -33,6 +33,18 @@ ...@@ -33,6 +33,18 @@
#include "nautilus-graphic-effects.h" #include "nautilus-graphic-effects.h"
/* shared utility to create a new pixbuf from the passed-in one */
static GdkPixbuf *
create_new_pixbuf (GdkPixbuf *src)
{
return gdk_pixbuf_new (gdk_pixbuf_get_format (src),
gdk_pixbuf_get_has_alpha (src),
gdk_pixbuf_get_bits_per_sample (src),
gdk_pixbuf_get_width (src),
gdk_pixbuf_get_height (src));
}
/* utility routine to bump the level of a color component with pinning */ /* utility routine to bump the level of a color component with pinning */
static guchar static guchar
...@@ -56,11 +68,7 @@ create_spotlight_pixbuf (GdkPixbuf* src) ...@@ -56,11 +68,7 @@ create_spotlight_pixbuf (GdkPixbuf* src)
guchar *pixdest; guchar *pixdest;
GdkPixbuf *dest; GdkPixbuf *dest;
dest = gdk_pixbuf_new (gdk_pixbuf_get_format (src), dest = create_new_pixbuf (src);
gdk_pixbuf_get_has_alpha (src),
gdk_pixbuf_get_bits_per_sample (src),
gdk_pixbuf_get_width (src),
gdk_pixbuf_get_height (src));
has_alpha = gdk_pixbuf_get_has_alpha (src); has_alpha = gdk_pixbuf_get_has_alpha (src);
width = gdk_pixbuf_get_width (src); width = gdk_pixbuf_get_width (src);
...@@ -96,7 +104,7 @@ GdkPixbuf * ...@@ -96,7 +104,7 @@ GdkPixbuf *
create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken) create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken)
{ {
gint i, j; gint i, j;
gint width, height, has_alpha, rowstride; gint width, height, has_alpha, src_rowstride, dst_rowstride;
guchar *target_pixels; guchar *target_pixels;
guchar *original_pixels; guchar *original_pixels;
guchar *pixsrc; guchar *pixsrc;
...@@ -107,22 +115,19 @@ create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken) ...@@ -107,22 +115,19 @@ create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken)
guchar r,g,b; guchar r,g,b;
GdkPixbuf *dest; GdkPixbuf *dest;
dest = gdk_pixbuf_new (gdk_pixbuf_get_format (src), dest = create_new_pixbuf (src);
gdk_pixbuf_get_has_alpha (src),
gdk_pixbuf_get_bits_per_sample (src),
gdk_pixbuf_get_width (src),
gdk_pixbuf_get_height (src));
has_alpha = gdk_pixbuf_get_has_alpha (src); has_alpha = gdk_pixbuf_get_has_alpha (src);
width = gdk_pixbuf_get_width (src); width = gdk_pixbuf_get_width (src);
height = gdk_pixbuf_get_height (src); height = gdk_pixbuf_get_height (src);
rowstride = gdk_pixbuf_get_rowstride (src); src_rowstride = gdk_pixbuf_get_rowstride (src);
dst_rowstride = gdk_pixbuf_get_rowstride (dest);
target_pixels = gdk_pixbuf_get_pixels (dest); target_pixels = gdk_pixbuf_get_pixels (dest);
original_pixels = gdk_pixbuf_get_pixels (src); original_pixels = gdk_pixbuf_get_pixels (src);
for (i = 0; i < height; i++) { for (i = 0; i < height; i++) {
pixdest = target_pixels + i*rowstride; pixdest = target_pixels + i*dst_rowstride;
pixsrc = original_pixels + i*rowstride; pixsrc = original_pixels + i*src_rowstride;
for (j = 0; j < width; j++) { for (j = 0; j < width; j++) {
r = *(pixsrc++); r = *(pixsrc++);
g = *(pixsrc++); g = *(pixsrc++);
...@@ -141,6 +146,45 @@ create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken) ...@@ -141,6 +146,45 @@ create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken)
} }
#undef INTENSITY #undef INTENSITY
/* this routine colorizes the passed-in pixbuf by multiplying each pixel with the passed in color */
GdkPixbuf *
create_colorized_pixbuf(GdkPixbuf *src, int red_value, int green_value, int blue_value)
{
int i, j;
int width, height, has_alpha, src_rowstride, dst_rowstride;
guchar *target_pixels;
guchar *original_pixels;
guchar *pixsrc;
guchar *pixdest;
GdkPixbuf *dest;
dest = create_new_pixbuf (src);
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);
dst_rowstride = gdk_pixbuf_get_rowstride (dest);
target_pixels = gdk_pixbuf_get_pixels (dest);
original_pixels = gdk_pixbuf_get_pixels (src);
for (i = 0; i < height; i++) {
pixdest = target_pixels + i*dst_rowstride;
pixsrc = original_pixels + i*src_rowstride;
for (j = 0; j < width; j++) {
*(pixdest++) = (*(pixsrc++) * red_value) >> 8;
*(pixdest++) = (*(pixsrc++) * green_value) >> 8;
*(pixdest++) = (*(pixsrc++) * blue_value) >> 8;
if (has_alpha) {
*(pixdest++) = *(pixsrc++);
}
}
}
return dest;
}
/* this routine takes the source pixbuf and returns a new one that's semi-transparent, by /* this routine takes the source pixbuf and returns a new one that's semi-transparent, by
clearing every other pixel's alpha value in a checkerboard grip. We have to do the clearing every other pixel's alpha value in a checkerboard grip. We have to do the
checkerboard instead of reducing the alpha since it will be turned into an alpha-less checkerboard instead of reducing the alpha since it will be turned into an alpha-less
......
...@@ -35,6 +35,9 @@ GdkPixbuf* create_spotlight_pixbuf (GdkPixbuf* source_pixbuf); ...@@ -35,6 +35,9 @@ GdkPixbuf* create_spotlight_pixbuf (GdkPixbuf* source_pixbuf);
/* return a darkened pixbuf for selection hiliting */ /* return a darkened pixbuf for selection hiliting */
GdkPixbuf* create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken); GdkPixbuf* create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken);
/* return a pixbuf colorized with the color specified by the parameter */
GdkPixbuf* create_colorized_pixbuf(GdkPixbuf *src, int red_value, int green_value, int blue_value);
/* return a semi-transparent pixbuf from the source pixbuf using a checkboard /* return a semi-transparent pixbuf from the source pixbuf using a checkboard
stipple in the alpha channel (so it can be converted to an alpha-less pixmap) */ stipple in the alpha channel (so it can be converted to an alpha-less pixmap) */
GdkPixbuf* make_semi_transparent(GdkPixbuf *source_pixbuf); GdkPixbuf* make_semi_transparent(GdkPixbuf *source_pixbuf);
......
...@@ -52,7 +52,6 @@ struct NautilusIconCanvasItemDetails { ...@@ -52,7 +52,6 @@ struct NautilusIconCanvasItemDetails {
GList *emblem_pixbufs; GList *emblem_pixbufs;
char *text; char *text;
GdkFont *font; GdkFont *font;
GdkFont *highlight_font;
ArtIRect embedded_text_rect; ArtIRect embedded_text_rect;
char *embedded_text_file_URI; char *embedded_text_file_URI;
...@@ -73,7 +72,6 @@ enum { ...@@ -73,7 +72,6 @@ enum {
ARG_0, ARG_0,
ARG_TEXT, ARG_TEXT,
ARG_FONT, ARG_FONT,
ARG_HIGHLIGHT_FONT,
ARG_HIGHLIGHTED_FOR_SELECTION, ARG_HIGHLIGHTED_FOR_SELECTION,
ARG_HIGHLIGHTED_AS_KEYBOARD_FOCUS, ARG_HIGHLIGHTED_AS_KEYBOARD_FOCUS,
ARG_HIGHLIGHTED_FOR_DROP, ARG_HIGHLIGHTED_FOR_DROP,
...@@ -183,10 +181,7 @@ nautilus_icon_canvas_item_initialize_class (NautilusIconCanvasItemClass *class) ...@@ -183,10 +181,7 @@ nautilus_icon_canvas_item_initialize_class (NautilusIconCanvasItemClass *class)
gtk_object_add_arg_type ("NautilusIconCanvasItem::text", gtk_object_add_arg_type ("NautilusIconCanvasItem::text",
GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TEXT); GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TEXT);
gtk_object_add_arg_type ("NautilusIconCanvasItem::font", gtk_object_add_arg_type ("NautilusIconCanvasItem::font",
GTK_TYPE_BOXED, GTK_ARG_READWRITE, ARG_FONT); GTK_TYPE_BOXED, GTK_ARG_READWRITE, ARG_FONT);
gtk_object_add_arg_type ("NautilusIconCanvasItem::highlight_font",
GTK_TYPE_BOXED, GTK_ARG_READWRITE, ARG_HIGHLIGHT_FONT);
gtk_object_add_arg_type ("NautilusIconCanvasItem::highlighted_for_selection", gtk_object_add_arg_type ("NautilusIconCanvasItem::highlighted_for_selection",
GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HIGHLIGHTED_FOR_SELECTION); GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HIGHLIGHTED_FOR_SELECTION);
gtk_object_add_arg_type ("NautilusIconCanvasItem::highlighted_as_keyboard_focus", gtk_object_add_arg_type ("NautilusIconCanvasItem::highlighted_as_keyboard_focus",
...@@ -257,10 +252,7 @@ nautilus_icon_canvas_item_destroy (GtkObject *object) ...@@ -257,10 +252,7 @@ nautilus_icon_canvas_item_destroy (GtkObject *object)
nautilus_gdk_pixbuf_list_free (details->emblem_pixbufs); nautilus_gdk_pixbuf_list_free (details->emblem_pixbufs);
g_free (details->text); g_free (details->text);
if (details->font != NULL) if (details->font != NULL)
gdk_font_unref (details->font); gdk_font_unref (details->font);
if (details->highlight_font != NULL)
gdk_font_unref (details->highlight_font);
g_free (details); g_free (details);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
...@@ -314,21 +306,6 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) ...@@ -314,21 +306,6 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
details->font = font; details->font = font;
break; break;
case ARG_HIGHLIGHT_FONT:
font = GTK_VALUE_BOXED (*arg);
if (nautilus_gdk_font_equal (font, details->highlight_font)) {
return;
}
if (font != NULL) {
gdk_font_ref (font);
}
if (details->highlight_font != NULL) {
gdk_font_unref (details->highlight_font);
}
details->highlight_font = font;
break;
case ARG_HIGHLIGHTED_FOR_SELECTION: case ARG_HIGHLIGHTED_FOR_SELECTION:
if (!details->is_highlighted_for_selection == !GTK_VALUE_BOOL (*arg)) { if (!details->is_highlighted_for_selection == !GTK_VALUE_BOOL (*arg)) {
return; return;
...@@ -384,11 +361,7 @@ nautilus_icon_canvas_item_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) ...@@ -384,11 +361,7 @@ nautilus_icon_canvas_item_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_FONT: case ARG_FONT:
GTK_VALUE_BOXED (*arg) = details->font; GTK_VALUE_BOXED (*arg) = details->font;
break; break;
case ARG_HIGHLIGHT_FONT:
GTK_VALUE_BOXED (*arg) = details->highlight_font;
break;
case ARG_HIGHLIGHTED_FOR_SELECTION: case ARG_HIGHLIGHTED_FOR_SELECTION:
GTK_VALUE_BOOL (*arg) = details->is_highlighted_for_selection; GTK_VALUE_BOOL (*arg) = details->is_highlighted_for_selection;
break; break;
...@@ -577,7 +550,6 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item, ...@@ -577,7 +550,6 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
NautilusIconCanvasItemDetails *details; NautilusIconCanvasItemDetails *details;
int width_so_far, height_so_far; int width_so_far, height_so_far;
GdkGC* gc; GdkGC* gc;
GdkFont *font;
int max_text_width; int max_text_width;
int icon_width, text_left, box_left; int icon_width, text_left, box_left;
GnomeIconTextInfo *icon_text_info; GnomeIconTextInfo *icon_text_info;
...@@ -587,12 +559,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item, ...@@ -587,12 +559,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
details = item->details; details = item->details;
if (details->is_highlighted_for_selection) if (details->font == NULL || details->text == NULL || details->text[0] == '\0') {
font = details->highlight_font;
else
font = details->font;
if (font == NULL || details->text == NULL || details->text[0] == '\0') {
details->text_height = 0; details->text_height = 0;
details->text_width = 0; details->text_width = 0;
return; return;
...@@ -607,7 +574,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item, ...@@ -607,7 +574,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
} }
max_text_width = floor (MAX_TEXT_WIDTH * GNOME_CANVAS_ITEM (item)->canvas->pixels_per_unit); max_text_width = floor (MAX_TEXT_WIDTH * GNOME_CANVAS_ITEM (item)->canvas->pixels_per_unit);
pieces = g_strsplit (details->text, "\n", 0); pieces = g_strsplit (details->text, "\n", 0);
for (i = 0; (text_piece = pieces[i]) != NULL; i++) { for (i = 0; (text_piece = pieces[i]) != NULL; i++) {
/* Replace empty string with space for measurement and drawing. /* Replace empty string with space for measurement and drawing.
...@@ -618,12 +585,18 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item, ...@@ -618,12 +585,18 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
} }
icon_text_info = gnome_icon_layout_text icon_text_info = gnome_icon_layout_text
(font, text_piece, " -_,;.?/&", max_text_width, TRUE); (details->font, text_piece, " -_,;.?/&", max_text_width, TRUE);
if (drawable != NULL) { if (drawable != NULL) {
text_left = icon_left + (icon_width - icon_text_info->width) / 2; text_left = icon_left + (icon_width - icon_text_info->width) / 2;
gnome_icon_paint_text (icon_text_info, drawable, gc, gnome_icon_paint_text (icon_text_info, drawable, gc,
text_left, icon_bottom + height_so_far, GTK_JUSTIFY_CENTER); text_left, icon_bottom + height_so_far, GTK_JUSTIFY_CENTER);
/* if it's selected, embolden the text by drawing again offset by one pixel */
if (details->is_highlighted_for_selection)
gnome_icon_paint_text (icon_text_info, drawable, gc,
text_left + 1, icon_bottom + height_so_far, GTK_JUSTIFY_CENTER);
} }
width_so_far = MAX (width_so_far, icon_text_info->width); width_so_far = MAX (width_so_far, icon_text_info->width);
......
...@@ -1354,8 +1354,6 @@ destroy (GtkObject *object) ...@@ -1354,8 +1354,6 @@ destroy (GtkObject *object)
for (i = 0; i < NAUTILUS_N_ELEMENTS (container->details->label_font); i++) { for (i = 0; i < NAUTILUS_N_ELEMENTS (container->details->label_font); i++) {
if (container->details->label_font[i] != NULL) if (container->details->label_font[i] != NULL)
gdk_font_unref (container->details->label_font[i]); gdk_font_unref (container->details->label_font[i]);
if (container->details->hilite_font[i] != NULL)
gdk_font_unref (container->details->hilite_font[i]);
} }
g_free (container->details); g_free (container->details);
...@@ -1891,14 +1889,6 @@ nautilus_icon_container_initialize (NautilusIconContainer *container) ...@@ -1891,14 +1889,6 @@ nautilus_icon_container_initialize (NautilusIconContainer *container)
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGER] = load_font ("-*-helvetica-medium-r-normal-*-18-*-*-*-*-*-*-*"); details->label_font[NAUTILUS_ZOOM_LEVEL_LARGER] = load_font ("-*-helvetica-medium-r-normal-*-18-*-*-*-*-*-*-*");
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGEST] = load_font ("-*-helvetica-medium-r-normal-*-18-*-*-*-*-*-*-*"); details->label_font[NAUTILUS_ZOOM_LEVEL_LARGEST] = load_font ("-*-helvetica-medium-r-normal-*-18-*-*-*-*-*-*-*");
details->hilite_font[NAUTILUS_ZOOM_LEVEL_SMALLEST] = load_font ("-*-helvetica-bold-r-normal-*-8-*-*-*-*-*-*-*");
details->hilite_font[NAUTILUS_ZOOM_LEVEL_SMALLER] = load_font ("-*-helvetica-bold-r-normal-*-8-*-*-*-*-*-*-*");
details->hilite_font[NAUTILUS_ZOOM_LEVEL_SMALL] = load_font ("-*-helvetica-bold-r-normal-*-10-*-*-*-*-*-*-*");
details->hilite_font[NAUTILUS_ZOOM_LEVEL_STANDARD] = load_font ("-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*");
details->hilite_font[NAUTILUS_ZOOM_LEVEL_LARGE] = load_font ("-*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*");
details->hilite_font[NAUTILUS_ZOOM_LEVEL_LARGER] = load_font ("-*-helvetica-bold-r-normal-*-18-*-*-*-*-*-*-*");
details->hilite_font[NAUTILUS_ZOOM_LEVEL_LARGEST] = load_font ("-*-helvetica-bold-r-normal-*-18-*-*-*-*-*-*-*");
/* FIXME: Read this from preferences. */ /* FIXME: Read this from preferences. */
details->single_click_mode = TRUE; details->single_click_mode = TRUE;
...@@ -2175,7 +2165,7 @@ update_icon (NautilusIconContainer *container, NautilusIcon *icon) ...@@ -2175,7 +2165,7 @@ update_icon (NautilusIconContainer *container, NautilusIcon *icon)
GList *emblem_icons, *emblem_pixbufs, *p; GList *emblem_icons, *emblem_pixbufs, *p;
char *label; char *label;
char *contents_as_text; char *contents_as_text;
GdkFont *font, *item_hilite_font; GdkFont *font;
details = container->details; details = container->details;
...@@ -2214,7 +2204,6 @@ update_icon (NautilusIconContainer *container, NautilusIcon *icon) ...@@ -2214,7 +2204,6 @@ update_icon (NautilusIconContainer *container, NautilusIcon *icon)
&label); &label);
font = details->label_font[details->zoom_level]; font = details->label_font[details->zoom_level];
item_hilite_font = details->hilite_font[details->zoom_level];
/* Choose to show mini-text based on this icon's requested size, /* Choose to show mini-text based on this icon's requested size,
* not zoom level, since icon may be stretched big or small. * not zoom level, since icon may be stretched big or small.
...@@ -2233,7 +2222,6 @@ update_icon (NautilusIconContainer *container, NautilusIcon *icon) ...@@ -2233,7 +2222,6 @@ update_icon (NautilusIconContainer *container, NautilusIcon *icon)
gnome_canvas_item_set (GNOME_CANVAS_ITEM (icon->item), gnome_canvas_item_set (GNOME_CANVAS_ITEM (icon->item),
"text", label, "text", label,
"font", font, "font", font,
"highlight_font", item_hilite_font,
"text_source", contents_as_text, "text_source", contents_as_text,
NULL); NULL);
nautilus_icon_canvas_item_set_image (icon->item, pixbuf, &text_rect); nautilus_icon_canvas_item_set_image (icon->item, pixbuf, &text_rect);
......
...@@ -148,7 +148,6 @@ struct NautilusIconContainerDetails { ...@@ -148,7 +148,6 @@ struct NautilusIconContainerDetails {
/* default fonts used to draw labels */ /* default fonts used to draw labels */
GdkFont *label_font[NAUTILUS_ZOOM_LEVEL_LARGEST + 1]; GdkFont *label_font[NAUTILUS_ZOOM_LEVEL_LARGEST + 1];
GdkFont *hilite_font[NAUTILUS_ZOOM_LEVEL_LARGEST + 1];
/* State used so arrow keys don't wander if icons aren't lined up. /* State used so arrow keys don't wander if icons aren't lined up.
* Keeps track of last axis arrow key was used on. * Keeps track of last axis arrow key was used on.
......
...@@ -33,6 +33,18 @@ ...@@ -33,6 +33,18 @@
#include "nautilus-graphic-effects.h" #include "nautilus-graphic-effects.h"
/* shared utility to create a new pixbuf from the passed-in one */
static GdkPixbuf *
create_new_pixbuf (GdkPixbuf *src)
{
return gdk_pixbuf_new (gdk_pixbuf_get_format (src),
gdk_pixbuf_get_has_alpha (src),
gdk_pixbuf_get_bits_per_sample (src),
gdk_pixbuf_get_width (src),
gdk_pixbuf_get_height (src));
}
/* utility routine to bump the level of a color component with pinning */ /* utility routine to bump the level of a color component with pinning */
static guchar static guchar
...@@ -56,11 +68,7 @@ create_spotlight_pixbuf (GdkPixbuf* src) ...@@ -56,11 +68,7 @@ create_spotlight_pixbuf (GdkPixbuf* src)
guchar *pixdest; guchar *pixdest;
GdkPixbuf *dest; GdkPixbuf *dest;
dest = gdk_pixbuf_new (gdk_pixbuf_get_format (src), dest = create_new_pixbuf (src);
gdk_pixbuf_get_has_alpha (src),
gdk_pixbuf_get_bits_per_sample (src),
gdk_pixbuf_get_width (src),
gdk_pixbuf_get_height (src));
has_alpha = gdk_pixbuf_get_has_alpha (src); has_alpha = gdk_pixbuf_get_has_alpha (src);
width = gdk_pixbuf_get_width (src); width = gdk_pixbuf_get_width (src);
...@@ -96,7 +104,7 @@ GdkPixbuf * ...@@ -96,7 +104,7 @@ GdkPixbuf *
create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken) create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken)
{ {
gint i, j; gint i, j;
gint width, height, has_alpha, rowstride; gint width, height, has_alpha, src_rowstride, dst_rowstride;
guchar *target_pixels; guchar *target_pixels;
guchar *original_pixels; guchar *original_pixels;
guchar *pixsrc; guchar *pixsrc;
...@@ -107,22 +115,19 @@ create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken) ...@@ -107,22 +115,19 @@ create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken)
guchar r,g,b; guchar r,g,b;
GdkPixbuf *dest; GdkPixbuf *dest;
dest = gdk_pixbuf_new (gdk_pixbuf_get_format (src), dest = create_new_pixbuf (src);
gdk_pixbuf_get_has_alpha (src),
gdk_pixbuf_get_bits_per_sample (src),
gdk_pixbuf_get_width (src),
gdk_pixbuf_get_height (src));
has_alpha = gdk_pixbuf_get_has_alpha (src); has_alpha = gdk_pixbuf_get_has_alpha (src);
width = gdk_pixbuf_get_width (src); width = gdk_pixbuf_get_width (src);
height = gdk_pixbuf_get_height (src); height = gdk_pixbuf_get_height (src);
rowstride = gdk_pixbuf_get_rowstride (src); src_rowstride = gdk_pixbuf_get_rowstride (src);
dst_rowstride = gdk_pixbuf_get_rowstride (dest);
target_pixels = gdk_pixbuf_get_pixels (dest); target_pixels = gdk_pixbuf_get_pixels (dest);
original_pixels = gdk_pixbuf_get_pixels (src); original_pixels = gdk_pixbuf_get_pixels (src);
for (i = 0; i < height; i++) { for (i = 0; i < height; i++) {
pixdest = target_pixels + i*rowstride; pixdest = target_pixels + i*dst_rowstride;
pixsrc = original_pixels + i*rowstride; pixsrc = original_pixels + i*src_rowstride;
for (j = 0; j < width; j++) { for (j = 0; j < width; j++) {
r = *(pixsrc++); r = *(pixsrc++);
g = *(pixsrc++); g = *(pixsrc++);
...@@ -141,6 +146,45 @@ create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken) ...@@ -141,6 +146,45 @@ create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken)
} }
#undef INTENSITY #undef INTENSITY
/* this routine colorizes the passed-in pixbuf by multiplying each pixel with the passed in color */
GdkPixbuf *
create_colorized_pixbuf(GdkPixbuf *src, int red_value, int green_value, int blue_value)
{
int i, j;
int width, height, has_alpha, src_rowstride, dst_rowstride;
guchar *target_pixels;
guchar *original_pixels;
guchar *pixsrc;
guchar *pixdest;
GdkPixbuf *dest;
dest = create_new_pixbuf (src);
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);
dst_rowstride = gdk_pixbuf_get_rowstride (dest);
target_pixels = gdk_pixbuf_get_pixels (dest);
original_pixels = gdk_pixbuf_get_pixels (src);
for (i = 0; i < height; i++) {
pixdest = target_pixels + i*dst_rowstride;
pixsrc = original_pixels + i*src_rowstride;
for (j = 0; j < width; j++) {
*(pixdest++) = (*(pixsrc++) * red_value) >> 8;
*(pixdest++) = (*(pixsrc++) * green_value) >> 8;
*(pixdest++) = (*(pixsrc++) * blue_value) >> 8;
if (has_alpha) {
*(pixdest++) = *(pixsrc++);
}
}
}
return dest;
}
/* this routine takes the source pixbuf and returns a new one that's semi-transparent, by /* this routine takes the source pixbuf and returns a new one that's semi-transparent, by
clearing every other pixel's alpha value in a checkerboard grip. We have to do the clearing every other pixel's alpha value in a checkerboard grip. We have to do the
checkerboard instead of reducing the alpha since it will be turned into an alpha-less checkerboard instead of reducing the alpha since it will be turned into an alpha-less
......
...@@ -35,6 +35,9 @@ GdkPixbuf* create_spotlight_pixbuf (GdkPixbuf* source_pixbuf); ...@@ -35,6 +35,9 @@ GdkPixbuf* create_spotlight_pixbuf (GdkPixbuf* source_pixbuf);
/* return a darkened pixbuf for selection hiliting */ /* return a darkened pixbuf for selection hiliting */
GdkPixbuf* create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken); GdkPixbuf* create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken);
/* return a pixbuf colorized with the color specified by the parameter */
GdkPixbuf* create_colorized_pixbuf(GdkPixbuf *src, int red_value, int green_value, int blue_value);
/* return a semi-transparent pixbuf from the source pixbuf using a checkboard /* return a semi-transparent pixbuf from the source pixbuf using a checkboard
stipple in the alpha channel (so it can be converted to an alpha-less pixmap) */ stipple in the alpha channel (so it can be converted to an alpha-less pixmap) */
GdkPixbuf* make_semi_transparent(GdkPixbuf *source_pixbuf); GdkPixbuf* make_semi_transparent(GdkPixbuf *source_pixbuf);
......
...@@ -52,7 +52,6 @@ struct NautilusIconCanvasItemDetails { ...@@ -52,7 +52,6 @@ struct NautilusIconCanvasItemDetails {
GList *emblem_pixbufs; GList *emblem_pixbufs;
char *text; char *text;
GdkFont *font; GdkFont *font;
GdkFont *highlight_font;
ArtIRect embedded_text_rect; ArtIRect embedded_text_rect;
char *embedded_text_file_URI; char *embedded_text_file_URI;
...@@ -73,7 +72,6 @@ enum { ...@@ -73,7 +72,6 @@ enum {
ARG_0, ARG_0,
ARG_TEXT, ARG_TEXT,
ARG_FONT,