/*****************************************************************************
* ctrl_slider.hpp
*****************************************************************************
- * Copyright (C) 2003 VideoLAN
- * $Id: ctrl_slider.hpp,v 1.4 2004/03/02 21:45:15 ipkiss Exp $
+ * Copyright (C) 2003 the VideoLAN team
+ * $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
- * Olivier Teulière <ipkiss@via.ecp.fr>
+ * Olivier Teulière <ipkiss@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef CTRL_SLIDER_HPP
/// Get the text of the tooltip
virtual UString getTooltipText() const { return m_tooltip; }
+ /// Get the type of control (custom RTTI)
+ virtual string getType() const { return "slider_cursor"; }
+
private:
/// Finite state machine of the control
FSM m_fsm;
const UString m_tooltip;
/// Initial size of the control
int m_width, m_height;
- /// Callback objects
- Callback m_cmdOverDown;
- Callback m_cmdDownOver;
- Callback m_cmdOverUp;
- Callback m_cmdUpOver;
- Callback m_cmdMove;
- Callback m_cmdScroll;
/// Position of the cursor
int m_xPosition, m_yPosition;
+ /// Callback objects
+ DEFINE_CALLBACK( CtrlSliderCursor, OverDown )
+ DEFINE_CALLBACK( CtrlSliderCursor, DownOver )
+ DEFINE_CALLBACK( CtrlSliderCursor, OverUp )
+ DEFINE_CALLBACK( CtrlSliderCursor, UpOver )
+ DEFINE_CALLBACK( CtrlSliderCursor, Move )
+ DEFINE_CALLBACK( CtrlSliderCursor, Scroll )
/// Last saved position of the cursor (stored as a percentage)
float m_lastPercentage;
/// Offset between the mouse pointer and the center of the cursor
/// Bezier curve of the slider
const Bezier &m_rCurve;
- /// Callback functions
- static void transOverDown( SkinObject *pCtrl );
- static void transDownOver( SkinObject *pCtrl );
- static void transOverUp( SkinObject *pCtrl );
- static void transUpOver( SkinObject *pCtrl );
- static void transMove( SkinObject *pCtrl );
- static void transScroll( SkinObject *pCtrl );
-
/// Method called when the position variable is modified
- virtual void onUpdate( Subject<VarPercent> &rVariable );
+ virtual void onUpdate( Subject<VarPercent> &rVariable, void * );
- /// Methode to compute the resize factors
+ /// Method to compute the resize factors
void getResizeFactors( float &rFactorX, float &rFactorY ) const;
+
+ /// Call notifyLayout
+ void refreshLayout();
};
/// Slider background
-class CtrlSliderBg: public CtrlGeneric
+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, VarBool *pVisible, const UString &rHelp );
- virtual ~CtrlSliderBg() {}
+ 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
virtual bool mouseOver( int x, int y ) const;
+ /// Draw the control on the given graphics
+ virtual void draw( OSGraphics &rImage, int xDest, int yDest );
+
/// Handle an event
virtual void handleEvent( EvtGeneric &rEvent );
+ /// Method called when the control is resized
+ virtual void onResize();
+
+ /// 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
const Bezier &m_rCurve;
/// Initial size of the control
int m_width, m_height;
-
- /// Methode to compute the resize factors
+ /// Background image sequence (optional)
+ GenericBitmap *m_pImgSeq;
+ /// Number of images in the background bitmap
+ 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
+ int m_position;
+
+ /// Method called when the observed variable is modified
+ virtual void onUpdate( Subject<VarPercent> &rVariable, void* );
+
+ /// Method to compute the resize factors
void getResizeFactors( float &rFactorX, float &rFactorY ) const;
};