Skip to content

Conversation

@lbssousa
Copy link

Summary

This pull request introduces comprehensive visibility controls for GregorioTeX elements, including support for phantom rendering modes, and decouples NABC and above-lines-text visibility from note visibility.

Changes Overview

This PR consists of two main commits:

1. Add Unified Visibility Controls (edd97f4)

Introduces a unified visibility control system across multiple GregorioTeX elements:

  • New visibility options: enabled, disabled, phantom, hphantom, vphantom
  • Affected elements: staff lines, lyrics, notes, clefs, above-lines-texts, and NABC
  • Shared helper macros: \gre@processvisibility and \gre@applyphantomwrapper for consistent handling
  • Deprecation: The old visible/invisible options are deprecated in favor of the new system

Key features:

  • Phantom modes preserve spacing while hiding visual elements
  • hphantom: preserves horizontal spacing only
  • vphantom: preserves vertical spacing only
  • phantom: preserves both horizontal and vertical spacing
  • Consistent API across all elements

2. Decouple NABC and Above-Lines Visibility (b43b12a)

Makes NABC and above-lines-text elements independent from note visibility:

  • NABC independence: NABC elements remain visible even when notes are disabled
  • Above-lines independence: Above-lines-text remains visible when notes are disabled
  • Smart spacing: Automatically adjusts spacing when notes or lines are hidden
  • Lua backend improvements: Enhanced recursive list traversal to detect NABC in phantom boxes
  • Rendering logic: New \gre@notes@rendernabc macro for NABC-only rendering when notes are disabled

Key features:

  • NABC and above-lines-text can be controlled independently from notes
  • Proper spacing adjustments when elements are selectively hidden
  • Maintains correct vertical positioning in all visibility combinations

Backward Compatibility

  • Old visible/invisible options remain functional but emit deprecation warnings
  • Existing scores will continue to work without modification
  • Users are encouraged to migrate to the new enabled/disabled options

Resolves

Introduce enabled/disabled/phantom visibility handling across staff lines, lyrics, notes, clefs, custos, and NABC, with shared helpers and documentation updates.
Keep NABC/above-lines elements independent of note visibility, adjust spacing when notes/lines are hidden, and document the separation.
lbssousa added a commit to lbssousa/gregorio-test that referenced this pull request Jan 21, 2026
@davidweichiang
Copy link
Contributor

davidweichiang commented Jan 23, 2026

For some elements, there isn't going to be any difference between phantom and disabled. In those cases, could it be confusing to have both options?

ETA: I'm thinking especially of all the options like \gresetlinesbehindpunctumcavum, etc. and am having trouble seeing why they need the new options at all.

\fi
}%

% Helpers to control text rendering mode (LuaTeX)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these ever used? I didn't see any place where they were.

\ifgre@showclef%
\gre@skip@temp@four = \gre@space@skip@afterclefnospace\relax%
\hbox{\gre@typeclef{#1}{#2}{0}{#3}{#4}{#5}{#6}{#7}\gre@hskip\gre@skip@temp@four}%
\ifnum\gre@clef@phantomwrapper>0\relax
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If \gre@clef@phantomwrapper is 0, then \gre@applyphantomwrapper does nothing, so can't you just call \gre@applyphantomwrapper in all cases?

@davidweichiang
Copy link
Contributor

What do you think about merging \ifgre@showxxx and \gre@xxx@phantomwrapper? There are many places where they are both set or both tested, so merging them could be more compact.

@lbssousa
Copy link
Author

For some elements, there isn't going to be any difference between phantom and disabled. In those cases, could it be confusing to have both options?

ETA: I'm thinking especially of all the options like \gresetlinesbehindpunctumcavum, etc. and am having trouble seeing why they need the new options at all.

I've did a deeper review and realized the only commands \gresetclef, \gresetnotes and \gresetlyrics make use of phantom wrapper.

I'll remove *phantom options from the other commands, buil I'll keep the vphantom option for \gresetlines command, to control whether the NABC/above-lines-text lines should be lowered closer to lyrics line.

Does it sound better for you, @davidweichiang ?

@davidweichiang
Copy link
Contributor

My opinions:

Should remain visible/invisible:

  • linesbehindpunctumcavum
  • linesbehindalteration
  • linesbehinddottedbar

I think all the options (enabled, disabled, phantom, hphantom, and vphantom) make sense:

  • lyrics. Cf. Empty lyrics shouldn't take up vertical space? #1661
  • notes. I would imagine that disabled and hphantom would imply additionaltopspace=0 and noteadditionalspacelinestext=0, but if I'm not mistaken, that's not implemented here yet.
  • clef. Probably vphantom is not very different from disabled and hphantom is not very different from phantom.
  • custosalteration. I can't really think of a use for any of the phantom options, though.

The following have zero width anyway, so hphantom is the same as disabled, and vphantom is the same as phantom. But enabled, disabled, and phantom make sense.

  • abovelinestext
  • translation
  • nabc
  • stafflines

\gre@dimen@temp@five=\dimexpr(\gre@dimen@staffheight %
+ \gre@space@dimen@spacebeneathtext %
+ \gre@space@dimen@spacelinestext)\relax%
% If notes/lines are hidden with hphantom or disabled, bring NABC/ALT closer to the lyrics line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be cleaner to do

temp5 = beneathtext+spacelinestext
if notes or lines are enabled or phantom or vphantom then temp5 += staffheight

instead of adding and then subtracting staffheight?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants