2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "GUISettingsSliderControl.h"
23 CGUISettingsSliderControl::CGUISettingsSliderControl(int parentID, int controlID, float posX, float posY, float width, float height, float sliderWidth, float sliderHeight, const CTextureInfo &textureFocus, const CTextureInfo &textureNoFocus, const CTextureInfo& backGroundTexture, const CTextureInfo& nibTexture, const CTextureInfo& nibTextureFocus, const CLabelInfo &labelInfo, int iType)
24 : CGUISliderControl(parentID, controlID, posX, posY, sliderWidth, sliderHeight, backGroundTexture, nibTexture,nibTextureFocus, iType)
25 , m_buttonControl(parentID, controlID, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo)
26 , m_label(posX, posY, width, height, labelInfo)
28 m_label.SetAlign((labelInfo.align & XBFONT_CENTER_Y) | XBFONT_RIGHT);
29 ControlType = GUICONTROL_SETTINGS_SLIDER;
32 CGUISettingsSliderControl::~CGUISettingsSliderControl(void)
36 void CGUISettingsSliderControl::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
40 float sliderPosX = m_buttonControl.GetXPosition() + m_buttonControl.GetWidth() - m_width - m_buttonControl.GetLabelInfo().offsetX;
41 float sliderPosY = m_buttonControl.GetYPosition() + (m_buttonControl.GetHeight() - m_height) * 0.5f;
42 CGUISliderControl::SetPosition(sliderPosX, sliderPosY);
44 m_buttonControl.SetFocus(HasFocus());
45 m_buttonControl.SetPulseOnSelect(m_pulseOnSelect);
46 m_buttonControl.SetEnabled(m_enabled);
47 m_buttonControl.DoProcess(currentTime, dirtyregions);
49 CGUISliderControl::Process(currentTime, dirtyregions);
52 void CGUISettingsSliderControl::Render()
54 m_buttonControl.Render();
55 CGUISliderControl::Render();
59 void CGUISettingsSliderControl::ProcessText()
63 changed |= m_label.SetMaxRect(m_buttonControl.GetXPosition(), m_buttonControl.GetYPosition(), m_posX - m_buttonControl.GetXPosition(), m_buttonControl.GetHeight());
64 changed |= m_label.SetText(CGUISliderControl::GetDescription());
66 changed |= m_label.SetColor(CGUILabel::COLOR_DISABLED);
68 changed |= m_label.SetColor(CGUILabel::COLOR_FOCUSED);
70 changed |= m_label.SetColor(CGUILabel::COLOR_TEXT);
76 bool CGUISettingsSliderControl::OnAction(const CAction &action)
78 return CGUISliderControl::OnAction(action);
81 void CGUISettingsSliderControl::FreeResources(bool immediately)
83 CGUISliderControl::FreeResources(immediately);
84 m_buttonControl.FreeResources(immediately);
87 void CGUISettingsSliderControl::DynamicResourceAlloc(bool bOnOff)
89 CGUISliderControl::DynamicResourceAlloc(bOnOff);
90 m_buttonControl.DynamicResourceAlloc(bOnOff);
93 void CGUISettingsSliderControl::AllocResources()
95 CGUISliderControl::AllocResources();
96 m_buttonControl.AllocResources();
99 void CGUISettingsSliderControl::SetInvalid()
101 CGUISliderControl::SetInvalid();
102 m_buttonControl.SetInvalid();
105 void CGUISettingsSliderControl::SetPosition(float posX, float posY)
107 m_buttonControl.SetPosition(posX, posY);
108 CGUISliderControl::SetInvalid();
111 void CGUISettingsSliderControl::SetWidth(float width)
113 m_buttonControl.SetWidth(width);
114 CGUISliderControl::SetInvalid();
117 void CGUISettingsSliderControl::SetHeight(float height)
119 m_buttonControl.SetHeight(height);
120 CGUISliderControl::SetInvalid();
123 void CGUISettingsSliderControl::SetEnabled(bool bEnable)
125 CGUISliderControl::SetEnabled(bEnable);
126 m_buttonControl.SetEnabled(bEnable);
129 CStdString CGUISettingsSliderControl::GetDescription() const
131 return m_buttonControl.GetDescription() + " " + CGUISliderControl::GetDescription();
134 bool CGUISettingsSliderControl::UpdateColors()
136 bool changed = CGUISliderControl::UpdateColors();
137 changed |= m_buttonControl.SetColorDiffuse(m_diffuseColor);
138 changed |= m_buttonControl.UpdateColors();