virtual ~Staff_elem();
Staff_elem();
NAME_MEMBERS(Staff_elem);
- void translate(Offset);
+
+ /**
+ translate the symbol. The symbol does not have to be created yet.
+ Overridable, since this staff-elem might act as a pseudo-list.
+ */
+ virtual void translate(Offset);
void add_processing();
void pre_processing();
void post_processing();
virtual Spanner* spanner() { return 0; }
virtual Item * item() { return 0; }
+ /**
+ add a dependency. It may be the 0 pointer, in which case, it is ignored.
+ */
void add_dependency(Staff_elem* );
void substitute_dependency(Staff_elem* old, Staff_elem * newdep);
protected:
-
+ virtual Interval do_height()const;
+ virtual Interval do_width()const;
/// do printing of derived info.
- virtual void do_print() const=0;
+ virtual void do_print() const {}
/// generate the molecule
- virtual Molecule* brew_molecule_p()const=0;
+ virtual Molecule* brew_molecule_p()const;
///executed directly after the item is added to the PScore
virtual void do_add_processing();
/// do calculations before determining horizontal spacing
Input_register const *ireg_C_;
int base_position_i_;
Array<Voice_group_registers*> group_l_arr_;
-
+ Staff_symbol * staff_sym_l_;
+protected:
+ virtual bool try_request(Request * r);
+ virtual Staff_info get_staff_info();
+ virtual bool acceptable_request_b(Request*) const ;
+ virtual void acknowledge_element(Staff_elem_info);
public:
/* *************** */
Voice_group_registers * old_group);
Voice_group_registers * get_group(String id);
void terminate_register(Request_register * reg);
- virtual bool try_request(Request * r);
- virtual Staff_info get_staff_info();
Staff_registers(Input_register const*);
- virtual bool acceptable_request_b(Request*) const ;
};
#endif // STAFF_REGS_HH
--- /dev/null
+/*
+ note-column.cc -- implement Note_column
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "note-column.hh"
+#include "debug.hh"
+#include "script.hh"
+#include "notehead.hh"
+#include "stem.hh"
+
+IMPLEMENT_STATIC_NAME(Note_column);
+
+
+void
+Note_column::add(Stem*stem_l)
+{
+ assert(!stem_l_);
+ stem_l_ = stem_l;
+ add_dependency(stem_l);
+}
+
+void
+Note_column::add(Notehead* n_l)
+{
+ head_l_arr_.push(n_l);
+ add_dependency(n_l);
+}
+
+void
+Note_column::add(Script*s_l)
+{
+ script_l_arr_.push(s_l);
+ add_dependency(s_l);
+}
+
+void
+Note_column::translate(Offset o)
+{
+ for (int i=0; i < head_l_arr_.size(); i++)
+ head_l_arr_[i]->translate(o);
+ for (int i=0; i < script_l_arr_.size(); i++)
+ script_l_arr_[i]->translate(o);
+ if (stem_l_)
+ stem_l_->translate(o);
+}
+
+
+void
+Note_column::do_print()const
+{
+ mtor << "heads: " << head_l_arr_.size() << '\n';
+ mtor << "scripts: " << script_l_arr_.size() << '\n';
+}
+
+Interval
+Note_column::do_height()const return r
+{
+ if (stem_l_)
+ r.unite(stem_l_->height());
+ for (int i=0; i < head_l_arr_.size(); i++)
+ r.unite(head_l_arr_[i]->height());
+ for (int i=0; i < script_l_arr_.size(); i++)
+ r.unite(script_l_arr_[i]->height());
+}
+
+Interval
+Note_column::do_width()const return r;
+{
+ if (stem_l_)
+ r.unite(stem_l_->width());
+ for (int i=0; i < head_l_arr_.size(); i++)
+ r.unite(head_l_arr_[i]->width());
+ for (int i=0; i < script_l_arr_.size(); i++)
+ r.unite(script_l_arr_[i]->width());
+}
+
+void
+Note_column::do_pre_processing()
+{
+ if (!script_l_arr_.size())
+ return;
+
+ Array<Script*> placed_l_arr_a[4];
+ for (int i=0; i < script_l_arr_.size(); i++) {
+ Script*s_l = script_l_arr_[i];
+ int j = (s_l->dir_i_ >0) ? 0 : 2;
+ if (!s_l->inside_staff_b_)
+ j ++;
+
+ placed_l_arr_a[j].push(s_l);
+ }
+ for (int j =0; j <4; j++) {
+ placed_l_arr_a[j].sort( Script::compare);
+ }
+
+ Notehead *top_head_l=0;
+ Notehead *bot_head_l=0;
+ for (int i=0; i< head_l_arr_.size(); i++) {
+ if (head_l_arr_[i]->extremal == -1)
+ bot_head_l = head_l_arr_[i];
+ else if (head_l_arr_[i]->extremal == 1)
+ top_head_l = head_l_arr_[i];
+ }
+ /* argh. This sux. */
+ if (!top_head_l)
+ top_head_l = bot_head_l;
+ if (!bot_head_l)
+ bot_head_l = top_head_l;
+ assert(bot_head_l && top_head_l);
+ Item *support_l=top_head_l;
+ int j;
+ for (j = 0; j < 2; j++ ) {
+ for (int i=0; i < placed_l_arr_a[j].size(); j++) {
+ placed_l_arr_a[j][i]->add_support(support_l);
+ support_l = placed_l_arr_a[j][i];
+ }
+ }
+
+ support_l=bot_head_l;
+ for (; j < 4; j++ ) {
+ for (int i=0; i < placed_l_arr_a[j].size(); i++) {
+ placed_l_arr_a[j][i]->add_support(support_l);
+ support_l = placed_l_arr_a[j][i];
+ }
+ }
+}
+Note_column::Note_column()
+{
+ stem_l_ =0;
+}
+
#include "musical-request.hh"
#include "complex-walker.hh"
#include "stem.hh"
+#include "staff-sym.hh"
Script_register::Script_register()
{
- script_p_ = 0;
post_move_processing();
}
{
if (!r_l->script())
return false ;
-
- if (script_req_l_
- && Script_req::compare(*script_req_l_, *r_l->script()))
+ for (int i=0; i < script_req_l_arr_.size(); i++)
+ if ( !Script_req::compare(*script_req_l_arr_[i], *r_l->script())) {
+ return true;
+ }
- return false;
-
- script_req_l_ = r_l->script();
+ script_req_l_arr_.push( r_l->script());
return true;
}
void
Script_register::process_requests()
{
- if (script_req_l_) {
- script_p_ = new Script(script_req_l_, 10);
- announce_element(
- Staff_elem_info(script_p_, script_req_l_));
+ for (int i=0; i < script_req_l_arr_.size(); i++){
+ Script_req* l=script_req_l_arr_[i];
+ Script *p =new Script( l);
+ script_p_arr_.push(p);
+ announce_element(Staff_elem_info(p, l));
}
}
+bool
+Script_register::acceptable_elem_b(Staff_elem*s_l)
+{
+ char const *nC = s_l->name();
+ return (nC == Stem::static_name());
+}
+
void
Script_register::acknowledge_element(Staff_elem_info info)
{
- if (!script_p_)
+ Staff_elem *elem_l = info.elem_l_;
+ if (!acceptable_elem_b(elem_l))
return;
- if (info.elem_p_->name() == Stem::static_name())
- script_p_->set_stem((Stem*)info.elem_p_);
- else if (info.req_l_->rhythmic())
- script_p_->set_support(info.elem_p_->item());
+
+ for (int i=0; i < script_p_arr_.size(); i++) {
+ Script*script_l = script_p_arr_[i];
+ if (elem_l->name() == Stem::static_name())
+ script_l->set_stem((Stem*)elem_l);
+ }
}
void
Script_register::pre_move_processing()
{
- if (script_p_){
- script_p_->dir = dir_i_;
- typeset_element(script_p_);
- script_p_ = 0;
+ Staff_symbol* s_l = get_staff_info().staff_sym_l_;
+ for (int i=0; i < script_p_arr_.size(); i++) {
+
+ Script*script_p = script_p_arr_[i];
+ script_p->set_staffsym( s_l);
+ typeset_element(script_p);
}
+ script_p_arr_.set_size(0);
}
void
Script_register::post_move_processing()
{
- script_req_l_ = 0;
+ script_req_l_arr_.set_size(0);
}
void
-Script_register::set_feature(Features i)
+Script_register::set_feature(Features )
{
- if (i.direction_i_|| i.initialiser_b_)
- dir_i_ = i.direction_i_;
+// if (i.direction_i_|| i.initialiser_b_)
+ //dir_i_ = i.direction_i_;
}
IMPLEMENT_STATIC_NAME(Script_register);
ADD_THIS_REGISTER(Script_register);
+/*
+ staff-elem.cc -- implement Staff_elem
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "paper-def.hh"
+#include "lookup.hh"
#include "p-score.hh"
#include "symbol.hh"
#include "p-staff.hh"
pstaff_l_ = s.pstaff_l_;
offset_ = Offset(0,0);
}
+
/**
TODO:
If deleted, then remove dependant_l_arr_ depency!
{
offset_ += O;
}
+
Interval
-Staff_elem::width() const
+Staff_elem::do_width() const return r;
{
- Interval r;
-
+
if (!output){
- Molecule*m = brew_molecule_p();
+ Molecule*m = brew_molecule_p();
r = m->extent().x;
delete m;
} else
r = output->extent().x;
-
+}
+Interval
+Staff_elem::width() const
+{
+ Interval r=do_width();
+
if (!r.empty_b()) // float exception on DEC Alpha
r+=offset_.x;
return r;
}
Interval
-Staff_elem::height() const
+Staff_elem::do_height() const return r
{
- Interval r;
-
if (!output){
Molecule*m = brew_molecule_p();
r = m->extent().y;
delete m;
} else
r = output->extent().y;
-
+}
+
+Interval
+Staff_elem::height() const
+{
+ Interval r=do_height();
+
if (!r.empty_b())
r+=offset_.y;
p->dependant_l_arr_.push(p);
}
IMPLEMENT_STATIC_NAME(Staff_elem);
+
+Molecule*
+Staff_elem::brew_molecule_p()const
+{
+ Atom a(paper()->lookup_l()->fill(Box(Interval(0,0), Interval(0,0))));
+ return new Molecule (a);
+}
Staff_registers::get_staff_info() return inf;
{
inf = Request_register::get_staff_info();
+ inf.staff_sym_l_=staff_sym_l_;
inf.c0_position_i_l_ = &c0_position_i_;
}
Staff_registers::Staff_registers(Input_register const*ireg_C)
{
+ staff_sym_l_ =0;
c0_position_i_ = 0;
base_position_i_ =0;
add( ireg_C->get_nongroup_p_arr());
(r->command() && r->command()->groupchange());
}
+void
+Staff_registers::acknowledge_element(Staff_elem_info i)
+{
+ Register_group_register::acknowledge_element(i);
+ if ( i.elem_l_->name() == Staff_symbol::static_name())
+ staff_sym_l_ = (Staff_symbol*)i.elem_l_;
+}
#include "molecule.hh"
#include "lookup.hh"
-Text_item::Text_item(Text_def *tdef_l, int staffsize_i)
+Text_item::Text_item(Text_def *tdef_l)
+ : Staff_side(this)
{
dir_i_ =-1;
- init(tdef_l, staffsize_i);
+ init(tdef_l);
}
Text_def*
}
void
-Text_item::init(Text_def *tdef_l, int staffsize_i)
+Text_item::init(Text_def *tdef_l)
{
- staffsize_i_ = staffsize_i;
tdef_p_ = new Text_def (*tdef_l);
}
-Text_item::Text_item(Text_req* treq_l, int staffsize_i)
+Text_item::Text_item(Text_req* treq_l)
+ : Staff_side(this)
{
- init(treq_l->tdef_p_, staffsize_i);
+ init(treq_l->tdef_p_);
dir_i_ = treq_l->dir_i_;
if (!dir_i_)
dir_i_ = -1;
void
Text_item::set_default_index()
{
- pos_i_ = (dir_i_ > 0) ? staffsize_i_ + 4: -4;
+ pos_i_ = get_position_i();
}
void