Example #1
0
void Qt5GLWidget::mouseMoveEvent(QMouseEvent* event) {
	int x = event->x();
	int y = m_height - event->y() + 1;

	int dx = x - m_x;
	int dy = m_y - y;
	m_x = x;
	m_y = y;

	if ((m_leftDown || m_rightDown || m_middleDown)
	&& (abs(x - m_startX) > m_mouseTolerance || abs(y - m_startY) > m_mouseTolerance)) {
		if (!m_mouseDragged) {
			// we are just starting to drag
			if (m_leftDown) mouseDragStart(Left, m_startX, m_startY);
			if (m_rightDown) mouseDragStart(Right, m_startX, m_startY);
			if (m_middleDown) mouseDragStart(Middle, m_startX, m_startY);
		}
		m_mouseDragged = true;

		if (m_leftDown) mouseDrag(Left, dx, dy, x, y);
		if (m_rightDown) mouseDrag(Right, dx, dy, x, y);
		if (m_middleDown) mouseDrag(Middle, dx, dy, x, y);

	} else {
		mouseMove(dx, dy, x, y);
	}
}
Example #2
0
void MLMultiSlider::mouseDown (const MouseEvent& e)
{
    if (!isEnabled()) return;
	mMousePos = Vec2(e.x, e.y);
	mCurrDragSlider = getSliderUnderPoint(mMousePos);
	mouseDrag(e);
}
Example #3
0
//! Connects to mouseDown, mouseDrag, mouseWheel and resize signals of \a window, with optional priority \a signalPriority
void CameraUi::connect( const app::WindowRef &window, int signalPriority )
{
	mWindow = window;
	mSignalPriority = signalPriority;
	if( window ) {
		mMouseDownConnection = window->getSignalMouseDown().connect( signalPriority,
			[this]( app::MouseEvent &event ) { mouseDown( event ); } );
		mMouseUpConnection = window->getSignalMouseUp().connect( signalPriority,
			[this]( app::MouseEvent &event ) { mouseUp( event ); } );
		mMouseDragConnection = window->getSignalMouseDrag().connect( signalPriority,
			[this]( app::MouseEvent &event ) { mouseDrag( event ); } );
		mMouseWheelConnection = window->getSignalMouseWheel().connect( signalPriority,
			[this]( app::MouseEvent &event ) { mouseWheel( event ); } );
		mWindowResizeConnection = window->getSignalResize().connect( signalPriority,
			[this]() {
				setWindowSize( mWindow->getSize() );
				if( mCamera )
					mCamera->setAspectRatio( mWindow->getAspectRatio() );
			}
		);
	}
	else
		disconnect();
		
	mLastAction = ACTION_NONE;
}
Example #4
0
void mainLoop() {
    //The first time you run TackFPS it will return a trash value, so get it out of the way now
    TackFPS(true);

    //Pre-emptively call the resize and draw functions to get the cycle going
    reshape(miWidth, miHeight);

    bool running = true;
    sf::Event event;
    while(running) {
        draw();
        while(window.pollEvent(event)) {
            switch(event.type) {
                case sf::Event::Closed: running = false; break;
                case sf::Event::Resized: reshape(event.size.width, event.size.height); break;
                case sf::Event::KeyPressed: keyDown(event.key.code); break;// TODO codes
                case sf::Event::MouseMoved: mouseDrag(event.mouseMove.x, event.mouseMove.y); break;
                case sf::Event::MouseButtonPressed: mousePress(event.mouseButton.button, 1, event.mouseButton.x, event.mouseButton.y); break;
                case sf::Event::MouseButtonReleased: mousePress(event.mouseButton.button, 0, event.mouseButton.x, event.mouseButton.y); break;
                case sf::Event::TextEntered: charTyped(event.text.unicode); break;
                default: cout << "unhandled event:" << event.type << endl; break;
            }
        }
        window.display();
    }
}
Example #5
0
void CameraUi::mouseDrag( app::MouseEvent &event )
{
	bool isLeftDown = event.isLeftDown();
	bool isMiddleDown = event.isMiddleDown() || event.isAltDown();
	bool isRightDown = event.isRightDown() || event.isControlDown();

	if( isMiddleDown )
		isLeftDown = false;

	mouseDrag( event.getPos(), isLeftDown, isMiddleDown, isRightDown );
	event.setHandled();
}
Example #6
0
//==============================================================================
void Joystick::mouseDown(const MouseEvent& e)
{
    mouseWasHidden = false;

    if (isEnabled())
    {
        if (e.mods.isPopupMenu() && menuEnabled)
        {
            menuShown = true;

            PopupMenu m;
            m.addItem (1, TRANS ("velocity-sensitive mode"), true, isVelocityBased);
            m.addSeparator();

            const int r = m.show();
            if (r == 1)
            {
                setVelocityBasedMode (! isVelocityBased);
            }
            else if (r == 2)
            {
//                setSliderStyle (RotaryHorizontalDrag);
            }
            else if (r == 3)
            {
//                setSliderStyle (RotaryVerticalDrag);
            }
        }
        else if (e.mods.isLeftButtonDown()
                 || e.mods.isMiddleButtonDown())
        {
            menuShown = false;

            // unbound mouse movements
            if (isVelocityBased)
            {
                e.source.enableUnboundedMouseMovement (true, false);
                mouseWasHidden = true;
            }

            startPressX = e.x;
            startPressY = e.y;

            // In case it was a click without a drag, do the drag anyway
            mouseDrag (e);
        }

        // So arrow keys works
        grabKeyboardFocus();
    }
}
void SplittableWaveDisplay::mouseDown(const MouseEvent &e){
    std::cout<<"Clicked \n";
    if (!e.mouseWasClicked()){
        mouseDrag(e);
    }
    
    if(e.mods.isShiftDown()){
        if (!e.mods.isAltDown()){
            }
        
    }
    else{}
        waveDisplay.mouseDown(e);
}
Example #8
0
bool TreentNode::deepMouseDrag( ci::app::MouseEvent &event )
{
  bool captured = false;
  auto gui_component = component<GuiComponent>();
  if( gui_component )
    captured = gui_component->mouseDrag( event, getWorldTransform() );

  for( TreentNodeRef &child : mChildren )
  { // stop evaluation if event was captured by self or a child
    if( captured )
      break;

    captured = child->deepMouseDrag( event );
  }
  return captured;
}
Example #9
0
bool Node::treeMouseDrag( MouseEvent event )
{
    if(!mIsVisible) return false;

    // test children first, from top to bottom
    NodeList nodes(mChildren);
    NodeList::reverse_iterator itr;
    bool handled = false;
    for(itr=nodes.rbegin(); itr!=nodes.rend()&&!handled; ++itr)
        handled = (*itr)->treeMouseDrag(event);

    // if not handled, test this node
    if(!handled) handled = mouseDrag(event);

    return handled;
}
void MouseThread::threadedFunction() {
  Action action;
  
  while (true) {
    action.type = NO_ACTION;

    lock();
    if (next.type != NO_ACTION) {
      action = next;
      next.type = NO_ACTION;
    }
    unlock();

    switch (action.type) {
      case NO_ACTION: {
        sleep(100);
        break;
      }
      case MOVE: {
        mouseMove(action.x1, action.y1);
        sleep(100);
        break;
      }
      case CLICK: {
        mouseDown(action.x1, action.y1);
        sleep(10);
        mouseUp(action.x1, action.y1);
        sleep(100);
        break;
      }
      case DRAG: {
        mouseDown(action.x1, action.y1);
        for (int i = 0; i < 10; ++i) {
          sleep(10);
          mouseDrag(action.x1 + (action.x2 - action.x1) * i / 10, action.y1 + (action.y2 - action.y1) * i / 10);
        }
        sleep(10);
        mouseUp(action.x2, action.y2);
        sleep(400);
        break;
      }
    }
  }
}
Example #11
0
void SliderBank::mouseDown (const MouseEvent& event)
{
	if (event.eventTime - prevMouseDownTime < RelativeTime(MicronSlider::doubleClickDuration))
	{ // double-click, initiate default-values painting
		resettingValuesToDefault = true;
		resetDoubleClickTimer();
	}
	else
	{ // first click, prime for double-click detection
		prevMouseDownTime = event.eventTime;
	}

	// possibly lock onto a particular slider for dragging.
	if (event.mods.isRightButtonDown() || ! broadStrokesEnabled)
		lockedSliderBeingDragged = findSliderAtPos(event.getPosition());

	// let mouseDrag work out which slider to click and manage tracking from there.
	mouseDrag(event);
}
Example #12
0
void ImageViewer::mouseMoveEvent(QMouseEvent *event) {
    QWidget::mouseMoveEvent(event);
    if(!mIsDisplaying)
        return;
    if(event->buttons() & Qt::LeftButton && mouseInteraction != MOUSE_ZOOM) {
        if(cursor().shape() != Qt::ClosedHandCursor) {
            setCursor(Qt::ClosedHandCursor);
        }
        mouseInteraction = MOUSE_DRAG;
        mouseWrapping ? mouseDragWrapping(event) : mouseDrag(event);
    } else if(event->buttons() & Qt::RightButton && mouseInteraction != MOUSE_DRAG) {
        // filter out possible mouse jitter by ignoring low delta drags
        if(mouseInteraction == MOUSE_ZOOM || abs(mousePressPos.y() - event->pos().y()) > ZOOM_THRESHOLD) {
            if(cursor().shape() != Qt::SizeVerCursor) {
                setCursor(Qt::SizeVerCursor);
            }
            mouseInteraction = MOUSE_ZOOM;
            mouseMoveZoom(event);
        }
    }
}
Example #13
0
void processCommand(const char *cmd) {
  int tmpx, tmpy, btn;
  float tmpInterval;
  UInt32 tmpkc;
  char str[CMD_STRING_MAXLEN];

  bzero(str, CMD_STRING_MAXLEN);
  if (IS_CMD(cmd, "mouselocation")) {

    CGPoint cgLoc = mouseLoc();
    printf("%.f %.f\n", cgLoc.x, cgLoc.y);

  } else if (IS_CMD(cmd, "mousewarp ")) {

    print_msg("Warping mouse to location.");
    sscanf(cmd, "mousewarp %d %d", &tmpx, &tmpy);
    mouseMove(tmpx, tmpy);

  } else if (IS_CMD(cmd, "mousemove ")) {

    print_msg("Moving mouse.");
    sscanf(cmd, "mousemove %d %d", &tmpx, &tmpy);
    mouseMoveTo(tmpx, tmpy, 0.7);

  } else if (IS_CMD(cmd, "mousedown")) {

    print_msg("Pressing mouse button.");
    sscanf(cmd, "mousedown %d", &btn);
    mousePress(btn, SINGLE_CLICK);

  } else if (IS_CMD(cmd, "mouseup")) {

    print_msg("Releasing mouse button.");
    sscanf(cmd, "mouseup %d", &btn);
    mouseRelease(btn, SINGLE_CLICK);

  } else if (IS_CMD(cmd, "mouseclick")) {

    print_msg("Clicking mouse.");
    sscanf(cmd, "mouseclick %d", &btn);
    mouseClick(btn, SINGLE_CLICK);

  } else if (IS_CMD(cmd, "mousedoubleclick")) {

    print_msg("Double-clicking mouse.");
    sscanf(cmd, "mousedoubleclick %d", &btn);
    mouseClick(btn, DOUBLE_CLICK);

  } else if (IS_CMD(cmd, "mousetripleclick")) {

    print_msg("Triple-clicking mouse.");
    sscanf(cmd, "mousetripleclick %d", &btn);
    mouseClick(btn, TRIPLE_CLICK);

  } else if (IS_CMD(cmd, "mousedrag ")) {

    print_msg("Dragging mouse.");
    sscanf(cmd, "mousedrag %d %d", &tmpx, &tmpy);
    mouseDrag(LEFT_MOUSE, tmpx, tmpy);

  } else if (IS_CMD(cmd, "press ")) {

    print_msg("Pressing key.");
    sscanf(cmd, "press %x", &tmpkc);
    keyPress((CGKeyCode)tmpkc, NULL);

  } else if (IS_CMD(cmd, "release ")) {

    print_msg("Releasing key.");
    sscanf(cmd, "release %x", &tmpkc);
    keyRelease((CGKeyCode)tmpkc, NULL);

  } else if (IS_CMD(cmd, "hit ")) {

    print_msg("Hitting key.");
    sscanf(cmd, "hit %x", &tmpkc);
    keyHit((CGKeyCode)tmpkc, NULL);

  } else if (IS_CMD(cmd, "type ")) {

    print_msg("Typing.");
    strncpy(str, &cmd[5], CMD_STRING_MAXLEN);
    typeString(str);

  } else if (IS_CMD(cmd, "wait")) {

    print_msg("Waiting.");
    sscanf(cmd, "wait %f", &tmpInterval);
    usleep(1000000 * tmpInterval);

  } else {

    print_msg("I don't know what you want to do.");

  }
}
Example #14
0
	void DDContainer::onMouseDrag(int _left, int _top, MouseButton _id)
	{
		mouseDrag(_id);

		Base::onMouseDrag(_left, _top, _id);
	}
