Fix keymap.
[vuplus_xbmc] / xbmc / guilib / GUIMoverControl.h
1 /*!
2 \file GUIMoverControl.h
3 \brief
4 */
5
6 #ifndef GUILIB_GUIMoverCONTROL_H
7 #define GUILIB_GUIMoverCONTROL_H
8
9 #pragma once
10
11 /*
12  *      Copyright (C) 2005-2013 Team XBMC
13  *      http://xbmc.org
14  *
15  *  This Program is free software; you can redistribute it and/or modify
16  *  it under the terms of the GNU General Public License as published by
17  *  the Free Software Foundation; either version 2, or (at your option)
18  *  any later version.
19  *
20  *  This Program is distributed in the hope that it will be useful,
21  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  *  GNU General Public License for more details.
24  *
25  *  You should have received a copy of the GNU General Public License
26  *  along with XBMC; see the file COPYING.  If not, see
27  *  <http://www.gnu.org/licenses/>.
28  *
29  */
30
31 #include "GUITexture.h"
32 #include "GUIControl.h"
33
34 #define ALLOWED_DIRECTIONS_ALL   0
35 #define ALLOWED_DIRECTIONS_UPDOWN  1
36 #define ALLOWED_DIRECTIONS_LEFTRIGHT 2
37
38 #define DIRECTION_NONE 0
39 #define DIRECTION_UP 1
40 #define DIRECTION_DOWN 2
41 #define DIRECTION_LEFT 3
42 #define DIRECTION_RIGHT 4
43
44 // normal alignment is TOP LEFT 0 = topleft, 1 = topright
45 #define ALIGN_RIGHT   1
46 #define ALIGN_BOTTOM  2
47
48 /*!
49  \ingroup controls
50  \brief
51  */
52 class CGUIMoverControl : public CGUIControl
53 {
54 public:
55   CGUIMoverControl(int parentID, int controlID,
56                    float posX, float posY, float width, float height,
57                    const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus);
58
59   virtual ~CGUIMoverControl(void);
60   virtual CGUIMoverControl *Clone() const { return new CGUIMoverControl(*this); };
61
62   virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
63   virtual void Render();
64   virtual bool OnAction(const CAction &action);
65   virtual void OnUp();
66   virtual void OnDown();
67   virtual void OnLeft();
68   virtual void OnRight();
69   virtual void AllocResources();
70   virtual void FreeResources(bool immediately = false);
71   virtual void DynamicResourceAlloc(bool bOnOff);
72   virtual void SetInvalid();
73   virtual void SetPosition(float posX, float posY);
74   void SetLimits(int iX1, int iY1, int iX2, int iY2);
75   void SetLocation(int iLocX, int iLocY, bool bSetPosition = true);
76   int GetXLocation() const { return m_iLocationX;};
77   int GetYLocation() const { return m_iLocationY;};
78   virtual bool CanFocus() const { return true; };
79
80 protected:
81   virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
82   virtual bool UpdateColors();
83   bool SetAlpha(unsigned char alpha);
84   void UpdateSpeed(int nDirection);
85   void Move(int iX, int iY);
86   CGUITexture m_imgFocus;
87   CGUITexture m_imgNoFocus;
88   unsigned int m_frameCounter;
89   unsigned int m_lastMoveTime;
90   int m_nDirection;
91   float m_fSpeed;
92   float m_fAnalogSpeed;
93   float m_fMaxSpeed;
94   float m_fAcceleration;
95   int m_iX1, m_iX2, m_iY1, m_iY2;
96   int m_iLocationX, m_iLocationY;
97 };
98 #endif