app/display/Makefile.am app/display/gimpdisplayshell-autoscroll.[ch] new

2005-01-02  Michael Natterer  <mitch@gimp.org>

	* app/display/Makefile.am
	* app/display/gimpdisplayshell-autoscroll.[ch]
	* app/display/gimpdisplayshell-coords.[ch]: new files factored out
	of gimpdisplayshell-callbacks.c

	* app/display/gimpdisplayshell.h (struct GimpDisplayShell): added
	"gpointer scroll_info" needed by autoscroll.

	* app/display/gimpdisplayshell-callbacks.c: removed the stuff
	above. Also removed the static autoscroll struct because it's not
	needed any longer.
This commit is contained in:
Michael Natterer 2005-01-02 20:42:31 +00:00 committed by Michael Natterer
parent 9ecaa8f22c
commit aef1cf9306
8 changed files with 433 additions and 267 deletions

View File

@ -1,3 +1,17 @@
2005-01-02 Michael Natterer <mitch@gimp.org>
* app/display/Makefile.am
* app/display/gimpdisplayshell-autoscroll.[ch]
* app/display/gimpdisplayshell-coords.[ch]: new files factored out
of gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell.h (struct GimpDisplayShell): added
"gpointer scroll_info" needed by autoscroll.
* app/display/gimpdisplayshell-callbacks.c: removed the stuff
above. Also removed the static autoscroll struct because it's not
needed any longer.
2005-01-02 DindinX <dindinx@gimp.org>
* plug-ins/common/mosaic.c: Added a preview. This still needs some

View File

@ -30,10 +30,14 @@ libappdisplay_a_sources = \
gimpdisplayshell.h \
gimpdisplayshell-appearance.c \
gimpdisplayshell-appearance.h \
gimpdisplayshell-autoscroll.c \
gimpdisplayshell-autoscroll.h \
gimpdisplayshell-callbacks.c \
gimpdisplayshell-callbacks.h \
gimpdisplayshell-close.c \
gimpdisplayshell-close.h \
gimpdisplayshell-coords.c \
gimpdisplayshell-coords.h \
gimpdisplayshell-cursor.c \
gimpdisplayshell-cursor.h \
gimpdisplayshell-dnd.c \

View File

@ -0,0 +1,156 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "display-types.h"
#include "core/gimpimage.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-autoscroll.h"
#include "gimpdisplayshell-coords.h"
#include "gimpdisplayshell-scroll.h"
#include "gimpdisplayshell-transform.h"
#include "tools/tools-types.h"
#include "tools/tool_manager.h"
#define AUTOSCROLL_DT 20
#define AUTOSCROLL_DX 0.1
typedef struct
{
GdkEventMotion *mevent;
GdkDevice *device;
guint32 time;
GdkModifierType state;
guint timeout_id;
} ScrollInfo;
/* local function prototypes */
static gboolean gimp_display_shell_autoscroll_timeout (gpointer data);
/* public functions */
void
gimp_display_shell_autoscroll_start (GimpDisplayShell *shell,
GdkModifierType state,
GdkEventMotion *mevent)
{
ScrollInfo *info;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (shell->scroll_info)
return;
info = g_new0 (ScrollInfo, 1);
info->mevent = mevent;
info->device = mevent->device;
info->time = gdk_event_get_time ((GdkEvent *) mevent);
info->state = state;
info->timeout_id = g_timeout_add (AUTOSCROLL_DT,
gimp_display_shell_autoscroll_timeout,
shell);
shell->scroll_info = info;
}
void
gimp_display_shell_autoscroll_stop (GimpDisplayShell *shell)
{
ScrollInfo *info;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (! shell->scroll_info)
return;
info = shell->scroll_info;
if (info->timeout_id)
{
g_source_remove (info->timeout_id);
info->timeout_id = 0;
}
g_free (info);
shell->scroll_info = NULL;
}
/* private functions */
static gboolean
gimp_display_shell_autoscroll_timeout (gpointer data)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
GimpDisplay *gdisp = shell->gdisp;
ScrollInfo *info = shell->scroll_info;
GimpCoords device_coords;
GimpCoords image_coords;
gint off_x = 0;
gint off_y = 0;
info->time += AUTOSCROLL_DT;
gimp_display_shell_get_device_coords (shell,
info->device, &device_coords);
if (device_coords.x < 0)
off_x = device_coords.x;
else if (device_coords.x > shell->disp_width)
off_x = device_coords.x - shell->disp_width;
if (device_coords.y < 0)
off_y = device_coords.y;
else if (device_coords.y > shell->disp_height)
off_y = device_coords.y - shell->disp_height;
if (off_x == 0 && off_y == 0)
{
g_free (info);
shell->scroll_info = NULL;
return FALSE;
}
gimp_display_shell_scroll (shell,
AUTOSCROLL_DX * (gdouble) off_x,
AUTOSCROLL_DX * (gdouble) off_y);
gimp_display_shell_untransform_coords (shell,
&device_coords, &image_coords);
tool_manager_motion_active (gdisp->gimage->gimp,
&image_coords,
info->time, info->state,
gdisp);
return TRUE;
}

