]> git.sesse.net Git - vlc/blob - modules/gui/skins2/controls/ctrl_radialslider.hpp
skins2: cosmetic
[vlc] / modules / gui / skins2 / controls / ctrl_radialslider.hpp
1 /*****************************************************************************
2  * ctrl_radialslider.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 #ifndef CTRL_RADIALSLIDER_HPP
26 #define CTRL_RADIALSLIDER_HPP
27
28 #include "ctrl_generic.hpp"
29 #include "../utils/fsm.hpp"
30 #include "../utils/observer.hpp"
31
32
33 class GenericBitmap;
34 class OSGraphics;
35 class VarPercent;
36
37
38 /// Radial slider
39 class CtrlRadialSlider: public CtrlGeneric, public Observer<VarPercent>
40 {
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 );
48
49     virtual ~CtrlRadialSlider();
50
51     /// Handle an event
52     virtual void handleEvent( EvtGeneric &rEvent );
53
54     /// Check whether coordinates are inside the control
55     virtual bool mouseOver( int x, int y ) const;
56
57     /// Draw the control on the given graphics
58     virtual void draw( OSGraphics &rImage, int xDest, int yDest, int w, int h );
59
60     /// Get the type of control (custom RTTI)
61     virtual string getType() const { return "radial_slider"; }
62
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     OSGraphics *m_pImgSeq;
80     /// Last saved position
81     int m_lastPos;
82
83     /// Callback objects
84     DEFINE_CALLBACK( CtrlRadialSlider, UpDown )
85     DEFINE_CALLBACK( CtrlRadialSlider, DownUp )
86     DEFINE_CALLBACK( CtrlRadialSlider, Move )
87
88     /// Method called when the observed variable is modified
89     virtual void onUpdate( Subject<VarPercent> &rVariable, void* );
90
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 );
95 };
96
97
98 #endif