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 Summary
Modifier and TypeMethodDescriptiongetWindowDecorationRenderer(Window window) Returns theWindowDecorationRendererfor a particular windowbooleanWill be polled by the theWindowBasedTextGUIto see if the window manager believes an update is required.voidonAdded(WindowBasedTextGUI textGUI, Window window, List<Window> allWindows) Called whenever a window is added to theWindowBasedTextGUI.voidonRemoved(WindowBasedTextGUI textGUI, Window window, List<Window> allWindows) Called whenever a window is removed from aWindowBasedTextGUI.voidprepareWindows(WindowBasedTextGUI textGUI, List<Window> allWindows, TerminalSize screenSize) Called by the GUI system before iterating through all windows during the drawing process.
-
Method Details
-
isInvalid
boolean isInvalid()Will be polled by the theWindowBasedTextGUIto 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 returntruehere. Please note that returningfalsewill 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:
trueif the window manager believes the GUI needs to be update,falseotherwise
-
getWindowDecorationRenderer
Returns theWindowDecorationRendererfor a particular window- Parameters:
window- Window to get the decoration renderer for- Returns:
WindowDecorationRendererfor the window
-
onAdded
Called whenever a window is added to theWindowBasedTextGUI. 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 toowindow- Window that was addedallWindows- All windows, including the new window, in the GUI
-
onRemoved
Called whenever a window is removed from aWindowBasedTextGUI. This gives the window manager an opportunity to clear internal state if needed.- Parameters:
textGUI- GUI that the window was removed fromwindow- Window that was removedallWindows- All windows, excluding the removed window, in the GUI
-
prepareWindows
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 usingWindow.setPosition(..)andWindow.setDecoratedSize(..). Be sure to inspect the window hints assigned to the window, in case you want to try to honour them. Use thegetWindowDecorationRenderer(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 windowsallWindows- All windows that are going to be drawn, in the order they will be drawnscreenSize- Size of the terminal that is available to draw on
-