コード例 #1
0
ファイル: Moveable.cpp プロジェクト: MajorBreakfast/cvt
	void Moveable::mouseMoveEvent( MouseMoveEvent& event )
	{
		if( _activeMode == 1 ) {
			int cx, cy, nx, ny, dx, dy;
			position( cx, cy );
			event.position( nx, ny );
			dx = nx - _lx;
			dy = ny - _ly;
			setPosition( cx + dx, cy + dy );
			_lx = nx - dx;
			_ly = ny - dy;
			update();
		} else if( _activeMode == 2 ) {
			int cw, ch, nx, ny, dx, dy;
			event.position( nx, ny );
			dx = nx - _lx;
			dy = ny - _ly;
			size( cw, ch );
			cw = Math::max( cw + dx, 32 );
			ch = Math::max( ch + dy, 32 );
			setSize( cw, ch );
			_lx = nx;
			_ly = ny;
			update();
		} else if( _activeWidget ) {
			mapGlobal( event.x, event.y );
			_activeWidget->mapLocal( event.x, event.y );
			_activeWidget->mouseMoveEvent( event );
		}
	}
コード例 #2
0
void AreaLightsExample::mouseMoveEvent(MouseMoveEvent& event) {
    if(_ui->handleMoveEvent(event.position())) {
        /* UI handles it */

    } else if((event.buttons() & MouseMoveEvent::Button::Left)) {
        const Vector2 delta = 3.0f*
            Vector2{event.position() - _previousMousePosition}/Vector2{GL::defaultFramebuffer.viewport().size()};
        _cameraRotation += delta;

        _previousMousePosition = event.position();

    } else return;

    redraw();
}
コード例 #3
0
void PrimitivesExample::mouseMoveEvent(MouseMoveEvent& event) {
    if(!(event.buttons() & MouseMoveEvent::Button::Left)) return;

    const Vector2 delta = 3.0f*
        Vector2{event.position() - _previousMousePosition}/
        Vector2{GL::defaultFramebuffer.viewport().size()};

    _transformation =
        Matrix4::rotationX(Rad{delta.y()})*
        _transformation*
        Matrix4::rotationY(Rad{delta.x()});

    _previousMousePosition = event.position();
    event.setAccepted();
    redraw();
}
コード例 #4
0
ファイル: Context.hpp プロジェクト: mosra/magnum-integration
template<class MouseMoveEvent> bool Context::handleMouseMoveEvent(MouseMoveEvent& event) {
    /* Ensure we use the context we're linked to */
    ImGui::SetCurrentContext(_context);

    ImGuiIO& io = ImGui::GetIO();
    io.MousePos = ImVec2(Vector2(event.position())*_eventScaling);
    return io.WantCaptureMouse;
}
コード例 #5
0
void Menu::mouseMoveEvent(MouseMoveEvent& event) {
    Vector2 cursorPosition =
        Vector2::yScale(-1.0f)*(Vector2(event.position())/Vector2(defaultFramebuffer.viewport().size())-Vector2(0.5f))*camera->projectionSize();

    MenuItem* collisionBefore = static_cast<MenuItem*>(shapes.firstCollision(*cursor));
    cursor->resetTransformation().translate(cursorPosition);
    MenuItem* collisionAfter = static_cast<MenuItem*>(shapes.firstCollision(*cursor));

    if(collisionBefore != collisionAfter) {
        if(collisionBefore) collisionBefore->hoverChanged(false);
        if(collisionAfter) collisionAfter->hoverChanged(true);
    }

    event.setAccepted();
    redraw();
}