Java Code Examples for org.eclipse.swt.widgets.Shell#setAlpha()

The following examples show how to use org.eclipse.swt.widgets.Shell#setAlpha() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DarkPanel.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Show the dark panel
 */
public void show() {
	if (parent.isDisposed()) {
		SWT.error(SWT.ERROR_WIDGET_DISPOSED);
	}

	panel = new Shell(parent, SWT.APPLICATION_MODAL | SWT.NO_TRIM);
	panel.setLayout(new FillLayout());
	panel.setAlpha(alpha);

	panel.addListener(SWT.KeyUp, event -> {
		event.doit = false;
	});

	canvas = new Canvas(panel, SWT.NO_BACKGROUND | SWT.DOUBLE_BUFFERED);
	canvas.addPaintListener(event -> {
		paintCanvas(event);
	});

	panel.setBounds(panel.getDisplay().map(parent, null, parent.getClientArea()));
	panel.open();
}
 
Example 2
Source File: Notifier.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param shell shell that will appear
 */
protected static void makeShellAppears(final Shell shell) {
	if (shell == null || shell.isDisposed()) {
		return;
	}

	final Rectangle clientArea = Display.getDefault().getPrimaryMonitor().getClientArea();
	final int startX = clientArea.x + clientArea.width - shell.getSize().x;

	final int stepForPosition = MAX_DURATION_FOR_OPENING / shell.getSize().y * STEP;
	final int stepForAlpha = STEP * 255 / shell.getSize().y;

	final int lastPosition = clientArea.y + clientArea.height - shell.getSize().y;

	shell.setAlpha(0);
	shell.setLocation(startX, clientArea.y + clientArea.height);
	shell.open();

	shell.getDisplay().timerExec(stepForPosition, new Runnable() {

		@Override
		public void run() {

			if (shell == null || shell.isDisposed()) {
				return;
			}

			shell.setLocation(startX, shell.getLocation().y - STEP);
			shell.setAlpha(shell.getAlpha() + stepForAlpha);
			if (shell.getLocation().y >= lastPosition) {
				shell.getDisplay().timerExec(stepForPosition, this);
			} else {
				shell.setAlpha(255);
				Display.getDefault().timerExec(DISPLAY_TIME, fadeOut(shell, false));
			}
		}
	});

}
 
Example 3
Source File: Notifier.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param shell shell that will disappear
 * @param fast if true, the fading is much faster
 * @return a runnable
 */
private static Runnable fadeOut(final Shell shell, final boolean fast) {
	return new Runnable() {

		@Override
		public void run() {
			if (shell == null || shell.isDisposed()) {
				return;
			}

			int currentAlpha = shell.getAlpha();
			currentAlpha -= FADE_OUT_STEP * (fast ? 8 : 1);

			if (currentAlpha <= 0) {
				shell.setAlpha(0);
				shell.dispose();
				return;
			}

			shell.setAlpha(currentAlpha);

			Display.getDefault().timerExec(FADE_TIMER, this);

		}

	};
}
 
Example 4
Source File: ColumnFileCount.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
private void openFilesMiniView(DownloadManager dm, TableCell cell) {
	UISWTViewBuilderCore builder = ViewManagerSWT.getInstance().getBuilder(
			Download.class, FilesView.MSGID_PREFIX);
	if (builder == null) {
		return;
	}
	SkinnedDialog skinnedDialog = BaseMdiEntry.buildSkinnedDialog("FilesView",
			dm, builder);
	if (skinnedDialog == null) {
		return;
	}

	skinnedDialog.setTitle(dm.getDisplayName());

	Shell shell = skinnedDialog.getShell();

	Rectangle bounds = ((TableCellSWT) cell).getBoundsOnDisplay();
	bounds.y += bounds.height;
	bounds.width = 630;
	bounds.height = (16 * dm.getNumFileInfos()) + 60;
	Rectangle realBounds = shell.computeTrim(0, 0, bounds.width, bounds.height);
	realBounds.width -= realBounds.x;
	realBounds.height -= realBounds.y;
	realBounds.x = bounds.x;
	realBounds.y = bounds.y;
	if (bounds.height > 500) {
		bounds.height = 500;
	}
	shell.setBounds(realBounds);
	shell.setAlpha(230);

	Utils.verifyShellRect(shell, true);

	skinnedDialog.openUnadjusted();
}
 
Example 5
Source File: DisplayOverlay.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public DisplayOverlay(final LayeredDisplayView view, final Composite c,
		final IOverlayProvider<OverlayInfo> provider) {
	this.createExtraInfo = provider != null;
	this.view = view;
	final IPartService ps = ((IWorkbenchPart) view).getSite().getService(IPartService.class);
	ps.addPartListener(pl2);
	referenceComposite = c;
	// parentShell = c.getShell();
	popup = new Shell(c.getShell(), SWT.NO_TRIM | SWT.NO_FOCUS);
	popup.setAlpha(140);
	final FillLayout layout = new FillLayout();
	layout.type = SWT.VERTICAL;
	layout.spacing = 10;
	popup.setLayout(layout);
	popup.setBackground(IGamaColors.BLACK.color());
	createPopupControl();
	popup.setAlpha(140);
	popup.layout();
	c.getShell().addShellListener(listener);
	// parentShell.addControlListener(listener);
	c.addControlListener(listener);
	if (provider != null) {
		provider.setTarget(new ThreadedOverlayUpdater(this), view.getDisplaySurface());
	}
	// if (GamaPreferences.Displays.CORE_SHOW_FPS.getValue()) {
	timer.schedule(new FPSTask(), 0, 1000);
	// }
}
 
Example 6
Source File: WorkaroundForIssue1353.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private static void createShell() {
	DEBUG.OUT("Shell created");
	shell = new Shell(WorkbenchHelper.getShell(), SWT.APPLICATION_MODAL);
	shell.setSize(5, 5);
	shell.setAlpha(0);
	shell.setBackground(IGamaColors.BLACK.color());
}