Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ public OfFloat(float x, float y, float width, float height) {
this(x, y, width, height, RoundingMode.ROUND, RoundingMode.ROUND);
}

private OfFloat(float x, float y, float width, float height, RoundingMode locationRounding, RoundingMode sizeRounding) {
public OfFloat(float x, float y, float width, float height, RoundingMode locationRounding, RoundingMode sizeRounding) {
this.locationRounding = locationRounding;
this.sizeRounding = sizeRounding;
setX(x);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public static Point pixelToPointAsLocation(Point point, int zoom) {
return pixelToPoint(point, zoom, RoundingMode.ROUND);
}

public static Point pixelToPointAsConservativeSize(Point point, int zoom) {
public static Point pixelToPointAsSufficientlyLargeSize(Point point, int zoom) {
return pixelToPoint(point, zoom, RoundingMode.UP);
}

Expand All @@ -150,16 +150,23 @@ private static Point.OfFloat pixelToPoint(Point.OfFloat point, int zoom) {
}

public static Rectangle pixelToPoint(Rectangle rect, int zoom) {
return pixelToPoint(rect, zoom, RoundingMode.ROUND);
}

public static Rectangle pixelToPointWithSufficientlyLargeSize(Rectangle rect, int zoom) {
return pixelToPoint(rect, zoom, RoundingMode.UP);
}

private static Rectangle pixelToPoint(Rectangle rect, int zoom, RoundingMode sizeRounding) {
if (zoom == 100 || rect == null) return rect;
Rectangle.OfFloat floatRect = Rectangle.OfFloat.from(rect);
Point.OfFloat scaledTopLeft = pixelToPoint(floatRect.getTopLeft(), zoom);
Point.OfFloat scaledBottomRight = pixelToPoint(floatRect.getBottomRight(), zoom);
Rectangle.OfFloat scaledRect = floatRect.clone();
scaledRect.setX(scaledTopLeft.getX());
scaledRect.setY(scaledTopLeft.getY());
scaledRect.setWidth(scaledBottomRight.getX() - scaledTopLeft.getX());
scaledRect.setHeight(scaledBottomRight.getY() - scaledTopLeft.getY());
return scaledRect;
float scaledX = scaledTopLeft.getX();
float scaleyY = scaledTopLeft.getY();
float scaledWidth = scaledBottomRight.getX() - scaledTopLeft.getX();
float scaledHeight = scaledBottomRight.getY() - scaledTopLeft.getY();
return new Rectangle.OfFloat(scaledX, scaleyY, scaledWidth, scaledHeight, RoundingMode.ROUND, sizeRounding);
}

public static Rectangle pixelToPoint(Drawable drawable, Rectangle rect, int zoom) {
Expand Down Expand Up @@ -252,6 +259,10 @@ public static Point pointToPixelAsLocation(Drawable drawable, Point point, int z
}

public static Point pointToPixelAsSize(Point point, int zoom) {
return pointToPixel(point, zoom, RoundingMode.ROUND);
}

public static Point pointToPixelAsSufficientlyLargeSize(Point point, int zoom) {
return pointToPixel(point, zoom, RoundingMode.UP);
}

Expand All @@ -260,16 +271,23 @@ public static Point pointToPixelAsLocation(Point point, int zoom) {
}

public static Rectangle pointToPixel(Rectangle rect, int zoom) {
return pointToPixel(rect, zoom, RoundingMode.ROUND);
}

public static Rectangle pointToPixelWithSufficientlyLargeSize(Rectangle rect, int zoom) {
return pointToPixel(rect, zoom, RoundingMode.UP);
}

private static Rectangle pointToPixel(Rectangle rect, int zoom, RoundingMode sizeRounding) {
if (zoom == 100 || rect == null) return rect;
Rectangle.OfFloat floatRect = Rectangle.OfFloat.from(rect);
Point.OfFloat scaledTopLeft = pointToPixel(floatRect.getTopLeft(), zoom);
Point.OfFloat scaledBottomRight = pointToPixel(floatRect.getBottomRight(), zoom);
Rectangle.OfFloat scaledRect = floatRect.clone();
scaledRect.setX(scaledTopLeft.getX());
scaledRect.setY(scaledTopLeft.getY());
scaledRect.setWidth(scaledBottomRight.getX() - scaledTopLeft.getX());
scaledRect.setHeight(scaledBottomRight.getY() - scaledTopLeft.getY());
return scaledRect;
float scaledX = scaledTopLeft.getX();
float scaleyY = scaledTopLeft.getY();
float scaledWidth = scaledBottomRight.getX() - scaledTopLeft.getX();
float scaledHeight = scaledBottomRight.getY() - scaledTopLeft.getY();
return new Rectangle.OfFloat(scaledX, scaleyY, scaledWidth, scaledHeight, RoundingMode.ROUND, sizeRounding);
}

public static Rectangle pointToPixel(Drawable drawable, Rectangle rect, int zoom) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ else if ((style & SWT.RIGHT) != 0) {
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
checkWidget ();
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int width = 0, height = 0, border = getBorderWidthInPixels ();
if ((style & SWT.ARROW) != 0) {
if ((style & (SWT.UP | SWT.DOWN)) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ public void clearSelection () {
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
checkWidget ();
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int width = 0, height = 0;
if (hintInPoints.x == SWT.DEFAULT) {
long newFont, oldFont = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Point computeSizeInPixels (Point hintInPoints, boolean changed) {
* Since computeTrim can be overridden by subclasses, we cannot
* call computeTrimInPixels directly.
*/
Rectangle trim = Win32DPIUtils.pointToPixel(computeTrim (0, 0, sizeInPoints.x, sizeInPoints.y), getZoom());
Rectangle trim = Win32DPIUtils.pointToPixelWithSufficientlyLargeSize(computeTrim (0, 0, sizeInPoints.x, sizeInPoints.y), getZoom());
return new Point (trim.width, trim.height);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,14 +621,14 @@ public Point computeSize (int wHint, int hHint, boolean changed){
int zoom = getZoom();
//We should never return a size that is to small, RoundingMode.UP ensures we at worst case report
//a size that is a bit too large by half a point
return Win32DPIUtils.pixelToPointAsConservativeSize(computeSizeInPixels(new Point.OfFloat(wHint, hHint, RoundingMode.UP), changed), zoom);
return Win32DPIUtils.pixelToPointAsSufficientlyLargeSize(computeSizeInPixels(new Point(wHint, hHint), changed), zoom);
}

Point computeSizeInPixels (Point hintInPoints, boolean changed) {
int width = DEFAULT_WIDTH;
int height = DEFAULT_HEIGHT;
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
if (hintInPoints.x != SWT.DEFAULT) width = hintInPixels.x;
if (hintInPoints.y != SWT.DEFAULT) height = hintInPixels.y;
int border = getBorderWidthInPixels ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected void checkSubclass () {
@Override
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int width = 0, height = 0;
int border = getBorderWidthInPixels ();
int newWidth = hintInPoints.x == SWT.DEFAULT ? 0x3FFF : hintInPixels.x + (border * 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,16 @@ protected void checkSubclass () {
public Point computeSize (int wHint, int hHint) {
checkWidget ();
int zoom = getZoom();
wHint = (wHint != SWT.DEFAULT ? DPIUtil.pointToPixel(wHint, zoom) : wHint);
hHint = (hHint != SWT.DEFAULT ? DPIUtil.pointToPixel(hHint, zoom) : hHint);
return Win32DPIUtils.pixelToPointAsConservativeSize(computeSizeInPixels(wHint, hHint), zoom);
return Win32DPIUtils.pixelToPointAsSufficientlyLargeSize(computeSizeInPixels(new Point(wHint, hHint)), zoom);
}
Point computeSizeInPixels (int wHint, int hHint) {
Point computeSizeInPixels (Point sizeHintInPoints) {
int zoom = getZoom();
Point sizeHintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(sizeHintInPoints, zoom);
int index = parent.indexOf (this);
if (index == -1) return new Point (0, 0);
int width = wHint, height = hHint;
if (wHint == SWT.DEFAULT) width = 32;
if (hHint == SWT.DEFAULT) height = 32;
int width = sizeHintInPixels.x, height = sizeHintInPixels.y;
if (sizeHintInPoints.x == SWT.DEFAULT) width = 32;
if (sizeHintInPoints.y == SWT.DEFAULT) height = 32;
if ((parent.style & SWT.VERTICAL) != 0) {
height += parent.getMargin (index);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected void checkSubclass () {
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
checkWidget ();
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int width = 0, height = 0;
if (hintInPoints.x == SWT.DEFAULT || hintInPoints.y == SWT.DEFAULT) {
if ((style & SWT.CALENDAR) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static int checkStyle (int style) {
@Override
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int height = 0, width = 0;
if (hintInPoints.x == SWT.DEFAULT || hintInPoints.y == SWT.DEFAULT) {
if (itemCount > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static int checkStyle (int style) {
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
checkWidget ();
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int width = 0, height = 0, border = getBorderWidthInPixels ();
if ((style & SWT.SEPARATOR) != 0) {
int lineWidth = getSystemMetrics (OS.SM_CXBORDER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
checkWidget ();
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int width, height;
/*
* When the text is empty, LM_GETIDEALSIZE returns zero width and height,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static int checkStyle (int style) {
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
checkWidget ();
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int width = 0, height = 0;
if (hintInPoints.x == SWT.DEFAULT) {
if ((style & SWT.H_SCROLL) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static int checkStyle (int style) {
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
checkWidget ();
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int border = getBorderWidthInPixels ();
int width = border * 2, height = border * 2;
if ((style & SWT.HORIZONTAL) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static int checkStyle (int style) {
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
checkWidget ();
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int border = getBorderWidthInPixels ();
int width = border * 2, height = border * 2;
if ((style & SWT.HORIZONTAL) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static int checkStyle (int style) {
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
checkWidget ();
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int border = getBorderWidthInPixels ();
int width = border * 2, height = border * 2;
RECT rect = new RECT ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget ();
int zoom = getZoom();
Rectangle rectangle = Win32DPIUtils.pointToPixel(new Rectangle(x, y, width, height), zoom);
return Win32DPIUtils.pixelToPoint(computeTrimInPixels(rectangle.x, rectangle.y, rectangle.width, rectangle.height), zoom);
Rectangle rectangle = Win32DPIUtils.pointToPixelWithSufficientlyLargeSize(new Rectangle(x, y, width, height), zoom);
return Win32DPIUtils.pixelToPointWithSufficientlyLargeSize(computeTrimInPixels(rectangle.x, rectangle.y, rectangle.width, rectangle.height), zoom);
}

Rectangle computeTrimInPixels (int x, int y, int width, int height) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static int checkStyle (int style) {
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
checkWidget ();
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int border = getBorderWidthInPixels ();
int width = border * 2, height = border * 2;
if ((style & SWT.HORIZONTAL) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void addVerifyListener (VerifyListener listener) {
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
checkWidget ();
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int width = 0, height = 0;
if (hintInPoints.x == SWT.DEFAULT || hintInPoints.y == SWT.DEFAULT) {
long newFont, oldFont = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ public void clearAll () {
@Override
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
if (fixScrollWidth) setScrollWidth (null, true);
//This code is intentionally commented
// if (itemHeight == -1 && hooks (SWT.MeasureItem)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ public void clearSelection () {
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
checkWidget ();
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int height = 0, width = 0;
if (hintInPoints.x == SWT.DEFAULT || hintInPoints.y == SWT.DEFAULT) {
long newFont, oldFont = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void clearSizeCache(boolean changed) {
@Override
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int count = (int)OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
if (count == this._count && hintInPixels.x == this._wHint && hintInPixels.y == this._hHint) {
// Return already cached values calculated previously
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1826,7 +1826,7 @@ long CompareFunc (long lParam1, long lParam2, long lParamSort) {
@Override
Point computeSizeInPixels (Point hintInPoints, boolean changed) {
int zoom = getZoom();
Point hintInPixels = Win32DPIUtils.pointToPixelAsSize(hintInPoints, zoom);
Point hintInPixels = Win32DPIUtils.pointToPixelAsSufficientlyLargeSize(hintInPoints, zoom);
int width = 0, height = 0;
if (hwndHeader != 0) {
HDITEM hdItem = new HDITEM ();
Expand Down
Loading