--- /dev/null
+/*
+ align-elem.cc -- implement Align_elem
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#include "align-element.hh"
+#include "interval.hh"
+#include "direction.hh"
+
+
+struct Align_element_content {
+ Score_element * elem_l_;
+ int priority_i_;
+
+ static int compare (Align_element_content const &h1,
+ Align_element_content const &h2)
+ {
+ return h1.priority_i_ - h2.priority_i_;
+ }
+ Align_element_content (Score_element *elem_l, int p)
+ {
+ priority_i_ = p;
+ elem_l_ = elem_l;
+ }
+ Align_element_content () {
+ elem_l_ = 0;
+ priority_i_ = 0;
+ }
+};
+
+
+
+void
+Align_element::add_element (Score_element*el_l)
+{
+ int p = priority_i_arr_.size ();
+ add_element_priority (el_l, p);
+}
+
+void
+Align_element::add_element_priority (Score_element *el, int p)
+{
+ assert (! contains_b (el));
+ elem_l_arr_.push (el);
+ priority_i_arr_.push (p);
+ add_dependency (el);
+}
+
+void
+Align_element::do_substitute_dependency (Score_element*o,
+ Score_element*n)
+{
+ int i;
+ while ((i = elem_l_arr_.find_i (o))>=0)
+ if (n)
+ elem_l_arr_[i] = n;
+ else
+ elem_l_arr_.del (i);
+
+ if (o == center_l_)
+ {
+ center_l_ = n;
+ }
+}
+
+/**
+ Align elements top to bottom.
+ The first element has its top at y = 0.0 afterwards
+
+ TODO configurable, like Horizontal_align_item
+
+ TODO should parametrise in direction and coordinate.
+ */
+void
+Align_element::do_post_processing()
+{
+ if (axis_ == Y_AXIS)
+ do_side_processing ();
+}
+
+void
+Align_element::do_pre_processing ()
+{
+ if (axis_ == X_AXIS)
+ do_side_processing ();
+}
+
+void
+Align_element::do_side_processing ()
+{
+ sort_elements ();
+ Array<Interval> dims;
+
+ for (int i=0; i < elem_l_arr_.size(); i++)
+ {
+ Interval y = elem_l_arr_[i]->extent(axis_) ;
+ if (y.empty_b())
+ y = Interval (0,0);
+
+ dims.push (y);
+ }
+
+ Real where_f=0;
+ Real center_f = 0.0;
+ for (int i=0 ; i < elem_l_arr_.size(); i++)
+ {
+ Real dy = - stacking_dir_ * dims[i][-stacking_dir_];
+ if (i)
+ dy += stacking_dir_ * dims[i-1][stacking_dir_];
+
+ if (i)
+ {
+ dy = (dy >? threshold_interval_[SMALLER] )
+ <? threshold_interval_[BIGGER];
+ }
+
+
+ if (!i && align_dir_ == LEFT)
+ center_f = where_f;
+ else if (align_dir_ == CENTER && elem_l_arr_[i] == center_l_)
+ center_f = where_f;
+
+ where_f += stacking_dir_ * dy;
+
+
+ elem_l_arr_[i]->translate_axis (where_f, axis_);
+ }
+
+ if (align_dir_ == RIGHT)
+ center_f = where_f;
+
+ if (center_f)
+ for (int i=0 ; i < elem_l_arr_.size(); i++)
+ elem_l_arr_[i]->translate_axis (- center_f, axis_);
+}
+
+Align_element::Align_element()
+{
+ threshold_interval_ = Interval (0, Interval::infinity ());
+ transparent_b_ = true;
+ set_empty (true);
+ stacking_dir_ = DOWN;
+ align_dir_ = LEFT;
+ axis_ = X_AXIS;
+ center_l_ =0;
+}
+
+
+bool
+Align_element::contains_b (Score_element const *e) const
+{
+ return elem_l_arr_.find_l (e);
+}
+
+
+IMPLEMENT_IS_TYPE_B1(Align_element, Score_element);
+
+void
+Align_element::sort_elements ()
+{
+ Array<Align_element_content> content;
+ for (int i =0; i < elem_l_arr_.size(); i++)
+ content.push (Align_element_content (elem_l_arr_[i], priority_i_arr_[i]));
+ content.sort (Align_element_content::compare);
+
+ elem_l_arr_.clear();
+ priority_i_arr_.clear();
+
+ for (int i =0; i < content.size(); i++)
+ {
+ elem_l_arr_.push (content[i].elem_l_);
+ priority_i_arr_.push (content[i].priority_i_);
+ }
+}
+
+void
+Align_element::do_print () const
+{
+#if 0
+ DOUT << "contains: ";
+ for (int i=0 ; i < item_l_arr_.size(); i++)
+ DOUT << item_l_arr_[i]->name () << ", ";
+#endif
+}
--- /dev/null
+/*
+ score-element.hh -- part of GNU LilyPond
+
+ (c) 1996,97 Han-Wen Nienhuys
+*/
+
+#ifndef STAFFELEM_HH
+#define STAFFELEM_HH
+
+#include "parray.hh"
+#include "virtual-methods.hh"
+#include "directed-graph.hh"
+#include "graphical-element.hh"
+
+#define SCORE_ELEMENT_CLONE(T) VIRTUAL_COPY_CONS (T, Score_element)
+
+
+typedef void (Score_element::*Score_element_method_pointer) (void);
+
+/** Both Spanner and Item are Score_element's. Most Score_element's depend
+ on other Score_element's, eg, Beam needs to know and set direction of
+ Stem. So the Beam has to be calculated *before* Stem. This is
+ accomplished with the dependencies fields of struct Score_element,
+ which are implemented in the Directed_graph_node class: all elements
+ form an acyclic graph.
+
+ (elem) */
+class Score_element : private Directed_graph_node, public virtual Graphical_element {
+public:
+ Paper_score *pscore_l_;
+
+ Score_element ();
+ Score_element (Score_element const&);
+ virtual void print () const;
+
+ Paper_def *paper () const;
+ Lookup * lookup_l () const;
+
+ virtual ~Score_element ();
+ DECLARE_MY_RUNTIME_TYPEINFO;
+
+ void add_processing ();
+
+ /**
+ Remove all links (dependencies, dependents, Axis_group_elements.
+ */
+ void unlink ();
+ void substitute_dependency (Score_element*,Score_element*);
+ void remove_dependency (Score_element*);
+ /**
+ add a dependency. It may be the 0 pointer, in which case, it is ignored.
+ */
+ void add_dependency (Score_element*);
+
+ /*
+ virtual accessors
+ */
+
+ virtual Spanner* access_Spanner () { return 0; }
+ virtual Span_bar* access_Span_bar () { return 0; }
+ virtual Axis_group_element * access_Axis_group_element () { return 0; }
+ virtual Score_element* access_Score_element () { return this; }
+
+ virtual Item * access_Item () { return 0; }
+ virtual Line_of_score * line_l () const;
+ virtual bool linked_b () const;
+ SCORE_ELEMENT_CLONE (Score_element);
+
+ /// do not print anything black
+ bool transparent_b_;
+
+ int size_i_;
+
+ // ugh: no protection. Denk na, Vrij Veilig
+ void calcalute_dependencies (int final, int busy, Score_element_method_pointer funcptr);
+
+protected:
+ /**
+ Administration: Where are we?. This is mainly used by Super_elem and
+ Score_element::calcalute_dependencies ()
+
+ 0 means ORPHAN,
+ -1 means deleted
+
+ */
+public:
+ int status_i_;
+protected:
+ Score_element* dependency (int) const;
+ Score_element* dependent (int) const;
+ int dependent_size () const;
+ int dependency_size () const;
+
+ virtual void do_brew_molecule ();
+ void junk_links ();
+ virtual Interval do_height () const;
+ virtual Interval do_width () const;
+
+ /// do printing of derived info.
+ virtual void do_print () const {}
+ /// generate the molecule
+ virtual Molecule* brew_molecule_p () const;
+ ///executed directly after the item is added to the Paper_score
+ virtual void do_add_processing ();
+ /// do calculations before determining horizontal spacing
+ virtual void do_pre_processing ();
+
+ /// generate rods & springs
+ virtual void do_space_processing ();
+
+ virtual void do_breakable_col_processing ();
+ /// do calculations after determining horizontal spacing
+ virtual void do_post_processing ();
+
+ virtual void do_substitute_dependency (Score_element * , Score_element *);
+ virtual void do_substitute_dependent (Score_element *, Score_element *);
+ virtual void do_break_processing ();
+ virtual void handle_broken_dependencies ();
+ virtual void handle_prebroken_dependencies ();
+ virtual Link_array<Score_element> get_extra_dependencies () const;
+ virtual void do_unlink ();
+ virtual void do_junk_links ();
+
+};
+
+
+#endif // STAFFELEM_HH
+
--- /dev/null
+/*
+ super-element.hh -- declare Super_elem
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+
+#ifndef SUPER_ELEM_HH
+#define SUPER_ELEM_HH
+
+#include "score-element.hh"
+/** The toplevel element. The Paper_score contains this element, and any
+ element shoud be a dependency for the super element.
+ */
+class Super_elem : public Score_element {
+public:
+ Link_array<Line_of_score> lines_arr_;
+ Line_of_score * line_of_score_l_;
+ void add_broken_line (Line_of_score*);
+ Super_elem();
+
+ void space_processing ();
+ void pre_processing();
+ void breakable_col_processing();
+ void break_processing();
+ void post_processing();
+ void output_all ();
+ void unlink_all ();
+
+protected:
+ virtual void do_substitute_dependency (Score_element*,Score_element*);
+ virtual void handle_broken_dependencies();
+
+ virtual void do_add_processing();
+ DECLARE_MY_RUNTIME_TYPEINFO;
+};
+
+#endif // SUPER_ELEM_HH
source file of the GNU LilyPond music typesetter
- (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "dimen.hh"
+#include "dimension.hh"
#include "span-bar.hh"
#include "lookup.hh"
#include "atom.hh"
#include "paper-def.hh"
#include "molecule.hh"
-#include "vertical-align-elem.hh"
+#include "align-element.hh"
void
-Span_bar::add (Bar*b)
+Span_bar::add_bar (Bar*b)
{
spanning_l_arr_.push (b);
add_dependency (b);
}
-
-
void
-Span_bar::do_substitute_dependency (Score_elem*o, Score_elem*n)
+Span_bar::do_substitute_dependency (Score_element*o, Score_element*n)
{
spanning_l_arr_.unordered_substitute (o, n);
}
-
void
-Span_bar::set (Vertical_align_element *a)
+Span_bar::set_align (Align_element *a)
{
add_dependency (a);
}
-
Interval
-Span_bar::do_width() const
+Span_bar::do_width () const
{
- return paper()->lookup_l ()->bar (type_str_, 40 PT).dim_.x (); // ugh
+ return lookup_l ()->bar (type_str_, 40 PT).dim_.x (); // ugh
}
void
-Span_bar::do_pre_processing()
+Span_bar::do_pre_processing ()
{
Bar::do_pre_processing ();
- if (spanning_l_arr_.size() < 1)
+ evaluate_empty ();
+}
+
+void
+Span_bar::do_post_processing ()
+{
+ Bar::do_post_processing ();
+}
+
+void
+Span_bar::evaluate_empty ()
+{
+ if (spanning_l_arr_.size () < 1)
{
transparent_b_ = true;
set_empty (true);
{
type_str_ = "|.";
}
+ else if (type_str_ == ":|:")
+ {
+ type_str_ = ".|.";
+ }
}
Atom
Span_bar::get_bar_sym (Real dy) const
{
- return paper()->lookup_l ()->bar (type_str_, dy);
+ if (dy < paper ()->staffheight_f () / 2)
+ return Atom ();
+
+ return lookup_l ()->bar (type_str_, dy);
}
-
Molecule*
-Span_bar::brew_molecule_p() const
+Span_bar::brew_molecule_p () const
{
Interval y_int;
- for (int i=0; i < spanning_l_arr_.size(); i++)
+ for (int i=0; i < spanning_l_arr_.size (); i++)
{
- Axis_group_element *common =
+ Graphical_axis_group *common =
common_group (spanning_l_arr_[i], Y_AXIS);
Real y = spanning_l_arr_[i]->relative_coordinate (common, Y_AXIS)
-relative_coordinate (common,Y_AXIS);
- y_int.unite (y + spanning_l_arr_[i]->height());
+ y_int.unite (y + spanning_l_arr_[i]->height ());
}
- Atom s = get_bar_sym (y_int.length());
+ Atom s = get_bar_sym (y_int.length ());
Molecule*output = new Molecule (Atom (s));
- output->translate_axis (y_int.center(), Y_AXIS);
+ output->translate_axis (y_int.center (), Y_AXIS);
return output;
}
+IMPLEMENT_IS_TYPE_B1 (Span_bar,Bar);
-IMPLEMENT_IS_TYPE_B1(Span_bar,Bar);
-
-Span_bar::Span_bar()
+Span_bar::Span_bar ()
{
type_str_ = "";
}
+
+Span_bar*
+Span_bar::access_Span_bar ()
+{
+ return this;
+}
source file of the GNU LilyPond music typesetter
- (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "vertical-group-elem.hh"
+#include "vertical-group-element.hh"
#include "interval.hh"
#include "item.hh"
#include "debug.hh"
-void
-Vertical_group_element::add_element (Graphical_element*e)
-{
- axis_admin_.add_element (e, this, Y_AXIS, Y_AXIS);
-}
-void
-Vertical_group_element::remove_element (Graphical_element*e)
+Vertical_group_element::Vertical_group_element()
+ : Axis_group_element (Y_AXIS,Y_AXIS)
{
- axis_admin_.remove_element (e, Y_AXIS, Y_AXIS);
}
-
Interval
Vertical_group_element::do_height() const
{
- return axis_admin_.extent (Y_AXIS);
-}
-void
-Vertical_group_element::remove_all()
-{
- axis_admin_.remove_all (Y_AXIS,Y_AXIS);
+ return Graphical_axis_group::extent (Y_AXIS);
}
IMPLEMENT_IS_TYPE_B1(Vertical_group_element, Axis_group_element);
--- /dev/null
+# title C++ rules
+# file make/C++_rules.make
+
+.SUFFIXES: .cc .o .hh .yy .ll .dep
+
+# compile rules:
+#
+$(outdir)/%.o: %.cc
+ $(DO_CXX_COMPILE)
+
+$(outdir)/%.o: $(outdir)/%.cc
+ $(DO_CXX_COMPILE)
+
+$(outdir)/%.cc: %.yy
+ $(BISON) $<
+ mv $<.tab.c $@
+
+$(outdir)/%.hh: %.yy
+ $(BISON) -d $<
+ mv $<.tab.h $@
+ mv $<.tab.c $(basename $@).cc
+
+$(outdir)/%.cc: %.ll
+ $(FLEX) -Cfe -p -p -t $< > $@
+# could be faster:
+# $(FLEX) -8 -Cf -t $< > $@
+
--- /dev/null
+# stepmake/C_rules.make
+
+.SUFFIXES: .c .o .h .y .l .dep
+
+$(outdir)/%.o: %.c
+ $(DO_C_COMPILE)
+
+$(outdir)/%.o: $(outdir)/%.c
+ $(DO_C_COMPILE)
+
+$(outdir)/%.c: %.y
+ $(BISON) $<
+# mv $<.tab.c $@
+ mv parser.tab.c $@
+
+$(outdir)/%.h: %.y
+ $(BISON) -d $<
+# mv $<.tab.h $@
+ mv parser.tab.h $@
+ mv parser.tab.c $(basename $@).c
+
+$(outdir)/%.c: %.l
+ $(FLEX) -Cfe -p -p -t $< > $@
+# could be faster:
+# $(FLEX) -8 -Cf -t $< > $@
+