private int getDX(final MouseEvent e) { return e.x - _lastState.getX(); }
private int getDX(final MouseEvent e) { return e.x - _lastState.getX(); }
private int getDX(final MouseEvent e) { return e.getX() - _lastState.getX(); }
private int getDX(final MouseEvent e) { return e.getX() - _lastState.getX(); }
private int getDX(final MouseEvent me) { return me.getX() - _lastState.getX(); }
@Override public boolean mouseClicked(final MouseButton button, final InputState state) { final int mouseX = state.getMouseState().getX(), mouseY = state.getMouseState().getY(); final UIComponent over = getUIComponent(mouseX, mouseY); if (over == _titleLabel || over == this) { _drawer.toggleExpanded(); } return true; } }
/** * Handle mouse releases. * * @param button * the button that was release. * @param currentIS * the current input state. * @return true if this event is consumed. */ public boolean fireMouseButtonReleased(final MouseButton button, final InputState currentIS) { boolean consumed = false; final int mouseX = currentIS.getMouseState().getX(), mouseY = currentIS.getMouseState().getY(); // if we have previously sent a component a mouseDown, send it the release event final UIComponent component = _mousePressedComponent; _mousePressedComponent = null; if (component != null) { consumed |= component.mouseReleased(button, currentIS); final int distance = Math.abs(mouseX - _mousePressedX) + Math.abs(mouseY - _mousePressedY); if (distance < UIHud.MOUSE_CLICK_SENSITIVITY) { component.mouseClicked(button, currentIS); } } if (button == _dragButton && _dragListener != null) { _dragListener.endDrag(component, mouseX, mouseY); _dragListener = null; consumed = true; } return consumed; }
/** * Handle wheel events. * * @param wheelDx * the change in wheel position. * @param currentIS * the current input state. * @return if this event is consumed. */ public boolean fireMouseWheelMoved(final int wheelDx, final InputState currentIS) { final UIComponent over = getUIComponent(currentIS.getMouseState().getX(), currentIS.getMouseState().getY()); if (over == null) { return false; } return over.mouseWheel(wheelDx, currentIS); }
@Override public void invoke(final long window, final double xoffset, final double yoffset) { wheelAccum += yoffset; final int dw = (int) MathUtils.floor(wheelAccum); if (dw == 0) { return; } wheelAccum -= dw; // Add our new state final int x = _lastState != null ? _lastState.getX() : 0; final int y = _lastState != null ? _lastState.getY() : 0; final MouseState event = new MouseState(x, y, 0, 0, dw, Maps.newEnumMap(_lastButtonState), null); addNextState(event); } });
/** * Handle wheel events. * * @param wheelDx * the change in wheel position. * @param currentIS * the current input state. * @return if this event is consumed. */ public boolean fireMouseWheelMoved(final int wheelDx, final InputState currentIS) { final UIComponent over = getUIComponent(currentIS.getMouseState().getX(), currentIS.getMouseState().getY()); if (over == null) { return false; } return over.mouseWheel(wheelDx, currentIS); }
@Override public void invoke(final long window, final int button, final int action, final int mods) { if (_ignoreInput) { return; } final MouseButton mb = getButtonByIndex(button); final boolean down = action == GLFW.GLFW_PRESS; final ButtonState state = down ? ButtonState.DOWN : ButtonState.UP; // check for clicks processButtonForClick(mb, down); // save our state _lastButtonState.put(mb, state); // Add our new state final int x = _lastState != null ? _lastState.getX() : 0; final int y = _lastState != null ? _lastState.getY() : 0; addNextState(new MouseState(x, y, 0, 0, 0, Maps.newEnumMap(_lastButtonState), _sendClickState && !_clicks.isEmpty() ? EnumMultiset.create(_clicks) : null)); } });
@Override public void invoke(final long window, final double xpos, final double ypos) { if (_ignoreInput) { return; } final int x = (int) MathUtils.round(xpos); final int y = _canvas.getContentHeight() - (int) MathUtils.round(ypos); final int dx = _lastState != null ? x - _lastState.getX() : 0; final int dy = _lastState != null ? y - _lastState.getY() : 0; if (dx != 0.0 || dy != 0.0) { _clickArmed.clear(); _clicks.clear(); _sendClickState = false; } // Add our new state final MouseState event = new MouseState(x, y, dx, dy, 0, Maps.newEnumMap(_lastButtonState), null); addNextState(event); } });
@Override public boolean mousePressed(final MouseButton button, final InputState state) { switchState(_writingState); final int x = state.getMouseState().getX() - AbstractUITextEntryComponent.this.getHudX() - AbstractUITextEntryComponent.this.getPadding().getLeft(); final int y = state.getMouseState().getY() - AbstractUITextEntryComponent.this.getHudY() - AbstractUITextEntryComponent.this.getPadding().getBottom(); setCaretPosition(_uiText != null ? _uiText.findCaretPosition(x, y) : 0); return true; }
@Override public boolean mousePressed(final MouseButton button, final InputState state) { switchState(_writingState); final int x = state.getMouseState().getX() - AbstractUITextEntryComponent.this.getHudX() - AbstractUITextEntryComponent.this.getPadding().getLeft(); final int y = state.getMouseState().getY() - AbstractUITextEntryComponent.this.getHudY() - AbstractUITextEntryComponent.this.getPadding().getBottom(); setCaretPosition(_uiText != null ? _uiText.findCaretPosition(x, y) : 0); clearSelection(); return true; }
@Override public void processInput(final Canvas source, final TwoInputStates inputStates, final AtomicBoolean inputConsumed, final InteractManager manager) { final Camera camera = source.getCanvasRenderer().getCamera(); final MouseState current = inputStates.getCurrent().getMouseState(); final MouseState previous = inputStates.getPrevious().getMouseState(); // first process mouse over state checkMouseOver(source, current, manager); // Now check drag status if (!checkShouldDrag(camera, current, previous, inputConsumed, manager)) { return; } // act on drag final Vector2 oldMouse = new Vector2(previous.getX(), previous.getY()); final double scale = getNewScale(oldMouse, current, camera, manager); // Set new scale on spatial state manager.getSpatialState().getTransform().setScale(scale); // apply our filters, if any, now that we've made updates. applyFilters(manager); }
@Override public void processInput(final Canvas source, final TwoInputStates inputStates, final AtomicBoolean inputConsumed, final InteractManager manager) { final Camera camera = source.getCanvasRenderer().getCamera(); final MouseState current = inputStates.getCurrent().getMouseState(); final MouseState previous = inputStates.getPrevious().getMouseState(); // first process mouse over state checkMouseOver(source, current, manager); // Now check drag status if (!checkShouldDrag(camera, current, previous, inputConsumed, manager)) { return; } // act on drag final Vector2 oldMouse = new Vector2(previous.getX(), previous.getY()); final Vector3 loc = getNewOffset(oldMouse, current, camera, manager); final Transform transform = manager.getSpatialState().getTransform(); transform.setTranslation(loc.addLocal(transform.getTranslation())); // apply our filters, if any, now that we've made updates. applyFilters(manager); }
protected Vector3 getNewOffset(final Vector2 oldMouse, final MouseState current, final Camera camera, final InteractManager manager) { // make plane object final Plane pickPlane = new Plane().setPlanePoints(_calcVec3A, _calcVec3B, _calcVec3C); // find out where we were hitting the plane before getPickRay(oldMouse, camera); if (!_calcRay.intersectsPlane(pickPlane, _calcVec3A)) { return _calcVec3A.zero(); } // find out where we are hitting the plane now getPickRay(new Vector2(current.getX(), current.getY()), camera); if (!_calcRay.intersectsPlane(pickPlane, _calcVec3B)) { return _calcVec3A.zero(); } // convert to target coord space final Node parent = manager.getSpatialTarget().getParent(); if (parent != null) { parent.getWorldTransform().applyInverse(_calcVec3A); parent.getWorldTransform().applyInverse(_calcVec3B); } return _calcVec3B.subtractLocal(_calcVec3A); } }
@Override public void processInput(final Canvas source, final TwoInputStates inputStates, final AtomicBoolean inputConsumed, final InteractManager manager) { final Camera camera = source.getCanvasRenderer().getCamera(); final MouseState current = inputStates.getCurrent().getMouseState(); final MouseState previous = inputStates.getPrevious().getMouseState(); // first process mouse over state checkMouseOver(source, current, manager); // Now check drag status if (!checkShouldDrag(camera, current, previous, inputConsumed, manager)) { return; } // act on drag if (_lastDragSpatial != null && _lastDragSpatial.getParent() instanceof InteractArrow) { final InteractArrow arrow = (InteractArrow) _lastDragSpatial.getParent(); _lastArrow = arrow; final Vector2 oldMouse = new Vector2(previous.getX(), previous.getY()); final Vector3 loc = getNewOffset(arrow, oldMouse, current, camera, manager); final Transform transform = manager.getSpatialState().getTransform(); transform.setTranslation(loc.addLocal(transform.getTranslation())); // apply our filters, if any, now that we've made updates. applyFilters(manager); } }
protected double getNewScale(final Vector2 oldMouse, final MouseState current, final Camera camera, final InteractManager manager) { // calculate a plane running through the Arrow and facing the camera. _calcVec3A.set(_handle.getWorldTranslation()); _calcVec3B.set(_calcVec3A).addLocal(camera.getLeft()); _calcVec3C.set(_calcVec3A).addLocal(_arrowDirection); final Plane pickPlane = new Plane().setPlanePoints(_calcVec3A, _calcVec3B, _calcVec3C); // find out where we were hitting the plane before getPickRay(oldMouse, camera); _calcRay.intersectsPlane(pickPlane, _calcVec3A); final double oldHeight = _calcVec3A.getY(); // find out where we are hitting the plane now getPickRay(new Vector2(current.getX(), current.getY()), camera); _calcRay.intersectsPlane(pickPlane, _calcVec3A); final double newHeight = _calcVec3A.getY(); // Use distance between points against arrow length to determine how big we need to grow our bounding radius final double delta = newHeight - oldHeight; final double oldRadius = manager.getSpatialTarget().getWorldBound().getRadius(); return manager.getSpatialTarget().getScale().getY() * (1.0 + delta / oldRadius); } }
@Override public void processInput(final Canvas source, final TwoInputStates inputStates, final AtomicBoolean inputConsumed, final InteractManager manager) { final Camera camera = source.getCanvasRenderer().getCamera(); final MouseState current = inputStates.getCurrent().getMouseState(); final MouseState previous = inputStates.getPrevious().getMouseState(); // first process mouse over state checkMouseOver(source, current, manager); // Now check drag status if (!checkShouldDrag(camera, current, previous, inputConsumed, manager)) { return; } // act on drag final PickData pickData = _results.getNumber() > 0 ? _results.getPickData(0) : null; if (pickData != null && _lastDragSpatial instanceof Mesh && pickData.getIntersectionRecord().getNumberOfIntersections() > 0) { final PrimitiveKey key = pickData.getIntersectionRecord().getIntersectionPrimitive(0); ((Mesh) _lastDragSpatial).getMeshData().getPrimitiveVertices(key.getPrimitiveIndex(), key.getSection(), new Vector3[] { _calcVec3A, _calcVec3B, _calcVec3C }); _lastDragSpatial.localToWorld(_calcVec3A, _calcVec3A); _lastDragSpatial.localToWorld(_calcVec3B, _calcVec3B); _lastDragSpatial.localToWorld(_calcVec3C, _calcVec3C); final Vector2 oldMouse = new Vector2(previous.getX(), previous.getY()); final Vector3 loc = getNewOffset(oldMouse, current, camera, manager); final Transform transform = manager.getSpatialState().getTransform(); transform.setTranslation(loc.addLocal(transform.getTranslation())); // apply our filters, if any, now that we've made updates. applyFilters(manager); } }