Commit d59a067b authored by Olivier Teulière's avatar Olivier Teulière

* 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.
parent 8f5550f3
......@@ -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>
......
......@@ -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
......
......@@ -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;
......
......@@ -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 );
......
......@@ -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
......@@ -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;
......
......@@ -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"] ),
......
......@@ -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"
......
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