Commit b704f90f authored by Cyril Deguet's avatar Cyril Deguet

* 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
parent 85fad441
...@@ -332,16 +332,16 @@ void CtrlSliderCursor::getResizeFactors( float &rFactorX, ...@@ -332,16 +332,16 @@ void CtrlSliderCursor::getResizeFactors( float &rFactorX,
} }
CtrlSliderBg::CtrlSliderBg( intf_thread_t *pIntf, CtrlSliderCursor &rCursor, CtrlSliderBg::CtrlSliderBg( intf_thread_t *pIntf, CtrlSliderCursor &rCursor,
const Bezier &rCurve, VarPercent &rVariable, const Bezier &rCurve, VarPercent &rVariable,
int thickness, GenericBitmap *pBackground, int thickness, GenericBitmap *pBackground,
int nbImages, VarBool *pVisible, int nbHoriz, int nbVert, int padHoriz, int padVert,
const UString &rHelp ): VarBool *pVisible, const UString &rHelp ):
CtrlGeneric( pIntf, rHelp, pVisible ), m_rCursor( rCursor ), CtrlGeneric( pIntf, rHelp, pVisible ), m_rCursor( rCursor ),
m_rVariable( rVariable ), m_thickness( thickness ), m_rCurve( rCurve ), m_rVariable( rVariable ), m_thickness( thickness ), m_rCurve( rCurve ),
m_width( rCurve.getWidth() ), m_height( rCurve.getHeight() ), 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 ) m_bgHeight( 0 ), m_position( 0 )
{ {
if( pBackground ) if( pBackground )
...@@ -352,14 +352,14 @@ CtrlSliderBg::CtrlSliderBg( intf_thread_t *pIntf, CtrlSliderCursor &rCursor, ...@@ -352,14 +352,14 @@ CtrlSliderBg::CtrlSliderBg( intf_thread_t *pIntf, CtrlSliderCursor &rCursor,
pBackground->getHeight() ); pBackground->getHeight() );
m_pImgSeq->drawBitmap( *pBackground, 0, 0 ); m_pImgSeq->drawBitmap( *pBackground, 0, 0 );
m_bgWidth = pBackground->getWidth(); m_bgWidth = pBackground->getWidth() / nbHoriz;
m_bgHeight = pBackground->getHeight() / nbImages; m_bgHeight = pBackground->getHeight() / nbVert;
// Observe the position variable // Observe the position variable
m_rVariable.addObserver( this ); m_rVariable.addObserver( this );
// Initial position // 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 ) ...@@ -386,10 +386,12 @@ void CtrlSliderBg::draw( OSGraphics &rImage, int xDest, int yDest )
{ {
if( m_pImgSeq ) 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 // Draw the background image
// XXX the "-2" is a hack for winamp skins... rImage.drawGraphics( *m_pImgSeq, x, y, xDest, yDest,
rImage.drawGraphics( *m_pImgSeq, 0, m_position * m_bgHeight, m_bgWidth - m_padHoriz, m_bgHeight - m_padVert );
xDest, yDest, m_bgWidth, m_bgHeight - 2);
} }
} }
...@@ -445,7 +447,7 @@ void CtrlSliderBg::handleEvent( EvtGeneric &rEvent ) ...@@ -445,7 +447,7 @@ void CtrlSliderBg::handleEvent( EvtGeneric &rEvent )
void CtrlSliderBg::onUpdate( Subject<VarPercent> &rVariable ) void CtrlSliderBg::onUpdate( Subject<VarPercent> &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 ); notifyLayout( m_bgWidth, m_bgHeight );
} }
......
...@@ -111,8 +111,9 @@ class CtrlSliderBg: public CtrlGeneric, public Observer<VarPercent> ...@@ -111,8 +111,9 @@ class CtrlSliderBg: public CtrlGeneric, public Observer<VarPercent>
public: public:
CtrlSliderBg( intf_thread_t *pIntf, CtrlSliderCursor &rCursor, CtrlSliderBg( intf_thread_t *pIntf, CtrlSliderCursor &rCursor,
const Bezier &rCurve, VarPercent &rVariable, const Bezier &rCurve, VarPercent &rVariable,
int thickness, GenericBitmap *pBackground, int nbImages, int thickness, GenericBitmap *pBackground, int nbHoriz,
VarBool *pVisible, const UString &rHelp ); int nbVert, int padHoriz, int padVert, VarBool *pVisible,
const UString &rHelp );
virtual ~CtrlSliderBg(); virtual ~CtrlSliderBg();
/// Tell whether the mouse is over the control /// Tell whether the mouse is over the control
...@@ -141,7 +142,9 @@ class CtrlSliderBg: public CtrlGeneric, public Observer<VarPercent> ...@@ -141,7 +142,9 @@ class CtrlSliderBg: public CtrlGeneric, public Observer<VarPercent>
/// Background image sequence (optional) /// Background image sequence (optional)
OSGraphics *m_pImgSeq; OSGraphics *m_pImgSeq;
/// Number of images in the background bitmap /// 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 /// Size of a background image
int m_bgWidth, m_bgHeight; int m_bgWidth, m_bgHeight;
/// Index of the current background image /// Index of the current background image
......
...@@ -591,9 +591,9 @@ void Builder::addSlider( const BuilderData::Slider &rData ) ...@@ -591,9 +591,9 @@ void Builder::addSlider( const BuilderData::Slider &rData )
GET_BMP( pBmpOver, rData.m_overId ); GET_BMP( pBmpOver, rData.m_overId );
GenericBitmap *pBgImage = NULL; 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); GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
...@@ -632,7 +632,8 @@ void Builder::addSlider( const BuilderData::Slider &rData ) ...@@ -632,7 +632,8 @@ void Builder::addSlider( const BuilderData::Slider &rData )
UString( getIntf(), rData.m_help.c_str() ) ); UString( getIntf(), rData.m_help.c_str() ) );
CtrlSliderBg *pBackground = new CtrlSliderBg( getIntf(), *pCursor, 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() ) ); pVisible, UString( getIntf(), rData.m_help.c_str() ) );
// Compute the position of the control // Compute the position of the control
......
...@@ -11,7 +11,7 @@ Checkbox id:string xPos:int yPos:int leftTop:string rightBottom:string visible:s ...@@ -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 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 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 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 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 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 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
This diff is collapsed.
...@@ -79,8 +79,6 @@ while 1: ...@@ -79,8 +79,6 @@ while 1:
initlist += ", " initlist += ", "
initlist += "m_" + varname + "( " + varname + " )" initlist += "m_" + varname + "( " + varname + " )"
vartype = vardef[1] vartype = vardef[1]
if vartype == "string":
vartype = "const string"
vars += " " + vartype + " m_" + varname + ";\n" vars += " " + vartype + " m_" + varname + ";\n"
str += constructor + " ):\n" + initlist + " {}\n\n" str += constructor + " ):\n" + initlist + " {}\n\n"
str += vars + " };\n" str += vars + " };\n"
......
...@@ -363,8 +363,6 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) ...@@ -363,8 +363,6 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
CheckDefault( "over", "none" ); CheckDefault( "over", "none" );
CheckDefault( "thickness", "10" ); CheckDefault( "thickness", "10" );
CheckDefault( "value", "none" ); CheckDefault( "value", "none" );
CheckDefault( "background", "none" );
CheckDefault( "nbimages", "1" );
CheckDefault( "tooltiptext", "" ); CheckDefault( "tooltiptext", "" );
CheckDefault( "help", "" ); CheckDefault( "help", "" );
...@@ -380,17 +378,34 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) ...@@ -380,17 +378,34 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
newValue = "playtree.slider"; newValue = "playtree.slider";
} }
const BuilderData::Slider slider( uniqueId( attr["id"] ), const BuilderData::Slider slider( uniqueId( attr["id"] ),
attr["visible"], attr["visible"], atoi( attr["x"] ) + m_xOffset,
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, atoi( attr["y"] ) + m_yOffset, attr["lefttop"],
attr["lefttop"], attr["rightbottom"], attr["up"], attr["down"], attr["rightbottom"], attr["up"], attr["down"],
attr["over"], attr["points"], atoi( attr["thickness"] ), attr["over"], attr["points"], atoi( attr["thickness"] ),
newValue, attr["background"], atoi( attr["nbimages"] ), newValue, "none", 0, 0, 0, 0, attr["tooltiptext"],
attr["tooltiptext"], attr["help"], m_curLayer, attr["help"], m_curLayer, m_curWindowId, m_curLayoutId );
m_curWindowId, m_curLayoutId );
m_curLayer++; m_curLayer++;
m_pData->m_listSlider.push_back( slider ); m_pData->m_listSlider.push_back( slider );
} }
else if( rName == "SliderBackground" )
{
RequireDefault( "image" );
CheckDefault( "nbhoriz", "1" );
CheckDefault( "nbvert", "1" );
CheckDefault( "padhoriz", "0" );
CheckDefault( "padvert", "0" );
// Retrieve the current slider data
BuilderData::Slider &slider = m_pData->m_listSlider.back();
slider.m_imageId = attr["image"];
slider.m_nbHoriz = atoi( attr["nbhoriz"] );
slider.m_nbVert = atoi( attr["nbvert"] );
slider.m_padHoriz = atoi( attr["padhoriz"] );
slider.m_padVert = atoi( attr["padvert"] );
}
else if( rName == "Text" ) else if( rName == "Text" )
{ {
RequireDefault( "font" ); RequireDefault( "font" );
......
...@@ -58,7 +58,6 @@ ...@@ -58,7 +58,6 @@
dragdrop CDATA "true" dragdrop CDATA "true"
playondrop CDATA "true" playondrop CDATA "true"
> >
<!ELEMENT Layout (Group)> <!ELEMENT Layout (Group)>
<!ATTLIST Layout <!ATTLIST Layout
id CDATA "none" id CDATA "none"
...@@ -151,10 +150,18 @@ ...@@ -151,10 +150,18 @@
thickness CDATA "10" thickness CDATA "10"
value CDATA "none" value CDATA "none"
background CDATA "none" background CDATA "none"
nbimages CDATA "1"
tooltiptext CDATA "" tooltiptext CDATA ""
help CDATA "" help CDATA ""
> >
<!ELEMENT SliderBackground EMPTY>
<!ATTLIST SliderBackground
id CDATA "none"
image CDATA #REQUIRED
nbhoriz CDATA "1"
nbvert CDATA "1"
padhoriz CDATA "0"
padvert CDATA "0"
>
<!ELEMENT RadialSlider EMPTY> <!ELEMENT RadialSlider EMPTY>
<!ATTLIST RadialSlider <!ATTLIST RadialSlider
id CDATA "none" id CDATA "none"
......
...@@ -20,6 +20,14 @@ ...@@ -20,6 +20,14 @@
</Bitmap> </Bitmap>
<Bitmap id="eqmain" file="eqmain.bmp" alphacolor="#FF0000"> <Bitmap id="eqmain" file="eqmain.bmp" alphacolor="#FF0000">
<SubBitmap id="eq_bg" x="0" y="0" width="275" height="116" /> <SubBitmap id="eq_bg" x="0" y="0" width="275" height="116" />
<SubBitmap id="eq_title_focus" x="0" y="134" width="275" height="14" />
<SubBitmap id="eq_notok_up" x="10" y="119" width="26" height="12" />
<SubBitmap id="eq_ok_up" x="69" y="119" width="26" height="12" />
<SubBitmap id="eq_notok_down" x="128" y="119" width="26" height="12" />
<SubBitmap id="eq_ok_down" x="187" y="119" width="26" height="12" />
<SubBitmap id="eq_slider_up" x="0" y="164" width="11" height="11" />
<SubBitmap id="eq_slider_down" x="0" y="176" width="11" height="11" />
<SubBitmap id="eq_slider_bg" x="13" y="164" width="210" height="130" />
</Bitmap> </Bitmap>
<Bitmap id="pledit" file="pledit.bmp" alphacolor="#FF0000"> <Bitmap id="pledit" file="pledit.bmp" alphacolor="#FF0000">
<SubBitmap id="pl_upleft_focus" x="0" y="0" width="25" height="20" /> <SubBitmap id="pl_upleft_focus" x="0" y="0" width="25" height="20" />
...@@ -81,7 +89,9 @@ ...@@ -81,7 +89,9 @@
<Image x="0" y="0" image="title_focus" action="move" /> <Image x="0" y="0" image="title_focus" action="move" />
<Text font="digits_font" x="30" y="26" width="75" text="$T"/> <Text font="digits_font" x="30" y="26" width="75" text="$T"/>
<Text font="text_font" x="111" y="27" width="155" text="$N"/> <Text font="text_font" x="111" y="27" width="155" text="$N"/>
<Slider value="volume" x="107" y="57" up="volume_up" down="volume_down" points="(7,6),(58,6)" background="volume_bg" nbimages="28" tooltiptext="Volume: $V%" /> <Slider value="volume" x="107" y="57" up="volume_up" down="volume_down" points="(7,6),(58,6)" tooltiptext="Volume: $V%">
<SliderBackground image="volume_bg" nbvert="28" padvert="1"/>
</Slider>
<Image x="16" y="72" image="time_bg"/> <Image x="16" y="72" image="time_bg"/>
<Slider value="time" x="29" y="77" up="time_up" down="time_down" points="(0,0),(220,0)" thickness="5" tooltiptext="Time: $T"/> <Slider value="time" x="29" y="77" up="time_up" down="time_down" points="(0,0),(220,0)" thickness="5" tooltiptext="Time: $T"/>
<Button x="263" y="3" up="quit_up" down="quit_down" over="quit_up" action="vlc.quit()" tooltiptext="Quit" /> <Button x="263" y="3" up="quit_up" down="quit_down" over="quit_up" action="vlc.quit()" tooltiptext="Quit" />
...@@ -108,6 +118,38 @@ ...@@ -108,6 +118,38 @@
<Anchor x="275" y="116" priority="40" range="15" /> <Anchor x="275" y="116" priority="40" range="15" />
<Anchor x="20" y="116" points="(0,0),(235,0)" priority="30" range="15" /> <Anchor x="20" y="116" points="(0,0),(235,0)" priority="30" range="15" />
<Image x="0" y="0" image="eq_bg" action="move" /> <Image x="0" y="0" image="eq_bg" action="move" />
<Image x="0" y="0" image="eq_title_focus" action="move" />
<Checkbox x="15" y="20" up1="eq_notok_up" down1="eq_notok_down" up2="eq_ok_up" down2="eq_ok_down" state="equalizer.isEnabled" action1="equalizer.enable()" action2="equalizer.disable()" tooltiptext1="Enable equalizer" tooltiptext2="Disable equalizer"/>
<Slider value="equalizer.band(0)" x="78" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
<SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1"/>
</Slider>
<Slider value="equalizer.band(1)" x="96" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
<SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1"/>
</Slider>
<Slider value="equalizer.band(2)" x="114" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
<SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1"/>
</Slider>
<Slider value="equalizer.band(3)" x="132" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
<SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1"/>
</Slider>
<Slider value="equalizer.band(4)" x="150" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
<SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1"/>
</Slider>
<Slider value="equalizer.band(5)" x="168" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
<SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1"/>
</Slider>
<Slider value="equalizer.band(6)" x="186" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
<SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1"/>
</Slider>
<Slider value="equalizer.band(7)" x="204" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
<SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1"/>
</Slider>
<Slider value="equalizer.band(8)" x="222" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
<SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1"/>
</Slider>
<Slider value="equalizer.band(9)" x="240" y="37" up="eq_slider_up" down="eq_slider_down" points="(6,55),(6,7)" thickness="6" tooltiptext="">
<SliderBackground image="eq_slider_bg" nbhoriz="14" nbvert="2" padhoriz="1" padvert="1"/>
</Slider>
</Group> </Group>
</Layout> </Layout>
</Window> </Window>
......
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