/
knob_mapper.h
77 lines (65 loc) · 3.27 KB
/
knob_mapper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
/****************************************************************************
* xtor - GTK based editor for MIDI synthesizers
*
* knob_mapper.h - Representation of controller's knobs
*
* Copyright (C) 2014 Ricard Wanderlof <ricard2013@butoba.net>
*
* Portions of this file derived from the GTK toolkit:
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/
#ifndef _KNOB_MAPPER_H_
#define _KNOB_MAPPER_H_
#include <gtk/gtk.h>
/* Description of a knob in our context. */
struct knob_descriptor {
GtkWidget *widget; /* Pointer to widget corresponding to this knob. */
void *ref; /* Ultimately a pointer to the adjustor (see xtor.c),
* but as a knob mapper we don't really know that. */
};
/* Callback for notifying UI of incoming parameter value changes */
typedef void (*knob_notify_cb)(void *widget_ref, int delta, void *ref);
/* Struct for run-time mapping of knobs to on-screen parameter frames.
* The mapping is done at startup during the processing of the glade file
* with the UI definitions. When running, the structures are accessed in
* order to map a given knob on a controller to a specific parameter,
* depending on in which frame the current focus is set. */
struct knob_mapper {
/* Start-up-time configuraton */
void *(*container_new)(GtkContainer *frame);
void *(*container_done)(void *knobmap_in);
void *(*container_add_widget)(void *knobmap_in,
struct knob_descriptor* knob_description);
void (*register_notify_cb)(knob_notify_cb cb, void *ref);
/* Run-time mapping */
struct knob_descriptor *(*knob)(void *knobmap_in, int knob_no,
int alt_knob_no, int row);
void (*invalidate)(void *knobmap_in);
};
/* Functions intended primarily for use by knob mappers. */
/* Get coordinates of @widget's allocation with respect to
* allocation of @container. */
gboolean get_allocation_coords(GtkContainer *container,
GtkWidget *widget,
GdkRectangle *allocation);
/* GCompareFunc to compare left-right positions of widgets a and b. */
gint left_right_compare(gconstpointer a, gconstpointer b);
#endif /* _KNOB_MAPPER_H_ */
/********************** End of file knob_mapper.h ***************************/