View File

@ -0,0 +1,29 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DISPLAY_SHELL_AUTOSCROLL_H__
#define __GIMP_DISPLAY_SHELL_AUTOSCROLL_H__
void gimp_display_shell_autoscroll_start (GimpDisplayShell *shell,
GdkModifierType state,
GdkEventMotion *mevent);
void gimp_display_shell_autoscroll_stop (GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_AUTOSCROLL_H__ */

View File

@ -17,6 +17,7 @@
*/
#include "config.h"
#include <stdlib.h>
#include <gtk/gtk.h>
@ -58,7 +59,9 @@
#include "gimpdisplayoptions.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-appearance.h"
#include "gimpdisplayshell-autoscroll.h"
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-coords.h"
#include "gimpdisplayshell-cursor.h"
#include "gimpdisplayshell-draw.h"
#include "gimpdisplayshell-layer-select.h"
@ -72,17 +75,6 @@
#include "gimp-intl.h"
typedef struct
{
GimpDisplayShell *shell;
GdkEventMotion *mevent;
GdkDevice *device;
guint32 time;
GdkModifierType state;
guint timeout_id;
} ScrollInfo;
/* #define DEBUG_MOVE_PUSH 1 */
@ -94,31 +86,6 @@ static void gimp_display_shell_vscrollbar_update (GtkAdjustment *adjustme
static void gimp_display_shell_hscrollbar_update (GtkAdjustment *adjustment,
GimpDisplayShell *shell);
static gboolean gimp_display_shell_get_event_coords (GimpDisplayShell *shell,
GdkEvent *event,
GdkDevice *device,
GimpCoords *coords);
static void gimp_display_shell_get_device_coords (GimpDisplayShell *shell,
GdkDevice *device,
GimpCoords *coords);
static void gimp_display_shell_get_time_coords (GimpDisplayShell *shell,
GdkDevice *device,
GdkTimeCoord *event,
GimpCoords *coords);
static gboolean gimp_display_shell_get_event_state (GimpDisplayShell *shell,
GdkEvent *event,
GdkDevice *device,
GdkModifierType *state);
static void gimp_display_shell_get_device_state (GimpDisplayShell *shell,
GdkDevice *device,
GdkModifierType *state);
static gboolean autoscroll_timeout (gpointer data);
static void begin_autoscrolling (ScrollInfo *info,
GimpDisplayShell *shell,
GdkModifierType state,
GdkEventMotion *mevent);
static void end_autoscrolling (ScrollInfo *info);
static GdkModifierType
gimp_display_shell_key_to_state (gint key);
@ -465,84 +432,6 @@ gimp_display_shell_check_device_cursor (GimpDisplayShell *shell)
shell->draw_cursor = ! current_device->has_cursor;
}
#define AUTOSCROLL_DT 20
#define AUTOSCROLL_DX 0.1
static gboolean
autoscroll_timeout (gpointer data)
{
ScrollInfo *info = data;
GimpDisplay *gdisp = info->shell->gdisp;
GimpCoords device_coords;
GimpCoords image_coords;
gint off_x = 0;
gint off_y = 0;
info->time += AUTOSCROLL_DT;
gimp_display_shell_get_device_coords (info->shell,
info->device, &device_coords);
if (device_coords.x < 0)
off_x = device_coords.x;
else if (device_coords.x > info->shell->disp_width)
off_x = device_coords.x - info->shell->disp_width;
if (device_coords.y < 0)
off_y = device_coords.y;
else if (device_coords.y > info->shell->disp_height)
off_y = device_coords.y - info->shell->disp_height;
if (off_x == 0 && off_y == 0)
{
info->timeout_id = 0;
return FALSE;
}
gimp_display_shell_scroll (info->shell,
AUTOSCROLL_DX * (gdouble) off_x,
AUTOSCROLL_DX * (gdouble) off_y);
gimp_display_shell_untransform_coords (info->shell,
&device_coords, &image_coords);
tool_manager_motion_active (gdisp->gimage->gimp,
&image_coords,
info->time, info->state,
gdisp);
return TRUE;
}
static void
begin_autoscrolling (ScrollInfo *info,
GimpDisplayShell *shell,
GdkModifierType state,
GdkEventMotion *mevent)
{
if (info->timeout_id)
return;
info->shell = shell;
info->mevent = mevent;
info->device = mevent->device;
info->time = gdk_event_get_time ((GdkEvent*) mevent);
info->state = state;
info->timeout_id = g_timeout_add (AUTOSCROLL_DT, autoscroll_timeout, info);
}
static void
end_autoscrolling (ScrollInfo *info)
{
if (info->timeout_id)
{
g_source_remove (info->timeout_id);
info->timeout_id = 0;
}
}
gboolean
gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
GdkEvent *event,
@ -559,7 +448,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
guint32 time;
gboolean return_val = FALSE;
gboolean update_cursor = FALSE;
static ScrollInfo scroll_info = { NULL, NULL, NULL, 0, 0,0 };
static GimpToolInfo *space_shaded_tool = NULL;
if (! canvas->window)
@ -869,7 +758,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
{
GdkEventButton *bevent = (GdkEventButton *) event;
end_autoscrolling (&scroll_info);
gimp_display_shell_autoscroll_stop (shell);
if (gimp->busy)
return TRUE;
@ -1137,7 +1026,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
mevent->y > shell->disp_height) &&
! gimp_tool_control_scroll_lock (active_tool->control))
{
begin_autoscrolling (&scroll_info, shell, state, mevent);
gimp_display_shell_autoscroll_start (shell, state, mevent);
}
if (gimp_tool_control_motion_mode (active_tool->control) ==
@ -1625,156 +1514,6 @@ gimp_display_shell_hscrollbar_update (GtkAdjustment *adjustment,
gimp_display_shell_scroll (shell, (adjustment->value - shell->offset_x), 0);
}
static gboolean
gimp_display_shell_get_event_coords (GimpDisplayShell *shell,
GdkEvent *event,
GdkDevice *device,
GimpCoords *coords)
{
if (gdk_event_get_axis (event, GDK_AXIS_X, &coords->x))
{
gdk_event_get_axis (event, GDK_AXIS_Y, &coords->y);
/* CLAMP() the return value of each *_get_axis() call to be safe
* against buggy XInput drivers. Provide default values if the
* requested axis does not exist.
*/
if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &coords->pressure))
coords->pressure = CLAMP (coords->pressure, GIMP_COORDS_MIN_PRESSURE,
GIMP_COORDS_MAX_PRESSURE);
else
coords->pressure = GIMP_COORDS_DEFAULT_PRESSURE;
if (gdk_event_get_axis (event, GDK_AXIS_XTILT, &coords->xtilt))
coords->xtilt = CLAMP (coords->xtilt, GIMP_COORDS_MIN_TILT,
GIMP_COORDS_MAX_TILT);
else
coords->xtilt = GIMP_COORDS_DEFAULT_TILT;
if (gdk_event_get_axis (event, GDK_AXIS_YTILT, &coords->ytilt))
coords->ytilt = CLAMP (coords->ytilt, GIMP_COORDS_MIN_TILT,
GIMP_COORDS_MAX_TILT);
else
coords->ytilt = GIMP_COORDS_DEFAULT_TILT;
if (gdk_event_get_axis (event, GDK_AXIS_WHEEL, &coords->wheel))
coords->wheel = CLAMP (coords->wheel, GIMP_COORDS_MIN_WHEEL,
GIMP_COORDS_MAX_WHEEL);
else
coords->wheel = GIMP_COORDS_DEFAULT_WHEEL;
return TRUE;
}
gimp_display_shell_get_device_coords (shell, device, coords);
return FALSE;
}
static void
gimp_display_shell_get_device_coords (GimpDisplayShell *shell,
GdkDevice *device,
GimpCoords *coords)
{
gdouble axes[GDK_AXIS_LAST];
gdk_device_get_state (device, shell->canvas->window, axes, NULL);
gdk_device_get_axis (device, axes, GDK_AXIS_X, &coords->x);
gdk_device_get_axis (device, axes, GDK_AXIS_Y, &coords->y);
/* CLAMP() the return value of each *_get_axis() call to be safe
* against buggy XInput drivers. Provide default values if the
* requested axis does not exist.
*/
if (gdk_device_get_axis (device, axes, GDK_AXIS_PRESSURE, &coords->pressure))
coords->pressure = CLAMP (coords->pressure, GIMP_COORDS_MIN_PRESSURE,
GIMP_COORDS_MAX_PRESSURE);
else
coords->pressure = GIMP_COORDS_DEFAULT_PRESSURE;
if (gdk_device_get_axis (device, axes, GDK_AXIS_XTILT, &coords->xtilt))
coords->xtilt = CLAMP (coords->xtilt, GIMP_COORDS_MIN_TILT,
GIMP_COORDS_MAX_TILT);
else
coords->xtilt = GIMP_COORDS_DEFAULT_TILT;
if (gdk_device_get_axis (device, axes, GDK_AXIS_YTILT, &coords->ytilt))
coords->ytilt = CLAMP (coords->ytilt, GIMP_COORDS_MIN_TILT,
GIMP_COORDS_MAX_TILT);
else
coords->ytilt = GIMP_COORDS_DEFAULT_TILT;
if (gdk_device_get_axis (device, axes, GDK_AXIS_WHEEL, &coords->wheel))
coords->wheel = CLAMP (coords->wheel, GIMP_COORDS_MIN_WHEEL,
GIMP_COORDS_MAX_WHEEL);
else
coords->wheel = GIMP_COORDS_DEFAULT_WHEEL;
}
static void
gimp_display_shell_get_time_coords (GimpDisplayShell *shell,
GdkDevice *device,
GdkTimeCoord *event,
GimpCoords *coords)
{
gdk_device_get_axis (device, event->axes, GDK_AXIS_X, &coords->x);
gdk_device_get_axis (device, event->axes, GDK_AXIS_Y, &coords->y);
/* CLAMP() the return value of each *_get_axis() call to be safe
* against buggy XInput drivers. Provide default values if the
* requested axis does not exist.
*/
if (gdk_device_get_axis (device, event->axes, GDK_AXIS_PRESSURE, &coords->pressure))
coords->pressure = CLAMP (coords->pressure, GIMP_COORDS_MIN_PRESSURE,
GIMP_COORDS_MAX_PRESSURE);
else
coords->pressure = GIMP_COORDS_DEFAULT_PRESSURE;
if (gdk_device_get_axis (device, event->axes, GDK_AXIS_XTILT, &coords->xtilt))
coords->xtilt = CLAMP (coords->xtilt, GIMP_COORDS_MIN_TILT,
GIMP_COORDS_MAX_TILT);
else
coords->xtilt = GIMP_COORDS_DEFAULT_TILT;
if (gdk_device_get_axis (device, event->axes, GDK_AXIS_YTILT, &coords->ytilt))
coords->ytilt = CLAMP (coords->ytilt, GIMP_COORDS_MIN_TILT,
GIMP_COORDS_MAX_TILT);
else
coords->ytilt = GIMP_COORDS_DEFAULT_TILT;
if (gdk_device_get_axis (device, event->axes, GDK_AXIS_WHEEL, &coords->wheel))
coords->wheel = CLAMP (coords->wheel, GIMP_COORDS_MIN_WHEEL,
GIMP_COORDS_MAX_WHEEL);
else
coords->wheel = GIMP_COORDS_DEFAULT_WHEEL;
}
static gboolean
gimp_display_shell_get_event_state (GimpDisplayShell *shell,
GdkEvent *event,
GdkDevice *device,
GdkModifierType *state)
{
if (gdk_event_get_state (event, state))
return TRUE;
gimp_display_shell_get_device_state (shell, device, state);
return FALSE;
}
static void
gimp_display_shell_get_device_state (GimpDisplayShell *shell,
GdkDevice *device,
GdkModifierType *state)
{
gdk_device_get_state (device, shell->canvas->window, NULL, state);
}
static GdkModifierType
gimp_display_shell_key_to_state (gint key)
{

View File

@ -0,0 +1,179 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "display-types.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-coords.h"
/* public functions */
gboolean
gimp_display_shell_get_event_coords (GimpDisplayShell *shell,
GdkEvent *event,
GdkDevice *device,
GimpCoords *coords)
{
if (gdk_event_get_axis (event, GDK_AXIS_X, &coords->x))
{
gdk_event_get_axis (event, GDK_AXIS_Y, &coords->y);
/* CLAMP() the return value of each *_get_axis() call to be safe
* against buggy XInput drivers. Provide default values if the
* requested axis does not exist.
*/
if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &coords->pressure))
coords->pressure = CLAMP (coords->pressure, GIMP_COORDS_MIN_PRESSURE,
GIMP_COORDS_MAX_PRESSURE);
else
coords->pressure = GIMP_COORDS_DEFAULT_PRESSURE;
if (gdk_event_get_axis (event, GDK_AXIS_XTILT, &coords->xtilt))
coords->xtilt = CLAMP (coords->xtilt, GIMP_COORDS_MIN_TILT,
GIMP_COORDS_MAX_TILT);
else
coords->xtilt = GIMP_COORDS_DEFAULT_TILT;
if (gdk_event_get_axis (event, GDK_AXIS_YTILT, &coords->ytilt))
coords->ytilt = CLAMP (coords->ytilt, GIMP_COORDS_MIN_TILT,
GIMP_COORDS_MAX_TILT);
else
coords->ytilt = GIMP_COORDS_DEFAULT_TILT;
if (gdk_event_get_axis (event, GDK_AXIS_WHEEL, &coords->wheel))
coords->wheel = CLAMP (coords->wheel, GIMP_COORDS_MIN_WHEEL,
GIMP_COORDS_MAX_WHEEL);
else
coords->wheel = GIMP_COORDS_DEFAULT_WHEEL;
return TRUE;
}
gimp_display_shell_get_device_coords (shell, device, coords);
return FALSE;
}
void
gimp_display_shell_get_device_coords (GimpDisplayShell *shell,
GdkDevice *device,
GimpCoords *coords)
{
gdouble axes[GDK_AXIS_LAST];
gdk_device_get_state (device, shell->canvas->window, axes, NULL);
gdk_device_get_axis (device, axes, GDK_AXIS_X, &coords->x);
gdk_device_get_axis (device, axes, GDK_AXIS_Y, &coords->y);
/* CLAMP() the return value of each *_get_axis() call to be safe
* against buggy XInput drivers. Provide default values if the
* requested axis does not exist.
*/
if (gdk_device_get_axis (device, axes, GDK_AXIS_PRESSURE, &coords->pressure))
coords->pressure = CLAMP (coords->pressure, GIMP_COORDS_MIN_PRESSURE,
GIMP_COORDS_MAX_PRESSURE);
else
coords->pressure = GIMP_COORDS_DEFAULT_PRESSURE;
if (gdk_device_get_axis (device, axes, GDK_AXIS_XTILT, &coords->xtilt))
coords->xtilt = CLAMP (coords->xtilt, GIMP_COORDS_MIN_TILT,
GIMP_COORDS_MAX_TILT);
else
coords->xtilt = GIMP_COORDS_DEFAULT_TILT;
if (gdk_device_get_axis (device, axes, GDK_AXIS_YTILT, &coords->ytilt))
coords->ytilt = CLAMP (coords->ytilt, GIMP_COORDS_MIN_TILT,
GIMP_COORDS_MAX_TILT);
else
coords->ytilt = GIMP_COORDS_DEFAULT_TILT;
if (gdk_device_get_axis (device, axes, GDK_AXIS_WHEEL, &coords->wheel))
coords->wheel = CLAMP (coords->wheel, GIMP_COORDS_MIN_WHEEL,
GIMP_COORDS_MAX_WHEEL);
else
coords->wheel = GIMP_COORDS_DEFAULT_WHEEL;
}
void
gimp_display_shell_get_time_coords (GimpDisplayShell *shell,
GdkDevice *device,
GdkTimeCoord *event,
GimpCoords *coords)
{
gdk_device_get_axis (device, event->axes, GDK_AXIS_X, &coords->x);
gdk_device_get_axis (device, event->axes, GDK_AXIS_Y, &coords->y);
/* CLAMP() the return value of each *_get_axis() call to be safe
* against buggy XInput drivers. Provide default values if the
* requested axis does not exist.
*/
if (gdk_device_get_axis (device, event->axes, GDK_AXIS_PRESSURE, &coords->pressure))
coords->pressure = CLAMP (coords->pressure, GIMP_COORDS_MIN_PRESSURE,
GIMP_COORDS_MAX_PRESSURE);
else
coords->pressure = GIMP_COORDS_DEFAULT_PRESSURE;
if (gdk_device_get_axis (device, event->axes, GDK_AXIS_XTILT, &coords->xtilt))
coords->xtilt = CLAMP (coords->xtilt, GIMP_COORDS_MIN_TILT,
GIMP_COORDS_MAX_TILT);
else
coords->xtilt = GIMP_COORDS_DEFAULT_TILT;
if (gdk_device_get_axis (device, event->axes, GDK_AXIS_YTILT, &coords->ytilt))
coords->ytilt = CLAMP (coords->ytilt, GIMP_COORDS_MIN_TILT,
GIMP_COORDS_MAX_TILT);
else
coords->ytilt = GIMP_COORDS_DEFAULT_TILT;
if (gdk_device_get_axis (device, event->axes, GDK_AXIS_WHEEL, &coords->wheel))
coords->wheel = CLAMP (coords->wheel, GIMP_COORDS_MIN_WHEEL,
GIMP_COORDS_MAX_WHEEL);
else
coords->wheel = GIMP_COORDS_DEFAULT_WHEEL;
}
gboolean
gimp_display_shell_get_event_state (GimpDisplayShell *shell,
GdkEvent *event,
GdkDevice *device,
GdkModifierType *state)
{
if (gdk_event_get_state (event, state))
return TRUE;
gimp_display_shell_get_device_state (shell, device, state);
return FALSE;
}
void
gimp_display_shell_get_device_state (GimpDisplayShell *shell,
GdkDevice *device,
GdkModifierType *state)
{
gdk_device_get_state (device, shell->canvas->window, NULL, state);
}

View File

@ -0,0 +1,43 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DISPLAY_SHELL_COORDS_H__
#define __GIMP_DISPLAY_SHELL_COORDS_H__
gboolean gimp_display_shell_get_event_coords (GimpDisplayShell *shell,
GdkEvent *event,
GdkDevice *device,
GimpCoords *coords);
void gimp_display_shell_get_device_coords (GimpDisplayShell *shell,
GdkDevice *device,
GimpCoords *coords);
void gimp_display_shell_get_time_coords (GimpDisplayShell *shell,
GdkDevice *device,
GdkTimeCoord *event,
GimpCoords *coords);
gboolean gimp_display_shell_get_event_state (GimpDisplayShell *shell,
GdkEvent *event,
GdkDevice *device,
GdkModifierType *state);
void gimp_display_shell_get_device_state (GimpDisplayShell *shell,
GdkDevice *device,
GdkModifierType *state);
#endif /* __GIMP_DISPLAY_SHELL_COORDS_H__ */

View File

@ -168,6 +168,8 @@ struct _GimpDisplayShell
guint32 last_motion_time;
GdkRectangle *highlight; /* in image coordinates, can be NULL */
gpointer scroll_info;
};
struct _GimpDisplayShellClass