midi_inspector_nk.c 16.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Copyright (c) 2015-2016 Hanspeter Portner (dev@open-music-kontrollers.ch)
 *
 * This is free software: you can redistribute it and/or modify
 * it under the terms of the Artistic License 2.0 as published by
 * The Perl Foundation.
 *
 * This source is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * Artistic License 2.0 for more details.
 *
 * You should have received a copy of the Artistic License 2.0
 * along the source as a COPYING file. If not, obtain it from
 * http://www.perlfoundation.org/artistic_license_2_0.
 */

18 19
#include <inttypes.h>

20 21
#include <sherlock.h>
#include <sherlock_nk.h>
22
#include <encoder.h>
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199

typedef struct _midi_msg_t midi_msg_t;

struct _midi_msg_t {
	uint8_t type;
	const char *key;
};

#define COMMANDS_NUM 18
static const midi_msg_t commands [COMMANDS_NUM] = {
	{ LV2_MIDI_MSG_NOTE_OFF							, "NoteOff" },
	{ LV2_MIDI_MSG_NOTE_ON							, "NoteOn" },
	{ LV2_MIDI_MSG_NOTE_PRESSURE				, "NotePressure" },
	{ LV2_MIDI_MSG_CONTROLLER						, "Controller" },
	{ LV2_MIDI_MSG_PGM_CHANGE						, "ProgramChange" },
	{ LV2_MIDI_MSG_CHANNEL_PRESSURE			, "ChannelPressure" },
	{ LV2_MIDI_MSG_BENDER								, "Bender" },
	{ LV2_MIDI_MSG_SYSTEM_EXCLUSIVE			, "SystemExclusive" },
	{ LV2_MIDI_MSG_MTC_QUARTER					, "QuarterFrame" },
	{ LV2_MIDI_MSG_SONG_POS							, "SongPosition" },
	{ LV2_MIDI_MSG_SONG_SELECT					, "SongSelect" },
	{ LV2_MIDI_MSG_TUNE_REQUEST					, "TuneRequest" },
	{ LV2_MIDI_MSG_CLOCK								, "Clock" },
	{ LV2_MIDI_MSG_START								, "Start" },
	{ LV2_MIDI_MSG_CONTINUE							, "Continue" },
	{ LV2_MIDI_MSG_STOP									, "Stop" },
	{ LV2_MIDI_MSG_ACTIVE_SENSE					, "ActiveSense" },
	{ LV2_MIDI_MSG_RESET								, "Reset" },
};

