/*****************************************************************************
* menu.cpp: functions to handle menu items
*****************************************************************************
- * Copyright (C) 2002 VideoLAN
- * $Id: menu.cpp,v 1.3 2003/01/08 02:16:09 ipkiss Exp $
+ * Copyright (C) 2002-2003 VideoLAN
+ * $Id: menu.cpp,v 1.4 2003/01/13 17:11:14 ipkiss Exp $
*
* Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
*
}
+/*****************************************************************************
+ * SetupMenus: This function dynamically generates some menus
+ *****************************************************************************
+ * The lock on p_input->stream must be taken before you call this function
+ *****************************************************************************/
void __fastcall TMenusGen::SetupMenus()
{
TMainFrameDlg * p_window = p_intf->p_sys->p_window;
p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
- if ( p_aout != NULL )
+ if( p_aout != NULL )
{
vlc_value_t val;
val.b_bool = 0;
p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
- if ( p_vout != NULL )
+ if( p_vout != NULL )
{
vlc_value_t val;
val.b_bool = 0;
vlc_value_t val;
int i_index;
+ /* We must delete all the '&' characters in the caption string, because
+ * Borland automatically adds one when (and only when!) you click on
+ * the menuitem. Grrrrr... */
+ AnsiString Caption = Item->Caption;
+ while( Caption.LastDelimiter( "&" ) != 0 )
+ {\r
+ Caption.Delete( Caption.LastDelimiter( "&" ), 1 );\r
+ }\r
+ val.psz_string = Caption.c_str();
+
/* set the new value */
- val.psz_string = Item->Name.c_str();
if( var_Set( p_object, psz_variable, val ) < 0 )
{
msg_Warn( p_object, "cannot set variable (%s)", val.psz_string );
{
TMenuItem * Item;
vlc_value_t val;
- char * psz_value;
+ char * psz_value = NULL;
int i;
/* remove previous menu */
Root->Clear();
/* get the current value */
- if ( var_Get( p_object, psz_variable, &val ) < 0 )
+ if( var_Get( p_object, psz_variable, &val ) < 0 )
{
return;
}
psz_value = val.psz_string;
- if ( var_Change( p_object, psz_variable, VLC_VAR_GETLIST, &val ) < 0 )
+ if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST, &val ) < 0 )
{
free( psz_value );
return;
}
/* append a menuitem for each option */
- for ( i = 0; i < val.p_list->i_count; i++ )
+ for( i = 0; i < val.p_list->i_count; i++ )
{
Item = new TMenuItem( Root );
Item->Caption = val.p_list->p_values[i].psz_string;
/* clean up everything */
var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val );
- free( psz_value );
+// free( psz_value );
}
/*****************************************************************************
Root->Enabled = true;
}
+
/*****************************************************************************
* win32.cpp : Win32 interface plugin for vlc
*****************************************************************************
- * Copyright (C) 2002 VideoLAN
- * $Id: win32.cpp,v 1.7 2003/01/08 02:16:09 ipkiss Exp $
+ * Copyright (C) 2002-2003 VideoLAN
+ * $Id: win32.cpp,v 1.8 2003/01/13 17:11:14 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
*
*****************************************************************************/
int Win32Manage( intf_thread_t *p_intf )
{
- aout_instance_t * p_aout;
- vout_thread_t * p_vout;
-
vlc_mutex_lock( &p_intf->change_lock );
/* If the "display popup" flag has changed */
p_intf->p_sys->p_input = NULL;
}
- if( p_intf->p_sys->p_input )
+ if( p_intf->p_sys->p_input != NULL && !p_intf->p_sys->p_input->b_die )
{
- input_thread_t *p_input = p_intf->p_sys->p_input;
+ vlc_bool_t b_need_menus = 0;
+ input_thread_t * p_input = p_intf->p_sys->p_input;
+ aout_instance_t * p_aout = NULL;
+ vout_thread_t * p_vout = NULL;
vlc_mutex_lock( &p_input->stream.stream_lock );
- if( !p_input->b_die )
+ /* New input or stream map change */
+ if( p_input->stream.b_changed )
+ {
+ p_intf->p_sys->p_window->ModeManage();
+ b_need_menus = 1;
+ p_intf->p_sys->b_playing = 1;
+ }
+
+ /* Manage the slider */
+ if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )
{
- /* New input or stream map change */
- if( p_input->stream.b_changed )
+ TTrackBar * TrackBar = p_intf->p_sys->p_window->TrackBar;
+ off_t NewValue = TrackBar->Position;
+
+#define p_area p_input->stream.p_selected_area
+ /* If the user hasn't touched the slider since the last time,
+ * then the input can safely change it */
+ if( NewValue == p_intf->p_sys->OldValue )
{
- p_intf->p_sys->p_window->ModeManage();
- p_intf->p_sys->p_menus->SetupMenus();
- p_intf->p_sys->b_playing = 1;
+ /* Update the value */
+ TrackBar->Position = p_intf->p_sys->OldValue =
+ ( (off_t)SLIDER_MAX_VALUE * p_area->i_tell ) /
+ p_area->i_size;
}
-
- /* Manage the slider */
- if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )
+ /* Otherwise, send message to the input if the user has
+ * finished dragging the slider */
+ else if( p_intf->p_sys->b_slider_free )
{
- TTrackBar * TrackBar = p_intf->p_sys->p_window->TrackBar;
- off_t NewValue = TrackBar->Position;
+ off_t i_seek = ( NewValue * p_area->i_size ) /
+ (off_t)SLIDER_MAX_VALUE;
-#define p_area p_input->stream.p_selected_area
- /* If the user hasn't touched the slider since the last time,
- * then the input can safely change it */
- if( NewValue == p_intf->p_sys->OldValue )
- {
- /* Update the value */
- TrackBar->Position = p_intf->p_sys->OldValue =
- ( (off_t)SLIDER_MAX_VALUE * p_area->i_tell ) /
- p_area->i_size;
- }
- /* Otherwise, send message to the input if the user has
- * finished dragging the slider */
- else if( p_intf->p_sys->b_slider_free )
- {
- off_t i_seek = ( NewValue * p_area->i_size ) /
- (off_t)SLIDER_MAX_VALUE;
-
- /* release the lock to be able to seek */
- vlc_mutex_unlock( &p_input->stream.stream_lock );
- input_Seek( p_input, i_seek, INPUT_SEEK_SET );
- vlc_mutex_lock( &p_input->stream.stream_lock );
-
- /* Update the old value */
- p_intf->p_sys->OldValue = NewValue;
- }
-
- /* Update the display */
-// TrackBar->Invalidate();
+ /* release the lock to be able to seek */
+ vlc_mutex_unlock( &p_input->stream.stream_lock );
+ input_Seek( p_input, i_seek, INPUT_SEEK_SET );
+ vlc_mutex_lock( &p_input->stream.stream_lock );
+ /* Update the old value */
+ p_intf->p_sys->OldValue = NewValue;
+ }
# undef p_area
+
+ }
+
+ if( p_intf->p_sys->i_part != p_input->stream.p_selected_area->i_part )
+ {
+ p_intf->p_sys->b_chapter_update = 1;
+ b_need_menus = 1;
+ }
+
+ /* Does the audio output require to update the menus ? */
+ p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
+ FIND_ANYWHERE );
+ if( p_aout != NULL )
+ {
+ vlc_value_t val;
+ if( var_Get( (vlc_object_t *)p_aout, "intf-change", &val ) >= 0
+ && val.b_bool )
+ {
+ p_intf->p_sys->b_aout_update = 1;
+ b_need_menus = 1;
}
- if( p_intf->p_sys->i_part !=
- p_input->stream.p_selected_area->i_part )
+ vlc_object_release( (vlc_object_t *)p_aout );
+ }
+
+ /* Does the video output require to update the menus ? */
+ p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
+ FIND_ANYWHERE );
+ if( p_vout != NULL )
+ {
+ vlc_value_t val;
+ if( var_Get( (vlc_object_t *)p_vout, "intf-change", &val ) >= 0
+ && val.b_bool )
{
-// p_intf->p_sys->b_chapter_update = 1;
- p_intf->p_sys->p_menus->SetupMenus();
+ p_intf->p_sys->b_vout_update = 1;
+ b_need_menus = 1;
}
+
+ vlc_object_release( (vlc_object_t *)p_vout );
}
+ if( b_need_menus )
+ p_intf->p_sys->p_menus->SetupMenus();
+
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
else if( p_intf->p_sys->b_playing && !p_intf->b_die )
p_intf->p_sys->b_playing = 0;
}
- /* Does the audio output require to update the menus ? */
- p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
- FIND_ANYWHERE );
- if( p_aout != NULL )
- {
- vlc_value_t val;
- if( var_Get( (vlc_object_t *)p_aout, "intf-change", &val ) >= 0
- && val.b_bool )
- {
-#if 0
- p_intf->p_sys->b_aout_update = 1;
- p_intf->p_sys->p_menus->SetupMenus();
-#endif
- }
-
- vlc_object_release( (vlc_object_t *)p_aout );
- }
-
- /* Does the video output require to update the menus ? */
- p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
- FIND_ANYWHERE );
- if( p_vout != NULL )
- {
- vlc_value_t val;
- if( var_Get( (vlc_object_t *)p_vout, "intf-change", &val ) >= 0
- && val.b_bool )
- {
-#if 0
- p_intf->p_sys->b_vout_update = 1;
- p_intf->p_sys->p_menus->SetupMenus();
-#endif
- }
-
- vlc_object_release( (vlc_object_t *)p_vout );
- }
-
if( p_intf->b_die )
{
vlc_mutex_unlock( &p_intf->change_lock );