[gimp] app: Allow for mypaint tool to differentiate extended and non-extended events
- From: Alexia Death <alexiade src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Allow for mypaint tool to differentiate extended and non-extended events
- Date: Tue, 29 Dec 2015 13:45:17 +0000 (UTC)
commit 53eb8677ea37c33ab00e948e6c054247a135cff1
Author: Alexia Death <alexiadeath gmail com>
Date: Tue Dec 29 14:53:19 2015 +0200
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.
app/core/core-types.h | 21 +++++++++++----------
app/core/gimpcoords-interpolate.c | 2 +-
app/core/gimpcoords.c | 4 ++++
app/paint/gimpmybrushcore.c | 9 ++++++++-
app/widgets/gimpdeviceinfo-coords.c | 31 +++++++++++++++++++++++++++++++
5 files changed, 55 insertions(+), 12 deletions(-)
---
diff --git a/app/core/core-types.h b/app/core/core-types.h
index e660c89..6ab8f05 100644
--- a/app/core/core-types.h
+++ b/app/core/core-types.h
@@ -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 */
diff --git a/app/core/gimpcoords-interpolate.c b/app/core/gimpcoords-interpolate.c
index 1cf5115..5096b1a 100644
--- a/app/core/gimpcoords-interpolate.c
+++ b/app/core/gimpcoords-interpolate.c
@@ -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;
diff --git a/app/core/gimpcoords.c b/app/core/gimpcoords.c
index fb65d20..da61328 100644
--- a/app/core/gimpcoords.c
+++ b/app/core/gimpcoords.c
@@ -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. */
diff --git a/app/paint/gimpmybrushcore.c b/app/paint/gimpmybrushcore.c
index b29691e..b52b7ba 100644
--- a/app/paint/gimpmybrushcore.c
+++ b/app/paint/gimpmybrushcore.c
@@ -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,
diff --git a/app/widgets/gimpdeviceinfo-coords.c b/app/widgets/gimpdeviceinfo-coords.c
index 9fef657..ef737ac 100644
--- a/app/widgets/gimpdeviceinfo-coords.c
+++ b/app/widgets/gimpdeviceinfo-coords.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]