6. Knobs Page Creation
6.1. Knobs Creation Main
A new knobs page is created with the function page_knobs
.
<<knobs_function_declarations>>=
static void page_knobs(monolith_page *pg);
<<knobs_functions>>=
static void page_knobs(monolith_page *pg)
{
page_knobs_d *knobs;
knobs = calloc(1, sizeof(page_knobs_d));
if(knobs == NULL) return;
page_knobs_init(pg, knobs);
if(knobs_type == 0)
page_knobs_runtime_init(monolith_page_monolith(pg));
<<knobs_assign_callbacks>>
monolith_page_data_set(pg, knobs);
}
6.2. Knobs Set Typeflag
<<knobs_assign_callbacks>>=
monolith_page_type_set(pg, knobs_type);
6.3. Knobs Open
When a knobs page is opened, the monome state is set.
<<knobs_function_declarations>>=
static void knobs_open(monolith_page *pg);
<<knobs_functions>>=
static void knobs_open(monolith_page *pg)
{
page_knobs_d *knobs;
knobs = monolith_page_data_get(pg);
if(knobs == NULL) return;
monolith_page_mstate_recall(knobs->mstate);
monolith_page_arcstate_recall(knobs->astate);
}
<<knobs_assign_callbacks>>=
monolith_page_open_set(pg, knobs_open);
6.4. Knobs Free
<<knobs_function_declarations>>=
static void knobs_free(monolith_page *pg);
<<knobs_functions>>=
static void knobs_free(monolith_page *pg)
{
page_knobs_d *knobs;
knobs = (page_knobs_d *)monolith_page_data_get(pg);
if(knobs == NULL) return;
page_knobs_cleanup(knobs);
free(knobs);
}
<<knobs_assign_callbacks>>=
monolith_page_free_set(pg, knobs_free);
6.5. Knobs Press Callback
Used to select the value to modify for the current knob.
<<knobs_function_declarations>>=
static void knobs_press(monolith_page *pg, int x, int y, int s);
<<knobs_functions>>=
static void knobs_press(monolith_page *pg, int x, int y, int s)
{
int lane, kx, ky;
page_knobs_d *knobs;
if (s == 0) return;
grid2knobs(x, y, &lane, &kx, &ky);
knobs = monolith_page_data_get(pg);
knobs_select(knobs, lane, kx, ky);
knobs_draw_lane(knobs, lane);
}
<<knobs_assign_callbacks>>=
monolith_page_press_set(pg, knobs_press);
6.6. Knobs Turn Callback
A wildcard knob. Can be set to control any of the 128 knob values.
<<knobs_function_declarations>>=
static void knobs_turn(monolith_page *pg, int s);
<<knobs_functions>>=
static void knobs_turn(monolith_page *pg, int s)
{
int aux_knob;
GFFLT val;
page_knobs_d *knobs;
int lane, sel;
int x, y;
knobs = monolith_page_data_get(pg);
aux_knob = knobs->aux_knob;
if (aux_knob < 0) return;
if (aux_knob >= 128) return;
val = knobs->vals[aux_knob];
val += s * knobs->inc * 3;
if (val < 0) val = 0;
if (val > 1) val = 1;
knobs->vals[aux_knob] = val;
x = aux_knob % 16;
y = aux_knob / 16;
lane = x / 4;
sel = y * 4 + (x % 4);
if (knobs->selected[lane] == sel) {
knobs_draw_lane(knobs, lane);
}
}
<<knobs_assign_callbacks>>=
monolith_page_turn_set(pg, knobs_turn);
6.7. Knobs Delta Callback
This is used to change the value of the currently selected knob.
<<knobs_function_declarations>>=
static void knobs_delta(monolith_page *pg, int n, int delta);
<<knobs_functions>>=
static void knobs_delta(monolith_page *pg, int n, int delta)
{
page_knobs_d *knobs;
knobs = monolith_page_data_get(pg);
knobs_increment(knobs, n, delta);
knobs_draw_lane(knobs, n);
}
<<knobs_assign_callbacks>>=
monolith_page_delta_set(pg, knobs_delta);
prev | home | next