neoscore.western.abstract_staff

class neoscore.western.abstract_staff.AbstractStaff[source]

Bases: PaintedObject, HasMusicFont

An abstract superclass for staves.

This is not meant to be used directly.

__init__(pos: PointDef, parent: Optional[PositionedObject], length: Unit, group: Optional[StaffGroup], line_spacing: Unit, line_count: int, music_font: Optional[MusicFont], pen: Optional[PenDef])[source]
Parameters
  • pos – The position of the object relative to its parent

  • pen – The pen to draw outlines with.

  • brush – The brush to fill shapes with.

  • parent – The parent object or None

property music_font: MusicFont

The music font used by this object.

property height: Unit

The height of the staff from top to bottom line.

If the staff only has one line, its height is defined as 0.

property line_spacing: Unit

The distance between two lines in the staff.

property line_count: int

The number of lines in the staff

property center_y: Unit

The position of the center staff position

property barline_extent: Tuple[Unit, Unit]

The starting and stopping Y positions of barlines in this staff.

For staves with more than 1 line, this extends from the top line to bottom line. For single-line staves, this extends from 1 unit above and below the staff.

property breakable_length: Unit

Staves are breakable over their full length

property group: StaffGroup

The staff group this belongs to.

A staff group should be assigned during initalization for proper display of staff systems.

find_ordered_descendants_with_attr(attr: str) List[Tuple[Unit, Any]][source]

Find all descendants with an attribute, sorted with their staff x positions

y_inside_staff(pos_y: Unit) bool[source]

Determine if a y-axis position is inside the staff.

This is true for any position within or on the outer lines.

fringe_layout_at(location: Optional[NewLine]) StaffFringeLayout[source]
render_complete(pos: Point, flowable_line: Optional[NewLine] = None, flowable_x: Optional[Unit] = None)[source]

Render the entire object.

This is used to render all objects outside flowables, as well as those inside flowables when they fit completely in one line of the flowable.

By default, this is a no-op. Subclasses with rendered appearances should override this.

This method behaves differently inside and outside of flowables. Whether this object is inside a flowable can be determined by whether a flowable_line is given. When inside a flowable, the given position is in global document coordinates, and created interfaces (or higher level classes) must not be assigned a parent. When not inside a flowable, the given position is relative to self.parent and created interfaces (or higher level classes) must be assigned a parent. In this case, created interfaces should use self.parent.interface_for_children as their parent.

This and other render methods should generally not be called directly.

Parameters
  • pos – The rendering position. If outside a flowable, this is relative to the parent. Otherwise, it is in document coordinates.

  • flowable_line – If in a Flowable, the line in which this object appears

  • flowable_x – If in a Flowable, the flowable x position of this render

render_before_break(pos: Point, flowable_line: NewLine, flowable_x: Unit)[source]

Render the beginning of the object up to a stopping point.

For use in flowable containers when rendering an object that crosses a line or page break. This function should render the beginning portion of the object up to the break.

By default, this is a no-op. Subclasses with rendered appearances should override this.

Created interfaces and higher level objects should not be assigned a parent.

This and other render methods should generally not be called directly.

Parameters
  • pos – The rendering position in document space for drawing.

  • flowable_line – The line in which this object appears

  • flowable_x – The flowable x position of this render

render_spanning_continuation(pos: Point, flowable_line: NewLine, object_x: Unit)[source]

Render the continuation of an object after a break and before another.

For use in flowable containers when rendering an object that crosses two breaks. This function should render the portion of the object surrounded by breaks on either side.

By default, this is a no-op. Subclasses with rendered appearances should override this.

Created interfaces and higher level objects should not be assigned a parent.

This and other render methods should generally not be called directly.

Parameters
  • pos – The rendering position in document space for drawing.

  • flowable_line – The line in which this object appears

  • object_x – The local object x position of the line’s start.

render_after_break(pos: Point, flowable_line: NewLine, object_x: Unit)[source]

Render the continuation of an object after a break.

For use in flowable containers when rendering an object that crosses a line or page break. This function should render the ending portion of an object after a break.

By default, this is a no-op. Subclasses with rendered appearances should override this.

Created interfaces and higher level objects should not be assigned a parent.

This and other render methods should generally not be called directly.

Parameters
  • pos – The rendering position in document space for drawing.

  • flowable_line – The line in which this object appears

  • object_x – The local object x position of the line’s start.

register_layout_controllers()[source]

Register any flowable margin controllers needed by the staff.

Staff subclasses must implement this.

fringe_layout_for_isolated_staff(location: Optional[NewLine]) StaffFringeLayout[source]

Determine the staff fringe layout of this staff in isolation.

This is the layout needed if this staff was alone in a staff system. StaffGroup uses this as a starting point in its fringe layout logic.

Staff subclasses must implement this.

pre_render_hook()[source]

Run code once just before document rendering begins.

Implementations must call the superclass function as well.