+ Monosynth: add inertia for pitch wheel
[calf.git] / src / calf / custom_ctl.h
blobed8c18566e7dceec6342ed1bf8928792bacfb7c0
1 /* Calf DSP Library
2 * A few useful widgets - a line graph, a knob, a VU meter - Panama!
4 * Copyright (C) 2008 Krzysztof Foltman
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 * Boston, MA 02111-1307, USA.
21 #ifndef __CALF_CUSTOM_CTL
22 #define __CALF_CUSTOM_CTL
24 #include <gtk/gtk.h>
25 #include <calf/giface.h>
27 G_BEGIN_DECLS
29 #define CALF_TYPE_LINE_GRAPH (calf_line_graph_get_type())
30 #define CALF_LINE_GRAPH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_LINE_GRAPH, CalfLineGraph))
31 #define CALF_IS_LINE_GRAPH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_LINE_GRAPH))
32 #define CALF_LINE_GRAPH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_LINE_GRAPH, CalfLineGraphClass))
33 #define CALF_IS_LINE_GRAPH_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_LINE_GRAPH))
34 #define CALF_LINE_GRAPH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALF_TYPE_LINE_GRAPH, CalfLineGraphClass))
36 struct CalfLineGraph
38 GtkDrawingArea parent;
39 calf_plugins::line_graph_iface *source;
40 int source_id;
41 bool is_square;
42 cairo_surface_t *cache_surface;
43 //GdkPixmap *cache_pixmap;
44 int last_generation;
47 struct CalfLineGraphClass
49 GtkDrawingAreaClass parent_class;
52 extern GtkWidget *calf_line_graph_new();
54 extern GType calf_line_graph_get_type();
56 extern void calf_line_graph_set_square(CalfLineGraph *graph, bool is_square);
58 extern int calf_line_graph_update_if(CalfLineGraph *graph, int generation);
60 #define CALF_TYPE_VUMETER (calf_vumeter_get_type())
61 #define CALF_VUMETER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_VUMETER, CalfVUMeter))
62 #define CALF_IS_VUMETER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_VUMETER))
63 #define CALF_VUMETER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_VUMETER, CalfVUMeterClass))
64 #define CALF_IS_VUMETER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_VUMETER))
65 #define CALF_VUMETER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALF_TYPE_VUMETER, CalfVUMeterClass))
67 enum CalfVUMeterMode
69 VU_STANDARD,
70 VU_MONOCHROME,
71 VU_MONOCHROME_REVERSE
74 struct CalfVUMeter
76 GtkDrawingArea parent;
77 CalfVUMeterMode mode;
78 float value;
79 cairo_surface_t *cache_surface;
82 struct CalfVUMeterClass
84 GtkDrawingAreaClass parent_class;
87 extern GtkWidget *calf_vumeter_new();
88 extern GType calf_vumeter_get_type();
89 extern void calf_vumeter_set_value(CalfVUMeter *meter, float value);
90 extern float calf_vumeter_get_value(CalfVUMeter *meter);
91 extern void calf_vumeter_set_mode(CalfVUMeter *meter, CalfVUMeterMode mode);
92 extern CalfVUMeterMode calf_vumeter_get_mode(CalfVUMeter *meter);
94 #define CALF_TYPE_KNOB (calf_knob_get_type())
95 #define CALF_KNOB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_KNOB, CalfKnob))
96 #define CALF_IS_KNOB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_KNOB))
97 #define CALF_KNOB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_KNOB, CalfKnobClass))
98 #define CALF_IS_KNOB_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_KNOB))
100 struct CalfKnob
102 GtkRange parent;
103 int knob_type;
104 double start_x, start_y, start_value, last_y;
107 struct CalfKnobClass
109 GtkRangeClass parent_class;
110 GdkPixbuf *knob_image;
113 extern GtkWidget *calf_knob_new();
114 extern GtkWidget *calf_knob_new_with_adjustment(GtkAdjustment *_adjustment);
116 extern GType calf_knob_get_type();
118 G_END_DECLS
120 class cairo_impl: public calf_plugins::cairo_iface
122 public:
123 cairo_t *context;
124 virtual void set_source_rgba(float r, float g, float b, float a = 1.f) { cairo_set_source_rgba(context, r, g, b, a); }
125 virtual void set_line_width(float width) { cairo_set_line_width(context, width); }
128 #endif