font for xmms/winamp2 skins is supported (the bitmap must have the
following layout: [
0123456789 -] with letters of size 9x13).
Non-digit characters are just skipped, with a hardcoded advance of 6
(it allows correct display of time in xmms skins; the ':' are skipped)
Small example at http://people.via.ecp.fr/~asmax/chaos.vlt (uncomplete skin)
* vars/time.cpp: notify the observers also when the input is stopped
* controls/ctrl_text.cpp: do not reset the FSM state and timer when the
text is displayed (was causing bugs in time display)
12 files changed:
void CtrlText::displayText( const UString &rText )
{
void CtrlText::displayText( const UString &rText )
{
// Create the images ('normal' and 'double') from the text
// 'Normal' image
if( m_pImg )
// Create the images ('normal' and 'double') from the text
// 'Normal' image
if( m_pImg )
// Update the current image used, as if the control size had changed
onChangePosition();
// Update the current image used, as if the control size had changed
onChangePosition();
- // XXX: will this always work?
- m_fsm.setState( "outStill" );
// Start the automatic movement, but only if the text is wider than the
// control
// Start the automatic movement, but only if the text is wider than the
// control
pThis->m_pImg->getWidth() >= pThis->getPosition()->getWidth() )
{
// The current image may have been set incorrectly in displayText(), so
pThis->m_pImg->getWidth() >= pThis->getPosition()->getWidth() )
{
// The current image may have been set incorrectly in displayText(), so
#include "../src/generic_bitmap.hpp"
#include "../src/top_window.hpp"
#include "../src/anchor.hpp"
#include "../src/generic_bitmap.hpp"
#include "../src/top_window.hpp"
#include "../src/anchor.hpp"
+#include "../src/bitmap_font.hpp"
#include "../src/ft2_font.hpp"
#include "../src/theme.hpp"
#include "../controls/ctrl_button.hpp"
#include "../src/ft2_font.hpp"
#include "../src/theme.hpp"
#include "../controls/ctrl_button.hpp"
// Create everything from the data in the XML
ADD_OBJECTS( Theme );
ADD_OBJECTS( Bitmap );
// Create everything from the data in the XML
ADD_OBJECTS( Theme );
ADD_OBJECTS( Bitmap );
+ ADD_OBJECTS( BitmapFont );
ADD_OBJECTS( Font );
ADD_OBJECTS( Window );
ADD_OBJECTS( Layout );
ADD_OBJECTS( Font );
ADD_OBJECTS( Window );
ADD_OBJECTS( Layout );
+void Builder::addBitmapFont( const BuilderData::BitmapFont &rData )
+{
+ GenericBitmap *pBmp = new PngBitmap( getIntf(), rData.m_file, 0 );
+ m_pTheme->m_bitmaps[rData.m_id] = GenericBitmapPtr( pBmp );
+
+ GenericFont *pFont = new BitmapFont( getIntf(), *pBmp );
+ if( pFont->init() )
+ {
+ m_pTheme->m_fonts[rData.m_id] = GenericFontPtr( pFont );
+ }
+ else
+ {
+ delete pFont;
+ }
+}
+
+
void Builder::addFont( const BuilderData::Font &rData )
{
GenericFont *pFont = new FT2Font( getIntf(), rData.m_fontFile,
void Builder::addFont( const BuilderData::Font &rData )
{
GenericFont *pFont = new FT2Font( getIntf(), rData.m_fontFile,
void addTheme( const BuilderData::Theme &rData );
void addBitmap( const BuilderData::Bitmap &rData );
void addTheme( const BuilderData::Theme &rData );
void addBitmap( const BuilderData::Bitmap &rData );
+ void addBitmapFont( const BuilderData::BitmapFont &rData );
void addFont( const BuilderData::Font &rData );
void addWindow( const BuilderData::Window &rData );
void addLayout( const BuilderData::Layout &rData );
void addFont( const BuilderData::Font &rData );
void addWindow( const BuilderData::Window &rData );
void addLayout( const BuilderData::Layout &rData );
Theme tooltipfont:string magnet:int alpha:uint32_t moveAlpha:uint32_t fadeTime:uint32_t
Bitmap id:string fileName:string alphaColor:uint32_t
Theme tooltipfont:string magnet:int alpha:uint32_t moveAlpha:uint32_t fadeTime:uint32_t
Bitmap id:string fileName:string alphaColor:uint32_t
+BitmapFont id:string file:string type:string
Font id:string fontFile:string size:int
Window id:string xPos:int yPos:int visible:bool dragDrop:bool playOnDrop:bool
Layout id:string width:int height:int minWidth:int maxWidth:int minHeight:int maxHeight:int windowId:string
Font id:string fontFile:string size:int
Window id:string xPos:int yPos:int visible:bool dragDrop:bool playOnDrop:bool
Layout id:string width:int height:int minWidth:int maxWidth:int minHeight:int maxHeight:int windowId:string
/// List
list<Bitmap> m_listBitmap;
/// List
list<Bitmap> m_listBitmap;
+ /// Type definition
+ struct BitmapFont
+ {
+ BitmapFont( const string & id, const string & file, const string & type ):
+m_id( id ), m_file( file ), m_type( type ) {}
+
+ const string m_id;
+ const string m_file;
+ const string m_type;
+ };
+ /// List
+ list<BitmapFont> m_listBitmapFont;
+
/// Type definition
struct Font
{
/// Type definition
struct Font
{
m_data.m_listBitmap.push_back( bitmap );
}
m_data.m_listBitmap.push_back( bitmap );
}
+ else if( rName == "BitmapFont" )
+ {
+ const BuilderData::BitmapFont font( attr["id"] , attr["file"],
+ attr["type"] );
+ m_data.m_listBitmapFont.push_back( font );
+ }
+
else if( rName == "Button" )
{
const BuilderData::Button button( uniqueId( attr["id"] ), atoi( attr["x"] ) +
else if( rName == "Button" )
{
const BuilderData::Button button( uniqueId( attr["id"] ), atoi( attr["x"] ) +
#include "bitmap_font.hpp"
#include "generic_bitmap.hpp"
#include "bitmap_font.hpp"
#include "generic_bitmap.hpp"
+#include "../utils/ustring.hpp"
BitmapFont::BitmapFont( intf_thread_t *pIntf, const GenericBitmap &rBitmap ):
GenericFont( pIntf ), m_rBitmap( rBitmap )
{
BitmapFont::BitmapFont( intf_thread_t *pIntf, const GenericBitmap &rBitmap ):
GenericFont( pIntf ), m_rBitmap( rBitmap )
{
+ m_width = 9;
+ m_height = 13;
}
GenericBitmap *BitmapFont::drawString( const UString &rString,
uint32_t color, int maxWidth ) const
{
}
GenericBitmap *BitmapFont::drawString( const UString &rString,
uint32_t color, int maxWidth ) const
{
+ uint32_t *pString = (uint32_t*)rString.u_str();
+ // Compute the text width
+ int width = 0;
+ for( uint32_t *ptr = pString; *ptr; ptr++ )
+ {
+ uint32_t c = *ptr;
+ if( (c >= '0' && c <= '9') || c == '-' )
+ {
+ width += m_width + 3;
+ }
+ else
+ {
+ width += 6;
+ }
+ }
+ // Create a bitmap
+ BitmapImpl *pBmp = new BitmapImpl( getIntf(), width, m_height );
+ int xDest = 0;
+ while( *pString )
+ {
+ uint32_t c = *(pString++);
+ int xSrc = -1;
+ if( c >= '0' && c <= '9' )
+ {
+ xSrc = (c - '0') * m_width;
+ }
+ else if( c == '-' )
+ {
+ xSrc = 11 * m_width;
+ }
+ if( xSrc != -1 )
+ {
+ pBmp->drawBitmap( m_rBitmap, xSrc, 0, xDest, 0, m_width,
+ m_height );
+ xDest += m_width + 3;
+ }
+ else
+ {
+ xDest += 6;
+ }
+ }
+ return pBmp;
private:
/// Bitmap
const GenericBitmap &m_rBitmap;
private:
/// Bitmap
const GenericBitmap &m_rBitmap;
+ /// Glyph size
+ int m_width, m_height;
#include "generic_bitmap.hpp"
#include "generic_bitmap.hpp"
-SubBitmap::SubBitmap( intf_thread_t *pIntf, const GenericBitmap &rSource,
- int left, int top, int width, int height ):
+BitmapImpl::BitmapImpl( intf_thread_t *pIntf, int width, int height ):
GenericBitmap( pIntf ), m_width( width ), m_height( height ),
m_pData( NULL )
{
m_pData = new uint8_t[width * height * 4];
GenericBitmap( pIntf ), m_width( width ), m_height( height ),
m_pData( NULL )
{
m_pData = new uint8_t[width * height * 4];
+ memset( m_pData, 0, width * height * 4 );
+}
+
+
+BitmapImpl::~BitmapImpl()
+{
+ delete[] m_pData;
+}
+
- uint32_t *pSrc = (uint32_t*)rSource.getData();
- uint32_t *pDest = (uint32_t*)m_pData;
+void BitmapImpl::drawBitmap( const GenericBitmap &rSource, int xSrc, int ySrc,
+ int xDest, int yDest, int width, int height )
+{
int srcWidth = rSource.getWidth();
int srcWidth = rSource.getWidth();
- for( int y = top; y < top + height; y++ )
+ uint32_t *pSrc = (uint32_t*)rSource.getData() + ySrc * srcWidth + xSrc;
+ uint32_t *pDest = (uint32_t*)m_pData + yDest * m_width + xDest ;
+ for( int y = 0; y < height; y++ )
{
memcpy( pDest, pSrc, 4 * width );
pSrc += srcWidth;
{
memcpy( pDest, pSrc, 4 * width );
pSrc += srcWidth;
-
-SubBitmap::~SubBitmap()
-{
- delete[] m_pData;
-}
-
#include "../utils/pointer.hpp"
#include "../utils/pointer.hpp"
-/// Base class for bitmaps
+/// Generic interface for bitmaps
class GenericBitmap: public SkinObject
{
public:
class GenericBitmap: public SkinObject
{
public:
-/// Bitmap created from a region of another bitmap
-class SubBitmap: public GenericBitmap
+/// Basic bitmap implementation
+class BitmapImpl: public GenericBitmap
- SubBitmap( intf_thread_t *pIntf, const GenericBitmap &rSource,
- int left, int top, int width, int height );
- ~SubBitmap();
+ /// Create an empty bitmap of the given size
+ BitmapImpl( intf_thread_t *pIntf, int width, int height );
+ ~BitmapImpl();
/// Get the width of the bitmap
virtual int getWidth() const { return m_width; }
/// Get the width of the bitmap
virtual int getWidth() const { return m_width; }
/// Each pixel is stored in 4 bytes in the order B,G,R,A
virtual uint8_t *getData() const { return m_pData; }
/// Each pixel is stored in 4 bytes in the order B,G,R,A
virtual uint8_t *getData() const { return m_pData; }
+ // Copy a region of another bitmap on this bitmap
+ void drawBitmap( const GenericBitmap &rSource, int xSrc, int ySrc,
+ int xDest, int yDest, int width, int height );
+
private:
/// Size of the bitmap.
int m_width, m_height;
private:
/// Size of the bitmap.
int m_width, m_height;
void Time::set( float percentage, bool updateVLC )
{
void Time::set( float percentage, bool updateVLC )
{
- if( getIntf()->p_sys->p_input == NULL )
- {
- return;
- }
-
VarPercent::set( percentage );
// Avoid looping forever...
VarPercent::set( percentage );
// Avoid looping forever...
+ if( updateVLC && getIntf()->p_sys->p_input )
{
vlc_value_t pos;
pos.f_float = percentage;
{
vlc_value_t pos;
pos.f_float = percentage;
-<!ELEMENT Theme (ThemeInfo,(Bitmap|Font|Window)*)>
+<!ELEMENT Theme (ThemeInfo,(Bitmap|BitmapFont|Font|Window)*)>
<!ATTLIST Theme
version CDATA #REQUIRED
tooltipfont CDATA "defaultfont"
<!ATTLIST Theme
version CDATA #REQUIRED
tooltipfont CDATA "defaultfont"