Skip to content

Amartya4256/c tab folder fix float aware #2211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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 @@ -892,9 +892,10 @@ public Rectangle getClientArea() {
trim.height += wrapHeight;
}
if (minimized) return new Rectangle(-trim.x, -trim.y, 0, 0);
int width = size.x - trim.width;
int height = size.y - trim.height;
return new Rectangle(-trim.x, -trim.y, width, height);
float width = ((Point.OfFloat) size).getX() - trim.width;
float height = ((Point.OfFloat) size).getY() - trim.height;
Rectangle.OfFloat r = new Rectangle.OfFloat(-trim.x, -trim.y, width, height);
return r;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void translateRectangleInGapPartiallyInRightBackAndForthInSingleZoomShouldBeTheS
void translateRectangleInGapPartiallyInRightBackAndForthInMultiZoomShouldBeInside() {
MultiZoomCoordinateSystemMapper mapper = getMultiZoomCoordinateSystemMapper();
setupMonitors(mapper);
Rectangle rectInPts = new MonitorAwareRectangle(1950, 400, 150, 100, monitors[1]);
Rectangle rectInPts = new Rectangle.WithMonitor(1950, 400, 150, 100, monitors[1]);
Rectangle rectInPxs = mapper.translateToDisplayCoordinates(rectInPts, monitors[0].getZoom());
assertEquals(rectInPts, mapper.translateFromDisplayCoordinates(rectInPxs, monitors[0].getZoom()));
}
Expand Down Expand Up @@ -223,15 +223,15 @@ private Point createExpectedPoint(CoordinateSystemMapper mapper, int x, int y, M
if (mapper instanceof SingleZoomCoordinateSystemMapper) {
return new Point(x, y);
} else {
return new MonitorAwarePoint(x, y, monitor);
return new Point.WithMonitor(x, y, monitor);
}
}

private Rectangle createExpectedRectangle(CoordinateSystemMapper mapper, int x, int y, int width, int height, Monitor monitor) {
if (mapper instanceof SingleZoomCoordinateSystemMapper) {
return new Rectangle(x, y, width, height);
} else {
return new MonitorAwareRectangle(x, y, width, height, monitor);
return new Rectangle.WithMonitor(x, y, width, height, monitor);
}
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import java.io.*;

import org.eclipse.swt.widgets.*;

/**
* Instances of this class represent places on the (x, y)
* coordinate plane.
Expand All @@ -41,7 +43,7 @@
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
*/

public sealed class Point implements Serializable permits MonitorAwarePoint {
public sealed class Point implements Serializable permits Point.OfFloat {

/**
* the x coordinate of the point
Expand All @@ -66,6 +68,8 @@ public Point (int x, int y) {
this.y = y;
}

private Point() {}

/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
Expand Down Expand Up @@ -116,5 +120,84 @@ public String toString () {
return "Point {" + x + ", " + y + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}

/**
* Instances of this class represent {@link org.eclipse.swt.graphics.Point}
* objects with the fields capable of storing more precise value in float.
*
* @since 3.130
* @noreference This class is not intended to be referenced by clients
*/
public static sealed class OfFloat extends Point permits Point.WithMonitor {

private static final long serialVersionUID = -1862062276431597053L;

public float residualX, residualY;

public OfFloat(int x, int y) {
super(x, y);
}

public OfFloat(float x, float y) {
super();
this.x = Math.round(x);
this.y = Math.round(y);
this.residualX = x - this.x;
this.residualY = y - this.y;
}

public float getX() {
return x + residualX;
}

public float getY() {
return y + residualY;
}

public void setX(float x) {
this.x = Math.round(x);
this.residualX = x - this.x;
}

public void setY(float y) {
this.y = Math.round(y);
this.residualY = y - this.y;
}
}

/**
* Instances of this class represent {@link org.eclipse.swt.graphics.Point.OfFloat}
* objects along with the context of the monitor in relation to which they are
* placed on the display. The monitor awareness makes it easy to scale and
* translate the points between pixels and points.
*
* @since 3.130
* @noreference This class is not intended to be referenced by clients
*/
public static final class WithMonitor extends Point.OfFloat {

private static final long serialVersionUID = 6077427420686999194L;

private final Monitor monitor;

/**
* Constructs a new Point.WithMonitor
*
* @param x the x coordinate of the point
* @param y the y coordinate of the point
* @param monitor the monitor with whose context the point is created
*/
public WithMonitor(int x, int y, Monitor monitor) {
super(x, y);
this.monitor = monitor;
}

/**
* {@return the monitor with whose context the instance is created}
*/
public Monitor getMonitor() {
return monitor;
}

}

}
Loading
Loading