Esempio n. 1
0
void TextBounceBehaviour::Update(float deltaTime)
{
	if(m_triggered)
	{
		if(!m_stop)
		{
			if(!m_valuesSet)
			{
				m_text->SetShadowOffset(D3DXVECTOR2(m_startingScale.x * 10, m_startingScale.y * 10));
				m_valuesSet = true;
			}

			m_bounceValue += m_bounceIncrement*deltaTime;
	
			D3DXVECTOR2 shadowScale = (m_text->GetScale() + m_bounceMaxHeight) - m_startingScale;
			m_text->SetShadowOffset(D3DXVECTOR2(shadowScale.x * 25, shadowScale.y * 25));
			
			D3DXVECTOR2 bounceValue(sin(m_bounceValue) * m_bounceMaxHeight.x, 
				sin(m_bounceValue) * m_bounceMaxHeight.y);
			m_text->SetScale(m_startingScale + bounceValue); 
		}
		else
		{
			if(m_valuesSet)
			{
				m_bounceValue += m_bounceIncrement*deltaTime;
	
				D3DXVECTOR2 shadowScale = (m_text->GetScale() + m_bounceMaxHeight) - m_startingScale;
				m_text->SetShadowOffset(D3DXVECTOR2(shadowScale.x * 25, shadowScale.y * 25));
			
				D3DXVECTOR2 bounceValue(sin(m_bounceValue) * m_bounceMaxHeight.x, 
					sin(m_bounceValue) * m_bounceMaxHeight.y);
				m_text->SetScale(m_startingScale + bounceValue); 

				D3DXVECTOR2 originalSize = m_startingScale;// - m_bounceMaxHeight;
				if(originalSize.x > m_text->GetScale().x - 0.1f && 
					originalSize.x < m_text->GetScale().x + 0.1f)
				{
					m_text->SetScale(originalSize);
					m_text->SetShadowOffset(m_shadowOffset);
					m_valuesSet = false;
					ResetValues();
					m_triggered = false;
				}
			}
		}
	}
}
Esempio n. 2
0
//------------------------------------------------------------------------
bool CScrollbar::onWheel (const CPoint &where, const CMouseWheelAxis &axis, const float &_distance, const CButtonState &buttons)
{
	if (!getMouseEnabled ())
		return false;

	if (buttons != 0 && !(buttons & (kShift|kMouseWheelInverted)))
		return false;

	if (direction == kHorizontal && axis == kMouseWheelAxisY)
		return false;

	if (direction == kVertical && axis == kMouseWheelAxisX)
		return false;

	float distance = _distance;
	if (direction == kHorizontal && axis == kMouseWheelAxisY)
		distance *= -1;
	if (buttons & kMouseWheelInverted)
		distance *= -1;

	if (buttons & kShift)
		value -= 0.1f * distance * wheelInc;
	else
		value -= distance * wheelInc;
	bounceValue ();

	if (isDirty ())
	{
		onVisualChange ();
		valueChanged ();
		invalid ();
	}
	return true;
}
Esempio n. 3
0
//------------------------------------------------------------------------
CMouseEventResult CMyParamDisplay::onMouseMoved (CPoint& where, const long& buttons)
{
	if (buttons & kLButton)
	{		
		value = (int)(mInitialValue - (float)(where.v - mInitialPos.v)/3);
		
		bounceValue ();
		
		if (isDirty () && listener)
			listener->valueChanged (this);
		if (isDirty ())
			invalid ();
	}
	return kMouseEventHandled;
}
Esempio n. 4
0
//------------------------------------------------------------------------
void CKickButton::draw (CDrawContext *pContext)
{
	CPoint where (offset.h, offset.v);

	bounceValue ();

	if (value == getMax ())
		where.v += heightOfOneImage;

	if (getDrawBackground ())
	{
		getDrawBackground ()->draw (pContext, getViewSize (), where);
	}
	setDirty (false);
}
Esempio n. 5
0
//------------------------------------------------------------------------
void CVuMeter::draw (CDrawContext *_pContext)
{
	if (!getOnBitmap ())
		return;

	CRect _rectOn (rectOn);
	CRect _rectOff (rectOff);
	CPoint pointOn;
	CPoint pointOff;
	CDrawContext *pContext = _pContext;

	bounceValue ();
	
	float newValue = getOldValue () - decreaseValue;
	if (newValue < value)
		newValue = value;
	setOldValue (newValue);

	newValue = (newValue - getMin ()) / getRange (); // normalize
	
	if (style & kHorizontal) 
	{
		CCoord tmp = (CCoord)(((int32_t)(nbLed * newValue + 0.5f) / (float)nbLed) * getOnBitmap ()->getWidth ());
		pointOff (tmp, 0);

		_rectOff.left += tmp;
		_rectOn.right = tmp + rectOn.left;
	}
	else 
	{
		CCoord tmp = (CCoord)(((int32_t)(nbLed * (1.f - newValue) + 0.5f) / (float)nbLed) * getOnBitmap ()->getHeight ());
		pointOn (0, tmp);

		_rectOff.bottom = tmp + rectOff.top;
		_rectOn.top     += tmp;
	}

	if (getOffBitmap ())
	{
		getOffBitmap ()->draw (pContext, _rectOff, pointOff);
	}

	getOnBitmap ()->draw (pContext, _rectOn, pointOn);

	setDirty (false);
}