Vector2 LandscapeTestData::TranslatePoint(const Vector2& point, const DAVA::Rect& destPlane) const
{
	DVASSERT(landscapeRect.dx != 0 && landscapeRect.dy !=0);
	
	Vector2 origPlaneSize = landscapeRect.GetSize();
	Vector2 destPlaneSize = destPlane.GetSize();

	Vector2 scale(destPlaneSize.x / origPlaneSize.x,
				  destPlaneSize.y / origPlaneSize.y);
	
	Vector2 relPos = point - landscapeRect.GetPosition();

	Vector2 newRelPos(relPos.x * scale.x,
					  relPos.y * scale.y);

	Vector2 newPos = newRelPos + destPlane.GetPosition();

	return newPos;
}
Пример #2
0
void HintManager::ShowHint(const WideString &hintMessage, const DAVA::Rect &controlRectAbsolute)
{
    if(0 != hintMessage.length())
    {
        //Add control
        HintControl *hintControl = new HintControl();
        hintControl->SetText(hintMessage);
        
        Rect screenRect = UIScreenManager::Instance()->GetScreen()->GetRect(true);
        
        Vector2 requestedSize = hintControl->GetSize();
        if(requestedSize.dx < controlRectAbsolute.GetSize().dx)
        {
            Vector2 pos(controlRectAbsolute.x - screenRect.x, controlRectAbsolute.y - screenRect.y + controlRectAbsolute.dy);
            hintControl->SetPosition(pos);
        }
        else if(controlRectAbsolute.x - screenRect.x < requestedSize.dx)
        {
            Vector2 pos(controlRectAbsolute.x - screenRect.x, controlRectAbsolute.y - screenRect.y + controlRectAbsolute.dy);
            hintControl->SetPosition(pos);
        }
        else 
        {
            Vector2 pos(controlRectAbsolute.x - screenRect.x + controlRectAbsolute.dx - requestedSize.dx, controlRectAbsolute.y - screenRect.y + controlRectAbsolute.dy);
            hintControl->SetPosition(pos);
        }
        
        ControlsFactory::AddBorder(hintControl);
        UIScreenManager::Instance()->GetScreen()->AddControl(hintControl);
        
        Animation *hintAlphaAnimation = hintControl->ColorAnimation( Color::Transparent(), NOTIFICATION_TIME, 
                                                                     Interpolation::EASY_IN, 2);
        hintAlphaAnimation->AddEvent(Animation::EVENT_ANIMATION_END, 
                                    Message(this, &HintManager::OnAlphaAnimationDone, hintControl));
        hints.push_back(hintControl);
    }
}