From 9aac9867abd6b99d4e2739c162bbd8fbc47a123d Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 18 Jan 2020 23:57:41 +0100 Subject: Add ability to go backwards --- glitchyclock.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/glitchyclock.c b/glitchyclock.c index 0e15787..a5e2894 100644 --- a/glitchyclock.c +++ b/glitchyclock.c @@ -122,6 +122,23 @@ static void run_cue(struct glitchyclock *gc) } +static void back_cue(struct glitchyclock *gc) +{ + if ( gc->cue == 0 ) return; + gc->cue--; + gc->real_time_last_cue = get_monotonic_seconds() - 10; + gc->flag = 1; + if ( cues[gc->cue].type == FADE_IN ) { + gc->real_time_last_reset = get_monotonic_seconds() - 10; + gc->base_hours = cues[gc->cue].hours; + gc->base_minutes = cues[gc->cue].minutes; + gc->base_seconds = cues[gc->cue].seconds; + } +} + + + + static gboolean draw_sig(GtkWidget *widget, cairo_t *cr, struct glitchyclock *gc) { double lw, lh; @@ -274,6 +291,12 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, struct glitchyc return TRUE; } + if ( event->keyval == GDK_KEY_BackSpace ) { + back_cue(gc); + redraw_cb(gc); + return TRUE; + } + if ( event->keyval == GDK_KEY_q ) { gtk_main_quit(); } -- cgit v1.2.3