Commit b09db111 authored by gbazin's avatar gbazin

* modules/gui/wxwindows/*:

   + bookmarks menu.
   + started work on bookmarks dialog.
   + started support for embeddable vout (via vout_RequestWindow()/vout_ReleaseWindow()).   
   + new --wxwin-bookmarks and --wxwin-embed config options.
parent e6b4ae3e
......@@ -16,6 +16,8 @@ SOURCES_wxwindows = \
timer.cpp \
fileinfo.cpp \
subtitles.cpp \
bookmarks.cpp \
video.cpp \
v4l.cpp \
$(NULL)
......
/*****************************************************************************
* bookmarks.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004 VideoLAN
* $Id: bookmarks.cpp 6961 2004-03-05 17:34:23Z sam $
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
* 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
* 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
* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <errno.h> /* ENOMEM */
#include <string.h> /* strerror() */
#include <stdio.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include "wxwindows.h"
/*****************************************************************************
* Event Table.
*****************************************************************************/
/* IDs for the controls and the menu commands */
enum
{
/* menu items */
ButtonAdd_Event = wxID_HIGHEST + 1,
ButtonDel_Event
};
BEGIN_EVENT_TABLE(BookmarksDialog, wxFrame)
/* Hide the window when the user closes the window */
EVT_CLOSE(BookmarksDialog::OnClose )
EVT_BUTTON( ButtonAdd_Event, BookmarksDialog::OnAdd )
EVT_BUTTON( ButtonDel_Event, BookmarksDialog::OnDel )
EVT_LIST_ITEM_ACTIVATED( -1, BookmarksDialog::OnActivateItem )
END_EVENT_TABLE()
/*****************************************************************************
* Constructor.
*****************************************************************************/
BookmarksDialog::BookmarksDialog( intf_thread_t *_p_intf, wxWindow *p_parent )
: wxFrame( p_parent->GetParent() ? p_parent->GetParent() : p_parent,
-1, wxU(_("Bookmarks")),
!p_parent->GetParent() ? wxDefaultPosition :
wxPoint( p_parent->GetParent()->GetRect().GetX(),
p_parent->GetParent()->GetRect().GetY() +
p_parent->GetParent()->GetRect().GetHeight() + 40 ),
!p_parent->GetParent() ? wxDefaultSize :
wxSize( p_parent->GetParent()->GetRect().GetWidth(), -1 ),
wxDEFAULT_FRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
{
/* Initializations */
p_intf = _p_intf;
wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
wxPanel *panel = new wxPanel( this, -1 );
wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
wxButton *button_add =
new wxButton( panel, ButtonAdd_Event, wxU(_("Add")) );
wxButton *button_del =
new wxButton( panel, ButtonDel_Event, wxU(_("Remove")) );
panel_sizer->Add( button_add, 0, wxEXPAND );
panel_sizer->Add( button_del, 0, wxEXPAND );
panel->SetSizerAndFit( panel_sizer );
list_ctrl = new wxListView( this, -1, wxDefaultPosition, wxDefaultSize,
wxLC_REPORT | wxSUNKEN_BORDER |
wxLC_SINGLE_SEL );
list_ctrl->InsertColumn( 0, wxU(_("Description")) );
list_ctrl->SetColumnWidth( 0, 240 );
list_ctrl->InsertColumn( 1, wxU(_("Size offset")) );
list_ctrl->InsertColumn( 2, wxU(_("Time offset")) );
sizer->Add( panel, 0, wxEXPAND | wxALL, 5 );
sizer->Add( list_ctrl, 1, wxEXPAND | wxALL, 5 );
SetSizer( sizer );
}
BookmarksDialog::~BookmarksDialog()
{
}
/*****************************************************************************
* Private methods.
*****************************************************************************/
void BookmarksDialog::Update()
{
input_thread_t *p_input =
(input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
if( !p_input ) return;
seekpoint_t **pp_bookmarks;
int i_bookmarks;
if( input_Control( p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks,
&i_bookmarks ) != VLC_SUCCESS )
{
vlc_object_release( p_input );
return;
}
list_ctrl->DeleteAllItems();
for( int i = 0; i < i_bookmarks; i++ )
{
list_ctrl->InsertItem( i, wxL2U( pp_bookmarks[i]->psz_name ) );
list_ctrl->SetItem( i, 1, wxString::Format(wxT("%i"),
pp_bookmarks[i]->i_byte_offset ) );
list_ctrl->SetItem( i, 2, wxString::Format(wxT("%i"),
pp_bookmarks[i]->i_time_offset/1000000 ) );
}
vlc_object_release( p_input );
}
bool BookmarksDialog::Show( bool show )
{
Update();
return wxFrame::Show( show );
}
void BookmarksDialog::OnClose( wxCommandEvent& event )
{
Hide();
}
void BookmarksDialog::OnAdd( wxCommandEvent& event )
{
input_thread_t *p_input =
(input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
if( !p_input ) return;
seekpoint_t bookmark;
vlc_value_t pos;
var_Get( p_input, "position", &pos );
bookmark.psz_name = NULL;
bookmark.i_byte_offset =
(pos.f_float * p_input->stream.p_selected_area->i_size);
var_Get( p_input, "time", &pos );
bookmark.i_time_offset = pos.i_time;
input_Control( p_input, INPUT_ADD_BOOKMARK, &bookmark );
vlc_object_release( p_input );
Update();
}
void BookmarksDialog::OnDel( wxCommandEvent& event )
{
input_thread_t *p_input =
(input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
if( !p_input ) return;
int i_focused = list_ctrl->GetFocusedItem();
if( i_focused >= 0 )
{
input_Control( p_input, INPUT_DEL_BOOKMARK, i_focused );
}
vlc_object_release( p_input );
Update();
}
void BookmarksDialog::OnActivateItem( wxListEvent& event )
{
input_thread_t *p_input =
(input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
if( !p_input ) return;
input_Control( p_input, INPUT_SET_BOOKMARK, event.GetIndex() );
vlc_object_release( p_input );
}
......@@ -2,7 +2,7 @@
* dialogs.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004 VideoLAN
* $Id: dialogs.cpp,v 1.16 2004/03/01 18:31:13 gbazin Exp $
* $Id$
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -64,6 +64,8 @@ BEGIN_EVENT_TABLE(DialogsProvider, wxFrame)
DialogsProvider::OnStreamWizardDialog)
EVT_COMMAND(INTF_DIALOG_FILEINFO, wxEVT_DIALOG,
DialogsProvider::OnFileInfo)
EVT_COMMAND(INTF_DIALOG_BOOKMARKS, wxEVT_DIALOG,
DialogsProvider::OnBookmarks)
EVT_COMMAND(INTF_DIALOG_POPUPMENU, wxEVT_DIALOG,
DialogsProvider::OnPopupMenu)
EVT_COMMAND(INTF_DIALOG_EXIT, wxEVT_DIALOG,
......@@ -86,6 +88,7 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf, wxWindow *p_parent )
p_prefs_dialog = NULL;
p_file_generic_dialog = NULL;
p_streamwizard_dialog = NULL;
p_bookmarks_dialog = NULL;
/* Give our interface a nice little icon */
p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );
......@@ -93,6 +96,11 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf, wxWindow *p_parent )
/* Create the messages dialog so it can begin storing logs */
p_messages_dialog = new Messages( p_intf, p_parent ? p_parent : this );
/* Check if user wants to show the bookmarks dialog by default */
wxCommandEvent dummy_event;
if( config_GetInt( p_intf, "wxwin-bookmarks" ) )
OnBookmarks( dummy_event );
/* Intercept all menu events in our custom event handler */
PushEventHandler( new MenuEvtHandler( p_intf, NULL ) );
}
......@@ -108,6 +116,7 @@ DialogsProvider::~DialogsProvider()
if( p_fileinfo_dialog ) delete p_fileinfo_dialog;
if( p_file_generic_dialog ) delete p_file_generic_dialog;
if( p_streamwizard_dialog ) delete p_streamwizard_dialog;
if( p_bookmarks_dialog ) delete p_bookmarks_dialog;
if( p_intf->p_sys->p_icon ) delete p_intf->p_sys->p_icon;
......@@ -194,6 +203,18 @@ void DialogsProvider::OnStreamWizardDialog( wxCommandEvent& WXUNUSED(event) )
}
}
void DialogsProvider::OnBookmarks( wxCommandEvent& WXUNUSED(event) )
{
/* Show/hide the open dialog */
if( !p_bookmarks_dialog )
p_bookmarks_dialog = new BookmarksDialog( p_intf, this );
if( p_bookmarks_dialog )
{
p_bookmarks_dialog->Show( !p_bookmarks_dialog->IsShown() );
}
}
void DialogsProvider::OnOpenFileGeneric( wxCommandEvent& event )
{
intf_dialog_args_t *p_arg = (intf_dialog_args_t *)event.GetClientData();
......
......@@ -2,7 +2,7 @@
* interface.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004, 2003 VideoLAN
* $Id: interface.cpp,v 1.87 2004/03/01 18:31:13 gbazin Exp $
* $Id$
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -105,6 +105,8 @@ END_EVENT_TABLE()
* Event Table.
*****************************************************************************/
DEFINE_LOCAL_EVENT_TYPE( wxEVT_INTF );
/* IDs for the controls and the menu commands */
enum
{
......@@ -127,7 +129,8 @@ enum
FileInfo_Event,
Prefs_Event,
Extra_Event,
Extended_Event,
Bookmarks_Event,
Skins_Event,
SliderScroll_Event,
......@@ -166,9 +169,10 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
EVT_MENU_OPEN(Interface::OnMenuOpen)
EVT_MENU( Extra_Event, Interface::OnExtra)
EVT_CHECKBOX( Adjust_Event, Interface::OnEnableAdjust)
EVT_MENU( Extended_Event, Interface::OnExtended)
EVT_MENU( Bookmarks_Event, Interface::OnShowDialog)
EVT_CHECKBOX( Adjust_Event, Interface::OnEnableAdjust)
EVT_TEXT( Ratio_Event, Interface::OnRatio)
EVT_CHECKBOX( Visual_Event, Interface::OnEnableVisual)
......@@ -201,6 +205,9 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
EVT_COMMAND_SCROLL(Saturation_Event, Interface::OnSaturationUpdate)
EVT_COMMAND_SCROLL(Gamma_Event, Interface::OnGammaUpdate)
/* Custom events */
EVT_COMMAND(0, wxEVT_INTF, Interface::UpdateSizeEvent)
END_EVENT_TABLE()
/*****************************************************************************
......@@ -240,7 +247,7 @@ Interface::Interface( intf_thread_t *_p_intf ):
frame_sizer->Hide( slider_frame );
/* Create the extra panel */
CreateOurExtraPanel();
CreateOurExtendedPanel();
frame_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
frame_sizer->Hide( extra_frame );
......@@ -255,6 +262,13 @@ Interface::Interface( intf_thread_t *_p_intf ):
/* Make sure we've got the right background colour */
SetBackgroundColour( slider_frame->GetBackgroundColour() );
/* Video window */
if( config_GetInt( p_intf, "wxwin-embed" ) )
{
VideoWindow( p_intf, this );
frame_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND , 0 );
}
/* Layout everything */
frame_sizer->Layout();
frame_sizer->Fit(this);
......@@ -281,13 +295,19 @@ Interface::~Interface()
delete timer;
}
void Interface::UpdateSizeEvent( wxCommandEvent& event )
{
frame_sizer->Layout();
frame_sizer->Fit(this);
}
/*****************************************************************************
* Private methods.
*****************************************************************************/
void Interface::CreateOurMenuBar()
{
#define HELP_SIMPLE N_("Quick file open")
#define HELP_ADV N_("Advanced open")
#define HELP_ADV N_("Advanced open")
#define HELP_FILE N_("Open a file")
#define HELP_DISC N_("Open Disc Media")
#define HELP_NET N_("Open a network stream")
......@@ -296,14 +316,14 @@ void Interface::CreateOurMenuBar()
#define HELP_EXIT N_("Exit this program")
#define HELP_STREAMWIZARD N_("Open the streaming wizard")
#define HELP_OTHER N_("Open other types of inputs")
#define HELP_PLAYLIST N_("Open the playlist")
#define HELP_LOGS N_("Show the program logs")
#define HELP_FILEINFO N_("Show information about the file being played")
#define HELP_FILEINFO N_("Show information about the file being played")
#define HELP_PREFS N_("Go to the preferences menu")
#define EXTRA_PREFS N_("Shows the extended GUI")
#define HELP_PREFS N_("Go to the preferences menu")
#define HELP_EXTENDED N_("Shows the extended GUI")
#define HELP_BOOKMARKS N_("Shows the bookmarks window")
#define HELP_ABOUT N_("About this program")
......@@ -485,7 +505,7 @@ void Interface::CreateOurSlider()
}
void Interface::CreateOurExtraPanel()
void Interface::CreateOurExtendedPanel()
{
char *psz_filters;
......@@ -752,8 +772,10 @@ void Interface::OnMenuOpen(wxMenuEvent& event)
p_settings_menu = SettingsMenu( p_intf, this );
/* Add static items */
p_settings_menu->AppendCheckItem( Extra_Event,
wxU(_("&Extended GUI") ), wxU(_(EXTRA_PREFS)) );
p_settings_menu->AppendCheckItem( Extended_Event,
wxU(_("&Extended GUI") ), wxU(_(HELP_EXTENDED)) );
p_settings_menu->AppendCheckItem( Bookmarks_Event,
wxU(_("&Bookmarks") ), wxU(_(HELP_BOOKMARKS)) );
p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
wxU(_(HELP_PREFS)) );
......@@ -831,8 +853,10 @@ void Interface::OnMenuOpen(wxMenuEvent& event)
#else
p_settings_menu = SettingsMenu( p_intf, this );
/* Add static items */
p_settings_menu->AppendCheckItem( Extra_Event, wxU(_("&Extended GUI") ),
wxU(_(EXTRA_PREFS)) );
p_settings_menu->AppendCheckItem( Extended_Event, wxU(_("&Extended GUI") ),
wxU(_(HELP_EXTENDED)) );
p_settings_menu->AppendCheckItem( Bookmarks_Event, wxU(_("&Bookmarks") ),
wxU(_(HELP_BOOKMARKS)) );
p_settings_menu->Append( Prefs_Event, wxU(_("&Preferences...")),
wxU(_(HELP_PREFS)) );
wxMenu *menu =
......@@ -934,6 +958,9 @@ void Interface::OnShowDialog( wxCommandEvent& event )
case StreamWizard_Event:
i_id = INTF_DIALOG_STREAMWIZARD;
break;
case Bookmarks_Event:
i_id = INTF_DIALOG_BOOKMARKS;
break;
default:
i_id = INTF_DIALOG_FILE;
break;
......@@ -943,7 +970,7 @@ void Interface::OnShowDialog( wxCommandEvent& event )
}
}
void Interface::OnExtra(wxCommandEvent& event)
void Interface::OnExtended(wxCommandEvent& event)
{
if( b_extra == VLC_FALSE)
{
......
......@@ -2,7 +2,7 @@
* menus.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004 VideoLAN
* $Id: menus.cpp,v 1.33 2004/02/26 12:04:14 gbazin Exp $
* $Id$
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -170,6 +170,8 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
FIND_ANYWHERE );
if( p_object != NULL )
{
ppsz_varnames[i] = "bookmark";
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "title";
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "chapter";
......@@ -342,6 +344,8 @@ wxMenu *NavigMenu( intf_thread_t *_p_intf, wxWindow *p_parent )
FIND_ANYWHERE );
if( p_object != NULL )
{
ppsz_varnames[i] = "bookmark";
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "title";
pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "chapter";
......
/*****************************************************************************
* video.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004, 2003 VideoLAN
* $Id: interface.cpp 6961 2004-03-05 17:34:23Z sam $
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
* 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
* 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
* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
#include <vlc/vout.h>
#include <vlc/intf.h>
#include "stream_control.h"
#include "wxwindows.h"
static void *GetWindow( intf_thread_t *p_intf, int *pi_x_hint, int *pi_y_hint,
unsigned int *pi_width_hint,
unsigned int *pi_height_hint );
static void ReleaseWindow( intf_thread_t *p_intf, void *p_window );
/* IDs for the controls and the menu commands */
enum
{
UpdateSize_Event = wxID_HIGHEST + 1,
UpdateHide_Event
};
class VideoWindow: public wxWindow
{
public:
/* Constructor */
VideoWindow( intf_thread_t *_p_intf, wxWindow *p_parent );
virtual ~VideoWindow();
void *GetWindow( int *, int *, unsigned int *, unsigned int * );
void ReleaseWindow( void * );
private:
intf_thread_t *p_intf;
wxWindow *p_parent;
vlc_mutex_t lock;
vlc_bool_t b_in_use;
wxWindow *p_child_window;
void UpdateSize( wxSizeEvent & );
void UpdateHide( wxSizeEvent & );
DECLARE_EVENT_TABLE();
};
BEGIN_EVENT_TABLE(VideoWindow, wxWindow)
EVT_CUSTOM( wxEVT_SIZE, UpdateSize_Event, VideoWindow::UpdateSize )
EVT_CUSTOM( wxEVT_SIZE, UpdateHide_Event, VideoWindow::UpdateHide )
END_EVENT_TABLE()
/*****************************************************************************
* Public methods.
*****************************************************************************/
wxWindow *VideoWindow( intf_thread_t *p_intf, wxWindow *p_parent )
{
return new VideoWindow::VideoWindow( p_intf, p_parent );
}
/*****************************************************************************
* Constructor.
*****************************************************************************/
VideoWindow::VideoWindow( intf_thread_t *_p_intf, wxWindow *_p_parent ):
wxWindow( _p_parent, -1 )
{
/* Initializations */
p_intf = _p_intf;
p_parent = _p_parent;
vlc_mutex_init( p_intf, &lock );
b_in_use = VLC_FALSE;
p_intf->pf_request_window = ::GetWindow;
p_intf->pf_release_window = ::ReleaseWindow;
p_intf->p_sys->p_video_window = this;
p_child_window = new wxWindow( this, -1, wxDefaultPosition, wxSize(0,0) );
p_child_window->Show();
Show();
p_intf->p_sys->p_video_sizer = new wxBoxSizer( wxHORIZONTAL );
p_intf->p_sys->p_video_sizer->Add( this, 1, wxEXPAND );
ReleaseWindow( NULL );
}
VideoWindow::~VideoWindow()
{
vlc_mutex_destroy( &lock );
}
/*****************************************************************************
* Private methods.
*****************************************************************************/
static void *GetWindow( intf_thread_t *p_intf, int *pi_x_hint, int *pi_y_hint,
unsigned int *pi_width_hint,
unsigned int *pi_height_hint )
{
return p_intf->p_sys->p_video_window->GetWindow( pi_x_hint, pi_y_hint,
pi_width_hint,
pi_height_hint );
}
/* Part of the hack to get the X11 window handle from the GtkWidget */
#ifdef __WXGTK__
extern "C" {
#ifdef __WXGTK20__
int gdk_x11_drawable_get_xid( void * );
#endif
void *gtk_widget_get_parent_window( void * );
}
#endif
void *VideoWindow::GetWindow( int *pi_x_hint, int *pi_y_hint,
unsigned int *pi_width_hint,
unsigned int *pi_height_hint )
{
#if defined(__WXGTK__) || defined(WIN32)
vlc_mutex_lock( &lock );
if( b_in_use )
{
msg_Dbg( p_intf, "Video window already in use" );
return NULL;
}
b_in_use = VLC_TRUE;
wxSizeEvent event( wxSize(*pi_width_hint, *pi_height_hint),
UpdateSize_Event );
AddPendingEvent( event );
vlc_mutex_unlock( &lock );
#ifdef __WXGTK__
GtkWidget *p_widget = p_child_window->GetHandle();
#ifdef __WXGTK20__
return (void *)gdk_x11_drawable_get_xid(