annotate src/audacious/ui_svis.c @ 3284:70789a2a5a65 trunk

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