Commit 7eba6693 authored by Olivier Teulière's avatar Olivier Teulière

* skins2/parser/builder.cpp: create the background part of the slider, even if

   the cursor cannot be created. This allows using the slider in some winamp
   skins which do not use cursors.
parent e55c41bf
......@@ -332,12 +332,12 @@ void CtrlSliderCursor::getResizeFactors( float &rFactorX,
}
CtrlSliderBg::CtrlSliderBg( intf_thread_t *pIntf, CtrlSliderCursor &rCursor,
CtrlSliderBg::CtrlSliderBg( intf_thread_t *pIntf,
const Bezier &rCurve, VarPercent &rVariable,
int thickness, GenericBitmap *pBackground,
int nbHoriz, int nbVert, int padHoriz, int padVert,
VarBool *pVisible, const UString &rHelp ):
CtrlGeneric( pIntf, rHelp, pVisible ), m_rCursor( rCursor ),
CtrlGeneric( pIntf, rHelp, pVisible ),
m_rVariable( rVariable ), m_thickness( thickness ), m_rCurve( rCurve ),
m_width( rCurve.getWidth() ), m_height( rCurve.getHeight() ),
m_pImgSeq( NULL ), m_nbHoriz( nbHoriz ), m_nbVert( nbVert ),
......@@ -418,12 +418,12 @@ void CtrlSliderBg::handleEvent( EvtGeneric &rEvent )
// Forward the clic to the cursor
EvtMouse evt( getIntf(), x, y, EvtMouse::kLeft, EvtMouse::kDown );
TopWindow *pWin = getWindow();
if( pWin )
if( pWin && m_pCursor )
{
EvtEnter evtEnter( getIntf() );
// XXX It was not supposed to be implemented like that !!
pWin->forwardEvent( evtEnter, m_rCursor );
pWin->forwardEvent( evt, m_rCursor );
pWin->forwardEvent( evtEnter, *m_pCursor );
pWin->forwardEvent( evt, *m_pCursor );
}
}
else if( rEvent.getAsString().find( "scroll" ) != string::npos )
......@@ -445,6 +445,12 @@ void CtrlSliderBg::handleEvent( EvtGeneric &rEvent )
}
void CtrlSliderBg::associateCursor( CtrlSliderCursor &rCursor )
{
m_pCursor = &rCursor;
}
void CtrlSliderBg::onUpdate( Subject<VarPercent> &rVariable )
{
m_position = (int)( m_rVariable.get() * (m_nbHoriz * m_nbVert - 1) );
......
......@@ -109,7 +109,7 @@ class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent>
class CtrlSliderBg: public CtrlGeneric, public Observer<VarPercent>
{
public:
CtrlSliderBg( intf_thread_t *pIntf, CtrlSliderCursor &rCursor,
CtrlSliderBg( intf_thread_t *pIntf,
const Bezier &rCurve, VarPercent &rVariable,
int thickness, GenericBitmap *pBackground, int nbHoriz,
int nbVert, int padHoriz, int padVert, VarBool *pVisible,
......@@ -128,9 +128,12 @@ class CtrlSliderBg: public CtrlGeneric, public Observer<VarPercent>
/// Get the type of control (custom RTTI)
virtual string getType() const { return "slider_bg"; }
/// Associate a cursor to this background
void associateCursor( CtrlSliderCursor &rCursor );
private:
/// Cursor of the slider
CtrlSliderCursor &m_rCursor;
CtrlSliderCursor *m_pCursor;
/// Variable associated to the slider
VarPercent &m_rVariable;
/// Thickness of the curve
......
......@@ -580,16 +580,12 @@ void Builder::addRadialSlider( const BuilderData::RadialSlider &rData )
void Builder::addSlider( const BuilderData::Slider &rData )
{
// Get the bitmaps of the slider
GenericBitmap *pBmpUp = NULL;
GET_BMP( pBmpUp, rData.m_upId );
GenericBitmap *pBmpDown = pBmpUp;
GET_BMP( pBmpDown, rData.m_downId );
GenericBitmap *pBmpOver = pBmpUp;
GET_BMP( pBmpOver, rData.m_overId );
// Add the background first, so that we will still have something almost
// functional if the cursor cannot be created properly (this happens for
// some winamp2 skins, where the images of the cursor are not always
// present)
// Get the bitmaps of the background
GenericBitmap *pBgImage = NULL;
if( rData.m_imageId != "none" )
{
......@@ -625,13 +621,8 @@ void Builder::addSlider( const BuilderData::Slider &rData )
return;
}
// Create the cursor and background controls
CtrlSliderCursor *pCursor = new CtrlSliderCursor( getIntf(), *pBmpUp,
*pBmpOver, *pBmpDown, *pCurve, *pVar, pVisible,
UString( getIntf(), rData.m_tooltip.c_str() ),
UString( getIntf(), rData.m_help.c_str() ) );
CtrlSliderBg *pBackground = new CtrlSliderBg( getIntf(), *pCursor,
// Create the background control
CtrlSliderBg *pBackground = new CtrlSliderBg( getIntf(),
*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() ) );
......@@ -643,10 +634,31 @@ void Builder::addSlider( const BuilderData::Slider &rData )
*pLayout );
pLayout->addControl( pBackground, pos, rData.m_layer );
m_pTheme->m_controls[rData.m_id + "_bg"] = CtrlGenericPtr( pBackground );
// Get the bitmaps of the cursor
GenericBitmap *pBmpUp = NULL;
GET_BMP( pBmpUp, rData.m_upId );
GenericBitmap *pBmpDown = pBmpUp;
GET_BMP( pBmpDown, rData.m_downId );
GenericBitmap *pBmpOver = pBmpUp;
GET_BMP( pBmpOver, rData.m_overId );
// Create the cursor control
CtrlSliderCursor *pCursor = new CtrlSliderCursor( getIntf(), *pBmpUp,
*pBmpOver, *pBmpDown, *pCurve, *pVar, pVisible,
UString( getIntf(), rData.m_tooltip.c_str() ),
UString( getIntf(), rData.m_help.c_str() ) );
pLayout->addControl( pCursor, pos, rData.m_layer );
m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pCursor );
m_pTheme->m_controls[rData.m_id + "_bg"] = CtrlGenericPtr( pBackground );
// Associate the cursor to the background
pBackground->associateCursor( *pCursor );
}
......
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