1 /* 2 * Copyright (c) 2015-2021 Hanspeter Portner (dev@open-music-kontrollers.ch) 3 * 4 * This is free software: you can redistribute it and/or modify 5 * it under the terms of the Artistic License 2.0 as published by 6 * The Perl Foundation. 7 * 8 * This source is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * Artistic License 2.0 for more details. 12 * 13 * You should have received a copy of the Artistic License 2.0 14 * along the source as a COPYING file. If not, obtain it from 15 * http://www.perlfoundation.org/artistic_license_2_0. 16 */ 17 18 #ifndef _SHERLOCK_NK_H 19 #define _SHERLOCK_NK_H 20 21 #define NK_PUGL_API 22 #include "nk_pugl/nk_pugl.h" 23 24 #include <osc.lv2/osc.h> 25 #include <sratom/sratom.h> 26 27 #define MAX_LINES 2048 28 29 typedef struct _item_t item_t; 30 typedef struct _plughandle_t plughandle_t; 31 32 typedef enum _item_type_t { 33 ITEM_TYPE_NONE, 34 ITEM_TYPE_FRAME, 35 ITEM_TYPE_EVENT 36 } item_type_t; 37 38 struct _item_t { 39 item_type_t type; 40 41 union { 42 struct { 43 int64_t offset; 44 uint32_t counter; 45 int32_t nsamples; 46 } frame; 47 48 struct { 49 LV2_Atom_Event ev; 50 uint8_t body [0]; 51 } event; 52 }; 53 }; 54 55 typedef enum _plugin_type_t { 56 SHERLOCK_ATOM_INSPECTOR, 57 SHERLOCK_MIDI_INSPECTOR, 58 SHERLOCK_OSC_INSPECTOR 59 } plugin_type_t; 60 61 struct _plughandle_t { 62 LV2UI_Write_Function write_function; 63 LV2UI_Controller controller; 64 65 LV2_URID_Map *map; 66 LV2_URID_Unmap *unmap; 67 LV2_Atom_Forge forge; 68 LV2_Atom_Forge_Frame frame; 69 LV2_URID event_transfer; 70 LV2_OSC_URID osc_urid; 71 72 float scale; 73 74 PROPS_T(props, MAX_NPROPS); 75 struct { 76 LV2_URID overwrite; 77 LV2_URID block; 78 LV2_URID follow; 79 LV2_URID pretty; 80 LV2_URID trace; 81 LV2_URID filter; 82 LV2_URID negate; 83 } urid; 84 state_t state; 85 state_t stash; 86 87 nk_pugl_window_t win; 88 89 bool ttl_dirty; 90 const LV2_Atom *selected; 91 struct nk_text_edit editor; 92 93 Sratom *sratom; 94 const char *base_uri; 95 96 float dy; 97 98 uint32_t counter; 99 int n_item; 100 item_t **items; 101 102 bool shadow; 103 plugin_type_t type; 104 105 char filter_uri [1024]; 106 LV2_URID filter; 107 }; 108 109 extern const char *max_items [5]; 110 extern const int32_t max_values [5]; 111 112 void 113 _midi_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *data); 114 115 void 116 _atom_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *data); 117 118 void 119 _osc_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *data); 120 121 void 122 _empty(struct nk_context *ctx); 123 124 void 125 _set_bool(plughandle_t *handle, LV2_URID property, int32_t val); 126 127 void 128 _set_urid(plughandle_t *handle, LV2_URID property, uint32_t val); 129 130 void 131 _clear(plughandle_t *handle); 132 133 void 134 _ruler(struct nk_context *ctx, float line_thickness, struct nk_color color); 135 136 void 137 _post_redisplay(plughandle_t *handle); 138 139 float 140 _get_scale(plughandle_t *handle); 141 142 int32_t 143 _check(struct nk_context *ctx, int32_t state); 144 145 #endif // _SHERLOCK_NK_H 146