Mercurial > audlegacy
annotate src/audacious/ui_svis.c @ 4307:cfaecedace4e
importing of winamp EQ presets library
| author | Eugene Zagidullin <e.asphyx@gmail.com> |
|---|---|
| date | Mon, 25 Feb 2008 02:29:28 +0300 |
| parents | e6ef8287d115 |
| children | de33c83aa06f |
| rev | line source |
|---|---|
| 3054 | 1 /* |
| 2 * Audacious - a cross-platform multimedia player | |
| 3 * Copyright (c) 2007 Audacious development team. | |
| 4 * | |
| 5 * Based on: | |
| 6 * BMP - Cross-platform multimedia player | |
| 7 * Copyright (C) 2003-2004 BMP development team. | |
| 8 * XMMS: | |
| 9 * Copyright (C) 1998-2003 XMMS development team. | |
| 10 * | |
| 11 * This program is free software; you can redistribute it and/or modify | |
| 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:
3054
diff
changeset
|
13 * the Free Software Foundation; under version 3 of the License. |
| 3054 | 14 * |
| 15 * This program is distributed in the hope that it will be useful, | |
| 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 * GNU General Public License for more details. | |
| 19 * | |
| 20 * You should have received a copy of the GNU General Public License | |
|
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3054
diff
changeset
|
21 * along with this program. If not, see <http://www.gnu.org/licenses>. |
|
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
22 * |
|
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
23 * The Audacious team does not consider modular code linking to |
|
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
24 * Audacious or using our public API to be a derived work. |
| 3054 | 25 */ |
| 26 | |
| 3251 | 27 #include "skin.h" |
| 3054 | 28 #include "ui_svis.h" |
| 29 #include "ui_vis.h" | |
| 30 #include "main.h" | |
| 31 #include "util.h" | |
| 32 #include "strings.h" | |
| 33 #include "playback.h" | |
| 34 #include <string.h> | |
| 35 #include <ctype.h> | |
| 36 #include <gtk/gtkmain.h> | |
| 37 #include <gtk/gtkmarshal.h> | |
| 38 #include <gtk/gtkimage.h> | |
| 39 | |
| 40 #define UI_TYPE_SVIS (ui_svis_get_type()) | |
| 41 | |
| 42 static gint svis_redraw_delays[] = { 1, 2, 4, 8 }; | |
| 43 | |
| 44 /* FIXME: Are the svis_scope_colors correct? */ | |
| 45 static guint8 svis_scope_colors[] = { 20, 19, 18, 19, 20 }; | |
| 46 static guint8 svis_vu_normal_colors[] = { 17, 17, 17, 12, 12, 12, 2, 2 }; | |
| 47 | |
| 48 #define DRAW_DS_PIXEL(ptr,value) \ | |
| 49 *(ptr) = (value); \ | |
| 50 *((ptr) + 1) = (value); \ | |
| 51 *((ptr) + 76) = (value); \ | |
| 52 *((ptr) + 77) = (value); | |
| 53 | |
| 54 #define SVIS_HEIGHT 5 | |
| 55 #define SVIS_WIDTH 38 | |
| 56 | |
| 57 enum { | |
| 58 DOUBLED, | |
| 59 LAST_SIGNAL | |
| 60 }; | |
| 61 | |
| 62 static void ui_svis_class_init (UiSVisClass *klass); | |
| 63 static void ui_svis_init (UiSVis *svis); | |
| 64 static void ui_svis_destroy (GtkObject *object); | |
| 65 static void ui_svis_realize (GtkWidget *widget); | |
| 66 static void ui_svis_unrealize (GtkWidget *widget); | |
| 67 static void ui_svis_map (GtkWidget *widget); | |
| 68 static void ui_svis_unmap (GtkWidget *widget); | |
| 69 static void ui_svis_size_request (GtkWidget *widget, GtkRequisition *requisition); | |
| 70 static void ui_svis_size_allocate (GtkWidget *widget, GtkAllocation *allocation); | |
| 71 static gboolean ui_svis_expose (GtkWidget *widget, GdkEventExpose *event); | |
|
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
72 static void ui_svis_toggle_scaled (UiSVis *svis); |
| 3054 | 73 |
| 74 static GtkWidgetClass *parent_class = NULL; | |
| 75 static guint vis_signals[LAST_SIGNAL] = { 0 }; | |
| 76 | |
| 77 GType ui_svis_get_type() { | |
| 78 static GType vis_type = 0; | |
| 79 if (!vis_type) { | |
| 80 static const GTypeInfo vis_info = { | |
| 81 sizeof (UiSVisClass), | |
| 82 NULL, | |
| 83 NULL, | |
| 84 (GClassInitFunc) ui_svis_class_init, | |
| 85 NULL, | |
| 86 NULL, | |
| 87 sizeof (UiSVis), | |
| 88 0, | |
| 89 (GInstanceInitFunc) ui_svis_init, | |
| 90 }; | |
| 91 vis_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSVis", &vis_info, 0); | |
| 92 } | |
| 93 | |
| 94 return vis_type; | |
| 95 } | |
| 96 | |
| 97 static void ui_svis_class_init(UiSVisClass *klass) { | |
| 98 GtkObjectClass *object_class; | |
| 99 GtkWidgetClass *widget_class; | |
| 100 | |
| 101 object_class = (GtkObjectClass*) klass; | |
| 102 widget_class = (GtkWidgetClass*) klass; | |
| 103 parent_class = gtk_type_class (gtk_widget_get_type ()); | |
| 104 | |
| 105 object_class->destroy = ui_svis_destroy; | |
| 106 | |
| 107 widget_class->realize = ui_svis_realize; | |
| 108 widget_class->unrealize = ui_svis_unrealize; | |
| 109 widget_class->map = ui_svis_map; | |
| 110 widget_class->unmap = ui_svis_unmap; | |
| 111 widget_class->expose_event = ui_svis_expose; | |
| 112 widget_class->size_request = ui_svis_size_request; | |
| 113 widget_class->size_allocate = ui_svis_size_allocate; | |
| 114 | |
|
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
115 klass->scaled = ui_svis_toggle_scaled; |
| 3054 | 116 |
| 117 vis_signals[DOUBLED] = | |
|
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
118 g_signal_new ("toggle-scaled", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
|
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
119 G_STRUCT_OFFSET (UiSVisClass, scaled), NULL, NULL, |
| 3054 | 120 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); |
| 121 } | |
| 122 | |
| 123 static void ui_svis_init(UiSVis *svis) { | |
| 124 | |
| 125 } | |
| 126 | |
| 127 GtkWidget* ui_svis_new(GtkWidget *fixed, gint x, gint y) { | |
| 128 UiSVis *svis = g_object_new (ui_svis_get_type (), NULL); | |
| 129 | |
| 130 svis->x = x; | |
| 131 svis->y = y; | |
| 132 | |
| 133 svis->width = SVIS_WIDTH; | |
| 134 svis->height = SVIS_HEIGHT; | |
| 135 | |
| 136 svis->fixed = fixed; | |
|
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
137 svis->scaled = FALSE; |
| 3054 | 138 |
| 139 svis->visible_window = TRUE; | |
| 140 svis->event_window = NULL; | |
| 141 | |
| 142 gtk_fixed_put(GTK_FIXED(svis->fixed), GTK_WIDGET(svis), svis->x, svis->y); | |
| 143 | |
| 144 return GTK_WIDGET(svis); | |
| 145 } | |
| 146 | |
| 147 static void ui_svis_destroy(GtkObject *object) { | |
| 148 UiSVis *svis; | |
| 149 | |
| 150 g_return_if_fail (object != NULL); | |
| 151 g_return_if_fail (UI_IS_SVIS (object)); | |
| 152 | |
| 153 svis = UI_SVIS (object); | |
| 154 | |
| 155 if (GTK_OBJECT_CLASS (parent_class)->destroy) | |
| 156 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); | |
| 157 } | |
| 158 | |
| 159 static void ui_svis_realize(GtkWidget *widget) { | |
| 160 UiSVis *svis; | |
| 161 GdkWindowAttr attributes; | |
| 162 gint attributes_mask; | |
| 163 | |
| 164 g_return_if_fail (widget != NULL); | |
| 165 g_return_if_fail (UI_IS_SVIS(widget)); | |
| 166 | |
| 167 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); | |
| 168 svis = UI_SVIS(widget); | |
| 169 | |
| 170 attributes.x = widget->allocation.x; | |
| 171 attributes.y = widget->allocation.y; | |
| 172 attributes.width = widget->allocation.width; | |
| 173 attributes.height = widget->allocation.height; | |
| 174 attributes.window_type = GDK_WINDOW_CHILD; | |
| 175 attributes.event_mask = gtk_widget_get_events(widget); | |
| 176 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK; | |
| 177 | |
| 178 if (svis->visible_window) | |
| 179 { | |
| 180 attributes.visual = gtk_widget_get_visual(widget); | |
| 181 attributes.colormap = gtk_widget_get_colormap(widget); | |
| 182 attributes.wclass = GDK_INPUT_OUTPUT; | |
| 183 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; | |
| 184 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); | |
| 185 GTK_WIDGET_UNSET_FLAGS(widget, GTK_NO_WINDOW); | |
| 186 gdk_window_set_user_data(widget->window, widget); | |
| 187 } | |
| 188 else | |
| 189 { | |
| 190 widget->window = gtk_widget_get_parent_window (widget); | |
| 191 g_object_ref (widget->window); | |
| 192 | |
| 193 attributes.wclass = GDK_INPUT_ONLY; | |
| 194 attributes_mask = GDK_WA_X | GDK_WA_Y; | |
| 195 svis->event_window = gdk_window_new (widget->window, &attributes, attributes_mask); | |
| 196 GTK_WIDGET_SET_FLAGS (widget, GTK_NO_WINDOW); | |
| 197 gdk_window_set_user_data(svis->event_window, widget); | |
| 198 } | |
| 199 | |
| 200 widget->style = gtk_style_attach(widget->style, widget->window); | |
| 201 } | |
| 202 | |
| 203 static void ui_svis_unrealize(GtkWidget *widget) { | |
| 204 UiSVis *svis; | |
| 205 svis = UI_SVIS(widget); | |
| 206 | |
| 207 if ( svis->event_window != NULL ) | |
| 208 { | |
| 209 gdk_window_set_user_data( svis->event_window , NULL ); | |
| 210 gdk_window_destroy( svis->event_window ); | |
| 211 svis->event_window = NULL; | |
| 212 } | |
| 213 | |
| 214 if (GTK_WIDGET_CLASS (parent_class)->unrealize) | |
| 215 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); | |
| 216 } | |
| 217 | |
| 218 static void ui_svis_map(GtkWidget *widget) | |
| 219 { | |
| 220 UiSVis *svis; | |
| 221 svis = UI_SVIS(widget); | |
| 222 | |
| 223 if (svis->event_window != NULL) | |
| 224 gdk_window_show (svis->event_window); | |
| 225 | |
| 226 if (GTK_WIDGET_CLASS (parent_class)->map) | |
| 227 (* GTK_WIDGET_CLASS (parent_class)->map) (widget); | |
| 228 } | |
| 229 | |
| 230 static void ui_svis_unmap (GtkWidget *widget) | |
| 231 { | |
| 232 UiSVis *svis; | |
| 233 svis = UI_SVIS(widget); | |
| 234 | |
| 235 if (svis->event_window != NULL) | |
| 236 gdk_window_hide (svis->event_window); | |
| 237 | |
| 238 if (GTK_WIDGET_CLASS (parent_class)->unmap) | |
| 239 (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget); | |
| 240 } | |
| 241 | |
| 242 static void ui_svis_size_request(GtkWidget *widget, GtkRequisition *requisition) { | |
| 243 UiSVis *svis = UI_SVIS(widget); | |
| 244 | |
|
4220
e6ef8287d115
fixed menurow and some obvious svis issues from svis, but IMHO ui_svis needs a
Cristi Magherusan <majeru@atheme.org>
parents:
4218
diff
changeset
|
245 requisition->width = svis->width * (svis->scaled ? cfg.scale_factor : 1); |
|
e6ef8287d115
fixed menurow and some obvious svis issues from svis, but IMHO ui_svis needs a
Cristi Magherusan <majeru@atheme.org>
parents:
4218
diff
changeset
|
246 requisition->height = svis->height*(svis->scaled ? cfg.scale_factor : 1); |
| 3054 | 247 } |
| 248 | |
| 249 static void ui_svis_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { | |
| 250 UiSVis *svis = UI_SVIS (widget); | |
| 251 | |
| 252 widget->allocation = *allocation; | |
|
4220
e6ef8287d115
fixed menurow and some obvious svis issues from svis, but IMHO ui_svis needs a
Cristi Magherusan <majeru@atheme.org>
parents:
4218
diff
changeset
|
253 widget->allocation.x *= (svis->scaled ? cfg.scale_factor : 1 ); |
|
e6ef8287d115
fixed menurow and some obvious svis issues from svis, but IMHO ui_svis needs a
Cristi Magherusan <majeru@atheme.org>
parents:
4218
diff
changeset
|
254 widget->allocation.y *= (svis->scaled ? cfg.scale_factor : 1); |
| 3054 | 255 if (GTK_WIDGET_REALIZED (widget)) |
| 256 { | |
| 257 if (svis->event_window != NULL) | |
| 258 gdk_window_move_resize(svis->event_window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); | |
| 259 else | |
| 260 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); | |
| 261 } | |
| 262 | |
|
4218
f1074a07ec09
mostly works, but the VIS is broken, and the eq window is too large...more bugs
Cristi Magherusan <majeru@atheme.org>
parents:
4216
diff
changeset
|
263 svis->x = widget->allocation.x/(svis->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:
4216
diff
changeset
|
264 svis->y = widget->allocation.y/(svis->scaled ? cfg.scale_factor : 1); |
| 3054 | 265 } |
| 266 | |
| 267 static gboolean ui_svis_expose(GtkWidget *widget, GdkEventExpose *event) { | |
| 268 g_return_val_if_fail (widget != NULL, FALSE); | |
| 269 g_return_val_if_fail (UI_IS_SVIS (widget), FALSE); | |
| 270 g_return_val_if_fail (event != NULL, FALSE); | |
| 271 | |
| 272 UiSVis *svis = UI_SVIS (widget); | |
| 273 | |
| 274 gint x, y, h; | |
| 275 guchar svis_color[24][3]; | |
| 276 guchar rgb_data[SVIS_WIDTH * 2 * SVIS_HEIGHT * 2], *ptr, c; | |
| 277 guint32 colors[24]; | |
| 278 GdkRgbCmap *cmap; | |
| 279 | |
| 280 if (!GTK_WIDGET_VISIBLE(widget)) | |
| 281 return FALSE; | |
| 282 | |
| 283 if (!svis->visible_window) | |
| 284 return FALSE; | |
| 285 | |
| 286 skin_get_viscolor(bmp_active_skin, svis_color); | |
| 287 for (y = 0; y < 24; y++) { | |
| 288 colors[y] = | |
| 289 svis_color[y][0] << 16 | svis_color[y][1] << 8 | svis_color[y][2]; | |
| 290 } | |
| 291 cmap = gdk_rgb_cmap_new(colors, 24); | |
| 292 | |
|
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
293 if (!cfg.scaled) { |
| 3054 | 294 memset(rgb_data, 0, SVIS_WIDTH * SVIS_HEIGHT); |
| 295 if (cfg.vis_type == VIS_ANALYZER && !playback_get_paused() && playback_get_playing()){ | |
| 296 for(y=0; y < SVIS_HEIGHT; y++){ | |
| 297 if (cfg.analyzer_type == ANALYZER_BARS){ | |
| 298 for(x=0;x< SVIS_WIDTH; x++){ | |
| 299 if(svis->data[x] > y << 1) | |
| 300 { | |
| 301 rgb_data[x*3+ (SVIS_HEIGHT - y) * SVIS_WIDTH] = 23; | |
| 302 rgb_data[x*3+1 + (SVIS_HEIGHT - y) * SVIS_WIDTH] = 23; | |
| 303 | |
| 304 } | |
| 305 } | |
| 306 } | |
| 307 else{ | |
| 308 for(x=0;x< SVIS_WIDTH; x++){ | |
| 309 if(svis->data[x] > y << 1) | |
| 310 { | |
| 311 rgb_data[x + (SVIS_HEIGHT - y) * SVIS_WIDTH] = 23; | |
| 312 } | |
| 313 } | |
| 314 } | |
| 315 } | |
| 316 } | |
| 317 else if (cfg.vis_type == VIS_VOICEPRINT){ | |
| 318 switch (cfg.vu_mode) { | |
| 319 case VU_NORMAL: | |
| 320 for (y = 0; y < 2; y++) { | |
| 321 ptr = rgb_data + ((y * 3) * 38); | |
| 322 h = (svis->data[y] * 7) / 37; | |
| 323 for (x = 0; x < h; x++, ptr += 5) { | |
| 324 c = svis_vu_normal_colors[x]; | |
| 325 *(ptr) = c; | |
| 326 *(ptr + 1) = c; | |
| 327 *(ptr + 2) = c; | |
| 328 *(ptr + 38) = c; | |
| 329 *(ptr + 39) = c; | |
| 330 *(ptr + 40) = c; | |
| 331 } | |
| 332 } | |
| 333 break; | |
| 334 case VU_SMOOTH: | |
| 335 for (y = 0; y < 2; y++) { | |
| 336 ptr = rgb_data + ((y * 3) * SVIS_WIDTH); | |
| 337 for (x = 0; x < svis->data[y]; x++, ptr++) { | |
| 338 c = 17 - ((x * 15) / 37); | |
| 339 *(ptr) = c; | |
| 340 *(ptr + 38) = c; | |
| 341 } | |
| 342 } | |
| 343 break; | |
| 344 } | |
| 345 } | |
| 346 else if (cfg.vis_type == VIS_SCOPE) { | |
| 347 for (x = 0; x < 38; x++) { | |
| 348 h = svis->data[x << 1] / 3; | |
| 349 ptr = rgb_data + ((4 - h) * 38) + x; | |
| 350 *ptr = svis_scope_colors[h]; | |
| 351 } | |
| 352 } | |
| 353 | |
| 354 } | |
|
4220
e6ef8287d115
fixed menurow and some obvious svis issues from svis, but IMHO ui_svis needs a
Cristi Magherusan <majeru@atheme.org>
parents:
4218
diff
changeset
|
355 else { /*svis scaling, this needs some work, since a lot of stuff is hardcoded --majeru*/ |
| 3054 | 356 |
|
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
357 memset(rgb_data, 0, SVIS_WIDTH * cfg.scale_factor * SVIS_HEIGHT * cfg.scale_factor); |
|
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
358 if (cfg.vis_type == VIS_ANALYZER && !playback_get_paused() && playback_get_playing()){ |
| 3054 | 359 for(y=0; y < SVIS_HEIGHT; y++){ |
| 360 if (cfg.analyzer_type == ANALYZER_BARS){ | |
| 361 for(x=0;x< SVIS_WIDTH; x++){ | |
| 362 if(svis->data[x] > y << 1) | |
| 363 { | |
|
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
364 ptr = rgb_data + x * 6 + (SVIS_HEIGHT * 2 - y * 2) * SVIS_WIDTH *2; |
| 3054 | 365 DRAW_DS_PIXEL(ptr, 23); |
| 366 DRAW_DS_PIXEL(ptr + 2, 23); | |
| 367 } | |
| 368 } | |
| 369 } | |
| 370 else{ | |
| 371 for(x=0;x< SVIS_WIDTH; x++){ | |
| 372 if(svis->data[x] > y << 1) | |
| 373 { | |
| 374 ptr = rgb_data + x * 2 + (SVIS_HEIGHT * 2 - y * 2) * SVIS_WIDTH * 2; | |
| 375 DRAW_DS_PIXEL(ptr, 23); | |
| 376 } | |
| 377 } | |
| 378 } | |
| 379 } | |
| 380 } | |
| 381 else if (cfg.vis_type == VIS_VOICEPRINT){ | |
| 382 switch (cfg.vu_mode) { | |
| 383 case VU_NORMAL: | |
| 384 for (y = 0; y < 2; y++) { | |
| 385 ptr = rgb_data + ((y * 3) * 152); | |
| 386 h = (svis->data[y] * 8) / 37; | |
| 387 for (x = 0; x < h; x++, ptr += 10) { | |
| 388 c = svis_vu_normal_colors[x]; | |
| 389 DRAW_DS_PIXEL(ptr, c); | |
| 390 DRAW_DS_PIXEL(ptr + 2, c); | |
| 391 DRAW_DS_PIXEL(ptr + 4, c); | |
| 392 DRAW_DS_PIXEL(ptr + 152, c); | |
| 393 DRAW_DS_PIXEL(ptr + 154, c); | |
| 394 DRAW_DS_PIXEL(ptr + 156, c); | |
| 395 } | |
| 396 } | |
| 397 break; | |
| 398 case VU_SMOOTH: | |
| 399 for (y = 0; y < 2; y++) { | |
| 400 ptr = rgb_data + ((y * 3) * 152); | |
| 401 for (x = 0; x < svis->data[y]; x++, ptr += 2) { | |
| 402 c = 17 - ((x * 15) / 37); | |
| 403 DRAW_DS_PIXEL(ptr, c); | |
| 404 DRAW_DS_PIXEL(ptr + 152, c); | |
| 405 } | |
| 406 } | |
| 407 break; | |
| 408 } | |
| 409 } | |
| 410 else if (cfg.vis_type == VIS_SCOPE) { | |
| 411 for (x = 0; x < 38; x++) { | |
| 412 h = svis->data[x << 1] / 3; | |
| 413 ptr = rgb_data + ((4 - h) * 152) + (x << 1); | |
| 414 *ptr = svis_scope_colors[h]; | |
| 415 *(ptr + 1) = svis_scope_colors[h]; | |
| 416 *(ptr + 76) = svis_scope_colors[h]; | |
| 417 *(ptr + 77) = svis_scope_colors[h]; | |
| 418 } | |
| 419 } | |
| 420 | |
|
4220
e6ef8287d115
fixed menurow and some obvious svis issues from svis, but IMHO ui_svis needs a
Cristi Magherusan <majeru@atheme.org>
parents:
4218
diff
changeset
|
421 |
| 3054 | 422 } |
| 423 | |
| 424 GdkPixmap *obj = NULL; | |
| 425 GdkGC *gc; | |
|
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
426 obj = gdk_pixmap_new(NULL, svis->width* ( svis->scaled ? cfg.scale_factor : 1), |
|
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
427 svis->height*(svis->scaled ? cfg.scale_factor : 1), gdk_rgb_get_visual()->depth); |
| 3054 | 428 gc = gdk_gc_new(obj); |
| 429 | |
|
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
430 if (!svis->scaled) { |
| 3054 | 431 gdk_draw_indexed_image(obj, gc, 0, 0, svis->width, svis->height, |
| 432 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data, | |
| 433 38, cmap); | |
| 434 } else { | |
| 435 gdk_draw_indexed_image(obj, gc, | |
| 436 0 << 1, 0 << 1, | |
| 437 svis->width << 1, svis->height << 1, | |
| 438 GDK_RGB_DITHER_NONE, (guchar *) rgb_data, | |
| 439 76, cmap); | |
| 440 } | |
| 441 | |
| 442 gdk_rgb_cmap_free(cmap); | |
| 443 gdk_draw_drawable (widget->window, gc, obj, 0, 0, 0, 0, | |
|
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
444 svis->width*(svis->scaled ? cfg.scale_factor : 1), |
|
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
445 svis->height*(svis->scaled ? cfg.scale_factor : 1)); |
| 3054 | 446 g_object_unref(obj); |
| 447 g_object_unref(gc); | |
| 448 | |
| 449 return FALSE; | |
| 450 } | |
| 451 | |
|
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
452 static void ui_svis_toggle_scaled(UiSVis *svis) { |
| 3054 | 453 GtkWidget *widget = GTK_WIDGET (svis); |
|
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
454 svis->scaled = !svis->scaled; |
| 3054 | 455 |
|
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
3251
diff
changeset
|
456 gtk_widget_set_size_request(widget, svis->width* cfg.scale_factor, svis->height * cfg.scale_factor); |
| 3054 | 457 |
| 458 gtk_widget_queue_draw(widget); | |
| 459 } | |
| 460 | |
| 461 void ui_svis_set_visible(GtkWidget *widget, gboolean window_is_visible) | |
| 462 { | |
| 463 UiSVis *svis; | |
| 464 gboolean widget_is_visible; | |
| 465 | |
| 466 g_return_if_fail(UI_IS_SVIS(widget)); | |
| 467 | |
| 468 svis = UI_SVIS (widget); | |
| 469 widget_is_visible = GTK_WIDGET_VISIBLE(widget); | |
| 470 | |
| 471 svis->visible_window = window_is_visible; | |
| 472 | |
| 473 if (GTK_WIDGET_REALIZED (widget)) | |
| 474 { | |
| 475 if ( widget_is_visible ) | |
| 476 gtk_widget_hide(widget); | |
| 477 | |
| 478 gtk_widget_unrealize(widget); | |
| 479 gtk_widget_realize(widget); | |
| 480 | |
| 481 if ( widget_is_visible ) | |
| 482 gtk_widget_show(widget); | |
| 483 } | |
| 484 | |
| 485 if (widget_is_visible) | |
| 486 gtk_widget_queue_resize(widget); | |
| 487 } | |
| 488 | |
| 489 void ui_svis_clear_data(GtkWidget *widget) { | |
| 490 gint i; | |
| 491 | |
| 492 UiSVis *svis = UI_SVIS (widget); | |
| 493 | |
| 494 for (i = 0; i < 75; i++) { | |
| 495 svis->data[i] = (cfg.vis_type == VIS_SCOPE) ? 6 : 0; | |
| 496 } | |
| 497 } | |
| 498 | |
| 499 void ui_svis_timeout_func(GtkWidget *widget, guchar * data) { | |
| 500 UiSVis *svis = UI_SVIS (widget); | |
| 501 static GTimer *timer = NULL; | |
| 502 gulong micros = 9999999; | |
| 503 gboolean falloff = FALSE; | |
| 504 gint i; | |
| 505 | |
| 506 if (!timer) { | |
| 507 timer = g_timer_new(); | |
| 508 g_timer_start(timer); | |
| 509 } | |
| 510 else { | |
| 511 g_timer_elapsed(timer, µs); | |
| 512 if (micros > 14000) | |
| 513 g_timer_reset(timer); | |
| 514 | |
| 515 } | |
| 516 | |
| 517 if (cfg.vis_type == VIS_VOICEPRINT) { | |
| 518 if (micros > 14000) | |
| 519 falloff = TRUE; | |
| 520 | |
| 521 for (i = 0; i < 2; i++) { | |
| 522 if (falloff || data) { | |
| 523 if (data && data[i] > svis->data[i]) | |
| 524 svis->data[i] = data[i]; | |
| 525 else if (falloff) { | |
| 526 if (svis->data[i] >= 2) | |
| 527 svis->data[i] -= 2; | |
| 528 else | |
| 529 svis->data[i] = 0; | |
| 530 } | |
| 531 } | |
| 532 | |
| 533 } | |
| 534 } | |
| 535 else if (data) { | |
| 536 for (i = 0; i < 75; i++) | |
| 537 svis->data[i] = data[i]; | |
| 538 } | |
| 539 | |
| 540 if (micros > 14000) { | |
| 541 if (!svis->refresh_delay) { | |
| 542 gtk_widget_queue_draw(widget); | |
| 543 svis->refresh_delay = svis_redraw_delays[cfg.vis_refresh]; | |
| 544 } | |
| 545 svis->refresh_delay--; | |
| 546 } | |
| 547 } |
