[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [albireo-dev] A small fix to address layout issues
|
Gordon Hirsch wrote:
> ... It is
> always 0, and that can cause problems during the SWT layout operation.
> The Swing component may not display at all, depending on the layout type
> and parameters.
Oh, but then negative values for the maximum size will be bad as well. Such
negative values could occur through integer overflow when there is a border.
I'm fixing it like this:
Index: org/eclipse/albireo/core/SwingControl.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.core/src/org/eclipse/albireo/core/SwingControl.java,v
retrieving revision 1.82
diff -c -3 -r1.82 SwingControl.java
*** org/eclipse/albireo/core/SwingControl.java 28 May 2008 14:09:58 -0000 1.82
--- org/eclipse/albireo/core/SwingControl.java 28 May 2008 14:18:42 -0000
***************
*** 680,695 ****
if (!isDisposed()) {
try {
onBehalfAWTTimes.put(Thread.currentThread(), new Integer(onBehalfAWTTime));
! Point minSize = new Point(min.width, min.height);
! Point prefSize = new Point(pref.width, pref.height);
! Point maxSize = new Point(max.width, max.height);
! // Augment the three sizes.
! minSize.x += 2*borderWidth;
! minSize.y += 2*borderWidth;
! prefSize.x += 2*borderWidth;
! prefSize.y += 2*borderWidth;
! maxSize.x += 2*borderWidth;
! maxSize.y += 2*borderWidth;
notePreferredSizeChanged(minSize, prefSize, maxSize);
} finally {
onBehalfAWTTimes.remove(Thread.currentThread());
--- 680,697 ----
if (!isDisposed()) {
try {
onBehalfAWTTimes.put(Thread.currentThread(), new Integer(onBehalfAWTTime));
! // Augment the three sizes by 2*borderWidth, avoiding
! // integer overflow.
! Point minSize =
! new Point(Math.min(min.width, Integer.MAX_VALUE-2*borderWidth) + 2*borderWidth,
! Math.min(min.height, Integer.MAX_VALUE-2*borderWidth) + 2*borderWidth);
! Point prefSize =
! new Point(Math.min(pref.width, Integer.MAX_VALUE-2*borderWidth) + 2*borderWidth,
! Math.min(pref.height, Integer.MAX_VALUE-2*borderWidth) + 2*borderWidth);
! Point maxSize =
! new Point(Math.min(max.width, Integer.MAX_VALUE-2*borderWidth) + 2*borderWidth,
! Math.min(max.height, Integer.MAX_VALUE-2*borderWidth) + 2*borderWidth);
! // Augment the three sizes, avoiding integer overflow.
notePreferredSizeChanged(minSize, prefSize, maxSize);
} finally {
onBehalfAWTTimes.remove(Thread.currentThread());
***************
*** 935,949 ****
int width =
(widthHint == SWT.DEFAULT ? pref.width :
widthHint < min.width ? min.width :
! widthHint > max.width ? max.width :
! widthHint)
! + 2*borderWidth;
int height =
(heightHint == SWT.DEFAULT ? pref.height :
heightHint < min.width ? min.height :
! heightHint > max.width ? max.height :
! heightHint)
! + 2*borderWidth;
if (verboseSizeLayout)
System.err.println("SWT thread: Computed size: " + width + " x " + height + " for " + swingComponent);
return new Point(width, height);
--- 937,953 ----
int width =
(widthHint == SWT.DEFAULT ? pref.width :
widthHint < min.width ? min.width :
! widthHint > max.width ? max.width :
! widthHint);
! // Augment by 2*borderWidth, avoiding integer overflow.
! width = Math.min(width, Integer.MAX_VALUE-2*borderWidth) + 2*borderWidth;
int height =
(heightHint == SWT.DEFAULT ? pref.height :
heightHint < min.width ? min.height :
! heightHint > max.width ? max.height :
! heightHint);
! // Augment by 2*borderWidth, avoiding integer overflow.
! height = Math.min(height, Integer.MAX_VALUE-2*borderWidth) + 2*borderWidth;
if (verboseSizeLayout)
System.err.println("SWT thread: Computed size: " + width + " x " + height + " for " + swingComponent);
return new Point(width, height);