Commit e223cd13 authored by Hanspeter Portner's avatar Hanspeter Portner

nk: put OSC arguments on separate rows.

parent 1ec862e8
Pipeline #22694350 passed with stages
in 5 minutes and 49 seconds
......@@ -84,7 +84,7 @@ _osc_timetag(mem_t *mem, LV2_OSC_Timetag *tt)
{
if(tt->integral <= 1UL)
{
_mem_printf(mem, "t:%s", "immediate");
_mem_printf(mem, "t : %s", "immediate");
}
else
{
......@@ -94,152 +94,170 @@ _osc_timetag(mem_t *mem, LV2_OSC_Timetag *tt)
char tmp [32];
if(strftime(tmp, 32, "%d-%b-%Y %T", ltime))
_mem_printf(mem, "t:%s.%06"PRIu32, tmp, us);
_mem_printf(mem, "t : %s.%06"PRIu32, tmp, us);
}
}
static void
_osc_message(plughandle_t *handle, struct nk_context *ctx, const LV2_Atom_Object *obj, float offset)
_osc_argument(plughandle_t *handle, struct nk_context *ctx, const LV2_Atom *arg,
const char *path, bool first)
{
const LV2_Atom_String *path = NULL;
const LV2_Atom_Tuple *args = NULL;
lv2_osc_message_get(&handle->osc_urid, obj, &path, &args);
const LV2_OSC_Type type = lv2_osc_argument_type(&handle->osc_urid, arg);
mem_t mem = {
.size = 1,
.buf = calloc(1, sizeof(char))
};
LV2_ATOM_TUPLE_FOREACH(args, arg)
switch(type)
{
const LV2_OSC_Type type = lv2_osc_argument_type(&handle->osc_urid, arg);
switch(type)
case LV2_OSC_INT32:
{
case LV2_OSC_INT32:
{
int32_t i;
lv2_osc_int32_get(&handle->osc_urid, arg, &i);
_mem_printf(&mem, "i:%"PRIi32, i);
} break;
case LV2_OSC_FLOAT:
{
float f;
lv2_osc_float_get(&handle->osc_urid, arg, &f);
_mem_printf(&mem, "f:%f", f);
} break;
case LV2_OSC_STRING:
{
const char *s;
lv2_osc_string_get(&handle->osc_urid, arg, &s);
_mem_printf(&mem, "s:%s", s);
} break;
case LV2_OSC_BLOB:
{
uint32_t sz;
const uint8_t *b;
lv2_osc_blob_get(&handle->osc_urid, arg, &sz, &b);
_mem_printf(&mem, "b(%"PRIu32"):", sz);
for(unsigned i=0; i<sz; i++)
_mem_printf(&mem, "%02"PRIx8, b[i]);
} break;
case LV2_OSC_TRUE:
{
_mem_printf(&mem, "T:rue");
} break;
case LV2_OSC_FALSE:
{
_mem_printf(&mem, "F:alse");
} break;
case LV2_OSC_NIL:
{
_mem_printf(&mem, "N:il");
} break;
case LV2_OSC_IMPULSE:
{
_mem_printf(&mem, "I:impulse");
} break;
int32_t i;
lv2_osc_int32_get(&handle->osc_urid, arg, &i);
_mem_printf(&mem, "i : %"PRIi32, i);
} break;
case LV2_OSC_FLOAT:
{
float f;
lv2_osc_float_get(&handle->osc_urid, arg, &f);
_mem_printf(&mem, "f : %f", f);
} break;
case LV2_OSC_STRING:
{
const char *s;
lv2_osc_string_get(&handle->osc_urid, arg, &s);
_mem_printf(&mem, "s : %s", s);
} break;
case LV2_OSC_BLOB:
{
uint32_t sz;
const uint8_t *b;
lv2_osc_blob_get(&handle->osc_urid, arg, &sz, &b);
_mem_printf(&mem, "b : (%"PRIu32") ", sz);
for(unsigned i=0; i<sz; i++)
_mem_printf(&mem, "%02"PRIx8, b[i]);
} break;
case LV2_OSC_TRUE:
{
_mem_printf(&mem, "T : true");
} break;
case LV2_OSC_FALSE:
{
_mem_printf(&mem, "F : false");
} break;
case LV2_OSC_NIL:
{
_mem_printf(&mem, "N : nil");
} break;
case LV2_OSC_IMPULSE:
{
_mem_printf(&mem, "I : iimpulse");
} break;
case LV2_OSC_INT64:
{
int64_t h;
lv2_osc_int64_get(&handle->osc_urid, arg, &h);
_mem_printf(&mem, "h:%"PRIi64, h);
} break;
case LV2_OSC_DOUBLE:
{
double d;
lv2_osc_double_get(&handle->osc_urid, arg, &d);
_mem_printf(&mem, "d:%lf", d);
} break;
case LV2_OSC_TIMETAG:
{
LV2_OSC_Timetag tt;
lv2_osc_timetag_get(&handle->osc_urid, arg, &tt);
_osc_timetag(&mem, &tt);
} break;
case LV2_OSC_INT64:
{
int64_t h;
lv2_osc_int64_get(&handle->osc_urid, arg, &h);
_mem_printf(&mem, "h : %"PRIi64, h);
} break;
case LV2_OSC_DOUBLE:
{
double d;
lv2_osc_double_get(&handle->osc_urid, arg, &d);
_mem_printf(&mem, "d : %lf", d);
} break;
case LV2_OSC_TIMETAG:
{
LV2_OSC_Timetag tt;
lv2_osc_timetag_get(&handle->osc_urid, arg, &tt);
_osc_timetag(&mem, &tt);
} break;
case LV2_OSC_SYMBOL:
{
LV2_URID S;
lv2_osc_symbol_get(&handle->osc_urid, arg, &S);
_mem_printf(&mem, "S:%s", handle->unmap->unmap(handle->unmap->handle, S));
} break;
case LV2_OSC_CHAR:
{
char c;
lv2_osc_char_get(&handle->osc_urid, arg, &c);
_mem_printf(&mem, "c:%c", c);
} break;
case LV2_OSC_RGBA:
{
uint8_t r [4];
lv2_osc_rgba_get(&handle->osc_urid, arg, r+0, r+1, r+2, r+3);
_mem_printf(&mem, "r:");
for(unsigned i=0; i<4; i++)
_mem_printf(&mem, "%02"PRIx8, r[i]);
} break;
case LV2_OSC_MIDI:
{
uint32_t sz;
const uint8_t *m;
lv2_osc_midi_get(&handle->osc_urid, arg, &sz, &m);
_mem_printf(&mem, "m(%"PRIu32"):", sz);
for(unsigned i=0; i<sz; i++)
_mem_printf(&mem, "%02"PRIx8, m[i]);
} break;
}
case LV2_OSC_SYMBOL:
{
LV2_URID S;
lv2_osc_symbol_get(&handle->osc_urid, arg, &S);
_mem_printf(&mem, "S : %s", handle->unmap->unmap(handle->unmap->handle, S));
} break;
case LV2_OSC_CHAR:
{
char c;
lv2_osc_char_get(&handle->osc_urid, arg, &c);
_mem_printf(&mem, "c : %c", c);
} break;
case LV2_OSC_RGBA:
{
uint8_t r [4];
lv2_osc_rgba_get(&handle->osc_urid, arg, r+0, r+1, r+2, r+3);
_mem_printf(&mem, "r : ");
for(unsigned i=0; i<4; i++)
_mem_printf(&mem, "%02"PRIx8, r[i]);
} break;
case LV2_OSC_MIDI:
{
uint32_t sz;
const uint8_t *m;
lv2_osc_midi_get(&handle->osc_urid, arg, &sz, &m);
_mem_printf(&mem, "m : (%"PRIu32") ", sz);
for(unsigned i=0; i<sz; i++)
_mem_printf(&mem, "%02"PRIx8, m[i]);
} break;
}
_mem_printf(&mem, " ");
if(!first)
{
_shadow(ctx, &handle->shadow);
_empty(ctx);
}
nk_layout_row_push(ctx, 0.4 - offset);
nk_label_colored(ctx, LV2_ATOM_BODY_CONST(path), NK_TEXT_LEFT, magenta);
if(first)
{
nk_label_colored(ctx, path, NK_TEXT_LEFT, magenta);
}
else
{
_empty(ctx);
}
nk_layout_row_push(ctx, 0.5);
if(mem.buf)
{
nk_label_colored(ctx, mem.buf, NK_TEXT_LEFT, cwhite);
free(mem.buf);
}
else
{
_empty(ctx);
}
nk_layout_row_push(ctx, 0.1);
nk_labelf_colored(ctx, NK_TEXT_RIGHT, blue, "%"PRIu32, obj->atom.size);
nk_labelf_colored(ctx, NK_TEXT_RIGHT, blue, "%"PRIu32, arg->size);
}
static void
_osc_message(plughandle_t *handle, struct nk_context *ctx, const LV2_Atom_Object *obj)
{
const LV2_Atom_String *path = NULL;
const LV2_Atom_Tuple *args = NULL;
lv2_osc_message_get(&handle->osc_urid, obj, &path, &args);
nk_layout_row_end(ctx);
bool first = true;
LV2_ATOM_TUPLE_FOREACH(args, arg)
{
_osc_argument(handle, ctx, arg, LV2_ATOM_BODY_CONST(path), first);
if(first)
first = false;
}
}
static void
_osc_packet(plughandle_t *handle, struct nk_context *ctx, const LV2_Atom_Object *obj, float offset);
_osc_packet(plughandle_t *handle, struct nk_context *ctx, int64_t frames,
const LV2_Atom_Object *obj, float offset);
static void
_osc_bundle(plughandle_t *handle, struct nk_context *ctx, const LV2_Atom_Object *obj, float offset)
{
const float widget_h = handle->dy;
const LV2_Atom_Object *timetag = NULL;
const LV2_Atom_Tuple *items = NULL;
lv2_osc_bundle_get(&handle->osc_urid, obj, &timetag, &items);
......@@ -253,10 +271,8 @@ _osc_bundle(plughandle_t *handle, struct nk_context *ctx, const LV2_Atom_Object
.buf = calloc(1, sizeof(char))
};
nk_layout_row_push(ctx, 0.4 - offset);
nk_label_colored(ctx, "#bundle", NK_TEXT_LEFT, red);
nk_layout_row_push(ctx, 0.5);
_osc_timetag(&mem, &tt);
if(mem.buf)
{
......@@ -264,32 +280,40 @@ _osc_bundle(plughandle_t *handle, struct nk_context *ctx, const LV2_Atom_Object
free(mem.buf);
}
else
{
_empty(ctx);
}
nk_layout_row_push(ctx, 0.1);
nk_labelf_colored(ctx, NK_TEXT_RIGHT, blue, "%"PRIu32, obj->atom.size);
nk_layout_row_end(ctx);
offset += 0.025;
LV2_ATOM_TUPLE_FOREACH(items, item)
{
nk_layout_row_begin(ctx, NK_DYNAMIC, widget_h, 4);
nk_layout_row_push(ctx, offset);
_shadow(ctx, &handle->shadow);
_empty(ctx);
_osc_packet(handle, ctx, (const LV2_Atom_Object *)item, offset);
_osc_packet(handle, ctx, -1, (const LV2_Atom_Object *)item, offset + 0.025);
}
}
static void
_osc_packet(plughandle_t *handle, struct nk_context *ctx, const LV2_Atom_Object *obj, float offset)
_osc_packet(plughandle_t *handle, struct nk_context *ctx, int64_t frames,
const LV2_Atom_Object *obj, float offset)
{
const float widget_h = handle->dy;
const float ratios [4] = {offset, 0.3f - offset, 0.6f, 0.1f};
nk_layout_row(ctx, NK_DYNAMIC, widget_h, 4, ratios);
_shadow(ctx, &handle->shadow);
if(frames > 0)
{
nk_labelf_colored(ctx, NK_TEXT_LEFT, yellow, "+%04"PRIi64, frames);
}
else
{
_empty(ctx);
}
if(lv2_osc_is_message_type(&handle->osc_urid, obj->body.otype))
{
_osc_message(handle, ctx, obj, offset);
_osc_message(handle, ctx, obj);
}
else if(lv2_osc_is_bundle_type(&handle->osc_urid, obj->body.otype))
{
......@@ -361,15 +385,9 @@ _osc_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *data
LV2_Atom_Event *ev = &itm->event.ev;
const LV2_Atom_Object *obj = (const LV2_Atom_Object *)&ev->body;
const int64_t frames = ev->time.frames;
const float off = 0.1;
nk_layout_row_begin(ctx, NK_DYNAMIC, widget_h, 4);
nk_layout_row_push(ctx, off);
_shadow(ctx, &handle->shadow);
nk_labelf_colored(ctx, NK_TEXT_LEFT, yellow, "+%04"PRIi64, frames);
const float offset = 0.1;
_osc_packet(handle, ctx, obj, off);
_osc_packet(handle, ctx, frames, obj, offset);
} break;
}
}
......
......@@ -404,12 +404,26 @@ cleanup(LV2UI_Handle instance)
static void
_osc_bundle(plughandle_t *handle, const LV2_Atom_Object *obj);
static void
_osc_message(plughandle_t *handle, const LV2_Atom_Object *obj)
{
const LV2_Atom_String *path = NULL;
const LV2_Atom_Tuple *args = NULL;
lv2_osc_message_get(&handle->osc_urid, obj, &path, &args);
LV2_ATOM_TUPLE_FOREACH(args, arg)
{
_append_item(handle, ITEM_TYPE_NONE, 0);
}
}
static void
_osc_packet(plughandle_t *handle, const LV2_Atom_Object *obj)
{
if(lv2_osc_is_message_type(&handle->osc_urid, obj->body.otype))
{
_append_item(handle, ITEM_TYPE_NONE, 0);
//_append_item(handle, ITEM_TYPE_NONE, 0);
_osc_message(handle, obj);
}
else if(lv2_osc_is_bundle_type(&handle->osc_urid, obj->body.otype))
{
......@@ -549,6 +563,10 @@ port_event(LV2UI_Handle instance, uint32_t i, uint32_t size, uint32_t urid,
{
_osc_bundle(handle, obj);
}
else
{
_osc_message(handle, obj);
}
} break;
case SHERLOCK_MIDI_INSPECTOR:
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment