source file of the GNU LilyPond music typesetter
- (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+ (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "staff-margin-engraver.hh"
-#include "script.hh"
-#include "text-def.hh"
-#include "paper-def.hh"
-#include "command-request.hh"
#include "bar.hh"
-#include "stem.hh"
-#include "time-description.hh"
-
+#include "timing-translator.hh"
+#include "text-item.hh"
+#include "side-position-interface.hh"
ADD_THIS_TRANSLATOR (Staff_margin_engraver);
Staff_margin_engraver::Staff_margin_engraver ()
{
- script_p_ = 0;
+ axis_ = X_AXIS;
+ type_ = "margin";
+ visibility_lambda_ = ly_eval_str ("postbreak-only-visibility");
}
-
/*
TODO
- fix alignment/support
- should be able to set whole paragraph (multiple lines, centre) to
+ should be able to set whole paragraph (multiple lines, center) to
left (right?) of staff, e.g.:
______
|_______
|______________
*/
void
-Staff_margin_engraver::acknowledge_element (Score_element_info i)
+Staff_margin_engraver::acknowledge_element (Score_element_info inf)
{
- Item * it = dynamic_cast <Item *> (i.elem_l_);
-
- if (!it
- || script_p_
- || !(dynamic_cast<Bar *> (it))
- || (i.origin_grav_l_arr_.size() != 1))
+ Item *i = cast_to_interesting_item (inf.elem_l_);
+ if (!i || inf.origin_trans_l_arr (this).size() != 1)
return;
- String string = get_property ("instrument");
- String str = get_property ("instr");
- if (now_moment () > Moment (0))
- string = str;
- if (!string.length_i ())
- return;
+ SCM long_name = get_property ("instrument", 0);
+ SCM short_name = get_property ("instr", 0);
- script_p_ = new Script;
- script_p_->axis_ = X_AXIS;
-
- Text_def *td_p =new Text_def;
- td_p->align_dir_ = LEFT;
- td_p->text_str_ = string;
- // huh?
- script_p_->dir_ = RIGHT;
- script_p_->specs_p_ = td_p;
- script_p_->breakable_b_ = true;
+ if (now_mom () > Moment (0))
+ long_name = short_name;
-
- Scalar pri = get_property ("marginBreakPriority");
- if (pri.length_i () && pri.isnum_b ())
- {
- script_p_->break_priority_i_ = int (pri);
- }
- else
- script_p_ ->break_priority_i_ = it->break_priority_i_;
-
- announce_element (Score_element_info (script_p_, 0));
-}
-
-void
-Staff_margin_engraver::do_pre_move_processing ()
-{
- if (script_p_)
+ if (gh_string_p (long_name))
{
- typeset_element (script_p_);
- script_p_ =0;
+ 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);
}
}