private void createFeedback() { dragShell = new Shell(SWT.NO_TRIM | SWT.NO_BACKGROUND); dragShell.setAlpha(175); ToolBar dragTB = new ToolBar(dragShell, SWT.RIGHT); ToolItem newTI = new ToolItem(dragTB, SWT.RADIO); newTI.setText(dragItem.getText()); newTI.setImage(dragItem.getImage()); dragTB.pack(); dragShell.pack(); dragShell.setVisible(true); }
private void animation10_Start_Simple() { if (_isShellFadingIn) { // show tool tip final Point size = _shell.getSize(); final Point defaultLocation = getToolTipLocation(size); final Point shellLocation = fixupDisplayBounds(size, defaultLocation); _shell.setLocation(shellLocation.x, shellLocation.y); _shell.setAlpha(0xff); setShellVisible(true); } else { // hide tooltip setShellVisible(false); } }
private void animation20_Runnable() { // final long start = System.nanoTime(); if (_shell == null || _shell.isDisposed() || _shell.isVisible() == false) { return; } try { /* * endAlpha will be the final fadeIn/fadeOut value when the animation stops */ int finalFadeAlpha = -1; int currentAlpha = _shell.getAlpha(); boolean isLoopBreak = false; _animationMoveCounter++; while (true) { int newAlpha = -1; if (_isShellFadingIn) { final int shellStartX = _shellStartLocation.x; final int shellStartY = _shellStartLocation.y; final int shellEndX = _shellEndLocation.x; final int shellEndY = _shellEndLocation.y; final Point shellCurrentLocation = _shell.getLocation(); final boolean isInTarget = shellCurrentLocation.x == shellEndX && shellCurrentLocation.y == shellEndY; final int diffAlpha = ALPHA_OPAQUE / _fadeInSteps; newAlpha = currentAlpha + diffAlpha; if (newAlpha > ALPHA_OPAQUE) { newAlpha = ALPHA_OPAQUE; } finalFadeAlpha = ALPHA_OPAQUE; if (isInTarget && currentAlpha == ALPHA_OPAQUE) { // target is reached and fully visible, stop animation _isShellFadingIn = false; return; } else { if (isInTarget == false) { // move to target final int diffX = shellStartX - shellEndX; final int diffY = shellStartY - shellEndY; final double moveX = (double) diffX / MOVE_STEPS * _animationMoveCounter; final double moveY = (double) diffY / MOVE_STEPS * _animationMoveCounter; final int shellCurrentX = (int) (shellStartX - moveX); final int shellCurrentY = (int) (shellStartY - moveY); _shell.setLocation(shellCurrentX, shellCurrentY); } } } else if (_isShellFadingOut) { if (_fadeOutDelayCounter++ < FADE_OUT_DELAY_STEPS) { // delay fade out _display.timerExec(FADE_TIME_INTERVAL, _animationTimer); return; } final int alphaDiff = ALPHA_OPAQUE / _fadeOutSteps; newAlpha = currentAlpha - alphaDiff; finalFadeAlpha = 0; if (newAlpha <= 0) { // shell is not visible any more, hide it now _shell.setAlpha(0); // hide shell setShellVisible(false); _isShellFadingOut = false; return; } } if (newAlpha == -1) { return; } else { if (newAlpha != currentAlpha) { _shell.setAlpha(newAlpha); } if (_shell.getAlpha() != newAlpha) { // platform do not support shell alpha, this occured on Ubuntu 12.04 if (isLoopBreak) { break; } // loop only once isLoopBreak = true; currentAlpha = finalFadeAlpha; continue; } else { _display.timerExec(FADE_TIME_INTERVAL, _animationTimer); break; } } } } catch (final Exception err) { StatusUtil.log(err); } finally { // final float timeDiff = (float) (System.nanoTime() - start) / 1000000; // System.out.println(UI.timeStampNano() + " animation20_Runnable:\t" + timeDiff + " ms\t" + // " ms"); // // TODO remove SYSTEM.OUT.PRINTLN } }
private void animation10_StartKomplex() { // final long start = System.nanoTime(); if (_isShellFadingIn) { // set fading in location final Point shellSize = _shell.getSize(); Point shellEndLocation = getToolTipLocation(shellSize); shellEndLocation = fixupDisplayBounds(shellSize, shellEndLocation); final boolean isShellVisible = _shell.isVisible(); if (shellEndLocation.x == _shellEndLocation.x && shellEndLocation.y == _shellEndLocation.y && isShellVisible) { // shell is already fading in with the correct location return; } // set new end location _shellEndLocation = shellEndLocation; if (isShellVisible) { // shell is already visible, move from the current position to the target position _shellStartLocation = _shell.getLocation(); } else { // shell is not visible, set position directly without moving animation, do only fading // animation _shellStartLocation = _shellEndLocation; _shell.setLocation(_shellStartLocation.x, _shellStartLocation.y); _shell.setAlpha(0); setShellVisible(true); } } else if (_isShellFadingOut) { // fading out has no movement _fadeOutDelayCounter = 0; } // start animation now _animationMoveCounter = 0; animation20_Runnable(); // System.out.println(UI.timeStampNano() // + " animation10_StartKomplex\t" // + ((float) (System.nanoTime() - start) / 1000000) // + " ms"); // // TODO remove SYSTEM.OUT.PRINTLN }