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