Example #15
0
void XGraphicsView::mouseMoveEvent(QMouseEvent* event) {
	QGraphicsView::mouseMoveEvent(event);
	if (clicked_) emit mouseDrag(event);
}
void Gdc2005Demo::handleUserInput(struct GdcStateInput& stateInput)
{
	const hkgKeyboard& keys = m_env->m_window->getKeyboard();

	// Show help on the keys if the user asks for it
	if ( keys.getKeyState('H') ||
		keys.getKeyState(HKG_VKEY_F1) ||
		( m_env->m_gamePad->isButtonPressed(HKG_PAD_BUTTON_L1)
		&& m_env->m_gamePad->isButtonPressed(HKG_PAD_BUTTON_R1)
		&& m_env->m_gamePad->isButtonPressed(HKG_PAD_BUTTON_0) )
		)
	{
		showKeys();
	}

	// For reference, on PC keyboard:
	//  HKG_VKEY_DELETE == HKG_PAD_BUTTON_L1
	//  HKG_VKEY_END == HKG_PAD_BUTTON_R1
	//  HKG_VKEY_INSERT == HKG_PAD_BUTTON_L2
	//  HKG_VKEY_HOME == HKG_PAD_BUTTON_R2

	// See if we want to chuck anything into the scene
	if ( m_env->m_gamePad->wasButtonPressed(HKG_PAD_BUTTON_2) )
	{
		hkVector4 startPos;
		m_env->m_window->getCurrentViewport()->getCamera()->getFrom( (float*)&startPos );

		hkVector4 velocity;
		m_env->m_window->getCurrentViewport()->getCamera()->getDir( (float*)&velocity );
		velocity.mul4( m_options.m_Physics.m_launchVelocity );

		chuckSomething( startPos, velocity );
	}

	// See if we want to shot the guy (right click or L2)
	if ( m_env->m_gamePad->isButtonPressed(HKG_PAD_BUTTON_L2) ||
		(m_env->m_window->getMouse().getButtonState() & HKG_MOUSE_RIGHT_BUTTON) )
	{
		hkVector4 rayStart;
		hkVector4 rayEnd;

		// unproject current 'mouse' pos.
		hkgCamera* cam = m_env->m_window->getViewport(0)->getCamera();
		int xPos = m_env->m_window->getMouse().getPosX();
		int yPos = m_env->m_window->getMouse().getPosY();
		cam->unProject( xPos, yPos, 0, m_env->m_window->getWidth(), m_env->m_window->getHeight(), (float*)&rayStart);
		cam->unProject( xPos, yPos, 1, m_env->m_window->getWidth(), m_env->m_window->getHeight(), (float*)&rayEnd);

		fireShot( rayStart, rayEnd, m_options.m_Physics.m_shotStrength ); // num == strength
	}

	// See if we want to drag objects around
	if( !m_mouseActive && ( m_env->m_gamePad->wasButtonPressed(HKG_PAD_BUTTON_R1) ||
		keys.getKeyState(HKG_VKEY_SPACE)) ) // Space == Button0 on PC == jump
	{
    	mouseDown(); // pick object under cursor
	}
	else if ( m_mouseActive )
	{
		if( !m_env->m_gamePad->isButtonPressed(HKG_PAD_BUTTON_R1) &&
			!m_env->m_window->getKeyboard().getKeyState(HKG_VKEY_SPACE) )
		{
			mouseUp(); // default physics game impl : delete mouse spring
		}
		else
		{
			mouseDrag(); // default physics game impl : unproject mouse and move spring.
		}
	}

	// Desired direction
	// If we are on a console we are using a stick and want that to dictate
	// the desired direction. Otherwise we will use the dpad ( keyboard dir keys )
	updateUserControl();

	// Die ? Get up? Jump?
	{
		const hkUint32 currentAnimationState = m_animationStateMachine->getCurrentState();
		const bool usingGamepad = m_env->m_window->hasGamePads() && !m_env->m_options->m_forceKeyboardGamepad;

		// DIE?
		if (m_env->m_gamePad->wasButtonPressed(HKG_PAD_BUTTON_1) && currentAnimationState != GDC_DYING_STATE && currentAnimationState != GDC_DEAD_STATE && currentAnimationState != GDC_GETTING_UP_STATE)
		{
			stateInput.m_shouldDie = true;
		}
		else
		{
			stateInput.m_shouldDie = false;
		}

		// DIVE?
		if (m_env->m_gamePad->wasButtonPressed(HKG_PAD_BUTTON_3) && currentAnimationState != GDC_DYING_STATE && currentAnimationState != GDC_DEAD_STATE && currentAnimationState != GDC_GETTING_UP_STATE)
		{
			stateInput.m_shouldDive = true;
		}
		else
		{
			stateInput.m_shouldDive = false;
		}

		// GET UP?
		if (m_env->m_gamePad->wasButtonPressed(HKG_PAD_BUTTON_1) && currentAnimationState == GDC_DEAD_STATE)
		{
			stateInput.m_shouldGetUp = true;
		}
		else
		{
			stateInput.m_shouldGetUp = false;
		}

		// JUMP?
		bool jumpPressed;
		if (usingGamepad)
		{
			jumpPressed = m_env->m_gamePad->wasButtonPressed(HKG_PAD_BUTTON_0);
		}
		else
		{
			jumpPressed = keys.wasKeyPressed('4');
		}
		if (jumpPressed && currentAnimationState!=GDC_DYING_STATE && currentAnimationState!=GDC_IN_AIR_STATE && currentAnimationState!=GDC_DEAD_STATE && currentAnimationState!=GDC_JUMP_STATE)
		{
			stateInput.m_shouldJump = true;
		}
		else
		{
			stateInput.m_shouldJump = false;
		}

	}
}
Example #17
0
	void DDContainer::notifyInvalideDrop(DDContainer* _sender)
	{
		mouseDrag( mDropButton );
	}
Example #18
0
 void mouseDown (const MouseEvent& e)
 {
     mouseDrag (e);
 }
Example #19
0
	void ItemBox::notifyMouseDrag(Widget* _sender, int _left, int _top, MouseButton _id)
	{
		mouseDrag(_id);
	}
Example #20
0
void ParamGraph::mouseDown(const MouseEvent& event){
    mouseDrag(event);
}
Example #21
0
 void mouseDown (const MouseEvent& e) override
 {
     mouseDrag (e);
 }
Example #22
0
	void ListCtrl::notifyMouseDrag(Widget* _sender, int _left, int _top)
	{
		mouseDrag();
	}