WindowManager
public class DefaultWindowManager extends Object implements WindowManager
Constructor | Description |
---|---|
DefaultWindowManager() |
Default constructor, will create a window manager that uses
DefaultWindowDecorationRenderer for drawing
window decorations, unless the current theme has an override. |
DefaultWindowManager(WindowDecorationRenderer windowDecorationRenderer,
TerminalSize initialScreenSize) |
Creates a new
DefaultWindowManager using a specified windowDecorationRendererOverride for drawing window
decorations. |
DefaultWindowManager(TerminalSize initialScreenSize) |
Creates a new
DefaultWindowManager using a DefaultWindowDecorationRenderer for drawing window
decorations, unless the current theme has an override. |
Modifier and Type | Method | Description |
---|---|---|
WindowDecorationRenderer |
getWindowDecorationRenderer(Window window) |
Returns the
WindowDecorationRenderer for a particular window |
boolean |
isInvalid() |
Will be polled by the the
WindowBasedTextGUI to see if the window manager believes an update is required. |
void |
onAdded(WindowBasedTextGUI textGUI,
Window window,
List<Window> allWindows) |
Called whenever a window is added to the
WindowBasedTextGUI . |
void |
onRemoved(WindowBasedTextGUI textGUI,
Window window,
List<Window> allWindows) |
Called whenever a window is removed from a
WindowBasedTextGUI . |
protected void |
prepareWindow(TerminalSize screenSize,
Window window) |
Called by
DefaultWindowManager when iterating through all windows to decide their size and position. |
void |
prepareWindows(WindowBasedTextGUI textGUI,
List<Window> allWindows,
TerminalSize screenSize) |
Called by the GUI system before iterating through all windows during the drawing process.
|
public DefaultWindowManager()
DefaultWindowDecorationRenderer
for drawing
window decorations, unless the current theme has an override. Any size calculations done before the text GUI has
actually been started and displayed on the terminal will assume the terminal size is 80x24.public DefaultWindowManager(TerminalSize initialScreenSize)
DefaultWindowManager
using a DefaultWindowDecorationRenderer
for drawing window
decorations, unless the current theme has an override. Any size calculations done before the text GUI has
actually been started and displayed on the terminal will use the size passed in with the
initialScreenSize
parameter (if null
then size will be assumed to be 80x24)initialScreenSize
- Size to assume the terminal has until the text GUI is started and can be notified of the
correct sizepublic DefaultWindowManager(WindowDecorationRenderer windowDecorationRenderer, TerminalSize initialScreenSize)
DefaultWindowManager
using a specified windowDecorationRendererOverride
for drawing window
decorations. Any size calculations done before the text GUI has actually been started and displayed on the
terminal will use the size passed in with the initialScreenSize
parameterwindowDecorationRenderer
- Window decoration renderer to use when drawing windowsinitialScreenSize
- Size to assume the terminal has until the text GUI is started and can be notified of the
correct sizepublic boolean isInvalid()
WindowManager
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.isInvalid
in interface WindowManager
true
if the window manager believes the GUI needs to be update, false
otherwisepublic WindowDecorationRenderer getWindowDecorationRenderer(Window window)
WindowManager
WindowDecorationRenderer
for a particular windowgetWindowDecorationRenderer
in interface WindowManager
window
- Window to get the decoration renderer forWindowDecorationRenderer
for the windowpublic void onAdded(WindowBasedTextGUI textGUI, Window window, List<Window> allWindows)
WindowManager
WindowBasedTextGUI
. This gives the window manager an opportunity
to setup internal state, if required, or decide on an initial position of the windowonAdded
in interface WindowManager
textGUI
- GUI that the window was added toowindow
- Window that was addedallWindows
- All windows, including the new window, in the GUIpublic void onRemoved(WindowBasedTextGUI textGUI, Window window, List<Window> allWindows)
WindowManager
WindowBasedTextGUI
. This gives the window manager an
opportunity to clear internal state if needed.onRemoved
in interface WindowManager
textGUI
- GUI that the window was removed fromwindow
- Window that was removedallWindows
- All windows, excluding the removed window, in the GUIpublic void prepareWindows(WindowBasedTextGUI textGUI, List<Window> allWindows, TerminalSize screenSize)
WindowManager
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
WindowManager.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.prepareWindows
in interface WindowManager
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 onprotected void prepareWindow(TerminalSize screenSize, Window window)
DefaultWindowManager
when iterating through all windows to decide their size and position. If
you override DefaultWindowManager
to add your own logic to how windows are placed on the screen, you can
override this method and selectively choose which window to interfere with. Note that the two key properties that
are read by the GUI system after preparing all windows are the position and decorated size. Your custom
implementation should set these two fields directly on the window. You can infer the decorated size from the
content size by using the window decoration renderer that is attached to the window manager.screenSize
- Size of the terminal that is available to draw onwindow
- Window to prepare decorated size and position forCopyright © 2020. All rights reserved.