Mercurial > hg > xmms-sid
annotate src/xs_curve.c @ 378:0f255a575720
Fix ending newline.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 09 Nov 2005 19:13:00 +0000 |
parents | 58079c6180a0 |
children | 54d86ee98b98 |
rev | line source |
---|---|
358 | 1 #include <stdlib.h> |
2 #include <string.h> | |
3 #include <math.h> | |
4 | |
5 #include "xs_curve.h" | |
6 #include <gtk/gtkdrawingarea.h> | |
7 #include <gtk/gtkmain.h> | |
8 #include <gtk/gtksignal.h> | |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
9 |
358 | 10 |
11 #define RADIUS 3 /* radius of the control points */ | |
12 #define MIN_DISTANCE 8 /* min distance between control points */ | |
13 | |
14 #define GRAPH_MASK (GDK_EXPOSURE_MASK | \ | |
15 GDK_POINTER_MOTION_MASK | \ | |
16 GDK_POINTER_MOTION_HINT_MASK | \ | |
17 GDK_ENTER_NOTIFY_MASK | \ | |
18 GDK_BUTTON_PRESS_MASK | \ | |
19 GDK_BUTTON_RELEASE_MASK | \ | |
20 GDK_BUTTON1_MOTION_MASK) | |
21 | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
22 enum |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
23 { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
24 ARG_0, |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
25 ARG_CURVE_TYPE, |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
26 ARG_MIN_X, |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
27 ARG_MAX_X, |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
28 ARG_MIN_Y, |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
29 ARG_MAX_Y |
358 | 30 }; |
31 | |
32 static GtkDrawingAreaClass *parent_class = NULL; | |
33 | |
34 | |
35 /* forward declarations: */ | |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
36 static void xs_curve_class_init(XSCurveClass * class); |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
37 static void xs_curve_init(XSCurve * curve); |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
38 static void xs_curve_set_arg(GtkObject * object, GtkArg * arg, guint arg_id); |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
39 static void xs_curve_get_arg(GtkObject * object, GtkArg * arg, guint arg_id); |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
40 static void xs_curve_finalize(GtkObject * object); |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
41 static gint xs_curve_graph_events(GtkWidget * widget, GdkEvent * event, XSCurve * c); |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
42 static void xs_curve_size_graph(XSCurve * curve); |
358 | 43 |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
44 GtkType xs_curve_get_type(void) |
358 | 45 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
46 static GtkType curve_type = 0; |
358 | 47 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
48 if (!curve_type) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
49 static const GtkTypeInfo curve_info = { |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
50 "XSCurve", |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
51 sizeof(XSCurve), |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
52 sizeof(XSCurveClass), |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
53 (GtkClassInitFunc) xs_curve_class_init, |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
54 (GtkObjectInitFunc) xs_curve_init, |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
55 /* reserved_1 */ NULL, |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
56 /* reserved_2 */ NULL, |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
57 (GtkClassInitFunc) NULL, |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
58 }; |
358 | 59 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
60 curve_type = gtk_type_unique(GTK_TYPE_DRAWING_AREA, &curve_info); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
61 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
62 return curve_type; |
358 | 63 } |
64 | |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
65 static void xs_curve_class_init(XSCurveClass * class) |
358 | 66 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
67 GtkObjectClass *object_class; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
68 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
69 parent_class = gtk_type_class(GTK_TYPE_DRAWING_AREA); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
70 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
71 object_class = (GtkObjectClass *) class; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
72 |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
73 object_class->set_arg = xs_curve_set_arg; |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
74 object_class->get_arg = xs_curve_get_arg; |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
75 object_class->finalize = xs_curve_finalize; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
76 |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
77 gtk_object_add_arg_type("XSCurve::min_x", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MIN_X); |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
78 gtk_object_add_arg_type("XSCurve::max_x", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MAX_X); |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
79 gtk_object_add_arg_type("XSCurve::min_y", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MIN_Y); |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
80 gtk_object_add_arg_type("XSCurve::max_y", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MAX_Y); |
358 | 81 } |
82 | |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
83 static void xs_curve_init(XSCurve * curve) |
358 | 84 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
85 gint old_mask; |
358 | 86 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
87 curve->pixmap = NULL; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
88 curve->height = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
89 curve->grab_point = -1; |
358 | 90 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
91 curve->num_points = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
92 curve->point = 0; |
358 | 93 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
94 curve->num_ctlpoints = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
95 curve->ctlpoint = NULL; |
358 | 96 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
97 curve->min_x = 0.0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
98 curve->max_x = 1.0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
99 curve->min_y = 0.0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
100 curve->max_y = 1.0; |
358 | 101 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
102 old_mask = gtk_widget_get_events(GTK_WIDGET(curve)); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
103 gtk_widget_set_events(GTK_WIDGET(curve), old_mask | GRAPH_MASK); |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
104 gtk_signal_connect(GTK_OBJECT(curve), "event", (GtkSignalFunc) xs_curve_graph_events, curve); |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
105 xs_curve_size_graph(curve); |
358 | 106 } |
107 | |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
108 static void xs_curve_set_arg(GtkObject * object, GtkArg * arg, guint arg_id) |
358 | 109 { |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
110 XSCurve *curve = XS_CURVE(object); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
111 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
112 switch (arg_id) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
113 case ARG_MIN_X: |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
114 xs_curve_set_range(curve, GTK_VALUE_FLOAT(*arg), curve->max_x, curve->min_y, curve->max_y); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
115 break; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
116 case ARG_MAX_X: |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
117 xs_curve_set_range(curve, curve->min_x, GTK_VALUE_FLOAT(*arg), curve->min_y, curve->max_y); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
118 break; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
119 case ARG_MIN_Y: |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
120 xs_curve_set_range(curve, curve->min_x, curve->max_x, GTK_VALUE_FLOAT(*arg), curve->max_y); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
121 break; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
122 case ARG_MAX_Y: |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
123 xs_curve_set_range(curve, curve->min_x, curve->max_x, curve->min_y, GTK_VALUE_FLOAT(*arg)); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
124 break; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
125 } |
358 | 126 } |
127 | |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
128 static void xs_curve_get_arg(GtkObject * object, GtkArg * arg, guint arg_id) |
358 | 129 { |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
130 XSCurve *curve = XS_CURVE(object); |
358 | 131 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
132 switch (arg_id) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
133 case ARG_MIN_X: |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
134 GTK_VALUE_FLOAT(*arg) = curve->min_x; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
135 break; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
136 case ARG_MAX_X: |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
137 GTK_VALUE_FLOAT(*arg) = curve->max_x; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
138 break; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
139 case ARG_MIN_Y: |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
140 GTK_VALUE_FLOAT(*arg) = curve->min_y; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
141 break; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
142 case ARG_MAX_Y: |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
143 GTK_VALUE_FLOAT(*arg) = curve->max_y; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
144 break; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
145 default: |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
146 arg->type = GTK_TYPE_INVALID; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
147 break; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
148 } |
358 | 149 } |
150 | |
374
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
151 static int xs_project(gfloat value, gfloat min, gfloat max, int norm) |
358 | 152 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
153 return (norm - 1) * ((value - min) / (max - min)) + 0.5; |
358 | 154 } |
155 | |
374
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
156 static gfloat xs_unproject(gint value, gfloat min, gfloat max, int norm) |
358 | 157 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
158 return value / (gfloat) (norm - 1) * (max - min) + min; |
358 | 159 } |
160 | |
161 /* Solve the tridiagonal equation system that determines the second | |
162 derivatives for the interpolation points. (Based on Numerical | |
163 Recipies 2nd Edition.) */ | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
164 static void spline_solve(int n, gfloat x[], gfloat y[], gfloat y2[]) |
358 | 165 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
166 gfloat p, sig, *u; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
167 gint i, k; |
358 | 168 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
169 u = g_malloc((n - 1) * sizeof(u[0])); |
358 | 170 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
171 y2[0] = u[0] = 0.0; /* set lower boundary condition to "natural" */ |
358 | 172 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
173 for (i = 1; i < n - 1; ++i) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
174 sig = (x[i] - x[i - 1]) / (x[i + 1] - x[i - 1]); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
175 p = sig * y2[i - 1] + 2.0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
176 y2[i] = (sig - 1.0) / p; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
177 u[i] = ((y[i + 1] - y[i]) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
178 / (x[i + 1] - x[i]) - (y[i] - y[i - 1]) / (x[i] - x[i - 1])); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
179 u[i] = (6.0 * u[i] / (x[i + 1] - x[i - 1]) - sig * u[i - 1]) / p; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
180 } |
358 | 181 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
182 y2[n - 1] = 0.0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
183 for (k = n - 2; k >= 0; --k) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
184 y2[k] = y2[k] * y2[k + 1] + u[k]; |
358 | 185 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
186 g_free(u); |
358 | 187 } |
188 | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
189 static gfloat spline_eval(int n, gfloat x[], gfloat y[], gfloat y2[], gfloat val) |
358 | 190 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
191 gint k_lo, k_hi, k; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
192 gfloat h, b, a; |
358 | 193 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
194 /* do a binary search for the right interval: */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
195 k_lo = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
196 k_hi = n - 1; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
197 while (k_hi - k_lo > 1) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
198 k = (k_hi + k_lo) / 2; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
199 if (x[k] > val) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
200 k_hi = k; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
201 else |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
202 k_lo = k; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
203 } |
358 | 204 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
205 h = x[k_hi] - x[k_lo]; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
206 g_assert(h > 0.0); |
358 | 207 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
208 a = (x[k_hi] - val) / h; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
209 b = (val - x[k_lo]) / h; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
210 return a * y[k_lo] + b * y[k_hi] + ((a * a * a - a) * y2[k_lo] + (b * b * b - b) * y2[k_hi]) * (h * h) / 6.0; |
358 | 211 } |
212 | |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
213 static void xs_curve_interpolate(XSCurve * c, gint width, gint height) |
358 | 214 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
215 gfloat *vector; |
374
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
216 gint i; |
358 | 217 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
218 vector = g_malloc(width * sizeof(vector[0])); |
358 | 219 |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
220 xs_curve_get_vector(c, width, vector); |
358 | 221 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
222 c->height = height; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
223 if (c->num_points != width) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
224 c->num_points = width; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
225 if (c->point) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
226 g_free(c->point); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
227 c->point = g_malloc(c->num_points * sizeof(c->point[0])); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
228 } |
358 | 229 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
230 for (i = 0; i < width; ++i) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
231 c->point[i].x = RADIUS + i; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
232 c->point[i].y = RADIUS + height - project(vector[i], c->min_y, c->max_y, height); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
233 } |
358 | 234 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
235 g_free(vector); |
358 | 236 } |
237 | |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
238 static void xs_curve_draw(XSCurve * c, gint width, gint height) |
358 | 239 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
240 GtkStateType state; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
241 GtkStyle *style; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
242 gint i; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
243 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
244 if (!c->pixmap) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
245 return; |
358 | 246 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
247 if (c->height != height || c->num_points != width) |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
248 xs_curve_interpolate(c, width, height); |
358 | 249 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
250 state = GTK_STATE_NORMAL; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
251 if (!GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(c))) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
252 state = GTK_STATE_INSENSITIVE; |
358 | 253 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
254 style = GTK_WIDGET(c)->style; |
358 | 255 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
256 /* clear the pixmap: */ |
374
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
257 gtk_paint_flat_box(style, c->pixmap, |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
258 GTK_STATE_NORMAL, GTK_SHADOW_NONE, |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
259 NULL, GTK_WIDGET(c), "curve_bg", |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
260 0, 0, width + RADIUS * 2, height + RADIUS * 2); |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
261 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
262 /* draw the grid lines: (XXX make more meaningful) */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
263 for (i = 0; i < 5; i++) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
264 gdk_draw_line(c->pixmap, style->dark_gc[state], |
374
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
265 RADIUS, i * (height / 4.0) + RADIUS, |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
266 width + RADIUS, i * (height / 4.0) + RADIUS); |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
267 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
268 gdk_draw_line(c->pixmap, style->dark_gc[state], |
374
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
269 i * (width / 4.0) + RADIUS, RADIUS, |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
270 i * (width / 4.0) + RADIUS, height + RADIUS); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
271 } |
358 | 272 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
273 gdk_draw_points(c->pixmap, style->fg_gc[state], c->point, c->num_points); |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
274 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
275 gdk_draw_pixmap(GTK_WIDGET(c)->window, style->fg_gc[state], c->pixmap, |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
276 0, 0, 0, 0, width + RADIUS * 2, height + RADIUS * 2); |
358 | 277 } |
278 | |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
279 static gint xs_curve_graph_events(GtkWidget * widget, GdkEvent * event, XSCurve * c) |
358 | 280 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
281 gint i, src, dst, leftbound, rightbound; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
282 GdkEventButton *bevent; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
283 GdkEventMotion *mevent; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
284 GtkWidget *w; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
285 gint tx, ty; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
286 gint cx, x, y, width, height; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
287 gint closest_point = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
288 gfloat rx, ry, min_x; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
289 guint distance; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
290 gint x1, x2, y1, y2; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
291 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
292 w = GTK_WIDGET(c); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
293 width = w->allocation.width - RADIUS * 2; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
294 height = w->allocation.height - RADIUS * 2; |
358 | 295 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
296 if ((width < 0) || (height < 0)) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
297 return FALSE; |
374
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
298 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
299 return FALSE; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
300 } |
358 | 301 |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
302 static void xs_curve_size_graph(XSCurve * curve) |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
303 { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
304 gint width, height; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
305 gfloat aspect; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
306 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
307 width = (curve->max_x - curve->min_x) + 1; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
308 height = (curve->max_y - curve->min_y) + 1; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
309 aspect = width / (gfloat) height; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
310 if (width > gdk_screen_width() / 4) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
311 width = gdk_screen_width() / 4; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
312 if (height > gdk_screen_height() / 4) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
313 height = gdk_screen_height() / 4; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
314 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
315 if (aspect < 1.0) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
316 width = height * aspect; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
317 else |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
318 height = width / aspect; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
319 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
320 gtk_drawing_area_size(GTK_DRAWING_AREA(curve), width + RADIUS * 2, height + RADIUS * 2); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
321 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
322 |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
323 static void xs_curve_reset_vector(XSCurve * curve) |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
324 { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
325 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
326 |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
327 void xs_curve_reset(XSCurve * c) |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
328 { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
329 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
330 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
331 |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
332 void xs_curve_set_range(XSCurve * curve, gfloat min_x, gfloat max_x, gfloat min_y, gfloat max_y) |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
333 { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
334 curve->min_x = min_x; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
335 curve->max_x = max_x; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
336 curve->min_y = min_y; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
337 curve->max_y = max_y; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
338 |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
339 xs_curve_size_graph(curve); |
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
340 xs_curve_reset_vector(curve); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
341 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
342 |
358 | 343 |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
344 GtkWidget *xs_curve_new(void) |
358 | 345 { |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
346 return gtk_type_new(xs_curve_get_type()); |
358 | 347 } |
348 | |
374
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
349 |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
350 static void xs_curve_finalize(GtkObject * object) |
358 | 351 { |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
352 XSCurve *curve; |
358 | 353 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
354 g_return_if_fail(object != NULL); |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
355 g_return_if_fail(XS_IS_CURVE(object)); |
358 | 356 |
370
df6f12a00305
Work on filter curve widget begins, based on GtkCurve widget from Gtk+ 1.2.10.
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
357 curve = XS_CURVE(object); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
358 if (curve->pixmap) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
359 gdk_pixmap_unref(curve->pixmap); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
360 if (curve->point) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
361 g_free(curve->point); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
362 if (curve->ctlpoint) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
363 g_free(curve->ctlpoint); |
358 | 364 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
358
diff
changeset
|
365 (*GTK_OBJECT_CLASS(parent_class)->finalize) (object); |
358 | 366 } |
374
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
367 |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
368 |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
369 void xs_curve_get_vector(XSCurve *curve, int veclen, gfloat vector[]) |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
370 { |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
371 } |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
372 |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
373 void xs_curve_set_vector(XSCurve *curve, int veclen, gfloat vector[]) |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
374 { |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
375 } |
58079c6180a0
More removal of original curve code.
Matti Hamalainen <ccr@tnsp.org>
parents:
370
diff
changeset
|
376 |