Skip to content

Commit

Permalink
[guilib] Add vertical orientation to GUISettingsSliderControl
Browse files Browse the repository at this point in the history
  • Loading branch information
AchimTuran committed Jul 13, 2016
1 parent de07785 commit 5152880
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
14 changes: 11 additions & 3 deletions xbmc/guilib/GUIControlFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,6 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl

XMLUtils::GetFloat(pControlNode, "markwidth", checkWidth);
XMLUtils::GetFloat(pControlNode, "markheight", checkHeight);
XMLUtils::GetFloat(pControlNode, "sliderwidth", sliderWidth);
XMLUtils::GetFloat(pControlNode, "sliderheight", sliderHeight);
if (!GetTexture(pControlNode, "textureradioonfocus", textureRadioOnFocus) || !GetTexture(pControlNode, "textureradioonnofocus", textureRadioOnNoFocus))
{
GetTexture(pControlNode, "textureradiofocus", textureRadioOnFocus); // backward compatibility
Expand Down Expand Up @@ -963,8 +961,18 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
{
StringUtils::ToLower(strTmp);
if (strTmp == "horizontal")
{
orientation = HORIZONTAL;
// default orientation for a settings slider is vertical
// consequently it has to changed here
float tmpVal = sliderWidth;
sliderWidth = sliderHeight;
sliderHeight = tmpVal;
}
}

XMLUtils::GetFloat(pControlNode, "sliderwidth", sliderWidth);
XMLUtils::GetFloat(pControlNode, "sliderheight", sliderHeight);
XMLUtils::GetFloat(pControlNode, "itemgap", buttonGap);
XMLUtils::GetInt(pControlNode, "movement", iMovementRange);
GetAspectRatio(pControlNode, "aspectratio", aspect);
Expand Down Expand Up @@ -1257,7 +1265,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
{
control = new CGUISettingsSliderControl(
parentID, id, posX, posY, width, height, sliderWidth, sliderHeight, textureFocus, textureNoFocus,
textureBar, textureNib, textureNibFocus, labelInfo, SLIDER_CONTROL_TYPE_PERCENTAGE);
textureBar, textureNib, textureNibFocus, labelInfo, SLIDER_CONTROL_TYPE_PERCENTAGE, orientation);

((CGUISettingsSliderControl *)control)->SetText(strLabel);
((CGUISettingsSliderControl *)control)->SetInfo(singleInfo);
Expand Down
38 changes: 32 additions & 6 deletions xbmc/guilib/GUISettingsSliderControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@

#include "GUISettingsSliderControl.h"

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)
: CGUISliderControl(parentID, controlID, posX, posY, sliderWidth, sliderHeight, backGroundTexture, nibTexture,nibTextureFocus, iType, HORIZONTAL)
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, ORIENTATION orientation)
: CGUISliderControl(parentID, controlID, posX, posY, sliderWidth, sliderHeight, backGroundTexture, nibTexture,nibTextureFocus, iType, orientation)
, m_buttonControl(parentID, controlID, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo)
, m_label(posX, posY, width, height, labelInfo)
{
m_label.SetAlign((labelInfo.align & XBFONT_CENTER_Y) | XBFONT_RIGHT);
if (CGUISliderControl::m_orientation == HORIZONTAL)
{
m_label.SetAlign((labelInfo.align & XBFONT_CENTER_Y) | XBFONT_RIGHT);
}
else
{
m_label.SetAlign((labelInfo.align & XBFONT_CENTER_Y) | XBFONT_CENTER_X);
m_buttonControl.m_label.SetAlign((labelInfo.align & XBFONT_CENTER_Y) | XBFONT_CENTER_X);
}
ControlType = GUICONTROL_SETTINGS_SLIDER;
}

Expand All @@ -37,8 +45,18 @@ void CGUISettingsSliderControl::Process(unsigned int currentTime, CDirtyRegionLi
{
if (m_bInvalidated)
{
float sliderPosX = m_buttonControl.GetXPosition() + m_buttonControl.GetWidth() - m_width - m_buttonControl.GetLabelInfo().offsetX;
float sliderPosY = m_buttonControl.GetYPosition() + (m_buttonControl.GetHeight() - m_height) * 0.5f;
float sliderPosX = 0.0f;
float sliderPosY = 0.0f;
if (CGUISliderControl::m_orientation == HORIZONTAL)
{
sliderPosX = m_buttonControl.GetXPosition() + m_buttonControl.GetWidth() - CGUISliderControl::m_width - m_buttonControl.GetLabelInfo().offsetX;
sliderPosY = m_buttonControl.GetYPosition() + (m_buttonControl.GetHeight() - CGUISliderControl::m_height)*0.5f;
}
else
{
sliderPosX = m_buttonControl.GetXPosition() + m_buttonControl.GetWidth()*0.5f - CGUISliderControl::m_width*0.5f;
sliderPosY = m_buttonControl.GetYPosition() + m_buttonControl.GetHeight()*0.5f - CGUISliderControl::m_height*0.5f;
}
CGUISliderControl::SetPosition(sliderPosX, sliderPosY);
}
m_buttonControl.SetFocus(HasFocus());
Expand All @@ -60,7 +78,15 @@ void CGUISettingsSliderControl::ProcessText()
{
bool changed = false;

changed |= m_label.SetMaxRect(m_buttonControl.GetXPosition(), m_buttonControl.GetYPosition(), m_posX - m_buttonControl.GetXPosition(), m_buttonControl.GetHeight());
if (CGUISliderControl::m_orientation == HORIZONTAL)
{
changed |= m_label.SetMaxRect(m_buttonControl.GetXPosition(), m_buttonControl.GetYPosition(), m_posX - m_buttonControl.GetXPosition(), m_buttonControl.GetHeight());
}
else
{
changed |= m_label.SetMaxRect(m_buttonControl.GetXPosition(), m_buttonControl.GetYPosition(), m_buttonControl.GetWidth(), (m_buttonControl.GetHeight() - CGUISettingsSliderControl::m_height)*0.5f);
changed |= m_buttonControl.m_label.SetMaxRect(m_buttonControl.GetXPosition(), CGUISliderControl::m_posY + CGUISettingsSliderControl::m_height, m_buttonControl.GetWidth(), (m_buttonControl.GetHeight() - CGUISettingsSliderControl::m_height)*0.5f);
}
changed |= m_label.SetText(CGUISliderControl::GetDescription());
if (IsDisabled())
changed |= m_label.SetColor(CGUILabel::COLOR_DISABLED);
Expand Down
2 changes: 1 addition & 1 deletion xbmc/guilib/GUISettingsSliderControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CGUISettingsSliderControl :
public CGUISliderControl
{
public:
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);
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, ORIENTATION orientation);
virtual ~CGUISettingsSliderControl(void);
virtual CGUISettingsSliderControl *Clone() const { return new CGUISettingsSliderControl(*this); };

Expand Down

0 comments on commit 5152880

Please sign in to comment.