1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
#pragma once
/*
* Copyright (C) 2005-2008 Team XBMC
* http://www.xbmc.org
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "GUIControl.h"
#include "GUITexture.h"
#include "GUIActionDescriptor.h"
#include "GUILabel.h"
class TiXmlNode;
class CButton
{
public:
CButton()
{
id = 0;
info = 0;
imageFocus = imageNoFocus = NULL;
};
~CButton()
{
delete imageFocus;
delete imageNoFocus;
}
int id;
int info;
std::string strLabel;
std::vector<CGUIActionDescriptor> clickActions;
CGUITexture *imageFocus;
CGUITexture *imageNoFocus;
};
class CGUIButtonScroller :
public CGUIControl
{
public:
CGUIButtonScroller(int parentID, int controlID, float posX, float posY, float width, float height, float gap, int iSlots, int iDefaultSlot, int iMovementRange, bool bHorizontal, int iAlpha, bool bWrapAround, bool bSmoothScrolling, const CTextureInfo& textureFocus, const CTextureInfo& textureNoFocus, const CLabelInfo& labelInfo);
CGUIButtonScroller(const CGUIButtonScroller &from);
virtual ~CGUIButtonScroller(void);
virtual CGUIButtonScroller *Clone() const { return new CGUIButtonScroller(*this); };
virtual bool OnAction(const CAction &action);
virtual bool OnMessage(CGUIMessage &message);
virtual void OnUp();
virtual void OnLeft();
virtual void OnRight();
virtual void OnDown();
virtual bool OnMouseOver(const CPoint &point);
virtual void Render();
virtual void AllocResources();
virtual void FreeResources(bool immediately = false);
virtual void DynamicResourceAlloc(bool bOnOff);
virtual void SetInvalid();
void ClearButtons();
void AddButton(const std::string &strLabel, const CStdString &strExecute, const int iIcon);
void SetActiveButton(int iButton);
int GetActiveButton() const;
int GetActiveButtonID() const;
virtual CStdString GetDescription() const;
virtual void SaveStates(std::vector<CControlState> &states);
void LoadButtons(TiXmlNode *node);
protected:
virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
virtual void UpdateColors();
int GetNext(int iCurrent) const;
int GetPrevious(int iCurrent);
int GetButton(int iOffset);
void DoUp();
void DoDown();
void RenderItem(float &posX, float &posY, int &iOffset, bool bText);
void GetScrollZone(float &fStartAlpha, float &fEndAlpha);
private:
// saved variables from the xml (as this control is user editable...)
int m_iXMLNumSlots;
int m_iXMLDefaultSlot;
float m_xmlPosX;
float m_xmlPosY;
float m_xmlWidth;
float m_xmlHeight;
float m_buttonGap; // gap between buttons
int m_iNumSlots; // number of button slots available
int m_iDefaultSlot; // default highlight position
int m_iMovementRange; // amoung that we can move the highlight
bool m_bHorizontal; // true if it's a horizontal button bar
int m_iAlpha; // amount of alpha (0..100)
bool m_bWrapAround; // whether the buttons wrap around or not
bool m_bSmoothScrolling; // whether there is smooth scrolling or not
int m_iCurrentSlot; // currently highlighted slot
int m_iOffset; // first item in the list
float m_scrollOffset; // offset when scrolling
bool m_bScrollUp; // true if we're scrolling up (or left)
bool m_bScrollDown; // true if scrolling down (or right)
bool m_bMoveUp; // true if we're scrolling up (or left)
bool m_bMoveDown; // true if scrolling down (or right)
float m_fScrollSpeed; // speed of scrolling
float m_fAnalogScrollSpeed; // speed of analog scroll (triggers)
// stuff we need for the buttons...
std::vector<CButton*> m_vecButtons;
typedef std::vector<CButton*>::iterator ivecButtons;
CGUITexture m_imgFocus;
CGUITexture m_imgNoFocus;
CLabelInfo m_label;
int m_iSlowScrollCount;
};
|