void BaseJoint::mousePressed(ofMouseEventArgs& args) { if (hitTest(ofVec2f(args.x, args.y))) { // selected = true; clickDistance = position - ofVec2f(args.x, args.y); // startDrag(); } }
//-------------------------------------------------------------- bool GuiContainer::touchDown(int _x, int _y, int button) { if(!enabled) return false; bool foundFocus = false; for(int i = controls.size()-1; i >= 0; i--) { if(controls[i]->isContainer()) { // if we're a container, call touchDown to propagate to children. foundFocus = controls[i]->touchDown(_x-x, _y-y, button); } else { foundFocus = controls[i]->_touchDown(_x-x, _y-y, button); } if(focusedControl!=NULL) focusedControl->focus = false; focusedControl = controls[i]; focusedControl->focus = true; if(foundFocus) return true; } // we found no focus, so run edit if((editing || movable) && hitTest(_x, _y)) { editPoint = ofPoint(_x, _y); moving = true; if(listeners!=NULL) { for(int i = 0; i < numListeners; i++) { listeners[i]->controlChanged(this); } } } return false; }
//-------------------------------------------------------------- bool GuiControl::_touchDown(int _x, int _y, int touchId){ if(!enabled) return false; down = over = hitTest(_x, _y); if(down) { if(editing) { editPoint = ofPoint(_x, _y); // todo this should be pixels not percent if(scalable && _x-x>width-SCALE_TRIANGLE_SIZE && _y-y>height-SCALE_TRIANGLE_SIZE) { editState = EDIT_SCALE; } else { editState = EDIT_MOVE; } } else { touchDown(_x, _y, touchId); } if(listeners!=NULL) { for(int i = 0; i < numListeners; i++) { listeners[i]->controlChanged(this); } //GuiControl * l = (GuiControl*) listener; //printf("%s\n", l->name.c_str()); } } return over; }
bool Widget::onTouchBegan(Touch *touch, Event *unusedEvent) { _hitted = false; if (isVisible() && isEnabled() && isAncestorsEnabled() && isAncestorsVisible(this) ) { _touchBeganPosition = touch->getLocation(); auto camera = Camera::getVisitingCamera(); if(hitTest(_touchBeganPosition, camera, nullptr)) { _hittedByCamera = camera; if (isClippingParentContainsPoint(_touchBeganPosition)) { _hitted = true; } } } if (!_hitted) { return false; } setHighlighted(true); /* * Propagate touch events to its parents */ if (_propagateTouchEvents) { this->propagateTouchEvent(TouchEventType::BEGAN, this, touch); } pushDownEvent(); return true; }
void ofxMSAInteractiveObject::_mouseDragged(ofMouseEventArgs &e) { int x = e.x; int y = e.y; int button = e.button; if(verbose) printf("ofxMSAInteractiveObject::_mouseDragged(x: %i, y: %i, button: %i)\n", x, y, button); if(!enabled) return; _mouseX = x; _mouseY = y; _mouseButton = button; if(hitTest(x, y)) { // if mouse is over the object if(!_mouseOver) { // if wasn't over previous frame // onPress(x, y); // call onPress - maybe not _mouseOver = true; // update flag } onDragOver(x, y, button); // and trigger onDragOver } else { if(_mouseOver) { // if mouse is not over the object, but the flag is true (From previous frame) onRollOut(); // call onRollOut _mouseOver = false; // update flag } if(_mouseDown) { onDragOutside(x, y, button); } } }
//-------------------------------------------------------------- bool GuiControl::_touchMoved(int _x, int _y, int touchId){ if(!enabled) return false; over = hitTest(_x, _y); if(over || (down && editing)) { if(editing) { if(editState==EDIT_MOVE) { x += _x - editPoint.x; y += _y - editPoint.y; } else if(editState==EDIT_SCALE) { width += _x - editPoint.x; height += _y - editPoint.y; if(width<5) width = 5; if(height<5) height = 5; } editPoint = ofPoint(_x, _y); } else { down = over; touchMoved(_x, _y, touchId); if(listeners!=NULL) { for(int i = 0; i < numListeners; i++) { listeners[i]->controlChanged(this); } } } } return over; }
bool wyNode::touchesMoved(wyMotionEvent& e) { // check any touch in node? bool inside = false; for(int i = 0; i < e.pointerCount; i++) { if(hasPid(e.pid[i])) { if(hitTest(e.x[i], e.y[i])) { inside = true; break; } } } // set selected status setSelected(inside); // if no touch in node, call move out selector if(!inside) { if(m_moveOutSelector != NULL) { if (m_moveOutSelector != NULL) { m_moveOutSelector->invoke(); } } } return m_interceptTouch; }
/*! \fn QString QAbstractTextDocumentLayout::anchorAt(const QPointF &position) const Returns the reference of the anchor the given \a position, or an empty string if no anchor exists at that point. */ QString QAbstractTextDocumentLayout::anchorAt(const QPointF& pos) const { int cursorPos = hitTest(pos, Qt::ExactHit); if (cursorPos == -1) return QString(); // compensate for preedit in the hit text block QTextBlock block = document()->firstBlock(); while (block.isValid()) { QRectF blockBr = blockBoundingRect(block); if (blockBr.contains(pos)) { QTextLayout *layout = block.layout(); int relativeCursorPos = cursorPos - block.position(); const int preeditLength = layout ? layout->preeditAreaText().length() : 0; if (preeditLength > 0 && relativeCursorPos > layout->preeditAreaPosition()) cursorPos -= qMin(cursorPos - layout->preeditAreaPosition(), preeditLength); break; } block = block.next(); } QTextDocumentPrivate *pieceTable = qobject_cast<const QTextDocument *>(parent())->docHandle(); QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos); QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format); return fmt.anchorHref(); }
//-------------------------------------------------------------- void ofxMSAInteractiveObject::_mouseDragged(ofMouseEventArgs &e) { int x = e.x; int y = e.y; int button = e.button; if(verbose) printf("ofxMSAInteractiveObject::_mouseDragged(x: %i, y: %i, button: %i)\n", x, y, button); if(!enabled) { _isMousePressed[button] = false; return; } if(hitTest(x, y)) { // if mouse is over the object if(!_isMouseOver) { // if wasn't over previous frame // onPress(x, y); // call onPress - maybe not _isMouseOver = true; // update flag onRollOver(x, y); // call onRollOver } onDragOver(x, y, button); // and trigger onDragOver } else { if(_isMouseOver) { // if mouse is not over the object, but the flag is true (From previous frame) onRollOut(); // call onRollOut _isMouseOver = false; // update flag } if(isMousePressed(button)) { onDragOutside(x, y, button); } _isMousePressed[button] = false; } _stateChangeTimestampMillis = ofGetElapsedTimeMillis(); mouseDragged(x, y, button); }
//-------------------------------------------------------------- bool ofxMtActionsObject::actionTouchHitTest(float _x, float _y) { if (rotatable || rotation != 0) { ofxVec2f p = ofxVec2f(_x, _y); p.x -= x; p.y -= y; p.rotateRad(-rotation); lastHit = p; p.x += x; p.y += y; return hitTest(p.x + width/2, p.y + height/2); } else { return hitTest(_x, _y); // } }
//-------------------------------------------------------------- void ofxMSAInteractiveObject::_mousePressed(ofMouseEventArgs &e) { int x = e.x; int y = e.y; int button = e.button; if(verbose) printf("ofxMSAInteractiveObject::_mousePressed(x: %i, y: %i, button: %i)\n", x, y, button); if(!enabled) { _isMousePressed[button] = false; return; } if(hitTest(x, y)) { // if mouse is over if(!isMousePressed(button)) { // if wasn't down previous frame _isMousePressed[button] = true; // update flag onPress(x, y, button); // call onPress } } else { // if mouse is not over _isMousePressed[button] = false; // update flag onPressOutside(x, y, button); } _stateChangeTimestampMillis = ofGetElapsedTimeMillis(); mousePressed(x, y, button); }
//-------------------------------------------------------------- void ofxMSAInteractiveObject::_mouseMoved(ofMouseEventArgs &e) { int x = e.x; int y = e.y; int button = e.button; if(verbose) printf("ofxMSAInteractiveObject::_mouseMoved(x: %i, y: %i)\n", x, y); if(!enabled) return; // _mouseX = x; // _mouseY = y; if(hitTest(x, y)) { // if mouse is over the object if(!_isMouseOver) { // if wasn't over previous frame _isMouseOver = true; // update flag onRollOver(x, y); // call onRollOver } onMouseMove(x, y); // and trigger onMouseMove } else if(_isMouseOver) { // if mouse is not over the object, but the flag is true (From previous frame) onRollOut(); // call onRollOut _isMouseOver = false; // update flag } _stateChangeTimestampMillis = ofGetElapsedTimeMillis(); mouseMoved(x, y); }
//----------------------------------------------- DWORD AflSpriteScroll::onLButtonDown(DWORD dwFlags,FLOAT fX,FLOAT fY) { INT iHit = hitTest(fX,fY); if(iHit == AFL_HIT_SCROLLBAR) { m_fClickPointBaseX = getPointX(); m_fClickPointBaseY = getPointY(); m_fClickPointX = fX; m_fClickPointY = fY; m_iBasePos = m_iScrollPos; m_iMode = AFL_SCROLLBAR; return 1; } if(iHit == AFL_HIT_SCROLL1) { setScrollPos(m_iScrollPos-m_dwScrollMin); return 1; } if(iHit == AFL_HIT_SCROLL2) { setScrollPos(m_iScrollPos+m_dwScrollMin); return 1; } return iHit; }
void ObjectMap::draw(const Point& testPoint, int color, int color2) { int hitZoneIndex; char txtBuf[32]; Point pickPoint; Point textPoint; Location pickLocation; pickPoint = testPoint; if (_vm->_scene->getFlags() & kSceneFlagISO) { assert(_vm->_actor->_protagonist); pickPoint.y -= _vm->_actor->_protagonist->_location.z; _vm->_isoMap->screenPointToTileCoords(pickPoint, pickLocation); pickLocation.toScreenPointUV(pickPoint); } hitZoneIndex = hitTest(pickPoint); for (HitZoneArray::iterator i = _hitZoneList.begin(); i != _hitZoneList.end(); ++i) { i->draw(_vm, (hitZoneIndex == i->getIndex()) ? color2 : color); } if (hitZoneIndex != -1) { snprintf(txtBuf, sizeof(txtBuf), "hitZone %d", hitZoneIndex); textPoint.x = 2; textPoint.y = 2; _vm->_font->textDraw(kKnownFontSmall, txtBuf, textPoint, kITEColorBrightWhite, kITEColorBlack, kFontOutline); } }
int QAbstractTextDocumentLayout_QtDShell::__override_hitTest(const QPointF& point0, int accuracy1, bool static_call) const { if (static_call) { return 0; } else { return hitTest((const QPointF& )point0, (Qt::HitTestAccuracy )accuracy1); } }
bool UIWidget::pointAtSelfBody(const CCPoint &pt) { if (!getAbsoluteVisible()) { return false; } return hitTest(getValidNode(),pt); }
bool GameMap::onTouchBegan(Touch* touch, Event* evt) { if (hitTest(touch->getLocation())) { _touched = true; } _movingDir = GameConst::DIRECTION::NONE; return true; }
void OnyxListWidget::mouseReleaseEvent(QMouseEvent * event) { int sel = hitTest(event->pos()); if (sel >= 0 && sel < items_per_page_) { select(first_visible_ + sel); activate(); } }
UI_Object* UI_Box::getMouseObject() { // get current mouse position int mouseX, mouseY; g_pStaticMouseUtil->getMousePos(&mouseX, &mouseY); float zDist; return hitTest(mouseX, mouseY, zDist); }
void Widget::onTouchMoved(Touch *touch, Event *unusedEvent) { _touchMovePos = touch->getLocation(); setFocused(hitTest(_touchMovePos)); Widget* widgetParent = getWidgetParent(); if (widgetParent) { widgetParent->checkChildInfo(1,this,_touchMovePos); } moveEvent(); }
/*! \fn QString QAbstractTextDocumentLayout::anchorAt(const QPointF &position) const Returns the reference of the anchor the given \a position, or an empty string if no anchor exists at that point. */ QString QAbstractTextDocumentLayout::anchorAt(const QPointF& pos) const { int cursorPos = hitTest(pos, Qt::ExactHit); if (cursorPos == -1) return QString(); QTextDocumentPrivate *pieceTable = qobject_cast<const QTextDocument *>(parent())->docHandle(); QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos); QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format); return fmt.anchorHref(); }
void ControlBase::onRelease(int x, int y, int button){ if(isDisabled())return; bPressed = false; if(hitTest(x, y)){ onRollOver(x, y); } else { controlState = CONTROL_STATE_IDLE; } ControlEventArgs e(this); ofNotifyEvent(release, e); }
void Widget::onTouchMoved(Touch *touch, Event *unusedEvent) { _touchMovePosition = touch->getLocation(); setHighlighted(hitTest(_touchMovePosition)); Widget* widgetParent = getWidgetParent(); if (widgetParent) { widgetParent->interceptTouchEvent(TouchEventType::MOVED, this, touch); } moveEvent(); }
void UIWidget::onTouchMoved(const CCPoint &touchPoint) { m_touchMovePos.x = touchPoint.x; m_touchMovePos.y = touchPoint.y; setFocused(hitTest(touchPoint)); if (m_pWidgetParent) { m_pWidgetParent->checkChildInfo(1,this,touchPoint); } moveEvent(); }
bool Slider::processMouseDown(const InputEvent& event) { static int zoominc = XMLSupport::parse_int (vs_config->getVariable("general","wheel_increment_lines","3")); if(event.code == LEFT_MOUSE_BUTTON && m_thumbLength != NO_THUMB_LENGTH && hitTest(event.loc)) { if(m_vertical) { if(event.loc.y < m_thumbRect.origin.y) { m_mouseState = MOUSE_PAGE_DOWN; } else if(event.loc.y > m_thumbRect.top()) { m_mouseState = MOUSE_PAGE_UP; } else { m_mouseState = MOUSE_THUMB_DRAG; m_buttonDownMouse = event.loc.y; m_buttonDownPosition = m_position; } } else { if(event.loc.x < m_thumbRect.origin.x) { m_mouseState = MOUSE_PAGE_UP; } else if(event.loc.x > m_thumbRect.right()) { m_mouseState = MOUSE_PAGE_DOWN; } else { m_mouseState = MOUSE_THUMB_DRAG; m_buttonDownMouse = event.loc.x; m_buttonDownPosition = m_position; } } setModal(true); // Make sure we don't miss anything. // Make sure we see mouse events *first* until we get a mouse-up. globalEventManager().pushResponder(this); return true; } else if (event.code == WHEELUP_MOUSE_BUTTON) { if(hitTest(event.loc)) { setPosition(position()-zoominc); } } else if (event.code == WHEELDOWN_MOUSE_BUTTON) { if(hitTest(event.loc)) { setPosition(position()+zoominc); } } return Control::processMouseDown(event); }
static BOOL onSetCursor( HWND hwnd, HWND hwndCursor, UINT codeHitTest, UINT msg ) { LPCTSTR cursor = IDC_ARROW; const int htCode = hitTest( hwnd ); if ( HTCLIENT == codeHitTest && isSizeCursor( htCode ) ) { cursor = isVertical( hwnd ) ? IDC_SIZENS : IDC_SIZEWE; } SetCursor( LoadCursor( 0, cursor ) ); return TRUE; }
void Physics::update(){ /**** UPDATE POSITIONS ****/ CIwArray<Entity*> & entities = rM.getEntities(); //move all entities for (CIwArray<Entity*>::iterator it = entities.begin(); it != entities.end(); it++){ Entity * e = *it; //maybe move by angle + force? this->translate(* e, e->vec); } SpaceShip * e = &rM.getSpaceShip(); if(not inbounds(* e)){ //move the ship back CIwFVec2 revVec = CIwFVec2( - e->vec.x, - e->vec.y); this->translate(* e, revVec); } /**** HITTEST BULLET TO ENEMY ****/ CIwArray<Bullet*> & bulletArray = rM.getBullets(); for (CIwArray<Bullet*>::iterator b = bulletArray.begin(); b != bulletArray.end(); b++){ Bullet * bullet = *b; CIwArray<Enemy*> & enemyArray = rM.getEnemies(); for (CIwArray<Enemy*>::iterator en = enemyArray.begin(); en != enemyArray.end(); en++){ Enemy * enemy = *en; if(hitTest(* bullet, * enemy)){ bullet->remove = true; enemy->damageTaken = true; if(enemy->health <= 0){ enemy->remove = true; } } } } /**** DELETE ENTITIES SET TO REMOVE ****/ CIwArray<Entity*> & entites = rM.getEntities(); CIwArray<Entity*>::iterator it = entites.begin(); //if we are removing elements, we need to be careful with the iterator! while(it != entites.end()){ Entity * e = *it; if( e->remove || (not inbounds(* e))){ rM.remove(e); } else { ++it; } } }
void InGameLayer::moveAllBalls(float dt) { Ball* mBall = NULL; for (int i = 0; i < ballList.size(); i++) { mBall = ballList.at(i); mBall->move(); mBall->setRotation(mBall->getRotation() + 10); } hitTest(); eachotherHit(); }
//-------------------------------------------------------------- bool GuiControl::_touchUp(int _x, int _y, int button){ if(!enabled) return false; over = hitTest(_x, _y); down = false; if(editing) { _touchMoved (_x, _y, button); } else { if(over) touchUp(_x, _y, button); } editState = EDIT_NONE; return over; }
HITTESTRESULT Panel::OnNcHitTest( CPoint point ) { HITTESTRESULT ht = hitTest( point ); if ( ht == BUT_CLOSE || ht == BUT_ROLLUP || ht == BUT_CLONE ) { paintCaptionButtons( ht ); SetTimer( HOVER_TIMERID, HOVER_TIMERMILLIS, 0 ); } return ht; }