]> git.sesse.net Git - vlc/commitdiff
* skins2: New Playlist.bgimage attribute, to specify a background image for
authorOlivier Teulière <ipkiss@videolan.org>
Sat, 14 May 2005 14:39:05 +0000 (14:39 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Sat, 14 May 2005 14:39:05 +0000 (14:39 +0000)
   the Playlist control. If no image is specified (default behaviour), the
   background is filled like before, with the bgcolor1 and bgcolor2 attributes.

doc/skins/skins2-howto.xml
modules/gui/skins2/controls/ctrl_list.cpp
modules/gui/skins2/controls/ctrl_list.hpp
modules/gui/skins2/parser/builder.cpp
modules/gui/skins2/parser/builder_data.def
modules/gui/skins2/parser/builder_data.hpp
modules/gui/skins2/parser/skin_parser.cpp
share/skins2/skin.dtd

index f687d2a6a944b4baa36dd19d598b58cc67daa45a..22e94d8a3f4b5abff9f23110740b696507b22728 100644 (file)
@@ -631,6 +631,11 @@ difficulty to understand how VLC skins work.</para>
       <para>Type of playlist. Currently, only "playlist" is recognized, so don't bother with this attribute :)</para>
       <para>Default value: playlist</para>
     </sect4>
+    <sect4 id="bgimage">
+      <title>bgimage</title>
+      <para>Identifiant of a <link linkend="Bitmap">Bitmap</link>, used as the background image. When no bitmap is specified, the background will be filled using the <link linkend="bgcolor1">bgcolor1</link> and <link linkend="bgcolor2">bgcolor2</link> attributes.</para>
+      <para>Default value: none</para>
+    </sect4>
     <sect4 id="fgcolor">
       <title>fgcolor</title>
       <para>Foreground color of the playlist items.</para>
@@ -648,12 +653,12 @@ difficulty to understand how VLC skins work.</para>
     </sect4>
     <sect4 id="bgcolor1">
       <title>bgcolor1</title>
-      <para>Background color for odd playlist items.</para>
+      <para>Background color for odd playlist items. This attribute is ignored if the <link linkend="bgimage">bgimage</link> one is used.</para>
       <para>Default value: #FFFFFF</para>
     </sect4>
     <sect4 id="bgcolor2">
       <title>bgcolor2</title>
-      <para>Background color for even playlist items.</para>
+      <para>Background color for even playlist items. This attribute is ignored if the <link linkend="bgimage">bgimage</link> one is used.</para>
       <para>Default value: #FFFFFF</para>
     </sect4>
 </sect3>
index 50fee9217ee8f94a71241cb25382074fc52dbf87..6d1779d3440803a6bdc391ed5a9e67168f6aa056 100644 (file)
@@ -28,6 +28,7 @@
 #include "../src/os_graphics.hpp"
 #include "../src/generic_bitmap.hpp"
 #include "../src/generic_font.hpp"
+#include "../src/scaled_bitmap.hpp"
 #include "../utils/position.hpp"
 #include "../utils/ustring.hpp"
 #include "../events/evt_key.hpp"
 #define LINE_INTERVAL 1  // Number of pixels inserted between 2 lines
 
 
-CtrlList::CtrlList( intf_thread_t *pIntf, VarList &rList, GenericFont &rFont,
+CtrlList::CtrlList( intf_thread_t *pIntf, VarList &rList,
+                    const GenericFont &rFont, const GenericBitmap *pBitmap,
                     uint32_t fgColor, uint32_t playColor, uint32_t bgColor1,
                     uint32_t bgColor2, uint32_t selColor,
                     const UString &rHelp, VarBool *pVisible ):
     CtrlGeneric( pIntf, rHelp, pVisible ), m_rList( rList ), m_rFont( rFont ),
-    m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ),
-    m_bgColor2( bgColor2 ), m_selColor( selColor ), m_pLastSelected( NULL ),
-    m_pImage( NULL ), m_lastPos( 0 )
+    m_pBitmap( pBitmap ), m_fgColor( fgColor ), m_playColor( playColor ),
+    m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ),
+    m_pLastSelected( NULL ), m_pImage( NULL ), m_lastPos( 0 )
 {
     // Observe the list and position variables
     m_rList.addObserver( this );
@@ -427,26 +429,52 @@ void CtrlList::makeImage()
     OSFactory *pOsFactory = OSFactory::instance( getIntf() );
     m_pImage = pOsFactory->createOSGraphics( width, height );
 
-    // Current background color
-    uint32_t bgColor = m_bgColor1;
+    VarList::ConstIterator it = m_rList[m_lastPos];
 
     // Draw the background
-    VarList::ConstIterator it = m_rList[m_lastPos];
-    for( int yPos = 0; yPos < height; yPos += itemHeight )
+    if( m_pBitmap )
     {
-        int rectHeight = __MIN( itemHeight, height - yPos );
-        if( it != m_rList.end() )
+        // A background bitmap is given, so we scale it, ignoring the
+        // background colors
+        ScaledBitmap bmp( getIntf(), *m_pBitmap, width, height );
+        m_pImage->drawBitmap( bmp, 0, 0 );
+
+        // Take care of the selection color
+        for( int yPos = 0; yPos < height; yPos += itemHeight )
         {
-            uint32_t color = ( (*it).m_selected ? m_selColor : bgColor );
-            m_pImage->fillRect( 0, yPos, width, rectHeight, color );
-            it++;
+            int rectHeight = __MIN( itemHeight, height - yPos );
+            if( it != m_rList.end() )
+            {
+                if( (*it).m_selected )
+                {
+                    m_pImage->fillRect( 0, yPos, width, rectHeight,
+                                        m_selColor );
+                }
+                it++;
+            }
         }
-        else
+    }
+    else
+    {
+        // No background bitmap, so use the 2 background colors
+        // Current background color
+        uint32_t bgColor = m_bgColor1;
+        for( int yPos = 0; yPos < height; yPos += itemHeight )
         {
-            m_pImage->fillRect( 0, yPos, width, rectHeight, bgColor );
+            int rectHeight = __MIN( itemHeight, height - yPos );
+            if( it != m_rList.end() )
+            {
+                uint32_t color = ( (*it).m_selected ? m_selColor : bgColor );
+                m_pImage->fillRect( 0, yPos, width, rectHeight, color );
+                it++;
+            }
+            else
+            {
+                m_pImage->fillRect( 0, yPos, width, rectHeight, bgColor );
+            }
+            // Flip the background color
+            bgColor = ( bgColor == m_bgColor1 ? m_bgColor2 : m_bgColor1 );
         }
-        // Flip the background color
-        bgColor = ( bgColor == m_bgColor1 ? m_bgColor2 : m_bgColor1 );
     }
 
     // Draw the items
index d2b6b5996252ca09d98874ed089343a291313f53..9e73be672bf72468267c02c1b217ce2746f88a07 100644 (file)
@@ -31,6 +31,7 @@
 
 class OSGraphics;
 class GenericFont;
+class GenericBitmap;
 
 
 /// Class for control list
@@ -38,7 +39,8 @@ class CtrlList: public CtrlGeneric, public Observer<VarList>,
     public Observer<VarPercent>
 {
     public:
-        CtrlList( intf_thread_t *pIntf, VarList &rList, GenericFont &rFont,
+        CtrlList( intf_thread_t *pIntf, VarList &rList,
+                  const GenericFont &rFont, const GenericBitmap *pBitmap,
                   uint32_t fgcolor, uint32_t playcolor, uint32_t bgcolor1,
                   uint32_t bgcolor2, uint32_t selColor,
                   const UString &rHelp, VarBool *pVisible );
@@ -66,12 +68,15 @@ class CtrlList: public CtrlGeneric, public Observer<VarList>,
         /// List associated to the control
         VarList &m_rList;
         /// Font
-        GenericFont &m_rFont;
+        const GenericFont &m_rFont;
+        /// Background bitmap
+        /** If NULL, the 2 background colors defined below will be used */
+        const GenericBitmap *m_pBitmap;
         /// Color of normal text
         uint32_t m_fgColor;
         /// Color of the playing item
         uint32_t m_playColor;
-        /// Background colors
+        /// Background colors, used when no background bitmap is given
         uint32_t m_bgColor1, m_bgColor2;
         /// Background of selected items
         uint32_t m_selColor;
index 12b044816a77bd0220cb6ca6a85239d86f151d78..e90a189b2829406404ebede6612b760d00a65355 100644 (file)
@@ -580,6 +580,10 @@ void Builder::addSlider( const BuilderData::Slider &rData )
 
 void Builder::addList( const BuilderData::List &rData )
 {
+    // Get the background bitmap, if any
+    GenericBitmap *pBgBmp = NULL;
+    GET_BMP( pBgBmp, rData.m_bgImageId );
+
     GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
     if( pLayout == NULL )
     {
@@ -608,7 +612,7 @@ void Builder::addList( const BuilderData::List &rData )
     VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
 
     // Create the list control
-    CtrlList *pList = new CtrlList( getIntf(), *pVar, *pFont,
+    CtrlList *pList = new CtrlList( getIntf(), *pVar, *pFont, pBgBmp,
        rData.m_fgColor, rData.m_playColor, rData.m_bgColor1,
        rData.m_bgColor2, rData.m_selColor,
        UString( getIntf(), rData.m_help.c_str() ), pVisible );
index 2b1c30f7ce5d3a48504a417e163d19271d0c72e5..89f4dc850a45703407624cdfac3d8f3fb0a1c018 100644 (file)
@@ -11,5 +11,5 @@ Image id:string xPos:int yPos:int leftTop:string rightBottom:string visible:stri
 Text id:string xPos:int yPos:int visible:string fontId:string text:string width:int leftTop:string rightBottom:string color:uint32_t help:string layer:int windowId:string layoutId:string
 RadialSlider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string sequence:string nbImages:int minAngle:float maxAngle:float value:string tooltip:string help:string layer:int windowId:string layoutId:string
 Slider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string upId:string downId:string overId:string points:string thickness:int value:string tooltip:string help:string layer:int windowId:string layoutId:string
-List id:string xPos:int yPos:int visible:string width:int height:int leftTop:string rightBottom:string fontId:string var:string fgColor:uint32_t playColor:uint32_t bgColor1:uint32_t bgColor2:uint32_t selColor:uint32_t help:string layer:int windowId:string layoutId:string
+List id:string xPos:int yPos:int visible:string width:int height:int leftTop:string rightBottom:string fontId:string var:string bgImageId:string fgColor:uint32_t playColor:uint32_t bgColor1:uint32_t bgColor2:uint32_t selColor:uint32_t help:string layer:int windowId:string layoutId:string
 Video id:string xPos:int yPos:int width:int height:int leftTop:string rightBottom:string visible:string help:string layer:int windowId:string layoutId:string
index 9e9bb74e462b6367fc07efa633bbb3116478c517..e6d809aacd37945398b6cb572e2648ed85dc3f0d 100644 (file)
@@ -301,8 +301,8 @@ m_id( id ), m_visible( visible ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( lef
     /// Type definition
     struct List
     {
-        List( const string & id, int xPos, int yPos, const string & visible, int width, int height, const string & leftTop, const string & rightBottom, const string & fontId, const string & var, uint32_t fgColor, uint32_t playColor, uint32_t bgColor1, uint32_t bgColor2, uint32_t selColor, const string & help, int layer, const string & windowId, const string & layoutId ):
-m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_fontId( fontId ), m_var( var ), m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {}
+        List( const string & id, int xPos, int yPos, const string & visible, int width, int height, const string & leftTop, const string & rightBottom, const string & fontId, const string & var, const string & bgImageId, uint32_t fgColor, uint32_t playColor, uint32_t bgColor1, uint32_t bgColor2, uint32_t selColor, const string & help, int layer, const string & windowId, const string & layoutId ):
+m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_fontId( fontId ), m_var( var ), m_bgImageId( bgImageId ), m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {}
 
         const string m_id;
         int m_xPos;
@@ -314,6 +314,7 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_width( width
         const string m_rightBottom;
         const string m_fontId;
         const string m_var;
+        const string m_bgImageId;
         uint32_t m_fgColor;
         uint32_t m_playColor;
         uint32_t m_bgColor1;
index 987c678183836b562013f154a08014bd09955f9c..36b99c2443c66799c4e929fec117ff707f058721 100644 (file)
@@ -215,6 +215,7 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
         CheckDefault( "height", "0" );
         CheckDefault( "lefttop", "lefttop" );
         CheckDefault( "rightbottom", "lefttop" );
+        CheckDefault( "bgimage", "none" );
         CheckDefault( "fgcolor", "#000000" );
         CheckDefault( "playcolor", "#FF0000" );
         CheckDefault( "bgcolor1", "#FFFFFF" );
@@ -227,7 +228,8 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
                 m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["visible"],
                 atoi( attr["width"]), atoi( attr["height"] ),
                 attr["lefttop"], attr["rightbottom"],
-                attr["font"], "playlist", convertColor( attr["fgcolor"] ),
+                attr["font"], "playlist", attr["bgimage"],
+                convertColor( attr["fgcolor"] ),
                 convertColor( attr["playcolor"] ),
                 convertColor( attr["bgcolor1"] ),
                 convertColor( attr["bgcolor2"] ),
index 251d3cc81b40fe388716004ff11577dcc086d3b5..2bb48391244565c6a6350864cd3da6c1755860c8 100644 (file)
         lefttop     CDATA   "lefttop"
         rightbottom CDATA   "lefttop"
         font        CDATA   #REQUIRED
+        bgimage     CDATA   "none"
         fgcolor     CDATA   "#000000"
         playcolor   CDATA   "#FF0000"
         bgcolor1    CDATA   "#FFFFFF"