annotate src/audacious/ui_svis.c @ 3054:34f37c59e87b

replace svis with UiSVis
author Tomasz Mon <desowin@gmail.com>
date Fri, 13 Jul 2007 11:40:00 +0200
parents
children 3b6d316f8b09
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
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; under version 2 of the License.
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
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
23 */
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
24
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
25 #include "widgets/widgetcore.h"
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
26 #include "ui_svis.h"
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
27 #include "ui_vis.h"
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
28 #include "main.h"
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
29 #include "util.h"
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
30 #include "strings.h"
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
31 #include "playback.h"
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32 #include <string.h>
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
33 #include <ctype.h>
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
34 #include <gtk/gtkmain.h>
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
35 #include <gtk/gtkmarshal.h>
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
36 #include <gtk/gtkimage.h>
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
37
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
38 #define UI_TYPE_SVIS (ui_svis_get_type())
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 static gint svis_redraw_delays[] = { 1, 2, 4, 8 };
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 /* FIXME: Are the svis_scope_colors correct? */
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
43 static guint8 svis_scope_colors[] = { 20, 19, 18, 19, 20 };
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
44 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
45
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
46 #define DRAW_DS_PIXEL(ptr,value) \
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
47 *(ptr) = (value); \
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
48 *((ptr) + 1) = (value); \
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
49 *((ptr) + 76) = (value); \
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50 *((ptr) + 77) = (value);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
51
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52 #define SVIS_HEIGHT 5
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53 #define SVIS_WIDTH 38
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 enum {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56 DOUBLED,
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57 LAST_SIGNAL
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 };
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
60 static void ui_svis_class_init (UiSVisClass *klass);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
61 static void ui_svis_init (UiSVis *svis);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62 static void ui_svis_destroy (GtkObject *object);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
63 static void ui_svis_realize (GtkWidget *widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
64 static void ui_svis_unrealize (GtkWidget *widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
65 static void ui_svis_map (GtkWidget *widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66 static void ui_svis_unmap (GtkWidget *widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67 static void ui_svis_size_request (GtkWidget *widget, GtkRequisition *requisition);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
68 static void ui_svis_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
69 static gboolean ui_svis_expose (GtkWidget *widget, GdkEventExpose *event);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
70 static void ui_svis_toggle_doublesize (UiSVis *svis);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
71
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72 static GtkWidgetClass *parent_class = NULL;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
73 static guint vis_signals[LAST_SIGNAL] = { 0 };
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
74
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75 GType ui_svis_get_type() {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
76 static GType vis_type = 0;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77 if (!vis_type) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78 static const GTypeInfo vis_info = {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79 sizeof (UiSVisClass),
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
80 NULL,
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
81 NULL,
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
82 (GClassInitFunc) ui_svis_class_init,
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 NULL,
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85 sizeof (UiSVis),
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86 0,
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
87 (GInstanceInitFunc) ui_svis_init,
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
88 };
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
89 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
90 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
91
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
92 return vis_type;
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
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
95 static void ui_svis_class_init(UiSVisClass *klass) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96 GtkObjectClass *object_class;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97 GtkWidgetClass *widget_class;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99 object_class = (GtkObjectClass*) klass;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
100 widget_class = (GtkWidgetClass*) klass;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
101 parent_class = gtk_type_class (gtk_widget_get_type ());
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
102
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
103 object_class->destroy = ui_svis_destroy;
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 widget_class->realize = ui_svis_realize;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
106 widget_class->unrealize = ui_svis_unrealize;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107 widget_class->map = ui_svis_map;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
108 widget_class->unmap = ui_svis_unmap;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
109 widget_class->expose_event = ui_svis_expose;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
110 widget_class->size_request = ui_svis_size_request;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111 widget_class->size_allocate = ui_svis_size_allocate;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113 klass->doubled = ui_svis_toggle_doublesize;
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 vis_signals[DOUBLED] =
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
116 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
117 G_STRUCT_OFFSET (UiSVisClass, doubled), NULL, NULL,
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121 static void ui_svis_init(UiSVis *svis) {
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 }
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 GtkWidget* ui_svis_new(GtkWidget *fixed, gint x, gint y) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126 UiSVis *svis = g_object_new (ui_svis_get_type (), NULL);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128 svis->x = x;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
129 svis->y = y;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131 svis->width = SVIS_WIDTH;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132 svis->height = SVIS_HEIGHT;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134 svis->fixed = fixed;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135 svis->double_size = FALSE;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
137 svis->visible_window = TRUE;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
138 svis->event_window = NULL;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 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
141
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142 return GTK_WIDGET(svis);
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
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
145 static void ui_svis_destroy(GtkObject *object) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
146 UiSVis *svis;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
147
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
148 g_return_if_fail (object != NULL);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149 g_return_if_fail (UI_IS_SVIS (object));
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151 svis = UI_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 if (GTK_OBJECT_CLASS (parent_class)->destroy)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
154 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157 static void ui_svis_realize(GtkWidget *widget) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158 UiSVis *svis;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
159 GdkWindowAttr attributes;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
160 gint attributes_mask;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
161
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
162 g_return_if_fail (widget != NULL);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
163 g_return_if_fail (UI_IS_SVIS(widget));
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
164
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
165 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
166 svis = UI_SVIS(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
168 attributes.x = widget->allocation.x;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
169 attributes.y = widget->allocation.y;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
170 attributes.width = widget->allocation.width;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
171 attributes.height = widget->allocation.height;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
172 attributes.window_type = GDK_WINDOW_CHILD;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
173 attributes.event_mask = gtk_widget_get_events(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
174 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
175
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
176 if (svis->visible_window)
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 attributes.visual = gtk_widget_get_visual(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
179 attributes.colormap = gtk_widget_get_colormap(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
180 attributes.wclass = GDK_INPUT_OUTPUT;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
181 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
182 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
183 GTK_WIDGET_UNSET_FLAGS(widget, GTK_NO_WINDOW);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
184 gdk_window_set_user_data(widget->window, widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
185 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
186 else
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 widget->window = gtk_widget_get_parent_window (widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
189 g_object_ref (widget->window);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
190
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
191 attributes.wclass = GDK_INPUT_ONLY;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
192 attributes_mask = GDK_WA_X | GDK_WA_Y;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
193 svis->event_window = gdk_window_new (widget->window, &attributes, attributes_mask);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
194 GTK_WIDGET_SET_FLAGS (widget, GTK_NO_WINDOW);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
195 gdk_window_set_user_data(svis->event_window, widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
196 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
197
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
198 widget->style = gtk_style_attach(widget->style, widget->window);
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
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
201 static void ui_svis_unrealize(GtkWidget *widget) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
202 UiSVis *svis;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
203 svis = UI_SVIS(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
204
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
205 if ( svis->event_window != NULL )
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 gdk_window_set_user_data( svis->event_window , NULL );
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
208 gdk_window_destroy( svis->event_window );
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
209 svis->event_window = NULL;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
210 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
211
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
212 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
213 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
214 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
215
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
216 static void ui_svis_map(GtkWidget *widget)
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 UiSVis *svis;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
219 svis = UI_SVIS(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
220
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
221 if (svis->event_window != NULL)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
222 gdk_window_show (svis->event_window);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
223
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
224 if (GTK_WIDGET_CLASS (parent_class)->map)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
225 (* GTK_WIDGET_CLASS (parent_class)->map) (widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
226 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
227
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
228 static void ui_svis_unmap (GtkWidget *widget)
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 UiSVis *svis;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
231 svis = UI_SVIS(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
232
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
233 if (svis->event_window != NULL)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
234 gdk_window_hide (svis->event_window);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
235
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
236 if (GTK_WIDGET_CLASS (parent_class)->unmap)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
237 (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
238 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
239
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
240 static void ui_svis_size_request(GtkWidget *widget, GtkRequisition *requisition) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
241 UiSVis *svis = UI_SVIS(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
242
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
243 requisition->width = svis->width*(1+svis->double_size);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
244 requisition->height = svis->height*(1+svis->double_size);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
245 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
246
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
247 static void ui_svis_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
248 UiSVis *svis = UI_SVIS (widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
249
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
250 widget->allocation = *allocation;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
251 widget->allocation.x *= (1+svis->double_size);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
252 widget->allocation.y *= (1+svis->double_size);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
253 if (GTK_WIDGET_REALIZED (widget))
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
254 {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
255 if (svis->event_window != NULL)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
256 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
257 else
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
258 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
259 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
260
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
261 svis->x = widget->allocation.x/(svis->double_size ? 2 : 1);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
262 svis->y = widget->allocation.y/(svis->double_size ? 2 : 1);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
263 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
264
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
265 static gboolean ui_svis_expose(GtkWidget *widget, GdkEventExpose *event) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
266 g_return_val_if_fail (widget != NULL, FALSE);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
267 g_return_val_if_fail (UI_IS_SVIS (widget), FALSE);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
268 g_return_val_if_fail (event != NULL, FALSE);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
269
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
270 UiSVis *svis = UI_SVIS (widget);
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 gint x, y, h;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
273 guchar svis_color[24][3];
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
274 guchar rgb_data[SVIS_WIDTH * 2 * SVIS_HEIGHT * 2], *ptr, c;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
275 guint32 colors[24];
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
276 GdkRgbCmap *cmap;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
277
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
278 if (!GTK_WIDGET_VISIBLE(widget))
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
279 return FALSE;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
280
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
281 if (!svis->visible_window)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
282 return FALSE;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
283
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
284 skin_get_viscolor(bmp_active_skin, svis_color);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
285 for (y = 0; y < 24; y++) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
286 colors[y] =
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
287 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
288 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
289 cmap = gdk_rgb_cmap_new(colors, 24);
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 if (!cfg.doublesize) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
292 memset(rgb_data, 0, SVIS_WIDTH * SVIS_HEIGHT);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
293 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
294 for(y=0; y < SVIS_HEIGHT; y++){
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
295 if (cfg.analyzer_type == ANALYZER_BARS){
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
296 for(x=0;x< SVIS_WIDTH; x++){
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
297 if(svis->data[x] > y << 1)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
298 {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
299 rgb_data[x*3+ (SVIS_HEIGHT - y) * SVIS_WIDTH] = 23;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
300 rgb_data[x*3+1 + (SVIS_HEIGHT - y) * SVIS_WIDTH] = 23;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
301
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
302 }
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 else{
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
306 for(x=0;x< SVIS_WIDTH; x++){
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
307 if(svis->data[x] > y << 1)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
308 {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
309 rgb_data[x + (SVIS_HEIGHT - y) * SVIS_WIDTH] = 23;
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 }
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 else if (cfg.vis_type == VIS_VOICEPRINT){
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
316 switch (cfg.vu_mode) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
317 case VU_NORMAL:
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
318 for (y = 0; y < 2; y++) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
319 ptr = rgb_data + ((y * 3) * 38);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
320 h = (svis->data[y] * 7) / 37;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
321 for (x = 0; x < h; x++, ptr += 5) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
322 c = svis_vu_normal_colors[x];
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
323 *(ptr) = c;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
324 *(ptr + 1) = c;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
325 *(ptr + 2) = c;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
326 *(ptr + 38) = c;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
327 *(ptr + 39) = c;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
328 *(ptr + 40) = c;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
329 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
330 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
331 break;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
332 case VU_SMOOTH:
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
333 for (y = 0; y < 2; y++) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
334 ptr = rgb_data + ((y * 3) * SVIS_WIDTH);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
335 for (x = 0; x < svis->data[y]; x++, ptr++) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
336 c = 17 - ((x * 15) / 37);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
337 *(ptr) = c;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
338 *(ptr + 38) = c;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
339 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
340 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
341 break;
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 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
344 else if (cfg.vis_type == VIS_SCOPE) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
345 for (x = 0; x < 38; x++) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
346 h = svis->data[x << 1] / 3;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
347 ptr = rgb_data + ((4 - h) * 38) + x;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
348 *ptr = svis_scope_colors[h];
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
349 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
350 }
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 else { /* doublesize */
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 memset(rgb_data, 0, SVIS_WIDTH * 2 * SVIS_HEIGHT * 2);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
356 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
357 for(y=0; y < SVIS_HEIGHT; y++){
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
358 if (cfg.analyzer_type == ANALYZER_BARS){
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
359 for(x=0;x< SVIS_WIDTH; x++){
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
360 if(svis->data[x] > y << 1)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
361 {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
362 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
363 DRAW_DS_PIXEL(ptr, 23);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
364 DRAW_DS_PIXEL(ptr + 2, 23);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
365 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
366 }
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 else{
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
369 for(x=0;x< SVIS_WIDTH; x++){
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
370 if(svis->data[x] > y << 1)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
371 {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
372 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
373 DRAW_DS_PIXEL(ptr, 23);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
374 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
375 }
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 else if (cfg.vis_type == VIS_VOICEPRINT){
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
380 switch (cfg.vu_mode) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
381 case VU_NORMAL:
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
382 for (y = 0; y < 2; y++) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
383 ptr = rgb_data + ((y * 3) * 152);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
384 h = (svis->data[y] * 8) / 37;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
385 for (x = 0; x < h; x++, ptr += 10) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
386 c = svis_vu_normal_colors[x];
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
387 DRAW_DS_PIXEL(ptr, c);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
388 DRAW_DS_PIXEL(ptr + 2, c);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
389 DRAW_DS_PIXEL(ptr + 4, c);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
390 DRAW_DS_PIXEL(ptr + 152, c);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
391 DRAW_DS_PIXEL(ptr + 154, c);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
392 DRAW_DS_PIXEL(ptr + 156, c);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
393 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
394 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
395 break;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
396 case VU_SMOOTH:
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
397 for (y = 0; y < 2; y++) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
398 ptr = rgb_data + ((y * 3) * 152);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
399 for (x = 0; x < svis->data[y]; x++, ptr += 2) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
400 c = 17 - ((x * 15) / 37);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
401 DRAW_DS_PIXEL(ptr, c);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
402 DRAW_DS_PIXEL(ptr + 152, c);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
403 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
404 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
405 break;
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 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
408 else if (cfg.vis_type == VIS_SCOPE) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
409 for (x = 0; x < 38; x++) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
410 h = svis->data[x << 1] / 3;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
411 ptr = rgb_data + ((4 - h) * 152) + (x << 1);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
412 *ptr = svis_scope_colors[h];
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
413 *(ptr + 1) = svis_scope_colors[h];
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
414 *(ptr + 76) = svis_scope_colors[h];
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
415 *(ptr + 77) = svis_scope_colors[h];
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
416 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
417 }
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 GdkPixmap *obj = NULL;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
423 GdkGC *gc;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
424 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
425 gc = gdk_gc_new(obj);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
426
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
427 if (!svis->double_size) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
428 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
429 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data,
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
430 38, cmap);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
431 } else {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
432 gdk_draw_indexed_image(obj, gc,
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
433 0 << 1, 0 << 1,
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
434 svis->width << 1, svis->height << 1,
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
435 GDK_RGB_DITHER_NONE, (guchar *) rgb_data,
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
436 76, cmap);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
437 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
438
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
439 gdk_rgb_cmap_free(cmap);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
440 gdk_draw_drawable (widget->window, gc, obj, 0, 0, 0, 0,
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
441 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
442 g_object_unref(obj);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
443 g_object_unref(gc);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
444
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
445 return FALSE;
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
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
448 static void ui_svis_toggle_doublesize(UiSVis *svis) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
449 GtkWidget *widget = GTK_WIDGET (svis);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
450 svis->double_size = !svis->double_size;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
451
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
452 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
453
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
454 gtk_widget_queue_draw(widget);
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
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
457 void ui_svis_set_visible(GtkWidget *widget, gboolean window_is_visible)
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 UiSVis *svis;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
460 gboolean widget_is_visible;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
461
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
462 g_return_if_fail(UI_IS_SVIS(widget));
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 svis = UI_SVIS (widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
465 widget_is_visible = GTK_WIDGET_VISIBLE(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
466
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
467 svis->visible_window = window_is_visible;
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 if (GTK_WIDGET_REALIZED (widget))
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 ( widget_is_visible )
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
472 gtk_widget_hide(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
473
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
474 gtk_widget_unrealize(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
475 gtk_widget_realize(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
476
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
477 if ( widget_is_visible )
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
478 gtk_widget_show(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
479 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
480
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
481 if (widget_is_visible)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
482 gtk_widget_queue_resize(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
483 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
484
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
485 void ui_svis_clear_data(GtkWidget *widget) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
486 gint i;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
487
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
488 UiSVis *svis = UI_SVIS (widget);
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 for (i = 0; i < 75; i++) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
491 svis->data[i] = (cfg.vis_type == VIS_SCOPE) ? 6 : 0;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
492 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
493 }
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 void ui_svis_timeout_func(GtkWidget *widget, guchar * data) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
496 UiSVis *svis = UI_SVIS (widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
497 static GTimer *timer = NULL;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
498 gulong micros = 9999999;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
499 gboolean falloff = FALSE;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
500 gint i;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
501
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
502 if (!timer) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
503 timer = g_timer_new();
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
504 g_timer_start(timer);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
505 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
506 else {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
507 g_timer_elapsed(timer, &micros);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
508 if (micros > 14000)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
509 g_timer_reset(timer);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
510
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
511 }
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 if (cfg.vis_type == VIS_VOICEPRINT) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
514 if (micros > 14000)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
515 falloff = TRUE;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
516
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
517 for (i = 0; i < 2; i++) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
518 if (falloff || data) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
519 if (data && data[i] > svis->data[i])
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
520 svis->data[i] = data[i];
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
521 else if (falloff) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
522 if (svis->data[i] >= 2)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
523 svis->data[i] -= 2;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
524 else
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
525 svis->data[i] = 0;
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
526 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
527 }
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 else if (data) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
532 for (i = 0; i < 75; i++)
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
533 svis->data[i] = data[i];
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
534 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
535
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
536 if (micros > 14000) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
537 if (!svis->refresh_delay) {
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
538 gtk_widget_queue_draw(widget);
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
539 svis->refresh_delay = svis_redraw_delays[cfg.vis_refresh];
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
540 }
34f37c59e87b replace svis with UiSVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
541 svis->refresh_delay--;
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 }