From 65d4e516ca27baac127592742a0374ed818998c3 Mon Sep 17 00:00:00 2001 From: Jeremy Attali Date: Mon, 16 Dec 2019 23:06:15 -0500 Subject: [PATCH] shapes: got it to work with radio button --- include/application.h | 5 +++- include/swappy.h | 1 + res/swappy.ui | 68 ++++++++++++++++++++++++++++++++++++++++--- src/application.c | 15 ++++++++++ 4 files changed, 84 insertions(+), 5 deletions(-) diff --git a/include/application.h b/include/application.h index 648d7ab..76c2dc2 100644 --- a/include/application.h +++ b/include/application.h @@ -6,4 +6,7 @@ bool application_init(struct swappy_state *state); int application_run(struct swappy_state *state); void application_finish(struct swappy_state *state); -void brush_clicked_handler(GtkWidget *widget, struct swappy_state *state); \ No newline at end of file +void brush_clicked_handler(GtkWidget *widget, struct swappy_state *state); +void text_clicked_handler(GtkWidget *widget, struct swappy_state *state); +void arrow_clicked_handler(GtkWidget *widget, struct swappy_state *state); +void shape_clicked_handler(GtkWidget *widget, struct swappy_state *state); \ No newline at end of file diff --git a/include/swappy.h b/include/swappy.h index 8f18fb7..25c540d 100644 --- a/include/swappy.h +++ b/include/swappy.h @@ -24,6 +24,7 @@ enum swappy_brush_point_kind { enum swappy_paint_mode_type { SWAPPY_PAINT_MODE_BRUSH = 0, /* Brush mode to draw arbitrary shapes */ SWAPPY_PAINT_MODE_TEXT, /* Mode to draw texts */ + SWAPPY_PAINT_MODE_ARROW, /* Rectangle shapes */ SWAPPY_PAINT_MODE_RECTANGLE, /* Rectangle shapes */ }; diff --git a/res/swappy.ui b/res/swappy.ui index fcd96ad..20f6339 100644 --- a/res/swappy.ui +++ b/res/swappy.ui @@ -157,7 +157,7 @@ False True - + True True @@ -174,7 +174,7 @@ - + True True @@ -190,7 +190,7 @@ - + True True @@ -216,7 +216,67 @@ - + + True + False + + + + True + True + False + True + False + brush + + + + False + True + 0 + + + + + + True + True + False + False + brush + + + + False + True + 1 + + + + + + True + True + False + False + brush + + + + False + True + 2 + + + + + + False + True + 1 + diff --git a/src/application.c b/src/application.c index 6aee5b4..1bc638f 100644 --- a/src/application.c +++ b/src/application.c @@ -23,6 +23,21 @@ static void switch_mode_to_brush(struct swappy_state *state) { state->mode = SWAPPY_PAINT_MODE_BRUSH; } +void text_clicked_handler(GtkWidget *widget, struct swappy_state *state) { + g_debug("switching mode to arrow"); + state->mode = SWAPPY_PAINT_MODE_ARROW; +} + +void arrow_clicked_handler(GtkWidget *widget, struct swappy_state *state) { + g_debug("switching mode to arrow"); + state->mode = SWAPPY_PAINT_MODE_ARROW; +} + +void rectangle_clicked_handler(GtkWidget *widget, struct swappy_state *state) { + g_debug("switching mode to rectangle"); + state->mode = SWAPPY_PAINT_MODE_RECTANGLE; +} + void application_finish(struct swappy_state *state) { g_debug("application is shutting down"); swappy_overlay_clear(state);