annotate src/skins/ui_skinned_equalizer_graph.c @ 2635:b990e7eb0c25

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