annotate src/sid/xs_curve.c @ 2509:1223e8510d8a

Change tabs to 4 spaces, everywhere.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 03 Apr 2008 00:52:14 +0300
parents 05bfc86250f3
children 45ef6d7c0174
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
1 /*
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
3
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
4 XSCurve, a custom Gtk+ spline widget for representing SIDPlay2/reSID
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
5 filter curves in the configuration GUI. Implementation based heavily
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
6 on GtkCurve from Gtk+ 1.2.10 (C) 1997 David Mosberger.
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
7 Spline formula from reSID 0.16 (C) 2004 Dag Lem.
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
8
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
9 Programmed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
10 (C) Copyright 2006-2007 Tecnic Software productions (TNSP)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
11
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
12 This program is free software; you can redistribute it and/or modify
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
13 it under the terms of the GNU General Public License as published by
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
14 the Free Software Foundation; either version 2 of the License, or
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
15 (at your option) any later version.
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
16
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
17 This program is distributed in the hope that it will be useful,
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
20 GNU General Public License for more details.
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
21
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
22 You should have received a copy of the GNU General Public License along
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
23 with this program; if not, write to the Free Software Foundation, Inc.,
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
24 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
25 */
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
26 #include <stdlib.h>
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
27 #include <string.h>
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
28 #include <math.h>
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
29 #include <stdio.h>
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
30 #include "xs_curve.h"
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
31 #include <gtk/gtkdrawingarea.h>
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
32 #include <gtk/gtkmain.h>
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
33 #include <gtk/gtkprivate.h>
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
34
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
35
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
36 #define RADIUS 3 /* radius of the control points */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
37 #define RADIUS2 (RADIUS * 2)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
38 #define MIN_DISTANCE 7 /* min distance between control points */
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
39
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
40
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
41 #define GRAPH_MASK (GDK_EXPOSURE_MASK | \
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
42 GDK_POINTER_MOTION_MASK | \
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
43 GDK_POINTER_MOTION_HINT_MASK | \
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
44 GDK_ENTER_NOTIFY_MASK | \
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
45 GDK_BUTTON_PRESS_MASK | \
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
46 GDK_BUTTON_RELEASE_MASK | \
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
47 GDK_BUTTON1_MOTION_MASK)
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
48
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
49 #define GET_X(i) curve->ctlpoints[i].x
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
50 #define GET_Y(i) curve->ctlpoints[i].y
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
51
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
52
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
53 enum {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
54 PROP_0,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
55 PROP_MIN_X,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
56 PROP_MAX_X,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
57 PROP_MIN_Y,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
58 PROP_MAX_Y
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
59 };
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
60
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
61 static GtkDrawingAreaClass *parent_class = NULL;
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
62
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
63 static void xs_curve_class_init(XSCurveClass * class);
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
64 static void xs_curve_init(XSCurve * curve);
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
65 static void xs_curve_get_property(GObject * object, guint param_id,
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
66 GValue * value, GParamSpec * pspec);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
67 static void xs_curve_set_property(GObject * object, guint param_id,
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
68 const GValue * value, GParamSpec * pspec);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
69 static void xs_curve_finalize(GObject * object);
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
70 static gint xs_curve_graph_events(GtkWidget * widget, GdkEvent * event, XSCurve * c);
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
71 static void xs_curve_size_graph(XSCurve * curve);
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
72
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
73
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
74 GtkType xs_curve_get_type(void)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
75 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
76 static GType curve_type = 0;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
77
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
78 if (!curve_type) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
79 static const GTypeInfo curve_info = {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
80 sizeof(XSCurveClass),
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
81 NULL, /* base_init */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
82 NULL, /* base_finalize */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
83 (GClassInitFunc) xs_curve_class_init,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
84 NULL, /* class_finalize */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
85 NULL, /* class_data */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
86 sizeof(XSCurve),
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
87 0, /* n_preallocs */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
88 (GInstanceInitFunc) xs_curve_init,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
89 };
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
90
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
91 curve_type = g_type_register_static(
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
92 GTK_TYPE_DRAWING_AREA, "XSCurve",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
93 &curve_info, 0);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
94 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
95 return curve_type;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
96 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
97
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
98
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
99 static void xs_curve_class_init(XSCurveClass *class)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
100 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
101 GObjectClass *gobject_class = G_OBJECT_CLASS(class);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
102
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
103 parent_class = g_type_class_peek_parent(class);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
104
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
105 gobject_class->finalize = xs_curve_finalize;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
106
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
107 gobject_class->set_property = xs_curve_set_property;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
108 gobject_class->get_property = xs_curve_get_property;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
109
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
110 g_object_class_install_property(gobject_class, PROP_MIN_X,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
111 g_param_spec_float("min-x",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
112 "Minimum X",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
113 "Minimum possible value for X",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
114 -G_MAXFLOAT, G_MAXFLOAT, 0.0,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
115 GTK_PARAM_READWRITE)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
116 );
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
117
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
118 g_object_class_install_property(gobject_class, PROP_MAX_X,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
119 g_param_spec_float("max-x",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
120 "Maximum X",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
121 "Maximum possible X value",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
122 -G_MAXFLOAT, G_MAXFLOAT, 1.0,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
123 GTK_PARAM_READWRITE)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
124 );
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
125
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
126 g_object_class_install_property(gobject_class, PROP_MIN_Y,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
127 g_param_spec_float("min-y",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
128 "Minimum Y",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
129 "Minimum possible value for Y",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
130 -G_MAXFLOAT, G_MAXFLOAT, 0.0,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
131 GTK_PARAM_READWRITE)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
132 );
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
133
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
134 g_object_class_install_property(gobject_class, PROP_MAX_Y,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
135 g_param_spec_float("max-y",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
136 "Maximum Y",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
137 "Maximum possible value for Y",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
138 -G_MAXFLOAT, G_MAXFLOAT, 1.0,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
139 GTK_PARAM_READWRITE)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
140 );
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
141 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
142
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
143
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
144 static void xs_curve_init(XSCurve *curve)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
145 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
146 gint old_mask;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
147
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
148 curve->pixmap = NULL;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
149 curve->grab_point = -1;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
150
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
151 curve->nctlpoints = 0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
152 curve->ctlpoints = NULL;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
153
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
154 curve->min_x = 0.0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
155 curve->max_x = 2047.0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
156 curve->min_y = 0.0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
157 curve->max_y = 24000.0;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
158
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
159 old_mask = gtk_widget_get_events(GTK_WIDGET(curve));
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
160 gtk_widget_set_events(GTK_WIDGET(curve), old_mask | GRAPH_MASK);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
161 g_signal_connect(curve, "event", G_CALLBACK(xs_curve_graph_events), curve);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
162 xs_curve_size_graph(curve);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
163 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
164
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
165
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
166 static void xs_curve_set_property(GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
167 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
168 XSCurve *curve = XS_CURVE(object);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
169
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
170 switch (prop_id) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
171 case PROP_MIN_X:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
172 xs_curve_set_range(curve,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
173 g_value_get_float(value), curve->max_x,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
174 curve->min_y, curve->max_y);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
175 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
176 case PROP_MAX_X:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
177 xs_curve_set_range(curve,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
178 curve->min_x, g_value_get_float(value),
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
179 curve->min_y, curve->max_y);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
180 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
181 case PROP_MIN_Y:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
182 xs_curve_set_range(curve,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
183 curve->min_x, curve->max_x,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
184 g_value_get_float(value), curve->max_y);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
185 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
186 case PROP_MAX_Y:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
187 xs_curve_set_range(curve,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
188 curve->min_x, curve->max_x,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
189 curve->min_y, g_value_get_float(value));
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
190 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
191 default:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
192 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
193 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
194 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
195 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
196
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
197
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
198 static void xs_curve_get_property(GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
199 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
200 XSCurve *curve = XS_CURVE(object);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
201
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
202 switch (prop_id) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
203 case PROP_MIN_X:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
204 g_value_set_float(value, curve->min_x);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
205 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
206 case PROP_MAX_X:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
207 g_value_set_float(value, curve->max_x);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
208 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
209 case PROP_MIN_Y:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
210 g_value_set_float(value, curve->min_y);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
211 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
212 case PROP_MAX_Y:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
213 g_value_set_float(value, curve->max_y);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
214 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
215 default:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
216 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
217 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
218 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
219 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
220
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
221
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
222 static int xs_project(gfloat value, gfloat min, gfloat max, int norm)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
223 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
224 return (norm - 1) * ((value - min) / (max - min)) + 0.5;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
225 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
226
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
227
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
228 static gfloat xs_unproject(gint value, gfloat min, gfloat max, int norm)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
229 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
230 return value / (gfloat) (norm - 1) * (max - min) + min;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
231 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
232
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
233
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
234 static inline void xs_cubic_coeff(gfloat x1, gfloat y1,
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
235 gfloat x2, gfloat y2,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
236 gfloat k1, gfloat k2,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
237 gfloat *a, gfloat *b,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
238 gfloat *c, gfloat *d)
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
239 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
240 gfloat dx = x2 - x1, dy = y2 - y1;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
241
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
242 *a = ((k1 + k2) - 2 * dy / dx) / (dx * dx);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
243 *b = ((k2 - k1) / dx - 3 * (x1 + x2) * (*a)) / 2;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
244 *c = k1 - (3 * x1 * (*a) + 2 * (*b)) * x1;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
245 *d = y1 - ((x1 * (*a) + (*b)) * x1 + (*c)) * x1;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
246 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
247
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
248
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
249 static void xs_curve_draw(XSCurve *curve, gint width, gint height)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
250 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
251 gfloat res = 5.0f;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
252 GtkStateType state;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
253 GtkStyle *style;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
254 gint i, ox = -1, oy = -1;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
255 t_xs_point *p0, *p1, *p2, *p3;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
256
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
257 if (!curve->pixmap)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
258 return;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
259
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
260 state = GTK_STATE_NORMAL;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
261 if (!GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(curve)))
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
262 state = GTK_STATE_INSENSITIVE;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
263
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
264 style = GTK_WIDGET(curve)->style;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
265
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
266 /* Clear the pixmap */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
267 gtk_paint_flat_box(style, curve->pixmap,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
268 GTK_STATE_NORMAL, GTK_SHADOW_NONE,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
269 NULL, GTK_WIDGET(curve), "curve_bg",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
270 0, 0,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
271 width + RADIUS2,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
272 height + RADIUS2);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
273
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
274
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
275 /* Draw the grid */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
276 for (i = 0; i < 5; i++) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
277 gdk_draw_line(curve->pixmap, style->dark_gc[state],
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
278 RADIUS, i * (height / 4.0) + RADIUS,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
279 width + RADIUS, i * (height / 4.0) + RADIUS);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
280
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
281 gdk_draw_line(curve->pixmap, style->dark_gc[state],
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
282 i * (width / 4.0) + RADIUS, RADIUS,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
283 i * (width / 4.0) + RADIUS, height + RADIUS);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
284 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
285
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
286 #if 1
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
287 /* Draw the spline/curve itself */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
288 p0 = curve->ctlpoints;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
289 p1 = p0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
290 p2 = p1; p2++;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
291 p3 = p2; p3++;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
292
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
293 /* Draw each curve segment */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
294 if (curve->nctlpoints > 5)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
295 for (i = 0; i < curve->nctlpoints; i++, ++p0, ++p1, ++p2, ++p3) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
296 gint n;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
297 gfloat k1, k2, a, b, c, d, x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
298
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
299 if (p1->x == p2->x)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
300 continue;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
301
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
302 if (p0->x == p1->x && p2->x == p3->x) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
303 k1 = k2 = (p2->y - p1->y) / (p2->x - p1->x);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
304 } else if (p0->x == p1->x) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
305 k2 = (p3->y - p1->y) / (p3->x - p1->x);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
306 k1 = (3 * (p2->y - p1->y) / (p2->x - p1->x) - k2) / 2;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
307 } else if (p2->x == p3->x) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
308 k1 = (p2->y - p0->y) / (p2->x - p0->x);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
309 k2 = (3 * (p2->y - p1->y) / (p2->x - p1->x) - k1) / 2;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
310 } else {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
311 k1 = (p2->y - p0->y) / (p2->x - p0->x);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
312 k2 = (p3->y - p1->y) / (p3->x - p1->x);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
313 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
314
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
315 xs_cubic_coeff(p1->x, p1->y, p2->x, p2->y, k1, k2, &a, &b, &c, &d);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
316
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
317 for (x = p1->x; x <= p2->x; x += res, n++) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
318 gfloat y = ((a * x + b) * x + c) * x + d;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
319 gint qx, qy;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
320 qx = RADIUS + xs_project(x, curve->min_x, curve->max_x, width);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
321 qy = RADIUS + xs_project(y, curve->min_y, curve->max_y, height);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
322
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
323 if (ox != -1) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
324 gdk_draw_line(curve->pixmap, style->fg_gc[state],
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
325 ox, oy, qx, qy);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
326 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
327 ox = qx; oy = qy;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
328 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
329 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
330
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
331 #endif
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
332
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
333 /* Draw control points */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
334 for (i = 0; i < curve->nctlpoints; ++i) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
335 gint x, y;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
336 GtkStateType cstate;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
337
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
338 if (GET_X(i) < curve->min_x || GET_Y(i) < curve->min_y ||
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
339 GET_X(i) >= curve->max_x || GET_Y(i) >= curve->max_y)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
340 continue;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
341
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
342 x = xs_project(GET_X(i), curve->min_x, curve->max_x, width);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
343 y = xs_project(GET_Y(i), curve->min_y, curve->max_y, height);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
344
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
345 if (i == curve->grab_point) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
346 cstate = GTK_STATE_SELECTED;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
347 gdk_draw_line(curve->pixmap, style->fg_gc[cstate],
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
348 x + RADIUS, RADIUS, x + RADIUS, height + RADIUS);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
349 gdk_draw_line(curve->pixmap, style->fg_gc[cstate],
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
350 RADIUS, y + RADIUS, width + RADIUS, y + RADIUS);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
351 } else
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
352 cstate = state;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
353
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
354 gdk_draw_arc(curve->pixmap, style->fg_gc[cstate], TRUE,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
355 x, y, RADIUS2, RADIUS2, 0, 360 * 64);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
356 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
357
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
358 /* Draw pixmap in the widget */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
359 gdk_draw_pixmap(GTK_WIDGET(curve)->window,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
360 style->fg_gc[state], curve->pixmap,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
361 0, 0, 0, 0,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
362 width + RADIUS2,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
363 height + RADIUS2);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
364 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
365
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
366
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
367 static gint xs_curve_graph_events(GtkWidget *widget, GdkEvent *event, XSCurve *curve)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
368 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
369 GdkCursorType new_type = curve->cursor_type;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
370 GdkEventButton *bevent;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
371 GtkWidget *w;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
372 gint i, width, height, x, y, tx, ty, cx, closest_point = 0, min_x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
373 guint distance;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
374
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
375 w = GTK_WIDGET(curve);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
376 width = w->allocation.width - RADIUS2;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
377 height = w->allocation.height - RADIUS2;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
378
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
379 if ((width < 0) || (height < 0))
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
380 return FALSE;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
381
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
382 /* get the pointer position */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
383 gdk_window_get_pointer(w->window, &tx, &ty, NULL);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
384 x = CLAMP((tx - RADIUS), 0, width - 1);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
385 y = CLAMP((ty - RADIUS), 0, height - 1);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
386 min_x = curve->min_x;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
387
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
388 distance = ~0U;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
389 for (i = 0; i < curve->nctlpoints; ++i) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
390 cx = xs_project(GET_X(i), min_x, curve->max_x, width);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
391 if ((guint) abs(x - cx) < distance) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
392 distance = abs(x - cx);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
393 closest_point = i;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
394 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
395 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
396
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
397 /* Act based on event type */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
398 switch (event->type) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
399 case GDK_CONFIGURE:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
400 if (curve->pixmap)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
401 gdk_pixmap_unref(curve->pixmap);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
402 curve->pixmap = 0;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
403
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
404 /* fall through */
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
405
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
406 case GDK_EXPOSE:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
407 if (!curve->pixmap) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
408 curve->pixmap = gdk_pixmap_new(w->window,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
409 w->allocation.width, w->allocation.height, -1);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
410 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
411 xs_curve_draw(curve, width, height);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
412 break;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
413
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
414 case GDK_BUTTON_PRESS:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
415 gtk_grab_add(widget);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
416
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
417 bevent = (GdkEventButton *) event;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
418 new_type = GDK_TCROSS;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
419
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
420 if (distance > MIN_DISTANCE) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
421 /* insert a new control point */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
422 if (curve->nctlpoints > 0) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
423 cx = xs_project(GET_X(closest_point), min_x, curve->max_x, width);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
424 if (x > cx) closest_point++;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
425 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
426
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
427 curve->nctlpoints++;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
428
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
429 curve->ctlpoints = g_realloc(curve->ctlpoints,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
430 curve->nctlpoints * sizeof(*curve->ctlpoints));
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
431
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
432 for (i = curve->nctlpoints - 1; i > closest_point; --i) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
433 memcpy(curve->ctlpoints + i,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
434 curve->ctlpoints + i - 1,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
435 sizeof(*curve->ctlpoints));
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
436 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
437 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
438
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
439 curve->grab_point = closest_point;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
440 GET_X(curve->grab_point) = xs_unproject(x, min_x, curve->max_x, width);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
441 GET_Y(curve->grab_point) = xs_unproject(y, curve->min_y, curve->max_y, height);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
442
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
443 xs_curve_draw(curve, width, height);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
444 break;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
445
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
446 case GDK_BUTTON_RELEASE:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
447 {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
448 gint src, dst;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
449
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
450 gtk_grab_remove(widget);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
451
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
452 /* delete inactive points: */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
453 for (src = dst = 0; src < curve->nctlpoints; ++src) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
454 if (GET_X(src) >= min_x) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
455 memcpy(curve->ctlpoints + dst,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
456 curve->ctlpoints + src,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
457 sizeof(*curve->ctlpoints));
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
458 dst++;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
459 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
460 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
461
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
462 if (dst < src) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
463 curve->nctlpoints -= (src - dst);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
464 if (curve->nctlpoints <= 0) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
465 curve->nctlpoints = 1;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
466 GET_X(0) = min_x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
467 GET_Y(0) = curve->min_y;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
468 xs_curve_draw(curve, width, height);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
469 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
470 curve->ctlpoints = g_realloc(curve->ctlpoints,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
471 curve->nctlpoints * sizeof(*curve->ctlpoints));
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
472 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
473
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
474 new_type = GDK_FLEUR;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
475 curve->grab_point = -1;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
476 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
477 xs_curve_draw(curve, width, height);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
478 break;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
479
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
480 case GDK_MOTION_NOTIFY:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
481 if (curve->grab_point == -1) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
482 /* if no point is grabbed... */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
483 if (distance <= MIN_DISTANCE)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
484 new_type = GDK_FLEUR;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
485 else
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
486 new_type = GDK_TCROSS;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
487 } else {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
488 gint leftbound, rightbound;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
489
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
490 /* drag the grabbed point */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
491 new_type = GDK_TCROSS;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
492
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
493 leftbound = -MIN_DISTANCE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
494 if (curve->grab_point > 0) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
495 leftbound = xs_project(
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
496 GET_X(curve->grab_point-1),
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
497 min_x, curve->max_x, width);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
498 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
499
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
500 rightbound = width + RADIUS2 + MIN_DISTANCE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
501 if (curve->grab_point + 1 < curve->nctlpoints) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
502 rightbound = xs_project(
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
503 GET_X(curve->grab_point+1),
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
504 min_x, curve->max_x, width);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
505 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
506
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
507 if ((tx <= leftbound) || (tx >= rightbound) ||
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
508 (ty > height + RADIUS2 + MIN_DISTANCE) || (ty < -MIN_DISTANCE)) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
509 GET_X(curve->grab_point) = min_x - 1.0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
510 } else {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
511 GET_X(curve->grab_point) =
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
512 xs_unproject(x, min_x, curve->max_x, width);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
513 GET_Y(curve->grab_point) =
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
514 xs_unproject(y, curve->min_y, curve->max_y, height);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
515 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
516
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
517 xs_curve_draw(curve, width, height);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
518 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
519
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
520 /* See if cursor type was changed and update accordingly */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
521 if (new_type != (GdkCursorType) curve->cursor_type) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
522 GdkCursor *cursor;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
523 curve->cursor_type = new_type;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
524 cursor = gdk_cursor_new(curve->cursor_type);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
525 gdk_window_set_cursor(w->window, cursor);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
526 gdk_cursor_destroy(cursor);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
527 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
528 break;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
529
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
530 default:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
531 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
532 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
533
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
534 return FALSE;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
535 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
536
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
537
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
538 static void xs_curve_size_graph(XSCurve *curve)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
539 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
540 gint width, height;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
541 gfloat aspect;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
542 GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(curve));
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
543
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
544 width = (curve->max_x - curve->min_x) + 1;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
545 height = (curve->max_y - curve->min_y) + 1;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
546 aspect = width / (gfloat) height;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
547
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
548 if (width > gdk_screen_get_width(screen) / 4)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
549 width = gdk_screen_get_width(screen) / 4;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
550
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
551 if (height > gdk_screen_get_height(screen) / 4)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
552 height = gdk_screen_get_height(screen) / 4;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
553
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
554 if (aspect < 1.0)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
555 width = height * aspect;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
556 else
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
557 height = width / aspect;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
558
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
559 gtk_widget_set_size_request(GTK_WIDGET(curve), width + RADIUS2, height + RADIUS2);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
560 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
561
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
562
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
563 static void xs_curve_update(XSCurve *curve)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
564 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
565 if (curve->pixmap) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
566 gint width, height;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
567
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
568 width = GTK_WIDGET(curve)->allocation.width - RADIUS2;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
569 height = GTK_WIDGET(curve)->allocation.height - RADIUS2;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
570 xs_curve_draw(curve, width, height);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
571 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
572 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
573
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
574
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
575 void xs_curve_reset(XSCurve *curve)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
576 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
577 if (curve->ctlpoints)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
578 g_free(curve->ctlpoints);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
579
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
580 curve->nctlpoints = 4;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
581 curve->ctlpoints = g_malloc(curve->nctlpoints * sizeof(curve->ctlpoints[0]));
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
582
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
583 GET_X(0) = curve->min_x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
584 GET_Y(0) = curve->min_y;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
585 GET_X(1) = curve->min_x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
586 GET_Y(1) = curve->min_y;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
587
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
588 GET_X(2) = curve->max_x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
589 GET_Y(2) = curve->max_y;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
590 GET_X(3) = curve->max_x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
591 GET_Y(3) = curve->max_y;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
592
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
593 xs_curve_update(curve);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
594 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
595
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
596
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
597 void xs_curve_set_range(XSCurve *curve, gfloat min_x, gfloat min_y, gfloat max_x, gfloat max_y)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
598 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
599 g_object_freeze_notify(G_OBJECT(curve));
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
600 if (curve->min_x != min_x) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
601 curve->min_x = min_x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
602 g_object_notify(G_OBJECT(curve), "min-x");
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
603 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
604 if (curve->max_x != max_x) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
605 curve->max_x = max_x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
606 g_object_notify(G_OBJECT(curve), "max-x");
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
607 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
608 if (curve->min_y != min_y) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
609 curve->min_y = min_y;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
610 g_object_notify(G_OBJECT(curve), "min-y");
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
611 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
612 if (curve->max_y != max_y) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
613 curve->max_y = max_y;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
614 g_object_notify(G_OBJECT(curve), "max-y");
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
615 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
616 g_object_thaw_notify(G_OBJECT(curve));
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
617
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
618 xs_curve_size_graph(curve);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
619 xs_curve_reset(curve);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
620 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
621
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
622
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
623 gboolean xs_curve_realloc_data(XSCurve *curve, gint npoints)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
624 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
625 if (npoints != curve->nctlpoints) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
626 curve->nctlpoints = npoints;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
627 curve->ctlpoints = (t_xs_point *) g_realloc(curve->ctlpoints,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
628 curve->nctlpoints * sizeof(*curve->ctlpoints));
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
629
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
630 if (curve->ctlpoints == NULL)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
631 return FALSE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
632 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
633
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
634 return TRUE;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
635 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
636
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
637
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
638 void xs_curve_get_data(XSCurve *curve, t_xs_point ***points, gint **npoints)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
639 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
640 *points = &(curve->ctlpoints);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
641 *npoints = &(curve->nctlpoints);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
642 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
643
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
644
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
645 gboolean xs_curve_set_points(XSCurve *curve, t_xs_int_point *points, gint npoints)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
646 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
647 gint i;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
648
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
649 if (!xs_curve_realloc_data(curve, npoints + 4))
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
650 return FALSE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
651
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
652 GET_X(0) = curve->min_x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
653 GET_Y(0) = curve->min_y;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
654 GET_X(1) = curve->min_x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
655 GET_Y(1) = curve->min_y;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
656
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
657 for (i = 0; i < npoints; i++) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
658 GET_X(i+2) = points[i].x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
659 GET_Y(i+2) = points[i].y;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
660 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
661
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
662 GET_X(npoints+2) = curve->max_x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
663 GET_Y(npoints+2) = curve->max_y;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
664 GET_X(npoints+3) = curve->max_x;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
665 GET_Y(npoints+3) = curve->max_y;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
666
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
667 xs_curve_update(curve);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
668 return TRUE;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
669 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
670
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
671
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
672 gboolean xs_curve_get_points(XSCurve *curve, t_xs_int_point **points, gint *npoints)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
673 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
674 gint i, n;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
675
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
676 n = curve->nctlpoints - 4;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
677
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
678 *points = g_malloc(n * sizeof(t_xs_int_point));
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
679 if (*points == NULL)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
680 return FALSE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
681
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
682 *npoints = n;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
683 for (i = 2; i < curve->nctlpoints - 2; i++) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
684 (*points)[i].x = GET_X(i);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
685 (*points)[i].y = GET_Y(i);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
686 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
687
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
688 return TRUE;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
689 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
690
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
691
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
692 GtkWidget *xs_curve_new(void)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
693 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
694 return g_object_new(XS_TYPE_CURVE, NULL);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
695 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
696
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
697
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
698 static void xs_curve_finalize(GObject *object)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
699 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
700 XSCurve *curve;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
701
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
702 g_return_if_fail(object != NULL);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
703 g_return_if_fail(XS_IS_CURVE(object));
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
704
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
705 curve = XS_CURVE(object);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
706 if (curve->pixmap)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
707 g_object_unref(curve->pixmap);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
708 if (curve->ctlpoints)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
709 g_free(curve->ctlpoints);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
710
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1956
diff changeset
711 G_OBJECT_CLASS(parent_class)->finalize(object);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents:
diff changeset
712 }