Exemplo n.º 1
0
void ScrollComponent::OnOverMove(VariantList *pVList)
{
	uint32 fingerID = 0;
	fingerID = pVList->Get(2).GetUINT32();
	if (*m_pEnforceFingerTracking && m_activeFinger == -1)
	{
		TouchTrackInfo *pTouch = GetBaseApp()->GetTouch(fingerID);
		if (pTouch->WasHandled()) return;
		m_activeFinger = fingerID;
	}

	if (!isInterestingFinger(fingerID)) return;
		
	//LogMsg("moved %s", PrintVector2(vDisplacement).c_str());

	if (*m_pScrollStyle == STYLE_EXACT)
	{
		m_vecDisplacement += pVList->m_variant[0].GetVector2()-m_lastTouchPos;
		m_vTotalDisplacementOnCurrentSwipe += pVList->m_variant[0].GetVector2()-m_lastTouchPos;
		if (m_bIsScrolling || *m_pSwipeDetectDistance != 0 || *m_pDontScrollUntilSwipeDetected == 0)
		{
			SetPosition(m_vecDisplacement, false);
			m_vecDisplacement = CL_Vec2f(0,0);
		}
	} else
	{
		m_vecDisplacement += (pVList->m_variant[0].GetVector2()-m_lastTouchPos)* *m_pPowerMod;
		m_vTotalDisplacementOnCurrentSwipe +=  pVList->m_variant[0].GetVector2()-m_lastTouchPos;
	}

	m_lastTouchPos = pVList->m_variant[0].GetVector2();

	//was it a big enough swipe to switch to scroll mode?  (scroll mode means they can't accidently hit any buttons/etc inside us)
	//using iPadMapX will roughly allow move movement on larger screens.. not going to be perfect unless we knew the pixels per cm of
	//the screen though.. hrm, not easy to get that.

	if (*m_pSwipeDetectDistance != 0 && m_vTotalDisplacementOnCurrentSwipe.length() > *m_pSwipeDetectDistance)
	{
		//TODO:  Should we check pos/size and if we don't require scrolling (everything fits on screen), not do the next call?
		SetIsScrolling(true);

		TouchTrackInfo *pTouch = GetBaseApp()->GetTouch(fingerID);
		pTouch->SetWasHandled(true, GetParent());
	}
}
Exemplo n.º 2
0
void ScrollComponent::OnOverStart(VariantList *pVList)
{
	uint32 fingerID = pVList->Get(2).GetUINT32();
	if (!isInterestingFinger(fingerID)) return;

	TouchTrackInfo *pTouch = GetBaseApp()->GetTouch(fingerID);

	if (*m_pEnforceFingerTracking && m_activeFinger == -1 && *m_pDontScrollUntilSwipeDetected == 0 && *m_pEatAllInput != 0)
	{
		if (pTouch->WasHandled()) return;
		pTouch->SetWasHandled(true, GetParent());
		m_activeFinger = fingerID;
	}

	pTouch->SetWasPreHandled(true, GetParent());
	
	
	SetIsScrolling(false); 
	m_lastTouchPos = pVList->m_variant[0].GetVector2();
}
void TouchDragComponent::OnInput( VariantList *pVList )
{
	//0 = message type, 1 = parent coordinate offset
	CL_Vec2f pt = pVList->Get(1).GetVector2();
	uint32 fingerID = 0;
	if (pVList->Get(2).GetType() == Variant::TYPE_UINT32)
	{
		fingerID = pVList->Get(2).GetUINT32();
	}

	//LogMsg("Detected finger %d at %s", fingerID, PrintVector2(pt).c_str());
	switch (eMessageType( int(pVList->Get(0).GetFloat())))
	{
	case MESSAGE_TYPE_GUI_CLICK_START:
		//first, determine if the click is on our area
		{

			if (*m_pDisabled != 0) return;

			CL_Rectf r(*m_pPos2d, CL_Sizef(m_pSize2d->x, m_pSize2d->y));

			ApplyPadding(&r, *m_pTouchPadding);
		
			if (r.contains(pt))
			{
						
				if (m_activeFingerID != -1)
				{
					//LogMsg("Ignoring new finger..");
					return;
				}
		
				TouchTrackInfo *pTouch = BaseApp::GetBaseApp()->GetTouch(pVList->Get(2).GetUINT32());
				if (pTouch->WasHandled()) return;
				pTouch->SetWasHandled(true);
                VariantList vList(pt, GetParent(), uint32(fingerID));
                
				GetParent()->GetFunction("OnOverStart")->m_sig_function(&vList);

				m_lastPos = pt;
				m_activeFingerID = fingerID;
			}
		}
		break;

	case MESSAGE_TYPE_GUI_CLICK_END:
		
		EndDrag(fingerID, pt);
	
		break;
	
	case MESSAGE_TYPE_GUI_CLICK_MOVE:
		

		if (*m_pDisabled != 0)
		{
			EndDrag(fingerID, pt);
			return;
		}

		if (m_activeFingerID == fingerID)
		{
			SetPosition(pt);
		}
	
		break;
        default: ;
	}	

}