def _make_global_context_block( font_size=3, minimum_distance=10, padding=4, ): assert isinstance(font_size, (int, float)) assert isinstance(padding, (int, float)) block = ContextBlock( type_='Engraver_group', name='GlobalContext', ) block.consists_commands.append('Axis_group_engraver') block.consists_commands.append('Time_signature_engraver') time_signature_grob = override(block).time_signature time_signature_grob.X_extent = (0, 0) time_signature_grob.X_offset = Scheme( 'ly:self-alignment-interface::x-aligned-on-self' ) time_signature_grob.Y_extent = (0, 0) time_signature_grob.break_align_symbol = False time_signature_grob.break_visibility = Scheme( 'end-of-line-invisible', ) time_signature_grob.font_size = font_size time_signature_grob.self_alignment_X = Scheme('center') spacing_vector = SpacingVector( 0, minimum_distance, padding, 0, ) grob = override(block).vertical_axis_group grob.default_staff_staff_spacing = spacing_vector return block
def __copy__(self, *arguments): """ Shallow copies component. Copies indicators. Does not copy spanners. Does not copy children. Returns new component. """ new_component = type(self)(*self.__getnewargs__()) if getattr(self, "_overrides", None) is not None: manager = copy.copy(override(self)) new_component._overrides = manager if getattr(self, "_lilypond_setting_name_manager", None) is not None: manager = copy.copy(setting(self)) new_component._lilypond_setting_name_manager = manager for wrapper in inspect(self).annotation_wrappers(): new_wrapper = copy.copy(wrapper) attach(new_wrapper, new_component) for wrapper in inspect(self).wrappers(): new_wrapper = copy.copy(wrapper) attach(new_wrapper, new_component) return new_component
def _get_format_pieces(self, tag=None): indent = LilyPondFormatManager.indent result = [] string = f'{self._escaped_name} {{' result.append(string) manager = LilyPondFormatManager # CAUTION: source context name must come before type_ to allow # context redefinition. if self.source_lilypond_type is not None: string = indent + rf'\{self.source_lilypond_type}' result.append(string) if self.name is not None: string = indent + rf'\name {self.name}' result.append(string) if self.type_ is not None: string = indent + rf'\type {self.type_}' result.append(string) if self.alias is not None: string = indent + rf'\alias {self.alias}' result.append(string) for statement in self.remove_commands: string = indent + rf'\remove {statement}' result.append(string) # CAUTION: LilyPond \consists statements are order-significant! for statement in self.consists_commands: string = indent + rf'\consists {statement}' result.append(string) for statement in self.accepts_commands: string = indent + rf'\accepts {statement}' result.append(string) overrides = override(self)._list_format_contributions('override') for statement in overrides: string = indent + statement result.append(string) setting_contributions = [] for key, value in setting(self)._get_attribute_tuples(): setting_contribution = \ manager.format_lilypond_context_setting_in_with_block( key, value) setting_contributions.append(setting_contribution) for setting_contribution in sorted(setting_contributions): string = indent + setting_contribution result.append(string) for item in self.items: if isinstance(item, str): string = indent + f'{item}' result.append(string) elif '_get_format_pieces' in dir(item): for piece in item._get_format_pieces(): if piece.isspace(): piece = '' else: piece = indent + piece result.append(piece) else: pass result.append('}') return result
def _get_format_pieces(self, tag=None): indent = LilyPondFormatManager.indent result = [] string = f"{self._escaped_name} {{" result.append(string) manager = LilyPondFormatManager # CAUTION: source context name must come before type_ to allow # context redefinition. if self.source_lilypond_type is not None: string = indent + rf"\{self.source_lilypond_type}" result.append(string) if self.name is not None: string = indent + rf"\name {self.name}" result.append(string) if self.type_ is not None: string = indent + rf"\type {self.type_}" result.append(string) if self.alias is not None: string = indent + rf"\alias {self.alias}" result.append(string) for statement in self.remove_commands: string = indent + rf"\remove {statement}" result.append(string) # CAUTION: LilyPond \consists statements are order-significant! for statement in self.consists_commands: string = indent + rf"\consists {statement}" result.append(string) for statement in self.accepts_commands: string = indent + rf"\accepts {statement}" result.append(string) overrides = override(self)._list_format_contributions("override") for statement in overrides: string = indent + statement result.append(string) setting_contributions = [] for key, value in setting(self)._get_attribute_tuples(): setting_contribution = manager.format_lilypond_context_setting_in_with_block( key, value ) setting_contributions.append(setting_contribution) for setting_contribution in sorted(setting_contributions): string = indent + setting_contribution result.append(string) for item in self.items: if isinstance(item, str): string = indent + f"{item}" result.append(string) elif "_get_format_pieces" in dir(item): for piece in item._get_format_pieces(): if piece.isspace(): piece = "" else: piece = indent + piece result.append(piece) else: pass result.append("}") return result
def _copy_override_and_set_from_leaf(self, leaf): if getattr(leaf, '_overrides', None) is not None: self._overrides = copy.copy(override(leaf)) if getattr(leaf, '_lilypond_setting_name_manager', None) is not None: self._lilypond_setting_name_manager = copy.copy(setting(leaf)) new_wrappers = [] for wrapper in leaf._wrappers: new_wrapper = copy.copy(wrapper) new_wrappers.append(new_wrapper) for new_wrapper in new_wrappers: attach(new_wrapper, self)
def _copy_override_and_set_from_leaf(self, leaf): if getattr(leaf, "_overrides", None) is not None: self._overrides = copy.copy(override(leaf)) if getattr(leaf, "_lilypond_setting_name_manager", None) is not None: self._lilypond_setting_name_manager = copy.copy(setting(leaf)) new_wrappers = [] for wrapper in leaf._wrappers: new_wrapper = copy.copy(wrapper) new_wrappers.append(new_wrapper) for new_wrapper in new_wrappers: attach(new_wrapper, self)
def _make_global_context_block( font_size=3, minimum_distance=10, padding=4 ): assert isinstance(font_size, (int, float)) assert isinstance(padding, (int, float)) block = ContextBlock(name="Global_Context", type_="Engraver_group") block.consists_commands.append("Axis_group_engraver") block.consists_commands.append("Time_signature_engraver") time_signature_grob = override(block).time_signature time_signature_grob.X_extent = (0, 0) time_signature_grob.X_offset = Scheme( "ly:self-alignment-interface::x-aligned-on-self" ) time_signature_grob.Y_extent = (0, 0) time_signature_grob.break_align_symbol = False time_signature_grob.break_visibility = Scheme("end-of-line-invisible") time_signature_grob.font_size = font_size time_signature_grob.self_alignment_X = Scheme("center") spacing_vector = SpacingVector(0, minimum_distance, padding, 0) grob = override(block).vertical_axis_group grob.default_staff_staff_spacing = spacing_vector return block