aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/guilib/GUIControlFactory.cpp4
-rw-r--r--xbmc/guilib/GUIControlFactory.h23
-rw-r--r--xbmc/guilib/GUIWindow.cpp8
-rw-r--r--xbmc/guilib/VisibleEffect.cpp33
4 files changed, 35 insertions, 33 deletions
diff --git a/xbmc/guilib/GUIControlFactory.cpp b/xbmc/guilib/GUIControlFactory.cpp
index f31b41fe68..629aecc165 100644
--- a/xbmc/guilib/GUIControlFactory.cpp
+++ b/xbmc/guilib/GUIControlFactory.cpp
@@ -1054,8 +1054,8 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
if (cam)
{
hasCamera = true;
- cam->QueryFloatAttribute("x", &camera.x);
- cam->QueryFloatAttribute("y", &camera.y);
+ camera.x = ParsePosition(cam->Attribute("x"), width);
+ camera.y = ParsePosition(cam->Attribute("y"), height);
}
if (XMLUtils::GetFloat(pControlNode, "depth", stereo))
diff --git a/xbmc/guilib/GUIControlFactory.h b/xbmc/guilib/GUIControlFactory.h
index ce9177e3d0..b8eea6a261 100644
--- a/xbmc/guilib/GUIControlFactory.h
+++ b/xbmc/guilib/GUIControlFactory.h
@@ -80,6 +80,18 @@ public:
\param parentID The parent id
\return true if a valid info label was read, false otherwise
*/
+
+ /*! \brief Parse a position string
+ Handles strings of the form
+ ### number of pixels
+ ###r number of pixels measured from the right
+ ###% percentage of parent size
+ \param pos the string to parse.
+ \param parentSize the size of the parent.
+ \sa GetPosition
+ */
+ static float ParsePosition(const char* pos, const float parentSize);
+
static bool GetInfoLabelFromElement(const TiXmlElement *element, CGUIInfoLabel &infoLabel, int parentID);
static void GetInfoLabel(const TiXmlNode *pControlNode, const std::string &labelTag, CGUIInfoLabel &infoLabel, int parentID);
static void GetInfoLabels(const TiXmlNode *pControlNode, const std::string &labelTag, std::vector<CGUIInfoLabel> &infoLabels, int parentID);
@@ -98,17 +110,6 @@ private:
static bool GetFloatRange(const TiXmlNode* pRootNode, const char* strTag, float& iMinValue, float& iMaxValue, float& iIntervalValue);
static bool GetIntRange(const TiXmlNode* pRootNode, const char* strTag, int& iMinValue, int& iMaxValue, int& iIntervalValue);
- /*! \brief Parse a position string
- Handles strings of the form
- ### number of pixels
- ###r number of pixels measured from the right
- ###% percentage of parent size
- \param pos the string to parse.
- \param parentSize the size of the parent.
- \sa GetPosition
- */
- static float ParsePosition(const char* pos, const float parentSize);
-
/*! \brief Get the value of a position tag from XML
Handles both absolute and relative values.
\param node the <control> XML node.
diff --git a/xbmc/guilib/GUIWindow.cpp b/xbmc/guilib/GUIWindow.cpp
index 70f7063f62..07f200b832 100644
--- a/xbmc/guilib/GUIWindow.cpp
+++ b/xbmc/guilib/GUIWindow.cpp
@@ -229,8 +229,8 @@ bool CGUIWindow::Load(TiXmlElement* pRootElement)
while (originElement)
{
COrigin origin;
- originElement->QueryFloatAttribute("x", &origin.x);
- originElement->QueryFloatAttribute("y", &origin.y);
+ origin.x = CGUIControlFactory::ParsePosition(originElement->Attribute("x"), static_cast<float>(m_coordsRes.iWidth));
+ origin.y = CGUIControlFactory::ParsePosition(originElement->Attribute("y"), static_cast<float>(m_coordsRes.iHeight));
if (originElement->FirstChild())
origin.condition = g_infoManager.Register(originElement->FirstChild()->Value(), GetID());
m_origins.push_back(origin);
@@ -239,8 +239,8 @@ bool CGUIWindow::Load(TiXmlElement* pRootElement)
}
else if (strValue == "camera")
{ // z is fixed
- pChild->QueryFloatAttribute("x", &m_camera.x);
- pChild->QueryFloatAttribute("y", &m_camera.y);
+ m_camera.x = CGUIControlFactory::ParsePosition(pChild->Attribute("x"), static_cast<float>(m_coordsRes.iWidth));
+ m_camera.y = CGUIControlFactory::ParsePosition(pChild->Attribute("y"), static_cast<float>(m_coordsRes.iHeight));
m_hasCamera = true;
}
else if (strValue == "depth" && pChild->FirstChild())
diff --git a/xbmc/guilib/VisibleEffect.cpp b/xbmc/guilib/VisibleEffect.cpp
index 471bf7e090..b4e642504d 100644
--- a/xbmc/guilib/VisibleEffect.cpp
+++ b/xbmc/guilib/VisibleEffect.cpp
@@ -26,6 +26,7 @@
#include "Tween.h"
#include "utils/XBMCTinyXML.h"
#include "utils/XMLUtils.h"
+#include "GUIControlFactory.h"
CAnimEffect::CAnimEffect(const TiXmlElement *node, EFFECT_TYPE effect)
{
@@ -268,21 +269,21 @@ CZoomEffect::CZoomEffect(const TiXmlElement *node, const CRect &rect) : CAnimEff
std::vector<std::string> params = StringUtils::Split(start, ",");
if (params.size() == 1)
{
- m_startX = (float)atof(params[0].c_str());
+ m_startX = CGUIControlFactory::ParsePosition(params[0].c_str(), rect.Width());
m_startY = m_startX;
}
else if (params.size() == 2)
{
- m_startX = (float)atof(params[0].c_str());
- m_startY = (float)atof(params[1].c_str());
+ m_startX = CGUIControlFactory::ParsePosition(params[0].c_str(), rect.Width());
+ m_startY = CGUIControlFactory::ParsePosition(params[1].c_str(), rect.Height());
}
else if (params.size() == 4)
{ // format is start="x,y,width,height"
// use width and height from our rect to calculate our sizing
- startPosX = (float)atof(params[0].c_str());
- startPosY = (float)atof(params[1].c_str());
- m_startX = (float)atof(params[2].c_str());
- m_startY = (float)atof(params[3].c_str());
+ startPosX = CGUIControlFactory::ParsePosition(params[0].c_str(), rect.Width());
+ startPosY = CGUIControlFactory::ParsePosition(params[1].c_str(), rect.Height());
+ m_startX = CGUIControlFactory::ParsePosition(params[2].c_str(), rect.Width());
+ m_startY = CGUIControlFactory::ParsePosition(params[3].c_str(), rect.Height());
m_startX *= 100.0f / width;
m_startY *= 100.0f / height;
}
@@ -293,21 +294,21 @@ CZoomEffect::CZoomEffect(const TiXmlElement *node, const CRect &rect) : CAnimEff
std::vector<std::string> params = StringUtils::Split(end, ",");
if (params.size() == 1)
{
- m_endX = (float)atof(params[0].c_str());
+ m_endX = CGUIControlFactory::ParsePosition(params[0].c_str(), rect.Width());
m_endY = m_endX;
}
else if (params.size() == 2)
{
- m_endX = (float)atof(params[0].c_str());
- m_endY = (float)atof(params[1].c_str());
+ m_endX = CGUIControlFactory::ParsePosition(params[0].c_str(), rect.Width());
+ m_endY = CGUIControlFactory::ParsePosition(params[1].c_str(), rect.Height());
}
else if (params.size() == 4)
{ // format is start="x,y,width,height"
// use width and height from our rect to calculate our sizing
- endPosX = (float)atof(params[0].c_str());
- endPosY = (float)atof(params[1].c_str());
- m_endX = (float)atof(params[2].c_str());
- m_endY = (float)atof(params[3].c_str());
+ endPosX = CGUIControlFactory::ParsePosition(params[0].c_str(), rect.Width());
+ endPosY = CGUIControlFactory::ParsePosition(params[1].c_str(), rect.Height());
+ m_endX = CGUIControlFactory::ParsePosition(params[2].c_str(), rect.Width());
+ m_endY = CGUIControlFactory::ParsePosition(params[3].c_str(), rect.Height());
m_endX *= 100.0f / width;
m_endY *= 100.0f / height;
}
@@ -321,9 +322,9 @@ CZoomEffect::CZoomEffect(const TiXmlElement *node, const CRect &rect) : CAnimEff
{
std::vector<std::string> commaSeparated = StringUtils::Split(centerPos, ",");
if (commaSeparated.size() > 1)
- m_center.y = (float)atof(commaSeparated[1].c_str());
+ m_center.y = CGUIControlFactory::ParsePosition(commaSeparated[1].c_str(), rect.Height());
if (!commaSeparated.empty())
- m_center.x = (float)atof(commaSeparated[0].c_str());
+ m_center.x = CGUIControlFactory::ParsePosition(commaSeparated[0].c_str(), rect.Width());
}
}
else