Changeset 900e1dcdd57e1755b085cca4ab7d0078e261f363

Show
Ignore:
Timestamp:
03/25/08 15:16:28 (4 months ago)
Author:
Jean-Paul Saman <jpsaman@videolan.org>
git-committer:
Jean-Paul Saman <jpsaman@videolan.org> 1206454588 +0100
git-parent:

[03a19fdb07baa26dad95bdcaf2be58fbd9fab5ac]

git-author:
Jean-Paul Saman <jpsaman@videolan.org> 1205759969 +0100
Message:

Refactor toolbar sizing.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • projects/mozilla/vlcplugin.cpp

    r03a19fd r900e1dc  
    4545    b_stream(0), 
    4646    b_autoplay(1), 
    47     b_show_toolbar(1), 
    48 #if XP_UNIX 
    49     i_control_height(45), 
    50 #endif 
     47    b_toolbar(0), 
    5148    psz_target(NULL), 
    5249    libvlc_instance(NULL), 
     
    6158    ,i_width((unsigned)-1) 
    6259    ,i_height((unsigned)-1) 
     60    ,i_tb_width(0) 
     61    ,i_tb_height(0) 
    6362    ,i_last_position(0) 
    6463#endif 
     
    168167            progid = argv[i]; 
    169168        } 
    170         else if( !strcmp( argn[i], "show_toolbar" ) ) 
    171         { 
    172             b_show_toolbar = boolValue(argv[i]); 
     169        else if( !strcmp( argn[i], "toolbar" ) ) 
     170        { 
     171            b_toolbar = boolValue(argv[i]); 
    173172        } 
    174173    } 
     
    460459    Window control = getControlWindow(); 
    461460    Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display; 
     461    unsigned int i_height = 0, i_width = 0; 
    462462 
    463463    /* load icons */ 
     
    465465                        &p_btnPlay, NULL, NULL); 
    466466    if( p_btnPlay ) 
    467         i_control_height = __MAX( i_control_height, p_btnPlay->height ); 
    468  
     467    { 
     468        i_height = __MAX( i_height, p_btnPlay->height ); 
     469        i_width  = __MAX( i_width,  p_btnPlay->width ); 
     470    } 
    469471    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/pause.xpm", 
    470472                        &p_btnPause, NULL, NULL); 
    471473    if( p_btnPause ) 
    472         i_control_height = __MAX( i_control_height, p_btnPause->height ); 
    473  
     474    { 
     475        i_height = __MAX( i_height, p_btnPause->height ); 
     476        i_width  = __MAX( i_width,  p_btnPause->width ); 
     477    } 
    474478    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/stop.xpm", 
    475479                        &p_btnStop, NULL, NULL ); 
    476480    if( p_btnStop ) 
    477         i_control_height = __MAX( i_control_height, p_btnStop->height ); 
    478  
     481    { 
     482        i_height = __MAX( i_height, p_btnStop->height ); 
     483        i_width  = __MAX( i_width,  p_btnStop->width ); 
     484    } 
    479485    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_line.xpm", 
    480486                        &p_timeline, NULL, NULL); 
    481487    if( p_timeline ) 
    482         i_control_height = __MAX( i_control_height, p_timeline->height ); 
    483  
     488    { 
     489        i_height = __MAX( i_height, p_timeline->height ); 
     490        i_width  = __MAX( i_width,  p_timeline->width ); 
     491    } 
    484492    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_icon.xpm", 
    485493                        &p_btnTime, NULL, NULL); 
    486494    if( p_btnTime ) 
    487         i_control_height = __MAX( i_control_height, p_btnTime->height ); 
    488  
     495    { 
     496        i_height = __MAX( i_height, p_btnTime->height ); 
     497        i_width  = __MAX( i_width,  p_btnTime->width ); 
     498    } 
    489499    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/fullscreen.xpm", 
    490500                        &p_btnFullscreen, NULL, NULL); 
    491501    if( p_btnFullscreen ) 
    492         i_control_height = __MAX( i_control_height, p_btnFullscreen->height); 
    493  
     502    { 
     503        i_height = __MAX( i_height, p_btnFullscreen->height ); 
     504        i_width  = __MAX( i_width,  p_btnFullscreen->width ); 
     505    } 
    494506    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_max.xpm", 
    495507                        &p_btnMute, NULL, NULL); 
    496508    if( p_btnMute ) 
    497         i_control_height = __MAX( i_control_height, p_btnMute->height); 
    498  
     509    { 
     510        i_height = __MAX( i_height, p_btnMute->height ); 
     511        i_width  = __MAX( i_width,  p_btnMute->width ); 
     512    } 
    499513    XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_mute.xpm", 
    500514                        &p_btnUnmute, NULL, NULL); 
    501515    if( p_btnUnmute ) 
    502         i_control_height = __MAX( i_control_height, p_btnUnmute->height); 
     516    { 
     517        i_height = __MAX( i_height, p_btnUnmute->height ); 
     518        i_width  = __MAX( i_width,  p_btnUnmute->width ); 
     519    } 
     520    setToolbarSize( i_width, i_height ); 
    503521 
    504522    if( !p_btnPlay || !p_btnPause || !p_btnStop || !p_timeline || 
     
    509527void VlcPlugin::hideToolbar() 
    510528{ 
     529    i_tb_width = i_tb_height = 0; 
     530 
    511531    if( p_btnPlay )  XDestroyImage( p_btnPlay ); 
    512532    if( p_btnPause ) XDestroyImage( p_btnPause ); 
     
    535555    int i_playing = 0; 
    536556    bool b_mute = false; 
    537  
     557    unsigned int dst_x, dst_y; 
    538558    GC gc; 
    539559    XGCValues gcv; 
     560#define BTN_SPACE ((unsigned int)4) 
    540561 
    541562    const NPWindow& window = getWindow(); 
     
    571592 
    572593    XFillRectangle( p_display, control, gc, 
    573                     0, 0, window.width, i_control_height ); 
     594                    0, 0, window.width, i_tb_height ); 
    574595    gcv.foreground = WhitePixel( p_display, 0 ); 
    575596    XChangeGC( p_display, gc, GCForeground, &gcv ); 
    576597 
    577598    /* position icons */ 
     599    dst_x = 4; dst_y = 4; 
     600 
    578601    fprintf( stderr, ">>>>>> is playing = %d\n", i_playing ); 
    579602    if( p_btnPause && (i_playing == 1) ) 
    580603    { 
    581         XPutImage( p_display, control, gc, p_btnPause, 0, 0, 4, 14
     604        XPutImage( p_display, control, gc, p_btnPause, 0, 0, dst_x, dst_y
    582605                   p_btnPause->width, p_btnPause->height ); 
    583606    } 
    584607    else if( p_btnPlay ) 
    585608    { 
    586         XPutImage( p_display, control, gc, p_btnPlay, 0, 0, 4, 14
     609        XPutImage( p_display, control, gc, p_btnPlay, 0, 0, dst_x, dst_y
    587610                   p_btnPlay->width, p_btnPlay->height ); 
    588611    } 
    589612 
     613    dst_x += BTN_SPACE + ( p_btnPlay ? p_btnPlay->width : 0 ); 
     614    dst_y = 4; 
     615 
    590616    if( p_btnStop ) 
    591         XPutImage( p_display, control, gc, p_btnStop, 0, 0, 39, 14
     617        XPutImage( p_display, control, gc, p_btnStop, 0, 0, dst_x, dst_y
    592618                   p_btnStop->width, p_btnStop->height ); 
     619 
     620    dst_x += BTN_SPACE + ( p_btnStop ? p_btnStop->width : 0 ); 
     621    dst_y = 4; 
     622 
    593623    if( p_btnFullscreen ) 
    594         XPutImage( p_display, control, gc, p_btnFullscreen, 0, 0, 67, 21
     624        XPutImage( p_display, control, gc, p_btnFullscreen, 0, 0, dst_x, dst_y
    595625                   p_btnFullscreen->width, p_btnFullscreen->height ); 
    596626 
     627    dst_x += BTN_SPACE + ( p_btnFullscreen ? p_btnFullscreen->width : 0 ); 
     628    dst_y = 4; 
     629 
    597630    if( p_btnUnmute && b_mute ) 
    598631    { 
    599         XPutImage( p_display, control, gc, p_btnUnmute, 0, 0, 94, 30
     632        XPutImage( p_display, control, gc, p_btnUnmute, 0, 0, dst_x, dst_y
    600633                   p_btnUnmute->width, p_btnUnmute->height ); 
     634 
     635        dst_x += BTN_SPACE + ( p_btnUnmute ? p_btnUnmute->width : 0 ); 
     636        dst_y = 4; 
    601637    } 
    602638    else if( p_btnMute ) 
    603639    { 
    604         XPutImage( p_display, control, gc, p_btnMute, 0, 0, 94, 30
     640        XPutImage( p_display, control, gc, p_btnMute, 0, 0, dst_x, dst_y
    605641                   p_btnMute->width, p_btnMute->height ); 
     642 
     643        dst_x += BTN_SPACE + ( p_btnMute ? p_btnMute->width : 0 ); 
     644        dst_y = 4; 
    606645    } 
    607646 
    608647    if( p_timeline ) 
    609         XPutImage( p_display, control, gc, p_timeline, 0, 0, 4, 4
    610                    (window.width-8), p_timeline->height ); 
     648        XPutImage( p_display, control, gc, p_timeline, 0, 0, dst_x, dst_y
     649                   (window.width-(dst_x+BTN_SPACE)), p_timeline->height ); 
    611650 
    612651    if( f_position > 0 ) 
    613652        i_last_position = (((float)window.width-8.0)/100.0)*f_position; 
     653 
    614654    if( p_btnTime ) 
    615655        XPutImage( p_display, control, gc, p_btnTime, 
    616                    0, 0, (4+i_last_position), 2
     656                   0, 0, (dst_x+i_last_position), dst_y
    617657                   p_btnTime->width, p_btnTime->height ); 
    618658 
  • projects/mozilla/vlcplugin.h

    r03a19fd r900e1dc  
    112112    void                hideToolbar(); 
    113113    void                redrawToolbar(); 
     114    void                getToolbarSize(unsigned int *width, unsigned int *height) 
     115                            { *width = i_tb_width; *height = i_tb_height; }; 
     116    int                 setToolbarSize(unsigned int width, unsigned int height) 
     117                            { i_tb_width = width; i_tb_height = height; return 1; }; 
    114118#endif 
    115119 
     
    119123    int      b_stream; 
    120124    int      b_autoplay; 
    121     int      b_show_toolbar; 
     125    int      b_toolbar; 
    122126    char *   psz_target; 
    123127 
    124 #if XP_UNIX 
    125     /* toolbar */ 
    126     int     i_control_height; 
    127 #endif 
    128128private: 
    129129    /* VLC reference */ 
     
    143143#if XP_UNIX 
    144144    unsigned int     i_width, i_height; 
     145    unsigned int     i_tb_width, i_tb_height; 
    145146    Window           npvideo, npcontrol; 
    146147 
  • projects/mozilla/vlcshell.cpp

    r03a19fd r900e1dc  
    365365NPError NPP_SetWindow( NPP instance, NPWindow* window ) 
    366366{ 
    367     /* height used by bottom toolbar (pixels). 0 if hidden */ 
    368     unsigned int i_toolbar_height
     367    Window control; 
     368    unsigned int i_control_height = 0, i_control_width = 0
    369369 
    370370    if( ! instance ) 
     
    380380        return NPERR_NO_ERROR; 
    381381    } 
     382    control = p_plugin->getControlWindow(); 
    382383 
    383384    libvlc_instance_t *p_vlc = p_plugin->getVLC(); 
    384  
    385  
    386     if( p_plugin->b_show_toolbar ) 
    387     { 
    388         i_toolbar_height = p_plugin->i_control_height; 
    389     } 
    390     else 
    391     { 
    392         i_toolbar_height = 0; 
    393     } 
    394385 
    395386    /* 
     
    497488 
    498489#ifdef XP_UNIX 
     490    if( p_plugin->b_toolbar ) 
     491    { 
     492        p_plugin->getToolbarSize( &i_control_width, &i_control_height ); 
     493    } 
     494    else 
     495    { 
     496        i_control_height = i_control_width = 0; 
     497    } 
     498 
    499499    if( window && window->window ) 
    500500    { 
     
    511511            /* create windows */ 
    512512            Window video = XCreateSimpleWindow( p_display, parent, 0, 0, 
    513                            window->width, window->height - i_toolbar_height, 
     513                           window->width, window->height - i_control_height, 
    514514                           0, i_blackColor, i_blackColor ); 
    515515            Window controls = (Window) NULL; 
    516             if( p_plugin->b_show_toolbar ) 
     516            if( p_plugin->b_toolbar ) 
    517517            { 
    518518                controls = XCreateSimpleWindow( p_display, parent, 
    519                                 0, window->height - i_toolbar_height-1, 
    520                                 window->width, i_toolbar_height-1, 
     519                                0, window->height - i_control_height-1, 
     520                                window->width, i_control_height-1, 
    521521                                0, i_blackColor, i_blackColor ); 
    522522            } 
     
    791791{ 
    792792    VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure); 
     793    Window control = p_plugin->getControlWindow(); 
    793794    const NPWindow& window = p_plugin->getWindow(); 
    794795    GC gc; 
    795796    XGCValues gcv; 
    796     /* height used to show the bottom toolbar in non-fullscreen mode */ 
    797     unsigned int i_toolbar_height; 
    798  
    799     if( p_plugin->b_show_toolbar ) 
     797    unsigned int i_control_height, i_control_width; 
     798 
     799    if( p_plugin->b_toolbar ) 
    800800    { 
    801801        p_plugin->showToolbar(); 
    802         i_toolbar_height = p_plugin->i_control_height
     802        p_plugin->getToolbarSize( &i_control_width, &i_control_height )
    803803    } 
    804804    else 
    805     { 
    806         i_toolbar_height = 0; 
    807     } 
     805        i_control_height = i_control_width = 0; 
    808806 
    809807    Window video = p_plugin->getVideoWindow(); 
     
    814812 
    815813    XFillRectangle( p_display, video, gc, 
    816                     0, 0, window.width, window.height - i_toolbar_height); 
     814                    0, 0, window.width, window.height - i_control_height); 
    817815 
    818816    gcv.foreground = WhitePixel( p_display, 0 ); 
     
    820818 
    821819    XDrawString( p_display, video, gc, 
    822                  window.width / 2 - 40, (window.height - i_toolbar_height) / 2, 
     820                 window.width / 2 - 40, (window.height - i_control_height) / 2, 
    823821                 WINDOW_TEXT, strlen(WINDOW_TEXT) ); 
    824822    XFreeGC( p_display, gc ); 
    825823 
    826     if( p_plugin->b_show_toolbar ) 
     824    if( p_plugin->b_toolbar ) 
    827825    { 
    828826        p_plugin->redrawToolbar(); 
     
    841839    int i_yPos = event->xbutton.y; 
    842840 
    843     if( p_plugin && p_plugin->b_show_toolbar ) 
     841    if( p_plugin && p_plugin->b_toolbar ) 
    844842    { 
    845843        libvlc_exception_t ex; 
     
    925923{ 
    926924    VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(closure); 
     925    Window control = p_plugin->getControlWindow(); 
    927926    const NPWindow& window = p_plugin->getWindow(); 
    928927    Window  drawable   = p_plugin->getVideoWindow(); 
     
    933932    Window base_window; 
    934933    unsigned int i_nchildren; 
    935     /* height used for the bottom control bar, 0 if hidden */ 
    936     unsigned int i_toolbar_height; 
    937  
    938     if( p_plugin->b_show_toolbar ) 
    939     { 
    940         i_toolbar_height = p_plugin->i_control_height; 
     934    unsigned int i_control_height, i_control_width; 
     935 
     936    if( p_plugin->b_toolbar ) 
     937    { 
     938        p_plugin->getToolbarSize( &i_control_width, &i_control_height ); 
    941939    } 
    942940    else 
    943941    { 
    944         i_toolbar_height = 0; 
     942        i_control_height = i_control_width = 0; 
    945943    } 
    946944 
     
    957955#endif /* X11_RESIZE_DEBUG */ 
    958956 
    959     if( ! p_plugin->setSize(window.width, (window.height - i_toolbar_height)) ) 
     957    if( ! p_plugin->setSize(window.width, (window.height - i_control_height)) ) 
    960958    { 
    961959        /* size already set */ 
     
    964962 
    965963    i_ret = XResizeWindow( p_display, drawable, 
    966                            window.width, (window.height - i_toolbar_height) ); 
     964                           window.width, (window.height - i_control_height) ); 
    967965 
    968966#ifdef X11_RESIZE_DEBUG 
     
    996994 
    997995        i_ret = XResizeWindow( p_display, base_window, 
    998                 window.width, ( window.height - i_toolbar_height ) ); 
     996                window.width, ( window.height - i_control_height ) ); 
    999997 
    1000998#ifdef X11_RESIZE_DEBUG