#define CONTROLLERS_NUM 72
static const midi_msg_t controllers [CONTROLLERS_NUM] = {
	{ LV2_MIDI_CTL_MSB_BANK             , "BankSelection_MSB" },
	{ LV2_MIDI_CTL_MSB_MODWHEEL         , "Modulation_MSB" },
	{ LV2_MIDI_CTL_MSB_BREATH           , "Breath_MSB" },
	{ LV2_MIDI_CTL_MSB_FOOT             , "Foot_MSB" },
	{ LV2_MIDI_CTL_MSB_PORTAMENTO_TIME  , "PortamentoTime_MSB" },
	{ LV2_MIDI_CTL_MSB_DATA_ENTRY       , "DataEntry_MSB" },
	{ LV2_MIDI_CTL_MSB_MAIN_VOLUME      , "MainVolume_MSB" },
	{ LV2_MIDI_CTL_MSB_BALANCE          , "Balance_MSB" },
	{ LV2_MIDI_CTL_MSB_PAN              , "Panpot_MSB" },
	{ LV2_MIDI_CTL_MSB_EXPRESSION       , "Expression_MSB" },
	{ LV2_MIDI_CTL_MSB_EFFECT1          , "Effect1_MSB" },
	{ LV2_MIDI_CTL_MSB_EFFECT2          , "Effect2_MSB" },
	{ LV2_MIDI_CTL_MSB_GENERAL_PURPOSE1 , "GeneralPurpose1_MSB" },
	{ LV2_MIDI_CTL_MSB_GENERAL_PURPOSE2 , "GeneralPurpose2_MSB" },
	{ LV2_MIDI_CTL_MSB_GENERAL_PURPOSE3 , "GeneralPurpose3_MSB" },
	{ LV2_MIDI_CTL_MSB_GENERAL_PURPOSE4 , "GeneralPurpose4_MSB" },

	{ LV2_MIDI_CTL_LSB_BANK             , "BankSelection_LSB" },
	{ LV2_MIDI_CTL_LSB_MODWHEEL         , "Modulation_LSB" },
	{ LV2_MIDI_CTL_LSB_BREATH           , "Breath_LSB" },
	{ LV2_MIDI_CTL_LSB_FOOT             , "Foot_LSB" },
	{ LV2_MIDI_CTL_LSB_PORTAMENTO_TIME  , "PortamentoTime_LSB" },
	{ LV2_MIDI_CTL_LSB_DATA_ENTRY       , "DataEntry_LSB" },
	{ LV2_MIDI_CTL_LSB_MAIN_VOLUME      , "MainVolume_LSB" },
	{ LV2_MIDI_CTL_LSB_BALANCE          , "Balance_LSB" },
	{ LV2_MIDI_CTL_LSB_PAN              , "Panpot_LSB" },
	{ LV2_MIDI_CTL_LSB_EXPRESSION       , "Expression_LSB" },
	{ LV2_MIDI_CTL_LSB_EFFECT1          , "Effect1_LSB" },
	{ LV2_MIDI_CTL_LSB_EFFECT2          , "Effect2_LSB" },
	{ LV2_MIDI_CTL_LSB_GENERAL_PURPOSE1 , "GeneralPurpose1_LSB" },
	{ LV2_MIDI_CTL_LSB_GENERAL_PURPOSE2 , "GeneralPurpose2_LSB" },
	{ LV2_MIDI_CTL_LSB_GENERAL_PURPOSE3 , "GeneralPurpose3_LSB" },
	{ LV2_MIDI_CTL_LSB_GENERAL_PURPOSE4 , "GeneralPurpose4_LSB" },

	{ LV2_MIDI_CTL_SUSTAIN              , "SustainPedal" },
	{ LV2_MIDI_CTL_PORTAMENTO           , "Portamento" },
	{ LV2_MIDI_CTL_SOSTENUTO            , "Sostenuto" },
	{ LV2_MIDI_CTL_SOFT_PEDAL           , "SoftPedal" },
	{ LV2_MIDI_CTL_LEGATO_FOOTSWITCH    , "LegatoFootSwitch" },
	{ LV2_MIDI_CTL_HOLD2                , "Hold2" },

	{ LV2_MIDI_CTL_SC1_SOUND_VARIATION  , "SC1_SoundVariation" },
	{ LV2_MIDI_CTL_SC2_TIMBRE           , "SC2_Timbre" },
	{ LV2_MIDI_CTL_SC3_RELEASE_TIME     , "SC3_ReleaseTime" },
	{ LV2_MIDI_CTL_SC4_ATTACK_TIME      , "SC4_AttackTime" },
	{ LV2_MIDI_CTL_SC5_BRIGHTNESS       , "SC5_Brightness" },
	{ LV2_MIDI_CTL_SC6                  , "SC6" },
	{ LV2_MIDI_CTL_SC7                  , "SC7" },
	{ LV2_MIDI_CTL_SC8                  , "SC8" },
	{ LV2_MIDI_CTL_SC9                  , "SC9" },
	{ LV2_MIDI_CTL_SC10                 , "SC10" },

	{ LV2_MIDI_CTL_GENERAL_PURPOSE5     , "GeneralPurpose5" },
	{ LV2_MIDI_CTL_GENERAL_PURPOSE6     , "GeneralPurpose6" },
	{ LV2_MIDI_CTL_GENERAL_PURPOSE7     , "GeneralPurpose7" },
	{ LV2_MIDI_CTL_GENERAL_PURPOSE8     , "GeneralPurpose8" },
	{ LV2_MIDI_CTL_PORTAMENTO_CONTROL   , "PortamentoControl" },

	{ LV2_MIDI_CTL_E1_REVERB_DEPTH      , "E1_ReverbDepth" },
	{ LV2_MIDI_CTL_E2_TREMOLO_DEPTH     , "E2_TremoloDepth" },
	{ LV2_MIDI_CTL_E3_CHORUS_DEPTH      , "E3_ChorusDepth" },
	{ LV2_MIDI_CTL_E4_DETUNE_DEPTH      , "E4_DetuneDepth" },
	{ LV2_MIDI_CTL_E5_PHASER_DEPTH      , "E5_PhaserDepth" },

	{ LV2_MIDI_CTL_DATA_INCREMENT       , "DataIncrement" },
	{ LV2_MIDI_CTL_DATA_DECREMENT       , "DataDecrement" },

	{ LV2_MIDI_CTL_NRPN_LSB             , "NRPN_LSB" },
	{ LV2_MIDI_CTL_NRPN_MSB             , "NRPN_MSB" },

	{ LV2_MIDI_CTL_RPN_LSB              , "RPN_LSB" },
	{ LV2_MIDI_CTL_RPN_MSB              , "RPN_MSB" },

	{ LV2_MIDI_CTL_ALL_SOUNDS_OFF       , "AllSoundsOff" },
	{ LV2_MIDI_CTL_RESET_CONTROLLERS    , "ResetControllers" },
	{ LV2_MIDI_CTL_LOCAL_CONTROL_SWITCH , "LocalControlSwitch" },
	{ LV2_MIDI_CTL_ALL_NOTES_OFF        , "AllNotesOff" },
	{ LV2_MIDI_CTL_OMNI_OFF             , "OmniOff" },
	{ LV2_MIDI_CTL_OMNI_ON              , "OmniOn" },
	{ LV2_MIDI_CTL_MONO1                , "Mono1" },
	{ LV2_MIDI_CTL_MONO2                , "Mono2" },
};

