From befc9feebf514736f140b50e46f7076ececd3d88 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 29 Apr 2023 18:38:44 +0200 Subject: Add add-sel and toggle-sel --- guile/starlet/open-sound-control/utils.scm | 5 +---- guile/starlet/selection.scm | 17 +++++++++++++++++ src/starlet-fixture-display.c | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/guile/starlet/open-sound-control/utils.scm b/guile/starlet/open-sound-control/utils.scm index 160d9bc..16ccbaf 100644 --- a/guile/starlet/open-sound-control/utils.scm +++ b/guile/starlet/open-sound-control/utils.scm @@ -73,10 +73,7 @@ (define (osc-select-button server button-method addr led fix) (add-osc-method server button-method "" - (lambda () - (if (selected? fix) - (desel fix) - (sel fix)))) + (lambda () (toggle-sel fix))) (add-and-run-hook! selection-hook diff --git a/guile/starlet/selection.scm b/guile/starlet/selection.scm index 32be41a..d0f2c1d 100644 --- a/guile/starlet/selection.scm +++ b/guile/starlet/selection.scm @@ -22,6 +22,8 @@ #:use-module (starlet utils) #:use-module (srfi srfi-1) #:export (sel + add-sel + toggle-sel desel selection-hook get-selection @@ -46,6 +48,21 @@ (run-hook selection-hook selection)) +(define (toggle-sel . fixture-list) + (if (selected? fixture-list) + (desel fixture-list) + (add-sel fixture-list))) + + +(define (add-sel . fixture-list) + (set! selection + (append selection + (filter (lambda (fix) + (not (selected? fix))) + (flatten-sublists fixture-list)))) + (run-hook selection-hook selection)) + + (define (selected? . fixture-list) (every (lambda (fix) (memq fix selection)) diff --git a/src/starlet-fixture-display.c b/src/starlet-fixture-display.c index 5ff3356..467c852 100644 --- a/src/starlet-fixture-display.c +++ b/src/starlet-fixture-display.c @@ -731,7 +731,7 @@ static gint button_press_sig(GtkWidget *window, GdkEventButton *event, event->y-OVERALL_BORDER); if ( fix != NULL ) { char tmp[256]; - snprintf(tmp, 256, "(sel %s)", fix->scheme_name); + snprintf(tmp, 256, "(toggle-sel %s)", fix->scheme_name); repl_send(fixd->repl, tmp); } return FALSE; -- cgit v1.2.3