Class OverlayMoveMode

java.lang.Object
privbot.ui.overlay.OverlayMoveMode

public final class OverlayMoveMode extends Object
"Move overlay": drag a flow's Builder panel to a new place, or drag its bottom-right corner to resize its width, in game.

Never on by default. While it is off every mouse callback returns false after one boolean read, and nothing is listening anyway (OverlayMoveInput attaches only while on). While on, a press is consumed only when it lands on a panel; every other click goes to the game.

A move is held here (the overlay draws the panel where it was dragged) and reported to the OverlayMoveMode.MoveListener 30 s after the last drag, or when the mode is turned off. Points are canvas pixels in the space the overlay paints in. A saved move snaps to the corner nearest the panel's centre, with offsets from that corner (see snap(int, int, int, int, java.awt.Dimension)), so a panel nudged near the top-right keeps following the right edge when the window is resized.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Receives a saved move: the corner anchor nearest the panel's centre and the offsets from it (OverlayPlacement rules), or FREE with the panel's top-left when the viewport is unknown.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    A move is saved this long after the last drag ended.
    static final int
    Size of the bottom-right square that resizes instead of moving.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Turns move mode off and saves any move not saved yet.
    void
    enable(String flowId)
    Turns move mode on for flowId's panel, or for every panel when it is null.
    boolean
    Whether move mode is on.
    boolean
    isMovable(String flowId)
    Whether flowId's panel shows the move border.
    boolean
    A drag: moves or resizes the pressed panel.
    boolean
    A press: starts a move (or a resize on the corner handle).
    boolean
    A release: ends the drag.
    The movable panel under p in last frame's bounds (topmost wins), or null; null while off.
    void
    Saves the held moves once 30 s have passed since the last drag (the timer calls this each second).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • AUTO_SAVE_IDLE_MS

      public static final long AUTO_SAVE_IDLE_MS
      A move is saved this long after the last drag ended.
      See Also:
    • RESIZE_HANDLE

      public static final int RESIZE_HANDLE
      Size of the bottom-right square that resizes instead of moving.
      See Also:
  • Constructor Details

    • OverlayMoveMode

      public OverlayMoveMode(Supplier<Map<String,Rectangle>> panelBounds, Supplier<Dimension> viewport, OverlayMoveMode.MoveListener listener)
      Parameters:
      panelBounds - last frame's panel rectangles, by panel id (the overlay's own panel bounds)
      viewport - the canvas size panels are clamped to, or a supplier of null when unknown
      listener - receives each saved move
  • Method Details

    • isEnabled

      public boolean isEnabled()
      Whether move mode is on.
    • enable

      public void enable(String flowId)
      Turns move mode on for flowId's panel, or for every panel when it is null.
    • disable

      public void disable()
      Turns move mode off and saves any move not saved yet.
    • isMovable

      public boolean isMovable(String flowId)
      Whether flowId's panel shows the move border.
    • panelAt

      public String panelAt(Point p)
      The movable panel under p in last frame's bounds (topmost wins), or null; null while off.
    • onPress

      public boolean onPress(Point p)
      A press: starts a move (or a resize on the corner handle). Consumed only over a movable panel.
    • onDrag

      public boolean onDrag(Point p)
      A drag: moves or resizes the pressed panel. Consumed only while a panel is being dragged.
    • onRelease

      public boolean onRelease(Point p)
      A release: ends the drag. Consumed only when it ends one; the 30 s save timer starts here.
    • poll

      public void poll()
      Saves the held moves once 30 s have passed since the last drag (the timer calls this each second).