void SliderThumbElement::handleTouchEvent(TouchEvent* touchEvent)
{
    HTMLInputElement* input = hostInput();
    ASSERT(input);
    if (input->isReadOnly() || input->isDisabledFormControl()) {
        clearExclusiveTouchIdentifier();
        stopDragging();
        touchEvent->setDefaultHandled();
        HTMLDivElement::defaultEventHandler(touchEvent);
        return;
    }

    const AtomicString& eventType = touchEvent->type();
    if (eventType == eventNames().touchstartEvent) {
        handleTouchStart(touchEvent);
        return;
    }
    if (eventType == eventNames().touchendEvent || eventType == eventNames().touchcancelEvent) {
        handleTouchEndAndCancel(touchEvent);
        return;
    }
    if (eventType == eventNames().touchmoveEvent) {
        handleTouchMove(touchEvent);
        return;
    }

    HTMLDivElement::defaultEventHandler(touchEvent);
}
void SliderThumbElement::unregisterForTouchEvents()
{
    if (!m_isRegisteredAsTouchEventListener)
        return;

    clearExclusiveTouchIdentifier();
    stopDragging();

    document().removeTouchEventListener(this);
    m_isRegisteredAsTouchEventListener = false;
}
Example #3
0
void SliderThumbElement::defaultEventHandler(Event* event) {
  if (!event->isMouseEvent()) {
    HTMLDivElement::defaultEventHandler(event);
    return;
  }

  // FIXME: Should handle this readonly/disabled check in more general way.
  // Missing this kind of check is likely to occur elsewhere if adding it in
  // each shadow element.
  HTMLInputElement* input = hostInput();
  if (!input || input->isDisabledOrReadOnly()) {
    stopDragging();
    HTMLDivElement::defaultEventHandler(event);
    return;
  }

  MouseEvent* mouseEvent = toMouseEvent(event);
  bool isLeftButton = mouseEvent->button() ==
                      static_cast<short>(WebPointerProperties::Button::Left);
  const AtomicString& eventType = event->type();

  // We intentionally do not call event->setDefaultHandled() here because
  // MediaControlTimelineElement::defaultEventHandler() wants to handle these
  // mouse events.
  if (eventType == EventTypeNames::mousedown && isLeftButton) {
    startDragging();
    return;
  }
  if (eventType == EventTypeNames::mouseup && isLeftButton) {
    stopDragging();
    return;
  }
  if (eventType == EventTypeNames::mousemove) {
    if (m_inDragMode)
      setPositionFromPoint(LayoutPoint(mouseEvent->absoluteLocation()));
    return;
  }

  HTMLDivElement::defaultEventHandler(event);
}
Example #4
0
void AutoDragger::useIdleTime() {
	TimeValue thisTime = getTime();

	if (thisTime != _lastTime) {
		int32 offsetX = (_stopLocation.x - _startLocation.x) * (int32)thisTime / (int32)getDuration();
		int32 offsetY = (_stopLocation.y - _startLocation.y) * (int32)thisTime / (int32)getDuration();
		_draggingElement->moveElementTo(_startLocation.x + offsetX, _startLocation.y + offsetY);
		_lastTime = thisTime;
	}

	if (_done)
		stopDragging();
}
void SliderThumbElement::defaultEventHandler(Event* event)
{
    if (!is<MouseEvent>(*event)) {
        HTMLDivElement::defaultEventHandler(event);
        return;
    }

    // FIXME: Should handle this readonly/disabled check in more general way.
    // Missing this kind of check is likely to occur elsewhere if adding it in each shadow element.
    HTMLInputElement* input = hostInput();
    if (!input || input->isDisabledOrReadOnly()) {
        stopDragging();
        HTMLDivElement::defaultEventHandler(event);
        return;
    }

    MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
    bool isLeftButton = mouseEvent.button() == LeftButton;
    const AtomicString& eventType = mouseEvent.type();

    // We intentionally do not call event->setDefaultHandled() here because
    // MediaControlTimelineElement::defaultEventHandler() wants to handle these
    // mouse events.
    if (eventType == eventNames().mousedownEvent && isLeftButton) {
        startDragging();
        return;
    } else if (eventType == eventNames().mouseupEvent && isLeftButton) {
        stopDragging();
        return;
    } else if (eventType == eventNames().mousemoveEvent) {
        if (m_inDragMode)
            setPositionFromPoint(mouseEvent.absoluteLocation());
        return;
    }

    HTMLDivElement::defaultEventHandler(&mouseEvent);
}
Example #6
0
void SliderThumbElement::handleTouchEndAndCancel(TouchEvent* touchEvent)
{
    unsigned identifier = exclusiveTouchIdentifier();
    if (identifier == NoIdentifier)
        return;

    // If our exclusive touch still exists, it was not the touch
    // that ended, so we should not stop dragging.
    Touch* exclusiveTouch = findTouchWithIdentifier(touchEvent->targetTouches(), identifier);
    if (exclusiveTouch)
        return;

    clearExclusiveTouchIdentifier();

    stopDragging();
}
Example #7
0
void AutoDragger::autoDrag(DisplayElement *dragElement, const Common::Point &startPoint, const Common::Point &stopPoint,
		TimeValue dragTime, TimeScale dragScale) {
	_draggingElement = dragElement;

	if (_draggingElement) {
		_startLocation = startPoint;
		_stopLocation = stopPoint;
		_lastTime = 0;
		_done = false;
		_draggingElement->moveElementTo(_startLocation.x, _startLocation.y);
		setScale(dragScale);
		setSegment(0, dragTime);
		setTime(0);
		scheduleCallBack(kTriggerAtStop, 0, 0);
		startIdling();
		start();
	} else {
		stopDragging();
	}
}
Example #8
0
void DynamicGoo::contactGround() {
    //Away to trapass body
    if (isDragging()) {
        //Change flag and reset normal status
        dragging=false;
        fallDown();
        //Emit a signal for the level class
        emit stopDragging();
        return;
    }
    else {

        if (!isSleeping() && qAbs(body->GetAngularVelocity())<body->GetLinearVelocity().Length() && prevTarget==NULL&&  (target==NULL ||(target!=NULL && (target->getVPosition()-body->GetPosition()).Length()<radius/10 ))) {

            ALbyte name[100]="resources/sounds/boing2.wav";
            QPair<unsigned int,unsigned int> source =sSystem->createSource(name);
            sSystem->setPitch(source.first,24.0/float(radius)*60.0/body->GetLinearVelocity().Length());
            sSystem->setVolume(source.first,2.0*body->GetLinearVelocity().Length()/80.0*radius/24.0);
            sSystem->setPosition(source.first,getPPosition());
            sSystem->playSource(source.first);
            sources.push_back(source);
        }
        onGround=true;
        groundPoint=this->getPPosition();

        //if has joint return;
        if (hasJoint()) {

            return;
        }
        if (sleeping) {
            body->SetGravityScale(1.0);
            return;
        }
        if(!hasJoint() && target==NULL) {
            emit this->nextTargetPlease(NULL);
        }
    }
}
Example #9
0
void DynamicGoo::contactGround(QPoint p){

    //Away to trapass body
    if (isDragging()) {
        //Change flag and reset normal status
        dragging=false;
        fallDown();
        //Emit a signal for the level class
        emit stopDragging();
        return;
    }
    else {


        onGround=true;
        groundPoint=this->getPPosition();


        //if has joint and is not sticked on ground
        if (hasJoint()){
            if (!sticked && stickable){
                onGround=true;
                groundPoint=this->getPPosition();
                emit this->createSticky(p);
                sticked=true; //flag to true
            }
            return;
        }
        if (sleeping) {
            body->SetGravityScale(1.0);
            return;
        }
        if(!hasJoint() && target==NULL){
            emit this->nextTargetPlease(NULL);
        }
    }
}
Example #10
0
void DynamicGoo::contactGround(){
    //Away to trapass body
    if (isDragging()) {
        //Change flag and reset normal status
        dragging=false;
        fallDown();
        //Emit a signal for the level class
        emit stopDragging();
        return;
    }
    else {

        if (!isSleeping() && qAbs(body->GetAngularVelocity())<body->GetLinearVelocity().Length() && prevTarget==NULL&&  (target==NULL ||(target!=NULL && (target->getVPosition()-body->GetPosition()).Length()<radius/10 )))
        {
            Goo::sSystem->SetPitch(boingSound, 24.0/float(radius)*60.0/body->GetLinearVelocity().Length());
            Goo::sSystem->SetVolume(boingSound, 2.0*body->GetLinearVelocity().Length()/80.0*radius/24.0);
            Goo::sSystem->SetPosition(boingSound, getPPosition());
            Goo::sSystem->Play(boingSound);
        }
        onGround=true;
        groundPoint=this->getPPosition();

        //if has joint return;
        if (hasJoint()){

            return;
        }
        if (sleeping) {
            body->SetGravityScale(1.0);
            return;
        }
        if(!hasJoint() && target==NULL){
            emit this->nextTargetPlease(NULL);
        }
    }
}
void SliderThumbElement::defaultEventHandler(Event* event)
{
    if (!event->isMouseEvent()
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
        && !event->isTouchEvent()
#endif
        ) {
        HTMLDivElement::defaultEventHandler(event);
        return;
    }

#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
    bool isLeftButton = false;

    if (event->isMouseEvent()) {
        MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
        isLeftButton = mouseEvent->button() == LeftButton;
    }
#else
    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
    bool isLeftButton = mouseEvent->button() == LeftButton;
#endif
    const AtomicString& eventType = event->type();

    if (eventType == eventNames().mousedownEvent && isLeftButton
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
            || eventType == eventNames().touchstartEvent
#endif
            ) {
        startDragging();
        return;
    } else if (eventType == eventNames().mouseupEvent && isLeftButton
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
            || eventType == eventNames().touchendEvent
            || eventType == eventNames().touchcancelEvent
#endif
            ) {
        stopDragging();
        return;
    } else if (eventType == eventNames().mousemoveEvent
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
            || eventType == eventNames().touchmoveEvent
#endif
            ) {
        if (m_inDragMode)
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
        {
            if (event->isMouseEvent()) {
                MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
#endif
            setPositionFromPoint(mouseEvent->absoluteLocation());
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
            } else if (event->isTouchEvent()) {
                TouchEvent* touchEvent = static_cast<TouchEvent*>(event);
                if (touchEvent->touches() && touchEvent->touches()->item(0)) {
                    IntPoint curPoint;
                    curPoint.setX(touchEvent->touches()->item(0)->pageX());
                    curPoint.setY(touchEvent->touches()->item(0)->pageY());
                    setPositionFromPoint(curPoint);
                    // Tell the webview that webkit will handle the following move events
                    event->setDefaultPrevented(true);
                }
            }

        }
#endif
        return;
    }

    HTMLDivElement::defaultEventHandler(event);
}
Example #12
0
void CSTimeInterface::mouseUp(Common::Point pos) {
	if (_options->getState()) {
		// TODO: options->mouseUp(pos);
		return;
	}

	if (!cursorGetState())
		return;

	if (_state == kCSTimeInterfaceStateDragging) {
		stopDragging();
		return;
	}

	if (_state == kCSTimeInterfaceStateDragStart)
		_state = kCSTimeInterfaceStateNormal;

	switch (cursorGetShape()) {
	case 4:
		cursorChangeShape(1);
		break;
	case 5:
		cursorChangeShape(2);
		break;
	case 14:
		cursorChangeShape(13);
		break;
	}

	if (_vm->getCase()->getCurrScene()->eventIsActive()) {
		if (_vm->getCurrentEventType() == kCSTimeEventWaitForClick)
			_vm->mouseClicked();
		return;
	}

	if (_book->getState() == 2) {
		// TODO: _book->mouseUp(pos);
		return;
	}

	if (_note->getState() == 2) {
		_note->closeNote();
		mouseMove(pos);
		return;
	}

	// TODO: if in sailing puzzle, sailing puzzle mouse up, return

	// TODO: case 20 ui craziness is handled seperately..

	if (_sceneRect.contains(pos)) {
		_vm->getCase()->getCurrScene()->mouseUp(pos);
		return;
	}

	if (_vm->getCase()->getCurrConversation()->getState() != (uint)~0) {
		_vm->getCase()->getCurrConversation()->mouseUp(pos);
		return;
	}

	if (_help->getState() != (uint)~0) {
		_help->mouseUp(pos);
		return;
	}

	// TODO: handle symbols

	if (_bookRect.contains(pos)) {
		// TODO: handle flashing cuffs
		// TODO: _book->open();
		return;
	}

	if (_noteRect.contains(pos)) {
		// TODO: special-casing for case 19
		if (_note->havePiece(0xffff))
			_note->drawBigNote();
	}

	if (_inventoryDisplay->_invRect.contains(pos)) {
		// TODO: special-casing for case 6
		_inventoryDisplay->mouseUp(pos);
	}
}