New rack rack-ears
[calf.git] / src / calf / ctl_linegraph.h
blobbe10532d8714dc8e4f3ac9233d0dcbf9cec96190
1 /* Calf DSP Library
2 * A few useful widgets - a line graph, a knob, a tube - Panama!
4 * Copyright (C) 2008-2010 Krzysztof Foltman, Torben Hohn, Markus
5 * Schmidt and others
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this program; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02111-1307, USA.
23 #ifndef _USE_MATH_DEFINES
24 #define _USE_MATH_DEFINES
25 #endif
26 #ifndef __CALF_CTL_LINEGRAPH
27 #define __CALF_CTL_LINEGRAPH
29 #include <gtk/gtk.h>
30 #include <calf/giface.h>
31 #include <calf/gui.h>
33 G_BEGIN_DECLS
35 #define CALF_TYPE_LINE_GRAPH (calf_line_graph_get_type())
36 #define CALF_LINE_GRAPH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_LINE_GRAPH, CalfLineGraph))
37 #define CALF_IS_LINE_GRAPH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_LINE_GRAPH))
38 #define CALF_LINE_GRAPH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_LINE_GRAPH, CalfLineGraphClass))
39 #define CALF_IS_LINE_GRAPH_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_LINE_GRAPH))
40 #define CALF_LINE_GRAPH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALF_TYPE_LINE_GRAPH, CalfLineGraphClass))
42 struct FreqHandle
44 bool active;
45 int dimensions;
46 int style;
47 char *label;
49 int param_active_no;
50 int param_x_no;
51 int param_y_no;
52 int param_z_no;
53 double value_x;
54 double value_y;
55 double value_z;
56 double last_value_x;
57 double last_value_y;
58 double last_value_z;
59 double default_value_x;
60 double default_value_y;
61 double default_value_z;
62 double pos_x;
63 double pos_y;
64 double pos_z;
66 float left_bound;
67 float right_bound;
68 gpointer data;
70 inline bool is_active() { return (param_active_no < 0 || active); }
73 #define FREQ_HANDLES 32
74 #define HANDLE_WIDTH 20.0
76 struct CalfLineGraph
78 static const int debug = 0; // 0 - 3
80 GtkDrawingArea parent;
81 const calf_plugins::line_graph_iface *source;
82 int source_id;
83 bool force_cache;
84 bool force_redraw;
85 int recreate_surfaces;
86 bool is_square;
87 float fade;
88 int mode, movesurf;
89 int generation;
90 unsigned int layers;
91 static const int pad_x = 0, pad_y = 0;
92 int size_x, size_y;
93 float zoom, offset;
94 int param_zoom, param_offset;
96 cairo_surface_t *background_surface;
97 cairo_surface_t *grid_surface;
98 cairo_surface_t *cache_surface;
99 cairo_surface_t *moving_surface[2];
100 cairo_surface_t *handles_surface;
101 cairo_surface_t *realtime_surface;
103 // crosshairs and FreqHandles
104 gdouble mouse_x, mouse_y;
105 bool use_crosshairs;
106 bool crosshairs_active;
108 int freqhandles;
109 bool use_freqhandles_buttons;
110 bool enforce_handle_order;
111 float min_handle_distance;
112 int handle_grabbed;
113 int handle_hovered;
114 int handle_redraw;
115 FreqHandle freq_handles[FREQ_HANDLES];
116 /// Cached hand (drag) cursor
117 GdkCursor *hand_cursor;
118 /// Cached arrow (drag) cursor
119 GdkCursor *arrow_cursor;
122 struct CalfLineGraphClass
124 GtkDrawingAreaClass parent_class;
127 extern GtkWidget *calf_line_graph_new();
129 extern GType calf_line_graph_get_type();
131 extern void calf_line_graph_set_square(CalfLineGraph *graph, bool is_square);
133 extern void calf_line_graph_expose_request (GtkWidget *widget, bool force = false);
135 G_END_DECLS
137 #endif