annotate src/skins/ui_svis.c @ 3085:ac0af6b39272

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