From d4179a12792269f2af090d27a4307c6a570ef8a2 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 2 Jul 2019 22:37:15 +0200 Subject: Rename "struct nanolight" to "struct lightctx" --- src/nanolight.c | 143 ++------------------------------------------------------ 1 file changed, 3 insertions(+), 140 deletions(-) (limited to 'src/nanolight.c') diff --git a/src/nanolight.c b/src/nanolight.c index 42bd068..b78a6f8 100644 --- a/src/nanolight.c +++ b/src/nanolight.c @@ -32,7 +32,7 @@ #include #define _(x) gettext(x) -#include "nanolight.h" +#include "lightctx.h" #include "scanout.h" #include "display.h" @@ -44,153 +44,16 @@ static void show_help(const char *s) } -static struct fixture *create_fixture(struct nanolight *nl, struct fixture_class *cls, - const char *label, int universe, int base_addr, - int flags) -{ - struct fixture *fix; - - if ( nl->n_fixtures == nl->max_fixtures ) { - struct fixture *fixtures_new; - fixtures_new = realloc(nl->fixtures, (64+nl->max_fixtures)*sizeof(struct fixture)); - if ( fixtures_new == NULL ) return NULL; - nl->fixtures = fixtures_new; - nl->max_fixtures += 64; - } - - fix = &nl->fixtures[nl->n_fixtures++]; - fix->label = strdup(label); - fix->universe = universe; - fix->base_addr = base_addr; - fix->cls = cls; - fix->flags = flags; - - fix->intensity = 0.0; - fix->cyan = 0.0; - fix->magenta = 0.0; - fix->yellow = 0.0; - fix->red = 0.0; - fix->green = 0.0; - fix->blue = 0.0; - fix->pan = 0.0; - fix->tilt = 0.0; - fix->gobo = 0; - fix->gobo_rotate = 0.0; - fix->gobo_spin = 0.0; - fix->prism = 0; - fix->prism_rotate = 0.0; - fix->prism_spin = 0.0; - fix->focus = 0.5; - fix->zoom = 0.5; - fix->frost = 0.0; - - return fix; -} - - static gboolean scanout_cb(gpointer data) { - scanout_all((struct nanolight *)data); + scanout_all((struct lightctx *)data); return G_SOURCE_CONTINUE; } -static void cap_value(float *val, float min, float max) -{ - if ( *val > max ) *val = max; - if ( *val < min ) *val = min; -} - - -void attr_movex(struct nanolight *nl, signed int d, int fine) -{ - int i; - float chg = fine ? d/60000.0 : d/10.0; - if ( nl->sel_attr != PANTILT ) return; - for ( i=0; in_sel; i++ ) { - struct fixture *fix = &nl->fixtures[nl->selection[i]]; - if ( !(fix->cls->attributes & PANTILT) ) continue; - fix->pan += chg; - cap_value(&fix->pan, -1.0, 1.0); - } -} - - -void attr_movey(struct nanolight *nl, signed int d, int fine) -{ - int i; - float chg = fine ? d/60000.0 : d/10.0; - for ( i=0; in_sel; i++ ) { - struct fixture *fix = &nl->fixtures[nl->selection[i]]; - - switch ( nl->sel_attr ) { - - case PANTILT : - fix->tilt += chg; - cap_value(&fix->tilt, -1.0, 1.0); - break; - - case FOCUS : - fix->focus += chg; - cap_value(&fix->focus, 0.0, 1.0); - break; - - case ZOOM : - fix->zoom += chg; - cap_value(&fix->zoom, 0.0, 1.0); - break; - - case FROST : - fix->frost += chg; - cap_value(&fix->frost, 0.0, 1.0); - break; - - case IRIS : - fix->iris += chg; - cap_value(&fix->iris, 0.0, 1.0); - break; - - case GOBO : - if ( (fix->gobo == 0) && (d<0) ) continue; - if ( (fix->gobo == fix->cls->n_gobos-1) && (d>0) ) continue; - fix->gobo += d; - break; - - case GOBO_ROTATE : - fix->gobo_rotate += chg; - cap_value(&fix->gobo_rotate, -1.0, 1.0); - break; - - case GOBO_SPIN : - fix->gobo_spin += chg; - cap_value(&fix->gobo_spin, -1.0, 1.0); - break; - - case PRISM : - if ( (fix->prism == 0) && (d<0) ) continue; - if ( (fix->prism == fix->cls->n_prisms-1) && (d>0) ) continue; - fix->prism += d; - break; - - case PRISM_ROTATE : - fix->prism_rotate += chg; - cap_value(&fix->prism_rotate, -1.0, 1.0); - break; - - case PRISM_SPIN : - fix->prism_spin += chg; - cap_value(&fix->prism_spin, -1.0, 1.0); - break; - - } - - } -} - - int main(int argc, char *argv[]) { - struct nanolight nl; + struct lightctx nl; struct fixture_class cls; int c; -- cgit v1.2.3