#define TIMECODES_NUM 8
static const midi_msg_t timecodes [TIMECODES_NUM] = {
	{ 0 , "FrameNumber_LSB" },
	{ 1 , "FrameNumber_MSB" },
	{ 2 , "Second_LSB" },
	{ 3 , "Second_MSB" },
	{ 4 , "Minute_LSB" },
	{ 5 , "Minute_MSB" },
	{ 6 , "Hour_LSB" },
	{ 7 , "RateAndHour_MSB" },
};

static int
_cmp_search(const void *itm1, const void *itm2)
{
	const midi_msg_t *msg1 = itm1;
	const midi_msg_t *msg2 = itm2;

	if(msg1->type < msg2->type)
		return -1;
	else if(msg1->type > msg2->type)
		return 1;

	return 0;
}

static inline const midi_msg_t *
_search_command(uint8_t type)
{
	return bsearch(&type, commands, COMMANDS_NUM, sizeof(midi_msg_t), _cmp_search);
}

static inline const midi_msg_t *
_search_controller(uint8_t type)
{
	return bsearch(&type, controllers, CONTROLLERS_NUM, sizeof(midi_msg_t), _cmp_search);
}

static inline const midi_msg_t *
_search_timecode(uint8_t type)
{
	return bsearch(&type, timecodes, TIMECODES_NUM, sizeof(midi_msg_t), _cmp_search);
}

static const char *keys [12] = {
	"C", "C#",
	"D", "D#",
	"E",
	"F", "F#",
	"G", "G#",
	"A", "A#",
	"B"
};

