Merge pull request #5312 from deathbeam/snap-center
Add TOP_CENTER snap corner to snap center viewport
This commit is contained in:
@@ -33,6 +33,7 @@ import static net.runelite.client.ui.overlay.OverlayPosition.ABOVE_CHATBOX_RIGHT
|
|||||||
import static net.runelite.client.ui.overlay.OverlayPosition.BOTTOM_LEFT;
|
import static net.runelite.client.ui.overlay.OverlayPosition.BOTTOM_LEFT;
|
||||||
import static net.runelite.client.ui.overlay.OverlayPosition.BOTTOM_RIGHT;
|
import static net.runelite.client.ui.overlay.OverlayPosition.BOTTOM_RIGHT;
|
||||||
import static net.runelite.client.ui.overlay.OverlayPosition.CANVAS_TOP_RIGHT;
|
import static net.runelite.client.ui.overlay.OverlayPosition.CANVAS_TOP_RIGHT;
|
||||||
|
import static net.runelite.client.ui.overlay.OverlayPosition.TOP_CENTER;
|
||||||
import static net.runelite.client.ui.overlay.OverlayPosition.TOP_LEFT;
|
import static net.runelite.client.ui.overlay.OverlayPosition.TOP_LEFT;
|
||||||
import static net.runelite.client.ui.overlay.OverlayPosition.TOP_RIGHT;
|
import static net.runelite.client.ui.overlay.OverlayPosition.TOP_RIGHT;
|
||||||
|
|
||||||
@@ -40,11 +41,12 @@ import static net.runelite.client.ui.overlay.OverlayPosition.TOP_RIGHT;
|
|||||||
@Value
|
@Value
|
||||||
class OverlayBounds
|
class OverlayBounds
|
||||||
{
|
{
|
||||||
private final Rectangle topLeft, topRight, bottomLeft, bottomRight, aboveChatboxRight, canvasTopRight;
|
private final Rectangle topLeft, topCenter, topRight, bottomLeft, bottomRight, aboveChatboxRight, canvasTopRight;
|
||||||
|
|
||||||
OverlayBounds(OverlayBounds other)
|
OverlayBounds(OverlayBounds other)
|
||||||
{
|
{
|
||||||
topLeft = new Rectangle(other.topLeft);
|
topLeft = new Rectangle(other.topLeft);
|
||||||
|
topCenter = new Rectangle(other.topCenter);
|
||||||
topRight = new Rectangle(other.topRight);
|
topRight = new Rectangle(other.topRight);
|
||||||
bottomLeft = new Rectangle(other.bottomLeft);
|
bottomLeft = new Rectangle(other.bottomLeft);
|
||||||
bottomRight = new Rectangle(other.bottomRight);
|
bottomRight = new Rectangle(other.bottomRight);
|
||||||
@@ -56,6 +58,7 @@ class OverlayBounds
|
|||||||
{
|
{
|
||||||
final OverlayBounds translated = new OverlayBounds(this);
|
final OverlayBounds translated = new OverlayBounds(this);
|
||||||
translated.getTopRight().translate(x, 0);
|
translated.getTopRight().translate(x, 0);
|
||||||
|
translated.getTopCenter().translate(x / 2, 0);
|
||||||
translated.getBottomLeft().translate(0, y);
|
translated.getBottomLeft().translate(0, y);
|
||||||
translated.getBottomRight().translate(x, y);
|
translated.getBottomRight().translate(x, y);
|
||||||
translated.getAboveChatboxRight().translate(x, y);
|
translated.getAboveChatboxRight().translate(x, y);
|
||||||
@@ -69,6 +72,8 @@ class OverlayBounds
|
|||||||
{
|
{
|
||||||
case TOP_LEFT:
|
case TOP_LEFT:
|
||||||
return topLeft;
|
return topLeft;
|
||||||
|
case TOP_CENTER:
|
||||||
|
return topCenter;
|
||||||
case TOP_RIGHT:
|
case TOP_RIGHT:
|
||||||
return topRight;
|
return topRight;
|
||||||
case BOTTOM_LEFT:
|
case BOTTOM_LEFT:
|
||||||
@@ -90,6 +95,10 @@ class OverlayBounds
|
|||||||
{
|
{
|
||||||
return TOP_LEFT;
|
return TOP_LEFT;
|
||||||
}
|
}
|
||||||
|
else if (bounds == topCenter)
|
||||||
|
{
|
||||||
|
return TOP_CENTER;
|
||||||
|
}
|
||||||
else if (bounds == topRight)
|
else if (bounds == topRight)
|
||||||
{
|
{
|
||||||
return TOP_RIGHT;
|
return TOP_RIGHT;
|
||||||
@@ -118,6 +127,6 @@ class OverlayBounds
|
|||||||
|
|
||||||
Collection<Rectangle> getBounds()
|
Collection<Rectangle> getBounds()
|
||||||
{
|
{
|
||||||
return Arrays.asList(topLeft, topRight, bottomLeft, bottomRight, aboveChatboxRight, canvasTopRight);
|
return Arrays.asList(topLeft, topCenter, topRight, bottomLeft, bottomRight, aboveChatboxRight, canvasTopRight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ public enum OverlayPosition
|
|||||||
* Place overlay in the top left viewport area
|
* Place overlay in the top left viewport area
|
||||||
*/
|
*/
|
||||||
TOP_LEFT,
|
TOP_LEFT,
|
||||||
|
/**
|
||||||
|
* Place overlay in the top center viewport area
|
||||||
|
*/
|
||||||
|
TOP_CENTER,
|
||||||
/**
|
/**
|
||||||
* Place overlay in the top right viewport area
|
* Place overlay in the top right viewport area
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -443,9 +443,14 @@ public class OverlayRenderer extends MouseListener implements KeyListener
|
|||||||
viewportOffset + BORDER,
|
viewportOffset + BORDER,
|
||||||
viewportOffset + BORDER_TOP);
|
viewportOffset + BORDER_TOP);
|
||||||
|
|
||||||
|
final Point topCenterPoint = new Point(
|
||||||
|
viewportOffset + viewportBounds.width / 2,
|
||||||
|
viewportOffset + BORDER
|
||||||
|
);
|
||||||
|
|
||||||
final Point topRightPoint = new Point(
|
final Point topRightPoint = new Point(
|
||||||
viewportOffset + viewportBounds.width - BORDER,
|
viewportOffset + viewportBounds.width - BORDER,
|
||||||
viewportOffset + BORDER);
|
topCenterPoint.y);
|
||||||
|
|
||||||
final Point bottomLeftPoint = new Point(
|
final Point bottomLeftPoint = new Point(
|
||||||
topLeftPoint.x,
|
topLeftPoint.x,
|
||||||
@@ -471,6 +476,7 @@ public class OverlayRenderer extends MouseListener implements KeyListener
|
|||||||
|
|
||||||
return new OverlayBounds(
|
return new OverlayBounds(
|
||||||
new Rectangle(topLeftPoint, SNAP_CORNER_SIZE),
|
new Rectangle(topLeftPoint, SNAP_CORNER_SIZE),
|
||||||
|
new Rectangle(topCenterPoint, SNAP_CORNER_SIZE),
|
||||||
new Rectangle(topRightPoint, SNAP_CORNER_SIZE),
|
new Rectangle(topRightPoint, SNAP_CORNER_SIZE),
|
||||||
new Rectangle(bottomLeftPoint, SNAP_CORNER_SIZE),
|
new Rectangle(bottomLeftPoint, SNAP_CORNER_SIZE),
|
||||||
new Rectangle(bottomRightPoint, SNAP_CORNER_SIZE),
|
new Rectangle(bottomRightPoint, SNAP_CORNER_SIZE),
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ public class OverlayUtil
|
|||||||
result.x -= dimension.width + (dimension.width == 0 ? 0 : padding);
|
result.x -= dimension.width + (dimension.width == 0 ? 0 : padding);
|
||||||
break;
|
break;
|
||||||
case TOP_LEFT:
|
case TOP_LEFT:
|
||||||
|
case TOP_CENTER:
|
||||||
result.y += dimension.height + (dimension.height == 0 ? 0 : padding);
|
result.y += dimension.height + (dimension.height == 0 ? 0 : padding);
|
||||||
break;
|
break;
|
||||||
case CANVAS_TOP_RIGHT:
|
case CANVAS_TOP_RIGHT:
|
||||||
@@ -226,6 +227,9 @@ public class OverlayUtil
|
|||||||
case TOOLTIP:
|
case TOOLTIP:
|
||||||
case TOP_LEFT:
|
case TOP_LEFT:
|
||||||
break;
|
break;
|
||||||
|
case TOP_CENTER:
|
||||||
|
result.x = result.x - dimension.width / 2;
|
||||||
|
break;
|
||||||
case BOTTOM_LEFT:
|
case BOTTOM_LEFT:
|
||||||
result.y = result.y - dimension.height;
|
result.y = result.y - dimension.height;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user