1 /*****************************************************************************
2 * osd.c - The OSD Menu core code.
3 *****************************************************************************
4 * Copyright (C) 2005-2008 M2X
7 * Authors: Jean-Paul Saman <jpsaman #_at_# m2x dot nl>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
32 #include <vlc_common.h>
35 #include <vlc_image.h>
41 /*****************************************************************************
43 *****************************************************************************/
45 static void osd_UpdateState( osd_menu_state_t *, int, int, int, int, picture_t * );
46 static inline osd_state_t *osd_VolumeStateChange( osd_state_t *, int );
47 static int osd_VolumeStep( vlc_object_t *, int, int );
48 static bool osd_isVisible( osd_menu_t *p_osd );
49 static bool osd_ParserLoad( osd_menu_t *, const char * );
50 static void osd_ParserUnload( osd_menu_t * );
52 static bool osd_isVisible( osd_menu_t *p_osd )
56 var_Get( p_osd, "osd-menu-visible", &val );
60 /*****************************************************************************
61 * Wrappers for loading and unloading osd parser modules.
62 *****************************************************************************/
63 static bool osd_ParserLoad( osd_menu_t *p_menu, const char *psz_file )
65 /* Stuff needed for Parser */
66 p_menu->psz_file = strdup( psz_file );
67 p_menu->p_image = image_HandlerCreate( p_menu );
68 if( !p_menu->p_image || !p_menu->psz_file )
70 msg_Err( p_menu, "unable to load images, aborting .." );
76 char *psz_ext = strrchr( p_menu->psz_file, '.' );
78 if( psz_ext && !strcmp( psz_ext, ".cfg") )
79 psz_type = (char*)"import-osd";
81 psz_type = (char*)"import-osd-xml";
83 p_menu->p_parser = module_need( p_menu, "osd parser",
85 if( !p_menu->p_parser )
93 static void osd_ParserUnload( osd_menu_t *p_menu )
96 image_HandlerDelete( p_menu->p_image );
98 if( p_menu->p_parser )
99 module_unneed( p_menu, p_menu->p_parser );
101 free( p_menu->psz_file );
105 * Change state on an osd_button_t.
107 * This function selects the specified state and returns a pointer vlc_custom_createto it. The
108 * following states are currently supported:
109 * \see OSD_BUTTON_UNSELECT
110 * \see OSD_BUTTON_SELECT
111 * \see OSD_BUTTON_PRESSED
113 static osd_state_t *osd_StateChange( osd_button_t *p_button, const int i_state )
115 osd_state_t *p_current = p_button->p_states;
116 osd_state_t *p_temp = NULL;
119 for( i=0; p_current != NULL; i++ )
121 if( p_current->i_state == i_state )
123 p_button->i_x = p_current->i_x;
124 p_button->i_y = p_current->i_y;
125 p_button->i_width = p_current->i_width;
126 p_button->i_height = p_current->i_height;
129 p_temp = p_current->p_next;
132 return p_button->p_states;
135 /*****************************************************************************
137 *****************************************************************************/
138 osd_menu_t *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file )
140 osd_menu_t *p_osd = NULL;
141 vlc_value_t lockval, val;
145 /* to be sure to avoid multiple creation */
146 var_Create( p_this->p_libvlc, "osd_mutex", VLC_VAR_MUTEX );
147 var_Create( p_this->p_libvlc, "osd", VLC_VAR_ADDRESS );
148 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
149 vlc_mutex_lock( lockval.p_address );
151 var_Get( p_this->p_libvlc, "osd", &val );
152 if( val.p_address == NULL )
154 static const char osdmenu_name[] = "osd menu";
156 p_osd = vlc_custom_create( p_this, sizeof( *p_osd ),
157 VLC_OBJECT_GENERIC, osdmenu_name );
161 p_osd->p_parser = NULL;
162 vlc_object_attach( p_osd, p_this->p_libvlc );
164 /* Parse configuration file */
165 if ( !osd_ParserLoad( p_osd, psz_file ) )
167 if( !p_osd->p_state )
170 /* Setup default button (first button) */
171 p_osd->p_state->p_visible = p_osd->p_button;
172 p_osd->p_state->p_visible->p_current_state =
173 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
174 p_osd->i_width = p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch;
175 p_osd->i_height = p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_lines;
177 if( p_osd->p_state->p_volume )
179 /* Update the volume state images to match the current volume */
180 i_volume = config_GetInt( p_this, "volume" );
181 i_steps = osd_VolumeStep( p_this, i_volume, p_osd->p_state->p_volume->i_ranges );
182 p_osd->p_state->p_volume->p_current_state = osd_VolumeStateChange(
183 p_osd->p_state->p_volume->p_states, i_steps );
185 /* Initialize OSD state */
186 osd_UpdateState( p_osd->p_state, p_osd->i_x, p_osd->i_y,
187 p_osd->i_width, p_osd->i_height, NULL );
189 /* Signal when an update of OSD menu is needed */
190 var_Create( p_osd, "osd-menu-update", VLC_VAR_BOOL );
191 var_Create( p_osd, "osd-menu-visible", VLC_VAR_BOOL );
193 var_SetBool( p_osd, "osd-menu-update", false );
194 var_SetBool( p_osd, "osd-menu-visible", false );
196 val.p_address = p_osd;
197 var_Set( p_this->p_libvlc, "osd", val );
200 p_osd = val.p_address;
201 vlc_object_hold( p_osd );
202 vlc_mutex_unlock( lockval.p_address );
206 vlc_mutex_unlock( lockval.p_address );
207 __osd_MenuDelete( p_this, p_osd );
211 void __osd_MenuDelete( vlc_object_t *p_this, osd_menu_t *p_osd )
215 if( !p_osd || !p_this ) return;
217 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
218 vlc_mutex_lock( lockval.p_address );
220 if( vlc_internals( VLC_OBJECT(p_osd) )->i_refcount == 1 )
224 var_Destroy( p_osd, "osd-menu-visible" );
225 var_Destroy( p_osd, "osd-menu-update" );
226 osd_ParserUnload( p_osd );
227 val.p_address = NULL;
228 var_Set( p_this->p_libvlc, "osd", val );
231 vlc_object_release( p_osd );
232 vlc_mutex_unlock( lockval.p_address );
235 static osd_menu_t *osd_Find( vlc_object_t *p_this )
239 if( var_Get( p_this->p_libvlc, "osd", &val ) )
241 return val.p_address;
244 /* The volume can be modified in another interface while the OSD Menu
245 * has not been instantiated yet. This routines updates the "volume OSD menu item"
246 * to reflect the current state of the GUI.
248 static inline osd_state_t *osd_VolumeStateChange( osd_state_t *p_current, int i_steps )
250 osd_state_t *p_temp = NULL;
253 if( i_steps < 0 ) i_steps = 0;
255 for( i=0; (i < i_steps) && (p_current != NULL); i++ )
257 p_temp = p_current->p_next;
258 if( !p_temp ) return p_current;
261 return (!p_temp) ? p_current : p_temp;
264 /* Update the state of the OSD Menu */
265 static void osd_UpdateState( osd_menu_state_t *p_state, int i_x, int i_y,
266 int i_width, int i_height, picture_t *p_pic )
270 p_state->i_width = i_width;
271 p_state->i_height = i_height;
272 p_state->p_pic = p_pic;
275 void __osd_MenuShow( vlc_object_t *p_this )
278 osd_button_t *p_button = NULL;
281 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
282 vlc_mutex_lock( lockval.p_address );
283 p_osd = osd_Find( p_this );
286 vlc_mutex_unlock( lockval.p_address );
287 msg_Err( p_this, "osd_MenuShow failed" );
291 #if defined(OSD_MENU_DEBUG)
292 msg_Dbg( p_osd, "menu on" );
294 p_button = p_osd->p_state->p_visible;
297 if( !p_button->b_range )
298 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_UNSELECT );
299 p_osd->p_state->p_visible = p_osd->p_button;
301 if( !p_osd->p_state->p_visible->b_range )
302 p_osd->p_state->p_visible->p_current_state =
303 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
305 osd_UpdateState( p_osd->p_state,
306 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
307 p_osd->p_state->p_visible->p_current_state->i_width,
308 p_osd->p_state->p_visible->p_current_state->i_height,
309 p_osd->p_state->p_visible->p_current_state->p_pic );
310 osd_SetMenuUpdate( p_osd, true );
312 osd_SetMenuVisible( p_osd, true );
314 vlc_mutex_unlock( lockval.p_address );
317 void __osd_MenuHide( vlc_object_t *p_this )
322 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
323 vlc_mutex_lock( lockval.p_address );
325 p_osd = osd_Find( p_this );
328 vlc_mutex_unlock( lockval.p_address );
329 msg_Err( p_this, "osd_MenuHide failed" );
333 #if defined(OSD_MENU_DEBUG)
334 msg_Dbg( p_osd, "menu off" );
336 osd_UpdateState( p_osd->p_state,
337 p_osd->p_state->i_x, p_osd->p_state->i_y,
339 osd_SetMenuUpdate( p_osd, true );
341 vlc_mutex_unlock( lockval.p_address );
344 void __osd_MenuActivate( vlc_object_t *p_this )
347 osd_button_t *p_button = NULL;
350 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
351 vlc_mutex_lock( lockval.p_address );
353 p_osd = osd_Find( p_this );
354 if( p_osd == NULL || !osd_isVisible( p_osd ) )
356 vlc_mutex_unlock( lockval.p_address );
357 msg_Err( p_this, "osd_MenuActivate failed" );
361 #if defined(OSD_MENU_DEBUG)
362 msg_Dbg( p_osd, "select" );
364 p_button = p_osd->p_state->p_visible;
366 * Is there a menu item above or below? If so, then select it.
368 if( p_button && p_button->p_up )
370 vlc_mutex_unlock( lockval.p_address );
371 __osd_MenuUp( p_this ); /* "menu select" means go to menu item above. */
374 if( p_button && p_button->p_down )
376 vlc_mutex_unlock( lockval.p_address );
377 __osd_MenuDown( p_this ); /* "menu select" means go to menu item below. */
381 if( p_button && !p_button->b_range )
383 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_PRESSED );
384 osd_UpdateState( p_osd->p_state,
385 p_button->i_x, p_button->i_y,
386 p_osd->p_state->p_visible->p_current_state->i_width,
387 p_osd->p_state->p_visible->p_current_state->i_height,
388 p_button->p_current_state->p_pic );
389 osd_SetMenuUpdate( p_osd, true );
390 osd_SetMenuVisible( p_osd, true );
391 osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), config_GetInt( p_osd, p_button->psz_action ) );
392 #if defined(OSD_MENU_DEBUG)
393 msg_Dbg( p_osd, "select (%d, %s)", config_GetInt( p_osd, p_button->psz_action ), p_button->psz_action );
396 vlc_mutex_unlock( lockval.p_address );
399 void __osd_MenuNext( vlc_object_t *p_this )
402 osd_button_t *p_button = NULL;
405 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
406 vlc_mutex_lock( lockval.p_address );
408 p_osd = osd_Find( p_this );
409 if( p_osd == NULL || !osd_isVisible( p_osd ) )
411 vlc_mutex_unlock( lockval.p_address );
412 msg_Err( p_this, "osd_MenuNext failed" );
416 p_button = p_osd->p_state->p_visible;
419 if( !p_button->b_range )
420 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_UNSELECT );
421 if( p_button->p_next )
422 p_osd->p_state->p_visible = p_button->p_next;
424 p_osd->p_state->p_visible = p_osd->p_button;
426 if( !p_osd->p_state->p_visible->b_range )
427 p_osd->p_state->p_visible->p_current_state =
428 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
430 osd_UpdateState( p_osd->p_state,
431 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
432 p_osd->p_state->p_visible->p_current_state->i_width,
433 p_osd->p_state->p_visible->p_current_state->i_height,
434 p_osd->p_state->p_visible->p_current_state->p_pic );
435 osd_SetMenuUpdate( p_osd, true );
437 #if defined(OSD_MENU_DEBUG)
438 msg_Dbg( p_osd, "direction right [button %s]", p_osd->p_state->p_visible->psz_action );
441 vlc_mutex_unlock( lockval.p_address );
444 void __osd_MenuPrev( vlc_object_t *p_this )
447 osd_button_t *p_button = NULL;
450 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
451 vlc_mutex_lock( lockval.p_address );
452 p_osd = osd_Find( p_this );
453 if( p_osd == NULL || !osd_isVisible( p_osd ) )
455 vlc_mutex_unlock( lockval.p_address );
456 msg_Err( p_this, "osd_MenuPrev failed" );
460 p_button = p_osd->p_state->p_visible;
463 if( !p_button->b_range )
464 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_UNSELECT );
465 if( p_button->p_prev )
466 p_osd->p_state->p_visible = p_button->p_prev;
468 p_osd->p_state->p_visible = p_osd->p_last_button;
470 if( !p_osd->p_state->p_visible->b_range )
471 p_osd->p_state->p_visible->p_current_state =
472 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
474 osd_UpdateState( p_osd->p_state,
475 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
476 p_osd->p_state->p_visible->p_current_state->i_width,
477 p_osd->p_state->p_visible->p_current_state->i_height,
478 p_osd->p_state->p_visible->p_current_state->p_pic );
479 osd_SetMenuUpdate( p_osd, true );
481 #if defined(OSD_MENU_DEBUG)
482 msg_Dbg( p_osd, "direction left [button %s]", p_osd->p_state->p_visible->psz_action );
485 vlc_mutex_unlock( lockval.p_address );
488 void __osd_MenuUp( vlc_object_t *p_this )
491 osd_button_t *p_button = NULL;
493 #if defined(OSD_MENU_DEBUG)
497 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
498 vlc_mutex_lock( lockval.p_address );
499 p_osd = osd_Find( p_this );
500 if( p_osd == NULL || !osd_isVisible( p_osd ) )
502 vlc_mutex_unlock( lockval.p_address );
503 msg_Err( p_this, "osd_MenuActivate failed" );
507 p_button = p_osd->p_state->p_visible;
510 if( !p_button->b_range )
512 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_SELECT );
514 p_osd->p_state->p_visible = p_button->p_up;
517 if( p_button->b_range && p_osd->p_state->p_visible->b_range )
519 osd_state_t *p_temp = p_osd->p_state->p_visible->p_current_state;
520 if( p_temp && p_temp->p_next )
521 p_osd->p_state->p_visible->p_current_state = p_temp->p_next;
523 else if( !p_osd->p_state->p_visible->b_range )
525 p_osd->p_state->p_visible->p_current_state =
526 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
529 osd_UpdateState( p_osd->p_state,
530 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
531 p_osd->p_state->p_visible->p_current_state->i_width,
532 p_osd->p_state->p_visible->p_current_state->i_height,
533 p_osd->p_state->p_visible->p_current_state->p_pic );
534 osd_SetMenuUpdate( p_osd, true );
535 /* If this is a range style action with associated images of only one state,
536 * then perform "menu select" on every menu navigation
538 if( p_button->b_range )
540 osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), config_GetInt(p_osd, p_button->psz_action) );
541 #if defined(OSD_MENU_DEBUG)
542 msg_Dbg( p_osd, "select (%d, %s)", val.i_int, p_button->psz_action );
546 #if defined(OSD_MENU_DEBUG)
547 msg_Dbg( p_osd, "direction up [button %s]", p_osd->p_state->p_visible->psz_action );
550 vlc_mutex_unlock( lockval.p_address );
553 void __osd_MenuDown( vlc_object_t *p_this )
556 osd_button_t *p_button = NULL;
558 #if defined(OSD_MENU_DEBUG)
562 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
563 vlc_mutex_lock( lockval.p_address );
565 p_osd = osd_Find( p_this );
566 if( p_osd == NULL || !osd_isVisible( p_osd ) )
568 vlc_mutex_unlock( lockval.p_address );
569 msg_Err( p_this, "osd_MenuActivate failed" );
573 p_button = p_osd->p_state->p_visible;
576 if( !p_button->b_range )
578 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_SELECT );
579 if( p_button->p_down )
580 p_osd->p_state->p_visible = p_button->p_down;
583 if( p_button->b_range && p_osd->p_state->p_visible->b_range )
585 osd_state_t *p_temp = p_osd->p_state->p_visible->p_current_state;
586 if( p_temp && p_temp->p_prev )
587 p_osd->p_state->p_visible->p_current_state = p_temp->p_prev;
589 else if( !p_osd->p_state->p_visible->b_range )
591 p_osd->p_state->p_visible->p_current_state =
592 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
595 osd_UpdateState( p_osd->p_state,
596 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
597 p_osd->p_state->p_visible->p_current_state->i_width,
598 p_osd->p_state->p_visible->p_current_state->i_height,
599 p_osd->p_state->p_visible->p_current_state->p_pic );
600 osd_SetMenuUpdate( p_osd, true );
601 /* If this is a range style action with associated images of only one state,
602 * then perform "menu select" on every menu navigation
604 if( p_button->b_range )
606 osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), config_GetInt(p_osd, p_button->psz_action_down) );
607 #if defined(OSD_MENU_DEBUG)
608 msg_Dbg( p_osd, "select (%d, %s)", val.i_int, p_button->psz_action_down );
612 #if defined(OSD_MENU_DEBUG)
613 msg_Dbg( p_osd, "direction down [button %s]", p_osd->p_state->p_visible->psz_action );
616 vlc_mutex_unlock( lockval.p_address );
619 static int osd_VolumeStep( vlc_object_t *p_this, int i_volume, int i_steps )
621 int i_volume_step = 0;
624 i_volume_step = config_GetInt( p_this->p_libvlc, "volume-step" );
625 return (i_volume/i_volume_step);
629 * Display current audio volume bitmap
631 * The OSD Menu audio volume bar is updated to reflect the new audio volume. Call this function
632 * when the audio volume is updated outside the OSD menu command "menu up", "menu down" or "menu select".
634 void __osd_Volume( vlc_object_t *p_this )
637 osd_button_t *p_button = NULL;
642 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
643 vlc_mutex_lock( lockval.p_address );
645 p_osd = osd_Find( p_this );
648 vlc_mutex_unlock( lockval.p_address );
649 msg_Err( p_this, "OSD menu volume update failed" );
653 if( p_osd->p_state && p_osd->p_state->p_volume )
656 p_button = p_osd->p_state->p_volume;
657 if( p_osd->p_state->p_volume )
658 p_osd->p_state->p_visible = p_osd->p_state->p_volume;
659 if( p_button && p_button->b_range )
661 /* Update the volume state images to match the current volume */
662 i_volume = config_GetInt( p_this, "volume" );
663 i_steps = osd_VolumeStep( p_this, i_volume, p_button->i_ranges );
664 p_button->p_current_state = osd_VolumeStateChange( p_button->p_states, i_steps );
666 osd_UpdateState( p_osd->p_state,
667 p_button->i_x, p_button->i_y,
668 p_button->p_current_state->i_width,
669 p_button->p_current_state->i_height,
670 p_button->p_current_state->p_pic );
671 osd_SetMenuUpdate( p_osd, true );
672 osd_SetMenuVisible( p_osd, true );
675 vlc_mutex_unlock( lockval.p_address );
678 osd_button_t *__osd_ButtonFind( vlc_object_t *p_this, int i_x, int i_y,
679 int i_window_height, int i_window_width,
680 int i_scale_width, int i_scale_height )
683 osd_button_t *p_button;
686 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
687 vlc_mutex_lock( lockval.p_address );
689 p_osd = osd_Find( p_this );
690 if( p_osd == NULL || !osd_isVisible( p_osd ) )
692 vlc_mutex_unlock( lockval.p_address );
693 msg_Err( p_this, "osd_ButtonFind failed" );
697 p_button = p_osd->p_button;
698 for( ; p_button != NULL; p_button = p_button->p_next )
700 int i_source_video_width = ( i_window_width * 1000 ) / i_scale_width;
701 int i_source_video_height = ( i_window_height * 1000 ) / i_scale_height;
702 int i_y_offset = p_button->i_y;
703 int i_x_offset = p_button->i_x;
704 int i_width = p_button->i_width;
705 int i_height = p_button->i_height;
707 if( p_osd->i_position > 0 )
709 int i_inv_scale_y = i_source_video_height;
710 int i_inv_scale_x = i_source_video_width;
713 if( p_osd->i_position & SUBPICTURE_ALIGN_BOTTOM )
715 i_y_offset = i_window_height - p_button->i_height -
716 (p_osd->i_y + p_button->i_y) * i_inv_scale_y / 1000;
718 else if ( !(p_osd->i_position & SUBPICTURE_ALIGN_TOP) )
720 i_y_offset = i_window_height / 2 - p_button->i_height / 2;
723 if( p_osd->i_position & SUBPICTURE_ALIGN_RIGHT )
725 i_x_offset = i_window_width - p_button->i_width -
726 (pi_x + p_button->i_x)
727 * i_inv_scale_x / 1000;
729 else if ( !(p_osd->i_position & SUBPICTURE_ALIGN_LEFT) )
731 i_x_offset = i_window_width / 2 - p_button->i_width / 2;
734 i_width = i_window_width - p_button->i_width - i_inv_scale_x / 1000;
735 i_height = i_window_height - p_button->i_height - i_inv_scale_y / 1000;
738 // TODO: write for Up / Down case too.
739 // TODO: handle absolute positioning case
740 if( ( i_x >= i_x_offset ) && ( i_x <= i_x_offset + i_width ) &&
741 ( i_y >= i_y_offset ) && ( i_y <= i_y_offset + i_height ) )
743 vlc_mutex_unlock( lockval.p_address );
748 vlc_mutex_unlock( lockval.p_address );
753 * Select the button provided as the new active button
755 void __osd_ButtonSelect( vlc_object_t *p_this, osd_button_t *p_button )
761 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
762 vlc_mutex_lock( lockval.p_address );
764 p_osd = osd_Find( p_this );
765 if( p_osd == NULL || !osd_isVisible( p_osd ) )
767 vlc_mutex_unlock( lockval.p_address );
768 msg_Err( p_this, "osd_ButtonSelect failed" );
772 p_old = p_osd->p_state->p_visible;
775 if( !p_old->b_range )
776 p_old->p_current_state = osd_StateChange( p_old, OSD_BUTTON_UNSELECT );
777 p_osd->p_state->p_visible = p_button;
779 if( !p_osd->p_state->p_visible->b_range )
780 p_osd->p_state->p_visible->p_current_state =
781 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
783 osd_UpdateState( p_osd->p_state,
784 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
785 p_osd->p_state->p_visible->p_current_state->i_width,
786 p_osd->p_state->p_visible->p_current_state->i_height,
787 p_osd->p_state->p_visible->p_current_state->p_pic );
788 osd_SetMenuUpdate( p_osd, true );
790 #if defined(OSD_MENU_DEBUG)
791 msg_Dbg( p_osd, "button selected is [button %s]", p_osd->p_state->p_visible->psz_action );
794 vlc_mutex_unlock( lockval.p_address );