i_npmode(mode),
b_stream(0),
b_autoplay(1),
- b_show_toolbar(1),
-#if XP_UNIX
- i_control_height(45),
-#endif
+ b_toolbar(0),
psz_target(NULL),
libvlc_instance(NULL),
libvlc_log(NULL),
#if XP_UNIX
,i_width((unsigned)-1)
,i_height((unsigned)-1)
+ ,i_tb_width(0)
+ ,i_tb_height(0)
,i_last_position(0)
#endif
{
{
progid = argv[i];
}
- else if( !strcmp( argn[i], "show_toolbar" ) )
+ else if( !strcmp( argn[i], "toolbar" ) )
{
- b_show_toolbar = boolValue(argv[i]);
+ b_toolbar = boolValue(argv[i]);
}
}
const NPWindow& window = getWindow();
Window control = getControlWindow();
Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
+ unsigned int i_height = 0, i_width = 0;
/* load icons */
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/play.xpm",
&p_btnPlay, NULL, NULL);
if( p_btnPlay )
- i_control_height = __MAX( i_control_height, p_btnPlay->height );
-
+ {
+ i_height = __MAX( i_height, p_btnPlay->height );
+ i_width = __MAX( i_width, p_btnPlay->width );
+ }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/pause.xpm",
&p_btnPause, NULL, NULL);
if( p_btnPause )
- i_control_height = __MAX( i_control_height, p_btnPause->height );
-
+ {
+ i_height = __MAX( i_height, p_btnPause->height );
+ i_width = __MAX( i_width, p_btnPause->width );
+ }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/stop.xpm",
&p_btnStop, NULL, NULL );
if( p_btnStop )
- i_control_height = __MAX( i_control_height, p_btnStop->height );
-
+ {
+ i_height = __MAX( i_height, p_btnStop->height );
+ i_width = __MAX( i_width, p_btnStop->width );
+ }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_line.xpm",
&p_timeline, NULL, NULL);
if( p_timeline )
- i_control_height = __MAX( i_control_height, p_timeline->height );
-
+ {
+ i_height = __MAX( i_height, p_timeline->height );
+ i_width = __MAX( i_width, p_timeline->width );
+ }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_icon.xpm",
&p_btnTime, NULL, NULL);
if( p_btnTime )
- i_control_height = __MAX( i_control_height, p_btnTime->height );
-
+ {
+ i_height = __MAX( i_height, p_btnTime->height );
+ i_width = __MAX( i_width, p_btnTime->width );
+ }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/fullscreen.xpm",
&p_btnFullscreen, NULL, NULL);
if( p_btnFullscreen )
- i_control_height = __MAX( i_control_height, p_btnFullscreen->height);
-
+ {
+ i_height = __MAX( i_height, p_btnFullscreen->height );
+ i_width = __MAX( i_width, p_btnFullscreen->width );
+ }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_max.xpm",
&p_btnMute, NULL, NULL);
if( p_btnMute )
- i_control_height = __MAX( i_control_height, p_btnMute->height);
-
+ {
+ i_height = __MAX( i_height, p_btnMute->height );
+ i_width = __MAX( i_width, p_btnMute->width );
+ }
XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_mute.xpm",
&p_btnUnmute, NULL, NULL);
if( p_btnUnmute )
- i_control_height = __MAX( i_control_height, p_btnUnmute->height);
+ {
+ i_height = __MAX( i_height, p_btnUnmute->height );
+ i_width = __MAX( i_width, p_btnUnmute->width );
+ }
+ setToolbarSize( i_width, i_height );
if( !p_btnPlay || !p_btnPause || !p_btnStop || !p_timeline ||
!p_btnTime || !p_btnFullscreen || !p_btnMute || !p_btnUnmute )
void VlcPlugin::hideToolbar()
{
+ i_tb_width = i_tb_height = 0;
+
if( p_btnPlay ) XDestroyImage( p_btnPlay );
if( p_btnPause ) XDestroyImage( p_btnPause );
if( p_btnStop ) XDestroyImage( p_btnStop );
float f_position = 0.0;
int i_playing = 0;
bool b_mute = false;
-
+ unsigned int dst_x, dst_y;
GC gc;
XGCValues gcv;
+#define BTN_SPACE ((unsigned int)4)
const NPWindow& window = getWindow();
Window control = getControlWindow();
gc = XCreateGC( p_display, control, GCForeground, &gcv );
XFillRectangle( p_display, control, gc,
- 0, 0, window.width, i_control_height );
+ 0, 0, window.width, i_tb_height );
gcv.foreground = WhitePixel( p_display, 0 );
XChangeGC( p_display, gc, GCForeground, &gcv );
/* position icons */
+ dst_x = 4; dst_y = 4;
+
fprintf( stderr, ">>>>>> is playing = %d\n", i_playing );
if( p_btnPause && (i_playing == 1) )
{
- XPutImage( p_display, control, gc, p_btnPause, 0, 0, 4, 14,
+ XPutImage( p_display, control, gc, p_btnPause, 0, 0, dst_x, dst_y,
p_btnPause->width, p_btnPause->height );
}
else if( p_btnPlay )
{
- XPutImage( p_display, control, gc, p_btnPlay, 0, 0, 4, 14,
+ XPutImage( p_display, control, gc, p_btnPlay, 0, 0, dst_x, dst_y,
p_btnPlay->width, p_btnPlay->height );
}
+ 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, 39, 14,
+ XPutImage( p_display, control, gc, p_btnStop, 0, 0, dst_x, dst_y,
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, 67, 21,
+ XPutImage( p_display, control, gc, p_btnFullscreen, 0, 0, dst_x, dst_y,
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, 94, 30,
+ XPutImage( p_display, control, gc, p_btnUnmute, 0, 0, dst_x, dst_y,
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, 94, 30,
+ XPutImage( p_display, control, gc, p_btnMute, 0, 0, dst_x, dst_y,
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, 4, 4,
- (window.width-8), p_timeline->height );
+ XPutImage( p_display, control, gc, p_timeline, 0, 0, dst_x, dst_y,
+ (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;
+
if( p_btnTime )
XPutImage( p_display, control, gc, p_btnTime,
- 0, 0, (4+i_last_position), 2,
+ 0, 0, (dst_x+i_last_position), dst_y,
p_btnTime->width, p_btnTime->height );
XFreeGC( p_display, gc );
NPError NPP_SetWindow( NPP instance, NPWindow* window )
{
- /* height used by bottom toolbar (pixels). 0 if hidden */
- unsigned int i_toolbar_height;
+ Window control;
+ unsigned int i_control_height = 0, i_control_width = 0;
if( ! instance )
{
/* we should probably show a splash screen here */
return NPERR_NO_ERROR;
}
+ control = p_plugin->getControlWindow();
libvlc_instance_t *p_vlc = p_plugin->getVLC();
-
- if( p_plugin->b_show_toolbar )
- {
- i_toolbar_height = p_plugin->i_control_height;
- }
- else
- {
- i_toolbar_height = 0;
- }
-
/*
* PLUGIN DEVELOPERS:
* Before setting window to point to the
#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;
+ }
+
if( window && window->window )
{
Window parent = (Window) window->window;
/* create windows */
Window video = XCreateSimpleWindow( p_display, parent, 0, 0,
- window->width, window->height - i_toolbar_height,
+ window->width, window->height - i_control_height,
0, i_blackColor, i_blackColor );
Window controls = (Window) NULL;
- if( p_plugin->b_show_toolbar )
+ if( p_plugin->b_toolbar )
{
controls = XCreateSimpleWindow( p_display, parent,
- 0, window->height - i_toolbar_height-1,
- window->width, i_toolbar_height-1,
+ 0, window->height - i_control_height-1,
+ window->width, i_control_height-1,
0, i_blackColor, i_blackColor );
}
static void Redraw( Widget w, XtPointer closure, XEvent *event )
{
VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
+ Window control = p_plugin->getControlWindow();
const NPWindow& window = p_plugin->getWindow();
GC gc;
XGCValues gcv;
- /* height used to show the bottom toolbar in non-fullscreen mode */
- unsigned int i_toolbar_height;
+ unsigned int i_control_height, i_control_width;
- if( p_plugin->b_show_toolbar )
+ if( p_plugin->b_toolbar )
{
p_plugin->showToolbar();
- i_toolbar_height = p_plugin->i_control_height;
+ p_plugin->getToolbarSize( &i_control_width, &i_control_height );
}
else
- {
- i_toolbar_height = 0;
- }
+ i_control_height = i_control_width = 0;
Window video = p_plugin->getVideoWindow();
Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
gc = XCreateGC( p_display, video, GCForeground, &gcv );
XFillRectangle( p_display, video, gc,
- 0, 0, window.width, window.height - i_toolbar_height);
+ 0, 0, window.width, window.height - i_control_height);
gcv.foreground = WhitePixel( p_display, 0 );
XChangeGC( p_display, gc, GCForeground, &gcv );
XDrawString( p_display, video, gc,
- window.width / 2 - 40, (window.height - i_toolbar_height) / 2,
+ window.width / 2 - 40, (window.height - i_control_height) / 2,
WINDOW_TEXT, strlen(WINDOW_TEXT) );
XFreeGC( p_display, gc );
- if( p_plugin->b_show_toolbar )
+ if( p_plugin->b_toolbar )
{
p_plugin->redrawToolbar();
p_plugin->hideToolbar();
int i_xPos = event->xbutton.x;
int i_yPos = event->xbutton.y;
- if( p_plugin && p_plugin->b_show_toolbar )
+ if( p_plugin && p_plugin->b_toolbar )
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
static void Resize ( Widget w, XtPointer closure, XEvent *event )
{
VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure);
+ Window control = p_plugin->getControlWindow();
const NPWindow& window = p_plugin->getWindow();
Window drawable = p_plugin->getVideoWindow();
Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display;
Window root_return, parent_return, * children_return;
Window base_window;
unsigned int i_nchildren;
- /* height used for the bottom control bar, 0 if hidden */
- unsigned int i_toolbar_height;
+ unsigned int i_control_height, i_control_width;
- if( p_plugin->b_show_toolbar )
+ if( p_plugin->b_toolbar )
{
- i_toolbar_height = p_plugin->i_control_height;
+ p_plugin->getToolbarSize( &i_control_width, &i_control_height );
}
else
{
- i_toolbar_height = 0;
+ i_control_height = i_control_width = 0;
}
#ifdef X11_RESIZE_DEBUG
}
#endif /* X11_RESIZE_DEBUG */
- if( ! p_plugin->setSize(window.width, (window.height - i_toolbar_height)) )
+ if( ! p_plugin->setSize(window.width, (window.height - i_control_height)) )
{
/* size already set */
return;
}
i_ret = XResizeWindow( p_display, drawable,
- window.width, (window.height - i_toolbar_height) );
+ window.width, (window.height - i_control_height) );
#ifdef X11_RESIZE_DEBUG
fprintf( stderr,
#endif /* X11_RESIZE_DEBUG */
i_ret = XResizeWindow( p_display, base_window,
- window.width, ( window.height - i_toolbar_height ) );
+ window.width, ( window.height - i_control_height ) );
#ifdef X11_RESIZE_DEBUG
fprintf( stderr,