annotate audacious/widgets/menurow.c @ 1859:a0a4321c5507 trunk

[svn] - main texture: resize to 425x100; add a colon to delimit minutes from seconds.
author nenolod
date Wed, 11 Oct 2006 18:42:49 -0700
parents a6e6d3500c13
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
3 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
4 * Based on XMMS:
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
6 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
10 * (at your option) any later version.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
11 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
16 *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
20 */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
21
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
22 #include "widgetcore.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
23
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
24 #include <glib.h>
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
25 #include <gdk/gdk.h>
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
26
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
27 #include "main.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
28 #include "menurow.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
29 #include "widget.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
30
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
31 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
32 menurow_draw(Widget * widget)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
33 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
34 MenuRow *mr = MENU_ROW(widget);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
35
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
36 GdkPixmap *obj = mr->mr_widget.parent;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
37
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
38 if (mr->mr_selected == MENUROW_NONE) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
39 if (cfg.always_show_cb || mr->mr_bpushed)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
40 skin_draw_pixmap(bmp_active_skin, obj,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
41 mr->mr_widget.gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
42 mr->mr_skin_index,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
43 mr->mr_nx, mr->mr_ny,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
44 mr->mr_widget.x, mr->mr_widget.y, 8, 43);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
45 else
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
46 skin_draw_pixmap(bmp_active_skin, obj,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
47 mr->mr_widget.gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
48 mr->mr_skin_index,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
49 mr->mr_nx + 8, mr->mr_ny,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
50 mr->mr_widget.x, mr->mr_widget.y, 8, 43);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
51 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
52 else {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
53 skin_draw_pixmap(bmp_active_skin, obj,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
54 mr->mr_widget.gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
55 mr->mr_skin_index,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
56 mr->mr_sx + ((mr->mr_selected - 1) * 8),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
57 mr->mr_sy, mr->mr_widget.x, mr->mr_widget.y, 8, 43);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
58 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
59 if (cfg.always_show_cb || mr->mr_bpushed) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
60 if (mr->mr_always_selected)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
61 skin_draw_pixmap(bmp_active_skin, obj,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
62 mr->mr_widget.gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
63 mr->mr_skin_index,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
64 mr->mr_sx + 8, mr->mr_sy + 10,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
65 mr->mr_widget.x, mr->mr_widget.y + 10, 8, 8);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
66 if (mr->mr_doublesize_selected)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
67 skin_draw_pixmap(bmp_active_skin, obj,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
68 mr->mr_widget.gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
69 mr->mr_skin_index,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
70 mr->mr_sx + 24, mr->mr_sy + 26,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
71 mr->mr_widget.x, mr->mr_widget.y + 26, 8, 8);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
72 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
73
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
74 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
75
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
76 MenuRowItem
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
77 menurow_find_selected(MenuRow * mr, gint x, gint y)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
78 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
79 MenuRowItem ret = MENUROW_NONE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
80
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
81 x -= mr->mr_widget.x;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
82 y -= mr->mr_widget.y;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
83 if (x > 0 && x < 8) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
84 if (y >= 0 && y <= 10)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
85 ret = MENUROW_OPTIONS;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
86 if (y >= 10 && y <= 17)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
87 ret = MENUROW_ALWAYS;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
88 if (y >= 18 && y <= 25)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
89 ret = MENUROW_FILEINFOBOX;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
90 if (y >= 26 && y <= 33)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
91 ret = MENUROW_DOUBLESIZE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
92 if (y >= 34 && y <= 42)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
93 ret = MENUROW_VISUALIZATION;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
94 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
95 return ret;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
96 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
97
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
98 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
99 menurow_button_press(GtkWidget * widget,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
100 GdkEventButton * event,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
101 gpointer data)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
102 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
103 MenuRow *mr = MENU_ROW(data);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
104
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
105 if (event->button != 1)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
106 return;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
107
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
108 if (widget_contains(&mr->mr_widget, event->x, event->y)) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
109 mr->mr_bpushed = TRUE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
110 mr->mr_selected = menurow_find_selected(mr, event->x, event->y);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
111
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
112 widget_draw(WIDGET(mr));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
113
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
114 if (mr->mr_change_callback)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
115 mr->mr_change_callback(mr->mr_selected);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
116 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
117 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
118
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
119 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
120 menurow_motion(GtkWidget * widget,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
121 GdkEventMotion * event,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
122 gpointer data)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
123 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
124 MenuRow *mr = MENU_ROW(data);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
125
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
126 if (mr->mr_bpushed) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
127 mr->mr_selected = menurow_find_selected(mr, event->x, event->y);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
128
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
129 widget_draw(WIDGET(mr));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
130
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
131 if (mr->mr_change_callback)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
132 mr->mr_change_callback(mr->mr_selected);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
133 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
134 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
135
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
136 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
137 menurow_button_release(GtkWidget * widget,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
138 GdkEventButton * event,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
139 gpointer data)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
140 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
141 MenuRow *mr = MENU_ROW(data);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
142
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
143 if (mr->mr_bpushed) {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
144 mr->mr_bpushed = FALSE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
145
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
146 if (mr->mr_selected == MENUROW_ALWAYS)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
147 mr->mr_always_selected = !mr->mr_always_selected;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
148
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
149 if (mr->mr_selected == MENUROW_DOUBLESIZE)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
150 mr->mr_doublesize_selected = !mr->mr_doublesize_selected;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
151
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
152 if ((int)(mr->mr_selected) != -1 && mr->mr_release_callback)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
153 mr->mr_release_callback(mr->mr_selected);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
154
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
155 mr->mr_selected = MENUROW_NONE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
156
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
157 widget_draw(WIDGET(mr));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
158 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
159 }
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
160
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
161 MenuRow *
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
162 create_menurow(GList ** wlist, GdkPixmap * parent, GdkGC * gc,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
163 gint x, gint y, gint nx, gint ny, gint sx, gint sy,
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
164 void (*ccb) (MenuRowItem),
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
165 void (*rcb) (MenuRowItem), SkinPixmapId si)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
166 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
167 MenuRow *mr;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
168
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
169 mr = g_new0(MenuRow, 1);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
170 widget_init(&mr->mr_widget, parent, gc, x, y, 8, 43, 1);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
171 mr->mr_widget.draw = menurow_draw;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
172 mr->mr_widget.button_press_cb = menurow_button_press;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
173 mr->mr_widget.motion_cb = menurow_motion;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
174 mr->mr_widget.button_release_cb = menurow_button_release;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
175 mr->mr_nx = nx;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
176 mr->mr_ny = ny;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
177 mr->mr_sx = sx;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
178 mr->mr_sy = sy;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
179 mr->mr_selected = MENUROW_NONE;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
180 mr->mr_change_callback = ccb;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
181 mr->mr_release_callback = rcb;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
182 mr->mr_skin_index = si;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
183
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
184 widget_list_add(wlist, WIDGET(mr));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
185 return mr;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents:
diff changeset
186 }