Merge pull request #11126 from Alexsuperfly/mouse-tooltips-moving

OverlayRenderer: prevent moving DYNAMIC and TOOLTIP overlays
This commit is contained in:
Tomas Slusny
2020-03-31 18:08:37 +02:00
committed by GitHub

View File

@@ -213,29 +213,7 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
for (Overlay overlay : overlays) for (Overlay overlay : overlays)
{ {
OverlayPosition overlayPosition = overlay.getPosition(); final OverlayPosition overlayPosition = getCorrectedOverlayPosition(overlay);
if (overlay.getPreferredPosition() != null)
{
overlayPosition = overlay.getPreferredPosition();
}
if (!isResizeable)
{
// On fixed mode, ABOVE_CHATBOX_RIGHT is in the same location as
// BOTTOM_RIGHT and CANVAS_TOP_RIGHT is same as TOP_RIGHT.
// Just use BOTTOM_RIGHT and TOP_RIGHT to prevent overlays from
// drawing over each other.
switch (overlayPosition)
{
case CANVAS_TOP_RIGHT:
overlayPosition = OverlayPosition.TOP_RIGHT;
break;
case ABOVE_CHATBOX_RIGHT:
overlayPosition = OverlayPosition.BOTTOM_RIGHT;
break;
}
}
if (overlayPosition == OverlayPosition.DYNAMIC || overlayPosition == OverlayPosition.TOOLTIP) if (overlayPosition == OverlayPosition.DYNAMIC || overlayPosition == OverlayPosition.TOOLTIP)
{ {
@@ -333,6 +311,13 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
{ {
for (Overlay overlay : overlayManager.getOverlays()) for (Overlay overlay : overlayManager.getOverlays())
{ {
final OverlayPosition overlayPosition = getCorrectedOverlayPosition(overlay);
if (overlayPosition == OverlayPosition.DYNAMIC || overlayPosition == OverlayPosition.TOOLTIP)
{
continue;
}
if (overlay.getBounds().contains(mousePoint)) if (overlay.getBounds().contains(mousePoint))
{ {
if (SwingUtilities.isRightMouseButton(mouseEvent)) if (SwingUtilities.isRightMouseButton(mouseEvent))
@@ -512,6 +497,35 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
overlay.getBounds().setSize(dimension); overlay.getBounds().setSize(dimension);
} }
private OverlayPosition getCorrectedOverlayPosition(final Overlay overlay)
{
OverlayPosition overlayPosition = overlay.getPosition();
if (overlay.getPreferredPosition() != null)
{
overlayPosition = overlay.getPreferredPosition();
}
if (!isResizeable)
{
// On fixed mode, ABOVE_CHATBOX_RIGHT is in the same location as
// BOTTOM_RIGHT and CANVAS_TOP_RIGHT is same as TOP_RIGHT.
// Just use BOTTOM_RIGHT and TOP_RIGHT to prevent overlays from
// drawing over each other.
switch (overlayPosition)
{
case CANVAS_TOP_RIGHT:
overlayPosition = OverlayPosition.TOP_RIGHT;
break;
case ABOVE_CHATBOX_RIGHT:
overlayPosition = OverlayPosition.BOTTOM_RIGHT;
break;
}
}
return overlayPosition;
}
private boolean shouldInvalidateBounds() private boolean shouldInvalidateBounds()
{ {
final Widget chatbox = client.getWidget(WidgetInfo.CHATBOX); final Widget chatbox = client.getWidget(WidgetInfo.CHATBOX);