abjad.wrapper
|
Wrapper. |
- class abjad.wrapper.Wrapper(*, annotation: str | None = None, check_duplicate_indicator: bool = False, component: Component | None = None, context_name: str | None = None, deactivate: bool = False, direction: Vertical | str | None = None, hide: bool = False, indicator: Any = None, synthetic_offset: Offset | None = None, tag: Tag = Tag(string=''))[source]
Wrapper.
Use
abjad.get.attach()
to attach an indicator to a component.Use
abjad.get.wrapper()
to inspect the wrapper that is created.>>> component = abjad.Note("c'4") >>> articulation = abjad.Articulation("accent") >>> abjad.attach(articulation, component, direction=abjad.UP) >>> wrapper = abjad.get.wrapper(component) >>> type(wrapper) <class 'abjad.wrapper.Wrapper'>
Gets annotation with which indicator is attached to component.
Gets component to which indicator is attached.
Gets name of context at which indicator is attached to component.
Is true when indicator is deactivated in LilyPond output.
Gets direction of indicator.
hide
()Is true when indcator does not appear in LilyPond output.
Gets indicator.
Is true when indicator is bundled.
Gets start offset and checks to see whether indicator leaks to the right.
set_deactivate
(argument)Sets wrapper
deactivate
flag.set_tag
(argument)Sets wrapper tag.
Gets site-adjusted start offset.
Gets start offset.
Gets synthetic offset.
tag
()Gets wrapper tag.
Unbundles indicator.
- context_name() str | None [source]
Gets name of context at which indicator is attached to component.
- leaked_start_offset() Offset [source]
Gets start offset and checks to see whether indicator leaks to the right. This is either the wrapper’s synthetic offset (if set); or the START offset of the wrapper’s component (if indicator DOES NOT leak); or else the STOP offset of the wrapper’s component (if indicator DOES leak).
Start- and stop-text-spans attach to the same leaf. But stop-text-span leaks to the right:
>>> voice = abjad.Voice("c'2 d'2") >>> start_text_span = abjad.StartTextSpan() >>> abjad.attach(start_text_span, voice[0]) >>> stop_text_span = abjad.StopTextSpan(leak=True) >>> abjad.attach(stop_text_span, voice[0]) >>> abjad.show(voice)
>>> string = abjad.lilypond(voice) >>> print(string) \new Voice { c'2 \startTextSpan <> \stopTextSpan d'2 }
Start offset and leaked start offset are the same for start-text-span:
>>> wrapper = abjad.get.wrapper(voice[0], abjad.StartTextSpan) >>> wrapper.start_offset(), wrapper.leaked_start_offset() (Offset((0, 1)), Offset((0, 1)))
Start offset and leaked start offset differ for stop-text-span:
>>> wrapper = abjad.get.wrapper(voice[0], abjad.StopTextSpan) >>> wrapper.start_offset(), wrapper.leaked_start_offset() (Offset((0, 1)), Offset((1, 2)))
- site_adjusted_start_offset() Offset [source]
Gets site-adjusted start offset. Indicators with site equal to
absolute_after
,after
orclosing
give a site-adjusted start offset equal to the stop offset of the wrapper’s component. Indicators with any other site give a site-adjusted start offset equal to the start offset of the wrapper’s component. This is the usual case, and means that site-adjusted start offset equals vanilla start offset. But ifsynthetic_offset
is set thensynthetic_offset
is returned directly without examining the format site at all.>>> staff = abjad.Staff("c'4") >>> abjad.attach(abjad.Ottava(-1, site="before"), staff[0]) >>> abjad.attach(abjad.Ottava(0, site="after"), staff[0]) >>> for wrapper in abjad.get.wrappers(staff[0], abjad.Ottava): ... wrapper.indicator(), wrapper.site_adjusted_start_offset() ... (Ottava(n=-1, site='before'), Offset((0, 1))) (Ottava(n=0, site='after'), Offset((1, 4)))