X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Futil%2FOverlappingFillLayout.java;fp=plugins%2Fnet.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Futil%2FOverlappingFillLayout.java;h=839ba71dbee8922bae225270711d995a7b71481e;hb=9ab92f6f3ac3dacda4b9dcf2d80b08c263905682;hp=0000000000000000000000000000000000000000;hpb=195bead5d9a92d28809137818fbaacc06cf815e3;p=Mograsim.git diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/util/OverlappingFillLayout.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/util/OverlappingFillLayout.java new file mode 100644 index 00000000..839ba71d --- /dev/null +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/util/OverlappingFillLayout.java @@ -0,0 +1,37 @@ +package net.mograsim.plugin.util; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Layout; + +public class OverlappingFillLayout extends Layout +{ + @Override + protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) + { + Point size = new Point(wHint == SWT.DEFAULT ? 0 : wHint, hHint == SWT.DEFAULT ? 0 : hHint); + + Control[] children = composite.getChildren(); + for (Control child : children) + { + Point childSize = child.computeSize(wHint, hHint, flushCache); + size.x = Math.max(size.x, childSize.x); + size.y = Math.max(size.y, childSize.y); + } + + return size; + } + + @Override + protected void layout(Composite composite, boolean flushCache) + { + Rectangle bounds = composite.getClientArea(); + + Control[] children = composite.getChildren(); + for (Control child : children) + child.setBounds(bounds); + } +} \ No newline at end of file