annotate src/skins/ui_vis.c @ 2642:c2603047a1a3

add few more config items
author Tomasz Mon <desowin@gmail.com>
date Fri, 23 May 2008 17:17:16 +0200
parents c9e40418a74c
children ed0ad7b373d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1 /*
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
2 * Audacious - a cross-platform multimedia player
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
3 * Copyright (c) 2007 Audacious development team.
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
4 *
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
5 * Based on:
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
6 * BMP - Cross-platform multimedia player
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
7 * Copyright (C) 2003-2004 BMP development team.
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
8 * XMMS:
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
9 * Copyright (C) 1998-2003 XMMS development team.
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
10 *
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; under version 3 of the License.
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
14 *
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
19 *
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
21 * along with this program. If not, see <http://www.gnu.org/licenses>.
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
22 *
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
23 * The Audacious team does not consider modular code linking to
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
24 * Audacious or using our public API to be a derived work.
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
25 */
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
26
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
27 #include "ui_skin.h"
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
28 #include "ui_vis.h"
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
29 #include "util.h"
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
30 #include "skins_cfg.h"
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
31 #include <audacious/plugin.h>
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
33 static const gfloat vis_afalloff_speeds[] = { 0.34, 0.5, 1.0, 1.3, 1.6 };
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
34 static const gfloat vis_pfalloff_speeds[] = { 1.2, 1.3, 1.4, 1.5, 1.6 };
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
35 static const gint vis_redraw_delays[] = { 1, 2, 4, 8 };
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
36 static const guint8 vis_scope_colors[] =
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
37 { 21, 21, 20, 20, 19, 19, 18, 19, 19, 20, 20, 21, 21 };
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
38 static guchar voiceprint_data[76*16];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
39
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
40 enum {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
41 DOUBLED,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
42 LAST_SIGNAL
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
43 };
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
44
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
45 static void ui_vis_class_init (UiVisClass *klass);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
46 static void ui_vis_init (UiVis *vis);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
47 static void ui_vis_destroy (GtkObject *object);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
48 static void ui_vis_realize (GtkWidget *widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
49 static void ui_vis_unrealize (GtkWidget *widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50 static void ui_vis_map (GtkWidget *widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
51 static void ui_vis_unmap (GtkWidget *widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52 static void ui_vis_size_request (GtkWidget *widget, GtkRequisition *requisition);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53 static void ui_vis_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54 static gboolean ui_vis_expose (GtkWidget *widget, GdkEventExpose *event);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 static void ui_vis_toggle_scaled (UiVis *vis);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57 static GtkWidgetClass *parent_class = NULL;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 static guint vis_signals[LAST_SIGNAL] = { 0 };
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
60 GType ui_vis_get_type() {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
61 static GType vis_type = 0;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62 if (!vis_type) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
63 static const GTypeInfo vis_info = {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
64 sizeof (UiVisClass),
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
65 NULL,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66 NULL,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67 (GClassInitFunc) ui_vis_class_init,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
68 NULL,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
69 NULL,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
70 sizeof (UiVis),
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
71 0,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72 (GInstanceInitFunc) ui_vis_init,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
73 };
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
74 vis_type = g_type_register_static (GTK_TYPE_WIDGET, "UiVis", &vis_info, 0);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
76
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77 return vis_type;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
80 static void ui_vis_class_init(UiVisClass *klass) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
81 GtkObjectClass *object_class;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
82 GtkWidgetClass *widget_class;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
83
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
84 object_class = (GtkObjectClass*) klass;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85 widget_class = (GtkWidgetClass*) klass;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86 parent_class = gtk_type_class (gtk_widget_get_type ());
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
87
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
88 object_class->destroy = ui_vis_destroy;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
89
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
90 widget_class->realize = ui_vis_realize;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
91 widget_class->unrealize = ui_vis_unrealize;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
92 widget_class->map = ui_vis_map;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
93 widget_class->unmap = ui_vis_unmap;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
94 widget_class->expose_event = ui_vis_expose;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
95 widget_class->size_request = ui_vis_size_request;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96 widget_class->size_allocate = ui_vis_size_allocate;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98 klass->doubled = ui_vis_toggle_scaled;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
100 vis_signals[DOUBLED] =
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
101 g_signal_new ("toggle-scaled", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
102 G_STRUCT_OFFSET (UiVisClass, doubled), NULL, NULL,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
103 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
104 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
105
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
106 static void ui_vis_init(UiVis *vis) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107 memset(voiceprint_data, 0, 16*76);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
108 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
109
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
110 GtkWidget* ui_vis_new(GtkWidget *fixed, gint x, gint y, gint width) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111 UiVis *vis = g_object_new (ui_vis_get_type (), NULL);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113 vis->x = x;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
114 vis->y = y;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
115
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
116 vis->width = width;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
117 vis->height = 16;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119 vis->fixed = fixed;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120 vis->scaled = FALSE;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
122 vis->visible_window = TRUE;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
123 vis->event_window = NULL;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
124
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
125 gtk_fixed_put(GTK_FIXED(vis->fixed), GTK_WIDGET(vis), vis->x, vis->y);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127 return GTK_WIDGET(vis);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
129
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130 static void ui_vis_destroy(GtkObject *object) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131 UiVis *vis;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133 g_return_if_fail (object != NULL);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134 g_return_if_fail (UI_IS_VIS (object));
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136 vis = UI_VIS (object);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
137
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
138 if (GTK_OBJECT_CLASS (parent_class)->destroy)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142 static void ui_vis_realize(GtkWidget *widget) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
143 UiVis *vis;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
144 GdkWindowAttr attributes;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
145 gint attributes_mask;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
146
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
147 g_return_if_fail (widget != NULL);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
148 g_return_if_fail (UI_IS_VIS(widget));
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151 vis = UI_VIS(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
152
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153 attributes.x = widget->allocation.x;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
154 attributes.y = widget->allocation.y;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155 attributes.width = widget->allocation.width;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156 attributes.height = widget->allocation.height;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157 attributes.window_type = GDK_WINDOW_CHILD;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158 attributes.event_mask = gtk_widget_get_events(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
159 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
160
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
161 if (vis->visible_window)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
162 {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
163 attributes.visual = gtk_widget_get_visual(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
164 attributes.colormap = gtk_widget_get_colormap(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
165 attributes.wclass = GDK_INPUT_OUTPUT;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
166 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
168 GTK_WIDGET_UNSET_FLAGS(widget, GTK_NO_WINDOW);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
169 gdk_window_set_user_data(widget->window, widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
170 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
171 else
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
172 {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
173 widget->window = gtk_widget_get_parent_window (widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
174 g_object_ref (widget->window);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
175
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
176 attributes.wclass = GDK_INPUT_ONLY;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
177 attributes_mask = GDK_WA_X | GDK_WA_Y;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
178 vis->event_window = gdk_window_new (widget->window, &attributes, attributes_mask);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
179 GTK_WIDGET_SET_FLAGS (widget, GTK_NO_WINDOW);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
180 gdk_window_set_user_data(vis->event_window, widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
181 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
182
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
183 widget->style = gtk_style_attach(widget->style, widget->window);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
184 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
185
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
186 static void ui_vis_unrealize(GtkWidget *widget) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
187 UiVis *vis;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
188 vis = UI_VIS(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
189
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
190 if ( vis->event_window != NULL )
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
191 {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
192 gdk_window_set_user_data( vis->event_window , NULL );
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
193 gdk_window_destroy( vis->event_window );
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
194 vis->event_window = NULL;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
195 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
196
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
197 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
198 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
199 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
200
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
201 static void ui_vis_map(GtkWidget *widget)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
202 {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
203 UiVis *vis;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
204 vis = UI_VIS(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
205
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
206 if (vis->event_window != NULL)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
207 gdk_window_show (vis->event_window);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
208
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
209 if (GTK_WIDGET_CLASS (parent_class)->map)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
210 (* GTK_WIDGET_CLASS (parent_class)->map) (widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
211 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
212
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
213 static void ui_vis_unmap (GtkWidget *widget)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
214 {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
215 UiVis *vis;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
216 vis = UI_VIS(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
217
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
218 if (vis->event_window != NULL)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
219 gdk_window_hide (vis->event_window);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
220
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
221 if (GTK_WIDGET_CLASS (parent_class)->unmap)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
222 (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
223 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
224
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
225 static void ui_vis_size_request(GtkWidget *widget, GtkRequisition *requisition) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
226 UiVis *vis = UI_VIS(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
227
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
228 requisition->width = vis->width*(vis->scaled ? config.scale_factor : 1);
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
229 requisition->height = vis->height*(vis->scaled ? config.scale_factor : 1);
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
230 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
231
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
232 static void ui_vis_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
233 UiVis *vis = UI_VIS (widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
234
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
235 widget->allocation = *allocation;
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
236 widget->allocation.x *= (vis->scaled ? config.scale_factor : 1);
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
237 widget->allocation.y *= (vis->scaled ? config.scale_factor : 1);
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
238 if (GTK_WIDGET_REALIZED (widget))
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
239 {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
240 if (vis->event_window != NULL)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
241 gdk_window_move_resize(vis->event_window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
242 else
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
243 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
244 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
245
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
246 vis->x = widget->allocation.x/(vis->scaled ? config.scale_factor : 1);
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
247 vis->y = widget->allocation.y/(vis->scaled ? config.scale_factor : 1);
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
248 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
249
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
250 static gboolean ui_vis_expose(GtkWidget *widget, GdkEventExpose *event) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
251 g_return_val_if_fail (widget != NULL, FALSE);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
252 g_return_val_if_fail (UI_IS_VIS (widget), FALSE);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
253 g_return_val_if_fail (event != NULL, FALSE);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
254
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
255 UiVis *vis = UI_VIS (widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
256
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
257 gint x, y, n, h = 0, h2;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
258 gfloat delta;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
259 guchar skin_col[2][3];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
260 guchar vis_color[24][3];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
261 guchar vis_voice_color[256][3], voice_c[3];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
262 guchar rgb_data[76 * 16 * 3 * 2 * 2], *ptr, c;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
263 guint32 colors[24];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
264 GdkColor *fgc, *bgc;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
265 GdkRgbCmap *cmap;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
266
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
267 if (!GTK_WIDGET_VISIBLE(widget))
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
268 return FALSE;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
269
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
270 if (!vis->visible_window)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
271 return FALSE;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
272
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
273 skin_get_viscolor(aud_active_skin, vis_color);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
274 for (y = 0; y < 24; y++) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
275 colors[y] =
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
276 vis_color[y][0] << 16 | vis_color[y][1] << 8 | vis_color[y][2];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
277 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
278 cmap = gdk_rgb_cmap_new(colors, 24);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
279
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
280 if (!vis->scaled) {
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2584
diff changeset
281 if(config.vis_type == VIS_VOICEPRINT /*&& config.voiceprint_mode != VOICEPRINT_NORMAL*/){
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
282 memset(rgb_data, 0, 76 * 16 * 3);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
283 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
284 else{
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
285 memset(rgb_data, 0, 76 * 16);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
286 for (y = 1; y < 16; y += 2) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
287 ptr = rgb_data + (y * 76);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
288 for (x = 0; x < 76; x += 2, ptr += 2)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
289 *ptr = 1;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
290 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
291 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
292 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
293 else{
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2584
diff changeset
294 if(config.vis_type == VIS_VOICEPRINT /*&& config.voiceprint_mode != VOICEPRINT_NORMAL*/){
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
295 memset(rgb_data, 0, 3 * 4 * 16 * 76);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
296 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
297 else{
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
298 memset(rgb_data, 0, (guint)(76 * config.scale_factor) * 32);
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
299 for (y = 1; y < 16; y += 2) {
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
300 ptr = rgb_data + (y * (guint)(76 * 4 * config.scale_factor));
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
301 for (x = 0; x < 76; x += 2, ptr += 4) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
302 *ptr = 1;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
303 *(ptr + 1) = 1;
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
304 *(ptr + (guint)(76 * config.scale_factor)) = 1;
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
305 *(ptr + (guint)(76 * config.scale_factor)+1) = 1;
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
306 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
307 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
308 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
309 }
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
310 if (config.vis_type == VIS_ANALYZER) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
311 for (x = 0; x < 75; x++) {
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
312 if (config.analyzer_type == ANALYZER_BARS && (x % 4) == 0)
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
313 h = vis->data[x >> 2];
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
314 else if (config.analyzer_type == ANALYZER_LINES)
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
315 h = vis->data[x];
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
316 if (h && (config.analyzer_type == ANALYZER_LINES ||
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
317 (x % 4) != 3)) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
318 if (!vis->scaled) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
319 ptr = rgb_data + ((16 - h) * 76) + x;
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
320 switch (config.analyzer_mode) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
321 case ANALYZER_NORMAL:
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
322 for (y = 0; y < h; y++, ptr += 76)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
323 *ptr = 18 - h + y;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
324 break;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
325 case ANALYZER_FIRE:
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
326 for (y = 0; y < h; y++, ptr += 76)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
327 *ptr = y + 2;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
328 break;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
329 case ANALYZER_VLINES:
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
330 for (y = 0; y < h; y++, ptr += 76)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
331 *ptr = 18 - h;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
332 break;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
333 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
334 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
335 else{
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2584
diff changeset
336 ptr = rgb_data + ((16 - h) * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * config.scale_factor);
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
337 switch (config.analyzer_mode) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
338 case ANALYZER_NORMAL:
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
339 for (y = 0; y < h; y++, ptr += (guint)(76 * 4 * config.scale_factor)) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
340 *ptr = 18 - h + y;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
341 *(ptr + 1) = 18 - h + y;
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
342 *(ptr + (guint)(76 * config.scale_factor)) = 18 - h + y;
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
343 *(ptr + (guint)(76 * config.scale_factor)+1) = 18 - h + y;
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
344 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
345 break;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
346 case ANALYZER_FIRE:
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
347 for (y = 0; y < h; y++, ptr += (guint)(76 * 4 * config.scale_factor)) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
348 *ptr = y + 2;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
349 *(ptr + 1) = y + 2;
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
350 *(ptr + (guint)(76 * config.scale_factor)) = y + 2;
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
351 *(ptr + (guint)(76 * config.scale_factor)+1) = y + 2;
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
352 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
353 break;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
354 case ANALYZER_VLINES:
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
355 for (y = 0; y < h; y++, ptr += (guint)(76 * 4 * config.scale_factor)) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
356 *ptr = 18 - h;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
357 *(ptr + 1) = 18 - h;
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
358 *(ptr + (guint)(76 * config.scale_factor)) = 18 - h;
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
359 *(ptr + (guint)(76 * config.scale_factor)+1) = 18 - h;
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
360 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
361
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
362 break;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
363 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
364 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
365 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
366 }
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
367 if (config.analyzer_peaks) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
368 for (x = 0; x < 75; x++) {
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
369 if (config.analyzer_type == ANALYZER_BARS && (x % 4) == 0)
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
370 h = vis->peak[x >> 2];
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
371 else if (config.analyzer_type == ANALYZER_LINES)
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
372 h = vis->peak[x];
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
373 if (h && (config.analyzer_type == ANALYZER_LINES || (x % 4) != 3)){
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
374
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
375 if (!vis->scaled) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
376 rgb_data[(16 - h) * 76 + x] = 23;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
377 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
378 else{
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2584
diff changeset
379 ptr = rgb_data + (16 - h) * (guint)(76 * 4 * config.scale_factor) + (guint)(x * config.scale_factor);
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
380 *ptr = 23;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
381 *(ptr + 1) = 23;
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
382 *(ptr + (guint)(76 * config.scale_factor)) = 23;
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
383 *(ptr + (guint)(76 * config.scale_factor)+1) = 23;
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
384 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
385 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
386 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
387 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
388 }
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
389 else if (config.vis_type == VIS_VOICEPRINT) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
390 if(!audacious_drct_get_paused() && audacious_drct_get_playing()){/*Don't scroll when it's paused or stopped*/
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
391 for (y = 0; y < 16; y ++)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
392 for (x = 75; x > 0; x--)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
393 voiceprint_data[x + y * 76] = voiceprint_data[x-1+y*76];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
394 for(y=0;y<16;y++)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
395 voiceprint_data[y * 76] = vis->data[y];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
396 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
397 if(audacious_drct_get_playing()){ /*Only draw the data if we're playing*/
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
398 if(config.voiceprint_mode == VOICEPRINT_NORMAL){
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
399 /* Create color gradient from the skin's background- and foreground color*/
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
400 fgc = skin_get_color(aud_active_skin, SKIN_TEXTFG);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
401 bgc = skin_get_color(aud_active_skin, SKIN_TEXTBG);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
402 skin_col[0][0] = fgc->red >> 8;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
403 skin_col[0][1] = fgc->green >> 8;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
404 skin_col[0][2] = fgc->blue >> 8;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
405 skin_col[1][0] = bgc->red >> 8;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
406 skin_col[1][1] = bgc->green >> 8;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
407 skin_col[1][2] = bgc->blue >> 8;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
408 for(n=0;n<3;n++){
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
409 for(x=0;x<256;x++){
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
410 if(skin_col[0][n] > skin_col[1][n]){
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
411 delta = (gfloat)(skin_col[0][n] - skin_col[1][n]) / 256.0;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
412 vis_voice_color[x][n] = skin_col[1][n] + (gfloat)(delta * x);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
413 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
414 else if(skin_col[0][n] == skin_col[1][n]){
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
415 vis_voice_color[x][n] = skin_col[0][n];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
416 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
417 else{
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
418 delta = (gfloat)(skin_col[1][n] - skin_col[0][n]) / 256.0;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
419 vis_voice_color[x][n] = skin_col[1][n] - (gfloat)(delta * x);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
420 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
421 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
422 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
423 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
424 for (y = 0; y < 16; y ++){
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
425 for (x = 0; x < 76; x++){
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
426 guint8 d = voiceprint_data[x + y*76];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
427
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
428 if(config.voiceprint_mode == VOICEPRINT_NORMAL){
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
429 voice_c[0] = vis_voice_color[d][0];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
430 voice_c[1] = vis_voice_color[d][1];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
431 voice_c[2] = vis_voice_color[d][2];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
432 }
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
433 else if(config.voiceprint_mode == VOICEPRINT_FIRE){
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
434 voice_c[0] = d < 64 ? (d * 2) : 255;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
435 voice_c[1] = d < 64 ? 0 : (d < 128 ? (d-64) * 2 : 255);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
436 voice_c[2] = d < 128 ? 0 : (d-128) * 2;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
437 /* Test for black->blue->green->red. Isn't pretty, though...
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
438 voice_c[0] = d > 192 ? (d - 192) << 2 : 0;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
439 voice_c[1] = d > 64 ? (d < 128 ? (d - 64) << 2 : (d < 192 ? (192 - d) << 2 : 0)) : 0;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
440 voice_c[2] = d < 64 ? d << 2 : (d < 128 ? (128 - d) << 2 : 0);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
441 */
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
442 }
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
443 else if(config.voiceprint_mode == VOICEPRINT_ICE){
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
444 voice_c[0] = d;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
445 voice_c[1] = d < 128 ? d * 2 : 255;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
446 voice_c[2] = d < 64 ? d * 4 : 255;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
447 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
448 if(!vis->scaled){
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
449 for(n=0;n<3;n++)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
450 rgb_data[x * 3 + y * 76*3+n] = voice_c[n];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
451 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
452 else{
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2584
diff changeset
453 ptr = rgb_data + (guint)(x * 3 * config.scale_factor) + (guint) (y * 76 * 3 * config.scale_factor);
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
454 for(n=0;n<3;n++)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
455 {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
456 *(ptr + n) = voice_c[n];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
457 *(ptr + n + 3) = voice_c[n];
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
458 *(ptr + (guint)(n + 76 * config.scale_factor * 3)) = voice_c[n];
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
459 *(ptr + (guint)(n + 3 + 76 * config.scale_factor * 3)) = voice_c[n];
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
460 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
461 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
462 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
463 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
464 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
465 }
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
466 if (config.vis_type == VIS_SCOPE) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
467 for (x = 0; x < 75; x++) {
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
468 switch (config.scope_mode) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
469 case SCOPE_DOT:
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
470 h = vis->data[x];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
471 if (!vis->scaled) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
472 ptr = rgb_data + ((14 - h) * 76) + x;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
473 *ptr = vis_scope_colors[h + 1];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
474 }else{
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2584
diff changeset
475 ptr = rgb_data + ((14 - h) * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * config.scale_factor);
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
476 *ptr = vis_scope_colors[h + 1];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
477 *(ptr + 1) = vis_scope_colors[h + 1];
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
478 *(ptr + (guint)(76 * config.scale_factor)) = vis_scope_colors[h + 1];
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
479 *(ptr + (guint)(76 * config.scale_factor)+1) = vis_scope_colors[h + 1];
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
480 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
481 break;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
482 case SCOPE_LINE:
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
483 if (x != 74) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
484 h = 14 - vis->data[x];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
485 h2 = 14 - vis->data[x + 1];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
486 if (h > h2) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
487 y = h;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
488 h = h2;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
489 h2 = y;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
490 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
491 if (!vis->scaled) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
492 ptr = rgb_data + (h * 76) + x;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
493 for (y = h; y <= h2; y++, ptr += 76)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
494 *ptr = vis_scope_colors[y - 2];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
495 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
496 else{
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2584
diff changeset
497 ptr = rgb_data + (h * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * config.scale_factor);
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
498 for (y = h; y <= h2; y++, ptr += (guint)(76 * 4 * config.scale_factor)) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
499 *ptr = vis_scope_colors[y - 2];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
500 *(ptr + 1) = vis_scope_colors[y - 2];
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
501 *(ptr + (guint)(76 * config.scale_factor)) = vis_scope_colors[y - 2];
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
502 *(ptr + (guint)(76 * config.scale_factor)+1) = vis_scope_colors[y - 2];
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
503 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
504 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
505 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
506 else {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
507 h = 14 - vis->data[x];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
508 if (!vis->scaled) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
509 ptr = rgb_data + (h * 76) + x;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
510 *ptr = vis_scope_colors[h + 1];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
511 }else{
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2584
diff changeset
512 ptr = rgb_data + (h * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * config.scale_factor);
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
513 *ptr = vis_scope_colors[h + 1];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
514 *(ptr + 1) = vis_scope_colors[h + 1];
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
515 *(ptr + (guint)(76 * config.scale_factor)) = vis_scope_colors[h + 1];
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
516 *(ptr + (guint)(76 * config.scale_factor)+1) = vis_scope_colors[h + 1];
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
517 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
518 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
519 break;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
520 case SCOPE_SOLID:
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
521 h = 14 - vis->data[x];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
522 h2 = 8;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
523 c = vis_scope_colors[(gint) vis->data[x]];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
524 if (h > h2) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
525 y = h;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
526 h = h2;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
527 h2 = y;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
528 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
529 if (!vis->scaled) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
530 ptr = rgb_data + (h * 76) + x;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
531 for (y = h; y <= h2; y++, ptr += 76)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
532 *ptr = c;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
533 }else{
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2584
diff changeset
534 ptr = rgb_data + (h * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * config.scale_factor);
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
535 for (y = h; y <= h2; y++, ptr += (guint)(76 * 4 * config.scale_factor)) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
536 *ptr = c;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
537 *(ptr + 1) = c;
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
538 *(ptr + (guint)(76 * config.scale_factor)) = c;
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
539 *(ptr + (guint)(76 * config.scale_factor)+1) = c;
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
540 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
541 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
542 break;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
543 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
544 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
545 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
546
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
547 GdkPixmap *obj = NULL;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
548 GdkGC *gc;
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2584
diff changeset
549 obj = gdk_pixmap_new(NULL, vis->width*(vis->scaled ? config.scale_factor : 1), vis->height*(vis->scaled ? config.scale_factor : 1), gdk_rgb_get_visual()->depth);
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
550 gc = gdk_gc_new(obj);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
551
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
552 if (!vis->scaled) {
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
553 if (config.vis_type == VIS_VOICEPRINT) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
554 gdk_draw_rgb_image(obj, gc, 0, 0, vis->width, vis->height,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
555 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
556 76 * 3);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
557 } else {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
558 gdk_draw_indexed_image(obj, gc, 0, 0, vis->width, vis->height,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
559 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
560 76 , cmap);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
561 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
562 } else {
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
563 if (config.vis_type == VIS_VOICEPRINT) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
564 gdk_draw_rgb_image(obj, gc, 0 << 1, 0 << 1,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
565 vis->width << 1, vis->height << 1,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
566 GDK_RGB_DITHER_NONE, (guchar *) rgb_data,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
567 76 * 2 * 3);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
568 } else {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
569 gdk_draw_indexed_image(obj, gc, 0 << 1, 0 << 1,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
570 vis->width << 1, vis->height << 1,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
571 GDK_RGB_DITHER_NONE, (guchar *) rgb_data,
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
572 76 * 2 , cmap);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
573 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
574 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
575
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
576 gdk_draw_drawable (widget->window, gc, obj, 0, 0, 0, 0,
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2584
diff changeset
577 vis->width*(vis->scaled ? config.scale_factor : 1), vis->height*(vis->scaled ? config.scale_factor : 1));
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
578 g_object_unref(obj);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
579 g_object_unref(gc);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
580 gdk_rgb_cmap_free(cmap);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
581 return FALSE;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
582 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
583
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
584 static void ui_vis_toggle_scaled(UiVis *vis) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
585 GtkWidget *widget = GTK_WIDGET (vis);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
586 vis->scaled = !vis->scaled;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
587
2642
c2603047a1a3 add few more config items
Tomasz Mon <desowin@gmail.com>
parents: 2584
diff changeset
588 gtk_widget_set_size_request(widget, vis->width*(vis->scaled ? config.scale_factor : 1), vis->height*(vis->scaled ? config.scale_factor : 1));
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
589
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
590 gtk_widget_queue_draw(GTK_WIDGET(vis));
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
591 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
592
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
593 void ui_vis_draw_pixel(GtkWidget *widget, guchar* texture, gint x, gint y, guint8 colour) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
594 UiVis *vis = UI_VIS (widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
595 if (vis->scaled){
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
596 texture[y * 76 + x] = colour;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
597 texture[y * 76 + x + 1] = colour;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
598 texture[y * 76 * 4 + x] = colour;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
599 texture[y * 76 * 4 + x + 1] = colour;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
600 } else {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
601 texture[y * 76 + x] = colour;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
602 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
603 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
604
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
605 void ui_vis_set_visible(GtkWidget *widget, gboolean window_is_visible)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
606 {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
607 UiVis *vis;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
608 gboolean widget_is_visible;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
609
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
610 g_return_if_fail(UI_IS_VIS(widget));
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
611
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
612 vis = UI_VIS (widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
613 widget_is_visible = GTK_WIDGET_VISIBLE(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
614
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
615 vis->visible_window = window_is_visible;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
616
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
617 if (GTK_WIDGET_REALIZED (widget))
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
618 {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
619 if ( widget_is_visible )
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
620 gtk_widget_hide(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
621
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
622 gtk_widget_unrealize(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
623 gtk_widget_realize(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
624
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
625 if ( widget_is_visible )
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
626 gtk_widget_show(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
627 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
628
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
629 if (widget_is_visible)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
630 gtk_widget_queue_resize(widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
631 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
632
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
633 void ui_vis_clear_data(GtkWidget *widget) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
634 gint i;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
635 UiVis *vis = UI_VIS (widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
636
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
637 memset(voiceprint_data, 0, 16*76);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
638 for (i = 0; i < 75; i++) {
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
639 vis->data[i] = (config.vis_type == VIS_SCOPE) ? 6 : 0;
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
640 vis->peak[i] = 0;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
641 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
642 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
643
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
644 void ui_vis_timeout_func(GtkWidget *widget, guchar * data) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
645 UiVis *vis = UI_VIS (widget);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
646 static GTimer *timer = NULL;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
647 gulong micros = 9999999;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
648 gboolean falloff = FALSE;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
649 gint i;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
650
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
651 if (!timer) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
652 timer = g_timer_new();
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
653 g_timer_start(timer);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
654 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
655 else {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
656 g_timer_elapsed(timer, &micros);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
657 if (micros > 14000)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
658 g_timer_reset(timer);
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
659 }
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
660 if (config.vis_type == VIS_ANALYZER) {
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
661 if (micros > 14000)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
662 falloff = TRUE;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
663 if (data || falloff) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
664 for (i = 0; i < 75; i++) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
665 if (data && data[i] > vis->data[i]) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
666 vis->data[i] = data[i];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
667 if (vis->data[i] > vis->peak[i]) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
668 vis->peak[i] = vis->data[i];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
669 vis->peak_speed[i] = 0.01;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
670
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
671 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
672 else if (vis->peak[i] > 0.0) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
673 vis->peak[i] -= vis->peak_speed[i];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
674 vis->peak_speed[i] *=
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
675 vis_pfalloff_speeds[config.peaks_falloff];
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
676 if (vis->peak[i] < vis->data[i])
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
677 vis->peak[i] = vis->data[i];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
678 if (vis->peak[i] < 0.0)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
679 vis->peak[i] = 0.0;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
680 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
681 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
682 else if (falloff) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
683 if (vis->data[i] > 0.0) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
684 vis->data[i] -=
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
685 vis_afalloff_speeds[config.analyzer_falloff];
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
686 if (vis->data[i] < 0.0)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
687 vis->data[i] = 0.0;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
688 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
689 if (vis->peak[i] > 0.0) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
690 vis->peak[i] -= vis->peak_speed[i];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
691 vis->peak_speed[i] *=
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
692 vis_pfalloff_speeds[config.peaks_falloff];
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
693 if (vis->peak[i] < vis->data[i])
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
694 vis->peak[i] = vis->data[i];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
695 if (vis->peak[i] < 0.0)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
696 vis->peak[i] = 0.0;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
697 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
698 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
699 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
700 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
701 }
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
702 else if (config.vis_type == VIS_VOICEPRINT && data){
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
703 for(i = 0; i < 16; i++)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
704 {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
705 vis->data[i] = data[15 - i];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
706 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
707 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
708 else if (data) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
709 for (i = 0; i < 75; i++)
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
710 vis->data[i] = data[i];
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
711 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
712
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
713 if (micros > 14000) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
714 if (!vis->refresh_delay) {
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
715 gtk_widget_queue_draw(widget);
2584
c9e40418a74c use plugin's own config
Tomasz Mon <desowin@gmail.com>
parents: 2579
diff changeset
716 vis->refresh_delay = vis_redraw_delays[config.vis_refresh];
2579
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
717 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
718 vis->refresh_delay--;
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
719 }
8fba3fbf1a0f add vis and svis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
720 }