diff options
author | Thomas White <taw@physics.org> | 2023-04-29 18:38:44 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2023-04-29 18:38:44 +0200 |
commit | befc9feebf514736f140b50e46f7076ececd3d88 (patch) | |
tree | e29d8ca3c834b8a127d55d8f0fa29b8bf0277e0a | |
parent | 55a076a607b5e65f90f98e4e5e9bac5852df1d3e (diff) |
Add add-sel and toggle-sel
-rw-r--r-- | guile/starlet/open-sound-control/utils.scm | 5 | ||||
-rw-r--r-- | guile/starlet/selection.scm | 17 | ||||
-rw-r--r-- | 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; |