mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
gtk-demo: Work without stylus
In the paint demo, don't assume that the event backlog contains pressure. It won't, if we are working with a plain old mouse.
This commit is contained in:
parent
5970a14217
commit
7f906bef06
@ -263,7 +263,7 @@ drawing_area_apply_stroke (DrawingArea *area,
|
||||
double y,
|
||||
double pressure)
|
||||
{
|
||||
if (gdk_device_tool_get_tool_type (tool) == GDK_DEVICE_TOOL_TYPE_ERASER)
|
||||
if (tool && gdk_device_tool_get_tool_type (tool) == GDK_DEVICE_TOOL_TYPE_ERASER)
|
||||
{
|
||||
cairo_set_line_width (area->cr, 10 * pressure * area->brush_size);
|
||||
cairo_set_operator (area->cr, CAIRO_OPERATOR_DEST_OUT);
|
||||
@ -314,7 +314,9 @@ stylus_gesture_motion (GtkGestureStylus *gesture,
|
||||
drawing_area_apply_stroke (area, tool,
|
||||
backlog[i].axes[GDK_AXIS_X],
|
||||
backlog[i].axes[GDK_AXIS_Y],
|
||||
backlog[i].axes[GDK_AXIS_PRESSURE]);
|
||||
backlog[i].flags & GDK_AXIS_FLAG_PRESSURE
|
||||
? backlog[i].axes[GDK_AXIS_PRESSURE]
|
||||
: 1);
|
||||
}
|
||||
|
||||
g_free (backlog);
|
||||
|
Loading…
Reference in New Issue
Block a user