java.lang.Object
net.ixdarklord.coolcatcanvas.api.client.gui.placement.GuiPlacement

public final class GuiPlacement extends Object
Finds where to put something of your own so it keeps out of the way of what else is on the screen: you give its size and where you'd like it, and it comes back there if that is clear, else at the nearest clear place found by sliding it in the directions you allow, past whatever is in its way, without leaving the bounds you set.

 GuiPlacement.Position at = GuiPlacement.hud()
         .size(width, 16).at(x, 4).gap(2)
         .directions(GuiPlacement.Direction.DOWN)
         .find();
 GuiAreas.unrecorded(() -> drawMine(graphics, at.x(), at.y()));
 
By default it searches every direction within the whole screen and leaves out anything covering more than 40% of the screen (vignettes and other overlays aren't in anyone's way). Client and render thread only.
  • Method Details

    • hud

      public static GuiPlacement hud()
      A placement among what the HUD drew last frame.
    • screen

      public static GuiPlacement screen()
      A placement among what the open screen drew last frame and its widgets.
    • among

      public static GuiPlacement among(List<GuiArea> areas)
      A placement among the areas given.
    • size

      public GuiPlacement size(int width, int height)
      The size of what is being placed.
    • at

      public GuiPlacement at(int x, int y)
      Where it would go if nothing were in the way (its top left corner).
    • gap

      public GuiPlacement gap(int gap)
      The pixels kept clear between it and anything else.
    • within

      public GuiPlacement within(int x, int y, int width, int height)
      The box it must stay inside (the whole screen unless set).
    • directions

      public GuiPlacement directions(GuiPlacement.Direction... directions)
      The directions it may slide in to get clear (every one unless set).
    • ignoreOverlays

      public GuiPlacement ignoreOverlays(float share)
      Leaves out anything covering more than this share of the screen, 0 to 1 (0.4 unless set; 1 keeps everything).
    • ignore

      public GuiPlacement ignore(Predicate<GuiArea> ignore)
      Leaves out the areas this matches as well (it adds to what is left out already).
    • ignoreDrawnInside

      public GuiPlacement ignoreDrawnInside(int x, int y, int width, int height)
      Leaves out the things drawn wholly inside this box, a panel of your own say (widgets there still count).
    • find

      public GuiPlacement.Position find()
      The place found: where it goes, and whether it had to move from where it was asked to go.