app: Allow for mypaint tool to differentiate extended and non-extended events

This adds a boolean to GimpCoords struct that is true for enabled
extended non-mouse devices and false for all the rest allowing
the mypaint brush to override the the pressure sent to the paint library.
This commit is contained in:
Alexia Death 2015-12-29 14:53:19 +02:00
parent e415b1cfab
commit 53eb8677ea
5 changed files with 55 additions and 12 deletions

View File

@ -248,16 +248,17 @@ typedef gint64 (* GimpMemsizeFunc) (gpointer instance,
struct _GimpCoords
{
gdouble x;
gdouble y;
gdouble pressure;
gdouble xtilt;
gdouble ytilt;
gdouble wheel;
gdouble velocity;
gdouble direction;
gdouble xscale; /* the view scale */
gdouble yscale;
gdouble x;
gdouble y;
gdouble pressure;
gdouble xtilt;
gdouble ytilt;
gdouble wheel;
gdouble velocity;
gdouble direction;
gdouble xscale; /* the view scale */
gdouble yscale;
gboolean extended;
};
/* temp hack as replacement for GdkSegment */

View File

@ -265,7 +265,7 @@ gimp_coords_interpolate_catmull (const GimpCoords catmul_pt1,
for (n = 1; n <= num_points; n++)
{
GimpCoords coords;
GimpCoords coords = past_coords; /*Make sure we carry over things we do not interpolate*/
gdouble velocity;
gdouble pressure;
gdouble p = (gdouble) n / num_points;

View File

@ -51,6 +51,7 @@ gimp_coords_mix (const gdouble amul,
ret_val->wheel = amul * a->wheel + bmul * b->wheel;
ret_val->velocity = amul * a->velocity + bmul * b->velocity;
ret_val->direction = amul * a->direction + bmul * b->direction;
ret_val->extended = b->extended || a->extended;
}
else
{
@ -62,6 +63,7 @@ gimp_coords_mix (const gdouble amul,
ret_val->wheel = amul * a->wheel;
ret_val->velocity = amul * a->velocity;
ret_val->direction = amul * a->direction;
ret_val->extended = a->extended;
}
}
@ -195,6 +197,8 @@ gimp_coords_equal (const GimpCoords *a,
a->wheel == b->wheel &&
a->velocity == b->velocity &&
a->direction == b->direction);
/* Extended attribute was omitted from this comparison deliberately
- it describes the events origin, not it's value*/
}
/* helper for calculating direction of two gimpcoords. */

View File

@ -251,6 +251,7 @@ gimp_mybrush_core_motion (GimpPaintCore *paint_core,
{
GimpMybrushCore *mybrush = GIMP_MYBRUSH_CORE (paint_core);
MyPaintRectangle rect;
gdouble pressure = coords->pressure;
mypaint_surface_begin_atomic ((MyPaintSurface *) mybrush->private->surface);
@ -269,14 +270,20 @@ gimp_mybrush_core_motion (GimpPaintCore *paint_core,
1.0f /* Pretend the cursor hasn't moved in a while */);
}
if (!coords->extended)
{
pressure = 0.5f; /* Mypaint expects non-extended devices to default to half pressure*/
}
mypaint_brush_stroke_to (mybrush->private->brush,
(MyPaintSurface *) mybrush->private->surface,
coords->x,
coords->y,
coords->pressure,
pressure,
coords->xtilt,
coords->ytilt,
(time - mybrush->private->last_time) * 0.001f);
mybrush->private->last_time = time;
mypaint_surface_end_atomic ((MyPaintSurface *) mybrush->private->surface,

View File

@ -101,6 +101,17 @@ gimp_device_info_get_event_coords (GimpDeviceInfo *info,
coords->wheel);
}
if (gimp_device_info_get_mode (info) != GDK_MODE_DISABLED &&
gdk_device_get_source (info->device) != GDK_SOURCE_MOUSE)
{
coords->extended = TRUE; /* The event was generated by an enabled extended non-mouse device */
}
else
{
coords->extended = FALSE; /* The event was generated by a not extended enabled device */
}
return TRUE;
}
@ -154,6 +165,16 @@ gimp_device_info_get_device_coords (GimpDeviceInfo *info,
GDK_AXIS_WHEEL,
coords->wheel);
}
if (gimp_device_info_get_mode (info) != GDK_MODE_DISABLED &&
gdk_device_get_source (info->device) != GDK_SOURCE_MOUSE)
{
coords->extended = TRUE; /* The event was generated by an enabled extended non-mouse device */
}
else
{
coords->extended = FALSE; /* The event was generated by a not extended enabled device */
}
}
void
@ -201,6 +222,16 @@ gimp_device_info_get_time_coords (GimpDeviceInfo *info,
GDK_AXIS_WHEEL,
coords->wheel);
}
if (gimp_device_info_get_mode (info) != GDK_MODE_DISABLED &&
gdk_device_get_source (info->device) != GDK_SOURCE_MOUSE)
{
coords->extended = TRUE; /* The event was generated by an enabled extended non-mouse device */
}
else
{
coords->extended = FALSE; /* The event was generated by a not extended enabled device */
}
}
gboolean