diff options
Diffstat (limited to 'plugins/eg-sampler.lv2/sampler_ui.c')
-rw-r--r-- | plugins/eg-sampler.lv2/sampler_ui.c | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/plugins/eg-sampler.lv2/sampler_ui.c b/plugins/eg-sampler.lv2/sampler_ui.c index 533e720..769dde0 100644 --- a/plugins/eg-sampler.lv2/sampler_ui.c +++ b/plugins/eg-sampler.lv2/sampler_ui.c @@ -1,33 +1,19 @@ -/* - LV2 Sampler Example Plugin UI - Copyright 2011-2016 David Robillard <d@drobilla.net> - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ +// Copyright 2011-2016 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC #include "peaks.h" #include "uris.h" -#include "lv2/atom/atom.h" -#include "lv2/atom/forge.h" -#include "lv2/atom/util.h" -#include "lv2/core/lv2.h" -#include "lv2/core/lv2_util.h" -#include "lv2/log/log.h" -#include "lv2/log/logger.h" -#include "lv2/midi/midi.h" -#include "lv2/ui/ui.h" -#include "lv2/urid/urid.h" +#include <lv2/atom/atom.h> +#include <lv2/atom/forge.h> +#include <lv2/atom/util.h> +#include <lv2/core/lv2.h> +#include <lv2/core/lv2_util.h> +#include <lv2/log/log.h> +#include <lv2/log/logger.h> +#include <lv2/midi/midi.h> +#include <lv2/ui/ui.h> +#include <lv2/urid/urid.h> #include <cairo.h> #include <gdk/gdk.h> @@ -197,13 +183,13 @@ on_canvas_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data) // Draw line through top peaks for (int i = 0; i < n_peaks; ++i) { const float peak = peaks[i]; - cairo_line_to(cr, i * scale, mid_y + (peak / 2.0f) * size.height); + cairo_line_to(cr, i * scale, mid_y + ((peak / 2.0f) * size.height)); } // Continue through bottom peaks for (int i = n_peaks - 1; i >= 0; --i) { const float peak = peaks[i]; - cairo_line_to(cr, i * scale, mid_y - (peak / 2.0f) * size.height); + cairo_line_to(cr, i * scale, mid_y - ((peak / 2.0f) * size.height)); } // Close shape @@ -365,7 +351,7 @@ port_event(LV2UI_Handle handle, const LV2_Atom_Object* obj = (const LV2_Atom_Object*)atom; if (obj->body.otype == ui->uris.patch_Set) { const char* path = read_set_file(&ui->uris, obj); - if (path && (!ui->filename || strcmp(path, ui->filename))) { + if (path && (!ui->filename || !!strcmp(path, ui->filename))) { g_free(ui->filename); ui->filename = g_strdup(path); gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(ui->file_button), @@ -435,7 +421,7 @@ ui_hide(LV2UI_Handle handle) static int ui_idle(LV2UI_Handle handle) { - SamplerUI* ui = (SamplerUI*)handle; + const SamplerUI* ui = (const SamplerUI*)handle; if (ui->window) { gtk_main_iteration_do(false); } @@ -447,11 +433,15 @@ extension_data(const char* uri) { static const LV2UI_Show_Interface show = {ui_show, ui_hide}; static const LV2UI_Idle_Interface idle = {ui_idle}; + if (!strcmp(uri, LV2_UI__showInterface)) { return &show; - } else if (!strcmp(uri, LV2_UI__idleInterface)) { + } + + if (!strcmp(uri, LV2_UI__idleInterface)) { return &idle; } + return NULL; } @@ -461,8 +451,7 @@ static const LV2UI_Descriptor descriptor = {SAMPLER_UI_URI, port_event, extension_data}; -LV2_SYMBOL_EXPORT -const LV2UI_Descriptor* +LV2_SYMBOL_EXPORT const LV2UI_Descriptor* lv2ui_descriptor(uint32_t index) { return index == 0 ? &descriptor : NULL; |