Commit f079727c authored by Yoann Peronneau's avatar Yoann Peronneau

* modules/gui/wxwindows/interface.cpp: Add new buttons for DVDs and CDs:

  - Menu, Previous Chapter, Next Chapter for DVDs
  - Previous Track, Next Track for CDs
parent cf9cb951
......@@ -27,6 +27,7 @@
#include <vlc/vlc.h>
#include <vlc/aout.h>
#include <vlc/vout.h>
#include <vlc/input.h>
#include <vlc/intf.h>
#include "wxwindows.h"
......@@ -138,6 +139,10 @@ enum
SlowStream_Event,
FastStream_Event,
DiscMenu_Event,
DiscPrev_Event,
DiscNext_Event,
/* it is important for the id corresponding to the "About" command to have
* this standard value as otherwise it won't be handled properly under Mac
* (where it is special and put into the "Apple" menu) */
......@@ -182,6 +187,11 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
EVT_MENU(FastStream_Event, Interface::OnFastStream)
/* Disc Buttons events */
EVT_BUTTON(DiscMenu_Event, Interface::OnDiscMenu)
EVT_BUTTON(DiscPrev_Event, Interface::OnDiscPrev)
EVT_BUTTON(DiscNext_Event, Interface::OnDiscNext)
/* Slider events */
EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
......@@ -350,7 +360,7 @@ void Interface::CreateOurMenuBar()
help_menu->Append( About_Event, wxU(_("About VLC media player")) );
/* Append the freshly created menus to the menu bar... */
wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
wxMenuBar *menubar = new wxMenuBar();
menubar->Append( file_menu, wxU(_("&File")) );
menubar->Append( view_menu, wxU(_("&View")) );
menubar->Append( p_settings_menu, wxU(_("&Settings")) );
......@@ -445,7 +455,7 @@ void Interface::CreateOurToolBar()
* version because we don't include wx.rc */
wxToolBar *toolbar =
CreateToolBar( wxTB_HORIZONTAL | wxTB_FLAT ); //| wxTB_DOCKABLE );
CreateToolBar( wxTB_HORIZONTAL | wxTB_FLAT );
toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
......@@ -495,24 +505,48 @@ void Interface::CreateOurSlider()
/* Create a new frame and sizer containing the slider */
slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
slider_frame->SetAutoLayout( TRUE );
wxBoxSizer *frame_sizer = new wxBoxSizer( wxHORIZONTAL );
//frame_sizer->SetMinSize( -1, 50 );
slider_sizer = new wxBoxSizer( wxHORIZONTAL );
//slider_sizer->SetMinSize( -1, 50 );
/* Create slider */
slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
/* Add Disc Buttons */
disc_frame = new wxPanel( slider_frame, -1, wxDefaultPosition,
wxDefaultSize );
disc_frame->SetAutoLayout( TRUE );
disc_sizer = new wxBoxSizer( wxHORIZONTAL );
disc_menu_button = new wxBitmapButton( disc_frame, DiscMenu_Event,
wxBitmap( playlist_xpm ) );
disc_prev_button = new wxBitmapButton( disc_frame, DiscPrev_Event,
wxBitmap( prev_xpm ) );
disc_next_button = new wxBitmapButton( disc_frame, DiscNext_Event,
wxBitmap( next_xpm ) );
disc_sizer->Add( disc_menu_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 1 );
disc_sizer->Add( disc_prev_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 1 );
disc_sizer->Add( disc_next_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 1 );
disc_frame->SetSizer( disc_sizer );
disc_sizer->Layout();
/* Add everything to the frame */
frame_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
slider_frame->SetSizer( frame_sizer );
frame_sizer->Layout();
frame_sizer->SetSizeHints(slider_frame);
slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
slider_sizer->Add( disc_frame, 0, wxALL, 2 );
slider_frame->SetSizer( slider_sizer );
disc_frame->Hide();
slider_sizer->Hide( disc_frame );
slider_sizer->Layout();
slider_sizer->Fit( slider_frame );
/* Hide the slider by default */
slider_frame->Hide();
}
static int ConvertHotkeyModifiers( int i_hotkey )
{
int i_accel_flags = 0;
......@@ -1068,6 +1102,54 @@ void Interface::TogglePlayButton( int i_playing_status )
i_old_playing_status = i_playing_status;
}
void Interface::OnDiscMenu( wxCommandEvent& WXUNUSED(event) )
{
input_thread_t *p_input =
(input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
if( p_input )
{
vlc_value_t val; val.i_int = 2;
var_Set( p_input, "title 0", val);
vlc_object_release( p_input );
}
}
void Interface::OnDiscPrev( wxCommandEvent& WXUNUSED(event) )
{
input_thread_t *p_input =
(input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
if( p_input )
{
int i_type = var_Type( p_input, "prev-chapter" );
vlc_value_t val; val.b_bool = VLC_TRUE;
var_Set( p_input, ( i_type & VLC_VAR_TYPE ) != 0 ?
"prev-chapter" : "prev-title", val );
vlc_object_release( p_input );
}
}
void Interface::OnDiscNext( wxCommandEvent& WXUNUSED(event) )
{
input_thread_t *p_input =
(input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
if( p_input )
{
int i_type = var_Type( p_input, "next-chapter" );
vlc_value_t val; val.b_bool = VLC_TRUE;
var_Set( p_input, ( i_type & VLC_VAR_TYPE ) != 0 ?
"next-chapter" : "next-title", val );
vlc_object_release( p_input );
}
}
#if wxUSE_DRAG_AND_DROP
/*****************************************************************************
* Definition of DragAndDrop class.
......
......@@ -95,6 +95,7 @@ Timer::~Timer()
*****************************************************************************/
void Timer::Notify()
{
input_thread_t *p_input = NULL;
#if defined( __WXMSW__ ) /* Work-around a bug with accelerators */
if( !b_init )
{
......@@ -122,6 +123,7 @@ void Timer::Notify()
{
p_main_interface->slider->SetValue( 0 );
b_old_seekable = VLC_FALSE;
b_disc_shown = VLC_FALSE;
p_main_interface->statusbar->SetStatusText(
wxU(p_intf->p_sys->p_input->input.p_item->psz_name), 2 );
......@@ -132,7 +134,13 @@ void Timer::Notify()
}
else if( p_intf->p_sys->p_input->b_dead )
{
/* Hide slider */
/* Hide slider and Disc Buttons */
p_main_interface->disc_frame->Hide();
p_main_interface->slider_sizer->Hide(
p_main_interface->disc_frame );
p_main_interface->slider_sizer->Layout();
p_main_interface->slider_sizer->Fit( p_main_interface->slider_frame );
p_main_interface->slider_frame->Hide();
p_main_interface->frame_sizer->Hide(
p_main_interface->slider_frame );
......@@ -148,7 +156,6 @@ void Timer::Notify()
p_intf->p_sys->p_input = NULL;
}
if( p_intf->p_sys->p_input )
{
input_thread_t *p_input = p_intf->p_sys->p_input;
......@@ -170,19 +177,67 @@ void Timer::Notify()
/* Change the name of b_old_seekable into b_show_bar or something like that */
var_Get( p_input, "position", &pos );
if( !b_old_seekable )
vlc_value_t val;
var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
if( val.i_int > 0 && !b_disc_shown )
{
b_disc_shown = VLC_TRUE;
vlc_value_t val;
#define HELP_MENU N_("Menu")
#define HELP_PCH N_("Previous chapter")
#define HELP_NCH N_("Next chapter")
#define HELP_PTR N_("Previous track")
#define HELP_NTR N_("Next track")
var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val,
NULL );
if( val.i_int > 0 )
{
p_main_interface->disc_menu_button->Show();
p_main_interface->disc_sizer->Show(
p_main_interface->disc_menu_button );
p_main_interface->disc_sizer->Layout();
p_main_interface->disc_sizer->Fit(
p_main_interface->disc_frame );
p_main_interface->disc_menu_button->SetToolTip(
wxU(_( HELP_MENU ) ) );
p_main_interface->disc_prev_button->SetToolTip(
wxU(_( HELP_PCH ) ) );
p_main_interface->disc_next_button->SetToolTip(
wxU(_( HELP_NCH ) ) );
}
else
{
p_main_interface->disc_menu_button->Hide();
p_main_interface->disc_sizer->Hide(
p_main_interface->disc_menu_button );
p_main_interface->disc_prev_button->SetToolTip(
wxU(_( HELP_PTR ) ) );
p_main_interface->disc_next_button->SetToolTip(
wxU(_( HELP_NTR ) ) );
}
p_main_interface->disc_frame->Show();
p_main_interface->slider_sizer->Show(
p_main_interface->disc_frame );
}
if( ! b_old_seekable )
{
if( pos.f_float > 0.0 )
{
/* Done like this, as it's the only way to know if the slider
* has to be displayed */
/* Done like this, as it's the only way to know if the */
/* slider has to be displayed */
b_old_seekable = VLC_TRUE;
p_main_interface->slider_frame->Show();
p_main_interface->frame_sizer->Show(
p_main_interface->slider_frame );
p_main_interface->frame_sizer->Layout();
p_main_interface->frame_sizer->Fit( p_main_interface );
}
}
......
......@@ -187,6 +187,7 @@ private:
int i_old_playing_status;
int i_old_rate;
vlc_bool_t b_old_seekable;
vlc_bool_t b_disc_shown;
};
......@@ -303,8 +304,15 @@ public:
wxSlider *slider;
wxWindow *slider_frame;
wxBoxSizer *slider_sizer;
wxPanel *extra_frame;
wxPanel *disc_frame;
wxBoxSizer *disc_sizer;
wxBitmapButton *disc_menu_button;
wxBitmapButton *disc_prev_button;
wxBitmapButton *disc_next_button;
wxFrame *extra_window;
vlc_bool_t b_extra;
......@@ -345,6 +353,10 @@ private:
void OnSlowStream( wxCommandEvent& event );
void OnFastStream( wxCommandEvent& event );
void OnDiscMenu( wxCommandEvent& event );
void OnDiscPrev( wxCommandEvent& event );
void OnDiscNext( wxCommandEvent& event );
void OnMenuOpen( wxMenuEvent& event );
#if defined( __WXMSW__ ) || defined( __WXMAC__ )
......
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