Ejemplo n.º 1
0
void FormulaCursor::moveTo ( BasicElement* element )
{
    moveTo(element,0);
    if (direction()==MoveLeft) {
        moveEnd();
    }
}
Ejemplo n.º 2
0
void BulletNormal::normalShoot(Hero* hero){
	Point aimWorldPos = hero->getPosition();
	Point dstPos = Vec2(aimWorldPos.x - this->getPositionX(), aimWorldPos.y - this->getPositionY());

	cocos2d::Size size = Director::getInstance()->getVisibleSize();
	Vec2 screenLenght = Vec2(size.width, size.height);
	float distance = screenLenght.length();
	float moveDistance = dstPos.length();

	float thisX = this->getPositionX();
	float thisY = this->getPositionY();

	Vec2 destinationPos;
	if (this->getPosition() != aimWorldPos)
	{
		float destinationPosX = thisX + (aimWorldPos.x - thisX)*distance / moveDistance;
		float destinationPosY = thisY + (aimWorldPos.y - thisY)*distance / moveDistance;
		destinationPos = Vec2(destinationPosX, destinationPosY);
	}
	auto moveTo = MoveTo::create(distance / BULLETDEFAULTSPEED, destinationPos);
	auto callFunc = CallFunc::create([&](){
		moveEnd();
	});
	auto actions = Sequence::create(moveTo, callFunc, NULL);
	this->runAction(actions);
}
Ejemplo n.º 3
0
void AnnotationRenderer::mouseMoveEvent(const MouseEvent& event)
{
	Point zoomedMouse = getParentView()->viewport().toView(event.pos());
	Point delta = zoomedMouse - m_previousMousePos;
	m_previousMousePos = zoomedMouse;
	if(delta.isNull())
		return;

	if (m_movingAction == MOVING_TEXT)
		moveText(delta);
	else if (m_movingAction == MOVING_POINT)
		moveEnd(delta);
}
Ejemplo n.º 4
0
void KNWidgetSwitcher::onActionMovingFinished()
{
    //Emit move finished signal.
    emit moveEnd();
    //Check out whether widget index is invalid.
    if(m_outWidgetIndex<0 || (m_outWidgetIndex>m_widgets.size()))
    {
        //Ignore the calling.
        return;
    }
    //Hide the widget.
    setWidgetVisible(m_outWidgetIndex, false);
    //Reset the out widget index to invalid.
    m_outWidgetIndex=-1;
}
Ejemplo n.º 5
0
void AnnotationRenderer::mouseReleaseEvent(const MouseEvent& event)
{
	Point zoomedMouse = getParentView()->viewport().toView(event.pos());
	Point deltaStart = m_startMousePos - m_previousMousePos;
	Point delta = zoomedMouse - m_startMousePos;

	if (m_movingAction == MOVING_TEXT)
	{
		moveText(deltaStart);
		getParentView()->document()->getUndoStack().push(std::make_shared<MoveObjectCommand>(m_annotation, delta));
	}
	else if (m_movingAction == MOVING_POINT)
	{
		moveEnd(deltaStart);
		getParentView()->document()->getUndoStack().push(std::make_shared<MoveAnnotationEndCommand>(m_annotation, delta));
	}
		
	m_movingAction = MOVING_NONE;
}
Ejemplo n.º 6
0
void QSplineEdit::moveControlHandle(int x, int y)
{
	if(m_selected == HNone) return;
	
	switch (m_selected) {
		case HStart:
			moveStart(y);
			break;
		case HEnd:
			moveEnd(y);
			break;
		case HControlLeft:
			moveControlLeft(x, y);
			break;
		case HControlRight:
			moveControlRight(x, y);
			break;
		default:
			break;
	}
	update();
}
Ejemplo n.º 7
0
bool BasicTextInput::keyPressed(Keyboard::Key key, KeyModifiers mod) {
	
	switch(key) {
		
		case Keyboard::Key_NumPad4: {
			if(mod.num) {
				break;
			}
		} /* fall-through */
		case Keyboard::Key_LeftArrow: {
			if(mod.shift) {
				moveStart();
			} else if(mod.control) {
				moveWordLeft();
			} else {
				moveLeft();
			}
			return true;
		}
		
		case Keyboard::Key_NumPad6: {
			if(mod.num) {
				break;
			}
		} /* fall-through */
		case Keyboard::Key_RightArrow: {
			if(mod.shift) {
				moveEnd();
			} else if(mod.control) {
				moveWordRight();
			} else {
				moveRight();
			}
			return true;
		}
		
		case Keyboard::Key_NumPad7: {
			if(mod.num) {
				break;
			}
		} /* fall-through */
		case Keyboard::Key_Home: {
			moveStart();
			return true;
		}
		
		case Keyboard::Key_NumPad1: {
			if(mod.num) {
				break;
			}
		} /* fall-through */
		case Keyboard::Key_End: {
			moveEnd();
			return true;
		}
		
		case Keyboard::Key_Backspace: {
			if(mod.control && mod.shift) {
				eraseStart();
			} else if(mod.control) {
				eraseWordLeft();
			} else {
				eraseLeft();
			}
			return true;
		}
		
		case Keyboard::Key_NumPoint: {
			if(mod.num) {
				break;
			}
		} /* fall-through */
		case Keyboard::Key_Delete: {
			if(mod.control && mod.shift) {
				eraseEnd();
			} else if(mod.control) {
				eraseWordRight();
			} else {
				eraseRight();
			}
			return true;
		}
		
		default: break;
	}
	
	if(mod.control) {
		switch(key) {
			
			case Keyboard::Key_A: {
				moveStart();
				return true;
			}
			
			case Keyboard::Key_B: {
				moveLeft();
				return true;
			}
			
			case Keyboard::Key_C: {
				clear();
				return true;
			}
			
			case Keyboard::Key_D: {
				eraseRight();
				return true;
			}
			
			case Keyboard::Key_E: {
				moveEnd();
				return true;
			}
			
			case Keyboard::Key_F: {
				moveRight();
				return true;
			}
			
			case Keyboard::Key_H: {
				eraseLeft();
				return true;
			}
			
			case Keyboard::Key_K: {
				eraseEnd();
				return true;
			}
			
			case Keyboard::Key_U: {
				eraseStart();
				return true;
			}
			
			case Keyboard::Key_V: {
				paste(mainApp->getWindow()->getClipboardText());
				return true;
			}
			
			case Keyboard::Key_W: {
				eraseWordLeft();
				return true;
			}
			
			default: break;
		}
	}
	
	return TextInputHandler::keyPressed(key, mod);
}