Table of Contents

Class FocusLayoutEngine

Namespace
Whim
Assembly
Whim.dll
A layout engine that displays one window at a time. FocusLayoutEngine supports showing windows as:
  • Normal: The focused window is shown in its normal size.
  • Maximized: The focused window is shown in its maximized size.
  • Minimized: The focused window can be hidden. Additionally, all non-focused windows are shown as minimized (minimized to the taskbar).

The SwapWindowInDirection(Direction, IWindow) and FocusWindowInDirection(Direction, IWindow) behaviour are a bit different to other layout engines:
public record FocusLayoutEngine : ILayoutEngine, IEquatable<FocusLayoutEngine>
Inheritance
FocusLayoutEngine
Implements
Inherited Members

Constructors

FocusLayoutEngine(LayoutEngineIdentity, bool)

Creates a new instance of the FocusLayoutEngine class.
public FocusLayoutEngine(LayoutEngineIdentity identity, bool maximized = false)

Parameters

identity LayoutEngineIdentity
The identity of the layout engine.
maximized bool
Whether the focused window should be maximized.

Properties

Count

The number of windows in the layout engine.
public int Count { get; }

Property Value

int

Identity

The identity of the layout engine.
public LayoutEngineIdentity Identity { get; }

Property Value

LayoutEngineIdentity

Name

The name of the layout engine.
public string Name { get; init; }

Property Value

string

Methods

AddWindow(IWindow)

Adds a window to the layout engine.
public ILayoutEngine AddWindow(IWindow window)

Parameters

window IWindow

Returns

ILayoutEngine
The new ILayoutEngine after the add.

ContainsWindow(IWindow)

Determines whether the layout engine contains the window.
public bool ContainsWindow(IWindow window)

Parameters

window IWindow

Returns

bool
True if the layout engine contains the window, otherwise false.

DoLayout(IRectangle<int>, IMonitor)

Performs a layout inside the available rectangle.
public IEnumerable<IWindowState> DoLayout(IRectangle<int> rectangle, IMonitor monitor)

Parameters

rectangle IRectangle<int>
The available area to do a layout inside.
monitor IMonitor
The monitor which the layout is being done for.

Returns

IEnumerable<IWindowState>
The layout result.

Remarks

For a given rectangle, the layout engine should return the same result every time.

FocusWindowInDirection(Direction, IWindow)

Focuses the window in the direction. It's recommended that this method is not called directly, but rather through the FocusWindowInDirection(Direction, IWindow?, bool) method.
public ILayoutEngine FocusWindowInDirection(Direction direction, IWindow window)

Parameters

direction Direction
The direction to focus in.
window IWindow
The origin window

Returns

ILayoutEngine

GetFirstWindow()

Retrieves the first window in the layout engine.
public IWindow? GetFirstWindow()

Returns

IWindow

MinimizeWindowEnd(IWindow)

Called when a window is being unminimized - i.e., the window size will no longer be Minimized. The layout engine can choose to ignore this call, if it does not support unminimizing windows.
public ILayoutEngine MinimizeWindowEnd(IWindow window)

Parameters

window IWindow

Returns

ILayoutEngine

MinimizeWindowStart(IWindow)

Called when a window is being minimized - i.e., the window size will become Minimized. The layout engine can choose to ignore this call, if it does not support minimizing windows.
public ILayoutEngine MinimizeWindowStart(IWindow window)

Parameters

window IWindow

Returns

ILayoutEngine

MoveWindowEdgesInDirection(Direction, IPoint<double>, IWindow)

Moves the focused window's edges by the specified deltas.
public ILayoutEngine MoveWindowEdgesInDirection(Direction edges, IPoint<double> deltas, IWindow window)

Parameters

edges Direction
The edges to change.
deltas IPoint<double>
The deltas to change the given edges by. The deltas are in the range [0, 1] for both x and y (the unit square).
window IWindow

Returns

ILayoutEngine
The new ILayoutEngine after the move.

MoveWindowToPoint(IWindow, IPoint<double>)

Move the window to the point. The point has a coordinate space of [0, 1] for both x and y.
public ILayoutEngine MoveWindowToPoint(IWindow window, IPoint<double> point)

Parameters

window IWindow
The window to move.
point IPoint<double>
The point to move the window to.

Returns

ILayoutEngine
The new ILayoutEngine after the move.

PerformCustomAction<T>(LayoutEngineCustomAction<T>)

Attempts to trigger a custom action in a layout engine.
public ILayoutEngine PerformCustomAction<T>(LayoutEngineCustomAction<T> action)

Parameters

action LayoutEngineCustomAction<T>
Metadata about the action to perform, and the payload to perform it with.

Returns

ILayoutEngine
A new layout engine if the action is handled, otherwise it returns the current layout engine.

Type Parameters

T
The type of the action's payload.

Remarks

This method is used to handle custom actions that are not part of the ILayoutEngine interface. For example, the SliceLayoutEngine uses this method to promote/demote windows in the window stack.

RemoveWindow(IWindow)

Removes a window from the layout engine.
public ILayoutEngine RemoveWindow(IWindow window)

Parameters

window IWindow

Returns

ILayoutEngine
The new ILayoutEngine after the remove.

SwapWindowInDirection(Direction, IWindow)

Swaps the window in the direction. It's recommended that this method is not called directly, but rather through SwapWindowInDirection(Direction, IWindow?, bool).
public ILayoutEngine SwapWindowInDirection(Direction direction, IWindow window)

Parameters

direction Direction
The direction to swap the window in.
window IWindow
The window to swap.

Returns

ILayoutEngine
The new ILayoutEngine after the swap.