From b704f90f33241a9662671812e1de8075ecf76bde Mon Sep 17 00:00:00 2001 From: Cyril Deguet Date: Thu, 10 Nov 2005 22:30:22 +0000 Subject: [PATCH] * winamp2.xml: all the equalizer sliders are working !! * all: the slider background is now in a dedicaded tag "SliderBackground". The number of images can now be parametrized in both directions, and the offset between 2 images (padhoriz and padvert) is no more hardcoded --- modules/gui/skins2/controls/ctrl_slider.cpp | 24 +- modules/gui/skins2/controls/ctrl_slider.hpp | 9 +- modules/gui/skins2/parser/builder.cpp | 7 +- modules/gui/skins2/parser/builder_data.def | 2 +- modules/gui/skins2/parser/builder_data.hpp | 245 ++++++++++---------- modules/gui/skins2/parser/gen_builder.py | 2 - modules/gui/skins2/parser/skin_parser.cpp | 31 ++- share/skins2/skin.dtd | 11 +- share/skins2/winamp2.xml | 44 +++- 9 files changed, 223 insertions(+), 152 deletions(-) diff --git a/modules/gui/skins2/controls/ctrl_slider.cpp b/modules/gui/skins2/controls/ctrl_slider.cpp index 744d3f806a..e9b8538427 100644 --- a/modules/gui/skins2/controls/ctrl_slider.cpp +++ b/modules/gui/skins2/controls/ctrl_slider.cpp @@ -332,16 +332,16 @@ void CtrlSliderCursor::getResizeFactors( float &rFactorX, } - CtrlSliderBg::CtrlSliderBg( intf_thread_t *pIntf, CtrlSliderCursor &rCursor, const Bezier &rCurve, VarPercent &rVariable, int thickness, GenericBitmap *pBackground, - int nbImages, VarBool *pVisible, - const UString &rHelp ): + int nbHoriz, int nbVert, int padHoriz, int padVert, + VarBool *pVisible, const UString &rHelp ): CtrlGeneric( pIntf, rHelp, pVisible ), m_rCursor( rCursor ), m_rVariable( rVariable ), m_thickness( thickness ), m_rCurve( rCurve ), m_width( rCurve.getWidth() ), m_height( rCurve.getHeight() ), - m_pImgSeq( NULL ), m_nbImages( nbImages ), m_bgWidth( 0 ), + m_pImgSeq( NULL ), m_nbHoriz( nbHoriz ), m_nbVert( nbVert ), + m_padHoriz( padHoriz ), m_padVert( padVert ), m_bgWidth( 0 ), m_bgHeight( 0 ), m_position( 0 ) { if( pBackground ) @@ -352,14 +352,14 @@ CtrlSliderBg::CtrlSliderBg( intf_thread_t *pIntf, CtrlSliderCursor &rCursor, pBackground->getHeight() ); m_pImgSeq->drawBitmap( *pBackground, 0, 0 ); - m_bgWidth = pBackground->getWidth(); - m_bgHeight = pBackground->getHeight() / nbImages; + m_bgWidth = pBackground->getWidth() / nbHoriz; + m_bgHeight = pBackground->getHeight() / nbVert; // Observe the position variable m_rVariable.addObserver( this ); // Initial position - m_position = (int)( m_rVariable.get() * (m_nbImages - 1) ); + m_position = (int)( m_rVariable.get() * (m_nbHoriz * m_nbVert - 1) ); } } @@ -386,10 +386,12 @@ void CtrlSliderBg::draw( OSGraphics &rImage, int xDest, int yDest ) { if( m_pImgSeq ) { + // Locate the right image in the background bitmap + int x = m_bgWidth * ( m_position % m_nbHoriz ); + int y = m_bgHeight * ( m_position / m_nbHoriz ); // Draw the background image - // XXX the "-2" is a hack for winamp skins... - rImage.drawGraphics( *m_pImgSeq, 0, m_position * m_bgHeight, - xDest, yDest, m_bgWidth, m_bgHeight - 2); + rImage.drawGraphics( *m_pImgSeq, x, y, xDest, yDest, + m_bgWidth - m_padHoriz, m_bgHeight - m_padVert ); } } @@ -445,7 +447,7 @@ void CtrlSliderBg::handleEvent( EvtGeneric &rEvent ) void CtrlSliderBg::onUpdate( Subject &rVariable ) { - m_position = (int)( m_rVariable.get() * (m_nbImages - 1) ); + m_position = (int)( m_rVariable.get() * (m_nbHoriz * m_nbVert - 1) ); notifyLayout( m_bgWidth, m_bgHeight ); } diff --git a/modules/gui/skins2/controls/ctrl_slider.hpp b/modules/gui/skins2/controls/ctrl_slider.hpp index 3188d51aec..c97252ee2b 100644 --- a/modules/gui/skins2/controls/ctrl_slider.hpp +++ b/modules/gui/skins2/controls/ctrl_slider.hpp @@ -111,8 +111,9 @@ class CtrlSliderBg: public CtrlGeneric, public Observer public: CtrlSliderBg( intf_thread_t *pIntf, CtrlSliderCursor &rCursor, const Bezier &rCurve, VarPercent &rVariable, - int thickness, GenericBitmap *pBackground, int nbImages, - VarBool *pVisible, const UString &rHelp ); + int thickness, GenericBitmap *pBackground, int nbHoriz, + int nbVert, int padHoriz, int padVert, VarBool *pVisible, + const UString &rHelp ); virtual ~CtrlSliderBg(); /// Tell whether the mouse is over the control @@ -141,7 +142,9 @@ class CtrlSliderBg: public CtrlGeneric, public Observer /// Background image sequence (optional) OSGraphics *m_pImgSeq; /// Number of images in the background bitmap - int m_nbImages; + int m_nbHoriz, m_nbVert; + /// Number of pixels between two images + int m_padHoriz, m_padVert; /// Size of a background image int m_bgWidth, m_bgHeight; /// Index of the current background image diff --git a/modules/gui/skins2/parser/builder.cpp b/modules/gui/skins2/parser/builder.cpp index ab7bb28088..40ed59d75c 100644 --- a/modules/gui/skins2/parser/builder.cpp +++ b/modules/gui/skins2/parser/builder.cpp @@ -591,9 +591,9 @@ void Builder::addSlider( const BuilderData::Slider &rData ) GET_BMP( pBmpOver, rData.m_overId ); GenericBitmap *pBgImage = NULL; - if( rData.m_background != "none" ) + if( rData.m_imageId != "none" ) { - GET_BMP( pBgImage, rData.m_background ); + GET_BMP( pBgImage, rData.m_imageId ); } GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId); @@ -632,7 +632,8 @@ void Builder::addSlider( const BuilderData::Slider &rData ) UString( getIntf(), rData.m_help.c_str() ) ); CtrlSliderBg *pBackground = new CtrlSliderBg( getIntf(), *pCursor, - *pCurve, *pVar, rData.m_thickness, pBgImage, rData.m_nbImages, + *pCurve, *pVar, rData.m_thickness, pBgImage, rData.m_nbHoriz, + rData.m_nbVert, rData.m_padHoriz, rData.m_padVert, pVisible, UString( getIntf(), rData.m_help.c_str() ) ); // Compute the position of the control diff --git a/modules/gui/skins2/parser/builder_data.def b/modules/gui/skins2/parser/builder_data.def index 5e884b012f..cd1b38b3d3 100644 --- a/modules/gui/skins2/parser/builder_data.def +++ b/modules/gui/skins2/parser/builder_data.def @@ -11,7 +11,7 @@ Checkbox id:string xPos:int yPos:int leftTop:string rightBottom:string visible:s Image id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string bmpId:string actionId:string resize:string help:string layer:int windowId:string layoutId:string 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 background:string nbImages:int 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 imageId:string nbHoriz:int nbVert:int padHoriz:int padVert:int 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 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 Tree id:string xPos:int yPos:int visible:string width:int height:int leftTop:string rightBottom:string fontId:string var:string bgImageId:string itemImageId:string openImageId:string closedImageId: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 autoResize:bool 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 3562660af1..5a6876ab8b 100644 --- a/modules/gui/skins2/parser/builder_data.hpp +++ b/modules/gui/skins2/parser/builder_data.hpp @@ -45,7 +45,7 @@ struct BuilderData Theme( const string & tooltipfont, int magnet, uint32_t alpha, uint32_t moveAlpha ): m_tooltipfont( tooltipfont ), m_magnet( magnet ), m_alpha( alpha ), m_moveAlpha( moveAlpha ) {} - const string m_tooltipfont; + string m_tooltipfont; int m_magnet; uint32_t m_alpha; uint32_t m_moveAlpha; @@ -59,8 +59,8 @@ m_tooltipfont( tooltipfont ), m_magnet( magnet ), m_alpha( alpha ), m_moveAlpha( Bitmap( const string & id, const string & fileName, uint32_t alphaColor ): m_id( id ), m_fileName( fileName ), m_alphaColor( alphaColor ) {} - const string m_id; - const string m_fileName; + string m_id; + string m_fileName; uint32_t m_alphaColor; }; /// List @@ -72,8 +72,8 @@ m_id( id ), m_fileName( fileName ), m_alphaColor( alphaColor ) {} 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; + string m_id; + string m_parent; int m_x; int m_y; int m_width; @@ -88,9 +88,9 @@ m_id( id ), m_parent( parent ), m_x( x ), m_y( y ), m_width( width ), m_height( 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; + string m_id; + string m_file; + string m_type; }; /// List list m_listBitmapFont; @@ -101,8 +101,8 @@ m_id( id ), m_file( file ), m_type( type ) {} Font( const string & id, const string & fontFile, int size ): m_id( id ), m_fontFile( fontFile ), m_size( size ) {} - const string m_id; - const string m_fontFile; + string m_id; + string m_fontFile; int m_size; }; /// List @@ -114,7 +114,7 @@ m_id( id ), m_fontFile( fontFile ), m_size( size ) {} Window( const string & id, int xPos, int yPos, bool visible, bool dragDrop, bool playOnDrop ): m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_dragDrop( dragDrop ), m_playOnDrop( playOnDrop ) {} - const string m_id; + string m_id; int m_xPos; int m_yPos; bool m_visible; @@ -130,14 +130,14 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_dragDrop( dr Layout( const string & id, int width, int height, int minWidth, int maxWidth, int minHeight, int maxHeight, const string & windowId ): m_id( id ), m_width( width ), m_height( height ), m_minWidth( minWidth ), m_maxWidth( maxWidth ), m_minHeight( minHeight ), m_maxHeight( maxHeight ), m_windowId( windowId ) {} - const string m_id; + string m_id; int m_width; int m_height; int m_minWidth; int m_maxWidth; int m_minHeight; int m_maxHeight; - const string m_windowId; + string m_windowId; }; /// List list m_listLayout; @@ -152,8 +152,8 @@ m_xPos( xPos ), m_yPos( yPos ), m_range( range ), m_priority( priority ), m_poin int m_yPos; int m_range; int m_priority; - const string m_points; - const string m_layoutId; + string m_points; + string m_layoutId; }; /// List list m_listAnchor; @@ -164,21 +164,21 @@ m_xPos( xPos ), m_yPos( yPos ), m_range( range ), m_priority( priority ), m_poin Button( const string & id, int xPos, int yPos, const string & leftTop, const string & rightBottom, const string & visible, const string & upId, const string & downId, const string & overId, const string & actionId, const string & tooltip, const string & help, int layer, const string & windowId, const string & layoutId ): m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_visible( visible ), m_upId( upId ), m_downId( downId ), m_overId( overId ), m_actionId( actionId ), m_tooltip( tooltip ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} - const string m_id; + string m_id; int m_xPos; int m_yPos; - const string m_leftTop; - const string m_rightBottom; - const string m_visible; - const string m_upId; - const string m_downId; - const string m_overId; - const string m_actionId; - const string m_tooltip; - const string m_help; + string m_leftTop; + string m_rightBottom; + string m_visible; + string m_upId; + string m_downId; + string m_overId; + string m_actionId; + string m_tooltip; + string m_help; int m_layer; - const string m_windowId; - const string m_layoutId; + string m_windowId; + string m_layoutId; }; /// List list