bool CGUISliderControl::ProcessSelector(CGUITexture &nib, unsigned int currentTime, float fScale, RangeSelector selector) { bool dirty = false; // we render the nib centered at the appropriate percentage, except where the nib // would overflow the background image if (m_orientation == HORIZONTAL) { dirty |= nib.SetHeight(nib.GetTextureHeight() * fScale); dirty |= nib.SetWidth(nib.GetHeight() * 2); } else { dirty |= nib.SetWidth(nib.GetTextureWidth() * fScale); dirty |= nib.SetHeight(nib.GetWidth() * 2); } CAspectRatio ratio(CAspectRatio::AR_KEEP); ratio.align = ASPECT_ALIGN_LEFT | ASPECT_ALIGNY_CENTER; dirty |= nib.SetAspectRatio(ratio); dirty |= nib.Process(currentTime); CRect rect = nib.GetRenderRect(); float offset; if (m_orientation == HORIZONTAL) { offset = GetProportion(selector) * m_width - rect.Width() / 2; if (offset > m_width - rect.Width()) offset = m_width - rect.Width(); if (offset < 0) offset = 0; dirty |= nib.SetPosition(m_guiBackground.GetXPosition() + offset, m_guiBackground.GetYPosition()); } else { offset = GetProportion(selector) * m_height - rect.Height() / 2; if (offset > m_height - rect.Height()) offset = m_height - rect.Height(); if (offset < 0) offset = 0; dirty |= nib.SetPosition(m_guiBackground.GetXPosition(), m_guiBackground.GetYPosition() + m_guiBackground.GetHeight() - offset - ((nib.GetHeight() - rect.Height()) / 2 + rect.Height())); } dirty |= nib.Process(currentTime); // need to process again as the position may have changed return dirty; }
bool CGUISliderControl::ProcessSelector(CGUITexture &nib, unsigned int currentTime, float fScaleY, RangeSelector selector) { bool dirty = false; // we render the nib centered at the appropriate percentage, except where the nib // would overflow the background image dirty |= nib.SetHeight(nib.GetTextureHeight() * fScaleY); dirty |= nib.SetWidth(nib.GetHeight() * 2); CAspectRatio ratio(CAspectRatio::AR_KEEP); ratio.align = ASPECT_ALIGN_LEFT | ASPECT_ALIGNY_CENTER; dirty |= nib.SetAspectRatio(ratio); CRect rect = nib.GetRenderRect(); float offset = GetProportion(selector) * m_width - rect.Width() / 2; if (offset > m_width - rect.Width()) offset = m_width - rect.Width(); if (offset < 0) offset = 0; dirty |= nib.SetPosition(m_guiBackground.GetXPosition() + offset, m_guiBackground.GetYPosition()); dirty |= nib.Process(currentTime); return dirty; }