本文整理汇总了C++中IWidget::GetState方法的典型用法代码示例。如果您正苦于以下问题:C++ IWidget::GetState方法的具体用法?C++ IWidget::GetState怎么用?C++ IWidget::GetState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWidget
的用法示例。
在下文中一共展示了IWidget::GetState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wp
IWidget *WidgetContainer::FindNearestByRadius(f32 radius, const EventInputPointer *ev) const
{
WidgetIteratorConst it = vWidget.begin();
WidgetIteratorConst end = vWidget.end();
IWidget *nearest = NULL;
f32 distance = radius;
f32 x = ev->GetX();
f32 y = ev->GetY();
for (; it != end; ++it)
{
IWidget *w = (*it);
ASSERT_NULL(w);
if (w->IsDisabled())
continue;
if (!(w->GetTrigger() & ev->GetPressed()))
continue;
if (w->GetState() == Seed::WidgetStateDrag)
continue;
f32 wX = w->GetX() + (w->GetWidth() / 2.0f);
f32 wY = w->GetY() + (w->GetHeight() / 2.0f);
Point2f wp((x * x) - (wX * wX), (y * y)-(wY * wY));
f32 dX = wp.SquareLength();
if (dX < distance)
{
distance = dX;
nearest = w;
}
}
return nearest;
}
示例2: OnInputPointerRelease
void WidgetContainer::OnInputPointerRelease(const EventInputPointer *ev)
{
ASSERT_NULL(ev);
WidgetIterator it = vWidget.begin();
WidgetIterator end = vWidget.end();
for (; it != end; ++it)
{
IWidget *w = (*it);
//BOOL consumed = FALSE;
bEventConsumed = FALSE;
ASSERT_NULL(w);
if (w->IsDisabled())
continue;
if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
{
WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
wc->OnInputPointerRelease(ev);
bEventConsumed = wc->IsEventConsumed();
if (bEventConsumed)
break;
}
//f32 cX = ev->GetX();
//f32 cY = ev->GetY();
u32 j = ev->GetJoystick();
if (!(w->GetTrigger() & ev->GetReleased()))
continue;
if (w->GetState() == Seed::WidgetStateDrag)
{
//LOG("> STOP DRAG [%d, %f, %f]", j, cX, cY);
bEventConsumed = this->DoDrop(ev, w);
}
else
{
if (w->GetPlayerState(j) == Seed::WidgetStatePressedOver)
{
//LOG("> RELEASE [%d, %f, %f]", j, cX, cY);
//consumed = this->DoRelease(ev, w);
bEventConsumed = this->DoRelease(ev, w);
}
else if (w->GetPlayerState(j) == Seed::WidgetStatePressedOut)
{
//LOG("> RELEASE OUT [%d, %f, %f]", j, cX, cY);
//consumed = this->DoReleaseOut(ev, w);
bEventConsumed = this->DoReleaseOut(ev, w);
}
}
//if (consumed)
if (bEventConsumed)
break;
}
}
示例3: OnInputPointerPress
void WidgetContainer::OnInputPointerPress(const EventInputPointer *ev)
{
ASSERT_NULL(ev);
WidgetIterator it = vWidget.begin();
WidgetIterator end = vWidget.end();
f32 cX = ev->GetX();
f32 cY = ev->GetY();
BOOL found = FALSE;
for (; it != end; ++it)
{
IWidget *w = (*it);
ASSERT_NULL(w);
bEventConsumed = FALSE;
if (w->IsDisabled())
continue;
if (!w->ContainsPoint(cX, cY))
continue;
if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
{
WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
wc->OnInputPointerPress(ev);
bEventConsumed = wc->IsEventConsumed();
if (bEventConsumed)
break;
}
if (!(w->GetTrigger() & ev->GetPressed()))
continue;
u32 j = ev->GetJoystick();
//LOG("> PRESS [%d, %f, %f]", j, cX, cY);
if (w->GetState() == Seed::WidgetStateDrag)
{
continue;
}
found = TRUE;
const EventWidget newEvent(w, NULL, WidgetEventPressed, j, cX, cY, ev->GetPressed(), ev->GetHold(), ev->GetReleased());
LOG(">PRESSED_OVER [id: %d]", w->GetId());
// GetState eh o baseado em prioridade a partir de todos os inputs.
if (w->GetState() != Seed::WidgetStatePressedOver && w->GetPlayerState(j) != Seed::WidgetStatePressedOver)
{
// muda apenas o estado interno do widget
LOG("\tEstado WIDGET");
w->OnWidgetPress(&newEvent);
}
w->SetState(Seed::WidgetStatePressed);
w->SetPlayerState(Seed::WidgetStatePressedOver, j);
LOG("\tEstado PLAYER");
w->SendOnPress(&newEvent);
LOG("\tEvento");
//if (newEvent.IsConsumed())
bEventConsumed = newEvent.IsConsumed();
if (bEventConsumed)
break;
}
if (!found) // avoid call
{
// If no widget have collision, then we try distance based input;
f32 maxDist = pConfiguration->GetInputDistanceRadius();
if (maxDist)
{
IWidget *nearest = this->FindNearestByRadius(maxDist, ev);
if (nearest)
{
IWidget *w = nearest;
if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
{
WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
wc->OnInputPointerPress(ev);
bEventConsumed = wc->IsEventConsumed();
if (bEventConsumed)
return;
}
u32 j = ev->GetJoystick();
const EventWidget newEvent(w, NULL, WidgetEventPressed, j, cX, cY, ev->GetPressed(), ev->GetHold(), ev->GetReleased());
LOG(">PRESSED_OVER [id: %d]", w->GetId());
// GetState eh o baseado em prioridade a partir de todos os inputs.
if (w->GetState() != Seed::WidgetStatePressedOver && w->GetPlayerState(j) != Seed::WidgetStatePressedOver)
{
// muda apenas o estado interno do widget
//.........这里部分代码省略.........
示例4: OnInputPointerPress
void WidgetContainer::OnInputPointerPress(const EventInputPointer *ev)
{
ASSERT_NULL(ev);
WidgetIterator it = vWidget.begin();
WidgetIterator end = vWidget.end();
for (; it != end; ++it)
{
IWidget *w = (*it);
ASSERT_NULL(w);
bEventConsumed = FALSE;
if (w->IsDisabled())
continue;
f32 cX = ev->GetX();
f32 cY = ev->GetY();
if (!w->ContainsPoint(cX, cY))
continue;
if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
{
WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
wc->OnInputPointerPress(ev);
bEventConsumed = wc->IsEventConsumed();
if (bEventConsumed)
break;
}
if (!(w->GetTrigger() & ev->GetPressed()))
continue;
u32 j = ev->GetJoystick();
//LOG("> PRESS [%d, %f, %f]", j, cX, cY);
if (w->GetState() == Seed::WidgetStateDrag)
{
continue;
}
const EventWidget newEvent(w, NULL, WidgetEventPressed, j, cX, cY, ev->GetPressed(), ev->GetHold(), ev->GetReleased());
LOG(">PRESSED_OVER [id: %d]", w->GetId());
// GetState eh o baseado em prioridade a partir de todos os inputs.
if (w->GetState() != Seed::WidgetStatePressedOver && w->GetPlayerState(j) != Seed::WidgetStatePressedOver)
{
// muda apenas o estado interno do widget
LOG("\tEstado WIDGET");
w->OnWidgetPress(&newEvent);
}
w->SetState(Seed::WidgetStatePressed);
w->SetPlayerState(Seed::WidgetStatePressedOver, j);
LOG("\tEstado PLAYER");
w->SendOnPress(&newEvent);
LOG("\tEvento");
//if (newEvent.IsConsumed())
bEventConsumed = newEvent.IsConsumed();
if (bEventConsumed)
break;
}
}