1 /*****************************************************************************
2 * ctrl_radialslider.hpp
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
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"
39 class CtrlRadialSlider: public CtrlGeneric, public Observer<VarPercent>
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,
49 virtual ~CtrlRadialSlider();
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"; }
64 /// Finite state machine of the control
66 /// Number of sub-images in the slider image
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
75 int m_width, m_height;
76 /// The last received event
78 /// Sequence of images
79 OSGraphics *m_pImgSeq;
80 /// Last saved position
84 DEFINE_CALLBACK( CtrlRadialSlider, UpDown )
85 DEFINE_CALLBACK( CtrlRadialSlider, DownUp )
86 DEFINE_CALLBACK( CtrlRadialSlider, Move )
88 /// Method called when the observed variable is modified
89 virtual void onUpdate( Subject<VarPercent> &rVariable, void* );
91 /// Change the position of the cursor, with the given position of
92 /// the mouse (relative to the layout). Is blocking is true, the
93 /// the cursor cannot do more than a half turn
94 void setCursor( int posX, int posY, bool blocking );