neoscore.core.layout_controllers

Objects which control flowable layouts

class neoscore.core.layout_controllers.LayoutController[source]

Bases: object

An abstract layout controller for working with Flowable layouts.

__init__(flowable_x: Unit)[source]
Parameters

flowable_x – The position of this controller within the owning flowable’s local space.

property flowable_x: Unit

The x position in the flowable’s local space.

class neoscore.core.layout_controllers.NewLine[source]

Bases: LayoutController, PositionedObject

A line break controller.

These are currently used only for automatically generated line breaks and should generally not be constructed directly. Line breaks can be controlled using BreakOpportunity objects instead.

__init__(pos: Union[Point, Tuple[Unit, Unit]], page: Page, flowable_x: Unit, length: Unit, height: Unit)[source]
Parameters
  • pos – The position of the top left corner of this line relative to the page.

  • page – The page this line appears on. This is used as the object’s parent.

  • flowable_x – The x position in the flowable’s local space where this line begins.

  • length – The line length

  • height – The line height

property page: Page

The page this controller appears on.

This is identical to parent.

property doc_end_pos: Point

The position of the new line’s bottom right corner.

This position is relative to the page.

property length: Unit

The length of the line.

property height: Unit

The height of the line.

class neoscore.core.layout_controllers.MarginController[source]

Bases: LayoutController

A controller defining flowable line margins.

A flowable can have any number of different margin layers identified by a given layer_key. A margin controller overrides the active margin values only for the specified layer. When a flowable generates its layout, it sums the margin values from all layers at the point of each new line to determine its margins.

This layered margin system is useful for situations like staves, where different object states will change the required margins. For example, instrument names call for a margin size that will often be longer on the first system than later ones, while clefs and key signatures contribute their own margin amounts which can vary between systems. In this case, one might create separate margin controllers for each of these layers.

These can be manually created and added to a flowable via Flowable.add_margin_controller to control margins.

__init__(flowable_x: Unit, margin_left: Unit, layer_key: str = '')[source]
Parameters
  • flowable_x – The position of this controller within the owning flowable’s local space.

  • margin_left – The margin value contributed by this controller in the specified layer

  • layer_key – The layer this controller applies to. Layer keys starting with _neoscore are reserved for internal purposes.

property margin_left: Unit

The left margin for generated lines while this controller is active

property layer_key: str