}
// tries to get a integer value for use in progressbars/sliders and such
-int CGUIInfoManager::GetInt(int info, int contextWindow) const
+int CGUIInfoManager::GetInt(int info, int contextWindow, const CGUIListItem *item /* = NULL */) const
{
+ if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
+ return GetMultiInfoInt(m_multiInfo[info - MULTI_INFO_START], contextWindow);
+
+ if (info >= LISTITEM_START && info <= LISTITEM_END)
+ return GetItemInt(item, info);
+
switch( info )
{
case PLAYER_VOLUME:
return (info.m_info < 0) ? !bReturn : bReturn;
}
+int CGUIInfoManager::GetMultiInfoInt(const GUIInfo &info, int contextWindow) const
+{
+ if (info.m_info >= LISTITEM_START && info.m_info <= LISTITEM_END)
+ {
+ CFileItemPtr item;
+ CGUIWindow *window = NULL;
+
+ int data1 = info.GetData1();
+ if (!data1) // No container specified, so we lookup the current view container
+ {
+ window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
+ if (window && window->IsMediaWindow())
+ data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
+ }
+
+ if (!window) // If we don't have a window already (from lookup above), get one
+ window = GetWindowWithCondition(contextWindow, 0);
+
+ if (window)
+ {
+ const CGUIControl *control = window->GetControl(data1);
+ if (control && control->IsContainer())
+ item = boost::static_pointer_cast<CFileItem>(((CGUIBaseContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()));
+ }
+
+ if (item) // If we got a valid item, do the lookup
+ return GetItemInt(item.get(), info.m_info);
+ }
+
+ return 0;
+}
+
/// \brief Examines the multi information sent and returns the string as appropriate
CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWindow) const
{
return (int)m_stringParameters.size() - 1;
}
+int CGUIInfoManager::GetItemInt(const CGUIListItem *item, int info) const
+{
+ if (!item) return 0;
+
+ if (info >= LISTITEM_PROPERTY_START && info - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
+ { // grab the property
+ CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START];
+ CStdString val = item->GetProperty(property);
+ return atoi(val);
+ }
+
+ switch (info)
+ {
+ /* add integer LISTITEM_ here */
+ break;
+ }
+
+ return 0;
+}
+
CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info) const
{
if (!item) return "";
bool changed = false;
if (!IsDisabled())
- {
- float percent = m_fPercent;
- 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;
- changed |= (percent != m_fPercent);
-
- if (m_width == 0)
- m_width = m_guiBackground.GetTextureWidth();
- if (m_height == 0)
- m_height = m_guiBackground.GetTextureHeight();
-
- changed |= m_guiBackground.SetHeight(m_height);
- changed |= m_guiBackground.SetWidth(m_width);
-
- float fScaleX, fScaleY;
- fScaleY = m_guiBackground.GetTextureHeight() ? m_height / m_guiBackground.GetTextureHeight() : 1.0f;
- fScaleX = m_guiBackground.GetTextureWidth() ? m_width / m_guiBackground.GetTextureWidth() : 1.0f;
-
- float posX = m_guiBackground.GetXPosition();
- float posY = m_guiBackground.GetYPosition();
-
- if (m_guiLeft.GetFileName().IsEmpty() && m_guiRight.GetFileName().IsEmpty())
- { // rendering without left and right image - fill the mid image completely
- float width = m_fPercent * m_width * 0.01f;
- float offset = fabs(fScaleY * 0.5f * (m_guiMid.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
- if (offset > 0) // Center texture to the background if necessary
- changed |= m_guiMid.SetPosition(posX, posY + offset);
- else
- changed |= m_guiMid.SetPosition(posX, posY);
- changed |= m_guiMid.SetHeight(fScaleY * m_guiMid.GetTextureHeight());
- if (m_bReveal)
- {
- changed |= m_guiMid.SetWidth(m_width);
- float x = posX, y = posY + offset, w = width, h = fScaleY * m_guiMid.GetTextureHeight();
- m_guiMidClipRect = CRect(x, y, x + w, y + h);
- }
- else
- {
- changed |= m_guiMid.SetWidth(width);
- m_guiMidClipRect = CRect();
- }
- }
- else
- {
- float fWidth = m_fPercent;
- float fFullWidth = m_guiBackground.GetTextureWidth() - m_guiLeft.GetTextureWidth() - m_guiRight.GetTextureWidth();
- fWidth /= 100.0f;
- fWidth *= fFullWidth;
-
- float offset = fabs(fScaleY * 0.5f * (m_guiLeft.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
- if (offset > 0) // Center texture to the background if necessary
- changed |= m_guiLeft.SetPosition(posX, posY + offset);
- else
- changed |= m_guiLeft.SetPosition(posX, posY);
- changed |= m_guiLeft.SetHeight(fScaleY * m_guiLeft.GetTextureHeight());
- changed |= m_guiLeft.SetWidth(fScaleX * m_guiLeft.GetTextureWidth());
-
- posX += fScaleX * m_guiLeft.GetTextureWidth();
- offset = fabs(fScaleY * 0.5f * (m_guiMid.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
- if (offset > 0) // Center texture to the background if necessary
- changed |= m_guiMid.SetPosition(posX, posY + offset);
- else
- changed |= m_guiMid.SetPosition(posX, posY);
- changed |= m_guiMid.SetHeight(fScaleY * m_guiMid.GetTextureHeight());
- if (m_bReveal)
- {
- changed |= m_guiMid.SetWidth(fScaleX * fFullWidth);
- float x = posX, y = posY + offset, w = fScaleX * fWidth, h = fScaleY * m_guiMid.GetTextureHeight();
- m_guiMidClipRect = CRect(x, y, x + w, y + h);
- }
- else
- {
- changed |= m_guiMid.SetWidth(fScaleX * fWidth);
- m_guiMidClipRect = CRect();
- }
-
- posX += fWidth * fScaleX;
-
- offset = fabs(fScaleY * 0.5f * (m_guiRight.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
- if (offset > 0) // Center texture to the background if necessary
- changed |= m_guiRight.SetPosition(posX, posY + offset);
- else
- changed |= m_guiRight.SetPosition(posX, posY);
- changed |= m_guiRight.SetHeight(fScaleY * m_guiRight.GetTextureHeight());
- changed |= m_guiRight.SetWidth(fScaleX * m_guiRight.GetTextureWidth());
- }
- float offset = fabs(fScaleY * 0.5f * (m_guiOverlay.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
- if (offset > 0) // Center texture to the background if necessary
- changed |= m_guiOverlay.SetPosition(m_guiBackground.GetXPosition(), m_guiBackground.GetYPosition() + offset);
- else
- changed |= m_guiOverlay.SetPosition(m_guiBackground.GetXPosition(), m_guiBackground.GetYPosition());
- changed |= m_guiOverlay.SetHeight(fScaleY * m_guiOverlay.GetTextureHeight());
- changed |= m_guiOverlay.SetWidth(fScaleX * m_guiOverlay.GetTextureWidth());
- }
-
+ changed |= UpdateLayout();
changed |= m_guiBackground.Process(currentTime);
changed |= m_guiMid.Process(currentTime);
changed |= m_guiLeft.Process(currentTime);
percent.Format("%2.f", m_fPercent);
return percent;
}
+
+bool CGUIProgressControl::UpdateLayout(void)
+{
+ bool bChanged(false);
+
+ if (m_width == 0)
+ m_width = m_guiBackground.GetTextureWidth();
+ if (m_height == 0)
+ m_height = m_guiBackground.GetTextureHeight();
+
+ bChanged |= m_guiBackground.SetHeight(m_height);
+ bChanged |= m_guiBackground.SetWidth(m_width);
+
+ float fScaleX, fScaleY;
+ fScaleY = m_guiBackground.GetTextureHeight() ? m_height / m_guiBackground.GetTextureHeight() : 1.0f;
+ fScaleX = m_guiBackground.GetTextureWidth() ? m_width / m_guiBackground.GetTextureWidth() : 1.0f;
+
+ float posX = m_guiBackground.GetXPosition();
+ float posY = m_guiBackground.GetYPosition();
+
+ if (m_guiLeft.GetFileName().IsEmpty() && m_guiRight.GetFileName().IsEmpty())
+ { // rendering without left and right image - fill the mid image completely
+ float width = m_fPercent * m_width * 0.01f;
+ float offset = fabs(fScaleY * 0.5f * (m_guiMid.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
+ if (offset > 0) // Center texture to the background if necessary
+ bChanged |= m_guiMid.SetPosition(posX, posY + offset);
+ else
+ bChanged |= m_guiMid.SetPosition(posX, posY);
+ bChanged |= m_guiMid.SetHeight(fScaleY * m_guiMid.GetTextureHeight());
+ if (m_bReveal)
+ {
+ bChanged |= m_guiMid.SetWidth(m_width);
+ float x = posX, y = posY + offset, w = width, h = fScaleY * m_guiMid.GetTextureHeight();
+ m_guiMidClipRect = CRect(x, y, x + w, y + h);
+ }
+ else
+ {
+ bChanged |= m_guiMid.SetWidth(width);
+ m_guiMidClipRect = CRect();
+ }
+ }
+ else
+ {
+ float fWidth = m_fPercent;
+ float fFullWidth = m_guiBackground.GetTextureWidth() - m_guiLeft.GetTextureWidth() - m_guiRight.GetTextureWidth();
+ fWidth /= 100.0f;
+ fWidth *= fFullWidth;
+
+ float offset = fabs(fScaleY * 0.5f * (m_guiLeft.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
+ if (offset > 0) // Center texture to the background if necessary
+ bChanged |= m_guiLeft.SetPosition(posX, posY + offset);
+ else
+ bChanged |= m_guiLeft.SetPosition(posX, posY);
+ bChanged |= m_guiLeft.SetHeight(fScaleY * m_guiLeft.GetTextureHeight());
+ bChanged |= m_guiLeft.SetWidth(fScaleX * m_guiLeft.GetTextureWidth());
+
+ posX += fScaleX * m_guiLeft.GetTextureWidth();
+ offset = fabs(fScaleY * 0.5f * (m_guiMid.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
+ if (offset > 0) // Center texture to the background if necessary
+ bChanged |= m_guiMid.SetPosition(posX, posY + offset);
+ else
+ bChanged |= m_guiMid.SetPosition(posX, posY);
+ bChanged |= m_guiMid.SetHeight(fScaleY * m_guiMid.GetTextureHeight());
+ if (m_bReveal)
+ {
+ bChanged |= m_guiMid.SetWidth(fScaleX * fFullWidth);
+ float x = posX, y = posY + offset, w = fScaleX * fWidth, h = fScaleY * m_guiMid.GetTextureHeight();
+ m_guiMidClipRect = CRect(x, y, x + w, y + h);
+ }
+ else
+ {
+ bChanged |= m_guiMid.SetWidth(fScaleX * fWidth);
+ m_guiMidClipRect = CRect();
+ }
+
+ posX += fWidth * fScaleX;
+
+ offset = fabs(fScaleY * 0.5f * (m_guiRight.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
+ if (offset > 0) // Center texture to the background if necessary
+ bChanged |= m_guiRight.SetPosition(posX, posY + offset);
+ else
+ bChanged |= m_guiRight.SetPosition(posX, posY);
+ bChanged |= m_guiRight.SetHeight(fScaleY * m_guiRight.GetTextureHeight());
+ bChanged |= m_guiRight.SetWidth(fScaleX * m_guiRight.GetTextureWidth());
+ }
+ float offset = fabs(fScaleY * 0.5f * (m_guiOverlay.GetTextureHeight() - m_guiBackground.GetTextureHeight()));
+ if (offset > 0) // Center texture to the background if necessary
+ bChanged |= m_guiOverlay.SetPosition(m_guiBackground.GetXPosition(), m_guiBackground.GetYPosition() + offset);
+ else
+ bChanged |= m_guiOverlay.SetPosition(m_guiBackground.GetXPosition(), m_guiBackground.GetYPosition());
+ bChanged |= m_guiOverlay.SetHeight(fScaleY * m_guiOverlay.GetTextureHeight());
+ bChanged |= m_guiOverlay.SetWidth(fScaleX * m_guiOverlay.GetTextureWidth());
+
+ return bChanged;
+}
+
+void CGUIProgressControl::UpdateInfo(const CGUIListItem *item)
+{
+ if (!IsDisabled())
+ {
+ float percent = m_fPercent;
+ if (m_iInfoCode)
+ m_fPercent = (float)g_infoManager.GetInt(m_iInfoCode, m_parentID, item);
+
+ if (m_fPercent < 0.0f) m_fPercent = 0.0f;
+ if (m_fPercent > 100.0f) m_fPercent = 100.0f;
+ }
+}