aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2018-05-13 13:05:33 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2018-05-13 13:05:33 +0200
commit530cf64f75ca01f0a70b592c4fa4e40bba4965a6 (patch)
tree1c4a53ea095b95ef63e7f19911cc5195453a66c2
parent70f3794ad7a79e3764c5d90ec1eddc372a76a7c4 (diff)
downloadsherlock.lv2-530cf64f75ca01f0a70b592c4fa4e40bba4965a6.tar.xz
atom_inspector: prototype filtering by URID.
-rw-r--r--VERSION2
-rw-r--r--atom_inspector.c8
-rw-r--r--atom_inspector_nk.c62
-rw-r--r--midi_inspector_nk.c6
-rw-r--r--osc_inspector_nk.c6
-rw-r--r--sherlock.h18
-rw-r--r--sherlock.ttl26
-rw-r--r--sherlock_nk.c47
-rw-r--r--sherlock_nk.h12
9 files changed, 138 insertions, 49 deletions
diff --git a/VERSION b/VERSION
index 9af4766..74fb453 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.17.129
+0.17.131
diff --git a/atom_inspector.c b/atom_inspector.c
index 8742d7c..227e398 100644
--- a/atom_inspector.c
+++ b/atom_inspector.c
@@ -241,10 +241,12 @@ run(LV2_Handle instance, uint32_t nsamples)
{
const LV2_Atom_Object *obj = (const LV2_Atom_Object *)&ev->body;
- const bool is_time = lv2_atom_forge_is_object_type(&notify->forge, obj->atom.type)
- && (obj->body.otype == handle->time_position);
+ const bool type_matches = lv2_atom_forge_is_object_type(&notify->forge, obj->atom.type)
+ ? (obj->body.otype == handle->state.filter)
+ : (obj->atom.type == handle->state.filter);
- if(!(!handle->state.time && is_time))
+ if( (!handle->state.negate && type_matches)
+ || (handle->state.negate && !type_matches) )
{
has_event = true;
if(notify->ref)
diff --git a/atom_inspector_nk.c b/atom_inspector_nk.c
index 18c578d..3c7c466 100644
--- a/atom_inspector_nk.c
+++ b/atom_inspector_nk.c
@@ -135,7 +135,45 @@ _atom_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *dat
nk_layout_row_dynamic(ctx, body_h, 2);
if(nk_group_begin(ctx, "Left", NK_WINDOW_NO_SCROLLBAR))
{
- const float content_h = nk_window_get_height(ctx) - 2*window_padding.y - 4*group_padding.y - 2*widget_h;
+ {
+ // has filter URID been updated meanwhile ?
+ if(handle->filter != handle->state.filter)
+ {
+ const char *uri = handle->unmap->unmap(handle->unmap->handle, handle->state.filter);
+
+ if(uri)
+ {
+ strncpy(handle->filter_uri, uri, sizeof(handle->filter_uri) - 1);
+ }
+ else
+ {
+ handle->filter_uri[0] = '\0';
+ }
+
+ handle->filter = handle->state.filter;
+ }
+
+ nk_layout_row_dynamic(ctx, widget_h, 1);
+ const nk_flags flags = NK_EDIT_FIELD
+ | NK_EDIT_AUTO_SELECT
+ | NK_EDIT_SIG_ENTER;
+ //nk_edit_focus(ctx, flags);
+ nk_flags mode = nk_edit_string_zero_terminated(ctx, flags, handle->filter_uri, sizeof(handle->filter_uri) - 1, nk_filter_ascii);
+ if(mode & NK_EDIT_COMMITED)
+ {
+ if(strlen(handle->filter_uri) == 0)
+ {
+ strncpy(handle->filter_uri, LV2_TIME__Position, sizeof(handle->filter_uri) - 1);
+ }
+
+ handle->state.filter = handle->map->map(handle->map->handle, handle->filter_uri);
+
+ fprintf(stderr, "%s: %u\n", __func__, handle->state.filter);
+ _set_urid(handle, handle->urid.filter, handle->state.filter);
+ }
+ }
+
+ const float content_h = nk_window_get_height(ctx) - 2*window_padding.y - 5*group_padding.y - 3*widget_h;
nk_layout_row_dynamic(ctx, content_h, 1);
nk_flags flags = NK_WINDOW_BORDER;
if(handle->state.follow)
@@ -290,7 +328,7 @@ _atom_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *dat
if(state_overwrite != handle->state.overwrite)
{
handle->state.overwrite = state_overwrite;
- _toggle(handle, handle->urid.overwrite, handle->state.overwrite, true);
+ _set_bool(handle, handle->urid.overwrite, handle->state.overwrite);
}
nk_label(ctx, "overwrite", NK_TEXT_LEFT);
@@ -298,7 +336,7 @@ _atom_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *dat
if(state_block != handle->state.block)
{
handle->state.block = state_block;
- _toggle(handle, handle->urid.block, handle->state.block, true);
+ _set_bool(handle, handle->urid.block, handle->state.block);
}
nk_label(ctx, "block", NK_TEXT_LEFT);
@@ -306,7 +344,7 @@ _atom_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *dat
if(state_follow != handle->state.follow)
{
handle->state.follow = state_follow;
- _toggle(handle, handle->urid.follow, handle->state.follow, true);
+ _set_bool(handle, handle->urid.follow, handle->state.follow);
}
nk_label(ctx, "follow", NK_TEXT_LEFT);
@@ -314,19 +352,19 @@ _atom_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *dat
if(state_pretty != handle->state.pretty)
{
handle->state.pretty = state_pretty;
- _toggle(handle, handle->urid.pretty, handle->state.pretty, true);
+ _set_bool(handle, handle->urid.pretty, handle->state.pretty);
handle->ttl_dirty = true;
}
nk_label(ctx, "pretty", NK_TEXT_LEFT);
- const int32_t state_time = _check(ctx, handle->state.time);
- if(state_time != handle->state.time)
+ const int32_t state_negate = _check(ctx, handle->state.negate);
+ if(state_negate != handle->state.negate)
{
- handle->state.time = state_time;
- _toggle(handle, handle->urid.time, handle->state.time, true);
+ handle->state.negate = state_negate;
+ _set_bool(handle, handle->urid.negate, handle->state.negate);
}
- nk_label(ctx, "time", NK_TEXT_LEFT);
+ nk_label(ctx, "negate", NK_TEXT_LEFT);
}
const bool max_reached = handle->n_item >= MAX_LINES;
@@ -367,14 +405,14 @@ _atom_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *dat
handle->ttl_dirty = false;
}
- const nk_flags flags = NK_EDIT_EDITOR;
+ const nk_flags flags = NK_EDIT_EDITOR
+ | NK_EDIT_READ_ONLY;
int len = nk_str_len(&handle->editor.string);
if(len > 0) //FIXME
{
const float content_h = nk_window_get_height(ctx) - 2*window_padding.y - 2*group_padding.y;
nk_layout_row_dynamic(ctx, content_h, 1);
- nk_edit_focus(ctx, flags);
const nk_flags mode = nk_edit_buffer(ctx, flags, &handle->editor, nk_filter_default);
(void)mode;
}
diff --git a/midi_inspector_nk.c b/midi_inspector_nk.c
index eb00907..deb06dd 100644
--- a/midi_inspector_nk.c
+++ b/midi_inspector_nk.c
@@ -494,7 +494,7 @@ _midi_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *dat
if(state_overwrite != handle->state.overwrite)
{
handle->state.overwrite = state_overwrite;
- _toggle(handle, handle->urid.overwrite, handle->state.overwrite, true);
+ _set_bool(handle, handle->urid.overwrite, handle->state.overwrite);
}
nk_label(ctx, "overwrite", NK_TEXT_LEFT);
@@ -502,7 +502,7 @@ _midi_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *dat
if(state_block != handle->state.block)
{
handle->state.block = state_block;
- _toggle(handle, handle->urid.block, handle->state.block, true);
+ _set_bool(handle, handle->urid.block, handle->state.block);
}
nk_label(ctx, "block", NK_TEXT_LEFT);
@@ -510,7 +510,7 @@ _midi_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *dat
if(state_follow != handle->state.follow)
{
handle->state.follow = state_follow;
- _toggle(handle, handle->urid.follow, handle->state.follow, true);
+ _set_bool(handle, handle->urid.follow, handle->state.follow);
}
nk_label(ctx, "follow", NK_TEXT_LEFT);
}
diff --git a/osc_inspector_nk.c b/osc_inspector_nk.c
index e819776..30947f9 100644
--- a/osc_inspector_nk.c
+++ b/osc_inspector_nk.c
@@ -385,7 +385,7 @@ _osc_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *data
if(state_overwrite != handle->state.overwrite)
{
handle->state.overwrite = state_overwrite;
- _toggle(handle, handle->urid.overwrite, handle->state.overwrite, true);
+ _set_bool(handle, handle->urid.overwrite, handle->state.overwrite);
}
nk_label(ctx, "overwrite", NK_TEXT_LEFT);
@@ -393,7 +393,7 @@ _osc_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *data
if(state_block != handle->state.block)
{
handle->state.block = state_block;
- _toggle(handle, handle->urid.block, handle->state.block, true);
+ _set_bool(handle, handle->urid.block, handle->state.block);
}
nk_label(ctx, "block", NK_TEXT_LEFT);
@@ -401,7 +401,7 @@ _osc_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *data
if(state_follow != handle->state.follow)
{
handle->state.follow = state_follow;
- _toggle(handle, handle->urid.follow, handle->state.follow, true);
+ _set_bool(handle, handle->urid.follow, handle->state.follow);
}
nk_label(ctx, "follow", NK_TEXT_LEFT);
}
diff --git a/sherlock.h b/sherlock.h
index f2a0ffe..6a90c4b 100644
--- a/sherlock.h
+++ b/sherlock.h
@@ -66,8 +66,9 @@ struct _state_t {
int32_t block;
int32_t follow;
int32_t pretty;
- int32_t time;
int32_t trace;
+ uint32_t filter;
+ int32_t negate;
};
struct _craft_t {
@@ -80,7 +81,7 @@ struct _craft_t {
};
};
-#define MAX_NPROPS 6
+#define MAX_NPROPS 7
static const props_def_t defs [MAX_NPROPS] = {
{
@@ -104,13 +105,18 @@ static const props_def_t defs [MAX_NPROPS] = {
.type = LV2_ATOM__Bool,
},
{
- .property = SHERLOCK_URI"#time",
- .offset = offsetof(state_t, time),
+ .property = SHERLOCK_URI"#trace",
+ .offset = offsetof(state_t, trace),
.type = LV2_ATOM__Bool,
},
{
- .property = SHERLOCK_URI"#trace",
- .offset = offsetof(state_t, trace),
+ .property = SHERLOCK_URI"#filter",
+ .offset = offsetof(state_t, filter),
+ .type = LV2_ATOM__URID,
+ },
+ {
+ .property = SHERLOCK_URI"#negate",
+ .offset = offsetof(state_t, negate),
.type = LV2_ATOM__Bool,
}
};
diff --git a/sherlock.ttl b/sherlock.ttl
index c8dab15..e990a9b 100644
--- a/sherlock.ttl
+++ b/sherlock.ttl
@@ -80,18 +80,24 @@ sherlock:pretty
rdfs:comment "Toggle whether to pretty print or not" ;
rdfs:range atom:Bool .
-sherlock:time
- a lv2:Parameter ;
- rdfs:label "Time" ;
- rdfs:comment "Toggle whether to show time events or not" ;
- rdfs:range atom:Bool .
-
sherlock:trace
a lv2:Parameter ;
rdfs:label "Trace" ;
rdfs:comment "Toggle whether to show trace output on console" ;
rdfs:range atom:Bool .
+sherlock:filter
+ a lv2:Parameter ;
+ rdfs:label "Filter" ;
+ rdfs:comment "Filter events according to type or object type" ;
+ rdfs:range atom:URID .
+
+sherlock:negate
+ a lv2:Parameter ;
+ rdfs:label "Negate" ;
+ rdfs:comment "Toggle negation of filter" ;
+ rdfs:range atom:Bool .
+
# Atom Inspector Plugin
sherlock:atom_inspector
a lv2:Plugin,
@@ -148,16 +154,18 @@ sherlock:atom_inspector
sherlock:block ,
sherlock:follow ,
sherlock:pretty ,
- sherlock:time ,
- sherlock:trace ;
+ sherlock:trace ,
+ sherlock:filter,
+ sherlock:negate ;
state:state [
sherlock:overwrite true ;
sherlock:block false ;
sherlock:follow true ;
sherlock:pretty true ;
- sherlock:time false ;
sherlock:trace false ;
+ sherlock:filter time:Position ;
+ sherlock:negate false ;
] .
# MIDI Inspector Plugin
diff --git a/sherlock_nk.c b/sherlock_nk.c
index e15a894..13ccabd 100644
--- a/sherlock_nk.c
+++ b/sherlock_nk.c
@@ -53,7 +53,7 @@ _discover(plughandle_t *handle)
}
void
-_toggle(plughandle_t *handle, LV2_URID property, int32_t val, bool is_bool)
+_set_bool(plughandle_t *handle, LV2_URID property, int32_t val)
{
ser_atom_t ser;
@@ -67,10 +67,33 @@ _toggle(plughandle_t *handle, LV2_URID property, int32_t val, bool is_bool)
lv2_atom_forge_urid(&handle->forge, property);
lv2_atom_forge_key(&handle->forge, handle->props.urid.patch_value);
- if(is_bool)
- lv2_atom_forge_bool(&handle->forge, val);
- else
- lv2_atom_forge_int(&handle->forge, val);
+ lv2_atom_forge_bool(&handle->forge, val);
+
+ lv2_atom_forge_pop(&handle->forge, &frame);
+
+ handle->write_function(handle->controller, 0, lv2_atom_total_size(ser_atom_get(&ser)),
+ handle->event_transfer, ser_atom_get(&ser));
+
+ ser_atom_deinit(&ser);
+ }
+}
+
+void
+_set_urid(plughandle_t *handle, LV2_URID property, uint32_t val)
+{
+ ser_atom_t ser;
+
+ if(ser_atom_init(&ser) == 0)
+ {
+ LV2_Atom_Forge_Frame frame;
+
+ ser_atom_reset(&ser, &handle->forge);
+ lv2_atom_forge_object(&handle->forge, &frame, 0, handle->props.urid.patch_set);
+ lv2_atom_forge_key(&handle->forge, handle->props.urid.patch_property);
+ lv2_atom_forge_urid(&handle->forge, property);
+
+ lv2_atom_forge_key(&handle->forge, handle->props.urid.patch_value);
+ lv2_atom_forge_urid(&handle->forge, val);
lv2_atom_forge_pop(&handle->forge, &frame);
@@ -300,11 +323,13 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
return NULL;
}
- handle->urid.overwrite = props_map(&handle->props, defs[0].property);;
- handle->urid.block = props_map(&handle->props, defs[1].property);;
- handle->urid.follow = props_map(&handle->props, defs[2].property);;
- handle->urid.pretty = props_map(&handle->props, defs[3].property);;
- handle->urid.time = props_map(&handle->props, defs[4].property);;
+ handle->urid.overwrite = props_map(&handle->props, SHERLOCK_URI"#overwrite");
+ handle->urid.block = props_map(&handle->props, SHERLOCK_URI"#block");
+ handle->urid.follow = props_map(&handle->props, SHERLOCK_URI"#follow");
+ handle->urid.pretty = props_map(&handle->props, SHERLOCK_URI"#pretty");
+ handle->urid.trace = props_map(&handle->props, SHERLOCK_URI"#trace");
+ handle->urid.filter = props_map(&handle->props, SHERLOCK_URI"#filter");
+ handle->urid.negate = props_map(&handle->props, SHERLOCK_URI"#negate");
nk_pugl_config_t *cfg = &handle->win.cfg;
cfg->height = 700;
@@ -434,7 +459,9 @@ port_event(LV2UI_Handle instance, uint32_t i, uint32_t size, uint32_t urid,
LV2_Atom_Forge_Ref ref = lv2_atom_forge_sequence_head(&handle->forge, &frame, 0);
if(props_advance(&handle->props, &handle->forge, 0, buf, &ref))
+ {
nk_pugl_post_redisplay(&handle->win);
+ }
lv2_atom_forge_pop(&handle->forge, &frame);
diff --git a/sherlock_nk.h b/sherlock_nk.h
index 8a9cf09..dc2f1a9 100644
--- a/sherlock_nk.h
+++ b/sherlock_nk.h
@@ -77,7 +77,9 @@ struct _plughandle_t {
LV2_URID block;
LV2_URID follow;
LV2_URID pretty;
- LV2_URID time;
+ LV2_URID trace;
+ LV2_URID filter;
+ LV2_URID negate;
} urid;
state_t state;
state_t stash;
@@ -99,6 +101,9 @@ struct _plughandle_t {
bool shadow;
plugin_type_t type;
+
+ char filter_uri [1024];
+ LV2_URID filter;
};
extern const char *max_items [5];
@@ -117,7 +122,10 @@ void
_empty(struct nk_context *ctx);
void
-_toggle(plughandle_t *handle, LV2_URID property, int32_t val, bool is_bool);
+_set_bool(plughandle_t *handle, LV2_URID property, int32_t val);
+
+void
+_set_urid(plughandle_t *handle, LV2_URID property, uint32_t val);
void
_clear(plughandle_t *handle);