mirror of https://github.com/GNOME/gimp.git
app: add the new distance, rotation and slider axes to GimpCoords
and add code to get them from events and devices.
This commit is contained in:
parent
4703a195bb
commit
ecb99ab445
|
@ -60,6 +60,10 @@
|
|||
#define GIMP_COORDS_MAX_WHEEL 1.0
|
||||
#define GIMP_COORDS_DEFAULT_WHEEL 0.5
|
||||
|
||||
#define GIMP_COORDS_DEFAULT_DISTANCE 0.0
|
||||
#define GIMP_COORDS_DEFAULT_ROTATION 0.0
|
||||
#define GIMP_COORDS_DEFAULT_SLIDER 0.0
|
||||
|
||||
#define GIMP_COORDS_DEFAULT_VELOCITY 0.0
|
||||
|
||||
#define GIMP_COORDS_DEFAULT_DIRECTION 0.0
|
||||
|
@ -72,6 +76,9 @@
|
|||
GIMP_COORDS_DEFAULT_TILT, \
|
||||
GIMP_COORDS_DEFAULT_TILT, \
|
||||
GIMP_COORDS_DEFAULT_WHEEL, \
|
||||
GIMP_COORDS_DEFAULT_DISTANCE, \
|
||||
GIMP_COORDS_DEFAULT_ROTATION, \
|
||||
GIMP_COORDS_DEFAULT_SLIDER, \
|
||||
GIMP_COORDS_DEFAULT_VELOCITY, \
|
||||
GIMP_COORDS_DEFAULT_DIRECTION,\
|
||||
GIMP_COORDS_DEFAULT_XSCALE, \
|
||||
|
@ -243,14 +250,22 @@ typedef gint64 (* GimpMemsizeFunc) (gpointer instance,
|
|||
|
||||
struct _GimpCoords
|
||||
{
|
||||
/* axes as reported by the device */
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
gdouble pressure;
|
||||
gdouble xtilt;
|
||||
gdouble ytilt;
|
||||
gdouble wheel;
|
||||
gdouble distance;
|
||||
gdouble rotation;
|
||||
gdouble slider;
|
||||
|
||||
/* synthetic axes */
|
||||
gdouble velocity;
|
||||
gdouble direction;
|
||||
|
||||
/* view transform */
|
||||
gdouble xscale; /* the view scale */
|
||||
gdouble yscale;
|
||||
gdouble angle; /* the view rotation angle */
|
||||
|
|
|
@ -49,6 +49,9 @@ gimp_coords_mix (const gdouble amul,
|
|||
ret_val->xtilt = amul * a->xtilt + bmul * b->xtilt;
|
||||
ret_val->ytilt = amul * a->ytilt + bmul * b->ytilt;
|
||||
ret_val->wheel = amul * a->wheel + bmul * b->wheel;
|
||||
ret_val->distance = amul * a->distance + bmul * b->distance;
|
||||
ret_val->rotation = amul * a->rotation + bmul * b->rotation;
|
||||
ret_val->slider = amul * a->slider + bmul * b->slider;
|
||||
ret_val->velocity = amul * a->velocity + bmul * b->velocity;
|
||||
ret_val->direction = amul * a->direction + bmul * b->direction;
|
||||
}
|
||||
|
@ -60,6 +63,9 @@ gimp_coords_mix (const gdouble amul,
|
|||
ret_val->xtilt = amul * a->xtilt;
|
||||
ret_val->ytilt = amul * a->ytilt;
|
||||
ret_val->wheel = amul * a->wheel;
|
||||
ret_val->distance = amul * a->distance;
|
||||
ret_val->rotation = amul * a->rotation;
|
||||
ret_val->slider = amul * a->slider;
|
||||
ret_val->velocity = amul * a->velocity;
|
||||
ret_val->direction = amul * a->direction;
|
||||
}
|
||||
|
@ -122,6 +128,9 @@ gimp_coords_scalarprod (const GimpCoords *a,
|
|||
a->xtilt * b->xtilt +
|
||||
a->ytilt * b->ytilt +
|
||||
a->wheel * b->wheel +
|
||||
a->distance * b->distance +
|
||||
a->rotation * b->rotation +
|
||||
a->slider * b->slider +
|
||||
a->velocity * b->velocity +
|
||||
a->direction * b->direction);
|
||||
}
|
||||
|
@ -144,6 +153,9 @@ gimp_coords_length_squared (const GimpCoords *a)
|
|||
upscaled_a.xtilt = a->xtilt * INPUT_RESOLUTION;
|
||||
upscaled_a.ytilt = a->ytilt * INPUT_RESOLUTION;
|
||||
upscaled_a.wheel = a->wheel * INPUT_RESOLUTION;
|
||||
upscaled_a.distance = a->distance * INPUT_RESOLUTION;
|
||||
upscaled_a.rotation = a->rotation * INPUT_RESOLUTION;
|
||||
upscaled_a.slider = a->slider * INPUT_RESOLUTION;
|
||||
upscaled_a.velocity = a->velocity * INPUT_RESOLUTION;
|
||||
upscaled_a.direction = a->direction * INPUT_RESOLUTION;
|
||||
|
||||
|
@ -172,6 +184,9 @@ gimp_coords_manhattan_dist (const GimpCoords *a,
|
|||
dist += ABS (a->xtilt - b->xtilt);
|
||||
dist += ABS (a->ytilt - b->ytilt);
|
||||
dist += ABS (a->wheel - b->wheel);
|
||||
dist += ABS (a->distance - b->distance);
|
||||
dist += ABS (a->rotation - b->rotation);
|
||||
dist += ABS (a->slider - b->slider);
|
||||
dist += ABS (a->velocity - b->velocity);
|
||||
dist += ABS (a->direction - b->direction);
|
||||
|
||||
|
@ -193,6 +208,9 @@ gimp_coords_equal (const GimpCoords *a,
|
|||
a->xtilt == b->xtilt &&
|
||||
a->ytilt == b->ytilt &&
|
||||
a->wheel == b->wheel &&
|
||||
a->distance == b->distance &&
|
||||
a->rotation == b->rotation &&
|
||||
a->slider == b->slider &&
|
||||
a->velocity == b->velocity &&
|
||||
a->direction == b->direction);
|
||||
|
||||
|
|
|
@ -101,6 +101,27 @@ gimp_device_info_get_event_coords (GimpDeviceInfo *info,
|
|||
coords->wheel);
|
||||
}
|
||||
|
||||
if (gdk_event_get_axis (event, GDK_AXIS_DISTANCE, &coords->distance))
|
||||
{
|
||||
coords->distance = gimp_device_info_map_axis (info,
|
||||
GDK_AXIS_DISTANCE,
|
||||
coords->distance);
|
||||
}
|
||||
|
||||
if (gdk_event_get_axis (event, GDK_AXIS_ROTATION, &coords->rotation))
|
||||
{
|
||||
coords->rotation = gimp_device_info_map_axis (info,
|
||||
GDK_AXIS_ROTATION,
|
||||
coords->rotation);
|
||||
}
|
||||
|
||||
if (gdk_event_get_axis (event, GDK_AXIS_SLIDER, &coords->slider))
|
||||
{
|
||||
coords->slider = gimp_device_info_map_axis (info,
|
||||
GDK_AXIS_SLIDER,
|
||||
coords->slider);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -172,6 +193,30 @@ gimp_device_info_get_device_coords (GimpDeviceInfo *info,
|
|||
GDK_AXIS_WHEEL,
|
||||
coords->wheel);
|
||||
}
|
||||
|
||||
if (gdk_device_get_axis (info->device,
|
||||
axes, GDK_AXIS_DISTANCE, &coords->distance))
|
||||
{
|
||||
coords->distance = gimp_device_info_map_axis (info,
|
||||
GDK_AXIS_DISTANCE,
|
||||
coords->distance);
|
||||
}
|
||||
|
||||
if (gdk_device_get_axis (info->device,
|
||||
axes, GDK_AXIS_ROTATION, &coords->rotation))
|
||||
{
|
||||
coords->rotation = gimp_device_info_map_axis (info,
|
||||
GDK_AXIS_ROTATION,
|
||||
coords->rotation);
|
||||
}
|
||||
|
||||
if (gdk_device_get_axis (info->device,
|
||||
axes, GDK_AXIS_SLIDER, &coords->slider))
|
||||
{
|
||||
coords->slider = gimp_device_info_map_axis (info,
|
||||
GDK_AXIS_SLIDER,
|
||||
coords->slider);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -219,6 +264,30 @@ gimp_device_info_get_time_coords (GimpDeviceInfo *info,
|
|||
GDK_AXIS_WHEEL,
|
||||
coords->wheel);
|
||||
}
|
||||
|
||||
if (gdk_device_get_axis (info->device,
|
||||
event->axes, GDK_AXIS_DISTANCE, &coords->distance))
|
||||
{
|
||||
coords->distance = gimp_device_info_map_axis (info,
|
||||
GDK_AXIS_DISTANCE,
|
||||
coords->distance);
|
||||
}
|
||||
|
||||
if (gdk_device_get_axis (info->device,
|
||||
event->axes, GDK_AXIS_ROTATION, &coords->rotation))
|
||||
{
|
||||
coords->rotation = gimp_device_info_map_axis (info,
|
||||
GDK_AXIS_ROTATION,
|
||||
coords->rotation);
|
||||
}
|
||||
|
||||
if (gdk_device_get_axis (info->device,
|
||||
event->axes, GDK_AXIS_SLIDER, &coords->slider))
|
||||
{
|
||||
coords->slider = gimp_device_info_map_axis (info,
|
||||
GDK_AXIS_SLIDER,
|
||||
coords->slider);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
@ -2635,7 +2635,7 @@ xcf_load_vector (XcfInfo *info,
|
|||
guint32 num_axes;
|
||||
guint32 num_control_points;
|
||||
guint32 type;
|
||||
gfloat coords[10] = GIMP_COORDS_DEFAULT_VALUES;
|
||||
gfloat coords[13] = GIMP_COORDS_DEFAULT_VALUES;
|
||||
GimpStroke *stroke;
|
||||
gint j;
|
||||
|
||||
|
|
Loading…
Reference in New Issue