Commit 5c46556d authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

cursors/Makefile.am added PNG version of all cursors.

2004-06-03  Michael Natterer  <mitch@gimp.org>

	* cursors/Makefile.am
	* cursors/*.png: added PNG version of all cursors.

	* cursors/gimp-tool-cursors.xcf: reordered and renamed all layers
	to match the new PNG filenames.

	* app/widgets/gimpcursor.[ch]: create cursors with alpha and color
	if the GdkDisplay supports it. Fall back to the old stuff
	otherwise.
parent 506c4c71
2004-06-03 Michael Natterer <mitch@gimp.org>
* cursors/Makefile.am
* cursors/*.png: added PNG version of all cursors.
* cursors/gimp-tool-cursors.xcf: reordered and renamed all layers
to match the new PNG filenames.
* app/widgets/gimpcursor.[ch]: create cursors with alpha and color
if the GdkDisplay supports it. Fall back to the old stuff
otherwise.
2004-06-03 Sven Neumann <sven@gimp.org>
* app/core/gimppattern.c (gimp_pattern_load_pixbuf): if a Title is
......
......@@ -24,6 +24,8 @@
#include "gimpcursor.h"
#include "cursors/gimp-tool-cursors.h"
/* standard gimp cursors */
#include "cursors/mouse.xbm"
#include "cursors/mouse_mask.xbm"
......@@ -136,6 +138,9 @@ struct _GimpBitmapCursor
GdkBitmap *bitmap;
GdkBitmap *mask;
const guint8 *pixbuf_data;
GdkPixbuf *pixbuf;
};
......@@ -146,32 +151,44 @@ static GimpBitmapCursor gimp_cursors[] =
{
mouse_bits, mouse_mask_bits,
mouse_width, mouse_height,
mouse_x_hot, mouse_y_hot, NULL, NULL
mouse_x_hot, mouse_y_hot, NULL, NULL,
cursor_mouse, NULL
},
{
crosshair_bits, crosshair_mask_bits,
crosshair_width, crosshair_height,
crosshair_x_hot, crosshair_y_hot, NULL, NULL
crosshair_x_hot, crosshair_y_hot, NULL, NULL,
cursor_crosshair, NULL
},
{
crosshair_small_bits, crosshair_small_mask_bits,
crosshair_small_width, crosshair_small_height,
crosshair_small_x_hot, crosshair_small_y_hot, NULL, NULL
crosshair_small_x_hot, crosshair_small_y_hot, NULL, NULL,
cursor_crosshair_small, NULL
},
{
bad_bits, bad_mask_bits,
bad_width, bad_height,
bad_x_hot, bad_y_hot, NULL, NULL
bad_x_hot, bad_y_hot, NULL, NULL,
cursor_bad, NULL
},
{
zoom_bits, zoom_mask_bits,
zoom_width, zoom_height,
zoom_x_hot, zoom_y_hot, NULL, NULL
zoom_x_hot, zoom_y_hot, NULL, NULL,
cursor_zoom, NULL
},
{
dropper_bits, dropper_mask_bits,
dropper_width, dropper_height,
dropper_x_hot, dropper_y_hot, NULL, NULL
dropper_x_hot, dropper_y_hot, NULL, NULL,
cursor_color_picker, NULL
}
};
......@@ -182,162 +199,226 @@ static GimpBitmapCursor gimp_stock_tool_cursors[] =
{
NULL, NULL,
0, 0,
0, 0, NULL, NULL
0, 0, NULL, NULL,
NULL, NULL
},
{
rect_select_small_bits, rect_select_small_mask_bits,
rect_select_small_width, rect_select_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_rect_select, NULL
},
{
ellipse_select_small_bits, ellipse_select_small_mask_bits,
ellipse_select_small_width, ellipse_select_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_ellipse_select, NULL
},
{
free_select_small_bits, free_select_small_mask_bits,
free_select_small_width, free_select_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_free_select, NULL
},
{
fuzzy_select_small_bits, fuzzy_select_small_mask_bits,
fuzzy_select_small_width, fuzzy_select_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_fuzzy_select, NULL
},
{
bezier_select_small_bits, bezier_select_small_mask_bits,
bezier_select_small_width, bezier_select_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_paths, NULL
},
{
scissors_small_bits, scissors_small_mask_bits,
scissors_small_width, scissors_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_iscissors, NULL
},
{
move_small_bits, move_small_mask_bits,
move_small_width, move_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_move, NULL
},
{
zoom_small_bits, zoom_small_mask_bits,
zoom_small_width, zoom_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_zoom, NULL
},
{
crop_small_bits, crop_small_mask_bits,
crop_small_width, crop_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_crop, NULL
},
{
resize_small_bits, resize_small_mask_bits,
resize_small_width, resize_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_resize, NULL
},
{
rotate_small_bits, rotate_small_mask_bits,
rotate_small_width, rotate_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_rotate, NULL
},
{
shear_small_bits, shear_small_mask_bits,
shear_small_width, shear_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_shear, NULL
},
{
perspective_small_bits, perspective_small_mask_bits,
perspective_small_width, perspective_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_perspective, NULL
},
{
flip_horizontal_small_bits, flip_horizontal_small_mask_bits,
flip_horizontal_small_width, flip_horizontal_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_flip_horizontal, NULL
},
{
flip_vertical_small_bits, flip_vertical_small_mask_bits,
flip_vertical_small_width, flip_vertical_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_flip_vertical, NULL
},
{
text_small_bits, text_small_mask_bits,
text_small_width, text_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_text, NULL
},
{
dropper_small_bits, dropper_small_mask_bits,
dropper_small_width, dropper_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_color_picker, NULL
},
{
bucket_fill_small_bits, bucket_fill_small_mask_bits,
bucket_fill_small_width, bucket_fill_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_bucket_fill, NULL
},
{
blend_small_bits, blend_small_mask_bits,
blend_small_width, blend_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_blend, NULL
},
{
pencil_small_bits, pencil_small_mask_bits,
pencil_small_width, pencil_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_pencil, NULL
},
{
paintbrush_small_bits, paintbrush_small_mask_bits,
paintbrush_small_width, paintbrush_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_paintbrush, NULL
},
{
airbrush_small_bits, airbrush_small_mask_bits,
airbrush_small_width, airbrush_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_airbrush, NULL
},
{
ink_small_bits, ink_small_mask_bits,
ink_small_width, ink_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_ink, NULL
},
{
clone_small_bits, clone_small_mask_bits,
clone_small_width, clone_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_clone, NULL
},
{
eraser_small_bits, eraser_small_mask_bits,
eraser_small_width, eraser_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_eraser, NULL
},
{
smudge_small_bits, smudge_small_mask_bits,
smudge_small_width, smudge_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_smudge, NULL
},
{
blur_small_bits, blur_small_mask_bits,
blur_small_width, blur_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_blur, NULL
},
{
dodge_small_bits, dodge_small_mask_bits,
dodge_small_width, dodge_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_dodge, NULL
},
{
burn_small_bits, burn_small_mask_bits,
burn_small_width, burn_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_burn, NULL
},
{
measure_small_bits, measure_small_mask_bits,
measure_small_width, measure_small_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
tool_measure, NULL
},
{
hand_small_bits, hand_small_mask_bits,
hand_small_width, hand_small_height,
hand_small_x_hot, hand_small_y_hot, NULL, NULL
hand_small_x_hot, hand_small_y_hot, NULL, NULL,
tool_hand, NULL
}
};
......@@ -348,57 +429,79 @@ static GimpBitmapCursor gimp_modifier_cursors[] =
{
NULL, NULL,
0, 0,
0, 0, NULL, NULL
0, 0, NULL, NULL,
NULL, NULL
},
{
plus_bits, plus_mask_bits,
plus_width, plus_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
modifier_plus, NULL
},
{
minus_bits, minus_mask_bits,
minus_width, minus_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
modifier_minus, NULL
},
{
intersect_bits, intersect_mask_bits,
intersect_width, intersect_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
modifier_intersect, NULL
},
{
move_bits, move_mask_bits,
move_width, move_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
modifier_move, NULL
},
{
resize_bits, resize_mask_bits,
resize_width, resize_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
modifier_resize, NULL
},
{
control_bits, control_mask_bits,
control_width, control_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
modifier_control, NULL
},
{
anchor_bits, anchor_mask_bits,
anchor_width, anchor_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
modifier_anchor, NULL
},
{
foreground_bits, foreground_mask_bits,
foreground_width, foreground_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
modifier_foreground, NULL
},
{
background_bits, background_mask_bits,
background_width, background_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
modifier_background, NULL
},
{
pattern_bits, pattern_mask_bits,
pattern_width, pattern_height,
0, 0, NULL, NULL
0, 0, NULL, NULL,
modifier_pattern, NULL
}
};
......@@ -419,11 +522,11 @@ create_cursor_bitmaps (GimpBitmapCursor *bmcursor)
g_return_if_fail (bmcursor->mask != NULL);
}
GdkCursor *
gimp_cursor_new (GdkDisplay *display,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier)
static GdkCursor *
gimp_cursor_new_from_bitmap (GdkDisplay *display,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier)
{
GdkCursor *cursor;
GdkBitmap *bitmap;
......@@ -566,6 +669,140 @@ gimp_cursor_new (GdkDisplay *display,
return cursor;
}
static void
create_cursor_pixbuf (GimpBitmapCursor *bmcursor)
{
if (bmcursor->pixbuf == NULL)
bmcursor->pixbuf = gdk_pixbuf_new_from_inline (-1, bmcursor->pixbuf_data,
FALSE, NULL);
g_return_if_fail (bmcursor->pixbuf != NULL);
}
static GdkCursor *
gimp_cursor_new_from_pixbuf (GdkDisplay *display,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier)
{
GdkCursor *cursor;
GdkPixbuf *pixbuf;
gint width;
gint height;
GimpBitmapCursor *bmcursor = NULL;
GimpBitmapCursor *bmmodifier = NULL;
GimpBitmapCursor *bmtool = NULL;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (cursor_type < GIMP_LAST_CURSOR_ENTRY, NULL);
if (cursor_type <= GDK_LAST_CURSOR)
return gdk_cursor_new_for_display (display, cursor_type);
g_return_val_if_fail (cursor_type >= GIMP_MOUSE_CURSOR, NULL);
/* allow the small tool cursor only with the standard mouse,
* the small crosshair and the bad cursor
*/
if (cursor_type != GIMP_MOUSE_CURSOR &&
cursor_type != GIMP_CROSSHAIR_SMALL_CURSOR &&
cursor_type != GIMP_BAD_CURSOR)
{
tool_cursor = GIMP_TOOL_CURSOR_NONE;
}
/* prepare the main cursor */
cursor_type -= GIMP_MOUSE_CURSOR;
bmcursor = &gimp_cursors[cursor_type];
if (! bmcursor->pixbuf)
create_cursor_pixbuf (bmcursor);
/* prepare the tool cursor */
if (tool_cursor >= GIMP_LAST_STOCK_TOOL_CURSOR_ENTRY)
{
tool_cursor = GIMP_TOOL_CURSOR_NONE;
}
if (tool_cursor != GIMP_TOOL_CURSOR_NONE)
{
bmtool = &gimp_stock_tool_cursors[tool_cursor];
if (! bmtool->pixbuf)
create_cursor_pixbuf (bmtool);
}
/* prepare the cursor modifier */
if (modifier >= GIMP_LAST_CURSOR_MODIFIER_ENTRY)
{
modifier = GIMP_CURSOR_MODIFIER_NONE;
}
if (modifier != GIMP_CURSOR_MODIFIER_NONE)
{
bmmodifier = &gimp_modifier_cursors[modifier];
if (! bmmodifier->pixbuf)
create_cursor_pixbuf (bmmodifier);
}
width = gdk_pixbuf_get_width (bmcursor->pixbuf);
height = gdk_pixbuf_get_height (bmcursor->pixbuf);
/* new bitmap and mask for on-the-fly cursor creation */
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
gdk_pixbuf_fill (pixbuf, 0);
/* first draw the bitmap completely ... */
gdk_pixbuf_composite (bmcursor->pixbuf, pixbuf,
0, 0, width, height,
0.0, 0.0, 1.0, 1.0,
GDK_INTERP_NEAREST, 255);
if (bmmodifier)
gdk_pixbuf_composite (bmmodifier->pixbuf, pixbuf,
0, 0, width, height,
0.0, 0.0, 1.0, 1.0,
GDK_INTERP_NEAREST, 255);
if (bmtool)
gdk_pixbuf_composite (bmtool->pixbuf, pixbuf,
0, 0, width, height,
0.0, 0.0, 1.0, 1.0,
GDK_INTERP_NEAREST, 255);
cursor = gdk_cursor_new_from_pixbuf (display, pixbuf,
bmcursor->x_hot,
bmcursor->y_hot);
g_object_unref (pixbuf);
return cursor;
}
GdkCursor *
gimp_cursor_new (GdkDisplay *display,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
if (gdk_display_supports_cursor_alpha (display) &&
gdk_display_supports_cursor_color (display))
{
return gimp_cursor_new_from_pixbuf (display,
cursor_type, tool_cursor, modifier);
}
return gimp_cursor_new_from_bitmap (display,
cursor_type, tool_cursor, modifier);
}
void
gimp_cursor_set (GtkWidget *widget,
GimpCursorType cursor_type,
......
......@@ -22,13 +22,12 @@
GdkCursor * gimp_cursor_new (GdkDisplay *display,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
void gimp_cursor_set (GtkWidget *widget,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
#endif /* __GIMP_CURSOR_H__ */
......@@ -2,3 +2,5 @@ Makefile
Makefile.in
.xvpics
.thumbnails
tool-cursors.list
gimp-tool-cursors.h
## Process this file with automake to produce Makefile.in
CURSOR_IMAGES = \
cursor-bad.png \
cursor-color-picker.png \
cursor-crosshair.png \
cursor-crosshair-small.png \
cursor-mouse.png \
cursor-zoom.png \
\
modifier-anchor.png \
modifier-background.png \
modifier-control.png \
modifier-foreground.png \
modifier-intersect.png \
modifier-minus.png \
modifier-move.png \
modifier-pattern.png \
modifier-plus.png \
modifier-resize.png \
\
tool-airbrush.png \
tool-blend.png \
tool-blur.png \
tool-bucket-fill.png \
tool-burn.png \
tool-clone.png \
tool-color-picker.png \
tool-crop.png \
tool-dodge.png \
tool-ellipse-select.png \
tool-eraser.png \
tool-flip-horizontal.png \
tool-flip-vertical.png \
tool-free-select.png \
tool-fuzzy-select.png \
tool-hand.png \
tool-ink.png \
tool-iscissors.png \
tool-measure.png \
tool-move.png \
tool-paintbrush.png \
tool-paths.png \
tool-pencil.png \
tool-perspective.png \
tool-rect-select.png \
tool-resize.png \
tool-rotate.png \
tool-shear.png \
tool-smudge.png \
tool-text.png \
tool-zoom.png
EXTRA_DIST = \
$(CURSOR_IMAGES) \
gimp-tool-cursors.xcf \
\
mouse.xbm \
mouse_mask.xbm \
crosshair.xbm \
......@@ -97,3 +151,18 @@ EXTRA_DIST = \
measure_small_mask.xbm \
hand_small.xbm \
hand_small_mask.xbm
noinst_DATA = gimp-tool-cursors.h
CLEANFILES = gimp-tool-cursors.h tool-cursors.list
tool-cursors.list: $(CURSOR_IMAGES) Makefile.am
( rm -f $@; \
for image in $(CURSOR_IMAGES); do \
echo $$image | \
sed -e 's|.*/||' -e 's|-|_|g' -e 's|\.png$$||' >> $@; \
echo " $(srcdir)/$$image" >> $@; \
done )
$(srcdir)/gimp-tool-cursors.h: tool-cursors.list
$(GDK_PIXBUF_CSOURCE) --raw --build-list `cat tool-cursors.list` > $(@F)