Skip to content

Commit

Permalink
config: don't set arrow type to none when size is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-niklaus committed Mar 9, 2024
1 parent 315496d commit f311668
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ A `LINE`-tool draws straight lines.

A `RECT`-tool draws rectangles.

"red Rectangle" = LINE (color = "red");
"red Rectangle" = RECT (color = "red");

If you define a tool with the same name as an input-device
(see the output of `xinput --list`) this input-device uses this tool:
Expand Down
10 changes: 5 additions & 5 deletions src/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ void on_monitors_changed ( GdkScreen *screen,


data->default_pen = paint_context_new (data, GROMIT_PEN, data->red, 7,
0, GROMIT_ARROW_NONE, 1, G_MAXUINT);
0, GROMIT_ARROW_END, 1, G_MAXUINT);
data->default_eraser = paint_context_new (data, GROMIT_ERASER, data->red, 75,
0, GROMIT_ARROW_NONE, 1, G_MAXUINT);
0, GROMIT_ARROW_END, 1, G_MAXUINT);

if(!data->composited) // set shape
{
Expand Down Expand Up @@ -398,10 +398,10 @@ gboolean on_motion (GtkWidget *win,
}
if (type == GROMIT_LINE)
{
GromitArrowType atype = devdata->cur_context->arrow_type;
draw_line (data, ev->device, devdata->lastx, devdata->lasty, ev->x, ev->y);
if (atype != GROMIT_ARROW_NONE)
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 direction =
atan2(ev->y - devdata->lasty, ev->x - devdata->lastx);
Expand Down Expand Up @@ -616,7 +616,7 @@ void on_mainapp_selection_received (GtkWidget *widget,
}
GromitPaintContext* line_ctx =
paint_context_new(data, GROMIT_PEN, fg_color, thickness,
0, GROMIT_ARROW_NONE, thickness, thickness);
0, GROMIT_ARROW_END, thickness, thickness);

GdkRectangle rect;
rect.x = MIN (startX,endX) - thickness / 2;
Expand Down
3 changes: 1 addition & 2 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ gboolean parse_config (GromitData *data)
type = GROMIT_PEN;
width = 7;
arrowsize = 0;
arrowtype = GROMIT_ARROW_NONE;
arrowtype = GROMIT_ARROW_END;
minwidth = 1;
maxwidth = G_MAXUINT;
fg_color = data->red;
Expand Down Expand Up @@ -340,7 +340,6 @@ gboolean parse_config (GromitData *data)
goto cleanup;
}
arrowsize = scanner->value.v_float;
arrowtype = GROMIT_ARROW_END;
}
else if ((intptr_t) scanner->value.v_symbol == 4)
{
Expand Down
6 changes: 2 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ void paint_context_print (gchar *name,
case GROMIT_ARROW_DOUBLE:
g_printerr(" arrowtype: double, ");
break;
case GROMIT_ARROW_NONE:
break;
}
}
g_printerr ("color: %s\n", gdk_rgba_to_string(context->paint_color));
Expand Down Expand Up @@ -778,10 +776,10 @@ void setup_main_app (GromitData *data, int argc, char ** argv)

data->default_pen =
paint_context_new (data, GROMIT_PEN, data->red, 7,
0, GROMIT_ARROW_NONE, 1, G_MAXUINT);
0, GROMIT_ARROW_END, 1, G_MAXUINT);
data->default_eraser =
paint_context_new (data, GROMIT_ERASER, data->red, 75,
0, GROMIT_ARROW_NONE, 1, G_MAXUINT);
0, GROMIT_ARROW_END, 1, G_MAXUINT);

gdk_event_handler_set ((GdkEventFunc) main_do_event, data, NULL);
gtk_key_snooper_install (snoop_key_press, data);
Expand Down
1 change: 0 additions & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ typedef enum

typedef enum
{
GROMIT_ARROW_NONE = 0,
GROMIT_ARROW_START = 1,
GROMIT_ARROW_END = 2,
GROMIT_ARROW_DOUBLE = (GROMIT_ARROW_START | GROMIT_ARROW_END )
Expand Down

0 comments on commit f311668

Please sign in to comment.