Small tweaks to pull request, remove unused code, use roundf instead of adding +0.5
This commit is contained in:
parent
17f7f84597
commit
a310550904
@ -436,15 +436,6 @@ void SpinnerWidget::setCustomText(const core::stringw& text)
|
|||||||
|
|
||||||
void SpinnerWidget::onClick()
|
void SpinnerWidget::onClick()
|
||||||
{
|
{
|
||||||
int x = m_x;
|
|
||||||
int y = m_y;
|
|
||||||
|
|
||||||
if (m_parent != NULL)
|
|
||||||
{
|
|
||||||
x += m_parent->getAbsolutePosition().UpperLeftCorner.X;
|
|
||||||
y += m_parent->getAbsolutePosition().UpperLeftCorner.Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_children[1].m_deactivated ||
|
if (m_children[1].m_deactivated ||
|
||||||
m_children[1].m_properties[PROP_ID] != "spinnerbody" ||
|
m_children[1].m_properties[PROP_ID] != "spinnerbody" ||
|
||||||
!isGauge())
|
!isGauge())
|
||||||
@ -458,14 +449,15 @@ void SpinnerWidget::onClick()
|
|||||||
core::recti body_rect
|
core::recti body_rect
|
||||||
= m_children[1].getIrrlichtElement()->getAbsolutePosition();
|
= m_children[1].getIrrlichtElement()->getAbsolutePosition();
|
||||||
|
|
||||||
if(body_rect.isPointInside(mouse_position))
|
if (body_rect.isPointInside(mouse_position))
|
||||||
{
|
{
|
||||||
float exact_hover = (float)((mouse_position.X -
|
float exact_hover = (float)((mouse_position.X -
|
||||||
body_rect.UpperLeftCorner.X) /
|
body_rect.UpperLeftCorner.X) /
|
||||||
(float)body_rect.getWidth()) * (m_max-m_min) + 0.5f;
|
(float)body_rect.getWidth()) * (m_max-m_min);
|
||||||
|
|
||||||
int new_value = ((exact_hover * (m_max-m_min)) /
|
float new_value_f = ((exact_hover * (m_max - m_min)) /
|
||||||
(m_max-m_min))+m_min;
|
(m_max - m_min)) + m_min;
|
||||||
|
int new_value = (int)roundf(new_value_f);
|
||||||
|
|
||||||
if (new_value > m_max) new_value = m_max;
|
if (new_value > m_max) new_value = m_max;
|
||||||
if (new_value < m_min) new_value = m_min;
|
if (new_value < m_min) new_value = m_min;
|
||||||
|
Loading…
Reference in New Issue
Block a user