From: Olivier Teulière Date: Sat, 14 May 2005 14:39:05 +0000 (+0000) Subject: * skins2: New Playlist.bgimage attribute, to specify a background image for X-Git-Tag: 0.8.2~224 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=d59a067be7d24dee1c46d45e761b91f931330e97;p=vlc * skins2: New Playlist.bgimage attribute, to specify a background image for the Playlist control. If no image is specified (default behaviour), the background is filled like before, with the bgcolor1 and bgcolor2 attributes. --- diff --git a/doc/skins/skins2-howto.xml b/doc/skins/skins2-howto.xml index f687d2a6a9..22e94d8a3f 100644 --- a/doc/skins/skins2-howto.xml +++ b/doc/skins/skins2-howto.xml @@ -631,6 +631,11 @@ difficulty to understand how VLC skins work. Type of playlist. Currently, only "playlist" is recognized, so don't bother with this attribute :) Default value: playlist + + bgimage + Identifiant of a Bitmap, used as the background image. When no bitmap is specified, the background will be filled using the bgcolor1 and bgcolor2 attributes. + Default value: none + fgcolor Foreground color of the playlist items. @@ -648,12 +653,12 @@ difficulty to understand how VLC skins work. bgcolor1 - Background color for odd playlist items. + Background color for odd playlist items. This attribute is ignored if the bgimage one is used. Default value: #FFFFFF bgcolor2 - Background color for even playlist items. + Background color for even playlist items. This attribute is ignored if the bgimage one is used. Default value: #FFFFFF diff --git a/modules/gui/skins2/controls/ctrl_list.cpp b/modules/gui/skins2/controls/ctrl_list.cpp index 50fee9217e..6d1779d344 100644 --- a/modules/gui/skins2/controls/ctrl_list.cpp +++ b/modules/gui/skins2/controls/ctrl_list.cpp @@ -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" @@ -42,14 +43,15 @@ #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 diff --git a/modules/gui/skins2/controls/ctrl_list.hpp b/modules/gui/skins2/controls/ctrl_list.hpp index d2b6b59962..9e73be672b 100644 --- a/modules/gui/skins2/controls/ctrl_list.hpp +++ b/modules/gui/skins2/controls/ctrl_list.hpp @@ -31,6 +31,7 @@ class OSGraphics; class GenericFont; +class GenericBitmap; /// Class for control list @@ -38,7 +39,8 @@ class CtrlList: public CtrlGeneric, public Observer, public Observer { 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, /// 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; diff --git a/modules/gui/skins2/parser/builder.cpp b/modules/gui/skins2/parser/builder.cpp index 12b044816a..e90a189b28 100644 --- a/modules/gui/skins2/parser/builder.cpp +++ b/modules/gui/skins2/parser/builder.cpp @@ -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 ); diff --git a/modules/gui/skins2/parser/builder_data.def b/modules/gui/skins2/parser/builder_data.def index 2b1c30f7ce..89f4dc850a 100644 --- a/modules/gui/skins2/parser/builder_data.def +++ b/modules/gui/skins2/parser/builder_data.def @@ -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 diff --git a/modules/gui/skins2/parser/builder_data.hpp b/modules/gui/skins2/parser/builder_data.hpp index 9e9bb74e46..e6d809aacd 100644 --- a/modules/gui/skins2/parser/builder_data.hpp +++ b/modules/gui/skins2/parser/builder_data.hpp @@ -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; diff --git a/modules/gui/skins2/parser/skin_parser.cpp b/modules/gui/skins2/parser/skin_parser.cpp index 987c678183..36b99c2443 100644 --- a/modules/gui/skins2/parser/skin_parser.cpp +++ b/modules/gui/skins2/parser/skin_parser.cpp @@ -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"] ), diff --git a/share/skins2/skin.dtd b/share/skins2/skin.dtd index 251d3cc81b..2bb4839124 100644 --- a/share/skins2/skin.dtd +++ b/share/skins2/skin.dtd @@ -182,6 +182,7 @@ lefttop CDATA "lefttop" rightbottom CDATA "lefttop" font CDATA #REQUIRED + bgimage CDATA "none" fgcolor CDATA "#000000" playcolor CDATA "#FF0000" bgcolor1 CDATA "#FFFFFF"