Ejemplo n.º 1
0
    virtual void mouseMoveEvent(MouseEvent & event) override
    {
        if (m_flightEnabled)
        {
            m_flightNav.mouseMove((event.pos()-m_lastMousePos));
            m_lastMousePos = event.pos();
            event.accept();
            return;
        }

        switch (m_nav.mode())
        {
        case glowutils::WorldInHandNavigation::PanInteraction:
            m_nav.panProcess(event.pos());
            event.accept();
            break;

        case glowutils::WorldInHandNavigation::RotateInteraction:
            m_nav.rotateProcess(event.pos());
            event.accept();
            break;
        case glowutils::WorldInHandNavigation::NoInteraction:
            break;
        }
    }
Ejemplo n.º 2
0
    void mouseEvent(MouseEvent const &event)
    {
        if(ClientApp::windowSystem().processEvent(event))
        {
            // Eaten by the window system.
            return;
        }

        // Fall back to legacy handling.
        switch(event.type())
        {
        case Event::MouseButton:
            Mouse_Qt_SubmitButton(
                        event.button() == MouseEvent::Left?     IMB_LEFT :
                        event.button() == MouseEvent::Middle?   IMB_MIDDLE :
                        event.button() == MouseEvent::Right?    IMB_RIGHT :
                        event.button() == MouseEvent::XButton1? IMB_EXTRA1 :
                        event.button() == MouseEvent::XButton2? IMB_EXTRA2 : IMB_MAXBUTTONS,
                        event.state() == MouseEvent::Pressed);
            break;

        case Event::MouseMotion:
            Mouse_Qt_SubmitMotion(IMA_POINTER, event.pos().x, event.pos().y);
            break;

        case Event::MouseWheel:
            Mouse_Qt_SubmitMotion(IMA_WHEEL, event.pos().x, event.pos().y);
            break;

        default:
            break;
        }
    }
Ejemplo n.º 3
0
    virtual void mousePressEvent(MouseEvent & event) override
    {
        switch (event.button())
        {
        case GLFW_MOUSE_BUTTON_LEFT:
            m_nav.panBegin(event.pos());
            event.accept();
            break;

        case GLFW_MOUSE_BUTTON_RIGHT:
            m_nav.rotateBegin(event.pos());
            event.accept();
            break;
        }
    }
Ejemplo n.º 4
0
    virtual void mouseMoveEvent(MouseEvent & event) override
    {
        switch (m_nav.mode())
        {
        case WorldInHandNavigation::PanInteraction:
            m_nav.panProcess(event.pos());
            event.accept();
            break;

        case WorldInHandNavigation::RotateInteraction:
            m_nav.rotateProcess(event.pos());
            event.accept();

        default:
            break;
        }
    }
Ejemplo n.º 5
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.º 6
0
 virtual void mouseMoveEvent(MouseEvent & event) override
 {
     switch (m_nav->mode())
     {
     case glowutils::WorldInHandNavigation::RotateInteraction:
         m_nav->rotateProcess(event.pos());
         event.accept();
         break;
     case glowutils::WorldInHandNavigation::PanInteraction:
     case glowutils::WorldInHandNavigation::NoInteraction:
         break;
     }
 }
Ejemplo n.º 7
0
void PixelToBufferProcessor::invokeEvent(Event* event) {
    MouseEvent* mouseEvent = dynamic_cast<MouseEvent*>(event);
    if (mouseEvent) {
        int button = mouseEvent->button();
        int state = mouseEvent->state();

        if (button == MouseEvent::MOUSE_BUTTON_LEFT && state == MouseEvent::MOUSE_STATE_PRESS) {
            fromPixel_.set(mouseEvent->pos());
            clearOutput();
        }
        mouseEvent->markAsUsed();

        return;
    }
}
Ejemplo n.º 8
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.º 9
0
bool AnnotationRenderer::mousePressEvent(const MouseEvent& event)
{
	Point zoomedMouse = getParentView()->viewport().toView(event.pos());

	if(m_textArea.contains(zoomedMouse))
	{
		m_movingAction = MOVING_TEXT;
		m_startMousePos = m_previousMousePos = zoomedMouse;
		return true;
	}

	if((zoomedMouse - m_endPos).norm() < 10)
	{
		m_movingAction = MOVING_POINT;
		m_startMousePos = m_previousMousePos = zoomedMouse;
		return true;
	}

	return false;
}
Ejemplo n.º 10
0
void MainWindow::mouseDragEvent(MouseEvent &e) {
  rotate += (e.pos()-mpos);
  mpos = e.pos();
  }
Ejemplo n.º 11
0
void MainWindow::mouseDownEvent(MouseEvent &e) {
  mpos = e.pos();
  }
Ejemplo n.º 12
0
void MainWindow::mouseDragEvent(MouseEvent &e) {
  spin += (e.pos() - mpos);
  mpos = e.pos();

  updateCamera();
  }
Ejemplo n.º 13
0
void LineEdit::mouseDragEvent(MouseEvent &e) {
  ep = e.pos();
  updateSel();
  update();
  }
