Skip to content

Commit

Permalink
Merge pull request #7686 from mkortstiege/radio-label2
Browse files Browse the repository at this point in the history
[guilib] use label2 to display the radiobutton value instead of a texture
  • Loading branch information
mkortstiege committed Aug 2, 2015
2 parents c71aac5 + 71eb0f7 commit e4b2d0a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
14 changes: 10 additions & 4 deletions xbmc/guilib/GUIButtonControl.cpp
Expand Up @@ -266,14 +266,20 @@ void CGUIButtonControl::SetInvalid()

void CGUIButtonControl::SetLabel(const string &label)
{ // NOTE: No fallback for buttons at this point
m_info.SetLabel(label, "", GetParentID());
SetInvalid();
if (m_info.GetLabel(GetParentID(), false) != label)
{
m_info.SetLabel(label, "", GetParentID());
SetInvalid();
}
}

void CGUIButtonControl::SetLabel2(const string &label2)
{ // NOTE: No fallback for buttons at this point
m_info2.SetLabel(label2, "", GetParentID());
SetInvalid();
if (m_info2.GetLabel(GetParentID(), false) != label2)
{
m_info2.SetLabel(label2, "", GetParentID());
SetInvalid();
}
}

void CGUIButtonControl::SetPosition(float posX, float posY)
Expand Down
1 change: 1 addition & 0 deletions xbmc/guilib/GUIControlFactory.cpp
Expand Up @@ -1247,6 +1247,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
textureRadioOnFocus, textureRadioOnNoFocus, textureRadioOffFocus, textureRadioOffNoFocus, textureRadioOnDisabled, textureRadioOffDisabled);

((CGUIRadioButtonControl *)control)->SetLabel(strLabel);
((CGUIRadioButtonControl *)control)->SetLabel2(strLabel2);
((CGUIRadioButtonControl *)control)->SetRadioDimensions(radioPosX, radioPosY, radioWidth, radioHeight);
((CGUIRadioButtonControl *)control)->SetToggleSelect(toggleSelect);
((CGUIRadioButtonControl *)control)->SetClickActions(clickActions);
Expand Down
13 changes: 12 additions & 1 deletion xbmc/guilib/GUIRadioButtonControl.cpp
Expand Up @@ -20,6 +20,7 @@

#include "GUIRadioButtonControl.h"
#include "GUIInfoManager.h"
#include "LocalizeStrings.h"
#include "input/Key.h"

CGUIRadioButtonControl::CGUIRadioButtonControl(int parentID, int controlID, float posX, float posY, float width, float height,
Expand All @@ -45,6 +46,7 @@ CGUIRadioButtonControl::CGUIRadioButtonControl(int parentID, int controlID, floa
m_imgRadioOnDisabled.SetAspectRatio(CAspectRatio::AR_KEEP);
m_imgRadioOffDisabled.SetAspectRatio(CAspectRatio::AR_KEEP);
ControlType = GUICONTROL_RADIO;
m_useLabel2 = false;
}

CGUIRadioButtonControl::~CGUIRadioButtonControl(void)
Expand Down Expand Up @@ -87,14 +89,17 @@ void CGUIRadioButtonControl::Process(unsigned int currentTime, CDirtyRegionList
m_bSelected = selected;
}
}

m_imgRadioOnFocus.Process(currentTime);
m_imgRadioOnNoFocus.Process(currentTime);
m_imgRadioOffFocus.Process(currentTime);
m_imgRadioOffNoFocus.Process(currentTime);
m_imgRadioOnDisabled.Process(currentTime);
m_imgRadioOffDisabled.Process(currentTime);

if (m_useLabel2)
SetLabel2(g_localizeStrings.Get(m_bSelected ? 16041 : 351));

CGUIButtonControl::Process(currentTime, dirtyregions);
}

Expand Down Expand Up @@ -193,6 +198,12 @@ void CGUIRadioButtonControl::SetRadioDimensions(float posX, float posY, float wi
m_imgRadioOnDisabled.SetHeight(height);
m_imgRadioOffDisabled.SetHeight(height);
}

// use label2 to display the button value in case no
// dimensions were specified and there's no label2 yet.
if (GetLabel2().empty() && !width && !height)
m_useLabel2 = true;

SetPosition(GetXPosition(), GetYPosition());
}

Expand Down
1 change: 1 addition & 0 deletions xbmc/guilib/GUIRadioButtonControl.h
Expand Up @@ -72,4 +72,5 @@ class CGUIRadioButtonControl :
float m_radioPosX;
float m_radioPosY;
INFO::InfoPtr m_toggleSelect;
bool m_useLabel2;
};

0 comments on commit e4b2d0a

Please sign in to comment.