/** * a Tooltip is activated when the mouse enters a controller. * * @param theController */ protected void activate(Controller<?> theController) { if (map.containsKey(theController)) { startTime = System.nanoTime(); _myController = theController; currentPosition.set( theController.getControlWindow().mouseX, theController.getControlWindow().mouseY, 0); updateText(map.get(_myController)); _myMode = ControlP5.WAIT; } }
/** * a Tooltip is activated when the mouse enters a controller. * * @param theController */ protected void activate(Controller<?> theController) { if (map.containsKey(theController)) { startTime = System.nanoTime(); controller = theController; currentPosition.set( theController.getControlWindow().getPointerX(), theController.getControlWindow().getPointerY(), 0); updateText(map.get(controller)); mode = Skatolo.WAIT; } }
/** @param theWindow */ void draw(ControlWindow theWindow) { // System.out.println(previousPosition+"\t"+currentPosition+"\t"+position); if (enabled) { if (mode >= Skatolo.WAIT) { previousPosition.set(currentPosition); currentPosition.set(theWindow.getPointerX(), theWindow.getPointerY(), 0); if (controller != null) { if (controller.getControlWindow().equals(theWindow)) { switch (mode) { case (Skatolo.WAIT): if (moved()) { startTime = System.nanoTime(); } if (System.nanoTime() > startTime + (delayInMillis * 1000000)) { position.set(currentPosition); alignH = Skatolo.RIGHT; if (position.x > (controller.getControlWindow().papplet().width - (getWidth() + 20))) { position.sub(new PVector(getWidth(), 0, 0)); alignH = Skatolo.LEFT; } mode = Skatolo.FADEIN; startTime = System.nanoTime(); currentAlpha = 0; } break; case (Skatolo.FADEIN): float t1 = System.nanoTime() - startTime; currentAlpha = (int) PApplet.map(t1, 0, 200 * 1000000, 0, maxAlpha); if (currentAlpha >= 250) { mode = Skatolo.IDLE; currentAlpha = 255; } break; case (Skatolo.IDLE): break; case (Skatolo.FADEOUT): float t2 = System.nanoTime() - startTime; currentAlpha = (int) PApplet.map(t2, 0, 200 * 1000000, maxAlpha, 0); if (currentAlpha <= 0) { mode = Skatolo.DONE; } break; case (Skatolo.DONE): controller = null; mode = Skatolo.INACTIVE; position.set(-1000, -1000, 0); } currentAlpha = PApplet.max(0, PApplet.min(currentAlpha, maxAlpha)); if (mode >= Skatolo.WAIT) { currentAlpha = (mode == Skatolo.WAIT) ? 0 : currentAlpha; theWindow.graphics().pushMatrix(); theWindow.graphics().translate(position.x, position.y); theWindow.graphics().translate(offset.x, offset.y); controllerView.display(theWindow.graphics(), null); // TODO: Warning HERE ! theWindow.graphics().popMatrix(); } if (mode < Skatolo.FADEOUT) { if (moved()) { deactivate(0); } } } } } } }
/** @param theWindow */ void draw(ControlWindow theWindow) { if (enabled) { if (_myMode >= ControlP5.WAIT) { previousPosition.set(currentPosition); currentPosition.set(theWindow.mouseX, theWindow.mouseY, 0); if (_myController != null) { if (_myController.getControlWindow().equals(theWindow)) { switch (_myMode) { case (ControlP5.WAIT): if (moved()) { startTime = System.nanoTime(); } if (System.nanoTime() > startTime + (_myDelayInMillis * 1000000)) { position.set(currentPosition); _myAlignH = ControlP5.RIGHT; if (position.x > (_myController.getControlWindow().papplet().width - (getWidth() + 20))) { position.sub(new PVector(getWidth(), 0, 0)); _myAlignH = ControlP5.LEFT; } _myMode = ControlP5.FADEIN; startTime = System.nanoTime(); _myAlpha = 0; } break; case (ControlP5.FADEIN): float t1 = System.nanoTime() - startTime; _myAlpha = (int) PApplet.map(t1, 0, 200 * 1000000, 0, _myMaxAlpha); if (_myAlpha >= 250) { _myMode = ControlP5.IDLE; _myAlpha = 255; } break; case (ControlP5.IDLE): break; case (ControlP5.FADEOUT): float t2 = System.nanoTime() - startTime; _myAlpha = (int) PApplet.map(t2, 0, 200 * 1000000, _myMaxAlpha, 0); if (_myAlpha <= 0) { _myMode = ControlP5.DONE; } break; case (ControlP5.DONE): _myController = null; _myMode = ControlP5.INACTIVE; position.set(-1000, -1000, 0); } _myAlpha = PApplet.max(0, PApplet.min(_myAlpha, _myMaxAlpha)); if (_myMode >= ControlP5.WAIT) { _myAlpha = (_myMode == ControlP5.WAIT) ? 0 : _myAlpha; theWindow.papplet().pushMatrix(); theWindow.papplet().translate(position.x, position.y); theWindow.papplet().translate(offset.x, offset.y); _myView.display(theWindow.papplet(), null); theWindow.papplet().popMatrix(); } if (_myMode < ControlP5.FADEOUT) { if (moved()) { deactivate(0); } } } } } } }