static inline const char *
_note(uint8_t val, int8_t *octave)
{
	*octave = val / 12 - 1;

	return keys[val % 12];
}

200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
static inline void
_shadow(struct nk_context *ctx, bool *shadow)
{
	if(*shadow)
	{
		struct nk_style *style = &ctx->style;
		const struct nk_vec2 group_padding = style->window.group_padding;
		struct nk_command_buffer *canvas = nk_window_get_canvas(ctx);

		struct nk_rect b = nk_widget_bounds(ctx);
		b.x -= group_padding.x;
		b.w *= 10;
		b.w += 8*group_padding.x;
		nk_fill_rect(canvas, b, 0.f, nk_rgb(0x28, 0x28, 0x28));
	}

	*shadow = !*shadow;
}

219 220 221 222 223
void
_midi_inspector_expose(struct nk_context *ctx, struct nk_rect wbounds, void *data)
{
	plughandle_t *handle = data;

224
	handle->dy = 20.f * _get_scale(handle);
225
	const float widget_h = handle->dy;
Hanspeter Portner's avatar
Hanspeter Portner committed
226 227
	struct nk_style *style = &ctx->style;
  const struct nk_vec2 window_padding = style->window.padding;
228
  const struct nk_vec2 group_padding = style->window.group_padding;
229

230 231
	const char *window_name = "Sherlock";
	if(nk_begin(ctx, window_name, wbounds, NK_WINDOW_NO_SCROLLBAR))
232
	{
233 234
		struct nk_panel *panel = nk_window_get_panel(ctx);
		struct nk_command_buffer *canvas = nk_window_get_canvas(ctx);
235

Hanspeter Portner's avatar
Hanspeter Portner committed
236 237
		const float body_h = panel->bounds.h - 4*window_padding.y - 2*widget_h;
		nk_layout_row_dynamic(ctx, body_h, 1);
238 239 240 241 242
		nk_flags flags = NK_WINDOW_BORDER;
		if(handle->state.follow)
			flags |= NK_WINDOW_NO_SCROLLBAR;
		struct nk_list_view lview;
		if(nk_list_view_begin(ctx, &lview, "Events", flags, widget_h, NK_MIN(handle->n_item, MAX_LINES)))
243
		{
244
			if(handle->state.follow)
245
			{
246 247 248 249 250 251 252
				lview.end = NK_MAX(handle->n_item, 0);
				lview.begin = NK_MAX(lview.end - lview.count, 0);
			}
			handle->shadow = lview.begin % 2 == 0;
			for(int l = lview.begin; (l < lview.end) && (l < handle->n_item); l++)
			{
				item_t *itm = handle->items[l];
253

254
				switch(itm->type)
255
				{
256
					case ITEM_TYPE_NONE:
257
					{
258 259 260 261 262
						// skip, was sysex payload
					} break;
					case ITEM_TYPE_FRAME:
					{
						nk_layout_row_dynamic(ctx, widget_h, 3);
263
						{
264 265 266 267 268 269
							struct nk_rect b = nk_widget_bounds(ctx);
							b.x -= group_padding.x;
							b.w *= 3;
							b.w += 4*group_padding.x;
							nk_fill_rect(canvas, b, 0.f, nk_rgb(0x18, 0x18, 0x18));
						}
270

271 272 273 274
						nk_labelf_colored(ctx, NK_TEXT_LEFT, orange, "@%"PRIi64, itm->frame.offset);
						nk_labelf_colored(ctx, NK_TEXT_CENTERED, green, "-%"PRIu32"-", itm->frame.counter);
						nk_labelf_colored(ctx, NK_TEXT_RIGHT, violet, "%"PRIi32, itm->frame.nsamples);
					} break;
275

276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
					case ITEM_TYPE_EVENT:
					{
						LV2_Atom_Event *ev = &itm->event.ev;
						const LV2_Atom *body = &ev->body;
						const int64_t frames = ev->time.frames;
						const uint8_t *msg = LV2_ATOM_BODY_CONST(body);
						const uint8_t cmd = (msg[0] & 0xf0) == 0xf0
							? msg[0]
							: msg[0] & 0xf0;

						const midi_msg_t *command_msg = _search_command(cmd);
						const char *command_str = command_msg
							? command_msg->key
							: "Unknown";

						char tmp [16];
						nk_layout_row_begin(ctx, NK_DYNAMIC, widget_h, 7);
						{
							nk_layout_row_push(ctx, 0.1);
							_shadow(ctx, &handle->shadow);
							nk_labelf_colored(ctx, NK_TEXT_LEFT, yellow, "+%04"PRIi64, frames);
297

298 299 300 301 302 303
							nk_layout_row_push(ctx, 0.2);
							const unsigned rem = body->size;
							const unsigned to = rem >= 4 ? 4 : rem % 4;
							for(unsigned i=0, ptr=0; i<to; i++, ptr+=3)
								sprintf(&tmp[ptr], "%02"PRIX8" ", msg[i]);
							tmp[to*3 - 1] = '\0';
304
							nk_label_colored(ctx, tmp, NK_TEXT_LEFT, cwhite);
305

306 307
							nk_layout_row_push(ctx, 0.2);
							nk_label_colored(ctx, command_str, NK_TEXT_LEFT, magenta);
308

309
							switch(cmd)
310
							{
311 312 313 314 315 316 317
								case LV2_MIDI_MSG_NOTE_OFF:
									// fall-through
								case LV2_MIDI_MSG_NOTE_ON:
									// fall-through
								case LV2_MIDI_MSG_NOTE_PRESSURE:
								{
									nk_layout_row_push(ctx, 0.1);
318
									nk_labelf_colored(ctx, NK_TEXT_RIGHT, cwhite, "Ch:%02"PRIu8,
319 320 321 322 323
										(msg[0] & 0x0f) + 1);

									nk_layout_row_push(ctx, 0.2);
									int8_t octave;
									const char *key = _note(msg[1], &octave);
324
									nk_labelf_colored(ctx, NK_TEXT_RIGHT, cwhite, "%s%+"PRIi8, key, octave);
325 326

									nk_layout_row_push(ctx, 0.1);
327
									nk_labelf_colored(ctx, NK_TEXT_RIGHT, cwhite, "%"PRIu8, msg[2]);
328 329 330 331
								} break;
								case LV2_MIDI_MSG_CONTROLLER:
								{
									nk_layout_row_push(ctx, 0.1);
332
									nk_labelf_colored(ctx, NK_TEXT_RIGHT, cwhite, "Ch:%02"PRIu8,
333 334 335 336 337 338 339
										(msg[0] & 0x0f) + 1);

									const midi_msg_t *controller_msg = _search_controller(msg[1]);
									const char *controller_str = controller_msg
										? controller_msg->key
										: "Unknown";
									nk_layout_row_push(ctx, 0.2);
340
									nk_label_colored(ctx, controller_str, NK_TEXT_RIGHT, cwhite);
341 342

									nk_layout_row_push(ctx, 0.1);
343
									nk_labelf_colored(ctx, NK_TEXT_RIGHT, cwhite, "%"PRIu8, msg[2]);
344 345 346 347 348 349
								} break;
								case LV2_MIDI_MSG_PGM_CHANGE:
									// fall-through
								case LV2_MIDI_MSG_CHANNEL_PRESSURE:
								{
									nk_layout_row_push(ctx, 0.1);
350
									nk_labelf_colored(ctx, NK_TEXT_RIGHT, cwhite, "Ch:%02"PRIu8,
351 352 353
										(msg[0] & 0x0f) + 1);

									nk_layout_row_push(ctx, 0.2);
354
									nk_labelf_colored(ctx, NK_TEXT_RIGHT, cwhite, "%"PRIu8, msg[1]);
355 356 357 358 359 360 361 362 363

									nk_layout_row_push(ctx, 0.1);
									_empty(ctx);
								}	break;
								case LV2_MIDI_MSG_BENDER:
								{
									const int16_t bender = (((int16_t)msg[2] << 7) | msg[1]) - 0x2000;

									nk_layout_row_push(ctx, 0.1);
364
									nk_labelf_colored(ctx, NK_TEXT_RIGHT, cwhite, "Ch:%02"PRIu8,
365 366 367
										(msg[0] & 0x0f) + 1);

									nk_layout_row_push(ctx, 0.2);
368
									nk_labelf_colored(ctx, NK_TEXT_RIGHT, cwhite, "%"PRIi16, bender);
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385

									nk_layout_row_push(ctx, 0.1);
									_empty(ctx);
								}	break;
								case LV2_MIDI_MSG_MTC_QUARTER:
								{
									const uint8_t msg_type = msg[1] >> 4;
									const uint8_t msg_val = msg[1] & 0xf;

									nk_layout_row_push(ctx, 0.1);
									_empty(ctx);

									const midi_msg_t *timecode_msg = _search_timecode(msg_type);
									const char *timecode_str = timecode_msg
										? timecode_msg->key
										: "Unknown";
									nk_layout_row_push(ctx, 0.2);
386
									nk_label_colored(ctx, timecode_str, NK_TEXT_RIGHT, cwhite);
387 388

									nk_layout_row_push(ctx, 0.1);
389
									nk_labelf_colored(ctx, NK_TEXT_RIGHT, cwhite, "%"PRIu8, msg_val);
390 391 392 393 394 395 396 397 398
								} break;
								case LV2_MIDI_MSG_SONG_POS:
								{
									const int16_t song_pos= (((int16_t)msg[2] << 7) | msg[1]);

									nk_layout_row_push(ctx, 0.1);
									_empty(ctx);

									nk_layout_row_push(ctx, 0.2);
399
									nk_labelf_colored(ctx, NK_TEXT_RIGHT, cwhite, "%"PRIu16, song_pos);
400 401 402 403 404 405 406 407 408 409

									nk_layout_row_push(ctx, 0.1);
									_empty(ctx);
								} break;
								case LV2_MIDI_MSG_SONG_SELECT:
								{
									nk_layout_row_push(ctx, 0.1);
									_empty(ctx);

									nk_layout_row_push(ctx, 0.2);
410
									nk_labelf_colored(ctx, NK_TEXT_RIGHT, cwhite, "%"PRIu8, msg[1]);
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440

									nk_layout_row_push(ctx, 0.1);
									_empty(ctx);
								} break;
								case LV2_MIDI_MSG_SYSTEM_EXCLUSIVE:
									// fall-throuh
								case LV2_MIDI_MSG_TUNE_REQUEST:
									// fall-throuh
								case LV2_MIDI_MSG_CLOCK:
									// fall-throuh
								case LV2_MIDI_MSG_START:
									// fall-throuh
								case LV2_MIDI_MSG_CONTINUE:
									// fall-throuh
								case LV2_MIDI_MSG_STOP:
									// fall-throuh
								case LV2_MIDI_MSG_ACTIVE_SENSE:
									// fall-throuh
								case LV2_MIDI_MSG_RESET:
								{
									nk_layout_row_push(ctx, 0.1);
									_empty(ctx);

									nk_layout_row_push(ctx, 0.2);
									_empty(ctx);

									nk_layout_row_push(ctx, 0.1);
									_empty(ctx);
								} break;
							}
441

442 443 444 445
							nk_layout_row_push(ctx, 0.1);
							nk_labelf_colored(ctx, NK_TEXT_RIGHT, blue, "%"PRIu32, body->size);
						}
						nk_layout_row_end(ctx);
446

447 448 449
						for(unsigned j=4; j<body->size; j+=4)
						{
							nk_layout_row_begin(ctx, NK_DYNAMIC, widget_h, 7);
450 451
							{
								nk_layout_row_push(ctx, 0.1);
452
								_shadow(ctx, &handle->shadow);
453 454 455
								_empty(ctx);

								nk_layout_row_push(ctx, 0.2);
456 457 458 459 460
								const unsigned rem = body->size - j;
								const unsigned to = rem >= 4 ? 4 : rem % 4;
								for(unsigned i=0, ptr=0; i<to; i++, ptr+=3)
									sprintf(&tmp[ptr], "%02"PRIX8" ", msg[j+i]);
								tmp[to*3 - 1] = '\0';
461
								nk_label_colored(ctx, tmp, NK_TEXT_LEFT, cwhite);
462 463 464 465 466 467 468 469 470 471 472 473 474

								nk_layout_row_push(ctx, 0.2);
								_empty(ctx);

								nk_layout_row_push(ctx, 0.1);
								_empty(ctx);

								nk_layout_row_push(ctx, 0.2);
								_empty(ctx);

								nk_layout_row_push(ctx, 0.1);
								_empty(ctx);

475 476 477
								nk_layout_row_push(ctx, 0.1);
								_empty(ctx);
							}
478
						}
479
					} break;
480 481 482
				}
			}

483 484
			nk_list_view_end(&lview);
		}
485

486 487 488 489 490 491
		const float n = 3;
		const float r0 = 1.f / n;
		const float r1 = 0.1f / 3;
		const float r2 = r0 - r1;
		const float footer [6] = {r1, r2, r1, r2, r1, r2};
		nk_layout_row(ctx, NK_DYNAMIC, widget_h, 6, footer);
492
		{
493
			const int32_t state_overwrite = _check(ctx, handle->state.overwrite);
Hanspeter Portner's avatar
Hanspeter Portner committed
494 495 496
			if(state_overwrite != handle->state.overwrite)
			{
				handle->state.overwrite = state_overwrite;
497
				_set_bool(handle, handle->urid.overwrite, handle->state.overwrite);
Hanspeter Portner's avatar
Hanspeter Portner committed
498
			}
499
			nk_label(ctx, "overwrite", NK_TEXT_LEFT);
Hanspeter Portner's avatar
Hanspeter Portner committed
500

501
			const int32_t state_block = _check(ctx, handle->state.block);
Hanspeter Portner's avatar
Hanspeter Portner committed
502 503 504
			if(state_block != handle->state.block)
			{
				handle->state.block = state_block;
505
				_set_bool(handle, handle->urid.block, handle->state.block);
Hanspeter Portner's avatar
Hanspeter Portner committed
506
			}
507
			nk_label(ctx, "block", NK_TEXT_LEFT);
Hanspeter Portner's avatar
Hanspeter Portner committed
508

509
			const int32_t state_follow = _check(ctx, handle->state.follow);
Hanspeter Portner's avatar
Hanspeter Portner committed
510 511 512
			if(state_follow != handle->state.follow)
			{
				handle->state.follow = state_follow;
513
				_set_bool(handle, handle->urid.follow, handle->state.follow);
Hanspeter Portner's avatar
Hanspeter Portner committed
514
			}
515
			nk_label(ctx, "follow", NK_TEXT_LEFT);
516
		}
517

518 519 520 521 522 523 524
		const bool max_reached = handle->n_item >= MAX_LINES;
		nk_layout_row_dynamic(ctx, widget_h, 2);
		if(nk_button_symbol_label(ctx,
			max_reached ? NK_SYMBOL_TRIANGLE_RIGHT: NK_SYMBOL_NONE,
			"clear", NK_TEXT_LEFT))
		{
			_clear(handle);
525
		}
526
		nk_label(ctx, "Sherlock.lv2: "SHERLOCK_VERSION, NK_TEXT_RIGHT);
527 528 529
	}
	nk_end(ctx);
}