Mercurial > audlegacy
annotate src/audacious/ui_skinned_equalizer_graph.c @ 4387:aca39c7f748e
Automated merge with ssh://hg.atheme.org//hg/audacious
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Sat, 29 Mar 2008 08:55:47 -0500 |
parents | 822bc79f54bd |
children | de33c83aa06f |
rev | line source |
---|---|
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
1 /* |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
2 * Audacious - a cross-platform multimedia player |
3840 | 3 * Copyright (c) 2007 Tomasz Moń |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
4 * |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
5 * Based on: |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
6 * BMP - Cross-platform multimedia player |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
7 * Copyright (C) 2003-2004 BMP development team. |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
8 * XMMS: |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
9 * Copyright (C) 1998-2003 XMMS development team. |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
10 * |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
11 * This program is free software; you can redistribute it and/or modify |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
12 * it under the terms of the GNU General Public License as published by |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3105
diff
changeset
|
13 * the Free Software Foundation; under version 3 of the License. |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
14 * |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
18 * GNU General Public License for more details. |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
19 * |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3105
diff
changeset
|
21 * along with this program; If not, see <http://www.gnu.org/licenses>. |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
22 */ |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
23 |
3251 | 24 #include "skin.h" |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
25 #include "ui_skinned_equalizer_graph.h" |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
26 #include "main.h" |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
27 #include "util.h" |
4310 | 28 #include "equalizer_flow.h" |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
29 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
30 #define UI_TYPE_SKINNED_EQUALIZER_GRAPH (ui_skinned_equalizer_graph_get_type()) |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
31 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
32 enum { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
33 DOUBLED, |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
34 LAST_SIGNAL |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
35 }; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
36 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
37 static void ui_skinned_equalizer_graph_class_init (UiSkinnedEqualizerGraphClass *klass); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
38 static void ui_skinned_equalizer_graph_init (UiSkinnedEqualizerGraph *equalizer_graph); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
39 static void ui_skinned_equalizer_graph_destroy (GtkObject *object); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
40 static void ui_skinned_equalizer_graph_realize (GtkWidget *widget); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
41 static void ui_skinned_equalizer_graph_size_request (GtkWidget *widget, GtkRequisition *requisition); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
42 static void ui_skinned_equalizer_graph_size_allocate (GtkWidget *widget, GtkAllocation *allocation); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
43 static gboolean ui_skinned_equalizer_graph_expose (GtkWidget *widget, GdkEventExpose *event); |
4218
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
44 static void ui_skinned_equalizer_graph_toggle_scaled (UiSkinnedEqualizerGraph *equalizer_graph); |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
45 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
46 static GtkWidgetClass *parent_class = NULL; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
47 static guint equalizer_graph_signals[LAST_SIGNAL] = { 0 }; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
48 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
49 GType ui_skinned_equalizer_graph_get_type() { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
50 static GType equalizer_graph_type = 0; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
51 if (!equalizer_graph_type) { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
52 static const GTypeInfo equalizer_graph_info = { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
53 sizeof (UiSkinnedEqualizerGraphClass), |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
54 NULL, |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
55 NULL, |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
56 (GClassInitFunc) ui_skinned_equalizer_graph_class_init, |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
57 NULL, |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
58 NULL, |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
59 sizeof (UiSkinnedEqualizerGraph), |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
60 0, |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
61 (GInstanceInitFunc) ui_skinned_equalizer_graph_init, |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
62 }; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
63 equalizer_graph_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedEqualizerGraph", &equalizer_graph_info, 0); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
64 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
65 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
66 return equalizer_graph_type; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
67 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
68 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
69 static void ui_skinned_equalizer_graph_class_init(UiSkinnedEqualizerGraphClass *klass) { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
70 GObjectClass *gobject_class; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
71 GtkObjectClass *object_class; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
72 GtkWidgetClass *widget_class; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
73 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
74 gobject_class = G_OBJECT_CLASS(klass); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
75 object_class = (GtkObjectClass*) klass; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
76 widget_class = (GtkWidgetClass*) klass; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
77 parent_class = gtk_type_class (gtk_widget_get_type ()); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
78 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
79 object_class->destroy = ui_skinned_equalizer_graph_destroy; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
80 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
81 widget_class->realize = ui_skinned_equalizer_graph_realize; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
82 widget_class->expose_event = ui_skinned_equalizer_graph_expose; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
83 widget_class->size_request = ui_skinned_equalizer_graph_size_request; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
84 widget_class->size_allocate = ui_skinned_equalizer_graph_size_allocate; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
85 |
4218
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
86 klass->scaled = ui_skinned_equalizer_graph_toggle_scaled; |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
87 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
88 equalizer_graph_signals[DOUBLED] = |
4218
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
89 g_signal_new ("toggle-scaled", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
90 G_STRUCT_OFFSET (UiSkinnedEqualizerGraphClass, scaled), NULL, NULL, |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
91 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
92 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
93 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
94 static void ui_skinned_equalizer_graph_init(UiSkinnedEqualizerGraph *equalizer_graph) { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
95 equalizer_graph->width = 113; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
96 equalizer_graph->height = 19; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
97 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
98 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
99 GtkWidget* ui_skinned_equalizer_graph_new(GtkWidget *fixed, gint x, gint y) { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
100 UiSkinnedEqualizerGraph *equalizer_graph = g_object_new (ui_skinned_equalizer_graph_get_type (), NULL); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
101 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
102 equalizer_graph->x = x; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
103 equalizer_graph->y = y; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
104 equalizer_graph->skin_index = SKIN_EQMAIN; |
4218
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
105 equalizer_graph->scaled = FALSE; |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
106 |
3939
d46d60247826
we don't need to store GtkFixed pointer, do we?
Tomasz Mon <desowin@gmail.com>
parents:
3933
diff
changeset
|
107 gtk_fixed_put(GTK_FIXED(fixed), GTK_WIDGET(equalizer_graph), equalizer_graph->x, equalizer_graph->y); |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
108 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
109 return GTK_WIDGET(equalizer_graph); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
110 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
111 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
112 static void ui_skinned_equalizer_graph_destroy(GtkObject *object) { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
113 UiSkinnedEqualizerGraph *equalizer_graph; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
114 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
115 g_return_if_fail (object != NULL); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
116 g_return_if_fail (UI_SKINNED_IS_EQUALIZER_GRAPH (object)); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
117 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
118 equalizer_graph = UI_SKINNED_EQUALIZER_GRAPH (object); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
119 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
120 if (GTK_OBJECT_CLASS (parent_class)->destroy) |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
121 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
122 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
123 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
124 static void ui_skinned_equalizer_graph_realize(GtkWidget *widget) { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
125 UiSkinnedEqualizerGraph *equalizer_graph; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
126 GdkWindowAttr attributes; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
127 gint attributes_mask; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
128 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
129 g_return_if_fail (widget != NULL); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
130 g_return_if_fail (UI_SKINNED_IS_EQUALIZER_GRAPH(widget)); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
131 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
132 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
133 equalizer_graph = UI_SKINNED_EQUALIZER_GRAPH(widget); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
134 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
135 attributes.x = widget->allocation.x; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
136 attributes.y = widget->allocation.y; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
137 attributes.width = widget->allocation.width; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
138 attributes.height = widget->allocation.height; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
139 attributes.wclass = GDK_INPUT_OUTPUT; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
140 attributes.window_type = GDK_WINDOW_CHILD; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
141 attributes.event_mask = gtk_widget_get_events(widget); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
142 attributes.event_mask |= GDK_EXPOSURE_MASK; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
143 attributes.visual = gtk_widget_get_visual(widget); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
144 attributes.colormap = gtk_widget_get_colormap(widget); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
145 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
146 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
147 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
148 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
149 widget->style = gtk_style_attach(widget->style, widget->window); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
150 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
151 gdk_window_set_user_data(widget->window, widget); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
152 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
153 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
154 static void ui_skinned_equalizer_graph_size_request(GtkWidget *widget, GtkRequisition *requisition) { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
155 UiSkinnedEqualizerGraph *equalizer_graph = UI_SKINNED_EQUALIZER_GRAPH(widget); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
156 |
4218
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
157 requisition->width = equalizer_graph->width*(equalizer_graph->scaled ? cfg.scale_factor : 1); |
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
158 requisition->height = equalizer_graph->height*(equalizer_graph->scaled ? cfg.scale_factor : 1); |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
159 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
160 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
161 static void ui_skinned_equalizer_graph_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
162 UiSkinnedEqualizerGraph *equalizer_graph = UI_SKINNED_EQUALIZER_GRAPH (widget); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
163 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
164 widget->allocation = *allocation; |
4218
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
165 widget->allocation.x *= (equalizer_graph->scaled ? cfg.scale_factor : 1); |
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
166 widget->allocation.y *= (equalizer_graph->scaled ? cfg.scale_factor : 1); |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
167 if (GTK_WIDGET_REALIZED (widget)) |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
168 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
169 |
4218
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
170 equalizer_graph->x = widget->allocation.x/(equalizer_graph->scaled ? cfg.scale_factor : 1); |
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
171 equalizer_graph->y = widget->allocation.y/(equalizer_graph->scaled ? cfg.scale_factor : 1); |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
172 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
173 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
174 void |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
175 init_spline(gfloat * x, gfloat * y, gint n, gfloat * y2) |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
176 { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
177 gint i, k; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
178 gfloat p, qn, sig, un, *u; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
179 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
180 u = (gfloat *) g_malloc(n * sizeof(gfloat)); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
181 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
182 y2[0] = u[0] = 0.0; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
183 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
184 for (i = 1; i < n - 1; i++) { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
185 sig = ((gfloat) x[i] - x[i - 1]) / ((gfloat) x[i + 1] - x[i - 1]); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
186 p = sig * y2[i - 1] + 2.0; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
187 y2[i] = (sig - 1.0) / p; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
188 u[i] = |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
189 (((gfloat) y[i + 1] - y[i]) / (x[i + 1] - x[i])) - |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
190 (((gfloat) y[i] - y[i - 1]) / (x[i] - x[i - 1])); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
191 u[i] = (6.0 * u[i] / (x[i + 1] - x[i - 1]) - sig * u[i - 1]) / p; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
192 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
193 qn = un = 0.0; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
194 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
195 y2[n - 1] = (un - qn * u[n - 2]) / (qn * y2[n - 2] + 1.0); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
196 for (k = n - 2; k >= 0; k--) |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
197 y2[k] = y2[k] * y2[k + 1] + u[k]; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
198 g_free(u); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
199 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
200 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
201 gfloat |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
202 eval_spline(gfloat xa[], gfloat ya[], gfloat y2a[], gint n, gfloat x) |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
203 { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
204 gint klo, khi, k; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
205 gfloat h, b, a; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
206 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
207 klo = 0; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
208 khi = n - 1; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
209 while (khi - klo > 1) { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
210 k = (khi + klo) >> 1; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
211 if (xa[k] > x) |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
212 khi = k; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
213 else |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
214 klo = k; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
215 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
216 h = xa[khi] - xa[klo]; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
217 a = (xa[khi] - x) / h; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
218 b = (x - xa[klo]) / h; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
219 return (a * ya[klo] + b * ya[khi] + |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
220 ((a * a * a - a) * y2a[klo] + |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
221 (b * b * b - b) * y2a[khi]) * (h * h) / 6.0); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
222 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
223 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
224 static gboolean ui_skinned_equalizer_graph_expose(GtkWidget *widget, GdkEventExpose *event) { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
225 g_return_val_if_fail (widget != NULL, FALSE); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
226 g_return_val_if_fail (UI_SKINNED_IS_EQUALIZER_GRAPH (widget), FALSE); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
227 g_return_val_if_fail (event != NULL, FALSE); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
228 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
229 UiSkinnedEqualizerGraph *equalizer_graph = UI_SKINNED_EQUALIZER_GRAPH (widget); |
4119 | 230 g_return_val_if_fail (equalizer_graph->width > 0 && equalizer_graph->height > 0, FALSE); |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
231 |
4214
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
232 GdkPixbuf *obj = NULL; |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
233 |
4214
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
234 obj = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, equalizer_graph->width, equalizer_graph->height); |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
235 |
4214
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
236 guint32 cols[19], rowstride; |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
237 gint i, y, ymin, ymax, py = 0; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
238 gfloat x[] = { 0, 11, 23, 35, 47, 59, 71, 83, 97, 109 }, yf[10]; |
4214
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
239 guchar* pixels, *p; |
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
240 gint n_channels; |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
241 /* |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
242 * This avoids the init_spline() function to be inlined. |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
243 * Inlining the function caused troubles when compiling with |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
244 * `-O' (at least on FreeBSD). |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
245 */ |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
246 void (*__init_spline) (gfloat *, gfloat *, gint, gfloat *) = init_spline; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
247 |
4214
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
248 skin_draw_pixbuf(widget, bmp_active_skin, obj, equalizer_graph->skin_index, 0, 294, 0, 0, |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
249 equalizer_graph->width, equalizer_graph->height); |
4214
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
250 skin_draw_pixbuf(widget, bmp_active_skin, obj, equalizer_graph->skin_index, 0, 314, |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
251 0, 9 + ((cfg.equalizer_preamp * 9) / 20), |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
252 equalizer_graph->width, 1); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
253 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
254 skin_get_eq_spline_colors(bmp_active_skin, cols); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
255 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
256 __init_spline(x, cfg.equalizer_bands, 10, yf); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
257 for (i = 0; i < 109; i++) { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
258 y = 9 - |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
259 (gint) ((eval_spline(x, cfg.equalizer_bands, yf, 10, i) * |
4310 | 260 9.0) / EQUALIZER_MAX_GAIN); |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
261 if (y < 0) |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
262 y = 0; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
263 if (y > 18) |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
264 y = 18; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
265 if (!i) |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
266 py = y; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
267 if (y < py) { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
268 ymin = y; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
269 ymax = py; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
270 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
271 else { |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
272 ymin = py; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
273 ymax = y; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
274 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
275 py = y; |
4197
bc51ab3fecd5
remove pixmap from SkinPixmap
Tomasz Mon <desowin@gmail.com>
parents:
4119
diff
changeset
|
276 |
4214
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
277 pixels = gdk_pixbuf_get_pixels(obj); |
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
278 rowstride = gdk_pixbuf_get_rowstride(obj); |
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
279 n_channels = gdk_pixbuf_get_n_channels(obj); |
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
280 |
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
281 for (y = ymin; y <= ymax; y++) |
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
282 { |
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
283 p = pixels + (y * rowstride) + (( i + 2) * n_channels); |
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
284 p[0] = (cols[y] & 0xff0000) >> 16; |
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
285 p[1] = (cols[y] & 0x00ff00) >> 8; |
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
286 p[2] = (cols[y] & 0x0000ff); |
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
287 /* do we really need to treat the alpha channel? */ |
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
288 /*if (n_channels == 4) |
41655c090c53
converted ui_skinned_equalizer_graph to GdkPixbuf
Cristi Magherusan <majeru@atheme.org>
parents:
4197
diff
changeset
|
289 p[3] = cols[y] >> 24;*/ |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
290 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
291 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
292 |
4218
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
293 ui_skinned_widget_draw(widget, obj, equalizer_graph->width, equalizer_graph->height, equalizer_graph->scaled); |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
294 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
295 g_object_unref(obj); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
296 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
297 return FALSE; |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
298 } |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
299 |
4218
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
300 static void ui_skinned_equalizer_graph_toggle_scaled(UiSkinnedEqualizerGraph *equalizer_graph) { |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
301 GtkWidget *widget = GTK_WIDGET (equalizer_graph); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
302 |
4218
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
303 equalizer_graph->scaled = !equalizer_graph->scaled; |
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
304 gtk_widget_set_size_request(widget, equalizer_graph->width*(equalizer_graph->scaled ? cfg.scale_factor : 1), |
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4214
diff
changeset
|
305 equalizer_graph->height*(equalizer_graph->scaled ? cfg.scale_factor : 1)); |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
306 |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
307 gtk_widget_queue_draw(GTK_WIDGET(equalizer_graph)); |
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
308 } |