2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-25 06:05:25 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "widgets-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-14 05:51:20 +08:00
|
|
|
#include "gimpcursor.h"
|
2000-03-02 03:32:41 +08:00
|
|
|
|
2004-06-03 20:36:02 +08:00
|
|
|
#include "cursors/gimp-tool-cursors.h"
|
|
|
|
|
2010-09-11 01:12:52 +08:00
|
|
|
|
2012-08-27 19:29:18 +08:00
|
|
|
#define cursor_default_x_hot 10
|
|
|
|
#define cursor_default_y_hot 10
|
|
|
|
|
2010-09-11 01:12:52 +08:00
|
|
|
#define cursor_mouse_x_hot 3
|
|
|
|
#define cursor_mouse_y_hot 2
|
|
|
|
#define cursor_crosshair_x_hot 15
|
|
|
|
#define cursor_crosshair_y_hot 15
|
|
|
|
#define cursor_zoom_x_hot 8
|
|
|
|
#define cursor_zoom_y_hot 8
|
|
|
|
#define cursor_color_picker_x_hot 1
|
|
|
|
#define cursor_color_picker_y_hot 30
|
2000-06-09 20:31:19 +08:00
|
|
|
|
2000-03-26 02:17:01 +08:00
|
|
|
|
2004-06-10 22:43:08 +08:00
|
|
|
typedef struct _GimpCursor GimpCursor;
|
2001-05-14 05:51:20 +08:00
|
|
|
|
2004-06-10 22:43:08 +08:00
|
|
|
struct _GimpCursor
|
2001-05-14 05:51:20 +08:00
|
|
|
{
|
2004-06-03 20:36:02 +08:00
|
|
|
const guint8 *pixbuf_data;
|
2010-09-11 01:12:52 +08:00
|
|
|
const gint x_hot, y_hot;
|
2004-06-10 22:43:08 +08:00
|
|
|
|
2004-06-03 20:36:02 +08:00
|
|
|
GdkPixbuf *pixbuf;
|
2001-05-14 05:51:20 +08:00
|
|
|
};
|
2000-03-26 02:17:01 +08:00
|
|
|
|
2001-02-25 03:29:47 +08:00
|
|
|
|
2004-06-10 22:43:08 +08:00
|
|
|
static GimpCursor gimp_cursors[] =
|
1999-05-05 17:10:35 +08:00
|
|
|
{
|
2002-11-18 07:13:26 +08:00
|
|
|
/* these have to match up with enum GimpCursorType in widgets-enums.h */
|
|
|
|
|
2004-06-05 07:08:29 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_none,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2004-06-05 07:08:29 +08:00
|
|
|
},
|
2000-03-02 03:32:41 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_mouse,
|
|
|
|
cursor_mouse_x_hot, cursor_mouse_y_hot
|
2000-03-02 03:32:41 +08:00
|
|
|
},
|
2000-06-06 08:28:28 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_crosshair,
|
|
|
|
cursor_crosshair_x_hot, cursor_crosshair_y_hot
|
2000-06-06 08:28:28 +08:00
|
|
|
},
|
2000-06-09 20:31:19 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_crosshair_small,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2000-06-09 20:31:19 +08:00
|
|
|
},
|
2000-03-02 03:32:41 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_bad,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2000-03-02 03:32:41 +08:00
|
|
|
},
|
2006-11-16 06:43:24 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_move,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2006-11-16 06:43:24 +08:00
|
|
|
},
|
2000-06-14 18:59:16 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_zoom,
|
|
|
|
cursor_zoom_x_hot, cursor_zoom_y_hot
|
2000-06-14 18:59:16 +08:00
|
|
|
},
|
2000-03-02 03:32:41 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_color_picker,
|
|
|
|
cursor_color_picker_x_hot, cursor_color_picker_y_hot
|
2006-06-02 23:23:47 +08:00
|
|
|
},
|
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_corner_top_left,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2006-06-02 23:23:47 +08:00
|
|
|
},
|
2012-08-27 05:59:05 +08:00
|
|
|
{
|
|
|
|
cursor_corner_top,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2012-08-27 05:59:05 +08:00
|
|
|
},
|
2006-06-02 23:23:47 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_corner_top_right,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2006-06-02 23:23:47 +08:00
|
|
|
},
|
2012-08-27 05:59:05 +08:00
|
|
|
{
|
|
|
|
cursor_corner_left,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2012-08-27 05:59:05 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
cursor_corner_right,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2012-08-27 05:59:05 +08:00
|
|
|
},
|
2006-06-02 23:23:47 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_corner_bottom_left,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2006-06-02 23:23:47 +08:00
|
|
|
},
|
2012-08-27 05:59:05 +08:00
|
|
|
{
|
|
|
|
cursor_corner_bottom,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2012-08-27 05:59:05 +08:00
|
|
|
},
|
2006-06-02 23:23:47 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_corner_bottom_right,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2006-06-02 23:23:47 +08:00
|
|
|
},
|
2012-08-27 05:59:05 +08:00
|
|
|
{
|
|
|
|
cursor_side_top_left,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2012-08-27 05:59:05 +08:00
|
|
|
},
|
2006-06-02 23:23:47 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_side_top,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2006-06-02 23:23:47 +08:00
|
|
|
},
|
2012-08-27 05:59:05 +08:00
|
|
|
{
|
|
|
|
cursor_side_top_right,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2012-08-27 05:59:05 +08:00
|
|
|
},
|
2006-06-02 23:23:47 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_side_left,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2006-06-02 23:23:47 +08:00
|
|
|
},
|
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_side_right,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2006-06-02 23:23:47 +08:00
|
|
|
},
|
2012-08-27 05:59:05 +08:00
|
|
|
{
|
|
|
|
cursor_side_bottom_left,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2012-08-27 05:59:05 +08:00
|
|
|
},
|
2006-06-02 23:23:47 +08:00
|
|
|
{
|
2010-09-11 01:12:52 +08:00
|
|
|
cursor_side_bottom,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2012-08-27 05:59:05 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
cursor_side_bottom_right,
|
2012-08-27 19:29:18 +08:00
|
|
|
cursor_default_x_hot, cursor_default_y_hot
|
2000-06-09 20:31:19 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2004-06-10 22:43:08 +08:00
|
|
|
static GimpCursor gimp_tool_cursors[] =
|
2000-06-09 20:31:19 +08:00
|
|
|
{
|
2002-11-18 07:13:26 +08:00
|
|
|
/* these have to match up with enum GimpToolCursorType in widgets-enums.h */
|
|
|
|
|
2010-09-11 01:12:52 +08:00
|
|
|
{ NULL },
|
2012-08-27 04:53:04 +08:00
|
|
|
{ tool_rect_select },
|
|
|
|
{ tool_ellipse_select },
|
|
|
|
{ tool_free_select },
|
|
|
|
{ tool_polygon_select },
|
|
|
|
{ tool_fuzzy_select },
|
|
|
|
{ tool_paths },
|
|
|
|
{ tool_paths_anchor },
|
|
|
|
{ tool_paths_control },
|
|
|
|
{ tool_paths_segment },
|
|
|
|
{ tool_iscissors },
|
|
|
|
{ tool_move },
|
|
|
|
{ tool_zoom },
|
|
|
|
{ tool_crop },
|
|
|
|
{ tool_resize },
|
|
|
|
{ tool_rotate },
|
|
|
|
{ tool_shear },
|
|
|
|
{ tool_perspective },
|
|
|
|
{ tool_flip_horizontal },
|
|
|
|
{ tool_flip_vertical },
|
|
|
|
{ tool_text },
|
|
|
|
{ tool_color_picker },
|
|
|
|
{ tool_bucket_fill },
|
|
|
|
{ tool_blend },
|
|
|
|
{ tool_pencil },
|
|
|
|
{ tool_paintbrush },
|
|
|
|
{ tool_airbrush },
|
|
|
|
{ tool_ink },
|
|
|
|
{ tool_clone },
|
|
|
|
{ tool_heal },
|
|
|
|
{ tool_eraser },
|
|
|
|
{ tool_smudge },
|
|
|
|
{ tool_blur },
|
|
|
|
{ tool_dodge },
|
|
|
|
{ tool_burn },
|
|
|
|
{ tool_measure },
|
|
|
|
{ tool_hand }
|
2000-06-09 20:31:19 +08:00
|
|
|
};
|
|
|
|
|
2004-06-10 22:43:08 +08:00
|
|
|
static GimpCursor gimp_cursor_modifiers[] =
|
2000-06-09 20:31:19 +08:00
|
|
|
{
|
2002-11-18 07:13:26 +08:00
|
|
|
/* these have to match up with enum GimpCursorModifier in widgets-enums.h */
|
|
|
|
|
2010-09-11 01:12:52 +08:00
|
|
|
{ NULL },
|
2012-08-27 04:53:04 +08:00
|
|
|
{ modifier_bad },
|
|
|
|
{ modifier_plus },
|
|
|
|
{ modifier_minus },
|
|
|
|
{ modifier_intersect },
|
|
|
|
{ modifier_move },
|
|
|
|
{ modifier_resize },
|
|
|
|
{ modifier_control },
|
|
|
|
{ modifier_anchor },
|
|
|
|
{ modifier_foreground },
|
|
|
|
{ modifier_background },
|
|
|
|
{ modifier_pattern },
|
|
|
|
{ modifier_join },
|
|
|
|
{ modifier_select }
|
1999-05-05 17:10:35 +08:00
|
|
|
};
|
|
|
|
|
2012-08-27 19:29:18 +08:00
|
|
|
|
2010-09-11 01:12:52 +08:00
|
|
|
static const GdkPixbuf *
|
2012-08-27 04:53:04 +08:00
|
|
|
get_cursor_pixbuf (GimpCursor *cursor)
|
1999-05-05 17:10:35 +08:00
|
|
|
{
|
2012-08-27 04:53:04 +08:00
|
|
|
if (! cursor->pixbuf)
|
|
|
|
cursor->pixbuf = gdk_pixbuf_new_from_inline (-1,
|
|
|
|
cursor->pixbuf_data,
|
|
|
|
FALSE, NULL);
|
|
|
|
g_return_val_if_fail (cursor->pixbuf != NULL, NULL);
|
2004-06-05 03:03:49 +08:00
|
|
|
|
2012-08-27 04:53:04 +08:00
|
|
|
return cursor->pixbuf;
|
2004-06-03 20:36:02 +08:00
|
|
|
}
|
|
|
|
|
2004-06-04 20:10:13 +08:00
|
|
|
GdkCursor *
|
|
|
|
gimp_cursor_new (GdkDisplay *display,
|
2011-07-25 04:09:21 +08:00
|
|
|
GimpHandedness cursor_handedness,
|
2004-06-04 20:10:13 +08:00
|
|
|
GimpCursorType cursor_type,
|
|
|
|
GimpToolCursorType tool_cursor,
|
|
|
|
GimpCursorModifier modifier)
|
2004-06-03 20:36:02 +08:00
|
|
|
{
|
2004-06-10 22:43:08 +08:00
|
|
|
GimpCursor *bmcursor = NULL;
|
|
|
|
GimpCursor *bmmodifier = NULL;
|
|
|
|
GimpCursor *bmtool = NULL;
|
2010-09-11 01:12:52 +08:00
|
|
|
GdkCursor *cursor;
|
|
|
|
GdkPixbuf *pixbuf;
|
2004-06-03 20:36:02 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
2004-06-05 07:08:29 +08:00
|
|
|
g_return_val_if_fail (cursor_type < GIMP_CURSOR_LAST, NULL);
|
2004-06-03 20:36:02 +08:00
|
|
|
|
2011-03-17 21:42:44 +08:00
|
|
|
if (cursor_type <= (GimpCursorType) GDK_LAST_CURSOR)
|
2004-06-03 20:36:02 +08:00
|
|
|
return gdk_cursor_new_for_display (display, cursor_type);
|
|
|
|
|
2004-06-05 07:08:29 +08:00
|
|
|
g_return_val_if_fail (cursor_type >= GIMP_CURSOR_NONE, NULL);
|
2004-06-03 20:36:02 +08:00
|
|
|
|
2006-06-02 23:23:47 +08:00
|
|
|
/* disallow the small tool cursor with some cursors
|
2004-06-03 20:36:02 +08:00
|
|
|
*/
|
2006-06-02 23:23:47 +08:00
|
|
|
if (cursor_type <= GIMP_CURSOR_NONE ||
|
|
|
|
cursor_type == GIMP_CURSOR_CROSSHAIR ||
|
|
|
|
cursor_type == GIMP_CURSOR_ZOOM ||
|
|
|
|
cursor_type == GIMP_CURSOR_COLOR_PICKER ||
|
|
|
|
cursor_type >= GIMP_CURSOR_LAST)
|
2004-06-03 20:36:02 +08:00
|
|
|
{
|
|
|
|
tool_cursor = GIMP_TOOL_CURSOR_NONE;
|
|
|
|
}
|
|
|
|
|
2004-06-10 22:43:08 +08:00
|
|
|
/* don't allow anything with the empty cursor
|
|
|
|
*/
|
|
|
|
if (cursor_type == GIMP_CURSOR_NONE)
|
|
|
|
{
|
|
|
|
tool_cursor = GIMP_TOOL_CURSOR_NONE;
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_NONE;
|
|
|
|
}
|
|
|
|
|
2007-08-02 21:33:38 +08:00
|
|
|
/* some more sanity checks
|
|
|
|
*/
|
|
|
|
if (cursor_type == GIMP_CURSOR_MOVE &&
|
|
|
|
modifier == GIMP_CURSOR_MODIFIER_MOVE)
|
|
|
|
{
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_NONE;
|
|
|
|
}
|
|
|
|
|
2011-07-25 04:09:21 +08:00
|
|
|
/* when cursor is "corner" or "side" sides must be exchanged for
|
|
|
|
* left-hand-mice-flipping of pixbuf below
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (cursor_handedness == GIMP_HANDEDNESS_LEFT)
|
|
|
|
{
|
2012-08-27 19:29:18 +08:00
|
|
|
switch (cursor_type)
|
2011-07-25 04:09:21 +08:00
|
|
|
{
|
2012-08-27 19:29:18 +08:00
|
|
|
case GIMP_CURSOR_CORNER_TOP_LEFT:
|
|
|
|
cursor_type = GIMP_CURSOR_CORNER_TOP_RIGHT; break;
|
|
|
|
|
|
|
|
case GIMP_CURSOR_CORNER_TOP_RIGHT:
|
|
|
|
cursor_type = GIMP_CURSOR_CORNER_TOP_LEFT; break;
|
|
|
|
|
|
|
|
case GIMP_CURSOR_CORNER_LEFT:
|
|
|
|
cursor_type = GIMP_CURSOR_CORNER_RIGHT; break;
|
|
|
|
|
|
|
|
case GIMP_CURSOR_CORNER_RIGHT:
|
|
|
|
cursor_type = GIMP_CURSOR_CORNER_LEFT; break;
|
|
|
|
|
|
|
|
case GIMP_CURSOR_CORNER_BOTTOM_LEFT:
|
|
|
|
cursor_type = GIMP_CURSOR_CORNER_BOTTOM_RIGHT; break;
|
|
|
|
|
|
|
|
case GIMP_CURSOR_CORNER_BOTTOM_RIGHT:
|
|
|
|
cursor_type = GIMP_CURSOR_CORNER_BOTTOM_LEFT; break;
|
|
|
|
|
|
|
|
case GIMP_CURSOR_SIDE_TOP_LEFT:
|
|
|
|
cursor_type = GIMP_CURSOR_SIDE_TOP_RIGHT; break;
|
|
|
|
|
|
|
|
case GIMP_CURSOR_SIDE_TOP_RIGHT:
|
|
|
|
cursor_type = GIMP_CURSOR_SIDE_TOP_LEFT; break;
|
|
|
|
|
|
|
|
case GIMP_CURSOR_SIDE_LEFT:
|
|
|
|
cursor_type = GIMP_CURSOR_SIDE_RIGHT; break;
|
|
|
|
|
|
|
|
case GIMP_CURSOR_SIDE_RIGHT:
|
|
|
|
cursor_type = GIMP_CURSOR_SIDE_LEFT; break;
|
|
|
|
|
|
|
|
case GIMP_CURSOR_SIDE_BOTTOM_LEFT:
|
|
|
|
cursor_type = GIMP_CURSOR_SIDE_BOTTOM_RIGHT; break;
|
|
|
|
|
|
|
|
case GIMP_CURSOR_SIDE_BOTTOM_RIGHT:
|
|
|
|
cursor_type = GIMP_CURSOR_SIDE_BOTTOM_LEFT; break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2012-08-27 05:59:05 +08:00
|
|
|
}
|
2011-07-25 04:09:21 +08:00
|
|
|
}
|
|
|
|
|
2004-06-03 20:36:02 +08:00
|
|
|
/* prepare the main cursor */
|
|
|
|
|
2004-06-05 07:08:29 +08:00
|
|
|
cursor_type -= GIMP_CURSOR_NONE;
|
2004-06-03 20:36:02 +08:00
|
|
|
bmcursor = &gimp_cursors[cursor_type];
|
|
|
|
|
|
|
|
/* prepare the tool cursor */
|
|
|
|
|
2007-08-02 21:33:38 +08:00
|
|
|
if (tool_cursor > GIMP_TOOL_CURSOR_NONE &&
|
|
|
|
tool_cursor < GIMP_TOOL_CURSOR_LAST)
|
|
|
|
{
|
|
|
|
bmtool = &gimp_tool_cursors[tool_cursor];
|
|
|
|
}
|
2004-06-03 20:36:02 +08:00
|
|
|
|
|
|
|
/* prepare the cursor modifier */
|
|
|
|
|
2007-08-02 21:33:38 +08:00
|
|
|
if (modifier > GIMP_CURSOR_MODIFIER_NONE &&
|
|
|
|
modifier < GIMP_CURSOR_MODIFIER_LAST)
|
|
|
|
{
|
|
|
|
bmmodifier = &gimp_cursor_modifiers[modifier];
|
|
|
|
}
|
2004-06-03 20:36:02 +08:00
|
|
|
|
2012-08-27 04:53:04 +08:00
|
|
|
pixbuf = gdk_pixbuf_copy (get_cursor_pixbuf (bmcursor));
|
2004-06-04 20:10:13 +08:00
|
|
|
|
2010-09-11 01:12:52 +08:00
|
|
|
if (bmmodifier || bmtool)
|
|
|
|
{
|
|
|
|
gint width = gdk_pixbuf_get_width (pixbuf);
|
|
|
|
gint height = gdk_pixbuf_get_height (pixbuf);
|
2004-06-04 20:10:13 +08:00
|
|
|
|
|
|
|
if (bmmodifier)
|
2012-08-27 04:53:04 +08:00
|
|
|
gdk_pixbuf_composite (get_cursor_pixbuf (bmmodifier), pixbuf,
|
2004-06-05 03:03:49 +08:00
|
|
|
0, 0, width, height,
|
|
|
|
0.0, 0.0, 1.0, 1.0,
|
2012-08-27 04:53:04 +08:00
|
|
|
GDK_INTERP_NEAREST, 200);
|
2004-06-04 20:10:13 +08:00
|
|
|
|
|
|
|
if (bmtool)
|
2012-08-27 04:53:04 +08:00
|
|
|
gdk_pixbuf_composite (get_cursor_pixbuf (bmtool), pixbuf,
|
2004-06-05 03:03:49 +08:00
|
|
|
0, 0, width, height,
|
|
|
|
0.0, 0.0, 1.0, 1.0,
|
2012-08-27 04:53:04 +08:00
|
|
|
GDK_INTERP_NEAREST, 200);
|
2004-06-03 20:36:02 +08:00
|
|
|
}
|
|
|
|
|
2011-07-25 04:09:21 +08:00
|
|
|
/* flip the cursor if mouse setting is left-handed */
|
|
|
|
|
|
|
|
if (cursor_handedness == GIMP_HANDEDNESS_LEFT)
|
|
|
|
{
|
|
|
|
GdkPixbuf *flipped = gdk_pixbuf_flip (pixbuf, TRUE);
|
|
|
|
gint width = gdk_pixbuf_get_width (flipped);
|
|
|
|
|
|
|
|
cursor = gdk_cursor_new_from_pixbuf (display, flipped,
|
|
|
|
(width - 1) - bmcursor->x_hot,
|
|
|
|
bmcursor->y_hot);
|
|
|
|
g_object_unref (flipped);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cursor = gdk_cursor_new_from_pixbuf (display, pixbuf,
|
|
|
|
bmcursor->x_hot,
|
|
|
|
bmcursor->y_hot);
|
|
|
|
}
|
|
|
|
|
2010-09-11 01:12:52 +08:00
|
|
|
g_object_unref (pixbuf);
|
2004-06-03 20:36:02 +08:00
|
|
|
|
2004-06-04 20:10:13 +08:00
|
|
|
return cursor;
|
2004-06-03 20:36:02 +08:00
|
|
|
}
|
|
|
|
|
2003-11-02 04:53:18 +08:00
|
|
|
void
|
|
|
|
gimp_cursor_set (GtkWidget *widget,
|
2011-07-25 04:09:21 +08:00
|
|
|
GimpHandedness cursor_handedness,
|
2003-11-02 04:53:18 +08:00
|
|
|
GimpCursorType cursor_type,
|
|
|
|
GimpToolCursorType tool_cursor,
|
|
|
|
GimpCursorModifier modifier)
|
|
|
|
{
|
|
|
|
GdkCursor *cursor;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
2010-04-20 01:21:07 +08:00
|
|
|
g_return_if_fail (gtk_widget_get_realized (widget));
|
2003-11-02 04:53:18 +08:00
|
|
|
|
|
|
|
cursor = gimp_cursor_new (gtk_widget_get_display (widget),
|
2011-07-25 04:09:21 +08:00
|
|
|
cursor_handedness,
|
2003-11-02 04:53:18 +08:00
|
|
|
cursor_type,
|
|
|
|
tool_cursor,
|
|
|
|
modifier);
|
2009-03-23 00:35:53 +08:00
|
|
|
gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
|
2003-11-02 04:53:18 +08:00
|
|
|
gdk_cursor_unref (cursor);
|
|
|
|
}
|