Interface WindowManager

All Known Implementing Classes:
DefaultWindowManager

public interface WindowManager
Window manager is a class that is plugged in to a WindowBasedTextGUI to manage the position and placement of windows. The window manager doesn't contain the list of windows so it normally does not need to maintain much state but it is passed all required objects as the window model changes.
See Also:
  • Method Details

    • isInvalid

      boolean isInvalid()
      Will be polled by the the WindowBasedTextGUI to see if the window manager believes an update is required. For example, it could be that there is no input, no events and none of the components are invalid, but the window manager decides for some other reason that the GUI needs to be updated, in that case you should return true here. Please note that returning false will not prevent updates from happening, it's just stating that the window manager isn't aware of some internal state change that would require an update.
      Returns:
      true if the window manager believes the GUI needs to be update, false otherwise
    • getWindowDecorationRenderer

      WindowDecorationRenderer getWindowDecorationRenderer(Window window)
      Returns the WindowDecorationRenderer for a particular window
      Parameters:
      window - Window to get the decoration renderer for
      Returns:
      WindowDecorationRenderer for the window
    • onAdded

      void onAdded(WindowBasedTextGUI textGUI, Window window, List<Window> allWindows)
      Called whenever a window is added to the WindowBasedTextGUI. This gives the window manager an opportunity to setup internal state, if required, or decide on an initial position of the window
      Parameters:
      textGUI - GUI that the window was added too
      window - Window that was added
      allWindows - All windows, including the new window, in the GUI
    • onRemoved

      void onRemoved(WindowBasedTextGUI textGUI, Window window, List<Window> allWindows)
      Called whenever a window is removed from a WindowBasedTextGUI. This gives the window manager an opportunity to clear internal state if needed.
      Parameters:
      textGUI - GUI that the window was removed from
      window - Window that was removed
      allWindows - All windows, excluding the removed window, in the GUI
    • prepareWindows

      void prepareWindows(WindowBasedTextGUI textGUI, List<Window> allWindows, TerminalSize screenSize)
      Called by the GUI system before iterating through all windows during the drawing process. The window manager should ensure the position and decorated size of all windows at this point by using Window.setPosition(..) and Window.setDecoratedSize(..). Be sure to inspect the window hints assigned to the window, in case you want to try to honour them. Use the getWindowDecorationRenderer(Window) method to get the currently assigned window decoration rendering class which can tell you the decorated size of a window given it's content size.
      Parameters:
      textGUI - Text GUI that is about to draw the windows
      allWindows - All windows that are going to be drawn, in the order they will be drawn
      screenSize - Size of the terminal that is available to draw on