/*
collision.hh -- declare Collision
- source file of the LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
*/
class Collision : public Item {
protected:
+ virtual void do_substitute_dependency(Score_elem*,Score_elem*);
virtual void do_pre_processing();
public:
- Array<Note_column*> clash_l_arr_;
+ Link_array<Note_column> clash_l_arr_;
NAME_MEMBERS(Collision);
void add (Note_column*ncol_l);
Collision();
/*
rest-collision.hh -- declare Rest_collision
- source file of the LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
#include "item.hh"
class Rest_collision : public Item {
- Array<Rest_column *> rest_l_arr_;
- Array<Note_column *> ncol_l_arr_;
+ Link_array<Rest_column> rest_l_arr_;
+ Link_array<Note_column> ncol_l_arr_;
public:
void add(Rest_column*);
void add(Collision*);
NAME_MEMBERS(Rest_collision);
protected:
virtual void do_post_processing();
+ virtual void do_substitute_dependency(Score_elem*,Score_elem*);
};
#endif // REST_COLLISION_HH
/*
script-column.hh -- declare Script_column
- source file of the LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
#ifndef SCRIPT_COLUMN_HH
#define SCRIPT_COLUMN_HH
+#include "elem-group.hh"
#include "item.hh"
/** a struct for treating a group of noteheads (noteheads, stem
(chord) and scripts ) as a single entity. */
-class Script_column : public Item {
+class Script_column : public Item, public Element_group {
+
protected:
- virtual Interval do_height()const;
- virtual Interval do_width()const;
- virtual void do_print() const ;
- virtual void do_pre_processing();
+ virtual void do_print() const;
+ virtual void do_substitute_dependency(Score_elem*, Score_elem*);
+ virtual void do_pre_processing() ;
public:
- Array<Script *> script_l_arr_;
- Array<Item *> support_l_arr_;
-
+ Link_array<Script> script_l_arr_;
+ Link_array<Item> support_l_arr_;
NAME_MEMBERS(Script_column);
- virtual void translate(Offset);
+
void add(Script *);
void add_support(Item*);
};
/**
store the wholes (for vapourware tremolo)
*/
- Array<Notehead*> whole_l_arr_;
- Array<Notehead*> head_l_arr_;
- Array<Notehead*> rest_l_arr_;
+ Link_array<Note_head> whole_l_arr_;
+ Link_array<Note_head> head_l_arr_;
+ Link_array<Note_head> rest_l_arr_;
public:
/// flagtype? 4 none, 8 8th flag, 0 = beam.
Stem(int staff_size_i);
/// ensure that this Stem also encompasses the Notehead #n#
- void add(Notehead*n);
+ void add(Note_head*n);
NAME_MEMBERS(Stem);
void do_print() const;
void set_stemend(Real);
int get_default_dir();
+ int get_center_distance();
void set_default_dir();
void set_default_stemlen();
void set_default_extents();
Real stem_start_f() const;
bool invisible_b()const;
+ bool chord_b()const;
/// heads that the stem encompasses (positions)
int max_head_i() const;
int min_head_i() const;
protected:
- void do_pre_processing();
+ virtual void do_substitute_dependency(Score_elem*,Score_elem*);
+ virtual void do_pre_processing();
virtual Interval do_width() const;
Molecule* brew_molecule_p() const;
};
/*
script-column.cc -- implement Script_column
- source file of the LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
#include "script-column.hh"
#include "debug.hh"
#include "script.hh"
-#include "notehead.hh"
+#include "note-head.hh"
#include "stem.hh"
IMPLEMENT_STATIC_NAME(Script_column);
Script_column::add(Script*s_l)
{
script_l_arr_.push(s_l);
- add_dependency(s_l);
-}
-
-void
-Script_column::translate(Offset o)
-{
- for (int i=0; i < script_l_arr_.size(); i++)
- script_l_arr_[i]->translate(o);
- for (int i=0; i < support_l_arr_.size(); i++)
- support_l_arr_[i]->translate(o);
+ add_element(s_l);
}
mtor << "scripts: " << script_l_arr_.size() << '\n';
}
-Interval
-Script_column::do_height()const return r
-{
- for (int i=0; i < script_l_arr_.size(); i++)
- r.unite(script_l_arr_[i]->height());
-}
-
-Interval
-Script_column::do_width()const
-{
- Interval r;
- for (int i=0; i < script_l_arr_.size(); i++)
- r.unite(script_l_arr_[i]->width());
- return r;
-}
void
Script_column::do_pre_processing()
Script_column::add_support(Item*i_l)
{
support_l_arr_.push(i_l);
- add_dependency(i_l);
+ add_element(i_l);
+}
+
+void
+Script_column::do_substitute_dependency(Score_elem*o,Score_elem*n)
+{
+ Element_group::do_substitute_dependency(o,n);
+ if (o->item()) {
+ script_l_arr_.substitute((Script*)o->item(),(Script*) (n?n->item():0));
+ support_l_arr_.substitute(o->item(), (n?n->item():0));
+ }
}
#include "dimen.hh"
#include "debug.hh"
#include "paper-def.hh"
-#include "notehead.hh"
+#include "note-head.hh"
#include "lookup.hh"
#include "molecule.hh"
#include "p-col.hh"
return (dir_i_ < 0)? stem_bottom_f_ : stem_top_f_;
}
+
void
Stem::set_stemend(Real se)
{
}
void
-Stem::add(Notehead *n)
+Stem::add(Note_head *n)
{
n->add_dependency(this);
if (n->rest_b_) {
{
return !head_l_arr_.size();
}
+bool
+Stem::chord_b() const
+{
+ return head_l_arr_.size() > 1;
+}
+
+// if dir_i_ is set we return a fake value.
+
+int
+Stem::get_center_distance()
+{
+ if (dir_i_)
+ return -dir_i_;
+
+ int staff_center = staff_size_i_ / 2;
+ int min = min_head_i() - staff_center;
+ int max = max_head_i() - staff_center;
+ return (abs(max) > abs(min)) ? max : min;
+}
int
Stem::get_default_dir()
{
- int staff_center = staff_size_i_ /2;
if (dir_i_)
- return dir_i_;
- Real mean = (min_head_i() + max_head_i())/2;
- return (mean > staff_center) ? -1: 1;
+ return dir_i_;
+ return -sign(get_center_distance());
}
+
void
Stem::set_default_dir()
{
{
if(!head_l_arr_.size())
return;
- head_l_arr_.sort(Notehead::compare);
+ head_l_arr_.sort(Note_head::compare);
head_l_arr_[0]->extremal_i_ = -1;
head_l_arr_.top()->extremal_i_ = 1;
int parity=1;
Paper_def *p =paper();
- Real dy = p->internote();
+ Real dy = p->internote_f();
Symbol ss =p->lookup_l()->stem(bot*dy,top*dy);
out = new Molecule(Atom(ss));
}
+void
+Stem::do_substitute_dependency(Score_elem*o,Score_elem*n)
+{
+ Item * o_l = o->item();
+ Item * n_l = n? n->item():0;
+ whole_l_arr_.substitute((Note_head*)o_l, (Note_head*)n_l);
+ head_l_arr_.substitute((Note_head*)o_l, (Note_head*)n_l);
+ rest_l_arr_.substitute((Note_head*)o_l, (Note_head*)n_l);
+}