Class Layers.layers

A layers widget can handle several widget trees, allowing multiple layers of widgets. A layer is identified by its position. Bottom layer has position 0. A layer can have a root widget associated (see the pack method). Widgets (and so, layers) are rendered from bottom layer up to top layer, in this order.

Properties

method event_direction : event_direction
method set_event_direction : ?delay:float -> ?propagate:bool -> event_direction -> unit

Children widgets

method children : Stk.Container.child option list

Return the list of children widgets, from bottom layer to top layer. Layers with no widget are present with None.

method children_widgets : Stk.Widget.widget list

Return the list of children widgets, i.e. the root widget of each layer, for layers which have one.

method widget_layer : Stk.Widget.widget -> int option

Return the layer of the given widget. The widget must be the root widget of the layer. If the widget is not found, None is returned.

Box.ng/unpacking

method unpack_layer : int -> unit

#unpack_layer layer removes the root widget of the given layer.

method unpack_widget : Stk.Widget.widget -> unit

#unpack_widget w removes the root widget w, setting root widget for the corresponding layer to None. If the widget is not found, do nothing.

method pack : ?layer:int -> ?opacity:float -> ?data:Stk.Container.child_data -> Stk.Widget.widget -> unit

#pack w packs widget w as root layer. Optional arguments are:

  • layer: if specified, use w as new root widget for this layer, eventually removing previous widget. If it is not specified, pack the widget as root for the first layer without root widget, eventually adding a layer to do so.
  • opacity sets Props.opacity property of w.
  • data associates the given value to w (in Container.child structure).

Operations on layers

method move_layer : int -> [ `Bottom | `Down of int | `Top | `Up of int ] -> int option

#move_layer layer target moves layer according to target, which can have the following values:

  • `Bottom: moves layer at the bottom of all layers,
  • `Down n: moves layer n positions down (or to the bottom if layer <= n),
  • `Up n: moves layer n positions up (or to the top if layer + n >= number of layers),
  • `Top: moves layer at the top of all layers.

The method returns the new position of the layer, if it changed. Remember that a layer is only identified by its position. So the returned value is the same layer, with the same root widget.