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>
36 #include <vlc_modules.h>
42 /*****************************************************************************
44 *****************************************************************************/
46 static void osd_UpdateState( osd_menu_state_t *, int, int, int, int, picture_t * );
47 static inline osd_state_t *osd_VolumeStateChange( osd_state_t *, int );
48 static int osd_VolumeStep( vlc_object_t *, int, int );
49 static bool osd_ParserLoad( osd_menu_t *, const char * );
50 static void osd_ParserUnload( osd_menu_t * );
52 static inline bool osd_isVisible( osd_menu_t *p_osd )
54 return var_GetBool( p_osd, "osd-menu-visible" );
57 static vlc_mutex_t *osd_GetMutex( vlc_object_t *p_this )
61 var_Create( p_this->p_libvlc, "osd_mutex", VLC_VAR_MUTEX );
62 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
63 return lockval.p_address;
66 /*****************************************************************************
67 * Wrappers for loading and unloading osd parser modules.
68 *****************************************************************************/
69 static bool osd_ParserLoad( osd_menu_t *p_menu, const char *psz_file )
71 /* Stuff needed for Parser */
72 p_menu->psz_file = strdup( psz_file );
73 p_menu->p_image = image_HandlerCreate( p_menu );
74 if( !p_menu->p_image || !p_menu->psz_file )
76 msg_Err( p_menu, "unable to load images, aborting .." );
82 const char *psz_ext = strrchr( p_menu->psz_file, '.' );
84 if( psz_ext && !strcmp( psz_ext, ".cfg") )
85 psz_type = "import-osd";
87 psz_type = "import-osd-xml";
89 p_menu->p_parser = module_need( p_menu, "osd parser",
91 if( !p_menu->p_parser )
99 static void osd_ParserUnload( osd_menu_t *p_menu )
101 if( p_menu->p_image )
102 image_HandlerDelete( p_menu->p_image );
104 if( p_menu->p_parser )
105 module_unneed( p_menu, p_menu->p_parser );
107 free( p_menu->psz_file );
111 * Change state on an osd_button_t.
113 * This function selects the specified state and returns a pointer
114 * vlc_custom_create to it. The following states are currently supported:
115 * \see OSD_BUTTON_UNSELECT
116 * \see OSD_BUTTON_SELECT
117 * \see OSD_BUTTON_PRESSED
119 static osd_state_t *osd_StateChange( osd_button_t *p_button, const int i_state )
121 osd_state_t *p_current = p_button->p_states;
122 osd_state_t *p_temp = NULL;
125 for( i= 0; p_current != NULL; i++ )
127 if( p_current->i_state == i_state )
129 p_button->i_x = p_current->i_x;
130 p_button->i_y = p_current->i_y;
131 p_button->i_width = p_current->i_width;
132 p_button->i_height = p_current->i_height;
135 p_temp = p_current->p_next;
138 return p_button->p_states;
141 #undef osd_MenuCreate
142 /*****************************************************************************
144 *****************************************************************************/
145 osd_menu_t *osd_MenuCreate( vlc_object_t *p_this, const char *psz_file )
147 osd_menu_t *p_osd = NULL;
153 /* to be sure to avoid multiple creation */
154 p_lock = osd_GetMutex( p_this );
155 vlc_mutex_lock( p_lock );
157 var_Create( p_this->p_libvlc, "osd-object", VLC_VAR_ADDRESS );
158 var_Get( p_this->p_libvlc, "osd-object", &val );
159 if( val.p_address == NULL )
161 static const char osdmenu_name[] = "osd menu";
163 p_osd = vlc_custom_create( p_this->p_libvlc, sizeof( *p_osd ),
164 VLC_OBJECT_GENERIC, osdmenu_name );
168 p_osd->p_parser = NULL;
170 /* Parse configuration file */
171 if ( !osd_ParserLoad( p_osd, psz_file ) )
173 if( !p_osd->p_state )
176 /* Setup default button (first button) */
177 p_osd->p_state->p_visible = p_osd->p_button;
178 p_osd->p_state->p_visible->p_current_state =
179 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
180 p_osd->i_width = p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch;
181 p_osd->i_height = p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_lines;
183 if( p_osd->p_state->p_volume )
185 /* Update the volume state images to match the current volume */
186 i_volume = config_GetInt( p_this, "volume" );
187 i_steps = osd_VolumeStep( p_this, i_volume, p_osd->p_state->p_volume->i_ranges );
188 p_osd->p_state->p_volume->p_current_state = osd_VolumeStateChange(
189 p_osd->p_state->p_volume->p_states, i_steps );
191 /* Initialize OSD state */
192 osd_UpdateState( p_osd->p_state, p_osd->i_x, p_osd->i_y,
193 p_osd->i_width, p_osd->i_height, NULL );
195 /* Signal when an update of OSD menu is needed */
196 var_Create( p_osd, "osd-menu-update", VLC_VAR_BOOL );
197 var_Create( p_osd, "osd-menu-visible", VLC_VAR_BOOL );
199 var_SetBool( p_osd, "osd-menu-update", false );
200 var_SetBool( p_osd, "osd-menu-visible", false );
202 var_SetAddress( p_this->p_libvlc, "osd-object", p_osd );
205 p_osd = val.p_address;
206 vlc_object_hold( p_osd );
207 vlc_mutex_unlock( p_lock );
211 vlc_mutex_unlock( p_lock );
212 osd_MenuDelete( p_this, p_osd );
216 #undef osd_MenuDelete
217 void osd_MenuDelete( vlc_object_t *p_this, osd_menu_t *p_osd )
221 if( !p_osd || !p_this ) return;
223 p_lock = osd_GetMutex( p_this );
224 vlc_mutex_lock( p_lock );
226 if( vlc_internals( VLC_OBJECT(p_osd) )->i_refcount == 1 )
228 var_Destroy( p_osd, "osd-menu-visible" );
229 var_Destroy( p_osd, "osd-menu-update" );
230 osd_ParserUnload( p_osd );
231 var_SetAddress( p_this->p_libvlc, "osd-object", NULL );
234 vlc_object_release( p_osd );
235 vlc_mutex_unlock( p_lock );
238 static osd_menu_t *osd_Find( vlc_object_t *p_this )
242 if( var_Get( p_this->p_libvlc, "osd-object", &val ) )
244 return val.p_address;
247 /* The volume can be modified in another interface while the OSD Menu
248 * has not been instantiated yet. This routines updates the "volume OSD menu item"
249 * to reflect the current state of the GUI.
251 static inline osd_state_t *osd_VolumeStateChange( osd_state_t *p_current, int i_steps )
253 osd_state_t *p_temp = NULL;
256 if( i_steps < 0 ) i_steps = 0;
258 for( i=0; (i < i_steps) && (p_current != NULL); i++ )
260 p_temp = p_current->p_next;
261 if( !p_temp ) return p_current;
264 return (!p_temp) ? p_current : p_temp;
267 /* Update the state of the OSD Menu */
268 static void osd_UpdateState( osd_menu_state_t *p_state, int i_x, int i_y,
269 int i_width, int i_height, picture_t *p_pic )
273 p_state->i_width = i_width;
274 p_state->i_height = i_height;
275 p_state->p_pic = p_pic;
279 void osd_MenuShow( vlc_object_t *p_this )
282 osd_button_t *p_button = NULL;
283 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
285 vlc_mutex_lock( p_lock );
286 p_osd = osd_Find( p_this );
289 vlc_mutex_unlock( p_lock );
290 msg_Err( p_this, "osd_MenuShow failed" );
294 #if defined(OSD_MENU_DEBUG)
295 msg_Dbg( p_osd, "menu on" );
297 p_button = p_osd->p_state->p_visible;
300 if( !p_button->b_range )
301 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_UNSELECT );
302 p_osd->p_state->p_visible = p_osd->p_button;
304 if( !p_osd->p_state->p_visible->b_range )
305 p_osd->p_state->p_visible->p_current_state =
306 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
308 osd_UpdateState( p_osd->p_state,
309 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
310 p_osd->p_state->p_visible->p_current_state->i_width,
311 p_osd->p_state->p_visible->p_current_state->i_height,
312 p_osd->p_state->p_visible->p_current_state->p_pic );
313 osd_SetMenuUpdate( p_osd, true );
315 osd_SetMenuVisible( p_osd, true );
317 vlc_mutex_unlock( p_lock );
321 void osd_MenuHide( vlc_object_t *p_this )
324 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
326 vlc_mutex_lock( p_lock );
328 p_osd = osd_Find( p_this );
331 vlc_mutex_unlock( p_lock );
332 msg_Err( p_this, "osd_MenuHide failed" );
336 #if defined(OSD_MENU_DEBUG)
337 msg_Dbg( p_osd, "menu off" );
339 osd_UpdateState( p_osd->p_state,
340 p_osd->p_state->i_x, p_osd->p_state->i_y,
342 osd_SetMenuUpdate( p_osd, true );
344 vlc_mutex_unlock( p_lock );
347 #undef osd_MenuActivate
348 void osd_MenuActivate( vlc_object_t *p_this )
351 osd_button_t *p_button = NULL;
352 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
354 vlc_mutex_lock( p_lock );
356 p_osd = osd_Find( p_this );
357 if( p_osd == NULL || !osd_isVisible( p_osd ) )
359 vlc_mutex_unlock( p_lock );
360 msg_Err( p_this, "osd_MenuActivate failed" );
364 #if defined(OSD_MENU_DEBUG)
365 msg_Dbg( p_osd, "select" );
367 p_button = p_osd->p_state->p_visible;
369 * Is there a menu item above or below? If so, then select it.
371 if( p_button && p_button->p_up )
373 vlc_mutex_unlock( p_lock );
374 osd_MenuUp( p_this ); /* "menu select" means go to menu item above. */
377 if( p_button && p_button->p_down )
379 vlc_mutex_unlock( p_lock );
380 osd_MenuDown( p_this ); /* "menu select" means go to menu item below. */
384 if( p_button && !p_button->b_range )
386 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_PRESSED );
387 osd_UpdateState( p_osd->p_state,
388 p_button->i_x, p_button->i_y,
389 p_osd->p_state->p_visible->p_current_state->i_width,
390 p_osd->p_state->p_visible->p_current_state->i_height,
391 p_button->p_current_state->p_pic );
392 osd_SetMenuUpdate( p_osd, true );
393 osd_SetMenuVisible( p_osd, true );
394 osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc),
395 var_InheritInteger( p_osd, p_button->psz_action ) );
396 #if defined(OSD_MENU_DEBUG)
397 msg_Dbg( p_osd, "select (%d, %s)",
398 (int)var_InheritInteger( p_osd, p_button->psz_action ),
399 p_button->psz_action );
402 vlc_mutex_unlock( p_lock );
406 void osd_MenuNext( vlc_object_t *p_this )
409 osd_button_t *p_button = NULL;
410 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
412 vlc_mutex_lock( p_lock );
414 p_osd = osd_Find( p_this );
415 if( p_osd == NULL || !osd_isVisible( p_osd ) )
417 vlc_mutex_unlock( p_lock );
418 msg_Err( p_this, "osd_MenuNext failed" );
422 p_button = p_osd->p_state->p_visible;
425 if( !p_button->b_range )
426 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_UNSELECT );
427 if( p_button->p_next )
428 p_osd->p_state->p_visible = p_button->p_next;
430 p_osd->p_state->p_visible = p_osd->p_button;
432 if( !p_osd->p_state->p_visible->b_range )
433 p_osd->p_state->p_visible->p_current_state =
434 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
436 osd_UpdateState( p_osd->p_state,
437 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
438 p_osd->p_state->p_visible->p_current_state->i_width,
439 p_osd->p_state->p_visible->p_current_state->i_height,
440 p_osd->p_state->p_visible->p_current_state->p_pic );
441 osd_SetMenuUpdate( p_osd, true );
443 #if defined(OSD_MENU_DEBUG)
444 msg_Dbg( p_osd, "direction right [button %s]", p_osd->p_state->p_visible->psz_action );
447 vlc_mutex_unlock( p_lock );
451 void osd_MenuPrev( vlc_object_t *p_this )
454 osd_button_t *p_button = NULL;
455 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
457 vlc_mutex_lock( p_lock );
458 p_osd = osd_Find( p_this );
459 if( p_osd == NULL || !osd_isVisible( p_osd ) )
461 vlc_mutex_unlock( p_lock );
462 msg_Err( p_this, "osd_MenuPrev failed" );
466 p_button = p_osd->p_state->p_visible;
469 if( !p_button->b_range )
470 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_UNSELECT );
471 if( p_button->p_prev )
472 p_osd->p_state->p_visible = p_button->p_prev;
474 p_osd->p_state->p_visible = p_osd->p_last_button;
476 if( !p_osd->p_state->p_visible->b_range )
477 p_osd->p_state->p_visible->p_current_state =
478 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
480 osd_UpdateState( p_osd->p_state,
481 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
482 p_osd->p_state->p_visible->p_current_state->i_width,
483 p_osd->p_state->p_visible->p_current_state->i_height,
484 p_osd->p_state->p_visible->p_current_state->p_pic );
485 osd_SetMenuUpdate( p_osd, true );
487 #if defined(OSD_MENU_DEBUG)
488 msg_Dbg( p_osd, "direction left [button %s]", p_osd->p_state->p_visible->psz_action );
491 vlc_mutex_unlock( p_lock );
495 void osd_MenuUp( vlc_object_t *p_this )
498 osd_button_t *p_button = NULL;
499 #if defined(OSD_MENU_DEBUG)
502 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
504 vlc_mutex_lock( p_lock );
505 p_osd = osd_Find( p_this );
506 if( p_osd == NULL || !osd_isVisible( p_osd ) )
508 vlc_mutex_unlock( p_lock );
509 msg_Err( p_this, "osd_MenuActivate failed" );
513 p_button = p_osd->p_state->p_visible;
516 if( !p_button->b_range )
518 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_SELECT );
520 p_osd->p_state->p_visible = p_button->p_up;
523 if( p_button->b_range && p_osd->p_state->p_visible->b_range )
525 osd_state_t *p_temp = p_osd->p_state->p_visible->p_current_state;
526 if( p_temp && p_temp->p_next )
527 p_osd->p_state->p_visible->p_current_state = p_temp->p_next;
529 else if( !p_osd->p_state->p_visible->b_range )
531 p_osd->p_state->p_visible->p_current_state =
532 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
535 osd_UpdateState( p_osd->p_state,
536 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
537 p_osd->p_state->p_visible->p_current_state->i_width,
538 p_osd->p_state->p_visible->p_current_state->i_height,
539 p_osd->p_state->p_visible->p_current_state->p_pic );
540 osd_SetMenuUpdate( p_osd, true );
541 /* If this is a range style action with associated images of only one state,
542 * then perform "menu select" on every menu navigation
544 if( p_button->b_range )
546 osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc),
547 var_InheritInteger(p_osd, p_button->psz_action) );
548 #if defined(OSD_MENU_DEBUG)
549 msg_Dbg( p_osd, "select (%"PRId64", %s)", val.i_int, p_button->psz_action );
553 #if defined(OSD_MENU_DEBUG)
554 msg_Dbg( p_osd, "direction up [button %s]", p_osd->p_state->p_visible->psz_action );
557 vlc_mutex_unlock( p_lock );
561 void osd_MenuDown( vlc_object_t *p_this )
564 osd_button_t *p_button = NULL;
565 #if defined(OSD_MENU_DEBUG)
568 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
570 vlc_mutex_lock( p_lock );
572 p_osd = osd_Find( p_this );
573 if( p_osd == NULL || !osd_isVisible( p_osd ) )
575 vlc_mutex_unlock( p_lock );
576 msg_Err( p_this, "osd_MenuActivate failed" );
580 p_button = p_osd->p_state->p_visible;
583 if( !p_button->b_range )
585 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_SELECT );
586 if( p_button->p_down )
587 p_osd->p_state->p_visible = p_button->p_down;
590 if( p_button->b_range && p_osd->p_state->p_visible->b_range )
592 osd_state_t *p_temp = p_osd->p_state->p_visible->p_current_state;
593 if( p_temp && p_temp->p_prev )
594 p_osd->p_state->p_visible->p_current_state = p_temp->p_prev;
596 else if( !p_osd->p_state->p_visible->b_range )
598 p_osd->p_state->p_visible->p_current_state =
599 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
602 osd_UpdateState( p_osd->p_state,
603 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
604 p_osd->p_state->p_visible->p_current_state->i_width,
605 p_osd->p_state->p_visible->p_current_state->i_height,
606 p_osd->p_state->p_visible->p_current_state->p_pic );
607 osd_SetMenuUpdate( p_osd, true );
608 /* If this is a range style action with associated images of only one state,
609 * then perform "menu select" on every menu navigation
611 if( p_button->b_range )
613 osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc),
614 var_InheritInteger(p_osd, p_button->psz_action_down) );
615 #if defined(OSD_MENU_DEBUG)
616 msg_Dbg( p_osd, "select (%"PRId64", %s)", val.i_int, p_button->psz_action_down );
620 #if defined(OSD_MENU_DEBUG)
621 msg_Dbg( p_osd, "direction down [button %s]", p_osd->p_state->p_visible->psz_action );
624 vlc_mutex_unlock( p_lock );
627 static int osd_VolumeStep( vlc_object_t *p_this, int i_volume, int i_steps )
629 int i_volume_step = 0;
632 i_volume_step = config_GetInt( p_this->p_libvlc, "volume-step" );
633 return (i_volume/i_volume_step);
638 * Display current audio volume bitmap
640 * The OSD Menu audio volume bar is updated to reflect the new audio volume. Call this function
641 * when the audio volume is updated outside the OSD menu command "menu up", "menu down" or "menu select".
643 void osd_Volume( vlc_object_t *p_this )
646 osd_button_t *p_button = NULL;
647 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
651 vlc_mutex_lock( p_lock );
653 p_osd = osd_Find( p_this );
656 vlc_mutex_unlock( p_lock );
657 msg_Err( p_this, "OSD menu volume update failed" );
661 if( p_osd->p_state && p_osd->p_state->p_volume )
664 p_button = p_osd->p_state->p_volume;
665 if( p_osd->p_state->p_volume )
666 p_osd->p_state->p_visible = p_osd->p_state->p_volume;
667 if( p_button && p_button->b_range )
669 /* Update the volume state images to match the current volume */
670 i_volume = config_GetInt( p_this, "volume" );
671 i_steps = osd_VolumeStep( p_this, i_volume, p_button->i_ranges );
672 p_button->p_current_state = osd_VolumeStateChange( p_button->p_states, i_steps );
674 osd_UpdateState( p_osd->p_state,
675 p_button->i_x, p_button->i_y,
676 p_button->p_current_state->i_width,
677 p_button->p_current_state->i_height,
678 p_button->p_current_state->p_pic );
679 osd_SetMenuUpdate( p_osd, true );
680 osd_SetMenuVisible( p_osd, true );
683 vlc_mutex_unlock( p_lock );
686 #undef osd_ButtonFind
687 osd_button_t *osd_ButtonFind( vlc_object_t *p_this, int i_x, int i_y,
688 int i_window_height, int i_window_width,
689 int i_scale_width, int i_scale_height )
692 osd_button_t *p_button;
693 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
695 vlc_mutex_lock( p_lock );
697 p_osd = osd_Find( p_this );
698 if( p_osd == NULL || !osd_isVisible( p_osd ) )
700 vlc_mutex_unlock( p_lock );
701 msg_Err( p_this, "osd_ButtonFind failed" );
705 p_button = p_osd->p_button;
706 for( ; p_button != NULL; p_button = p_button->p_next )
708 int i_source_video_width = ( i_window_width * 1000 ) / i_scale_width;
709 int i_source_video_height = ( i_window_height * 1000 ) / i_scale_height;
710 int i_y_offset = p_button->i_y;
711 int i_x_offset = p_button->i_x;
712 int i_width = p_button->i_width;
713 int i_height = p_button->i_height;
715 if( p_osd->i_position > 0 )
717 int i_inv_scale_y = i_source_video_height;
718 int i_inv_scale_x = i_source_video_width;
721 if( p_osd->i_position & SUBPICTURE_ALIGN_BOTTOM )
723 i_y_offset = i_window_height - p_button->i_height -
724 (p_osd->i_y + p_button->i_y) * i_inv_scale_y / 1000;
726 else if ( !(p_osd->i_position & SUBPICTURE_ALIGN_TOP) )
728 i_y_offset = i_window_height / 2 - p_button->i_height / 2;
731 if( p_osd->i_position & SUBPICTURE_ALIGN_RIGHT )
733 i_x_offset = i_window_width - p_button->i_width -
734 (pi_x + p_button->i_x)
735 * i_inv_scale_x / 1000;
737 else if ( !(p_osd->i_position & SUBPICTURE_ALIGN_LEFT) )
739 i_x_offset = i_window_width / 2 - p_button->i_width / 2;
742 i_width = i_window_width - p_button->i_width - i_inv_scale_x / 1000;
743 i_height = i_window_height - p_button->i_height - i_inv_scale_y / 1000;
746 // TODO: write for Up / Down case too.
747 // TODO: handle absolute positioning case
748 if( ( i_x >= i_x_offset ) && ( i_x <= i_x_offset + i_width ) &&
749 ( i_y >= i_y_offset ) && ( i_y <= i_y_offset + i_height ) )
751 vlc_mutex_unlock( p_lock );
756 vlc_mutex_unlock( p_lock );
760 #undef osd_ButtonSelect
762 * Select the button provided as the new active button
764 void osd_ButtonSelect( vlc_object_t *p_this, osd_button_t *p_button )
768 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
770 vlc_mutex_lock( p_lock );
772 p_osd = osd_Find( p_this );
773 if( p_osd == NULL || !osd_isVisible( p_osd ) )
775 vlc_mutex_unlock( p_lock );
776 msg_Err( p_this, "osd_ButtonSelect failed" );
780 p_old = p_osd->p_state->p_visible;
783 if( !p_old->b_range )
784 p_old->p_current_state = osd_StateChange( p_old, OSD_BUTTON_UNSELECT );
785 p_osd->p_state->p_visible = p_button;
787 if( !p_osd->p_state->p_visible->b_range )
788 p_osd->p_state->p_visible->p_current_state =
789 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
791 osd_UpdateState( p_osd->p_state,
792 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
793 p_osd->p_state->p_visible->p_current_state->i_width,
794 p_osd->p_state->p_visible->p_current_state->i_height,
795 p_osd->p_state->p_visible->p_current_state->p_pic );
796 osd_SetMenuUpdate( p_osd, true );
798 #if defined(OSD_MENU_DEBUG)
799 msg_Dbg( p_osd, "button selected is [button %s]", p_osd->p_state->p_visible->psz_action );
802 vlc_mutex_unlock( p_lock );