Mercurial > libdvdnav.hg
annotate highlight.c @ 76:0e2abe7083de src
more consistent console output
author | mroi |
---|---|
date | Tue, 27 Aug 2002 19:15:08 +0000 |
parents | 940b438a9c9f |
children | 129ac4af16a4 |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net> | |
3 * | |
4 * This file is part of libdvdnav, a DVD navigation library. | |
5 * | |
6 * libdvdnav is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * libdvdnav is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
19 * | |
20 * $Id$ | |
21 * | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include "config.h" | |
26 #endif | |
27 | |
28 /* | |
29 #define BUTTON_TESTING | |
30 */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
31 #include <assert.h> |
0 | 32 |
33 #include <dvdnav.h> | |
34 #include "dvdnav_internal.h" | |
35 | |
36 #include "vm.h" | |
37 #include <dvdread/nav_types.h> | |
38 | |
39 #ifdef BUTTON_TESTING | |
40 #include <dvdread/nav_print.h> | |
41 #endif | |
42 | |
43 /* Highlighting API calls */ | |
44 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
45 dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int* button) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
46 if(!this) |
0 | 47 return S_ERR; |
48 | |
49 /* Simply return the appropriate value based on the SPRM */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
50 (*button) = (this->vm->state.HL_BTNN_REG) >> 10; |
0 | 51 |
52 return S_OK; | |
53 } | |
54 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
55 btni_t *__get_current_button(dvdnav_t *this) { |
0 | 56 int button = 0; |
57 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
58 if(dvdnav_get_current_highlight(this, &button) != S_OK) { |
76 | 59 printerr("Unable to get information on current highlight."); |
0 | 60 return NULL; |
61 } | |
62 #ifdef BUTTON_TESTING | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
63 navPrint_PCI(&(this->pci)); |
0 | 64 #endif |
65 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
66 return &(this->pci.hli.btnit[button-1]); |
0 | 67 } |
68 | |
29 | 69 dvdnav_status_t dvdnav_button_auto_action(dvdnav_t *this) { |
70 btni_t *button_ptr; | |
71 | |
72 if(!this) | |
73 return S_ERR; | |
74 | |
75 if((button_ptr = __get_current_button(this)) == NULL) { | |
76 return S_ERR; | |
77 } | |
78 if (button_ptr->auto_action_mode == 1) { | |
79 return S_OK; | |
80 } | |
81 return S_ERR; | |
82 } | |
83 | |
84 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
85 dvdnav_status_t dvdnav_upper_button_select(dvdnav_t *this) { |
0 | 86 btni_t *button_ptr; |
87 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
88 if(!this) |
0 | 89 return S_ERR; |
90 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
91 if((button_ptr = __get_current_button(this)) == NULL) { |
0 | 92 return S_ERR; |
93 } | |
94 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
95 dvdnav_button_select(this, button_ptr->up); |
29 | 96 if (dvdnav_button_auto_action(this) ) { |
97 dvdnav_button_activate(this); | |
98 } | |
99 | |
0 | 100 return S_OK; |
101 } | |
102 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
103 dvdnav_status_t dvdnav_lower_button_select(dvdnav_t *this) { |
0 | 104 btni_t *button_ptr; |
105 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
106 if(!this) |
0 | 107 return S_ERR; |
108 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
109 if((button_ptr = __get_current_button(this)) == NULL) { |
0 | 110 return S_ERR; |
111 } | |
112 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
113 dvdnav_button_select(this, button_ptr->down); |
29 | 114 if (dvdnav_button_auto_action(this) ) { |
115 dvdnav_button_activate(this); | |
116 } | |
0 | 117 |
118 return S_OK; | |
119 } | |
120 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
121 dvdnav_status_t dvdnav_right_button_select(dvdnav_t *this) { |
0 | 122 btni_t *button_ptr; |
123 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
124 if(!this) |
0 | 125 return S_ERR; |
126 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
127 if((button_ptr = __get_current_button(this)) == NULL) { |
0 | 128 printerr("Error fetching information on current button."); |
129 return S_ERR; | |
130 } | |
131 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
132 dvdnav_button_select(this, button_ptr->right); |
29 | 133 if (dvdnav_button_auto_action(this) ) { |
134 dvdnav_button_activate(this); | |
135 } | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
136 |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
137 return S_OK; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
138 } |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
139 |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
140 dvdnav_status_t dvdnav_left_button_select(dvdnav_t *this) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
141 btni_t *button_ptr; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
142 |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
143 if(!this) |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
144 return S_ERR; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
145 |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
146 if((button_ptr = __get_current_button(this)) == NULL) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
147 return S_ERR; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
148 } |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
149 |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
150 dvdnav_button_select(this, button_ptr->left); |
29 | 151 if (dvdnav_button_auto_action(this) ) { |
152 dvdnav_button_activate(this); | |
153 } | |
0 | 154 |
155 return S_OK; | |
156 } | |
157 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
158 dvdnav_status_t dvdnav_get_highlight_area(pci_t* nav_pci , int32_t button, int32_t mode, |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
159 dvdnav_highlight_area_t* highlight) { |
0 | 160 btni_t *button_ptr; |
31 | 161 #ifdef BUTTON_TESTING |
76 | 162 fprintf(MSG_OUT, "libdvdnav: Button get_highlight_area %i\n", button); |
31 | 163 #endif |
0 | 164 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
165 /* Set the highlight SPRM if the passed button was valid*/ |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
166 if((button <= 0) || (button > nav_pci->hli.hl_gi.btn_ns)) { |
76 | 167 fprintf(MSG_OUT, "libdvdnav: Unable to select button number %i as it doesn't exist\n", |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
168 button); |
0 | 169 return S_ERR; |
170 } | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
171 button_ptr = &nav_pci->hli.btnit[button-1]; |
0 | 172 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
173 highlight->sx = button_ptr->x_start; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
174 highlight->sy = button_ptr->y_start; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
175 highlight->ex = button_ptr->x_end; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
176 highlight->ey = button_ptr->y_end; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
177 if(button_ptr->btn_coln != 0) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
178 highlight->palette = nav_pci->hli.btn_colit.btn_coli[button_ptr->btn_coln-1][mode]; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
179 } else { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
180 highlight->palette = 0; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
181 } |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
182 highlight->pts = nav_pci->hli.hl_gi.hli_s_ptm; |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
183 highlight->buttonN = button; |
31 | 184 #ifdef BUTTON_TESTING |
76 | 185 fprintf(MSG_OUT, "libdvdnav: highlight.c:Highlight area is (%u,%u)-(%u,%u), display = %i, button = %u\n", |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
186 button_ptr->x_start, button_ptr->y_start, |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
187 button_ptr->x_end, button_ptr->y_end, |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
188 1, |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
189 button); |
31 | 190 #endif |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
191 |
0 | 192 return S_OK; |
193 } | |
194 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
195 dvdnav_status_t dvdnav_button_activate(dvdnav_t *this) { |
0 | 196 int button; |
26 | 197 btni_t *button_ptr = NULL; |
0 | 198 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
199 if(!this) |
0 | 200 return S_ERR; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
201 pthread_mutex_lock(&this->vm_lock); |
0 | 202 |
203 /* Precisely the same as selecting a button except we want | |
204 * a different palette */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
205 if(dvdnav_get_current_highlight(this, &button) != S_OK) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
206 pthread_mutex_unlock(&this->vm_lock); |
0 | 207 return S_ERR; |
208 } | |
57 | 209 /* FIXME: dvdnav_button_select should really return a |
210 * special case for explicit NO-BUTTONS. | |
211 */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
212 if(dvdnav_button_select(this, button) != S_OK) { |
57 | 213 /* Special code to handle still menus with no buttons. |
214 * the navigation is expected to report to the appicatino that a STILL is | |
215 * underway. In turn, the application is supposed to report to the user | |
216 * that the playback is pause. The user is then expected to undo the pause. | |
217 * ie: hit play. At that point, the navigation should release the still and | |
218 * go to the next Cell. | |
219 * Explanation by Mathieu Lavage <mathieu_lacage@realmagic.fr> | |
220 * Code added by jcdutton. | |
221 */ | |
222 if (this->position_current.still != 0) { | |
223 /* In still, but no buttons. */ | |
224 vm_get_next_cell(this->vm); | |
225 this->position_current.still = 0; | |
226 pthread_mutex_unlock(&this->vm_lock); | |
227 return S_OK; | |
228 } | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
229 pthread_mutex_unlock(&this->vm_lock); |
0 | 230 return S_ERR; |
231 } | |
26 | 232 /* FIXME: The button command should really be passed in the API instead. */ |
233 button_ptr = __get_current_button(this); | |
0 | 234 /* Finally, make the VM execute the appropriate code and |
235 * scedule a jump */ | |
31 | 236 #ifdef BUTTON_TESTING |
76 | 237 fprintf(MSG_OUT, "libdvdnav: Evaluating Button Activation commands.\n"); |
31 | 238 #endif |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
239 if(vm_eval_cmd(this->vm, &(button_ptr->cmd)) == 1) { |
26 | 240 /* Command caused a jump */ |
241 this->vm->hop_channel++; | |
242 this->position_current.still = 0; | |
0 | 243 } |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
244 pthread_mutex_unlock(&this->vm_lock); |
0 | 245 return S_OK; |
246 } | |
247 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
248 dvdnav_status_t dvdnav_button_select(dvdnav_t *this, int button) { |
0 | 249 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
250 if(!this) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
251 printerrf("Unable to select button number %i as this state bad", |
0 | 252 button); |
253 return S_ERR; | |
254 } | |
255 | |
31 | 256 #ifdef BUTTON_TESTING |
76 | 257 fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button); |
31 | 258 #endif |
0 | 259 |
260 /* Set the highlight SPRM if the passed button was valid*/ | |
57 | 261 /* FIXME: this->pci should be provided by the application. */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
262 if((button <= 0) || (button > this->pci.hli.hl_gi.btn_ns)) { |
0 | 263 printerrf("Unable to select button number %i as it doesn't exist", |
264 button); | |
265 return S_ERR; | |
266 } | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
267 this->vm->state.HL_BTNN_REG = (button << 10); |
0 | 268 |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
269 this->hli_state = 1; /* Selected */ |
0 | 270 |
64
2759605b41f6
We need to update the button info when moving around in menus.
mroi
parents:
57
diff
changeset
|
271 this->position_current.button = -1; /* Force Highligh change */ |
0 | 272 |
273 return S_OK; | |
274 } | |
275 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
276 dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *this, |
0 | 277 int button) { |
278 /* A trivial function */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
279 if(dvdnav_button_select(this, button) != S_ERR) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
280 return dvdnav_button_activate(this); |
0 | 281 } |
282 | |
283 /* Should never get here without an error */ | |
284 return S_ERR; | |
285 } | |
286 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
287 dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, int x, int y) { |
0 | 288 int button, cur_button; |
69 | 289 uint32_t best,dist; |
290 int mx,my,dx,dy,d; | |
291 | |
0 | 292 /* FIXME: At the moment, the case of no button matchin (x,y) is |
293 * silently ignored, is this OK? */ | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
294 if(!this) |
0 | 295 return S_ERR; |
296 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
297 if(dvdnav_get_current_highlight(this, &cur_button) != S_OK) { |
0 | 298 return S_ERR; |
299 } | |
300 | |
69 | 301 best = 0; |
302 dist = 0x08000000; /* >> than (720*720)+(567*567); */ | |
303 | |
0 | 304 /* Loop through each button */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
305 for(button=1; button <= this->pci.hli.hl_gi.btn_ns; button++) { |
0 | 306 btni_t *button_ptr = NULL; |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
307 button_ptr = &(this->pci.hli.btnit[button-1]); |
0 | 308 if((x >= button_ptr->x_start) && (x <= button_ptr->x_end) && |
309 (y >= button_ptr->y_start) && (y <= button_ptr->y_end)) { | |
69 | 310 mx = (button_ptr->x_start + button_ptr->x_end)/2; |
311 my = (button_ptr->y_start + button_ptr->y_end)/2; | |
312 dx = mx - x; | |
313 dy = my - y; | |
314 d = (dx*dx) + (dy*dy); | |
315 /* If the mouse is within the button and the mouse is closer | |
316 * to the center of this button then it is the best choice. */ | |
317 if(d < dist) { | |
318 dist = d; best=button; | |
0 | 319 } |
320 } | |
321 } | |
69 | 322 |
323 if (best!=0) { | |
324 /* As an efficiency measure, only re-select the button | |
325 * if it is different to the previously selected one. */ | |
326 if(best != cur_button) { | |
327 dvdnav_button_select(this, best); | |
328 } | |
329 } | |
0 | 330 |
331 return S_OK; | |
332 } | |
333 | |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
334 dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *this, int x, int y) { |
0 | 335 /* A trivial function */ |
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
336 if(dvdnav_mouse_select(this, x,y) != S_ERR) { |
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
10
diff
changeset
|
337 return dvdnav_button_activate(this); |
0 | 338 } |
339 | |
340 /* Should never get here without an error */ | |
341 return S_ERR; | |
342 } | |
343 |