diff options
author | AlTheKiller <AlTheKiller@svn> | 2009-09-23 01:49:50 +0000 |
---|---|---|
committer | AlTheKiller <AlTheKiller@svn> | 2009-09-23 01:49:50 +0000 |
commit | 45285e8a9300cd754a760560640b75b09f98035e (patch) | |
tree | ad9f093885ad5c98e9dd4156674e7691c22ed0a2 /guilib/GUIButtonScroller.h |
step 3/4: Move linuxport to trunk. How'd I get roped into this?
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@23097 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'guilib/GUIButtonScroller.h')
-rw-r--r-- | guilib/GUIButtonScroller.h | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/guilib/GUIButtonScroller.h b/guilib/GUIButtonScroller.h new file mode 100644 index 0000000000..76d4e5f34a --- /dev/null +++ b/guilib/GUIButtonScroller.h @@ -0,0 +1,128 @@ +#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" + +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 bool OnMouseClick(int button, const CPoint &point); + virtual bool OnMouseWheel(char wheel, const CPoint &point); + virtual void Render(); + virtual void AllocResources(); + virtual void FreeResources(); + virtual void DynamicResourceAlloc(bool bOnOff); + 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 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; +}; |