smaller, to accomodate for natural sign.
(internal_brew_molecule): only do this when the accidental is
close enough.
(extent): new function
2003-09-29 Han-Wen Nienhuys <hanwen@cs.uu.nl>
2003-09-29 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ * lily/note-head.cc (internal_brew_molecule): make left protusion
+ smaller, to accomodate for natural sign.
+ (internal_brew_molecule): only do this when the accidental is
+ close enough.
+ (extent): new function
+
* lily/skyline.cc (merge_skyline): new function
(heighten_skyline): new function
* lily/skyline.cc (merge_skyline): new function
(heighten_skyline): new function
+ c'!4 cis'! cis' <cis'! gis'>
}
\paper { raggedright = ##t}
}
}
\paper { raggedright = ##t}
}
DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM ));
static Interval head_extent (Grob*, Axis);
static Molecule brew_ledger_lines (Grob *me, int pos, int interspaces,
DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM ));
static Interval head_extent (Grob*, Axis);
static Molecule brew_ledger_lines (Grob *me, int pos, int interspaces,
- Interval x_extent, bool take_space);
- DECLARE_SCHEME_CALLBACK (brew_ez_molecule, (SCM ));
+ Interval x_extent, bool);
+ DECLARE_SCHEME_CALLBACK (brew_ez_molecule, (SCM));
+ DECLARE_SCHEME_CALLBACK (extent, (SCM,SCM));
static bool has_interface (Grob*);
static Real stem_attachment_coordinate (Grob *, Axis a);
static int get_balltype (Grob*) ;
static bool has_interface (Grob*);
static Real stem_attachment_coordinate (Grob *, Axis a);
static int get_balltype (Grob*) ;
int pos,
int interspaces,
Interval x_extent,
int pos,
int interspaces,
Interval x_extent,
{
Real inter_f = Staff_symbol_referencer::staff_space (me)/2;
int line_count = (abs (pos) < interspaces)
{
Real inter_f = Staff_symbol_referencer::staff_space (me)/2;
int line_count = (abs (pos) < interspaces)
: (abs (pos) - interspaces) / 2;
Molecule molecule = Molecule();
: (abs (pos) - interspaces) / 2;
Molecule molecule = Molecule();
if (line_count)
{
Real ledgerlinethickness =
if (line_count)
{
Real ledgerlinethickness =
Molecule proto_ledger_line =
Lookup::round_filled_box (ledger_line, blotdiameter);
Molecule proto_ledger_line =
Lookup::round_filled_box (ledger_line, blotdiameter);
if (!take_space)
proto_ledger_line.set_empty (true);
if (!take_space)
proto_ledger_line.set_empty (true);
Direction dir = (Direction)sign (pos);
Real offs = (Staff_symbol_referencer::on_staffline (me, pos))
? 0.0
Direction dir = (Direction)sign (pos);
Real offs = (Staff_symbol_referencer::on_staffline (me, pos))
? 0.0
-internal_brew_molecule (Grob *me, bool ledger_take_space)
+internal_brew_molecule (Grob *me, bool with_ledgers)
{
SCM style = me->get_grob_property ("style");
if (!gh_symbol_p (style))
{
SCM style = me->get_grob_property ("style");
if (!gh_symbol_p (style))
int interspaces = Staff_symbol_referencer::line_count (me)-1;
int pos = (int)rint (Staff_symbol_referencer::get_position (me));
int interspaces = Staff_symbol_referencer::line_count (me)-1;
int pos = (int)rint (Staff_symbol_referencer::get_position (me));
+ if (with_ledgers && interspaces >= 0
&& abs (pos) - interspaces > 1)
{
Interval hd = out.extent (X_AXIS);
Real left_ledger_protusion = hd.length ()/4;
Real right_ledger_protusion = left_ledger_protusion;
&& abs (pos) - interspaces > 1)
{
Interval hd = out.extent (X_AXIS);
Real left_ledger_protusion = hd.length ()/4;
Real right_ledger_protusion = left_ledger_protusion;
- if (unsmob_grob(me->get_grob_property ("accidental-grob")))
+ if (Grob * g = unsmob_grob(me->get_grob_property ("accidental-grob")))
{
/*
make a little room for accidentals.
{
/*
make a little room for accidentals.
TODO: this will look silly if a chord has ledger lines,
and only the bottom note has an accidental.
*/
TODO: this will look silly if a chord has ledger lines,
and only the bottom note has an accidental.
*/
-
- left_ledger_protusion *= 0.66;
- right_ledger_protusion *= 0.9;
+
+ Grob *common = g->common_refpoint (me, X_AXIS);
+ Real d =
+ me->extent (common, X_AXIS)[LEFT]
+ -g->extent (common, X_AXIS)[RIGHT];
+
+ left_ledger_protusion = left_ledger_protusion <? (d/2);
}
Interval l_extents = Interval (hd[LEFT] - left_ledger_protusion,
hd[RIGHT] + right_ledger_protusion);
out.add_molecule (Note_head::brew_ledger_lines (me, pos, interspaces,
}
Interval l_extents = Interval (hd[LEFT] - left_ledger_protusion,
hd[RIGHT] + right_ledger_protusion);
out.add_molecule (Note_head::brew_ledger_lines (me, pos, interspaces,
- l_extents,
- ledger_take_space));
/*
ledgers don't take space. See top of file.
*/
/*
ledgers don't take space. See top of file.
*/
- return internal_brew_molecule (me, false).smobbed_copy ();
+ return internal_brew_molecule (me, true).smobbed_copy ();
Interval
Note_head::head_extent (Grob *me, Axis a)
{
Interval
Note_head::head_extent (Grob *me, Axis a)
{
- Molecule * mol = me->get_molecule();
- return mol ? mol ->extent (a) : Interval(0,0);
+ SCM brewer = me->get_grob_property ("molecule-callback");
+ if (brewer == Note_head::brew_molecule_proc)
+ {
+ Molecule mol = internal_brew_molecule (me, false);
+
+ if (!mol.empty_b())
+ return mol.extent (a);
+ }
+ else
+ {
+ Molecule * mol = me->get_molecule ();
+ if (mol)
+ return mol->extent (a) ;
+ }
+
+ return Interval (0,0);
+/*
+ This is necessary to prevent a cyclic dependency: the appearance of
+ the ledgers depends on positioning, so the Grob::get_molecule() can
+ not be used for determining the note head extent.
+
+ */
+MAKE_SCHEME_CALLBACK (Note_head,extent,2);
+SCM
+Note_head::extent (SCM smob, SCM axis)
+{
+ Grob *me = unsmob_grob (smob);
+ return ly_interval2scm (head_extent (me, (Axis) gh_scm2int (axis)));
+}
MAKE_SCHEME_CALLBACK (Note_head,brew_ez_molecule,1);
MAKE_SCHEME_CALLBACK (Note_head,brew_ez_molecule,1);
SCM
Note_head::brew_ez_molecule (SCM smob)
{
SCM
Note_head::brew_ez_molecule (SCM smob)
{
EasyNotation = \translator {
\ScoreContext
NoteHead \override #'molecule-callback = #Note_head::brew_ez_molecule
EasyNotation = \translator {
\ScoreContext
NoteHead \override #'molecule-callback = #Note_head::brew_ez_molecule
+ NoteHead \override #'Y-extent-callback = #'()
+ NoteHead \override #'X-extent-callback = #'()
(molecule-callback . ,Note_head::brew_molecule)
(ligature-primitive-callback . ,Note_head::brew_molecule)
(glyph-name-procedure . ,find-notehead-symbol)
(molecule-callback . ,Note_head::brew_molecule)
(ligature-primitive-callback . ,Note_head::brew_molecule)
(glyph-name-procedure . ,find-notehead-symbol)
+ (X-extent-callback . ,Note_head::extent)
+ (Y-extent-callback . ,Note_head::extent)
(Y-offset-callbacks . (,Staff_symbol_referencer::callback))
(stem-attachment-function . ,note-head-style->attachment-coordinates)
(meta . ((interfaces . (rhythmic-grob-interface rhythmic-head-interface font-interface note-head-interface staff-symbol-referencer-interface item-interface ))))
(Y-offset-callbacks . (,Staff_symbol_referencer::callback))
(stem-attachment-function . ,note-head-style->attachment-coordinates)
(meta . ((interfaces . (rhythmic-grob-interface rhythmic-head-interface font-interface note-head-interface staff-symbol-referencer-interface item-interface ))))
. (
(font-family . roman)
(style . default)
. (
(font-family . roman)
(style . default)
- (molecule-callback . ,tablature-molecule-callback)
+ (molecule-callback . ,Text_item::brew_molecule)
(Y-offset-callbacks . (,Staff_symbol_referencer::callback))
(extra-offset . (0 . -0.65)) ;; UGH! TODO: Clean this up!
(stem-attachment-function . ,tablature-stem-attachment-function)
(Y-offset-callbacks . (,Staff_symbol_referencer::callback))
(extra-offset . (0 . -0.65)) ;; UGH! TODO: Clean this up!
(stem-attachment-function . ,tablature-stem-attachment-function)
(ly:get-grob-property grob 'text)
)))
molecule ; return the molecule.
(ly:get-grob-property grob 'text)
)))
molecule ; return the molecule.
; The TabNoteHead tablatureFormat callback.
; Compute the text grob-property
; The TabNoteHead tablatureFormat callback.
; Compute the text grob-property