From: fred Date: Sun, 25 May 1997 22:09:14 +0000 (+0000) Subject: lilypond-0.0.65 X-Git-Tag: release/1.5.59~6130 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=55b8675d15414a9f192d55f509b3bd4aadb339dd;p=lilypond.git lilypond-0.0.65 --- diff --git a/lily/elem-group.cc b/lily/elem-group.cc new file mode 100644 index 0000000000..e4a012d3f3 --- /dev/null +++ b/lily/elem-group.cc @@ -0,0 +1,93 @@ +/* + elem-group.cc -- implement Element_group + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "elem-group.hh" +#include "interval.hh" +#include "item.hh" +#include "debug.hh" + +Interval +Element_group::do_height()const +{ + Interval r; + for (int i=0; i < elem_l_arr_.size(); i++) + r.unite(elem_l_arr_[i]->height()); + return r; +} + +Interval +Element_group::do_width()const +{ + Interval r; + for (int i=0; i < elem_l_arr_.size(); i++) + if (elem_l_arr_[i]->item()) // makes no at preprocessing for spanners. + r.unite(elem_l_arr_[i]->width()); + return r; +} + +void +Element_group::add_element(Score_elem*i_l) +{ + i_l->group_element_i_ ++; + + assert(! elem_l_arr_.find_l(i_l)); + elem_l_arr_.push(i_l); + add_dependency(i_l); +} + +void +Element_group::translate(Offset o) +{ + for (int i=0; i < elem_l_arr_.size(); i++) + elem_l_arr_[i]->translate(o); +} + +IMPLEMENT_STATIC_NAME(Element_group); + +void +Element_group::do_print() const +{ +#ifndef NPRINT + for (int i=0; i < elem_l_arr_.size(); i++) + mtor << elem_l_arr_[i]->name() << ' '; +#endif +} + +void +Element_group::do_substitute_dependency(Score_elem* old, Score_elem *new_l) +{ + int i; + + while ((i=elem_l_arr_.find_i(old))>=0) { + + old->group_element_i_--; + if (new_l){ + new_l->group_element_i_ ++; + elem_l_arr_[i] = new_l; + }else { + elem_l_arr_.del(i); + } + } + +} + +String +Element_group::TeX_string()const +{ + return ""; +} + +Element_group::Element_group(Element_group const&s) + :elem_l_arr_(s.elem_l_arr_) +{ + for (int i=0; i < elem_l_arr_.size(); i++) + elem_l_arr_[i]->group_element_i_ ++; +} + +Element_group::Element_group() +{} diff --git a/lily/include/elem-group.hh b/lily/include/elem-group.hh new file mode 100644 index 0000000000..0e544adbc0 --- /dev/null +++ b/lily/include/elem-group.hh @@ -0,0 +1,37 @@ +/* + elem-group.hh -- declare Element_group + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef ELEM_GROUP_HH +#define ELEM_GROUP_HH +#include "score-elem.hh" + +/** A class to treat a group of elements as a single entity. The + dimensions are the unions of the dimensions of what it contains. + Translation means translating the contents. + */ +class Element_group : virtual Score_elem{ +protected: + Link_array elem_l_arr_; + virtual void do_substitute_dependency(Score_elem* old, Score_elem* new_l); + virtual Interval do_height()const; + virtual Interval do_width()const; + virtual void do_print() const ; + virtual Element_group* elem_group() { return this; } + + +public: + Element_group(); + Element_group(Element_group const&); + NAME_MEMBERS(Element_group); + virtual void translate(Offset); + virtual void add_element(Score_elem*); + virtual String TeX_string()const; +}; + +#endif // ELEM_GROUP_HH