Permalink
Browse files

partially support progress bars in guilists. add a <progress> tag to …

…the <control> tag of the progress bar in the skin xml containing the name of the property in the CListItem that contains the value % of the progress bar
  • Loading branch information...
1 parent 8a0f443 commit 9f11fb761338202fc97f99c45836de2b71d6ca64 @opdenkamp committed Jul 29, 2011
@@ -622,6 +622,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
CStdString strTmp;
int singleInfo = 0;
CStdString strLabel;
+ CStdString strProgressProperty;
int iUrlSet=0;
int iToggleSelect;
@@ -969,6 +970,8 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
XMLUtils::GetBoolean(pControlNode, "password", bPassword);
+ GetString(pControlNode, "progress", strProgressProperty);
+
// view type
VIEW_TYPE viewType = VIEW_TYPE_NONE;
CStdString viewLabel;
@@ -1234,6 +1237,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
textureBackground, textureLeft, textureMid, textureRight,
textureOverlay, bReveal);
((CGUIProgressControl *)control)->SetInfo(singleInfo);
+ ((CGUIProgressControl *)control)->SetProperty(strProgressProperty);
}
else if (type == CGUIControl::GUICONTROL_IMAGE)
{
@@ -55,7 +55,8 @@ void CGUIListGroup::AddControl(CGUIControl *control, int position /*= -1*/)
control->GetControlType() == CGUIControl::GUICONTROL_BORDEREDIMAGE ||
control->GetControlType() == CGUIControl::GUICONTROL_MULTI_IMAGE ||
control->GetControlType() == CGUIControl::GUICONTROL_MULTISELECT ||
- control->GetControlType() == CGUIControl::GUICONTROL_TEXTBOX))
+ control->GetControlType() == CGUIControl::GUICONTROL_TEXTBOX ||
+ control->GetControlType() == CGUIControl::GUICONTROL_PROGRESS))
CLog::Log(LOGWARNING, "Trying to add unsupported control type %d", control->GetControlType());
}
CGUIControlGroup::AddControl(control, position);
@@ -21,6 +21,9 @@
#include "GUIProgressControl.h"
#include "GUIInfoManager.h"
+#include "GUIListItem.h"
+#include "GUIWindowManager.h"
+#include "FileItem.h"
CGUIProgressControl::CGUIProgressControl(int parentID, int controlID,
float posX, float posY, float width,
@@ -38,6 +41,7 @@ CGUIProgressControl::CGUIProgressControl(int parentID, int controlID,
, m_guiOverlay(posX, posY, width, height, overlayTexture)
{
m_fPercent = 0;
+ m_fUpdatedInfo = -1;
m_iInfoCode = 0;
ControlType = GUICONTROL_PROGRESS;
m_bReveal = reveal;
@@ -61,7 +65,9 @@ void CGUIProgressControl::Process(unsigned int currentTime, CDirtyRegionList &di
if (!IsDisabled())
{
float percent = m_fPercent;
- if (m_iInfoCode)
+ if (!m_strProperty.IsEmpty() && m_fUpdatedInfo >= 0)
+ m_fPercent = m_fUpdatedInfo;
+ else if (m_iInfoCode)
m_fPercent = (float)g_infoManager.GetInt(m_iInfoCode);
if (m_fPercent < 0.0f) m_fPercent = 0.0f;
if (m_fPercent > 100.0f) m_fPercent = 100.0f;
@@ -301,3 +307,30 @@ CStdString CGUIProgressControl::GetDescription() const
percent.Format("%2.f", m_fPercent);
return percent;
}
+
+void CGUIProgressControl::SetProperty(const CStdString &strProperty)
+{
+ m_strProperty = strProperty;
+}
+
+void CGUIProgressControl::UpdateInfo(const CGUIListItem *item)
+{
+ if (!m_strProperty.IsEmpty())
+ {
+ if (item && item->HasProperty(m_strProperty))
+ {
+ m_fUpdatedInfo = item->GetPropertyDouble(m_strProperty);
+ }
+ else if (!item)
+ {
+ CGUIWindow *window = g_windowManager.GetWindow(m_parentID);
+ if (window && window->HasListItems())
+ {
+ CFileItemPtr listItem = window->GetCurrentListItem();
+ m_fUpdatedInfo = listItem->GetPropertyDouble(m_strProperty);
+ }
+ }
+ }
+
+ CGUIControl::UpdateInfo(item);
+}
@@ -60,9 +60,11 @@ class CGUIProgressControl :
void SetPercentage(float fPercent);
void SetInfo(int iInfo);
int GetInfo() const {return m_iInfoCode;};
+ void SetProperty(const CStdString &strProperty);
float GetPercentage() const;
CStdString GetDescription() const;
+ virtual void UpdateInfo(const CGUIListItem *item = NULL);
protected:
virtual bool UpdateColors();
CGUITexture m_guiBackground;
@@ -73,6 +75,8 @@ class CGUIProgressControl :
CRect m_guiMidClipRect;
int m_iInfoCode;
+ CStdString m_strProperty;
+ float m_fUpdatedInfo;
float m_fPercent;
bool m_bReveal;
};

2 comments on commit 9f11fb7

@jmarshallnz

Other than the ListGroup.cpp change, I don't think any of this is necessary. Why not allow the item to be passed to GetInt() like it is for GetLabel() et. al. and hook up Listitem.Property in there? That way it's available everywhere and you don't need the includes in GUIProgressControl

@opdenkamp
Owner

yup. it's been cleaned up in 5f09cae + cd04d6e

Please sign in to comment.