本文整理汇总了C++中PointerEvent::setType方法的典型用法代码示例。如果您正苦于以下问题:C++ PointerEvent::setType方法的具体用法?C++ PointerEvent::setType怎么用?C++ PointerEvent::setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointerEvent
的用法示例。
在下文中一共展示了PointerEvent::setType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generatePointerEvents
void Pointer::generatePointerEvents(unsigned int pointerID, const PickResultPointer& pickResult) {
// TODO: avatars/HUD?
auto pointerManager = DependencyManager::get<PointerManager>();
// NOTE: After this loop: _prevButtons = buttons that were removed
// If switching to disabled or should stop triggering, release all buttons
Buttons buttons;
Buttons newButtons;
Buttons sameButtons;
if (_enabled && shouldTrigger(pickResult)) {
buttons = getPressedButtons(pickResult);
for (const std::string& button : buttons) {
if (_prevButtons.find(button) == _prevButtons.end()) {
newButtons.insert(button);
} else {
sameButtons.insert(button);
_prevButtons.erase(button);
}
}
}
// Hover events
bool doHover = shouldHover(pickResult);
Pointer::PickedObject hoveredObject = getHoveredObject(pickResult);
PointerEvent hoveredEvent = buildPointerEvent(hoveredObject, pickResult);
hoveredEvent.setType(PointerEvent::Move);
hoveredEvent.setID(pointerID);
bool moveOnHoverLeave = (!_enabled && _prevEnabled) || (!doHover && _prevDoHover);
hoveredEvent.setMoveOnHoverLeave(moveOnHoverLeave);
// if shouldHover && !_prevDoHover, only send hoverBegin
if (_enabled && _hover && doHover && !_prevDoHover) {
if (hoveredObject.type == ENTITY) {
emit pointerManager->hoverBeginEntity(hoveredObject.objectID, hoveredEvent);
} else if (hoveredObject.type == LOCAL_ENTITY) {
emit pointerManager->hoverBeginOverlay(hoveredObject.objectID, hoveredEvent);
} else if (hoveredObject.type == HUD) {
emit pointerManager->hoverBeginHUD(hoveredEvent);
}
} else if (_enabled && _hover && doHover) {
if (hoveredObject.type == LOCAL_ENTITY) {
if (_prevHoveredObject.type == LOCAL_ENTITY) {
if (hoveredObject.objectID == _prevHoveredObject.objectID) {
emit pointerManager->hoverContinueOverlay(hoveredObject.objectID, hoveredEvent);
} else {
PointerEvent prevHoveredEvent = buildPointerEvent(_prevHoveredObject, pickResult);
prevHoveredEvent.setID(pointerID);
prevHoveredEvent.setMoveOnHoverLeave(moveOnHoverLeave);
emit pointerManager->hoverEndOverlay(_prevHoveredObject.objectID, prevHoveredEvent);
emit pointerManager->hoverBeginOverlay(hoveredObject.objectID, hoveredEvent);
}
} else {
emit pointerManager->hoverBeginOverlay(hoveredObject.objectID, hoveredEvent);
if (_prevHoveredObject.type == ENTITY) {
emit pointerManager->hoverEndEntity(_prevHoveredObject.objectID, hoveredEvent);
} else if (_prevHoveredObject.type == HUD) {
emit pointerManager->hoverEndHUD(hoveredEvent);
}
}
}
// TODO: this is basically repeated code. is there a way to clean it up?
if (hoveredObject.type == ENTITY) {
if (_prevHoveredObject.type == ENTITY) {
if (hoveredObject.objectID == _prevHoveredObject.objectID) {
emit pointerManager->hoverContinueEntity(hoveredObject.objectID, hoveredEvent);
} else {
PointerEvent prevHoveredEvent = buildPointerEvent(_prevHoveredObject, pickResult);
prevHoveredEvent.setID(pointerID);
prevHoveredEvent.setMoveOnHoverLeave(moveOnHoverLeave);
emit pointerManager->hoverEndEntity(_prevHoveredObject.objectID, prevHoveredEvent);
emit pointerManager->hoverBeginEntity(hoveredObject.objectID, hoveredEvent);
}
} else {
emit pointerManager->hoverBeginEntity(hoveredObject.objectID, hoveredEvent);
if (_prevHoveredObject.type == LOCAL_ENTITY) {
emit pointerManager->hoverEndOverlay(_prevHoveredObject.objectID, hoveredEvent);
} else if (_prevHoveredObject.type == HUD) {
emit pointerManager->hoverEndHUD(hoveredEvent);
}
}
}
if (hoveredObject.type == HUD) {
if (_prevHoveredObject.type == HUD) {
// There's only one HUD
emit pointerManager->hoverContinueHUD(hoveredEvent);
} else {
emit pointerManager->hoverBeginHUD(hoveredEvent);
if (_prevHoveredObject.type == ENTITY) {
emit pointerManager->hoverEndEntity(_prevHoveredObject.objectID, hoveredEvent);
} else if (_prevHoveredObject.type == LOCAL_ENTITY) {
emit pointerManager->hoverEndOverlay(_prevHoveredObject.objectID, hoveredEvent);
}
}
}
if (hoveredObject.type == NONE) {
if (_prevHoveredObject.type == ENTITY) {
emit pointerManager->hoverEndEntity(_prevHoveredObject.objectID, hoveredEvent);
//.........这里部分代码省略.........