Commit afe32c01 authored by Anthony Loiseau's avatar Anthony Loiseau Committed by Jean-Paul Saman

Add "toolbar:bool" RW property for the JS API, fix toolbar visibility

The mozilla plugin has already a "toolbar"(bool) parameter.
For coherency between ActiveX and mozilla plugin, the "toolbar"
parameter has been added to ActiveX, which has created also a
"toolbar" property in the exported API (JavaScript for web pages).
This commit add it to mozilla plugin too, to maintain coherency.

This commit also fix toolbar visibility when toolbar="true" parameter
is used in embed object.
Signed-off-by: default avatarJean-Paul Saman <jpsaman@videolan.org>
parent 4dd78ea8
...@@ -59,6 +59,14 @@ VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) : ...@@ -59,6 +59,14 @@ VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) :
,i_tb_width(0) ,i_tb_width(0)
,i_tb_height(0) ,i_tb_height(0)
,i_last_position(0) ,i_last_position(0)
,p_btnPlay(NULL)
,p_btnPause(NULL)
,p_btnStop(NULL)
,p_btnMute(NULL)
,p_btnUnmute(NULL)
,p_btnFullscreen(NULL)
,p_btnTime(NULL)
,p_timeline(NULL)
#endif #endif
{ {
memset(&npwindow, 0, sizeof(NPWindow)); memset(&npwindow, 0, sizeof(NPWindow));
...@@ -157,7 +165,8 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[]) ...@@ -157,7 +165,8 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
{ {
ppsz_argv[ppsz_argc++] = "--loop"; ppsz_argv[ppsz_argc++] = "--loop";
} }
else { else
{
ppsz_argv[ppsz_argc++] = "--no-loop"; ppsz_argv[ppsz_argc++] = "--no-loop";
} }
} }
...@@ -418,61 +427,70 @@ void VlcPlugin::showToolbar() ...@@ -418,61 +427,70 @@ void VlcPlugin::showToolbar()
{ {
const NPWindow& window = getWindow(); const NPWindow& window = getWindow();
Window control = getControlWindow(); Window control = getControlWindow();
Window video = getVideoWindow();
Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display; Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
unsigned int i_height = 0, i_width = 0; unsigned int i_height = 0, i_width = 0;
/* load icons */ /* load icons */
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/play.xpm", if( !p_btnPlay )
&p_btnPlay, NULL, NULL); XpmReadFileToImage( p_display, DATA_PATH "/mozilla/play.xpm",
&p_btnPlay, NULL, NULL);
if( p_btnPlay ) if( p_btnPlay )
{ {
i_height = __MAX( i_height, p_btnPlay->height ); i_height = __MAX( i_height, p_btnPlay->height );
i_width += p_btnPlay->width; i_width += p_btnPlay->width;
} }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/pause.xpm", if( !p_btnPause )
&p_btnPause, NULL, NULL); XpmReadFileToImage( p_display, DATA_PATH "/mozilla/pause.xpm",
&p_btnPause, NULL, NULL);
if( p_btnPause ) if( p_btnPause )
{ {
i_height = __MAX( i_height, p_btnPause->height ); i_height = __MAX( i_height, p_btnPause->height );
i_width += p_btnPause->width; i_width += p_btnPause->width;
} }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/stop.xpm", if( !p_btnStop )
&p_btnStop, NULL, NULL ); XpmReadFileToImage( p_display, DATA_PATH "/mozilla/stop.xpm",
&p_btnStop, NULL, NULL );
if( p_btnStop ) if( p_btnStop )
{ {
i_height = __MAX( i_height, p_btnStop->height ); i_height = __MAX( i_height, p_btnStop->height );
i_width += p_btnStop->width; i_width += p_btnStop->width;
} }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_line.xpm", if( !p_timeline )
&p_timeline, NULL, NULL); XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_line.xpm",
&p_timeline, NULL, NULL);
if( p_timeline ) if( p_timeline )
{ {
i_height = __MAX( i_height, p_timeline->height ); i_height = __MAX( i_height, p_timeline->height );
i_width += p_timeline->width; i_width += p_timeline->width;
} }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_icon.xpm", if( !p_btnTime )
&p_btnTime, NULL, NULL); XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_icon.xpm",
&p_btnTime, NULL, NULL);
if( p_btnTime ) if( p_btnTime )
{ {
i_height = __MAX( i_height, p_btnTime->height ); i_height = __MAX( i_height, p_btnTime->height );
i_width += p_btnTime->width; i_width += p_btnTime->width;
} }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/fullscreen.xpm", if( !p_btnFullscreen )
&p_btnFullscreen, NULL, NULL); XpmReadFileToImage( p_display, DATA_PATH "/mozilla/fullscreen.xpm",
&p_btnFullscreen, NULL, NULL);
if( p_btnFullscreen ) if( p_btnFullscreen )
{ {
i_height = __MAX( i_height, p_btnFullscreen->height ); i_height = __MAX( i_height, p_btnFullscreen->height );
i_width += p_btnFullscreen->width; i_width += p_btnFullscreen->width;
} }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_max.xpm", if( !p_btnMute )
&p_btnMute, NULL, NULL); XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_max.xpm",
&p_btnMute, NULL, NULL);
if( p_btnMute ) if( p_btnMute )
{ {
i_height = __MAX( i_height, p_btnMute->height ); i_height = __MAX( i_height, p_btnMute->height );
i_width += p_btnMute->width; i_width += p_btnMute->width;
} }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_mute.xpm", if( !p_btnUnmute )
&p_btnUnmute, NULL, NULL); XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_mute.xpm",
&p_btnUnmute, NULL, NULL);
if( p_btnUnmute ) if( p_btnUnmute )
{ {
i_height = __MAX( i_height, p_btnUnmute->height ); i_height = __MAX( i_height, p_btnUnmute->height );
...@@ -483,10 +501,24 @@ void VlcPlugin::showToolbar() ...@@ -483,10 +501,24 @@ void VlcPlugin::showToolbar()
if( !p_btnPlay || !p_btnPause || !p_btnStop || !p_timeline || if( !p_btnPlay || !p_btnPause || !p_btnStop || !p_timeline ||
!p_btnTime || !p_btnFullscreen || !p_btnMute || !p_btnUnmute ) !p_btnTime || !p_btnFullscreen || !p_btnMute || !p_btnUnmute )
fprintf(stderr, "Error: some button images not found in %s\n", DATA_PATH ); fprintf(stderr, "Error: some button images not found in %s\n", DATA_PATH );
/* reset panels position and size */
/* XXX use i_width */
XResizeWindow( p_display, video, window.width, window.height - i_height);
XMoveWindow( p_display, control, 0, window.height - i_height );
XResizeWindow( p_display, control, window.width, i_height -1);
b_toolbar = 1; /* says toolbar is now shown */
redrawToolbar();
} }
void VlcPlugin::hideToolbar() void VlcPlugin::hideToolbar()
{ {
const NPWindow& window = getWindow();
Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
Window control = getControlWindow();
Window video = getVideoWindow();
i_tb_width = i_tb_height = 0; i_tb_width = i_tb_height = 0;
if( p_btnPlay ) XDestroyImage( p_btnPlay ); if( p_btnPlay ) XDestroyImage( p_btnPlay );
...@@ -506,6 +538,15 @@ void VlcPlugin::hideToolbar() ...@@ -506,6 +538,15 @@ void VlcPlugin::hideToolbar()
p_btnFullscreen = NULL; p_btnFullscreen = NULL;
p_btnMute = NULL; p_btnMute = NULL;
p_btnUnmute = NULL; p_btnUnmute = NULL;
/* reset panels position and size */
/* XXX use i_width */
XResizeWindow( p_display, video, window.width, window.height );
XMoveWindow( p_display, control, 0, window.height-1 );
XResizeWindow( p_display, control, window.width, 1 );
b_toolbar = 0; /* says toolbar is now hidden */
redrawToolbar();
} }
void VlcPlugin::redrawToolbar() void VlcPlugin::redrawToolbar()
...@@ -518,12 +559,19 @@ void VlcPlugin::redrawToolbar() ...@@ -518,12 +559,19 @@ void VlcPlugin::redrawToolbar()
unsigned int dst_x, dst_y; unsigned int dst_x, dst_y;
GC gc; GC gc;
XGCValues gcv; XGCValues gcv;
unsigned int i_tb_width, i_tb_height;
#define BTN_SPACE ((unsigned int)4) #define BTN_SPACE ((unsigned int)4)
/* This method does nothing if toolbar is hidden. */
if( !b_toolbar )
return;
const NPWindow& window = getWindow(); const NPWindow& window = getWindow();
Window control = getControlWindow(); Window control = getControlWindow();
Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display; Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
getToolbarSize( &i_tb_width, &i_tb_height );
/* get media instance */ /* get media instance */
libvlc_exception_init( &ex ); libvlc_exception_init( &ex );
p_md = libvlc_playlist_get_media_player( getVLC(), &ex ); p_md = libvlc_playlist_get_media_player( getVLC(), &ex );
...@@ -557,64 +605,69 @@ void VlcPlugin::redrawToolbar() ...@@ -557,64 +605,69 @@ void VlcPlugin::redrawToolbar()
XChangeGC( p_display, gc, GCForeground, &gcv ); XChangeGC( p_display, gc, GCForeground, &gcv );
/* position icons */ /* position icons */
dst_x = 4; dst_y = 4; dst_x = BTN_SPACE;
dst_y = i_tb_height >> 1; /* baseline = vertical middle */
fprintf( stderr, ">>>>>> is playing = %d\n", i_playing ); fprintf( stderr, ">>>>>> is playing = %d\n", i_playing );
if( p_btnPause && (i_playing == 1) ) if( p_btnPause && (i_playing == 1) )
{ {
XPutImage( p_display, control, gc, p_btnPause, 0, 0, dst_x, dst_y, XPutImage( p_display, control, gc, p_btnPause, 0, 0, dst_x,
dst_y - (p_btnPause->height >> 1),
p_btnPause->width, p_btnPause->height ); p_btnPause->width, p_btnPause->height );
dst_x += BTN_SPACE + p_btnPause->width;
} }
else if( p_btnPlay ) else if( p_btnPlay )
{ {
XPutImage( p_display, control, gc, p_btnPlay, 0, 0, dst_x, dst_y, XPutImage( p_display, control, gc, p_btnPlay, 0, 0, dst_x,
dst_y - (p_btnPlay->height >> 1),
p_btnPlay->width, p_btnPlay->height ); p_btnPlay->width, p_btnPlay->height );
dst_x += BTN_SPACE + p_btnPlay->width;
} }
dst_x += BTN_SPACE + ( p_btnPlay ? p_btnPlay->width : 0 );
dst_y = 4;
if( p_btnStop ) if( p_btnStop )
XPutImage( p_display, control, gc, p_btnStop, 0, 0, dst_x, dst_y, XPutImage( p_display, control, gc, p_btnStop, 0, 0, dst_x,
dst_y - (p_btnStop->height >> 1),
p_btnStop->width, p_btnStop->height ); p_btnStop->width, p_btnStop->height );
dst_x += BTN_SPACE + ( p_btnStop ? p_btnStop->width : 0 ); dst_x += BTN_SPACE + ( p_btnStop ? p_btnStop->width : 0 );
dst_y = 4;
if( p_btnFullscreen ) if( p_btnFullscreen )
XPutImage( p_display, control, gc, p_btnFullscreen, 0, 0, dst_x, dst_y, XPutImage( p_display, control, gc, p_btnFullscreen, 0, 0, dst_x,
dst_y - (p_btnFullscreen->height >> 1),
p_btnFullscreen->width, p_btnFullscreen->height ); p_btnFullscreen->width, p_btnFullscreen->height );
dst_x += BTN_SPACE + ( p_btnFullscreen ? p_btnFullscreen->width : 0 ); dst_x += BTN_SPACE + ( p_btnFullscreen ? p_btnFullscreen->width : 0 );
dst_y = 4;
if( p_btnUnmute && b_mute ) if( p_btnUnmute && b_mute )
{ {
XPutImage( p_display, control, gc, p_btnUnmute, 0, 0, dst_x, dst_y, XPutImage( p_display, control, gc, p_btnUnmute, 0, 0, dst_x,
dst_y - (p_btnUnmute->height >> 1),
p_btnUnmute->width, p_btnUnmute->height ); p_btnUnmute->width, p_btnUnmute->height );
dst_x += BTN_SPACE + ( p_btnUnmute ? p_btnUnmute->width : 0 ); dst_x += BTN_SPACE + ( p_btnUnmute ? p_btnUnmute->width : 0 );
dst_y = 4;
} }
else if( p_btnMute ) else if( p_btnMute )
{ {
XPutImage( p_display, control, gc, p_btnMute, 0, 0, dst_x, dst_y, XPutImage( p_display, control, gc, p_btnMute, 0, 0, dst_x,
dst_y - (p_btnMute->height >> 1),
p_btnMute->width, p_btnMute->height ); p_btnMute->width, p_btnMute->height );
dst_x += BTN_SPACE + ( p_btnMute ? p_btnMute->width : 0 ); dst_x += BTN_SPACE + ( p_btnMute ? p_btnMute->width : 0 );
dst_y = 4;
} }
if( p_timeline ) if( p_timeline )
XPutImage( p_display, control, gc, p_timeline, 0, 0, dst_x, dst_y, XPutImage( p_display, control, gc, p_timeline, 0, 0, dst_x,
dst_y - (p_timeline->height >> 1),
(window.width-(dst_x+BTN_SPACE)), p_timeline->height ); (window.width-(dst_x+BTN_SPACE)), p_timeline->height );
if( f_position > 0 ) if( f_position > 0 )
i_last_position = (((float)window.width-8.0)/100.0)*f_position; i_last_position = (int)( f_position *
( ((float)(window.width-(dst_x+BTN_SPACE))) / 100.0 ));
if( p_btnTime ) if( p_btnTime )
XPutImage( p_display, control, gc, p_btnTime, XPutImage( p_display, control, gc, p_btnTime,
0, 0, (dst_x+i_last_position), dst_y, 0, 0, (dst_x+i_last_position),
dst_y - (p_btnTime->height >> 1),
p_btnTime->width, p_btnTime->height ); p_btnTime->width, p_btnTime->height );
XFreeGC( p_display, gc ); XFreeGC( p_display, gc );
......
...@@ -490,18 +490,15 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -490,18 +490,15 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
#endif /* XP_WIN */ #endif /* XP_WIN */
#ifdef XP_UNIX #ifdef XP_UNIX
if( p_plugin->b_toolbar ) /* default to hidden toolbar, shown at the end of this method if asked *
{ * developers note : getToolbarSize need to wait the end of this method
p_plugin->getToolbarSize( &i_control_width, &i_control_height ); */
} i_control_height = 0;
else i_control_width = window->width;
{
i_control_height = i_control_width = 0;
}
if( window && window->window ) if( window && window->window )
{ {
Window parent = (Window) window->window; Window parent = (Window) window->window;
if( !curwin.window || (parent != (Window)curwin.window) ) if( !curwin.window || (parent != (Window)curwin.window) )
{ {
Display *p_display = ( (NPSetWindowCallbackStruct *) Display *p_display = ( (NPSetWindowCallbackStruct *)
...@@ -516,13 +513,10 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -516,13 +513,10 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
window->width, window->height - i_control_height, window->width, window->height - i_control_height,
0, i_blackColor, i_blackColor ); 0, i_blackColor, i_blackColor );
Window controls = (Window) NULL; Window controls = (Window) NULL;
if( p_plugin->b_toolbar ) controls = XCreateSimpleWindow( p_display, parent,
{ 0, window->height - i_control_height-1,
controls = XCreateSimpleWindow( p_display, parent, window->width, i_control_height-1,
0, window->height - i_control_height-1, 0, i_blackColor, i_blackColor );
window->width, i_control_height-1,
0, i_blackColor, i_blackColor );
}
XMapWindow( p_display, parent ); XMapWindow( p_display, parent );
XMapWindow( p_display, video ); XMapWindow( p_display, video );
...@@ -561,6 +555,12 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -561,6 +555,12 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
if( controls ) { p_plugin->setControlWindow( controls ); } if( controls ) { p_plugin->setControlWindow( controls ); }
Redraw( w, (XtPointer)p_plugin, NULL ); Redraw( w, (XtPointer)p_plugin, NULL );
/* now display toolbar if asked through parameters */
if( p_plugin->b_toolbar )
{
p_plugin->showToolbar();
}
} }
} }
else if ( curwin.window ) else if ( curwin.window )
...@@ -800,10 +800,7 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event ) ...@@ -800,10 +800,7 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event )
unsigned int i_control_height, i_control_width; unsigned int i_control_height, i_control_width;
if( p_plugin->b_toolbar ) if( p_plugin->b_toolbar )
{
p_plugin->showToolbar();
p_plugin->getToolbarSize( &i_control_width, &i_control_height ); p_plugin->getToolbarSize( &i_control_width, &i_control_height );
}
else else
i_control_height = i_control_width = 0; i_control_height = i_control_width = 0;
...@@ -824,11 +821,7 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event ) ...@@ -824,11 +821,7 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event )
WINDOW_TEXT, strlen(WINDOW_TEXT) ); WINDOW_TEXT, strlen(WINDOW_TEXT) );
XFreeGC( p_display, gc ); XFreeGC( p_display, gc );
if( p_plugin->b_toolbar ) p_plugin->redrawToolbar();
{
p_plugin->redrawToolbar();
p_plugin->hideToolbar();
}
} }
static void ControlHandler( Widget w, XtPointer closure, XEvent *event ) static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
......
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