Nevron Open Vision Documentation
Layouts - Getting Started

All NOV layouts derive from the base NLayout class. It exposes an abstract Layout method, which takes two arguments as input - a list of objects, which must be arranged and a NLayoutContext instance. 

The purpose of the layout context is to abstract the particular type of layout from the actual type of objects it works with as well as to help the layout build a body representation for each of the arranged objects. This is achieved with the help of two adapters:


That are discussed by this topic. Both the Body Adapter and the Graph Adapter must be adequate for the type of objects being arranged. The following code example applies a stakc layout to the children of a NOV UI Panel:

Arrange Widgets Example
Copy Code
// get the widgets of the panel as an objects list
NList<object> widgets = panel.GetChildren().CastAll<object>();
// create a layout context
NLayoutContext context = new NLayoutContext();
context.BodyAdapter = new NWidgetBodyAdapter();
context.GraphAdapter = null;
context.LayoutArea = new NRectangle(0, 0, 100, 100);
// create a stack layout and use it
NStackLayout layout = new NStackLayout();
layout.Arrange(widgets, context);
The Graph Adapter is needed only when arranging tree or graph object structures. The Layout Area is also needed only for layouts that respect the layout area.
Body Adapter

NOV layouts are generally designed to be able to arrange any types of objects. For example: NOV Layouts are used for the arrangement of NOV UI as well as for the arrangement of NOV Diagram shapes. In order for them to do that they define the notion of "layout body" - which is a layout specific object that a specific layout knows how to arrange. The layout context is resposible for converting each actually arrange object to the respective layout body. It does so with an instance of the NBodyAdapter abstract class that is accessible from the NLayoutContext-BodyAdapter property.

Each domain of NOV elements that can be subject to layout typically provide a body adapter out of the box. Currently available are:

Nevron.Nov.UI.NWidgetBodyAdapter - adapts widgets to layout bodies and vice versa.

Graph Adapter
The graph adapter is used by tree and graph layouts (to be introduced by NOV diagram). The purpose of the graph adapter is to adapt the set of arrange objects as a generic graph data structure, suitable for graph drawing algorithms.
See Also
Send Feedback