+1.3.33.jcn1
+===========
+
+* Rewrote Staff_margin_engraver. Staff margin texts now hang on a new
+ breakable item: Left_edge_item.
+
+* Fixed vertical alignment for dynamic elements. Orphaned dynamic items
+ (not supported by a Dynamic_line_spanner) still collide with Staff,
+ although they now have staff support, which was supposed to fix this.
+
+1.3.32.jcn4
+===========
+
+* Fixed Staff_margin_engraver for "instrument", "instr" is still broken.
+
+* Dynamic elements are only put in a Dynamic_line_spanner if there
+ actually is more than one adjacent note-column with a dynamic.
+ This breaks the fine looks of all dynamics, again :-)
+
1.3.33
======
MAJOR_VERSION=1
MINOR_VERSION=3
PATCH_LEVEL=33
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=jcn1
# use the above to send patches: MY_PATCH_LEVEL is always empty for a
# released version.
--- /dev/null
+\score
+{
+ \context StaffGroup = a <
+ \context PianoStaff = b <
+ \context Staff = "c" \notes\relative c'' { b1 \break b }
+ \context Staff = "d" \notes\relative c'' { b1 \break b }
+ >
+ >
+
+ \paper {
+ indent=100.0\mm;
+ linewidth=150.0\mm;
+ \translator
+ {
+ \StaffContext
+ \consists "Staff_margin_engraver";
+ numberOfStaffLines = #1
+ marginScriptPadding = #10 % urg: this is in PT
+ instrument = #"Foo"
+ instr = #"Foo"
+ }
+ }
+}
--- /dev/null
+\score
+{
+ \context StaffGroup = a <
+ \context PianoStaff = b <
+ \context Staff = "c" \notes\relative c'' { b1 \break b }
+ \context Staff = "d" \notes\relative c'' { b1 \break b }
+ >
+ >
+
+ \paper {
+ indent=100.0\mm;
+ linewidth=150.0\mm;
+ \translator
+ {
+ \StaffContext
+ \consists "Staff_margin_engraver";
+ numberOfStaffLines = #1
+ marginScriptPadding = #30 % urg: this is in PT
+ instrument = #"Foo"
+ instr = #"Bar"
+ }
+ }
+}
*/
#include "debug.hh"
#include "dimensions.hh"
+#include "dimension-cache.hh"
#include "crescendo.hh"
#include "musical-request.hh"
#include "lookup.hh"
#include "staff-symbol-referencer.hh"
#include "translator-group.hh"
+
+/*
+ TODO:
+
+ * fix vertical placement of orphaned items
+ * fix padding
+ */
+
class Dynamic_line_spanner : public Spanner
{
public:
Dynamic_line_spanner* line_spanner_;
Moment last_request_mom_;
+
+ Note_column* pending_column_;
+ Link_array<Score_element> pending_element_arr_;
void typeset_all ();
virtual void do_process_music ();
virtual void do_pre_move_processing ();
virtual void do_post_move_processing ();
+ virtual void typeset_element (Score_element*);
};
ADD_THIS_TRANSLATOR (Dynamic_engraver);
line_spanner_ = 0;
span_start_req_l_ = 0;
cresc_p_ =0;
+ pending_column_ = 0;
text_req_l_ = 0;
span_req_l_drul_[START] = 0;
void
Dynamic_engraver::do_process_music ()
{
- if ((span_req_l_drul_[START] || text_req_l_) && !line_spanner_)
+ if ((span_req_l_drul_[START] || text_req_l_)
+ && !line_spanner_
+ && pending_element_arr_.size ())
{
line_spanner_ = new Dynamic_line_spanner;
+ assert (pending_column_);
+ line_spanner_->add_column (pending_column_);
side_position (line_spanner_).set_axis (Y_AXIS);
announce_element (Score_element_info
(line_spanner_,
text_req_l_ ? text_req_l_ : span_req_l_drul_[START]));
}
-
+
+ if (line_spanner_ && pending_element_arr_.size ())
+ {
+ for (int i = 0; i < pending_element_arr_.size (); i++)
+ pending_element_arr_[i]->set_parent (line_spanner_, Y_AXIS);
+ pending_element_arr_.clear ();
+ }
+
if (span_req_l_drul_[START] || text_req_l_)
last_request_mom_ = now_mom ();
+ else
+ pending_element_arr_.clear ();
+
if (text_req_l_)
{
text_p_->set_elt_property ("style", gh_str02scm ("dynamic"));
text_p_->set_elt_property ("script-priority",
gh_int2scm (100));
-
- assert (line_spanner_);
- text_p_->set_parent (line_spanner_, Y_AXIS);
+ pending_element_arr_.push (text_p_);
+ text_p_->set_elt_property ("self-alignment-Y", gh_int2scm (0));
+ text_p_->dim_cache_[Y_AXIS]->off_callbacks_.push
+ (Side_position_interface::aligned_on_self);
announce_element (Score_element_info (text_p_, text_req_l_));
}
{
assert (!finished_cresc_p_);
cresc_p_->set_bound(RIGHT, get_staff_info ().musical_pcol_l ());
- // cresc_p_->add_dependency (get_staff_info ().musical_pcol_l ());
finished_cresc_p_ = cresc_p_;
cresc_p_ = 0;
span_start_req_l_ = 0;
cresc_p_->set_bound(LEFT, get_staff_info ().musical_pcol_l ());
- // cresc_p_->add_dependency (get_staff_info ().musical_pcol_l ());
-
/*
We know how wide the text is, if we can be sure that the
text already has relevant pointers into the paperdef,
Since font-size may be set by a context higher up, we
can not be sure of the size.
+
+
+ We shouldn't try to do this stuff here, the Item should
+ do it when the score is finished. We could maybe
+ set a callback to have the Item do the alignment if
+ it is not a special symbol, like Crescendo.
*/
index_set_cell (finished_cresc_p_->get_elt_property ("dynamic-drul"),
RIGHT, SCM_BOOL_T);
}
-
- assert (line_spanner_);
- cresc_p_->set_parent (line_spanner_, Y_AXIS);
- // cresc_p_->add_dependency (line_spanner_);
+ pending_element_arr_.push (cresc_p_);
+ cresc_p_->set_elt_property ("self-alignment-Y", gh_int2scm (0));
+ cresc_p_->dim_cache_[Y_AXIS]->off_callbacks_.push
+ (Side_position_interface::aligned_on_self);
announce_element (Score_element_info (cresc_p_, span_req_l_drul_[START]));
}
}
}
}
+void
+Dynamic_engraver::typeset_element (Score_element* e)
+{
+ side_position (e).add_staff_support ();
+ Engraver::typeset_element (e);
+}
void
Dynamic_engraver::typeset_all ()
* continue through piece */
if (line_spanner_ && last_request_mom_ < now_mom ())
{
-
- side_position (line_spanner_).add_staff_support ();
-
typeset_element (line_spanner_);
line_spanner_ = 0;
}
void
Dynamic_engraver::acknowledge_element (Score_element_info i)
{
- if (line_spanner_)
+ if (Note_column* n = dynamic_cast<Note_column*> (i.elem_l_))
{
- if (Note_column* n = dynamic_cast<Note_column*> (i.elem_l_))
+ if (line_spanner_)
{
side_position (line_spanner_).add_support (n);
line_spanner_->add_column (n);
}
+ else
+ {
+ pending_column_ = n;
+ }
}
}
struct Key_performer;
struct Keyword;
struct Keyword_table;
+struct Left_edge_item;
struct Lily_stream;
struct Line_group_engraver;
struct Line_of_score;
-/*
- staff-margin-engraver.hh -- declare Staff_margin_engraver
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-
-
-#ifndef STAFF_MARGIN_ENGRAVER_HH
-#define STAFF_MARGIN_ENGRAVER_HH
-
-#include "bar-script-engraver.hh"
-
-/**
- put (instrument) text to left of line
- */
-class Staff_margin_engraver : public Bar_script_engraver
-{
-public:
- VIRTUAL_COPY_CONS(Translator);
- Staff_margin_engraver ();
-protected:
- void acknowledge_element (Score_element_info);
-};
-
-#endif // STAFF_MARGIN_ENGRAVER_HH
(c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
*/
-#include "staff-margin-engraver.hh"
+#include "translator.hh"
+#include "engraver.hh"
#include "bar.hh"
+#include "dimension-cache.hh"
#include "timing-translator.hh"
#include "text-item.hh"
#include "side-position-interface.hh"
+#include "bar-script-engraver.hh"
#include "staff-symbol-referencer.hh"
+#include "staff-symbol.hh"
+
+/*
+ TODO:
+
+ * padding
+ * merge with/derive from/add functionality to Bar_script_engraver
+ */
+
+/**
+ Hang on left edge of staff to provide suppor for simple items.
+ */
+class Left_edge_item : public Item
+{
+public:
+ VIRTUAL_COPY_CONS (Score_element);
+};
+
+/**
+ put (instrument) text to left of line
+ */
+class Staff_margin_engraver : public Engraver
+{
+public:
+ VIRTUAL_COPY_CONS (Translator);
+ Staff_margin_engraver ();
+
+protected:
+ virtual void do_pre_move_processing ();
+ virtual void acknowledge_element (Score_element_info);
+
+private:
+ String type_;
+ Text_item* text_p_;
+ Left_edge_item* left_edge_p_;
+ void create_text (SCM);
+};
ADD_THIS_TRANSLATOR (Staff_margin_engraver);
+
Staff_margin_engraver::Staff_margin_engraver ()
{
- axis_ = X_AXIS;
type_ = "margin";
+ text_p_ = 0;
+ left_edge_p_ = 0;
}
+void
+Staff_margin_engraver::acknowledge_element (Score_element_info info)
+{
+ SCM s = get_property ("instrument");
+
+ if (now_mom () > Moment (0))
+ s = get_property ("instr");
+
+ //s = ly_str02scm ("HALLO");
+
+ if (dynamic_cast<Bar*> (info.elem_l_) && gh_string_p (s))
+ create_text (s);
+}
-/*
- TODO
-
- should be able to set whole paragraph (multiple lines, center) to
- left (right?) of staff, e.g.:
- ______
- |_______
- 2 Clarinetti |________
- (Bb) |___________
- |______________
-*/
void
-Staff_margin_engraver::acknowledge_element (Score_element_info inf)
+Staff_margin_engraver::create_text (SCM text)
{
- Item *i = cast_to_interesting_item (inf.elem_l_);
- if (!i || inf.origin_trans_l_arr (this).size() != 1)
- return;
+ if (!text_p_)
+ {
+ assert (!left_edge_p_);
+ Left_edge_item* l = new Left_edge_item;
+
+ l->set_elt_property ("breakable", SCM_BOOL_T);
+ l->set_elt_property ("break-aligned", SCM_BOOL_T);
+ announce_element (Score_element_info (l, 0));
- SCM long_name = get_property ("instrument");
- SCM short_name = get_property ("instr");
+ Staff_symbol_referencer_interface sl (l);
+ sl.set_interface ();
+ left_edge_p_ = l;
+
+ Text_item* t = new Text_item;
- if (now_mom () > Moment (0))
- long_name = short_name;
+ t->set_elt_property ("self-alignment-Y", gh_int2scm (0));
+ t->dim_cache_[Y_AXIS]->off_callbacks_.push
+ (Side_position_interface::aligned_on_self);
- if (gh_string_p (long_name))
- {
- create_items (0);
- text_p_->set_elt_property ("text", long_name);
- text_p_->set_elt_property ("direction", gh_int2scm (LEFT));
- Bar_script_engraver::attach_script_to_item (i);
-
- /*
- UGH. ignores font size settings.
- */
- Interval iv(text_p_->extent (Y_AXIS));
- text_p_->translate_axis (- iv.center (), Y_AXIS);
-
- Real staff_space = Staff_symbol_referencer_interface (text_p_).staff_space ();
- SCM s = get_property ("staffMarginHorizontalPadding");
- if (gh_number_p (s))
- {
- text_p_->translate_axis (gh_scm2double (s) * staff_space, X_AXIS);
- }
- s = get_property ("staffMarginVerticalPadding");
+ t->set_parent (l, X_AXIS);
+ t->set_parent (l, Y_AXIS);
+
+ // 'just to be sure': see Clef_item::do_add_processing
+ l->add_dependency (t);
+
+ announce_element (Score_element_info (t, 0));
+
+ SCM s = get_property (type_ + "ScriptPadding");
if (gh_number_p (s))
{
- text_p_->translate_axis (gh_scm2double (s) * staff_space, Y_AXIS);
+ //t->set_elt_property ("padding", s);
+ t->translate_axis (-gh_scm2double (s), X_AXIS);
}
+ text_p_ = t;
}
+ //text_p_->set_elt_property ("style", s);
+ //text_p_->set_elt_property ("direction", gh_int2scm (RIGHT));
+ text_p_->set_elt_property ("text", text);
}
+void
+Staff_margin_engraver::do_pre_move_processing ()
+{
+ if (text_p_)
+ {
+ text_p_->set_elt_property("visibility-lambda",
+ ly_eval_str ("begin-of-line-visible"));
+ typeset_element (text_p_);
+ text_p_ = 0;
+ assert (left_edge_p_);
+ typeset_element (left_edge_p_);
+ left_edge_p_ = 0;
+ }
+}
\type "Engraver_group_engraver";
\name Voice;
- dynamicPadding = #5.0
+ dynamicPadding = #2.0
Generic_property_list = #generic-voice-properties
\consists "Output_property_engraver";
% \consists "Score_priority_engraver";
\consists "Break_align_engraver";
breakAlignOrder = #'(
+ "Left_edge_item"
"Span_bar"
"Breathing_sign"
"Clef_item"
#'Stem_tremolo::beam-width = 1.5 * \quartwidth ;
+#'Left_edge_item::visibility-lambda = #begin-of-line-visible
#'Clef_item::visibility-lambda = #begin-of-line-visible
#'Key_item::visibility-lambda = #begin-of-line-visible
#'Breathing_sign::visibility-lambda = #begin-of-line-invisible
}
\translator {
\HaraKiriStaffContext
+ marginScriptPadding = #10 %% urg, this is in pt
\accepts "VoiceOne";
\accepts "VoiceTwo";
}
\paper {
- \translator { \OrchestralPartStaffContext }
+ \translator {
+ \OrchestralPartStaffContext
+ marginScriptPadding = #10 %% urg, this is in pt
+ }
\translator {
\VoiceContext
\name "VoiceOne";
;; (Measured in staff space)
(define space-alist
'(
+ (("" "Left_edge_item") . (minimum-space -15.0))
(("" "Clef_item") . (minimum-space 1.0))
(("" "Staff_bar") . (minimum-space 0.0))
(("" "Clef_item") . (minimum-space 1.0))