Skip to content

Commit

Permalink
Make the line thickness changer applicable to mouse drawing as well.
Browse files Browse the repository at this point in the history
This commit removes the special mouse handling by settings default
pressure to full-on. Thus, dynamic line thickness will be taken into account
for mouse events as well now.
  • Loading branch information
bk138 committed Nov 16, 2016
1 parent 5b50ba3 commit c2b4d4a
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions src/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ gboolean on_buttonpress (GtkWidget *win,
gpointer user_data)
{
GromitData *data = (GromitData *) user_data;
gdouble pressure = 0.5;
gdouble pressure = 1;

/* get the data for this device */
GdkDevice *master = ev->device;
Expand Down Expand Up @@ -263,18 +263,13 @@ gboolean on_buttonpress (GtkWidget *win,
slavedata->motion_time = ev->time;

snap_undo_state (data);
if (gdk_device_get_source(slave) == GDK_SOURCE_MOUSE)
{
data->maxwidth = slavedata->cur_context->width;
}
else
{
gdk_event_get_axis ((GdkEvent *) ev, GDK_AXIS_PRESSURE, &pressure);
data->maxwidth = (CLAMP (pressure + line_thickener, 0, 1) *
(double) (slavedata->cur_context->width -
slavedata->cur_context->minwidth) +
slavedata->cur_context->minwidth);
}

gdk_event_get_axis ((GdkEvent *) ev, GDK_AXIS_PRESSURE, &pressure);
data->maxwidth = (CLAMP (pressure + line_thickener, 0, 1) *
(double) (slavedata->cur_context->width -
slavedata->cur_context->minwidth) +
slavedata->cur_context->minwidth);

if (ev->button <= 5)
draw_line (data, slave, ev->x, ev->y, ev->x, ev->y);

Expand All @@ -292,7 +287,7 @@ gboolean on_motion (GtkWidget *win,
GdkTimeCoord **coords = NULL;
gint nevents;
int i;
gdouble pressure = 0.5;
gdouble pressure = 1;

/* get the data for this device */
GdkDevice *master = ev->device;
Expand Down Expand Up @@ -336,13 +331,10 @@ gboolean on_motion (GtkWidget *win,
GDK_AXIS_PRESSURE, &pressure);
if (pressure > 0)
{
if (gdk_device_get_source(slave) == GDK_SOURCE_MOUSE)
data->maxwidth = slavedata->cur_context->width;
else
data->maxwidth = (CLAMP (pressure + line_thickener, 0, 1) *
(double) (slavedata->cur_context->width -
slavedata->cur_context->minwidth) +
slavedata->cur_context->minwidth);
data->maxwidth = (CLAMP (pressure + line_thickener, 0, 1) *
(double) (slavedata->cur_context->width -
slavedata->cur_context->minwidth) +
slavedata->cur_context->minwidth);

gdk_device_get_axis(slave, coords[i]->axes,
GDK_AXIS_X, &x);
Expand All @@ -366,13 +358,10 @@ gboolean on_motion (GtkWidget *win,

if (pressure > 0)
{
if (gdk_device_get_source(slave) == GDK_SOURCE_MOUSE)
data->maxwidth = slavedata->cur_context->width;
else
data->maxwidth = (CLAMP (pressure + line_thickener, 0, 1) *
(double) (slavedata->cur_context->width -
slavedata->cur_context->minwidth) +
slavedata->cur_context->minwidth);
data->maxwidth = (CLAMP (pressure + line_thickener, 0, 1) *
(double) (slavedata->cur_context->width -
slavedata->cur_context->minwidth) +
slavedata->cur_context->minwidth);

if(slavedata->motion_time > 0)
{
Expand Down

0 comments on commit c2b4d4a

Please sign in to comment.