Ejemplo n.º 14
0
void Widget::processEvent(Event* event, PassKey<Widget, WindowSystemPrivate>)
{
	switch(event->type()) {
	case Event::kFocusIn: {
		if(isAcceptsFocus_) {
			Widget* widget = first_;
			Widget* next = widget;

			while(next) {
				widget = next;

				if(widget->isAcceptsFocus_ && widget->first_ && widget->isVisible()
				   && widget->isEnabled()) {
					next = widget->first_;
				}
				else {
					next = next->next_;
				}
			}

			if(focus_)
				focus_->hasFocus_ = false;

			focus_ = widget;

			if(focus_) {
				focus_->hasFocus_ = true;
				focus_->dispatchEvent(event);
			}
		}

		return; }

	case Event::kFocusOut:
		if(focus_) {
			focus_->hasFocus_ = false;
			focus_->dispatchEvent(event);
		}

		return;

	case Event::kMouseEnter: {
		if(!hasGrab_) {
			MouseEvent* e = static_cast<MouseEvent*>(event);
			dispatchEvent(e);

			updateHoverPoint(e->pos());
		}

		return; }

	case Event::kMouseLeave: {
		if(!hasGrab_)
			sendMouseLeave();

		return; }

	case Event::kMouseMove: {
		MouseEvent* e = static_cast<MouseEvent*>(event);
		Widget* widget;
		Point<int> pos;

		if(hasGrab_) {
			std::tie(widget, pos) = hoveredWidget();

			e->setPos(e->windowPos() - pos, {});
			widget->processMouseEvent(e);
		}
		else {
			std::tie(widget, pos) = updateHoverPoint(e->pos());

			e->setPos(pos, {});
			widget->dispatchEvent(e);
		}

		return; }

	case Event::kMousePress: {
		MouseEvent* e = static_cast<MouseEvent*>(event);
		hasGrab_ = true;

		Widget* widget;
		Point<int> pos;
		std::tie(widget, pos) = hoveredWidget();

		widget->updateFocus(this);

		e->setPos(e->windowPos() - pos, {});
		widget->processMouseEvent(e);
		return; }

	case Event::kMouseRelease: {
		MouseEvent* e = static_cast<MouseEvent*>(event);

		Widget* widget;
		Point<int> pos;
		std::tie(widget, pos) = hoveredWidget();

		Point<int> eventPos = e->pos();
		e->setPos(e->windowPos() - pos, {});
		widget->processMouseEvent(e);

		if(e->buttons() == MouseButton::kNone) {
			hasGrab_ = false;
			updateHoverPoint(eventPos);
		}

		Duration duration = widget->timeCounter_.restart();
		if(duration <= 300_ms && e->button() != MouseButton::kNone
		   && e->button() == widget->lastButton_) {
			MouseEvent ev(Event::kMouseDoubleClick);
			ev.setTimestamp(e->timestamp(), {});
			ev.setModifiers(e->modifiers(), {});
			ev.setPos(e->pos(), {});
			ev.setWindowPos(e->windowPos(), {});
			ev.setGlobalPos(e->globalPos(), {});
			ev.setButton(e->button(), {});
			ev.setButtons(e->buttons(), {});
			widget->processEvent(&ev, {});

			widget->lastButton_ = MouseButton::kNone;
		}
		else {
			widget->lastButton_ = e->button();
		}

		return; }

	case Event::kMouseWheel: {
		MouseWheelEvent* e = static_cast<MouseWheelEvent*>(event);

		Widget* widget;
		Point<int> pos;
		std::tie(widget, pos) = hoveredWidget();

		e->setPos(e->windowPos() - pos, {});
		widget->processMouseEvent(e);
		return; }

	case Event::kKeyPress: {
		Widget* widget = focus_;
		while(focus_) {
			if(focus_->dispatchEvent(event)) {
				if(event->isAccepted())
					return;
			}

			widget = widget->parent_;
		}

		return; }

	case Event::kKeyRelease: {
		Widget* widget = focus_;
		while(focus_) {
			if(focus_->dispatchEvent(event)) {
				if(event->isAccepted())
					return;
			}

			widget = widget->parent_;
		}

		return; }

	case Event::kShow: {
		show();
		break; }

	case Event::kHide: {
		hide();
		break; }

	case Event::kEnable: {
		enable();
		break; }

	case Event::kDisable: {
		disable();
		break; }

	case Event::kClose : {
		if(dispatchEvent(event) && event->isAccepted()) {
			hide();
		}

		return; }

	case Event::kPaint: {
		repaint(static_cast<PaintEvent*>(event));

		// repaint() calls the dispatchEvent() by itself so we don't need to call it one
		// more time
		return; }

	case Event::kMove: {
		MoveEvent* e = static_cast<MoveEvent*>(event);
		pos_ = e->pos();
		break; }

	case Event::kResize: {
		ResizeEvent* e = static_cast<ResizeEvent*>(event);
		size_ = e->size();
		break; }

	default:
		break;
	}

	dispatchEvent(event);

	if(event->type() == Event::kResize && layout_) {
		layout_->setGeometry(rect());
	}
}