root/gtkimageview/src/gtkiimagetool.h

Revision 235, 3.8 kB (checked in by bjourne, 6 years ago)

Totally change how the tool sets the cursor of the view.

Previously, the tools changed the cursor in
gtk_iimage_tool_motion_notify() and
gtk_iimage_tool_button_press()/release(). However, those call points
are not enough. For example if the pointer is over a hotspot in the
image, then if the view is scrolled by the arrow keys, then the
pointer may move away from the hotspot and the cursor might need to be
updated.

To solve this problem, an interface function named
gtk_iimage_tool_cursor_at_point() has been added to the GtkIImageTool
interface. It is called whenever the offset of the view changes and
when it gets motion notify events. This function replaces the new
redundant gtk_iimage_tool_get_default_cursor() function.

Line 
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; coding: utf-8 -*-
2  *
3  * Copyright © 2007 Björn Lindqvist <bjourne@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public License
7  * as published by the Free Software Foundation; either version 2, or
8  * (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18  * 02111-1307, USA.
19  */
20 #ifndef __GTK_IIMAGE_TOOL_H__
21 #define __GTK_IIMAGE_TOOL_H__
22
23 #include <gdk/gdk.h>
24 #include <gtk/gtk.h>
25 #include "image_view_drawer.h"
26
27 G_BEGIN_DECLS
28
29 #define GTK_TYPE_IIMAGE_TOOL            (gtk_iimage_tool_get_type ())
30 #define GTK_IIMAGE_TOOL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IIMAGE_TOOL, GtkIImageTool))
31 #define GTK_IIMAGE_TOOL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IIMAGE_TOOL, GtkIImageToolClass))
32 #define GTK_IS_IIMAGE_TOOL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IIMAGE_TOOL))
33 #define GTK_IS_IIMAGE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IIMAGE_TOOL))
34 #define GTK_IIMAGE_TOOL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_IIMAGE_TOOL, GtkIImageToolClass))
35
36 typedef struct _GtkIImageTool GtkIImageTool;
37 typedef struct _GtkIImageToolClass GtkIImageToolClass;
38
39 struct _GtkIImageToolClass
40 {
41     GTypeInterface parent;
42     gboolean       (*button_press)           (GtkIImageTool  *tool,
43                                               GdkEventButton *ev);
44     gboolean       (*button_release)         (GtkIImageTool  *tool,
45                                               GdkEventButton *ev);
46     gboolean       (*motion_notify)          (GtkIImageTool  *tool,
47                                               GdkEventMotion *ev);
48     GdkCursor*     (*cursor_at_point)    (GtkIImageTool  *tool,
49                                           int             x,
50                                           int             y);
51     void           (*pixbuf_changed)         (GtkIImageTool  *tool,
52                                               gboolean        reset_fit);
53     void           (*paint_image)            (GtkIImageTool  *tool,
54                                               DrawSettings   *ds,
55                                               GdkDrawable    *drawable);
56 };
57
58 GType         gtk_iimage_tool_get_type       (void) G_GNUC_CONST;
59
60
61 /* Pseudo signal handlers. */
62 gboolean      gtk_iimage_tool_button_press   (GtkIImageTool  *tool,
63                                               GdkEventButton *ev);
64 gboolean      gtk_iimage_tool_button_release (GtkIImageTool  *tool,
65                                               GdkEventButton *ev);
66 gboolean      gtk_iimage_tool_motion_notify  (GtkIImageTool  *tool,
67                                               GdkEventMotion *ev);
68 void          gtk_iimage_tool_pixbuf_changed (GtkIImageTool  *tool,
69                                               gboolean        reset_fit);
70 void          gtk_iimage_tool_paint_image    (GtkIImageTool  *tool,
71                                               DrawSettings   *ds,
72                                               GdkDrawable    *drawable);
73
74 /* Read-only properties. */
75 GdkCursor    *gtk_iimage_tool_cursor_at_point (GtkIImageTool *tool,
76                                                int            x,
77                                                int            y);
78
79 #endif
80
Note: See TracBrowser for help on using the browser.