+2004-03-13 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * lily/include/global-context.hh (Context): clean-up data hiding.
+
+ * lily/include/music-iterator.hh (class Music_iterator): clean-up
+ data hiding.
+
+ * lily/include/grace-fixup.hh (struct Grace_fixup): new file.
+
+ * input/regression/stem-shorten.ly: add chord case.
+
+ * lily/stem.cc (get_default_stem_end_position): shorten stems
+ triggered by note-head positions, not by forced-direction. This
+ fixes a bug with too short stems.
+
2004-03-12 Jan Nieuwenhuizen <janneke@gnu.org>
* scripts/lilypond-book.py (Lilypond_snippet.output_html,
\version "2.1.30"
\header{
-texidoc="
-The staccato dot (and all scripts with follow-into-staff set) must
-not be on staff lines.
-"
+
+ texidoc=" The staccato dot (and all scripts with follow-into-staff
+set) must not be on staff lines. The staccato dot is close to the
+notehead. If the head is in a space, then the dot is in the space next
+to it. "
+
}
+
\score {
- \context Voice \notes\relative c' {
- e'4-. f-. d-. c-. b-.
+ \context Voice \notes\relative c' {
+ e'4-. f-. g-. d-. c-. b-.
\stemDown
e,-. d-. c-. b-. a-. g-.
- }
- \paper {
- raggedright = ##t
- }
+ }
+ \paper {
+ raggedright = ##t
+ }
}
\header {
- texidoc = "Stems in forced directions (as well as the ones
- starting from the middle line) are shortened."
+ texidoc = "If note head is `over' the center line, the stem is
+ shortened. This happens with forced stem directions, and with some
+ chord configurations."
}
\score {
- \notes \relative c'' { \stemDown d c b a g f e
- \stemBoth
- \stemUp a b c d e f g a
- }
- \paper {raggedright = ##t }
+ \notes \relative c'' {
+ \stemDown d c b a g f e
+ \stemBoth
+ \stemUp a b c d e f g a
+ \stemBoth
+ <g, e'>2 <b e g> <c e g> <d f g>
+
+ }
+ \paper {
+ raggedright = ##t
+ }
}
#include "score-context.hh"
#include "context-def.hh"
#include "music-output-def.hh"
+#include "grace-fixup.hh"
-Global_context::Global_context (Music_output_def*o)
+Global_context::Global_context (Music_output_def *o, Moment final)
{
output_def_ = o;
+ final_mom_ = final;
definition_ = o->find_context_def (ly_symbol2scm ("Global"));
unsmob_context_def (definition_)->apply_default_property_operations (this);
accepts_list_ = scm_list_1 (ly_symbol2scm ("Score"));
void
Global_context::add_moment_to_process (Moment m)
{
- if (m > final_mom_)
+ if (m > final_mom_)
return;
if (m < now_mom_)
if (w.main_part_.is_infinity ())
break ;
-#if 0
- // printf ("proccing %s\n ", w.to_string ().to_str0 ());
- if (first)
- {
- /*
- Huh?
- */
- set_property ("measurePosition", w.smobbed_copy ());
- }
-#endif
-
prepare (w);
if (iter->ok ())
}
one_time_step ();
- first = false;
+ first = false;
}
}
}
/*
- Add a function to execute before stepping to the next time step.
- */
+ Add a function to execute before stepping to the next time step.
+*/
void
Global_context::add_finalization (SCM x)
{
set_property ("finalizations" ,lst);
}
+Moment
+Global_context::previous_moment () const
+{
+ return prev_mom_;
+}
class Hyphen_engraver : public Engraver
{
- Music* ev_;
- Spanner* hyphen_;
- Spanner * finished_hyphen_;
+ Music *ev_;
+ Spanner *hyphen_;
+ Spanner *finished_hyphen_;
public:
TRANSLATOR_DECLARATIONS (Hyphen_engraver);
friend class Music_output_def;
public:
- Global_context (Music_output_def*);
+ Global_context (Music_output_def*, Moment final);
int get_moments_left () const;
Moment sneaky_insert_extra_moment (Moment);
void add_moment_to_process (Moment);
virtual Music_output_def* get_output_def () const;
virtual Moment now_mom () const;
+ Moment previous_moment () const;
+protected:
Moment final_mom_;
Moment prev_mom_;
Moment now_mom_;
-protected:
};
--- /dev/null
+/*
+ grace-fixup.hh -- declare Grace_fixup
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#ifndef GRACE_FIXUP_HH
+#define GRACE_FIXUP_HH
+
+#include "moment.hh"
+
+/*
+
+ This is a lookahead list for grace notes.
+
+ { ... X \grace Y Z ... }
+
+ normally, the ending of X is the start of Z. In case of a grace
+ note, we take off a little at the end of X. What is stored: START
+ (start point of X), LENGTH (length of X), GRACE_START (start_music
+ of Y), and the next fixup element.
+
+ This is also done for nested musics, i.e.
+
+ voiceA = \notes { \grace b16 c'2 }
+ voiceB = \notes { c'2 \voiceA }
+
+ the iterator for voiceB will contain a fixup entry with (START=0/1,
+ LENGTH=2/1, GRACE_START=(0G-1/16) )
+
+ Graces at the start of a sequential music iterator are handled
+ by initting here_mom_ with Music::start_music (); no fixups are needed.
+
+*/
+struct Grace_fixup
+{
+ Moment start_;
+ Moment length_;
+
+ Rational grace_start_;
+
+ Grace_fixup * next_;
+};
+
+#endif /* GRACE_FIXUP_HH */
+
class Axis_group_engraver;
class Bar_engraver;
class Bar_req_collect_engraver;
-class Base_span_bar_engraver;
class Beaming_info_list;
class Bezier;
class Bezier_bow;
class Font_metric;
class Font_size_engraver;
class Global_context;
+class Grace_fixup;
class Gourlay_breaking;
-class Grace_engraver_group;
class Grace_iterator;
class Grace_music;
-class Grace_performer_group;
class Hara_kiri_engraver;
class Hara_kiri_line_group_engraver;
class Includable_lexer;
class Ligature_bracket_engraver;
class Line_group_engraver_group;
class System;
-class Local_key_item;
class Lookup;
class Lyric_combine_music;
class Lyric_combine_music_iterator;
public:
Moment music_get_length () const;
- Moment music_start_mom () const;
+ virtual Moment music_start_mom () const;
Music_iterator ();
/**
#include "music-iterator.hh"
#include "protected-scm.hh"
-/*
-
- This is a lookahead list for grace notes.
-
- { ... X \grace Y Z ... }
-
- normally, the ending of X is the start of Z. In case of a grace
- note, we take off a little at the end of X. What is stored: START
- (start point of X), LENGTH (length of X), GRACE_START (start_music
- of Y), and the next fixup element.
-
- This is also done for nested musics, i.e.
-
- voiceA = \notes { \grace b16 c'2 }
- voiceB = \notes { c'2 \voiceA }
-
- the iterator for voiceB will contain a fixup entry with (START=0/1,
- LENGTH=2/1, GRACE_START=(0G-1/16) )
-
- Graces at the start of a sequential music iterator are handled
- by initting here_mom_ with Music::start_music (); no fixups are needed.
-
-*/
-struct Grace_fixup
-{
- Moment start_;
- Moment length_;
-
- Rational grace_start_;
- Grace_fixup *next_;
-};
/** Sequential_music iteration: walk each element in turn, and
construct an iterator for every element.
void next_grace_fixup ();
private:
+ Moment last_mom_;
Moment here_mom_;
- SCM list_;
SCM cursor_;
Grace_fixup * grace_fixups_;
/**
The name says it all: make multi measure rests
-
*/
class Multi_measure_rest_engraver : public Engraver
{
Moment stop_moment_;
bool bar_seen_;
-
+ Item *last_command_item_ ;
Spanner *last_rest_;
Spanner *mmrest_;
Multi_measure_rest_engraver::Multi_measure_rest_engraver ()
{
+ last_command_item_ = 0;
bar_seen_ = false;
start_measure_ = 0;
mmrest_ = 0;
Grob *cmc = unsmob_grob (get_property ("breakableSeparationItem"));
if (!cmc)
cmc = unsmob_grob (get_property ("currentCommandColumn"));
-
- Item *it = dynamic_cast<Item*> (cmc);
-
+
+ /*
+ Ugh, this is a kludge - need this for multi-measure-rest-grace.ly
+ */
+ last_command_item_ = dynamic_cast<Item*> (cmc);
+ }
+
+ if (last_command_item_ && (mmrest_ || last_rest_))
+ {
+
+ if (last_rest_)
+ {
+ add_bound_item (last_rest_, last_command_item_);
+ for (int i = 0; i < last_numbers_.size (); i++)
+ add_bound_item (last_numbers_[i], last_command_item_);
+ }
+
if (mmrest_)
{
- add_bound_item (mmrest_, it);
+ add_bound_item (mmrest_, last_command_item_);
for (int i = 0; i < numbers_.size (); i++)
- add_bound_item (numbers_[i], it);
+ add_bound_item (numbers_[i], last_command_item_);
+
+ last_command_item_ = 0;
}
-
- if (last_rest_)
- {
- add_bound_item (last_rest_,it);
- for (int i = 0; i < last_numbers_.size (); i++)
- add_bound_item (last_numbers_[i], it);
- }
}
+
SCM smp = get_property ("measurePosition");
Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
assert (m);
p->music_length_ = m->get_length ();
p->start_mom_ = m->start_mom ();
+
return iter;
}
Cpu_timer timer;
- Global_context * trans = new Global_context (odef);
+ Global_context * trans = new Global_context (odef,
+ music->get_length ()
+ );
if (!trans)
{
}
progress_indication (_ ("Interpreting music..."));
- trans->final_mom_ = music->get_length ();
SCM protected_iter = Music_iterator::get_static_get_iterator (music);
Music_iterator * iter = unsmob_iterator (protected_iter);
iter->init_translator (music, trans);
if (! iter->ok ())
{
warning (_ ("Need music in a score"));
- return SCM_BOOL_F; // todo: shoudl throw exception.
+ return SCM_BOOL_F; // todo: should throw exception.
}
trans->run_iterator_on_me (iter);
#include "context.hh"
#include "sequential-iterator.hh"
#include "music-list.hh"
-
-Grace_fixup *get_grace_fixups (SCM cursor);
+#include "grace-fixup.hh"
/*
Sequential_iterator::Sequential_iterator ()
{
here_mom_ = Moment (0);
- list_ = SCM_EOL;
cursor_ = SCM_EOL;
grace_fixups_ = 0;
iter_ = 0;
void
-Sequential_iterator::derived_mark ()const
+Sequential_iterator::derived_mark () const
{
if (iter_)
scm_gc_mark (iter_->self_scm ());
- scm_gc_mark (list_);
scm_gc_mark (cursor_);
}
void
-Sequential_iterator::derived_substitute (Context *f,Context *t)
+Sequential_iterator::derived_substitute (Context *f, Context *t)
{
if (iter_)
- iter_->substitute_outlet (f,t);
-
+ iter_->substitute_outlet (f, t);
}
+/*
+ TODO: this should be made lazily.
+ */
Grace_fixup *
create_grace_fixup_list (SCM cursor)
{
void
Sequential_iterator::construct_children ()
{
- list_ = get_music_list ();
- cursor_ = list_;
+ cursor_ = get_music_list ();
iter_ = 0;
if (gh_pair_p (cursor_))
{
- Music *m =unsmob_music (ly_car (cursor_));
+ Music *m = unsmob_music (ly_car (cursor_));
iter_ = unsmob_iterator (get_iterator (m));
}
next_element (true);
}
+ last_mom_ = Moment (-1);
here_mom_ = get_music ()->start_mom ();
grace_fixups_ = create_grace_fixup_list (cursor_);
&& get_grace_fixup ())
{
Grace_fixup *gf = get_grace_fixup ();
-
+
+ last_mom_ = here_mom_;
here_mom_ += gf->length_;
here_mom_.grace_part_ += gf->grace_start_;
}
else if (len.grace_part_ && !len.main_part_)
{
+ last_mom_ = here_mom_;
here_mom_.grace_part_ =0;
}
else
in that chunk should be in len.grace_part_
*/
+ last_mom_ = here_mom_;;
here_mom_ += len;
}
set_translator (child_report);
}
-
-
void
Sequential_iterator::process (Moment until)
{
grace_fixups_ = n;
}
-
Grace_fixup*
Sequential_iterator::get_grace_fixup () const
{
*/
class Span_bar_engraver : public Engraver
{
- Item * spanbar_;
+ Item *spanbar_;
Link_array<Item> bars_;
public:
protected:
virtual void acknowledge_grob (Grob_info);
virtual void stop_translation_timestep ();
-
};
-
Span_bar_engraver::Span_bar_engraver ()
{
spanbar_ =0;
}
-
-
void
Span_bar_engraver::acknowledge_grob (Grob_info i)
{
spanbar_ = make_item ("SpanBar");
spanbar_->set_parent (bars_[0], X_AXIS);
-
announce_grob (spanbar_, SCM_EOL);
}
}
}
+
void
Span_bar_engraver::stop_translation_timestep ()
{
SCM vissym =ly_symbol2scm ("break-visibility");
SCM vis = bars_[0]->internal_get_property (vissym);
- if (scm_equal_p (spanbar_->internal_get_property (vissym), vis) != SCM_BOOL_T)
+ if (gh_equal_p (spanbar_->internal_get_property (vissym), vis))
spanbar_->internal_set_property (vissym, vis);
typeset_grob (spanbar_);
}
-
-
-
-
-
ENTER_DESCRIPTION (Span_bar_engraver,
/* descr */ "This engraver makes cross-staff barlines: It catches all normal "
"bar lines, and draws a single span-bar across them.",
}
}
-
-
/* URGURGURG
'set-default-stemlen' sets direction too
*/
set_grob_direction (me, dir);
}
-
/* stems in unnatural (forced) direction should be shortened,
according to [Roush & Gourlay] */
- if (!chord_start_y (me)
- || (get_direction (me) != get_default_dir (me)))
+ if (dir * head_positions (me)[dir] >= 0)
{
-
-
SCM sshorten = me->get_property ("stem-shorten");
SCM scm_shorten = gh_pair_p (sshorten) ?
robust_list_ref ((duration_log (me) - 2) >? 0, sshorten): SCM_EOL;
/* On boundary: shorten only half */
- if (abs (head_positions (me)[get_direction (me)]) <= 1)
+ if (abs (head_positions (me)[dir]) <= 1)
shorten *= 0.5;
length -= shorten;
{
Global_context *global =get_global_context ();
- Moment now = global->now_mom_;
- Moment dt = now - global->prev_mom_;
+ Moment now = global->now_mom ();
+ Moment dt = now - global->previous_moment ();
if (dt < Moment (0))
{
programming_error ("Moving backwards in time");
;; This value is sensitive: if too large, staccato dots will move a
;; space a away.
- (padding . 0.25)
+ (padding . 0.20)
(staff-padding . 0.25)
;; (script-priority . 0) priorities for scripts, see script.scm
(X-offset-callbacks . (,Self_alignment_interface::centered_on_parent))