skins2: reuse graphics from generic bitmap cache (radialslider)
[vlc.git] / modules / gui / skins2 / controls / ctrl_radialslider.hpp
blobb7d427b797184b67e323f2277b74187fb263b22b
1 /*****************************************************************************
2 * ctrl_radialslider.hpp
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
5 * $Id$
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifndef CTRL_RADIALSLIDER_HPP
26 #define CTRL_RADIALSLIDER_HPP
28 #include "ctrl_generic.hpp"
29 #include "../utils/fsm.hpp"
30 #include "../utils/observer.hpp"
33 class GenericBitmap;
34 class OSGraphics;
35 class VarPercent;
38 /// Radial slider
39 class CtrlRadialSlider: public CtrlGeneric, public Observer<VarPercent>
41 public:
42 /// Create a radial slider with the given image, which must be
43 /// composed of numImg subimages of the same size
44 CtrlRadialSlider( intf_thread_t *pIntf, const GenericBitmap &rBmpSeq,
45 int numImg, VarPercent &rVariable, float minAngle,
46 float maxAngle, const UString &rHelp,
47 VarBool *pVisible );
49 virtual ~CtrlRadialSlider();
51 /// Handle an event
52 virtual void handleEvent( EvtGeneric &rEvent );
54 /// Check whether coordinates are inside the control
55 virtual bool mouseOver( int x, int y ) const;
57 /// Draw the control on the given graphics
58 virtual void draw( OSGraphics &rImage, int xDest, int yDest, int w, int h );
60 /// Get the type of control (custom RTTI)
61 virtual string getType() const { return "radial_slider"; }
63 private:
64 /// Finite state machine of the control
65 FSM m_fsm;
66 /// Number of sub-images in the slider image
67 int m_numImg;
68 /// Variable associated to the slider
69 VarPercent &m_rVariable;
70 /// Min and max angles of the button
71 float m_minAngle, m_maxAngle;
72 /// Position of the cursor
73 int m_position;
74 /// Size of an image
75 int m_width, m_height;
76 /// The last received event
77 EvtGeneric *m_pEvt;
78 /// Sequence of images
79 const OSGraphics * const m_pImgSeq;
81 /// Callback objects
82 DEFINE_CALLBACK( CtrlRadialSlider, UpDown )
83 DEFINE_CALLBACK( CtrlRadialSlider, DownUp )
84 DEFINE_CALLBACK( CtrlRadialSlider, Move )
86 /// Method called when the observed variable is modified
87 virtual void onUpdate( Subject<VarPercent> &rVariable, void* );
89 /// Change the position of the cursor, with the given position of
90 /// the mouse (relative to the layout). Is blocking is true, the
91 /// the cursor cannot do more than a half turn
92 void setCursor( int posX, int posY, bool blocking );
96 #endif