several bitmaps in a skin from regions of the same image file.
Usage is:
<Bitmap id="body" file="main.bmp" alphacolor="#FF0000">
<SubBitmap id="sub1" x="0" y="10" width="100" height="100" />
<SubBitmap id="sub2" x="100" y="10" width="100" height="100" />
</Bitmap>
// Create everything from the data in the XML
ADD_OBJECTS( Theme );
ADD_OBJECTS( Bitmap );
+ ADD_OBJECTS( SubBitmap );
ADD_OBJECTS( BitmapFont );
ADD_OBJECTS( Font );
ADD_OBJECTS( Window );
}
+void Builder::addSubBitmap( const BuilderData::SubBitmap &rData )
+{
+ // Get the parent bitmap
+ GenericBitmap *pParentBmp = NULL;
+ GET_BMP( pParentBmp, rData.m_parent );
+ if( !pParentBmp )
+ {
+ msg_Err( getIntf(), "unknown bitmap id: %s", rData.m_parent.c_str() );
+ return;
+ }
+
+ // Copy a region of the parent bitmap to the new one
+ BitmapImpl *pBmp =
+ new BitmapImpl( getIntf(), rData.m_width, rData.m_height );
+ pBmp->drawBitmap( *pParentBmp, rData.m_x, rData.m_y, 0, 0, rData.m_width,
+ rData.m_height );
+
+ m_pTheme->m_bitmaps[rData.m_id] = GenericBitmapPtr( pBmp );
+}
+
+
void Builder::addBitmapFont( const BuilderData::BitmapFont &rData )
{
GenericBitmap *pBmp =
void addTheme( const BuilderData::Theme &rData );
void addBitmap( const BuilderData::Bitmap &rData );
+ void addSubBitmap( const BuilderData::SubBitmap &rData );
void addBitmapFont( const BuilderData::BitmapFont &rData );
void addFont( const BuilderData::Font &rData );
void addWindow( const BuilderData::Window &rData );
Theme tooltipfont:string magnet:int alpha:uint32_t moveAlpha:uint32_t
Bitmap id:string fileName:string alphaColor:uint32_t
+SubBitmap id:string parent:string x:int y:int width:int height:int
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
/// List
list<Bitmap> m_listBitmap;
+ /// Type definition
+ struct SubBitmap
+ {
+ SubBitmap( const string & id, const string & parent, int x, int y, int width, int height ):
+m_id( id ), m_parent( parent ), m_x( x ), m_y( y ), m_width( width ), m_height( height ) {}
+
+ const string m_id;
+ const string m_parent;
+ int m_x;
+ int m_y;
+ int m_width;
+ int m_height;
+ };
+ /// List
+ list<SubBitmap> m_listSubBitmap;
+
/// Type definition
struct BitmapFont
{
RequireDefault( "file" );
RequireDefault( "alphacolor" );
- const BuilderData::Bitmap bitmap( uniqueId( attr["id"] ),
+ m_curBitmapId = uniqueId( attr["id"] );
+ const BuilderData::Bitmap bitmap( m_curBitmapId,
convertFileName( attr["file"] ),
convertColor( attr["alphacolor"] ) );
m_data.m_listBitmap.push_back( bitmap );
}
+ else if( rName == "SubBitmap" )
+ {
+ RequireDefault( "id" );
+ RequireDefault( "x" );
+ RequireDefault( "y" );
+ RequireDefault( "width" );
+ RequireDefault( "height" );
+
+ const BuilderData::SubBitmap bitmap( uniqueId( attr["id"] ),
+ m_curBitmapId, atoi( attr["x"] ), atoi( attr["y"] ),
+ atoi( attr["width"] ), atoi( attr["height"] ) );
+ m_data.m_listSubBitmap.push_back( bitmap );
+ }
+
else if( rName == "BitmapFont" )
{
RequireDefault( "id" );
/// Container for mapping data from the XML
BuilderData m_data;
/// Current IDs
+ string m_curBitmapId;
string m_curWindowId;
string m_curLayoutId;
string m_curListId;
>
<!-- main elements -->
-<!ELEMENT Bitmap EMPTY>
+<!ELEMENT Bitmap (SubBitmap)*>
<!ATTLIST Bitmap
id CDATA #REQUIRED
file CDATA #REQUIRED
alphacolor CDATA #REQUIRED
>
+<!ELEMENT SubBitmap EMPTY>
+ <!ATTLIST SubBitmap
+ id CDATA #REQUIRED
+ x CDATA #REQUIRED
+ y CDATA #REQUIRED
+ width CDATA #REQUIRED
+ height CDATA #REQUIRED
+ >
<!ELEMENT Font EMPTY>
<!ATTLIST Font
id CDATA #REQUIRED