Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config, main, callbacks, drawing: enable smaller increments of arrows #220

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,13 @@ gboolean on_motion (GtkWidget *win,
if (devdata->cur_context->arrowsize > 0)
{
GromitArrowType atype = devdata->cur_context->arrow_type;
gint width = devdata->cur_context->arrowsize * devdata->cur_context->width / 2;
gfloat width = devdata->cur_context->arrowsize * devdata->cur_context->width;
gfloat direction =
atan2(ev->y - devdata->lasty, ev->x - devdata->lastx);
if (atype & GROMIT_ARROW_END)
draw_arrow(data, ev->device, ev->x, ev->y, width * 2, direction);
draw_arrow(data, ev->device, ev->x, ev->y, width, direction);
if (atype & GROMIT_ARROW_START)
draw_arrow(data, ev->device, devdata->lastx, devdata->lasty, width * 2, M_PI + direction);
draw_arrow(data, ev->device, devdata->lastx, devdata->lasty, width, M_PI + direction);
}
}
else if (type == GROMIT_RECT)
Expand Down
9 changes: 5 additions & 4 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ gboolean parse_config (GromitData *data)

GromitPaintType type;
GdkRGBA *fg_color=NULL;
guint width, arrowsize, minwidth, maxwidth;
guint width, minwidth, maxwidth;
gfloat arrowsize;
guint minlen, maxangle, radius, simplify, snapdist;
GromitArrowType arrowtype;

Expand Down Expand Up @@ -373,9 +374,9 @@ gboolean parse_config (GromitData *data)
}
else if ((intptr_t) scanner->value.v_symbol == SYM_ARROWSIZE)
{
gfloat v = parse_get_float(scanner, "Missing arrowsize (float)");
if (isnan(v)) goto cleanup;
arrowsize = (guint)(v + 0.5);
arrowsize = parse_get_float(scanner, "Missing arrowsize (float)");
if (isnan(arrowsize)) goto cleanup;
if (arrowsize < 1) arrowsize = 1;
arrowtype = GROMIT_ARROW_END;
}
else if ((intptr_t) scanner->value.v_symbol == SYM_ARROWTYPE)
Expand Down
2 changes: 1 addition & 1 deletion src/drawing.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void draw_line (GromitData *data,
void draw_arrow (GromitData *data,
GdkDevice *dev,
gint x1, gint y1,
gint width,
gfloat width,
gfloat direction)
{
GdkRectangle rect;
Expand Down
2 changes: 1 addition & 1 deletion src/drawing.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ typedef struct


void draw_line (GromitData *data, GdkDevice *dev, gint x1, gint y1, gint x2, gint y2);
void draw_arrow (GromitData *data, GdkDevice *dev, gint x1, gint y1, gint width, gfloat direction);
void draw_arrow (GromitData *data, GdkDevice *dev, gint x1, gint y1, gfloat width, gfloat direction);

#endif
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ GromitPaintContext *paint_context_new (GromitData *data,
GromitPaintType type,
GdkRGBA *paint_color,
guint width,
guint arrowsize,
gfloat arrowsize,
GromitArrowType arrowtype,
guint simpilfy,
guint radius,
Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void clear_screen (GromitData *data);

GromitPaintContext *paint_context_new (GromitData *data, GromitPaintType type,
GdkRGBA *fg_color, guint width,
guint arrowsize, GromitArrowType arrowtype,
gfloat arrowsize, GromitArrowType arrowtype,
guint simpilfy, guint radius, guint maxangle, guint minlen, guint snapdist,
guint minwidth, guint maxwidth);
void paint_context_free (GromitPaintContext *context);
Expand Down
Loading