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 ) :
,i_tb_width(0)
,i_tb_height(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
{
memset(&npwindow, 0, sizeof(NPWindow));
......@@ -157,7 +165,8 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
{
ppsz_argv[ppsz_argc++] = "--loop";
}
else {
else
{
ppsz_argv[ppsz_argc++] = "--no-loop";
}
}
......@@ -418,10 +427,12 @@ void VlcPlugin::showToolbar()
{
const NPWindow& window = getWindow();
Window control = getControlWindow();
Window video = getVideoWindow();
Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
unsigned int i_height = 0, i_width = 0;
/* load icons */
if( !p_btnPlay )
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/play.xpm",
&p_btnPlay, NULL, NULL);
if( p_btnPlay )
......@@ -429,6 +440,7 @@ void VlcPlugin::showToolbar()
i_height = __MAX( i_height, p_btnPlay->height );
i_width += p_btnPlay->width;
}
if( !p_btnPause )
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/pause.xpm",
&p_btnPause, NULL, NULL);
if( p_btnPause )
......@@ -436,6 +448,7 @@ void VlcPlugin::showToolbar()
i_height = __MAX( i_height, p_btnPause->height );
i_width += p_btnPause->width;
}
if( !p_btnStop )
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/stop.xpm",
&p_btnStop, NULL, NULL );
if( p_btnStop )
......@@ -443,6 +456,7 @@ void VlcPlugin::showToolbar()
i_height = __MAX( i_height, p_btnStop->height );
i_width += p_btnStop->width;
}
if( !p_timeline )
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_line.xpm",
&p_timeline, NULL, NULL);
if( p_timeline )
......@@ -450,6 +464,7 @@ void VlcPlugin::showToolbar()
i_height = __MAX( i_height, p_timeline->height );
i_width += p_timeline->width;
}
if( !p_btnTime )
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_icon.xpm",
&p_btnTime, NULL, NULL);
if( p_btnTime )
......@@ -457,6 +472,7 @@ void VlcPlugin::showToolbar()
i_height = __MAX( i_height, p_btnTime->height );
i_width += p_btnTime->width;
}
if( !p_btnFullscreen )
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/fullscreen.xpm",
&p_btnFullscreen, NULL, NULL);
if( p_btnFullscreen )
......@@ -464,6 +480,7 @@ void VlcPlugin::showToolbar()
i_height = __MAX( i_height, p_btnFullscreen->height );
i_width += p_btnFullscreen->width;
}
if( !p_btnMute )
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_max.xpm",
&p_btnMute, NULL, NULL);
if( p_btnMute )
......@@ -471,6 +488,7 @@ void VlcPlugin::showToolbar()
i_height = __MAX( i_height, p_btnMute->height );
i_width += p_btnMute->width;
}
if( !p_btnUnmute )
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_mute.xpm",
&p_btnUnmute, NULL, NULL);
if( p_btnUnmute )
......@@ -483,10 +501,24 @@ void VlcPlugin::showToolbar()
if( !p_btnPlay || !p_btnPause || !p_btnStop || !p_timeline ||
!p_btnTime || !p_btnFullscreen || !p_btnMute || !p_btnUnmute )
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()
{
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;
if( p_btnPlay ) XDestroyImage( p_btnPlay );
......@@ -506,6 +538,15 @@ void VlcPlugin::hideToolbar()
p_btnFullscreen = NULL;
p_btnMute = 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()
......@@ -518,12 +559,19 @@ void VlcPlugin::redrawToolbar()
unsigned int dst_x, dst_y;
GC gc;
XGCValues gcv;
unsigned int i_tb_width, i_tb_height;
#define BTN_SPACE ((unsigned int)4)
/* This method does nothing if toolbar is hidden. */
if( !b_toolbar )
return;
const NPWindow& window = getWindow();
Window control = getControlWindow();
Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
getToolbarSize( &i_tb_width, &i_tb_height );
/* get media instance */
libvlc_exception_init( &ex );
p_md = libvlc_playlist_get_media_player( getVLC(), &ex );
......@@ -557,64 +605,69 @@ void VlcPlugin::redrawToolbar()
XChangeGC( p_display, gc, GCForeground, &gcv );
/* 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 );
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 );
dst_x += BTN_SPACE + p_btnPause->width;
}
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 );
dst_x += BTN_SPACE + p_btnPlay->width;
}
dst_x += BTN_SPACE + ( p_btnPlay ? p_btnPlay->width : 0 );
dst_y = 4;
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 );
dst_x += BTN_SPACE + ( p_btnStop ? p_btnStop->width : 0 );
dst_y = 4;
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 );
dst_x += BTN_SPACE + ( p_btnFullscreen ? p_btnFullscreen->width : 0 );
dst_y = 4;
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 );
dst_x += BTN_SPACE + ( p_btnUnmute ? p_btnUnmute->width : 0 );
dst_y = 4;
}
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 );
dst_x += BTN_SPACE + ( p_btnMute ? p_btnMute->width : 0 );
dst_y = 4;
}
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 );
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 )
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 );
XFreeGC( p_display, gc );
......
......@@ -490,14 +490,11 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
#endif /* XP_WIN */
#ifdef XP_UNIX
if( p_plugin->b_toolbar )
{
p_plugin->getToolbarSize( &i_control_width, &i_control_height );
}
else
{
i_control_height = i_control_width = 0;
}
/* default to hidden toolbar, shown at the end of this method if asked *
* developers note : getToolbarSize need to wait the end of this method
*/
i_control_height = 0;
i_control_width = window->width;
if( window && window->window )
{
......@@ -516,13 +513,10 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
window->width, window->height - i_control_height,
0, i_blackColor, i_blackColor );
Window controls = (Window) NULL;
if( p_plugin->b_toolbar )
{
controls = XCreateSimpleWindow( p_display, parent,
0, window->height - i_control_height-1,
window->width, i_control_height-1,
0, i_blackColor, i_blackColor );
}
XMapWindow( p_display, parent );
XMapWindow( p_display, video );
......@@ -561,6 +555,12 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
if( controls ) { p_plugin->setControlWindow( controls ); }
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 )
......@@ -800,10 +800,7 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event )
unsigned int i_control_height, i_control_width;
if( p_plugin->b_toolbar )
{
p_plugin->showToolbar();
p_plugin->getToolbarSize( &i_control_width, &i_control_height );
}
else
i_control_height = i_control_width = 0;
......@@ -824,11 +821,7 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event )
WINDOW_TEXT, strlen(WINDOW_TEXT) );
XFreeGC( p_display, gc );
if( p_plugin->b_toolbar )
{
p_plugin->redrawToolbar();
p_plugin->hideToolbar();
}
}
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