annotate audacious/widgets/vis.c @ 1709:950b24509828 trunk

[svn] - actually on second thought, i don't see the point in this
author nenolod
date Fri, 15 Sep 2006 20:10:47 -0700
parents a6e6d3500c13
children 1d9c1026d9f8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
3 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
4 * Based on XMMS:
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
6 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
10 * (at your option) any later version.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
11 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
16 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
20 */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
21
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
22 #include "widgetcore.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
23
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
24 #include <glib.h>
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
25 #include <gdk/gdk.h>
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
26 #include <string.h>
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
27
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
28 #include "main.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
29 #include "skin.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
30 #include "widget.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
31
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
32 static const gfloat vis_afalloff_speeds[] = { 0.34, 0.5, 1.0, 1.3, 1.6 };
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
33 static const gfloat vis_pfalloff_speeds[] = { 1.2, 1.3, 1.4, 1.5, 1.6 };
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
34 static const gint vis_redraw_delays[] = { 1, 2, 4, 8 };
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
35 static const guint8 vis_scope_colors[] =
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
36 { 21, 21, 20, 20, 19, 19, 18, 19, 19, 20, 20, 21, 21 };
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
37
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
38 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
39 vis_timeout_func(Vis * vis, guchar * data)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
40 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
41 static GTimer *timer = NULL;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
42 gulong micros = 9999999;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
43 gboolean falloff = FALSE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
44 gint i;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
45
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
46 if (!timer) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
47 timer = g_timer_new();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
48 g_timer_start(timer);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
49 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
50 else {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
51 g_timer_elapsed(timer, &micros);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
52 if (micros > 14000)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
53 g_timer_reset(timer);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
54
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
55 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
56
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
57 if (cfg.vis_type == VIS_ANALYZER) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
58 if (micros > 14000)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
59 falloff = TRUE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
60 if (data || falloff) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
61 for (i = 0; i < 75; i++) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
62 if (data && data[i] > vis->vs_data[i]) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
63 vis->vs_data[i] = data[i];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
64 if (vis->vs_data[i] > vis->vs_peak[i]) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
65 vis->vs_peak[i] = vis->vs_data[i];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
66 vis->vs_peak_speed[i] = 0.01;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
67
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
68 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
69 else if (vis->vs_peak[i] > 0.0) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
70 vis->vs_peak[i] -= vis->vs_peak_speed[i];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
71 vis->vs_peak_speed[i] *=
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
72 vis_pfalloff_speeds[cfg.peaks_falloff];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
73 if (vis->vs_peak[i] < vis->vs_data[i])
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
74 vis->vs_peak[i] = vis->vs_data[i];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
75 if (vis->vs_peak[i] < 0.0)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
76 vis->vs_peak[i] = 0.0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
77 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
78 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
79 else if (falloff) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
80 if (vis->vs_data[i] > 0.0) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
81 vis->vs_data[i] -=
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
82 vis_afalloff_speeds[cfg.analyzer_falloff];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
83 if (vis->vs_data[i] < 0.0)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
84 vis->vs_data[i] = 0.0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
85 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
86 if (vis->vs_peak[i] > 0.0) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
87 vis->vs_peak[i] -= vis->vs_peak_speed[i];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
88 vis->vs_peak_speed[i] *=
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
89 vis_pfalloff_speeds[cfg.peaks_falloff];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
90 if (vis->vs_peak[i] < vis->vs_data[i])
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
91 vis->vs_peak[i] = vis->vs_data[i];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
92 if (vis->vs_peak[i] < 0.0)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
93 vis->vs_peak[i] = 0.0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
94 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
95 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
96 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
97 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
98 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
99 else if (data) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
100 for (i = 0; i < 75; i++)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
101 vis->vs_data[i] = data[i];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
102 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
103
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
104 if (micros > 14000) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
105 if (!vis->vs_refresh_delay) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
106 vis_draw((Widget *) vis);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
107 vis->vs_refresh_delay = vis_redraw_delays[cfg.vis_refresh];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
108
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
109 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
110 vis->vs_refresh_delay--;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
111 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
112 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
113
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
114 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
115 vis_draw(Widget * w)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
116 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
117 Vis *vis = (Vis *) w;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
118 gint x, y, h = 0, h2;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
119 guchar vis_color[24][3];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
120 guchar rgb_data[152 * 32], *ptr, c;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
121 guint32 colors[24];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
122 GdkRgbCmap *cmap;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
123
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
124 if (!vis->vs_widget.visible)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
125 return;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
126
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
127 skin_get_viscolor(bmp_active_skin, vis_color);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
128 for (y = 0; y < 24; y++) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
129 colors[y] =
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
130 vis_color[y][0] << 16 | vis_color[y][1] << 8 | vis_color[y][2];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
131 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
132 cmap = gdk_rgb_cmap_new(colors, 24);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
133
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
134 memset(rgb_data, 0, 76 * 16);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
135 for (y = 1; y < 16; y += 2) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
136 ptr = rgb_data + (y * 76);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
137 for (x = 0; x < 76; x += 2, ptr += 2)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
138 *ptr = 1;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
139 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
140 if (cfg.vis_type == VIS_ANALYZER) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
141 for (x = 0; x < 75; x++) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
142 if (cfg.analyzer_type == ANALYZER_BARS && (x % 4) == 0)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
143 h = vis->vs_data[x >> 2];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
144 else if (cfg.analyzer_type == ANALYZER_LINES)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
145 h = vis->vs_data[x];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
146 if (h && (cfg.analyzer_type == ANALYZER_LINES ||
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
147 (x % 4) != 3)) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
148 ptr = rgb_data + ((16 - h) * 76) + x;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
149 switch (cfg.analyzer_mode) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
150 case ANALYZER_NORMAL:
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
151 for (y = 0; y < h; y++, ptr += 76)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
152 *ptr = 18 - h + y;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
153 break;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
154 case ANALYZER_FIRE:
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
155 for (y = 0; y < h; y++, ptr += 76)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
156 *ptr = y + 2;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
157 break;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
158 case ANALYZER_VLINES:
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
159 for (y = 0; y < h; y++, ptr += 76)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
160 *ptr = 18 - h;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
161 break;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
162 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
163 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
164 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
165 if (cfg.analyzer_peaks) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
166 for (x = 0; x < 75; x++) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
167 if (cfg.analyzer_type == ANALYZER_BARS && (x % 4) == 0)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
168 h = vis->vs_peak[x >> 2];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
169 else if (cfg.analyzer_type == ANALYZER_LINES)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
170 h = vis->vs_peak[x];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
171 if (h
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
172 && (cfg.analyzer_type == ANALYZER_LINES
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
173 || (x % 4) != 3))
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
174 rgb_data[(16 - h) * 76 + x] = 23;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
175 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
176 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
177 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
178 else if (cfg.vis_type == VIS_SCOPE) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
179 for (x = 0; x < 75; x++) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
180 switch (cfg.scope_mode) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
181 case SCOPE_DOT:
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
182 h = vis->vs_data[x];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
183 ptr = rgb_data + ((15 - h) * 76) + x;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
184 *ptr = vis_scope_colors[h];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
185 break;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
186 case SCOPE_LINE:
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
187 if (x != 74) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
188 h = 15 - vis->vs_data[x];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
189 h2 = 15 - vis->vs_data[x + 1];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
190 if (h > h2) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
191 y = h;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
192 h = h2;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
193 h2 = y;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
194 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
195 ptr = rgb_data + (h * 76) + x;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
196 for (y = h; y <= h2; y++, ptr += 76)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
197 *ptr = vis_scope_colors[y - 3];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
198
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
199 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
200 else {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
201 h = 15 - vis->vs_data[x];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
202 ptr = rgb_data + (h * 76) + x;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
203 *ptr = vis_scope_colors[h];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
204 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
205 break;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
206 case SCOPE_SOLID:
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
207 h = 15 - vis->vs_data[x];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
208 h2 = 9;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
209 c = vis_scope_colors[(gint) vis->vs_data[x]];
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
210 if (h > h2) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
211 y = h;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
212 h = h2;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
213 h2 = y;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
214 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
215 ptr = rgb_data + (h * 76) + x;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
216 for (y = h; y <= h2; y++, ptr += 76)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
217 *ptr = c;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
218 break;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
219 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
220 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
221 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
222
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
223 /* FIXME: The check "shouldn't" be neccessary? */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
224 /* if (GTK_IS_WINDOW(vis->vs_window)) { */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
225 GDK_THREADS_ENTER();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
226 gdk_draw_indexed_image(vis->vs_window, vis->vs_widget.gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
227 vis->vs_widget.x, vis->vs_widget.y,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
228 vis->vs_widget.width, vis->vs_widget.height,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
229 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
230 76, cmap);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
231 GDK_THREADS_LEAVE();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
232 /* } else {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
233 vis->vs_window = mainwin->window;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
234 GDK_THREADS_ENTER();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
235 gdk_draw_indexed_image(vis->vs_window, vis->vs_widget.gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
236 vis->vs_widget.x, vis->vs_widget.y,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
237 vis->vs_widget.width, vis->vs_widget.height,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
238 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
239 76, cmap);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
240 GDK_THREADS_LEAVE();
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
241 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
242 */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
243
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
244 gdk_rgb_cmap_free(cmap);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
245 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
246
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
247 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
248 vis_clear_data(Vis * vis)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
249 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
250 gint i;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
251
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
252 if (!vis)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
253 return;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
254
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
255 for (i = 0; i < 75; i++) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
256 vis->vs_data[i] = (cfg.vis_type == VIS_SCOPE) ? 6 : 0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
257 vis->vs_peak[i] = 0;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
258 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
259 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
260
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
261 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
262 vis_clear(Vis * vis)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
263 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
264 gdk_window_clear_area(vis->vs_window, vis->vs_widget.x,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
265 vis->vs_widget.y, vis->vs_widget.width,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
266 vis->vs_widget.height);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
267 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
268
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
269 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
270 vis_set_window(Vis * vis, GdkWindow * window)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
271 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
272 vis->vs_window = window;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
273 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
274
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
275 Vis *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
276 create_vis(GList ** wlist,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
277 GdkPixmap * parent,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
278 GdkWindow * window,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
279 GdkGC * gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
280 gint x, gint y,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
281 gint width)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
282 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
283 Vis *vis;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
284
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
285 vis = g_new0(Vis, 1);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
286
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
287 widget_init(&vis->vs_widget, parent, gc, x, y, width, 16, 1);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
288 widget_list_add(wlist, WIDGET(vis));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
289
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
290 return vis;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
291 }