X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.utils.ui%2Fsrc%2Forg%2Fsimantics%2Futils%2Fui%2Finternal%2Fawt%2FCleanResizeListener.java;h=902d66c316775b71d78f63801b64260adda049db;hp=c2101580d8605c8365f7c2efa6fe401aa2809b6a;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/internal/awt/CleanResizeListener.java b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/internal/awt/CleanResizeListener.java index c2101580d..902d66c31 100644 --- a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/internal/awt/CleanResizeListener.java +++ b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/internal/awt/CleanResizeListener.java @@ -1,50 +1,50 @@ -/******************************************************************************* - * Copyright (c) 2007 SAS Institute. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * SAS Institute - initial API and implementation - *******************************************************************************/ -package org.simantics.utils.ui.internal.awt; - -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; - -public class CleanResizeListener extends ControlAdapter { - - private Rectangle oldRect = null; - - public void controlResized(ControlEvent e) { - assert e != null; - assert Display.getCurrent() != null; // On SWT event thread - - // Prevent garbage from Swing lags during resize. Fill exposed areas - // with background color. - Composite composite = (Composite) e.widget; - // Rectangle newRect = composite.getBounds(); - // newRect = composite.getDisplay().map(composite.getParent(), composite, newRect); - Rectangle newRect = composite.getClientArea(); - if (oldRect != null) { - int heightDelta = newRect.height - oldRect.height; - int widthDelta = newRect.width - oldRect.width; - if ((heightDelta > 0) || (widthDelta > 0)) { - GC gc = new GC(composite); - try { - gc.fillRectangle(newRect.x, oldRect.height, newRect.width, heightDelta); - gc.fillRectangle(oldRect.width, newRect.y, widthDelta, newRect.height); - } finally { - gc.dispose(); - } - } - } - oldRect = newRect; - } - -} +/******************************************************************************* + * Copyright (c) 2007 SAS Institute. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * SAS Institute - initial API and implementation + *******************************************************************************/ +package org.simantics.utils.ui.internal.awt; + +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; + +public class CleanResizeListener extends ControlAdapter { + + private Rectangle oldRect = null; + + public void controlResized(ControlEvent e) { + assert e != null; + assert Display.getCurrent() != null; // On SWT event thread + + // Prevent garbage from Swing lags during resize. Fill exposed areas + // with background color. + Composite composite = (Composite) e.widget; + // Rectangle newRect = composite.getBounds(); + // newRect = composite.getDisplay().map(composite.getParent(), composite, newRect); + Rectangle newRect = composite.getClientArea(); + if (oldRect != null) { + int heightDelta = newRect.height - oldRect.height; + int widthDelta = newRect.width - oldRect.width; + if ((heightDelta > 0) || (widthDelta > 0)) { + GC gc = new GC(composite); + try { + gc.fillRectangle(newRect.x, oldRect.height, newRect.width, heightDelta); + gc.fillRectangle(oldRect.width, newRect.y, widthDelta, newRect.height); + } finally { + gc.dispose(); + } + } + } + oldRect = newRect; + } + +}