Commit 7822e559 authored by VideoLAN's avatar VideoLAN

* ./modules/win32/menu.cpp: reorganized the code for menus generation,

   and got rid of the global variable (at last!) in the win32 interface.

Please check that navigation and language selection aren't too much
broken for DVDs...
parent a71b1c8c
...@@ -398,7 +398,7 @@ void __fastcall TMainFrameDlg::PrevTitleActionExecute( TObject *Sender ) ...@@ -398,7 +398,7 @@ void __fastcall TMainFrameDlg::PrevTitleActionExecute( TObject *Sender )
p_intf->p_sys->b_title_update = 1; p_intf->p_sys->b_title_update = 1;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
SetupMenus( p_intf ); p_intf->p_sys->p_menus->SetupMenus();
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
} }
} }
...@@ -412,14 +412,14 @@ void __fastcall TMainFrameDlg::NextTitleActionExecute( TObject *Sender ) ...@@ -412,14 +412,14 @@ void __fastcall TMainFrameDlg::NextTitleActionExecute( TObject *Sender )
if( i_id < p_intf->p_sys->p_input->stream.i_area_nb ) if( i_id < p_intf->p_sys->p_input->stream.i_area_nb )
{ {
p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id]; p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];
input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area ); input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
p_intf->p_sys->b_title_update = 1; p_intf->p_sys->b_title_update = 1;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
SetupMenus( p_intf ); p_intf->p_sys->p_menus->SetupMenus();
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
} }
} }
...@@ -439,7 +439,7 @@ void __fastcall TMainFrameDlg::PrevChapterActionExecute( TObject *Sender ) ...@@ -439,7 +439,7 @@ void __fastcall TMainFrameDlg::PrevChapterActionExecute( TObject *Sender )
p_intf->p_sys->b_chapter_update = 1; p_intf->p_sys->b_chapter_update = 1;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
SetupMenus( p_intf ); p_intf->p_sys->p_menus->SetupMenus();
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
} }
} }
...@@ -449,7 +449,7 @@ void __fastcall TMainFrameDlg::NextChapterActionExecute( TObject *Sender ) ...@@ -449,7 +449,7 @@ void __fastcall TMainFrameDlg::NextChapterActionExecute( TObject *Sender )
input_area_t * p_area; input_area_t * p_area;
p_area = p_intf->p_sys->p_input->stream.p_selected_area; p_area = p_intf->p_sys->p_input->stream.p_selected_area;
if( p_area->i_part < p_area->i_part_nb ) if( p_area->i_part < p_area->i_part_nb )
{ {
p_area->i_part++; p_area->i_part++;
...@@ -459,7 +459,7 @@ void __fastcall TMainFrameDlg::NextChapterActionExecute( TObject *Sender ) ...@@ -459,7 +459,7 @@ void __fastcall TMainFrameDlg::NextChapterActionExecute( TObject *Sender )
p_intf->p_sys->b_chapter_update = 1; p_intf->p_sys->b_chapter_update = 1;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
SetupMenus( p_intf ); p_intf->p_sys->p_menus->SetupMenus();
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
} }
} }
...@@ -512,7 +512,7 @@ void __fastcall TMainFrameDlg::ModeManage() ...@@ -512,7 +512,7 @@ void __fastcall TMainFrameDlg::ModeManage()
if( p_intf->p_sys->p_input != NULL ) if( p_intf->p_sys->p_input != NULL )
{ {
switch( p_intf->p_sys->p_input->stream.i_method & 0xf0 ) switch( p_intf->p_sys->p_input->stream.i_method & 0xf0 )
{ {
case INPUT_METHOD_FILE: case INPUT_METHOD_FILE:
GroupBoxFile->Visible = true; GroupBoxFile->Visible = true;
ActiveGB = GroupBoxFile; ActiveGB = GroupBoxFile;
...@@ -580,7 +580,7 @@ void __fastcall TMainFrameDlg::ModeManage() ...@@ -580,7 +580,7 @@ void __fastcall TMainFrameDlg::ModeManage()
else else
{ {
/* add space between tolbar and statusbar when /* add space between tolbar and statusbar when
* nothing is displayed; isn't it nicer ? :) */ * nothing is displayed; isn't it nicer ? :) */
i_Height += 17; i_Height += 17;
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
......
/***************************************************************************** /*****************************************************************************
* menu.cpp: functions to handle menu items * menu.cpp: functions to handle menu items
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* * $Id: menu.cpp,v 1.2 2002/12/13 03:52:58 videolan Exp $
* Authors: Olivier Teuliere <ipkiss@via.ecp.fr> *
* * Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * This program is free software; you can redistribute it and/or modify
* the Free Software Foundation; either version 2 of the License, or * it under the terms of the GNU General Public License as published by
* (at your option) any later version. * the Free Software Foundation; either version 2 of the License, or
* * (at your option) any later version.
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * This program is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU General Public License for more details.
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software * You should have received a copy of the GNU General Public License
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * along with this program; if not, write to the Free Software
*****************************************************************************/ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <vcl.h>
//#pragma hdrstop #include <vcl.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/intf.h> #include <vlc/intf.h>
#include "menu.h" #include "menu.h"
#include "win32_common.h" #include "win32_common.h"
/*****************************************************************************
/**************************************************************************** * TMenusGen::*Click: callbacks for the menuitems
* Local Prototypes ****************************************************************************
****************************************************************************/ * These functions need to be in a class, or we won't be able to pass them
extern intf_thread_t *p_intfGlobal; * as arguments (since TNotifyEvent uses __closure)
****************************************************************************/
static TMenuItem *Index2Item( TMenuItem *, int, bool );
static int Item2Index( TMenuItem *, TMenuItem * ); /*
static void __fastcall LangChange( TMenuItem *, TMenuItem *, TMenuItem *, int ); * Audio
static void __fastcall ProgramChange( TMenuItem *, TMenuItem * ); */
static void __fastcall RadioMenu( TMenuItem *, AnsiString, void __fastcall TMenusGen::MenuAudioClick( TObject *Sender )
int, int, TNotifyEvent ); {
static void __fastcall ProgramMenu( TMenuItem *, pgrm_descriptor_t *, LangChange( MenuAudio, (TMenuItem *)Sender, PopupAudio, AUDIO_ES );
TNotifyEvent ); }
static void __fastcall LanguageMenu( TMenuItem *t, es_descriptor_t *,
int, TNotifyEvent ); void __fastcall TMenusGen::PopupAudioClick( TObject *Sender )
static void __fastcall NavigationMenu( TMenuItem *, TNotifyEvent ); {
LangChange( PopupAudio, (TMenuItem *)Sender, MenuAudio, AUDIO_ES );
}
static TMenuItem *Index2Item( TMenuItem *Root, int i_index, bool SingleColumn )
{ /*
if( SingleColumn || ( i_index < 20 ) ) * Subtitles
{ */
return Root->Items[i_index];
} void __fastcall TMenusGen::MenuSubtitleClick( TObject *Sender )
else {
{ LangChange( MenuSubtitles, (TMenuItem *)Sender,
return Root->Items[i_index / 10]->Items[i_index % 10]; PopupSubtitles, SPU_ES );
} }
}
void __fastcall TMenusGen::PopupSubtitleClick( TObject *Sender )
static int Item2Index( TMenuItem *Root, TMenuItem *Item ) {
{ LangChange( PopupSubtitles, (TMenuItem *)Sender,
if( Item->Parent == Root ) MenuSubtitles, SPU_ES );
{ }
return Item->MenuIndex;
} /*
else * Program
{ */
return( 10 * Item->Parent->MenuIndex + Item->MenuIndex );
} void __fastcall TMenusGen::MenuProgramClick( TObject *Sender )
} {
ProgramChange( (TMenuItem *)Sender, PopupProgram );
}
/****************************************************************************
* LangChange: change audio or subtitles languages void __fastcall TMenusGen::PopupProgramClick( TObject *Sender )
**************************************************************************** {
* Toggle the language, and update the selected menuitems. ProgramChange( (TMenuItem *)Sender, MenuProgram );
****************************************************************************/ }
static void __fastcall LangChange( TMenuItem *RootCurrent, TMenuItem *Item,
TMenuItem *RootOther, int i_cat ) /*
{ * Title
intf_thread_t * p_intf = p_intfGlobal; */
es_descriptor_t * p_es;
es_descriptor_t * p_es_old; void __fastcall TMenusGen::MenuTitleClick( TObject *Sender )
int i_index; {
int i_es; TMenuItem * Item = (TMenuItem *)Sender;
TMenuItem * ItemTitle;
/* find the selected ES */ int i_title = Item->Tag;
i_es = Item->Tag;
input_ChangeArea( p_intf->p_sys->p_input,
/* find selected menu item */ p_intf->p_sys->p_input->stream.pp_areas[i_title] );
i_index = Item2Index( RootCurrent, Item ) - 1; Item->Checked = true;
if( i_index < 0 ) ItemTitle = Index2Item( PopupNavigation, i_title - 1, false );
{ Index2Item( ItemTitle, 0, false )->Checked = true;
/* 'None' was selected */
p_es = NULL; input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
} }
else
{ /*
vlc_mutex_lock( &p_intfGlobal->p_sys->p_input->stream.stream_lock ); * Chapter
p_es = p_intfGlobal->p_sys->p_input->stream.pp_es[i_es]; */
vlc_mutex_unlock( &p_intfGlobal->p_sys->p_input->stream.stream_lock );
} void __fastcall TMenusGen::MenuChapterClick( TObject *Sender )
{
/* find the current ES */ TMenuItem * Item = (TMenuItem *)Sender;
if( i_cat == AUDIO_ES ) TMenuItem * ItemTitle;
{ input_area_t * p_area;
p_es_old = p_intf->p_sys->p_audio_es_old; int i_title;
p_intf->p_sys->p_audio_es_old = p_es; int i_chapter = Item->Tag;
}
else p_area = p_intf->p_sys->p_input->stream.p_selected_area;
{ p_area->i_part = i_chapter;
p_es_old = p_intf->p_sys->p_spu_es_old;
p_intf->p_sys->p_spu_es_old = p_es; input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );
}
i_title = p_intf->p_sys->p_input->stream.p_selected_area->i_id;
/* exchange them */ ItemTitle = Index2Item( PopupNavigation, i_title - 1, false );
input_ToggleES( p_intfGlobal->p_sys->p_input, p_es_old, false ); Index2Item( ItemTitle, i_chapter - 1, false )->Checked = true;
input_ToggleES( p_intfGlobal->p_sys->p_input, p_es, true );
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
Item->Checked = true; }
Index2Item( RootOther, i_index + 1, true )->Checked = true;
} /*
* Navigation
*/
/****************************************************************************
* ProgramChange: change the program void __fastcall TMenusGen::PopupNavigationClick( TObject *Sender )
**************************************************************************** {
* Toggle the program, and update the selected menuitems. TMenuItem * Item = (TMenuItem *)Sender;
****************************************************************************/ TMenuItem * ItemTitle;
static void __fastcall ProgramChange( TMenuItem *Item, TMenuItem *RootOther ) input_area_t * p_area;
{ int i_title = Data2Title( Item->Tag );
intf_thread_t * p_intf = p_intfGlobal; int i_chapter = Data2Chapter( Item->Tag );
int i_program = Item->Tag;
p_area = p_intf->p_sys->p_input->stream.pp_areas[i_title];
/* toggle the program */ p_area->i_part = i_chapter;
input_ChangeProgram( p_intfGlobal->p_sys->p_input, (u16)i_program );
input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );
/* check selected menu items */
Item->Checked = true; Item->Checked = true;
Index2Item( RootOther, i_program - 1, true )->Checked = true; ItemTitle = Index2Item( MenuTitle, i_title - 1, false );
if( ItemTitle->Checked )
/* update audio/subtitles menus */ {
p_intf->p_sys->b_audio_update = 1; /* same title, new chapter */
p_intf->p_sys->b_spu_update = 1; Index2Item( MenuChapter, i_chapter - 1, false )->Checked = true;
vlc_mutex_lock( &p_intfGlobal->p_sys->p_input->stream.stream_lock ); }
SetupMenus( p_intf ); else
vlc_mutex_unlock( &p_intfGlobal->p_sys->p_input->stream.stream_lock ); {
p_intf->p_sys->b_audio_update = 0; /* new title => we must rebuild the chapter menu */
p_intf->p_sys->b_spu_update = 0; vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
RadioMenu(
input_SetStatus( p_intfGlobal->p_sys->p_input, INPUT_STATUS_PLAY ); MenuChapter, "Chapter",
} p_intf->p_sys->p_input->stream.p_selected_area->i_part_nb,
i_chapter, MenuChapterClick );
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
/**************************************************************************** }
* TMainFrameDlg::*Click: callbacks for the menuitems
**************************************************************************** input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
* These functions need to be in a class, or we won't be able to pass them }
* as arguments (since TNotifyEvent uses __closure)
****************************************************************************/
__fastcall TMenusGen::TMenusGen( intf_thread_t *_p_intf ) : TObject()
/* {
* Audio p_intf = _p_intf;
*/
/* Initialize local pointers to menu items of the main window */
void __fastcall TMainFrameDlg::MenuAudioClick( TObject *Sender ) TMainFrameDlg * p_window = p_intf->p_sys->p_window;
{ if( p_window == NULL )
LangChange( MenuAudio, (TMenuItem *)Sender, PopupAudio, AUDIO_ES ); {
} msg_Err( p_intf, "Main window wasn't created, expect problems..." );
return;
void __fastcall TMainFrameDlg::PopupAudioClick( TObject *Sender ) }
{
LangChange( PopupAudio, (TMenuItem *)Sender, MenuAudio, AUDIO_ES ); MenuAudio = p_window->MenuAudio;
} PopupAudio = p_window->PopupAudio;
MenuSubtitles = p_window->MenuSubtitles;
/* PopupSubtitles = p_window->PopupSubtitles;
* Subtitles MenuProgram = p_window->MenuProgram;
*/ PopupProgram = p_window->PopupProgram;
MenuTitle = p_window->MenuTitle;
void __fastcall TMainFrameDlg::MenuSubtitleClick( TObject *Sender ) MenuChapter = p_window->MenuChapter;
{ PopupNavigation = p_window->PopupNavigation;
LangChange( MenuSubtitles, (TMenuItem *)Sender, PopupSubtitles, SPU_ES ); }
}
void __fastcall TMenusGen::SetupMenus()
void __fastcall TMainFrameDlg::PopupSubtitleClick( TObject *Sender ) {
{ TMainFrameDlg * p_window = p_intf->p_sys->p_window;
LangChange( PopupSubtitles, (TMenuItem *)Sender, MenuSubtitles, SPU_ES ); input_thread_t *p_input = p_intf->p_sys->p_input;
} es_descriptor_t * p_audio_es;
es_descriptor_t * p_spu_es;
/*
* Program p_intf->p_sys->b_chapter_update |= p_intf->p_sys->b_title_update;
*/ p_intf->p_sys->b_audio_update |= p_intf->p_sys->b_program_update;
// p_intf->p_sys->b_audio_update |= p_intf->p_sys->b_title_update;
void __fastcall TMainFrameDlg::MenuProgramClick( TObject *Sender ) p_intf->p_sys->b_spu_update |= p_intf->p_sys->b_program_update;
{ // p_intf->p_sys->b_spu_update |= p_intf->p_sys->b_title_update;
ProgramChange( (TMenuItem *)Sender, PopupProgram );
} if( p_intf->p_sys->b_program_update )
{
void __fastcall TMainFrameDlg::PopupProgramClick( TObject *Sender ) pgrm_descriptor_t * p_pgrm;
{
ProgramChange( (TMenuItem *)Sender, MenuProgram ); if( p_input->stream.p_new_program )
} {
p_pgrm = p_input->stream.p_new_program;
/* }
* Navigation else
*/ {
p_pgrm = p_input->stream.p_selected_program;
void __fastcall TMainFrameDlg::PopupNavigationClick( TObject *Sender ) }
{
TMenuItem * Item = (TMenuItem *)Sender; ProgramMenu( p_window->MenuProgram, p_pgrm, MenuProgramClick );
TMenuItem * ItemTitle; ProgramMenu( p_window->PopupProgram, p_pgrm, PopupProgramClick );
input_area_t * p_area;
int i_title = DATA2TITLE( Item->Tag ); p_intf->p_sys->b_program_update = 0;
int i_chapter = DATA2CHAPTER( Item->Tag ); }
p_area = p_intfGlobal->p_sys->p_input->stream.pp_areas[i_title]; if( p_intf->p_sys->b_title_update )
p_area->i_part = i_chapter; {
// why "-1" ?
input_ChangeArea( p_intfGlobal->p_sys->p_input, (input_area_t*)p_area ); RadioMenu( p_window->MenuTitle, "Title",
p_input->stream.i_area_nb - 1,
Item->Checked = true; p_input->stream.p_selected_area->i_id,
ItemTitle = Index2Item( MenuTitle, i_title - 1, false ); MenuTitleClick );
if( ItemTitle->Checked )
{ AnsiString CurrentTitle;
/* same title, new chapter */ CurrentTitle.sprintf( "%d", p_input->stream.p_selected_area->i_id );
Index2Item( MenuChapter, i_chapter - 1, false )->Checked = true; p_window->LabelTitleCurrent->Caption = CurrentTitle;
}
else p_intf->p_sys->b_title_update = 0;
{ }
/* new title => we must rebuild the chapter menu */
vlc_mutex_lock( &p_intfGlobal->p_sys->p_input->stream.stream_lock ); if( p_intf->p_sys->b_chapter_update )
RadioMenu( MenuChapter, "Chapter", {
p_intfGlobal->p_sys->p_input->stream.p_selected_area->i_part_nb, RadioMenu( p_window->MenuChapter, "Chapter",
i_chapter, MenuChapterClick ); p_input->stream.p_selected_area->i_part_nb,
vlc_mutex_unlock( &p_intfGlobal->p_sys->p_input->stream.stream_lock ); p_input->stream.p_selected_area->i_part,
} MenuChapterClick );
input_SetStatus( p_intfGlobal->p_sys->p_input, INPUT_STATUS_PLAY ); NavigationMenu( p_window->PopupNavigation,
} PopupNavigationClick );
/* AnsiString CurrentChapter;
* Title CurrentChapter.sprintf( "%d", p_input->stream.p_selected_area->i_part );
*/ p_window->LabelChapterCurrent->Caption = CurrentChapter;
void __fastcall TMainFrameDlg::MenuTitleClick( TObject *Sender ) p_intf->p_sys->i_part = p_input->stream.p_selected_area->i_part;
{
TMenuItem * Item = (TMenuItem *)Sender; p_intf->p_sys->b_chapter_update = 0;
TMenuItem * ItemTitle; }
int i_title = Item->Tag;
/* look for selected ES */
input_ChangeArea( p_intfGlobal->p_sys->p_input, p_audio_es = NULL;
p_intfGlobal->p_sys->p_input->stream.pp_areas[i_title] ); p_spu_es = NULL;
Item->Checked = true;
ItemTitle = Index2Item( PopupNavigation, i_title - 1, false ); for( int i = 0; i < p_input->stream.i_selected_es_number; i++ )
Index2Item( ItemTitle, 0, false )->Checked = true; {
if( p_input->stream.pp_selected_es[i]->i_cat == AUDIO_ES )
input_SetStatus( p_intfGlobal->p_sys->p_input, INPUT_STATUS_PLAY ); {
} p_audio_es = p_input->stream.pp_selected_es[i];
}
/*
* Chapter if( p_input->stream.pp_selected_es[i]->i_cat == SPU_ES )
*/ {
p_spu_es = p_input->stream.pp_selected_es[i];
void __fastcall TMainFrameDlg::MenuChapterClick( TObject *Sender ) }
{ }
TMenuItem * Item = (TMenuItem *)Sender; this->p_audio_es_old = p_audio_es;
TMenuItem * ItemTitle; this->p_spu_es_old = p_spu_es;
input_area_t * p_area;
int i_title; vlc_mutex_unlock( &p_input->stream.stream_lock );
int i_chapter = Item->Tag;
/* audio menus */
p_area = p_intfGlobal->p_sys->p_input->stream.p_selected_area; if( p_intf->p_sys->b_audio_update )
p_area->i_part = i_chapter; {
LanguageMenu( p_window->MenuAudio, p_audio_es, AUDIO_ES,
input_ChangeArea( p_intfGlobal->p_sys->p_input, (input_area_t*)p_area ); MenuAudioClick );
LanguageMenu( p_window->PopupAudio, p_audio_es, AUDIO_ES,
i_title = p_intfGlobal->p_sys->p_input->stream.p_selected_area->i_id; PopupAudioClick );
ItemTitle = Index2Item( PopupNavigation, i_title - 1, false );
Index2Item( ItemTitle, i_chapter - 1, false )->Checked = true; p_intf->p_sys->b_audio_update = 0;
}
input_SetStatus( p_intfGlobal->p_sys->p_input, INPUT_STATUS_PLAY );
} /* sub picture menus */
if( p_intf->p_sys->b_spu_update )
{
/**************************************************************************** LanguageMenu( p_window->PopupSubtitles, p_spu_es, SPU_ES,
* Functions to generate menus PopupSubtitleClick );
****************************************************************************/ LanguageMenu( p_window->MenuSubtitles, p_spu_es, SPU_ES,
MenuSubtitleClick );
/*****************************************************************************
* RadioMenu: update interactive menus of the interface p_intf->p_sys->b_spu_update = 0;
***************************************************************************** }
* Sets up menus with information from input
* Warning: since this function is designed to be called by management vlc_mutex_lock( &p_input->stream.stream_lock );
* function, the interface lock has to be taken }
*****************************************************************************/
static void __fastcall RadioMenu( TMenuItem * Root, AnsiString ItemName,
int i_nb, int i_selected, /*****************************************************************************
TNotifyEvent MenuItemClick ) * Private functions
{ *****************************************************************************/
TMenuItem * ItemGroup; TMenuItem * TMenusGen::Index2Item( TMenuItem *Root, int i_index, bool SingleColumn )
TMenuItem * Item; {
TMenuItem * ItemActive; if( SingleColumn || ( i_index < 20 ) )
AnsiString Name; return Root->Items[i_index];
int i_item; else
return Root->Items[i_index / 10]->Items[i_index % 10];
/* remove previous menu */ }
Root->Enabled = false;
Root->Clear(); int TMenusGen::Item2Index( TMenuItem *Root, TMenuItem *Item )
{
ItemActive = NULL; if( Item->Parent == Root )
return Item->MenuIndex;
for( i_item = 0; i_item < i_nb; i_item++ ) else
{ return( 10 * Item->Parent->MenuIndex + Item->MenuIndex );
/* we group titles/chapters in packets of ten for small screens */ }
if( ( i_item % 10 == 0 ) && ( i_nb > 20 ) )
{ int __fastcall TMenusGen::Data2Title( int data )
if( i_item != 0 ) {
{ return (int) (data >> 16 );
Root->Add( ItemGroup ); }
}
int __fastcall TMenusGen::Data2Chapter( int data )
Name.sprintf( "%ss %d to %d", ItemName, i_item + 1, i_item + 10 ); {
ItemGroup = new TMenuItem( Root ); return (int) (data & 0xffff);
ItemGroup->Hint = Name; }
/* set the accelerator character */ int __fastcall TMenusGen::Pos2Data( int title, int chapter )
Name.Insert( "&", Name.Length() - 1 ); {
ItemGroup->Caption = Name; return (int) (( title << 16 ) | ( chapter & 0xffff ));
} }
Name.sprintf( "%s %d", ItemName, i_item + 1 ); /****************************************************************************
Item = new TMenuItem( Root ); * LangChange: change audio or subtitles languages
Item->RadioItem = true; ****************************************************************************
Item->Hint = Name; * Toggle the language, and update the selected menuitems.
****************************************************************************/
/* set the accelerator character */ void __fastcall TMenusGen::LangChange( TMenuItem *RootCurrent, TMenuItem *Item,
Name.Insert( "&", Name.Length() ); TMenuItem *RootOther, int i_cat )
Item->Caption = Name; {
es_descriptor_t * p_es;
/* FIXME: temporary hack to save i_item with the Item es_descriptor_t * p_es_old;
* It will be used in the callback. */ int i_index;
Item->Tag = i_item + 1; int i_es;
if( i_selected == i_item + 1 ) /* find the selected ES */
{ i_es = Item->Tag;
ItemActive = Item;
} /* find selected menu item */
i_index = Item2Index( RootCurrent, Item ) - 1;
/* setup signal handling */ if( i_index < 0 )
Item->OnClick = MenuItemClick; {
/* 'None' was selected */
if( i_nb > 20 ) p_es = NULL;
{ }
ItemGroup->Add( Item ); else
} {
else vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
{ p_es = p_intf->p_sys->p_input->stream.pp_es[i_es];
Root->Add( Item ); vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
} }
}
/* find the current ES */
// if( ( i_nb > 20 ) && ( i_item % 10 ) ) ? if( i_cat == AUDIO_ES )
if( i_nb > 20 ) {
{ p_es_old = this->p_audio_es_old;
Root->Add( ItemGroup ); this->p_audio_es_old = p_es;
} }
else
/* check currently selected chapter */ {
if( ItemActive != NULL ) p_es_old = this->p_spu_es_old;
{ this->p_spu_es_old = p_es;
ItemActive->Checked = true; }
}
/* exchange them */
/* be sure that menu is enabled, if there are several items */ input_ToggleES( p_intf->p_sys->p_input, p_es_old, false );
if( i_nb > 1 ) input_ToggleES( p_intf->p_sys->p_input, p_es, true );
{
Root->Enabled = true; Item->Checked = true;
} Index2Item( RootOther, i_index + 1, true )->Checked = true;
} }
/****************************************************************************
/***************************************************************************** * ProgramChange: change the program
* ProgramMenu: update the programs menu of the interface ****************************************************************************
***************************************************************************** * Toggle the program, and update the selected menuitems.
* Builds the program menu according to what have been found in the PAT ****************************************************************************/
* by the input. Useful for multi-programs streams such as DVB ones. void __fastcall TMenusGen::ProgramChange( TMenuItem *Item,
*****************************************************************************/ TMenuItem *RootOther )
static void __fastcall ProgramMenu( TMenuItem * Root, {
pgrm_descriptor_t * p_pgrm, int i_program = Item->Tag;
TNotifyEvent MenuItemClick )
{ /* toggle the program */
TMenuItem * Item; input_ChangeProgram( p_intf->p_sys->p_input, (uint16_t)i_program );
TMenuItem * ItemActive;
AnsiString Name; /* check selected menu items */
int i; Item->Checked = true;
Index2Item( RootOther, i_program - 1, true )->Checked = true;
/* remove previous menu */
Root->Clear(); /* update audio/subtitles menus */
Root->Enabled = false; p_intf->p_sys->b_audio_update = 1;
p_intf->p_sys->b_spu_update = 1;
ItemActive = NULL; vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
SetupMenus();
/* create a set of program buttons and append them to the container */ vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
for( i = 0; i < p_intfGlobal->p_sys->p_input->stream.i_pgrm_number; i++ ) p_intf->p_sys->b_audio_update = 0;
{ p_intf->p_sys->b_spu_update = 0;
Name.sprintf( "id %d",
p_intfGlobal->p_sys->p_input->stream.pp_programs[i]->i_number ); input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
}
Item = new TMenuItem( Root );
Item->Caption = Name; /*****************************************************************************
Item->Hint = Name; * ProgramMenu: update the programs menu of the interface
Item->RadioItem = true; *****************************************************************************
Item->OnClick = MenuItemClick; * Builds the program menu according to what have been found in the PAT
* by the input. Useful for multi-programs streams such as DVB ones.
/* FIXME: temporary hack to save the program id with the Item *****************************************************************************/
* It will be used in the callback. */ void __fastcall TMenusGen::ProgramMenu( TMenuItem *Root,
Item->Tag = i + 1; pgrm_descriptor_t *p_pgrm, TNotifyEvent MenuItemClick)
{
if( p_pgrm == p_intfGlobal->p_sys->p_input->stream.pp_programs[i] ) TMenuItem * Item;
{ TMenuItem * ItemActive;
/* don't lose Item when we append into menu */
ItemActive = Item; /* remove previous menu */
} Root->Clear();
Root->Enabled = false;
/* Add the item to the submenu */
Root->Add( Item ); ItemActive = NULL;
}
/* create a set of program buttons and append them to the container */
/* check currently selected program */ for( int i = 0; i < p_intf->p_sys->p_input->stream.i_pgrm_number; i++ )
if( ItemActive != NULL ) {
{ AnsiString Name;
ItemActive->Checked = true; Name.sprintf( "id %d",
} p_intf->p_sys->p_input->stream.pp_programs[i]->i_number );
/* be sure that menu is enabled if more than 1 program */ Item = new TMenuItem( Root );
if( p_intfGlobal->p_sys->p_input->stream.i_pgrm_number > 1 ) Item->Caption = Name;
{ Item->Hint = Name;
Root->Enabled = true; Item->RadioItem = true;
} Item->OnClick = MenuItemClick;
}
/* FIXME: temporary hack to save the program id with the Item
* It will be used in the callback. */
/***************************************************************************** Item->Tag = i + 1;
* LanguageMenus: update interactive menus of the interface
***************************************************************************** if( p_pgrm == p_intf->p_sys->p_input->stream.pp_programs[i] )
* Sets up menus with information from input: {
* - languages /* don't lose Item when we append into menu */
* - sub-pictures ItemActive = Item;
* Warning: since this function is designed to be called by management }
* function, the interface lock has to be taken
*****************************************************************************/ /* Add the item to the submenu */
static void __fastcall LanguageMenu( TMenuItem * Root, es_descriptor_t * p_es, Root->Add( Item );
int i_cat, TNotifyEvent MenuItemClick ) }
{
TMenuItem * Separator; /* check currently selected program */
TMenuItem * Item; if( ItemActive != NULL )
TMenuItem * ItemActive; {
AnsiString Name; ItemActive->Checked = true;
int i_item; }
int i;
/* be sure that menu is enabled if more than 1 program */
/* remove previous menu */ if( p_intf->p_sys->p_input->stream.i_pgrm_number > 1 )
Root->Clear(); {
Root->Enabled = false; Root->Enabled = true;
}
/* special case for "off" item */ }
Name = "None";
Item = new TMenuItem( Root ); /*****************************************************************************
Item->RadioItem = true; * RadioMenu: update interactive menus of the interface
Item->Hint = Name; *****************************************************************************
Item->Caption = Name; * Sets up menus with information from input
Item->OnClick = MenuItemClick; * Warning: since this function is designed to be called by management
Item->Tag = -1; * function, the interface lock has to be taken
Root->Add( Item ); *****************************************************************************/
void __fastcall TMenusGen::RadioMenu( TMenuItem *Root, AnsiString ItemName,
/* separator item */ int i_nb, int i_selected, TNotifyEvent MenuItemClick )
Separator = new TMenuItem( Root ); {
Separator->Caption = "-"; TMenuItem * ItemGroup;
Root->Add( Separator ); TMenuItem * Item;
TMenuItem * ItemActive;
ItemActive = NULL; AnsiString Name;
i_item = 0;
/* remove previous menu */
vlc_mutex_lock( &p_intfGlobal->p_sys->p_input->stream.stream_lock ); Root->Enabled = false;
Root->Clear();
#define ES p_intfGlobal->p_sys->p_input->stream.pp_es[i]
/* create a set of language buttons and append them to the Root */ ItemActive = NULL;
for( i = 0; i < p_intfGlobal->p_sys->p_input->stream.i_es_number; i++ )
{ for( int i_item = 0; i_item < i_nb; i_item++ )
if( ( ES->i_cat == i_cat ) && {
( !ES->p_pgrm || /* we group titles/chapters in packets of ten for small screens */
ES->p_pgrm == if( ( i_item % 10 == 0 ) && ( i_nb > 20 ) )
p_intfGlobal->p_sys->p_input->stream.p_selected_program ) ) {
{ if( i_item != 0 )
i_item++; {
Name = p_intfGlobal->p_sys->p_input->stream.pp_es[i]->psz_desc; Root->Add( ItemGroup );
if( Name.IsEmpty() ) }
{
Name.sprintf( "Language %d", i_item ); Name.sprintf( "%ss %d to %d", ItemName, i_item + 1, i_item + 10 );
} ItemGroup = new TMenuItem( Root );
ItemGroup->Hint = Name;
Item = new TMenuItem( Root ); ItemGroup->RadioItem = true;
Item->RadioItem = true;
Item->Hint = Name; /* set the accelerator character */
Item->Caption = Name; Name.Insert( "&", Name.Length() - 1 );
Item->Tag = i; ItemGroup->Caption = Name;
}
if( p_es == p_intfGlobal->p_sys->p_input->stream.pp_es[i] )
{ Name.sprintf( "%s %d", ItemName, i_item + 1 );
/* don't lose Item when we append into menu */ Item = new TMenuItem( Root );
ItemActive = Item; Item->RadioItem = true;
} Item->Hint = Name;
/* setup signal hanling */ /* set the accelerator character */
Item->OnClick = MenuItemClick; Name.Insert( "&", Name.Length() );
Root->Add( Item ); Item->Caption = Name;
}
} /* FIXME: temporary hack to save i_item with the Item
#undef ES * It will be used in the callback. */
Item->Tag = i_item + 1;
vlc_mutex_unlock( &p_intfGlobal->p_sys->p_input->stream.stream_lock );
if( i_selected == i_item + 1 )
/* check currently selected item */ {
if( ItemActive != NULL ) ItemActive = Item;
{ }
ItemActive->Checked = true;
} /* setup signal handling */
Item->OnClick = MenuItemClick;
/* be sure that menu is enabled if non empty */
if( i_item > 0 ) if( i_nb > 20 )
{ ItemGroup->Add( Item );
Root->Enabled = true; else
} Root->Add( Item );
} }
// if( ( i_nb > 20 ) && ( i_item % 10 ) ) ?
/***************************************************************************** if( i_nb > 20 )
* NavigationMenu: sets menus for titles and chapters selection {
***************************************************************************** Root->Add( ItemGroup );
* Generates two types of menus: }
* -simple list of titles
* -cascaded lists of chapters for each title /* check currently selected chapter */
*****************************************************************************/ if( ItemActive != NULL )
static void __fastcall NavigationMenu( TMenuItem * Root, {
TNotifyEvent MenuItemClick ) ItemActive->Checked = true;
{ }
TMenuItem * TitleGroup;
TMenuItem * TitleItem; /* be sure that menu is enabled, if there are several items */
TMenuItem * ItemActive; if( i_nb > 1 )
TMenuItem * ChapterGroup; {
TMenuItem * ChapterItem; Root->Enabled = true;
AnsiString Name; }
int i_title; }
int i_chapter;
int i_title_nb; /*****************************************************************************
int i_chapter_nb; * LanguageMenus: update interactive menus of the interface
*****************************************************************************
* Sets up menus with information from input:
/* remove previous menu */ * - languages
Root->Enabled = false; * - sub-pictures
Root->Clear(); * Warning: since this function is designed to be called by management
* function, the interface lock has to be taken
ItemActive = NULL; *****************************************************************************/
i_title_nb = p_intfGlobal->p_sys->p_input->stream.i_area_nb; void __fastcall TMenusGen::LanguageMenu( TMenuItem *Root, es_descriptor_t *p_es,
int i_cat, TNotifyEvent MenuItemClick )
/* loop on titles */ {
for( i_title = 1; i_title < i_title_nb; i_title++ ) TMenuItem * Separator;
{ TMenuItem * Item;
/* we group titles in packets of ten for small screens */ TMenuItem * ItemActive;
if( ( i_title % 10 == 1 ) && ( i_title_nb > 20 ) ) AnsiString Name;
{
if( i_title != 1 ) /* remove previous menu */
{ Root->Clear();
Root->Add( TitleGroup ); Root->Enabled = false;
}
/* special case for "off" item */
Name.sprintf( "%d - %d", i_title, i_title + 9 ); Name = "None";
TitleGroup = new TMenuItem( Root ); Item = new TMenuItem( Root );
TitleGroup->RadioItem = true; Item->RadioItem = true;
TitleGroup->Hint = Name; Item->Hint = Name;
TitleGroup->Caption = Name; Item->Caption = Name;
} Item->OnClick = MenuItemClick;
Item->Tag = -1;
Name.sprintf( "Title %d (%d)", i_title, Root->Add( Item );
p_intfGlobal->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb );
/* separator item */
{ Separator = new TMenuItem( Root );
TitleItem = new TMenuItem( Root ); Separator->Caption = "-";
TitleItem->RadioItem = true; Root->Add( Separator );
TitleItem->Hint = Name;
TitleItem->Caption = Name; ItemActive = NULL;
int i_item = 0;
i_chapter_nb =
p_intfGlobal->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb; vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
/* loop on chapters */ #define ES p_intf->p_sys->p_input->stream.pp_es[i]
for( i_chapter = 0; i_chapter < i_chapter_nb; i_chapter++ ) /* create a set of language buttons and append them to the Root */
{ for( int i = 0; i < p_intf->p_sys->p_input->stream.i_es_number; i++ )
/* we group chapters in packets of ten for small screens */ {
if( ( i_chapter % 10 == 0 ) && ( i_chapter_nb > 20 ) ) if( ( ES->i_cat == i_cat ) &&
{ ( !ES->p_pgrm ||
if( i_chapter != 0 ) ES->p_pgrm ==
{ p_intf->p_sys->p_input->stream.p_selected_program ) )
TitleItem->Add( ChapterGroup ); {
} i_item++;
Name = p_intf->p_sys->p_input->stream.pp_es[i]->psz_desc;
Name.sprintf( "%d - %d", i_chapter + 1, i_chapter + 10 ); if( Name.IsEmpty() )
ChapterGroup = new TMenuItem( TitleItem ); {
ChapterGroup->RadioItem = true; Name.sprintf( "Language %d", i_item );
ChapterGroup->Hint = Name; }
ChapterGroup->Caption = Name;
} Item = new TMenuItem( Root );
Item->RadioItem = true;
Name.sprintf( "Chapter %d", i_chapter + 1 ); Item->Hint = Name;
Item->Caption = Name;
ChapterItem = new TMenuItem( TitleItem ); Item->Tag = i;
ChapterItem->RadioItem = true;
ChapterItem->Hint = Name; if( p_es == p_intf->p_sys->p_input->stream.pp_es[i] )
ChapterItem->Caption = Name; {
/* don't lose Item when we append into menu */
/* FIXME: temporary hack to save i_title and i_chapter with ItemActive = Item;
* ChapterItem, since we will need them in the callback */ }
ChapterItem->Tag = (int)POS2DATA( i_title, i_chapter + 1 );
/* setup signal hanling */
#define p_area p_intfGlobal->p_sys->p_input->stream.pp_areas[i_title] Item->OnClick = MenuItemClick;
if( ( p_area == Root->Add( Item );
p_intfGlobal->p_sys->p_input->stream.p_selected_area ) && }
( p_area->i_part == i_chapter + 1 ) ) }
{ #undef ES
ItemActive = ChapterItem;
} vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
#undef p_area
/* check currently selected item */
/* setup signal hanling */ if( ItemActive != NULL )
ChapterItem->OnClick = MenuItemClick; {
ItemActive->Checked = true;
if( i_chapter_nb > 20 ) }
{
ChapterGroup->Add( ChapterItem ); /* be sure that menu is enabled if non empty */
} if( i_item > 0 )
else {
{ Root->Enabled = true;
TitleItem->Add( ChapterItem ); }
} }
}
/*****************************************************************************
if( i_chapter_nb > 20 ) * NavigationMenu: sets menus for titles and chapters selection
{ *****************************************************************************
TitleItem->Add( ChapterGroup ); * Generates two types of menus:
} * -simple list of titles
* -cascaded lists of chapters for each title
if( p_intfGlobal->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb *****************************************************************************/
> 1 ) void __fastcall TMenusGen::NavigationMenu( TMenuItem *Root,
{ TNotifyEvent MenuItemClick )
/* be sure that menu is sensitive */ {
Root->Enabled = true; TMenuItem * TitleGroup;
} TMenuItem * TitleItem;
} TMenuItem * ItemActive;
TMenuItem * ChapterGroup;
if( i_title_nb > 20 ) TMenuItem * ChapterItem;
{ AnsiString Name;
TitleGroup->Add( TitleItem ); int i_title_nb;
} int i_chapter_nb;
else
{
Root->Add( TitleItem ); /* remove previous menu */
} Root->Enabled = false;
} Root->Clear();
if( i_title_nb > 20 ) ItemActive = NULL;
{ i_title_nb = p_intf->p_sys->p_input->stream.i_area_nb;
Root->Add( TitleGroup );
} /* loop on titles */
for( int i_title = 1; i_title < i_title_nb; i_title++ )
/* Default selected chapter */ {
if( ItemActive != NULL ) /* we group titles in packets of ten for small screens */
{ if( ( i_title % 10 == 1 ) && ( i_title_nb > 20 ) )
ItemActive->Checked = true; {
} if( i_title != 1 )
{
/* be sure that menu is sensitive */ Root->Add( TitleGroup );
Root->Enabled = true; }
}
Name.sprintf( "%d - %d", i_title, i_title + 9 );
TitleGroup = new TMenuItem( Root );
/***************************************************************************** TitleGroup->RadioItem = true;
* SetupMenus: function that generates title/chapter/audio/subpic TitleGroup->Hint = Name;
* menus with help from preceding functions TitleGroup->Caption = Name;
*****************************************************************************/ }
int __fastcall SetupMenus( intf_thread_t * p_intf )
{ Name.sprintf( "Title %d (%d)", i_title,
TMainFrameDlg * p_window = p_intf->p_sys->p_window; p_intf->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb );
es_descriptor_t * p_audio_es; {
es_descriptor_t * p_spu_es; TitleItem = new TMenuItem( Root );
int i; TitleItem->RadioItem = true;
TitleItem->Hint = Name;
p_intf->p_sys->b_chapter_update |= p_intf->p_sys->b_title_update; TitleItem->Caption = Name;
p_intf->p_sys->b_audio_update |= p_intf->p_sys->b_title_update |
p_intf->p_sys->b_program_update; i_chapter_nb =
p_intf->p_sys->b_spu_update |= p_intf->p_sys->b_title_update | p_intf->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb;
p_intf->p_sys->b_program_update;
/* loop on chapters */
if( p_intf->p_sys->b_program_update ) for( int i_chapter = 0; i_chapter < i_chapter_nb; i_chapter++ )
{ {
pgrm_descriptor_t * p_pgrm; /* we group chapters in packets of ten for small screens */
if( ( i_chapter % 10 == 0 ) && ( i_chapter_nb > 20 ) )
if( p_intfGlobal->p_sys->p_input->stream.p_new_program ) {
{ if( i_chapter != 0 )
p_pgrm = p_intfGlobal->p_sys->p_input->stream.p_new_program; {
} TitleItem->Add( ChapterGroup );
else }
{
p_pgrm = p_intfGlobal->p_sys->p_input->stream.p_selected_program; Name.sprintf( "%d - %d", i_chapter + 1, i_chapter + 10 );
} ChapterGroup = new TMenuItem( TitleItem );
ChapterGroup->RadioItem = true;
ProgramMenu( p_window->MenuProgram, p_pgrm, ChapterGroup->Hint = Name;
p_window->MenuProgramClick ); ChapterGroup->Caption = Name;
ProgramMenu( p_window->PopupProgram, p_pgrm, }
p_window->PopupProgramClick );
Name.sprintf( "Chapter %d", i_chapter + 1 );
p_intf->p_sys->b_program_update = 0;
} ChapterItem = new TMenuItem( TitleItem );
ChapterItem->RadioItem = true;
if( p_intf->p_sys->b_title_update ) ChapterItem->Hint = Name;
{ ChapterItem->Caption = Name;
RadioMenu( p_window->MenuTitle, "Title",
//why "-1" ? /* FIXME: temporary hack to save i_title and i_chapter with
p_intfGlobal->p_sys->p_input->stream.i_area_nb - 1, * ChapterItem, since we will need them in the callback */
p_intfGlobal->p_sys->p_input->stream.p_selected_area->i_id, ChapterItem->Tag = Pos2Data( i_title, i_chapter + 1 );
p_window->MenuTitleClick );
#define p_area p_intf->p_sys->p_input->stream.pp_areas[i_title]
AnsiString CurrentTitle; if( ( p_area ==
CurrentTitle.sprintf( "%d", p_intf->p_sys->p_input->stream.p_selected_area ) &&
p_intfGlobal->p_sys->p_input->stream.p_selected_area->i_id ); ( p_area->i_part == i_chapter + 1 ) )
p_window->LabelTitleCurrent->Caption = CurrentTitle; {
ItemActive = ChapterItem;
p_intf->p_sys->b_title_update = 0; }
} #undef p_area
if( p_intf->p_sys->b_chapter_update ) /* setup signal handling */
{ ChapterItem->OnClick = MenuItemClick;
RadioMenu( p_window->MenuChapter, "Chapter",
p_intfGlobal->p_sys->p_input->stream.p_selected_area->i_part_nb, if( i_chapter_nb > 20 )
p_intfGlobal->p_sys->p_input->stream.p_selected_area->i_part, ChapterGroup->Add( ChapterItem );
p_window->MenuChapterClick ); else
TitleItem->Add( ChapterItem );
NavigationMenu( p_window->PopupNavigation, }
p_window->PopupNavigationClick );
if( i_chapter_nb > 20 )
AnsiString CurrentChapter; {
CurrentChapter.sprintf( "%d", TitleItem->Add( ChapterGroup );
p_intfGlobal->p_sys->p_input->stream.p_selected_area->i_part ); }
p_window->LabelChapterCurrent->Caption = CurrentChapter;
if( p_intf->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb
p_intf->p_sys->i_part = > 1 )
p_intfGlobal->p_sys->p_input->stream.p_selected_area->i_part; {
/* be sure that menu is sensitive */
p_intf->p_sys->b_chapter_update = 0; Root->Enabled = true;
} }
}
/* look for selected ES */
p_audio_es = NULL; if( i_title_nb > 20 )
p_spu_es = NULL; TitleGroup->Add( TitleItem );
else
for( i = 0; i < p_intfGlobal->p_sys->p_input->stream.i_selected_es_number; i++ ) Root->Add( TitleItem );
{ }
if( p_intfGlobal->p_sys->p_input->stream.pp_selected_es[i]->i_cat
== AUDIO_ES ) if( i_title_nb > 20 )
{ {
p_audio_es = p_intfGlobal->p_sys->p_input->stream.pp_selected_es[i]; Root->Add( TitleGroup );
p_intfGlobal->p_sys->p_audio_es_old = p_audio_es; }
}
/* Default selected chapter */
if( p_intfGlobal->p_sys->p_input->stream.pp_selected_es[i]->i_cat if( ItemActive != NULL )
== SPU_ES ) {
{ ItemActive->Checked = true;
p_spu_es = p_intfGlobal->p_sys->p_input->stream.pp_selected_es[i]; }
p_intfGlobal->p_sys->p_spu_es_old = p_spu_es;
} /* be sure that menu is sensitive */
} Root->Enabled = true;
}
vlc_mutex_unlock( &p_intfGlobal->p_sys->p_input->stream.stream_lock );
/* audio menus */
if( p_intf->p_sys->b_audio_update )
{
LanguageMenu( p_window->MenuAudio, p_audio_es, AUDIO_ES,
p_window->MenuAudioClick );
LanguageMenu( p_window->PopupAudio, p_audio_es, AUDIO_ES,
p_window->PopupAudioClick );
p_intf->p_sys->b_audio_update = 0;
}
/* sub picture menus */
if( p_intf->p_sys->b_spu_update )
{
LanguageMenu( p_window->PopupSubtitles, p_spu_es, SPU_ES,
p_window->PopupSubtitleClick );
LanguageMenu( p_window->MenuSubtitles, p_spu_es, SPU_ES,
p_window->MenuSubtitleClick );
p_intf->p_sys->b_spu_update = 0;
}
vlc_mutex_lock( &p_intfGlobal->p_sys->p_input->stream.stream_lock );
return true;
}
/***************************************************************************** /*****************************************************************************
* menu.h: prototypes for menu functions * menu.h: prototypes for menu functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* * $Id: menu.h,v 1.2 2002/12/13 03:52:58 videolan Exp $
* Authors: Olivier Teuliere <ipkiss@via.ecp.fr> *
* * Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * This program is free software; you can redistribute it and/or modify
* the Free Software Foundation; either version 2 of the License, or * it under the terms of the GNU General Public License as published by
* (at your option) any later version. * the Free Software Foundation; either version 2 of the License, or
* * (at your option) any later version.
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * This program is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU General Public License for more details.
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software * You should have received a copy of the GNU General Public License
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * along with this program; if not, write to the Free Software
*****************************************************************************/ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
int __fastcall SetupMenus( intf_thread_t * );
#ifndef menuH
/***************************************************************************** #define menuH
* Convert user_data structures to title and chapter information //----------------------------------------------------------------------------
*****************************************************************************/ class TMenusGen : public TObject
#define DATA2TITLE( data ) ( (int)((long)(data)) >> 16 ) {
#define DATA2CHAPTER( data ) ( (int)((long)(data)) & 0xffff ) private:
#define POS2DATA( title, chapter ) ( NULL + ( ((title) << 16) \ intf_thread_t *p_intf;
| ((chapter) & 0xffff)) )
/* local pointers to main window menu items */
TMenuItem *MenuAudio;
TMenuItem *PopupAudio;
TMenuItem *MenuSubtitles;
TMenuItem *PopupSubtitles;
TMenuItem *MenuProgram;
TMenuItem *PopupProgram;
TMenuItem *MenuTitle;
TMenuItem *MenuChapter;
TMenuItem *PopupNavigation;
/* Language information */
es_descriptor_t * p_audio_es_old;
es_descriptor_t * p_spu_es_old;
/* Helpful functions */
int Item2Index( TMenuItem *Root, TMenuItem *Item );
TMenuItem *Index2Item( TMenuItem *Root, int i_index, bool SingleColumn );
int __fastcall Data2Title( int data );
int __fastcall Data2Chapter( int data );
int __fastcall Pos2Data( int title, int chapter );
void __fastcall LangChange( TMenuItem *, TMenuItem *, TMenuItem *, int );
void __fastcall ProgramChange( TMenuItem *, TMenuItem * );
void __fastcall ProgramMenu( TMenuItem *, pgrm_descriptor_t *,
TNotifyEvent );
void __fastcall RadioMenu( TMenuItem *, AnsiString, int, int,
TNotifyEvent );
void __fastcall LanguageMenu( TMenuItem *, es_descriptor_t *, int,
TNotifyEvent );
void __fastcall NavigationMenu( TMenuItem *, TNotifyEvent );
public:
__fastcall TMenusGen( intf_thread_t *_p_intf );
/* menu generation */
void __fastcall SetupMenus();
/* callbacks for menuitems */
void __fastcall MenuAudioClick( TObject *Sender );
void __fastcall PopupAudioClick( TObject *Sender );
void __fastcall MenuSubtitleClick( TObject *Sender );
void __fastcall PopupSubtitleClick( TObject *Sender );
void __fastcall MenuProgramClick( TObject *Sender );
void __fastcall PopupProgramClick( TObject *Sender );
void __fastcall MenuTitleClick( TObject *Sender );
void __fastcall MenuChapterClick( TObject *Sender );
void __fastcall PopupNavigationClick( TObject *Sender );
};
//----------------------------------------------------------------------------
#endif
...@@ -662,7 +662,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name ) ...@@ -662,7 +662,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
break; break;
default: default:
msg_Warn( p_intf, "unknown config type" ); msg_Warn( p_intf, "unknown config type: %i", p_item->i_type );
break; break;
} }
......
...@@ -2,14 +2,15 @@ ...@@ -2,14 +2,15 @@
* win32.cpp : Win32 interface plugin for vlc * win32.cpp : Win32 interface plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: win32.cpp,v 1.5 2002/12/13 03:52:58 videolan Exp $
* *
* Authors: Olivier Teulire <ipkiss@via.ecp.fr> * Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -50,8 +51,6 @@ static void Run ( intf_thread_t * ); ...@@ -50,8 +51,6 @@ static void Run ( intf_thread_t * );
int Win32Manage( void *p_data ); int Win32Manage( void *p_data );
intf_thread_t *p_intfGlobal;
/***************************************************************************** /*****************************************************************************
* Open: initialize interface * Open: initialize interface
*****************************************************************************/ *****************************************************************************/
...@@ -67,7 +66,6 @@ static int Open ( vlc_object_t *p_this ) ...@@ -67,7 +66,6 @@ static int Open ( vlc_object_t *p_this )
return( 1 ); return( 1 );
}; };
p_intfGlobal = p_intf;
p_intf->pf_run = Run; p_intf->pf_run = Run;
p_intf->p_sys->p_sub = msg_Subscribe( p_intf ); p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
...@@ -109,6 +107,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -109,6 +107,7 @@ static void Run( intf_thread_t *p_intf )
p_intf->p_sys->p_window = new TMainFrameDlg( NULL, p_intf ); p_intf->p_sys->p_window = new TMainFrameDlg( NULL, p_intf );
p_intf->p_sys->p_playwin = new TPlaylistDlg( NULL, p_intf ); p_intf->p_sys->p_playwin = new TPlaylistDlg( NULL, p_intf );
p_intf->p_sys->p_messages = new TMessagesDlg( NULL, p_intf ); p_intf->p_sys->p_messages = new TMessagesDlg( NULL, p_intf );
p_intf->p_sys->p_menus = new TMenusGen( p_intf );
/* show main window and wait until it is closed */ /* show main window and wait until it is closed */
p_intf->p_sys->p_window->ShowModal(); p_intf->p_sys->p_window->ShowModal();
...@@ -116,6 +115,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -116,6 +115,7 @@ static void Run( intf_thread_t *p_intf )
if( p_intf->p_sys->p_disc ) delete p_intf->p_sys->p_disc; if( p_intf->p_sys->p_disc ) delete p_intf->p_sys->p_disc;
if( p_intf->p_sys->p_network ) delete p_intf->p_sys->p_network; if( p_intf->p_sys->p_network ) delete p_intf->p_sys->p_network;
if( p_intf->p_sys->p_preferences ) delete p_intf->p_sys->p_preferences; if( p_intf->p_sys->p_preferences ) delete p_intf->p_sys->p_preferences;
delete p_intf->p_sys->p_menus;
delete p_intf->p_sys->p_messages; delete p_intf->p_sys->p_messages;
delete p_intf->p_sys->p_playwin; delete p_intf->p_sys->p_playwin;
} }
...@@ -158,7 +158,7 @@ int Win32Manage( intf_thread_t *p_intf ) ...@@ -158,7 +158,7 @@ int Win32Manage( intf_thread_t *p_intf )
vlc_object_release( p_intf->p_sys->p_input ); vlc_object_release( p_intf->p_sys->p_input );
p_intf->p_sys->p_input = NULL; p_intf->p_sys->p_input = NULL;
} }
if( p_intf->p_sys->p_input ) if( p_intf->p_sys->p_input )
{ {
input_thread_t *p_input = p_intf->p_sys->p_input; input_thread_t *p_input = p_intf->p_sys->p_input;
...@@ -171,7 +171,7 @@ int Win32Manage( intf_thread_t *p_intf ) ...@@ -171,7 +171,7 @@ int Win32Manage( intf_thread_t *p_intf )
if( p_input->stream.b_changed ) if( p_input->stream.b_changed )
{ {
p_intf->p_sys->p_window->ModeManage(); p_intf->p_sys->p_window->ModeManage();
SetupMenus( p_intf ); p_intf->p_sys->p_menus->SetupMenus();
p_intf->p_sys->b_playing = 1; p_intf->p_sys->b_playing = 1;
} }
...@@ -209,7 +209,7 @@ int Win32Manage( intf_thread_t *p_intf ) ...@@ -209,7 +209,7 @@ int Win32Manage( intf_thread_t *p_intf )
/* Update the display */ /* Update the display */
// TrackBar->Invalidate(); // TrackBar->Invalidate();
# undef p_area # undef p_area
} }
...@@ -217,7 +217,7 @@ int Win32Manage( intf_thread_t *p_intf ) ...@@ -217,7 +217,7 @@ int Win32Manage( intf_thread_t *p_intf )
p_input->stream.p_selected_area->i_part ) p_input->stream.p_selected_area->i_part )
{ {
// p_intf->p_sys->b_chapter_update = 1; // p_intf->p_sys->b_chapter_update = 1;
SetupMenus( p_intf ); p_intf->p_sys->p_menus->SetupMenus();
} }
} }
...@@ -239,7 +239,7 @@ int Win32Manage( intf_thread_t *p_intf ) ...@@ -239,7 +239,7 @@ int Win32Manage( intf_thread_t *p_intf )
/* Just in case */ /* Just in case */
return( FALSE ); return( FALSE );
} }
vlc_mutex_unlock( &p_intf->change_lock ); vlc_mutex_unlock( &p_intf->change_lock );
return( TRUE ); return( TRUE );
......
...@@ -62,6 +62,7 @@ struct intf_sys_t ...@@ -62,6 +62,7 @@ struct intf_sys_t
TDiscDlg * p_disc; /* disc selection window */ TDiscDlg * p_disc; /* disc selection window */
TNetworkDlg * p_network; /* network stream window */ TNetworkDlg * p_network; /* network stream window */
TPreferencesDlg * p_preferences; /* preferences window */ TPreferencesDlg * p_preferences; /* preferences window */
TMenusGen * p_menus; /* object for menu generation */
/* The slider */ /* The slider */
off_t OldValue; /* previous value */ off_t OldValue; /* previous value */
...@@ -78,10 +79,6 @@ struct intf_sys_t ...@@ -78,10 +79,6 @@ struct intf_sys_t
TLabel * p_label_chapter; TLabel * p_label_chapter;
int i_part; /* current chapter */ int i_part; /* current chapter */
/* Language information */
es_descriptor_t * p_audio_es_old;
es_descriptor_t * p_spu_es_old;
/* The input thread */ /* The input thread */
input_thread_t * p_input; input_thread_t * p_input;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment