+2005-03-10 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ * flower
+ * lily
+ * kpath-guile: Nitpick run: buildscripts/fixcc.py.
+
2005-03-10 Han-Wen Nienhuys <hanwen@xs4all.nl>
* lily/accidental.cc: special bboxes for natural.
// nextstep
#ifndef CLOCKS_PER_SEC
#ifdef CLK_TCK
-#define CLOCKS_PER_SEC CLK_TCK
+#define CLOCKS_PER_SEC CLK_TCK
#elif defined _SC_CLK_TCK
-#define CLOCKS_PER_SEC sysconf (_SC_CLK_TCK)
+#define CLOCKS_PER_SEC sysconf (_SC_CLK_TCK)
#else
#error cannot determine CLOCKS_PER_SEC
#endif
Cpu_timer::read ()
{
clock_t stop = clock ();
- return (stop-start_clock_)/Real (CLOCKS_PER_SEC);
+ return (stop - start_clock_) / Real (CLOCKS_PER_SEC);
}
-/*
+/*
direction.cc -- implement Direction
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "direction.hh"
String s ("center");
if (a == Y_AXIS)
{
- s = ( d == UP ? "up" : "down");
+ s = (d == UP ? "up" : "down");
}
else if (a == X_AXIS)
{
- s = (d == LEFT ? "left" : "right" );
+ s = (d == LEFT ? "left" : "right");
}
return s;
}
/*
file-name.cc - implement File_name
-
+
source file of the Flower Library
-
+
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
+ Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "file-name.hh"
#include "config.hh"
-#if HAVE_SYS_STAT_H
+#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
return s;
}
-char const*
+char const *
File_name::to_str0 () const
{
return to_string ().to_str0 ();
/*
file-path.cc - implement File_path
-
+
source file of the Flower Library
-
+
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
+ Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "file-path.hh"
#include <cerrno>
#include "config.hh"
-#if HAVE_SYS_STAT_H
+#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
}
/** Find a file.
-
- Check absolute file name, search in the current dir (DUH! FIXME!),
- in the construction-arg (what's that?), and in any other appended
- directory, in this order.
- @return
- The file name if found, or empty string if not found. */
+Check absolute file name, search in the current dir (DUH! FIXME!),
+in the construction-arg (what's that?), and in any other appended
+directory, in this order.
+
+@return
+The file name if found, or empty string if not found. */
String
File_path::find (String name) const
{
- if (!name.length () || (name == "-") )
+ if (!name.length () || (name == "-"))
return name;
/* Handle absolute file name. */
return name;
}
}
-
+
for (int i = 0; i < size (); i++)
{
String file_name = elem (i);
struct stat sbuf;
if (stat (file_name.to_str0 (), &sbuf) != 0)
continue;
-
+
if (! (sbuf.st_mode & __S_IFREG))
continue;
#endif
#if !STAT_MACROS_BROKEN
-
+
struct stat sbuf;
if (stat (file_name.to_str0 (), &sbuf) != 0)
continue;
}
/** Find a file.
-
- Seach in the current dir (DUH! FIXME?), in the construction-arg
- (what's that?, and in any other appended directory, in this order.
- Search for NAME, or name without extension, or name with any of
- EXTENSIONS, in that order.
+Seach in the current dir (DUH! FIXME?), in the construction-arg
+(what's that?, and in any other appended directory, in this order.
+
+Search for NAME, or name without extension, or name with any of
+EXTENSIONS, in that order.
- @return
- The file name if found, or empty string if not found. */
+@return
+The file name if found, or empty string if not found. */
String
File_path::find (String name, char const *extensions[])
{
File_path::try_append (String s)
{
if (s == "")
- s = ".";
+ s = ".";
if (FILE *f = fopen (s.to_str0 (), "r"))
{
fclose (f);
/*
- process command line, GNU style.
+ process command line, GNU style.
- this is Copyleft (c) 1996--2005 Han-Wen Nienhuys, <hanwen@cs.uu.nl>
- */
+ this is Copyleft (c) 1996--2005 Han-Wen Nienhuys, <hanwen@cs.uu.nl>
+*/
#include "getopt-long.hh"
#include "string-convert.hh"
#if !HAVE_GETTEXT
-inline char*
-gettext (char const* s)
+inline char *
+gettext (char const *s)
{
- return (char*)s;
+ return (char *)s;
}
#else
#include <libintl.h>
const Long_option_init *
Getopt_long::parselong ()
{
- char const *optnm = arg_value_char_a_a_[array_index_] + 2 ;
+ char const *optnm = arg_value_char_a_a_[array_index_] + 2;
assert (*optnm);
char const *endopt = strchr (optnm, '=');
{
String str;
if (shortname_char_)
- str += "-" + shortname_char_;
+ str += "-" + shortname_char_;
if (shortname_char_ && longname_str0_)
str += ", ";
if (longname_str0_)
s = s + "=";
else
s = s + " ";
-
+
s = s + gettext (take_arg_str0_);
}
return s;
{
case E_ARGEXPECT:
str += _f ("option `%s' requires an argument",
- found_option_->to_string ());
+ found_option_->to_string ());
break;
- case E_NOARGEXPECT:
+ case E_NOARGEXPECT:
str += _f ("option `%s' doesn't allow an argument",
- found_option_->to_string ());
+ found_option_->to_string ());
break;
case E_UNKNOWNOPTION:
str += _f ("unrecognized option: `%s'",
- String (argument_index_
- ? String ("-" + String_convert::form_string ("%c",
- arg_value_char_a_a_[array_index_][argument_index_]))
- : String (arg_value_char_a_a_[array_index_])));
+ String (argument_index_
+ ? String ("-" + String_convert::form_string ("%c",
+ arg_value_char_a_a_[array_index_][argument_index_]))
+ : String (arg_value_char_a_a_[array_index_])));
break;
case E_ILLEGALARG:
str += _f ("invalid argument `%s' to option `%s'",
- optional_argument_str0_, found_option_->to_string ());
+ optional_argument_str0_, found_option_->to_string ());
break;
default:
assert (false);
}
- fprintf(error_out_, "%s\n", str.to_str0 ());
+ fprintf (error_out_, "%s\n", str.to_str0 ());
exit (2);
}
const Long_option_init *
Getopt_long::parseshort ()
{
- char c=arg_value_char_a_a_[array_index_][argument_index_];
- found_option_=0;
+ char c = arg_value_char_a_a_[array_index_][argument_index_];
+ found_option_ = 0;
assert (c);
- for (int i=0; i < table_len_; i++)
+ for (int i = 0; i < table_len_; i++)
if (option_a_[i].shortname_char_ == c)
{
- found_option_ = option_a_+i;
+ found_option_ = option_a_ + i;
break;
}
}
optional_argument_str0_ = arg_value_char_a_a_[array_index_] + argument_index_;
- array_index_ ++;
+ array_index_++;
argument_index_ = 0;
if (!optional_argument_str0_[0])
{
optional_argument_str0_ = arg_value_char_a_a_[array_index_];
- array_index_ ++;
+ array_index_++;
}
if (!optional_argument_str0_)
{
}
const Long_option_init *
-Getopt_long::operator () ()
+Getopt_long::operator() ()
{
if (!ok ())
return 0;
if (argument_index_)
return parseshort ();
- const char * argument = arg_value_char_a_a_[array_index_];
+ const char *argument = arg_value_char_a_a_[array_index_];
if (argument[0] != '-')
return 0;
}
}
-
-
-Getopt_long::Getopt_long (int c, char **v, Long_option_init *lo)
+Getopt_long::Getopt_long (int c, char **v, Long_option_init *lo)
{
option_a_ = lo;
error_out_ = stderr;
// reached end of option table?
table_len_ =0;
- for (int i = 0; option_a_[i].longname_str0_ ||option_a_[i].shortname_char_; i++)
- table_len_ ++;
+ for (int i = 0; option_a_[i].longname_str0_ ||option_a_[i].shortname_char_; i++)
+ table_len_++;
}
bool
Getopt_long::ok () const
{
- return array_index_ < argument_count_;
+ return array_index_ < argument_count_;
}
void
{
if (array_index_ >= argument_count_)
return 0;
- char const * a = arg_value_char_a_a_[array_index_];
+ char const *a = arg_value_char_a_a_[array_index_];
return a + argument_index_;
}
char const *
Getopt_long::get_next_arg ()
{
- char const * a = current_arg ();
+ char const *a = current_arg ();
if (a)
{
- array_index_ ++;
+ array_index_++;
argument_index_= 0;
}
return a;
}
-
const int EXTRA_SPACES = 5;
String
-Long_option_init::table_string (Long_option_init *l)
+Long_option_init::table_string (Long_option_init *l)
{
String argstr = "ARG";
String tabstr = "";
int wid = 0;
- for (int i=0; l[i].shortname_char_ || l[i].longname_str0_; i++)
+ for (int i = 0; l[i].shortname_char_ || l[i].longname_str0_; i++)
{
wid = wid >? l[i].str_for_help ().length ();
}
- for (int i=0; l[i].shortname_char_ || l[i].longname_str0_; i++)
+ for (int i = 0; l[i].shortname_char_ || l[i].longname_str0_; i++)
{
- String s = " " + l[i].str_for_help ();
+ String s = " " + l[i].str_for_help ();
s += String_convert::char_string (' ', wid - s.length () + EXTRA_SPACES);
tabstr += s + gettext (l[i].help_str0_) + "\n";
}
-
return tabstr;
}
char s[2] = {a.shortname_char_, 0};
return strcmp (s, b.longname_str0_);
}
-
+
return strcmp (a.longname_str0_, b.longname_str0_);
}
-/*
- arithmetic-operator.hh -- declare
-
+/*
+ arithmetic-operator.hh -- declare
+
source file of the Flower Library
-
+
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef ARITHMETIC_OPERATOR_HH
#define ARITHMETIC_OPERATOR_HH
-#define IMPLEMENT_ARITHMETIC_OPERATOR(type, op) \
-inline type \
-operator op (type a1, type const& a2) \
-{ \
- a1 op ## = a2; \
- return a1; \
-}
+#define IMPLEMENT_ARITHMETIC_OPERATOR(type, op) \
+ inline type \
+ operator op (type a1, type const &a2) \
+ { \
+ a1 op ## = a2; \
+ return a1; \
+ }
#endif /* ARITHMETIC_OPERATOR_HH */
/*
(c) 1995--2005 Han-Wen Nienhuys
- Distributed under GNU GPL
+ Distributed under GNU GPL
*/
#ifndef ARRAY_H
#endif
/// copy a bare (C-)array from #src# to #dest# sized #count#
-template<class T> void arrcpy (T*dest, T const*src, int count);
+template<class T> void arrcpy (T *dest, T const *src, int count);
/**
- Scaleable array/stack template, for a type T with default constructor.
-
-
- This template implements a scaleable vector. With (or without) range
- checking. The type T should have a default constructor. It is
- best suited for simple types, such as int, double or String, it
- provides a paranoidly safe replacement for the new T[int] construct.
-
- You should \bf{never} store pointers to objects in an Array (since
- the array may be relocated without the pointer knowing it).
-
- It uses stack terminology, (push, pop, top), and can be used as a stack.
-
-
- */
+ Scaleable array/stack template, for a type T with default constructor.
+
+
+ This template implements a scaleable vector. With (or without) range
+ checking. The type T should have a default constructor. It is
+ best suited for simple types, such as int, double or String, it
+ provides a paranoidly safe replacement for the new T[int] construct.
+
+ You should \bf{never} store pointers to objects in an Array (since
+ the array may be relocated without the pointer knowing it).
+
+ It uses stack terminology, (push, pop, top), and can be used as a stack.
+*/
template<class T>
class Array
{
T *array_;
/// stretch or shrink array.
- void remax (int newmax)
- {
- T* newarr = new T[newmax];
- size_ = (newmax < size_) ? newmax : size_;
- arrcpy (newarr, array_, size_);
-
- delete[] array_;
- array_ = newarr;
- max_ = newmax;
- }
+ void remax (int newmax)
+ {
+ T *newarr = new T[newmax];
+ size_ = (newmax < size_) ? newmax : size_;
+ arrcpy (newarr, array_, size_);
+
+ delete[] array_;
+ array_ = newarr;
+ max_ = newmax;
+ }
int size_;
public:
/// check invariants
- void OK () const ;
+ void OK () const;
/** report the size_.
- @see
+ @see
{setsize_}
*/
- int size () const
- {
- return size_;
- }
-
+ int size () const
+ {
+ return size_;
+ }
+
/// POST: size () == 0
- void clear ()
- {
- size_ = 0;
- }
+ void clear ()
+ {
+ size_ = 0;
+ }
Array (T *tp, int n)
- {
- array_ = new T[n];
- max_ =size_ = n;
- arrcpy (array_, tp, n);
- }
-
- Array ()
- { array_ = 0; max_ =0; size_ =0; }
+ {
+ array_ = new T[n];
+ max_ =size_ = n;
+ arrcpy (array_, tp, n);
+ }
- // ugh, get around gcc 2.8.1 ice; see bezier.cc
- Array (int i)
- {
- max_ = size_ = i;
- array_ = new T[i];
- }
+ Array ()
+ { array_ = 0; max_ =0; size_ =0; }
+ // ugh, get around gcc 2.8.1 ice; see bezier.cc
+ Array (int i)
+ {
+ max_ = size_ = i;
+ array_ = new T[i];
+ }
/** set the size_ to #s#.
POST: size () == s.
Warning: contents are unspecified */
- void set_size (int s)
- {
- if (s > max_) remax (s);
- size_ = s;
- }
-
- ~Array ()
- { delete[] array_; }
+ void set_size (int s)
+ {
+ if (s > max_) remax (s);
+ size_ = s;
+ }
+
+ ~Array ()
+ { delete[] array_; }
/// return a "new"ed copy of array
- T* copys () const
- {
- T* Tarray = new T[size_];
- arrcpy (Tarray, array_, size_);
- return Tarray;
- }
+ T *copys () const
+ {
+ T *Tarray = new T[size_];
+ arrcpy (Tarray, array_, size_);
+ return Tarray;
+ }
T const *accesses () const
- {
- return array_;
- }
- void operator= (Array const & src)
- {
- set_size (src.size_);
- arrcpy (array_,src.array_, size_);
- }
- Array (Array const & src)
- {
- array_ = src.copys ();
- max_ = size_ = src.size_;
- }
+ {
+ return array_;
+ }
+ void operator= (Array const &src)
+ {
+ set_size (src.size_);
+ arrcpy (array_, src.array_, size_);
+ }
+ Array (Array const &src)
+ {
+ array_ = src.copys ();
+ max_ = size_ = src.size_;
+ }
/// tighten array size_.
- void tighten_maxsize () {
+ void tighten_maxsize ()
+ {
remax (size_);
}
-
- T * remove_array ();
+
+ T *remove_array ();
/// access element
- T &operator[] (int i)
- {
- return elem_ref (i);
- }
+ T &operator[] (int i)
+ {
+ return elem_ref (i);
+ }
/// access element
- T const & operator[] (int i) const
- {
- return elem_ref (i);
- }
+ T const &operator[] (int i) const
+ {
+ return elem_ref (i);
+ }
/// access element
- T &elem_ref (int i) const
- {
- assert (i >=0 && i < size_);
- return ((T*)array_)[i];
- }
+ T &elem_ref (int i) const
+ {
+ assert (i >=0 && i < size_);
+ return ((T *)array_)[i];
+ }
/// access element
- T elem (int i) const
- {
- return elem_ref (i);
- }
+ T elem (int i) const
+ {
+ return elem_ref (i);
+ }
/// add to the end of array
- void push (T x)
- {
- if (size_ == max_)
- remax (2*max_ + 1);
-
- // T::operator= (T &) is called here. Safe to use with automatic
- // vars
- array_[size_++] = x;
- }
+ void push (T x)
+ {
+ if (size_ == max_)
+ remax (2*max_ + 1);
+
+ // T::operator= (T &) is called here. Safe to use with automatic
+ // vars
+ array_[size_++] = x;
+ }
/// remove and return last entry
- T pop ()
- {
- assert (!is_empty ());
- T l = top (0);
- set_size (size ()-1);
- return l;
- }
+ T pop ()
+ {
+ assert (!is_empty ());
+ T l = top (0);
+ set_size (size () - 1);
+ return l;
+ }
/// access last entry
- T& top (int j=0)
- {
- return (*this)[size_-j-1];
- }
+ T &top (int j = 0)
+ {
+ return (*this)[size_ - j - 1];
+ }
/// return last entry
- T top (int j=0) const
- {
- return (*this)[size_-j-1];
- }
-
- T& boundary (int dir, int idx)
- {
- assert (dir);
- if (dir == 1)
- return top (idx);
- else
- return elem_ref (idx);
- }
+ T top (int j = 0) const
+ {
+ return (*this)[size_ - j - 1];
+ }
+
+ T &boundary (int dir, int idx)
+ {
+ assert (dir);
+ if (dir == 1)
+ return top (idx);
+ else
+ return elem_ref (idx);
+ }
T boundary (int dir, int idx) const
- {
- assert (dir);
- if (dir == 1)
- return top (idx);
- else
- return elem (idx);
- }
- void swap (int i,int j)
- {
- T t ((*this)[i]);
- (*this)[i]= (*this)[j];
- (*this)[j]=t;
- }
- bool is_empty () const
- { return !size_; }
+ {
+ assert (dir);
+ if (dir == 1)
+ return top (idx);
+ else
+ return elem (idx);
+ }
+ void swap (int i, int j)
+ {
+ T t ((*this)[i]);
+ (*this)[i]= (*this)[j];
+ (*this)[j] = t;
+ }
+ bool is_empty () const
+ { return !size_; }
void insert (T k, int j);
/**
remove i-th element, and return it.
*/
- T get (int i)
- {
- T t = elem (i);
- del (i);
- return t;
- }
+ T get (int i)
+ {
+ T t = elem (i);
+ del (i);
+ return t;
+ }
void unordered_del (int i)
- {
- elem_ref (i) = top ();
- set_size (size () -1);
- }
- void del (int i)
- {
- assert (i >=0&& i < size_);
- arrcpy (array_+i, array_+i+1, size_-i-1);
- size_--;
- }
+ {
+ elem_ref (i) = top ();
+ set_size (size () -1);
+ }
+ void del (int i)
+ {
+ assert (i >=0&& i < size_);
+ arrcpy (array_ + i, array_ + i + 1, size_ - i - 1);
+ size_--;
+ }
// quicksort.
- void sort (int (*compare) (T const&,T const&),
+ void sort (int (*compare) (T const &, T const &),
int lower = -1, int upper = -1);
- void concat (Array<T> const &src)
- {
- int s = size_;
- set_size (size_ + src.size_);
- arrcpy (array_+s,src.array_, src.size_);
- }
- Array<T> slice (int lower, int upper) const;
+ void concat (Array<T> const &src)
+ {
+ int s = size_;
+ set_size (size_ + src.size_);
+ arrcpy (array_ + s, src.array_, src.size_);
+ }
+ Array<T> slice (int lower, int upper) const;
void reverse ();
};
template<class T>
-int default_compare (T const&a , T const&b)
+int default_compare (T const &a, T const &b)
{
if (a < b)
return -1;
Distributed under GNU GPL
*/
-
#if 0
#include "array.hh"
#ifdef INLINE
#endif
/*
- functions with loops don't inline
- */
+ functions with loops don't inline
+*/
-template<class T> INLINE void
-arrcpy (T*dest, T const* src, int count)
+template<class T> INLINE void
+arrcpy (T *dest, T const *src, int count)
{
- for (int i_shadows_local=0; i_shadows_local < count ; i_shadows_local++)
+ for (int i_shadows_local = 0; i_shadows_local < count; i_shadows_local++)
#ifdef __powerpc__
{
/*
urg: wierd egcs-1.1.2-12c (stock LinuxPPC R5) bug on ppc
bug report filed
fixed in egcs-1.1.2-12f
- ftp://dev.linuxppc.org/users/fsirl/R5/RPMS/ppc/
+ ftp://dev.linuxppc.org/users/fsirl/R5/RPMS/ppc/
*/
*dest = *src;
dest++, src++;
}
#else
- *dest++ = *src++;
+ *dest++ = *src++;
#endif
}
template<class T> INLINE void
-Array<T>::insert (T k, int j)
+Array<T>::insert (T k, int j)
{
assert (j >=0 && j<= size_);
- set_size (size_+1);
- for (int i=size_-1; i > j; i--)
- array_[i] = array_[i-1];
+ set_size (size_ + 1);
+ for (int i = size_ - 1; i > j; i--)
+ array_[i] = array_[i - 1];
array_[j] = k;
}
template<class T> INLINE void
-Array<T>::sort (int (*compare) (T const&,T const&), int lower, int upper)
+Array<T>::sort (int (*compare) (T const &, T const &), int lower, int upper)
{
- if (lower < 0)
+ if (lower < 0)
{
- lower = 0 ;
+ lower = 0;
upper = size () - 1;
}
if (lower >= upper)
return;
- swap (lower, (lower+upper)/2);
+ swap (lower, (lower + upper) / 2);
int last = lower;
for (int i= lower +1; i <= upper; i++)
if (compare (array_[i], array_[lower]) < 0)
- swap (++last,i);
+ swap (++last, i);
swap (lower, last);
- sort (compare, lower, last-1);
- sort (compare, last+1, upper);
+ sort (compare, lower, last - 1);
+ sort (compare, last + 1, upper);
}
template<class T> INLINE void
-Array<T>::reverse ()
+Array<T>::reverse ()
{
- int h = size_/2;
- for (int i =0,j = size_-1; i < h; i++,j--)
- swap (i,j);
+ int h = size_ / 2;
+ for (int i =0, j = size_ - 1; i < h; i++, j--)
+ swap (i, j);
}
template<class T> INLINE
T *
Array<T>::remove_array ()
{
- T * p = array_;
+ T *p = array_;
size_ = 0;
max_ = 0;
array_ =0;
{
assert (lower >= 0 && lower <=upper&& upper <= size_);
Array<T> r;
- int s =upper-lower;
+ int s =upper - lower;
r.set_size (s);
- arrcpy (r.array_, array_ + lower, s);
+ arrcpy (r.array_, array_ + lower, s);
return r;
}
-
template<class T>
void
binary_search_bounds (Array<T> const &table,
- T const &key, int (*compare) (T const&, T const &),
+ T const &key, int (*compare) (T const &, T const &),
int *lo,
int *hi)
{
/* binary search */
do
- {
+ {
cmp = (*lo + *hi) / 2;
- result = (*compare) (key, table[cmp]);
+ result = (*compare) (key, table[cmp]);
if (result < 0)
- *hi = cmp;
+ *hi = cmp;
else
- *lo = cmp;
+ *lo = cmp;
}
while (*hi - *lo > 1);
}
-
/*
lookup with binsearch, return array index.
*/
template<class T>
int
binary_search (Array<T> const &table,
- T const &key, int (*compare) (T const&, T const &),
+ T const &key, int (*compare) (T const &, T const &),
int lo = 0,
- int hi = -1
- )
+ int hi = -1)
{
if (hi < 0)
hi = table.size ();
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef AXES_HH
#define AXES_HH
#include <cassert>
-enum Axis {
+enum Axis
+ {
X_AXIS =0,
Y_AXIS =1,
- NO_AXES=2,
-};
+ NO_AXES = 2,
+ };
static inline
Axis
Axis
other_axis (Axis a)
{
- return a == Y_AXIS ? X_AXIS : Y_AXIS;
+ return a == Y_AXIS ? X_AXIS : Y_AXIS;
}
#endif // AXES_HH
flowerlib
(c) 1996--2005 Han-Wen Nienhuys
- */
+*/
#ifndef COMPARE_HH
#define COMPARE_HH
-#define ONE_OPERATOR(type, function, op) \
-inline bool \
-operator op (type t1, type t2) {\
- return function (t1, t2) op 0;\
-}\
-
-#define GPP_MINMAX_OPERATOR(type, op, opp) \
-inline type \
-operator op (type t1, type t2)\
-{\
- return (t1 opp t2) ? t1 : t2;\
-}\
+#define ONE_OPERATOR(type, function, op) \
+ inline bool \
+ operator op (type t1, type t2) \
+ { \
+ return function (t1, t2) op 0; \
+ }
+#define GPP_MINMAX_OPERATOR(type, op, opp) \
+ inline type \
+ operator op (type t1, type t2) \
+ { \
+ return (t1 opp t2) ? t1 : t2; \
+ }
#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
-#define GPP_MINMAX(type, prefix)\
- prefix GPP_MINMAX_OPERATOR (type, <?, <)\
- prefix GPP_MINMAX_OPERATOR (type, >?, >)
+#define GPP_MINMAX(type, prefix) \
+ prefix GPP_MINMAX_OPERATOR (type, <?, <) \
+ prefix GPP_MINMAX_OPERATOR (type, >?, >)
#else
-#define GPP_MINMAX(type, prefix)
+#define GPP_MINMAX (type, prefix)
#endif
-/** handy notations for a signed comparison.
- make the operators{<,<=,==,>=,>} and the MAX and MIN of two.
- Please fill a & in the type argument if necessary.
- */
-#define TEMPLATE_INSTANTIATE_COMPARE(type, function, prefix) \
-prefix ONE_OPERATOR (type, function, >)\
-prefix ONE_OPERATOR (type, function, >=)\
-prefix ONE_OPERATOR (type, function, ==)\
-prefix ONE_OPERATOR (type, function, !=)\
-prefix ONE_OPERATOR (type, function, <)\
-prefix ONE_OPERATOR (type, function, <=)\
-GPP_MINMAX (type, prefix)\
-prefix inline type max (type t1, type t2) { return (t1 > t2)? t1 : t2; }\
-prefix inline type min (type t1, type t2) { return (t1 < t2)? t1 : t2; }\
- \
-prefix bool operator< (type t1, type t2) /* stupid fix to allow ; */
-
-
-
-#define INSTANTIATE_COMPARE(type, func) TEMPLATE_INSTANTIATE_COMPARE (type,func,)
-
-
-
+/** handy notations for a signed comparison.
+ make the operators{<,<=,==,>=,>} and the MAX and MIN of two.
+ Please fill a & in the type argument if necessary.
+*/
+#define TEMPLATE_INSTANTIATE_COMPARE(type, function, prefix) \
+ prefix ONE_OPERATOR (type, function, >) \
+ prefix ONE_OPERATOR (type, function, >=) \
+ prefix ONE_OPERATOR (type, function, ==) \
+ prefix ONE_OPERATOR (type, function, !=) \
+ prefix ONE_OPERATOR (type, function, <) \
+ prefix ONE_OPERATOR (type, function, <=) \
+ GPP_MINMAX (type, prefix) \
+ prefix inline type max (type t1, type t2) { return (t1 > t2)? t1 : t2; } \
+ prefix inline type min (type t1, type t2) { return (t1 < t2)? t1 : t2; } \
+ \
+ prefix bool operator< (type t1, type t2) /* stupid fix to allow ; */
+
+#define INSTANTIATE_COMPARE(type, func) TEMPLATE_INSTANTIATE_COMPARE (type, func,)
+
#endif
-
+
-/*
+/*
cons.hh -- declare LISP like datatypes
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef CONS_HH
#define CONS_HH
-
#include <cassert>
template<class T>
class Cons
{
public:
- T * car_;
- Cons * next_;
+ T *car_;
+ Cons *next_;
Cons ()
- {
- car_=0;
- next_ =0;
- }
- Cons (T*t, Cons<T>*c)
- {
- car_ = t;
- next_ = c;
- }
- virtual ~Cons ()
- {
- delete next_;
- }
+ {
+ car_ = 0;
+ next_ =0;
+ }
+ Cons (T *t, Cons<T>*c)
+ {
+ car_ = t;
+ next_ = c;
+ }
+ virtual ~Cons ()
+ {
+ delete next_;
+ }
};
template<class T>
{
public:
Killing_cons (T *t, Cons<T> *p)
- : Cons<T> ( t,p)
- {
- }
+ : Cons<T> (t, p)
+ {
+ }
virtual ~Killing_cons ();
};
-
/// remove the link pointed to by *p.
template<class T>
Cons<T> *remove_cons (Cons<T> **pp)
template<class T> int cons_list_size (Cons<T> *l)
{
- int i=0;
+ int i = 0;
while (l)
{
l = l->next_;
- i++;
+ i++;
}
return i;
}
-
-
-
template<class T>
Cons<T> * last_cons (Cons<T> * head)
{
/**
- Invariants:
+Invariants:
+
+(*tail_) is either the head_ pointer, or a next_ pointer from the list.
- (*tail_) is either the head_ pointer, or a next_ pointer from the list.
-
- **tail_ == NULL
- */
+**tail_ == NULL
+*/
template<class T>
class Cons_list
Cons<T> * head_;
Cons<T> ** nil_pointer_address_;
Cons_list ()
- {
- init ();
- }
+ {
+ init ();
+ }
void init ()
- {
- head_ =0;
- nil_pointer_address_ = &head_;
- }
+ {
+ head_ =0;
+ nil_pointer_address_ = &head_;
+ }
void append (T *c)
- {
- append (new Cons<T> (c,0));
- }
+ {
+ append (new Cons<T> (c, 0));
+ }
void append (Cons<T> *c)
- {
- assert (!c->next_);
- *nil_pointer_address_ = c;
- while (*nil_pointer_address_)
- nil_pointer_address_ = & (*nil_pointer_address_)->next_;
- }
+ {
+ assert (!c->next_);
+ *nil_pointer_address_ = c;
+ while (*nil_pointer_address_)
+ nil_pointer_address_ = &(*nil_pointer_address_)->next_;
+ }
/**
PRE: *pp should either be the head_ pointer, or the next_ pointer
from a list cell.
*/
Cons<T> *remove_cons (Cons<T> **pp)
- {
- if (& (*pp)->next_ == nil_pointer_address_)
- nil_pointer_address_ = pp;
+ {
+ if (& (*pp)->next_ == nil_pointer_address_)
+ nil_pointer_address_ = pp;
- return ::remove_cons (pp);
- }
+ return ::remove_cons (pp);
+ }
/// junk everything after the first I elements.
void truncate (int i)
- {
- Cons<T> **p = &head_;
- for (; *p && i; p = & ((*p)->next_))
- {
- i--;
- }
-
- if (*p)
- {
- delete *p;
- *p = 0;
- }
- nil_pointer_address_ = p;
- }
+ {
+ Cons<T> **p = &head_;
+ for (; *p && i; p = &((*p)->next_))
+ {
+ i--;
+ }
+
+ if (*p)
+ {
+ delete *p;
+ *p = 0;
+ }
+ nil_pointer_address_ = p;
+ }
void junk ()
- {
- delete head_;
- head_ =0;
- }
+ {
+ delete head_;
+ head_ =0;
+ }
~Cons_list ()
- {
- junk ();
- }
+ {
+ junk ();
+ }
int size ()
- {
- return cons_list_size (head_);
- }
+ {
+ return cons_list_size (head_);
+ }
};
-
template<class T>
-void copy_killing_cons_list (Cons_list<T>&, Cons<T> *src);
+void copy_killing_cons_list (Cons_list<T>&, Cons<T> *src);
template<class T>
void
clone_killing_cons_list (Cons_list<T>&, Cons<T> *src);
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef CPU_TIMER_HH
#define CPU_TIMER_HH
#include "real.hh"
-class Cpu_timer {
+class Cpu_timer
+{
clock_t start_clock_;
public:
Cpu_timer ();
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef DIRECTION_HH
#define DIRECTION_HH
#include "axes.hh"
-enum Direction
-{
- UP=1,
- DOWN=-1,
- LEFT=-1,
- RIGHT=1,
- MIN=-1,
- MAX=1,
- CENTER=0,
- SMALLER=-1,
- BIGGER=1,
- START = -1,
- STOP = 1,
+enum Direction
+ {
+ UP = 1,
+ DOWN=-1,
+ LEFT=-1,
+ RIGHT = 1,
+ MIN=-1,
+ MAX = 1,
+ CENTER = 0,
+ SMALLER=-1,
+ BIGGER = 1,
+ START = -1,
+ STOP = 1,
+
+ /*
+ This is necessary to safely write loops,
+ since
- /*
- This is necessary to safely write loops,
- since
-
dir <= RIGHT
- is otherwise transformed into true unconditionally.
- */
- DIRECTION_LIMIT = 2,
- DIRECTION_NEG_LIMIT = -2,
-};
+ is otherwise transformed into true unconditionally.
+ */
+ DIRECTION_LIMIT = 2,
+ DIRECTION_NEG_LIMIT = -2,
+ };
inline Direction
other_dir (Direction const d)
}
inline Direction
-operator - (Direction const d)
+operator- (Direction const d)
{
return other_dir (d);
}
// huh?
inline Direction
-flip (Direction *i) {
+flip (Direction *i)
+{
if (*i == (Direction)1)
- *i = (Direction)-1;
- else if (*i == (Direction)-1)
+ *i = (Direction) - 1;
+ else if (*i == (Direction) - 1)
*i = (Direction)1;
return *i;
}
/**
if d > 0: the max operator
if d < 0: the min operator
- */
+*/
template<class T> T minmax (Direction d, T, T);
// String direction_string (Direction, Axis);
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef DRUL_ARRAY_HH
#define DRUL_ARRAY_HH
#include "real.hh"
/**
- Left/right or Up/down arrays. Drul is nicer sounding than udlr
- */
+ Left/right or Up/down arrays. Drul is nicer sounding than udlr
+*/
template<class T>
struct Drul_array
{
T array_[2];
T &elem_ref (Direction d)
{
- assert (d==1 || d== -1);
- return array_[ (d+1)/2];
+ assert (d == 1 || d== -1);
+ return array_[ (d + 1) / 2];
}
T elem (Direction d) const
{
- assert (d==1 || d== -1);
- return array_[ (d+1)/2];
+ assert (d == 1 || d== -1);
+ return array_[ (d + 1) / 2];
}
T &operator[] (Direction d)
{
String ext_;
File_name (String);
-
+
String to_string () const;
char const *to_str0 () const;
};
#include "array.hh"
#include "string.hh"
-/**
- search in directories for a file.
+/**
+ search in directories for a file.
Abstraction of PATH variable. An interface for searching input files.
Search a number of dirs for a file.
- TODO: add a unix style PATH interface
+ TODO: add a unix style PATH interface
*/
class File_path : private Array<String>
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef FILE_STORAGE_HH
#define FILE_STORAGE_HH
#include "flower-proto.hh"
-
/**
- store a file in-memory.
- */
+ store a file in-memory.
+*/
class File_storage
{
public:
- virtual char const* to_str0 () const=0;
- virtual int length () const=0;
+ virtual char const *to_str0 () const = 0;
+ virtual int length () const = 0;
virtual ~File_storage (){}
};
#ifndef FPROTO_HH
#define FPROTO_HH
-
-char const * flower_version_str0 ();
+char const *flower_version_str0 ();
template<class T> struct Link_array;
template<class T> struct Array;
-template<class T,class K> struct Assoc;
-template<class K, class V> struct Hash_table;
-template<class K, class V> struct Hash_table_iter;
+template < class T, class K> struct Assoc;
+template < class K, class V> struct Hash_table;
+template < class K, class V> struct Hash_table_iter;
template<class T> struct Link_list;
template<class T> struct Interval_t;
template<class T> struct PQueue;
struct Mapped_file_storage;
struct Simple_file_storage;
-
-
#endif // FPROTO_HH
/**
a struct this for initialising the commandline options.
*/
-struct Long_option_init {
- char const * take_arg_str0_;
- char const * longname_str0_;
+struct Long_option_init
+{
+ char const *take_arg_str0_;
+ char const *longname_str0_;
/*
= 0: don't take short version.
*/
char shortname_char_;
- char const * help_str0_;
-
+ char const *help_str0_;
+
String to_string () const;
String str_for_help () const;
// NO constructor!
- static int compare (Long_option_init const&,Long_option_init const&);
- static String table_string (Long_option_init *);
+ static int compare (Long_option_init const &, Long_option_init const &);
+ static String table_string (Long_option_init *);
};
-
/** C++ for version of long_getopt. For processing GNU style command
- line arguments. No pointer (return values, arguments) contents are
- copied.
-
- TODO: handle
- command - , and command --
-
- argument reordering
- */
-class Getopt_long {
+ line arguments. No pointer (return values, arguments) contents are
+ copied.
+
+ TODO: handle
+ command - , and command --
+
+ argument reordering
+*/
+class Getopt_long
+{
/// the option info.
const Long_option_init *option_a_;
int table_len_;
-
+
/// if doing short option, arg_value_char_a_a_[optind][optindind] is processed next.
int argument_index_;
/// the option found
const Long_option_init *found_option_;
-
-public:
+public:
/** errorcodes: no error, argument expected, no argument expected,
- unknown option, illegal argument (eg. int expected). */
+ unknown option, illegal argument (eg. int expected). */
enum Errorcod { E_NOERROR = 0, E_ARGEXPECT, E_NOARGEXPECT, E_UNKNOWNOPTION,
- E_ILLEGALARG } ;
+ E_ILLEGALARG };
/// argument. Set to 0 if not present
- char const * optional_argument_str0_;
+ char const *optional_argument_str0_;
/// current error status
Errorcod error_;
/// report an error and abort
void report (Errorcod c);
-
/// return an integer (with err. detect)
long get_argument_index ();
-
-
+
/**
- What to do with errors.
- report messages on #*os#, and abort.
- if #os# is null, then do not report nor abort, just set #error#
- */
-
+ What to do with errors.
+ report messages on #*os#, and abort.
+ if #os# is null, then do not report nor abort, just set #error#
+ */
+
void seterror (FILE *os);
/// construct: pass arguments and option info.
- Getopt_long (int c, char **v, Long_option_init *lo);
+ Getopt_long (int c, char **v, Long_option_init *lo);
- /** get the next option.
- @return pointer to next option found.
- 0 if error occurred, or next argument is no option.
- */
- const Long_option_init *operator () ();
+ /** get the next option.
+ @return pointer to next option found.
+ 0 if error occurred, or next argument is no option.
+ */
+ const Long_option_init *operator() ();
char const *current_arg ();
- char const * get_next_arg ();
+ char const *get_next_arg ();
};
#endif // GETOPT_LONG_HH
-/*
+/*
guile-compatibility.hh -- declare compat functions for GUILE 1.6
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef GUILE_COMPATIBILITY_HH
inline SCM scm_car (SCM x)
{
if (SCM_NCONSP (x))
- abort ();
+ abort ();
return SCM_CAR (x);
}
inline SCM scm_caar (SCM x) { return SCM_CAAR (x); }
#define scm_gc_register_collectable_memory(a, b, c) scm_done_malloc (b)
#define scm_is_vector(x) (SCM_VECTORP ((SCM) x))
#define SCM_HASHTABLE_P(x) (SCM_VECTORP ((SCM) x))
-#define SCM_VECTOR_REF(v, i) (SCM_VELTS ((v))[(i)])
+#define SCM_VECTOR_REF(v, i) (SCM_VELTS ((v))[ (i)])
#define scm_from_bool(x) (x ? SCM_BOOL_T : SCM_BOOL_F)
#define scm_from_int(x) SCM_MAKINUM (x)
#define scm_from_unsigned_integer(x) scm_uint2num (x)
inline int ly_c_symbol_p (SCM x) { return SCM_SYMBOLP (x); }
#define scm_is_symbol(x) ly_c_symbol_p (x)
inline int ly_c_boolean_p (SCM x) { return SCM_BOOLP (x); }
-#define scm_is_bool(x) ly_c_boolean_p(x)
+#define scm_is_bool(x) ly_c_boolean_p (x)
inline int ly_c_eq_p (SCM x, SCM y) { return SCM_EQ_P (x, y); }
#define scm_is_eq(x, y) (SCM_EQ_P ((x), (y)))
#define scm_is_pair(x) (SCM_CONSP (x))
#define scm_c_vector_length(x) SCM_VECTOR_LENGTH (x)
-#define scm_c_vector_ref(x, y) SCM_VECTOR_REF(x, y)
+#define scm_c_vector_ref(x, y) SCM_VECTOR_REF (x, y)
inline double ly_scm2double (SCM x) { return scm_num2dbl (x, "ly_scm2double"); }
#define scm_to_double(x) (ly_scm2double (x))
-/*
+/*
international.hh -- declare stuff for internationalization
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
-
- */
+*/
#ifndef INTERNATIONAL_HH
#define INTERNATIONAL_HH
-
/**
- Internationalisation: _i ("to be translated") gets an entry in the POT file
- gettext () must be invoked explicitely to do the actual "translation".
- See flower/getopt-long.cc.
- */
+ Internationalisation: _i ("to be translated") gets an entry in the POT file
+ gettext () must be invoked explicitely to do the actual "translation".
+ See flower/getopt-long.cc.
+*/
#define _i(sz) sz
// don't inline: get warnings only once
/**
- Internationalisation: _ ("to be translated") gets "translated" by GNU gettext
+ Internationalisation: _ ("to be translated") gets "translated" by GNU gettext
*/
String _ (char const *ch);
/**
- Internationalisation: _f ("Usage: %s [FILE]", "lilypond") gets "translated" by
- GNU gettext
+ Internationalisation: _f ("Usage: %s [FILE]", "lilypond") gets "translated" by
+ GNU gettext
*/
-String _f (char const* format, ...);
-String _f (char const* format, String s, String s2 = "", String s3 = "");
+String _f (char const *format, ...);
+String _f (char const *format, String s, String s2 = "", String s3 = "");
#endif // INTERNATIONAL_HH
-/*
+/*
interval-set.hh -- declare Interval_set
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef INTERVAL_SET_HH
Abysmal performance (quadratic) for large N, hopefully we don't have
that large N. In any case, this should probably be rewritten to use
a balanced tree.
- */
+*/
struct Interval_set
{
Array<Interval> allowed_regions_;
/*
interval.hh -- part of flowerlib
-
+
(c) 1996--2005 Han-Wen Nienhuys
*/
static String T_to_string (T arg);
T center () const;
void translate (T t)
- {
- elem_ref (LEFT) += t;
- elem_ref (RIGHT) += t;
- }
+ {
+ elem_ref (LEFT) += t;
+ elem_ref (RIGHT) += t;
+ }
void widen (T t)
{
elem_ref (LEFT) -= t;
- elem_ref (RIGHT) += t;
+ elem_ref (RIGHT) += t;
}
-
+
T distance (T t) const
{
if (t > elem (RIGHT))
return T (0);
}
/**
- PRE
- *this and h are comparable
- */
+ PRE
+ *this and h are comparable
+ */
void unite (Interval_t<T> h);
void intersect (Interval_t<T> h);
void add_point (T p)
{
- elem_ref(LEFT) = elem (LEFT) <? p;
- elem_ref(RIGHT) = elem (RIGHT) >? p;
+ elem_ref (LEFT) = elem (LEFT) <? p;
+ elem_ref (RIGHT) = elem (RIGHT) >? p;
}
T length () const;
T delta () const;
/*
TODO: strip hungarian suffix.
- */
+ */
bool is_empty () const
{
return elem (LEFT) > elem (RIGHT);
}
- bool superset (Interval_t<T> const&) const;
+ bool superset (Interval_t<T> const &) const;
Interval_t ()
{
set_empty ();
}
- Interval_t (T m, T M) : Drul_array<T> (m,M)
- {
- }
- Interval_t<T> &operator -= (T r) {
+ Interval_t (T m, T M) : Drul_array<T> (m, M)
+ {
+ }
+ Interval_t<T> &operator-= (T r)
+ {
*this += -r;
return *this;
}
- Interval_t<T> &operator += (T r) {
+ Interval_t<T> &operator+= (T r)
+ {
elem_ref (LEFT) += r;
elem_ref (RIGHT) +=r;
return *this;
}
- Interval_t<T> &operator *= (T r) {
+ Interval_t<T> &operator*= (T r)
+ {
if (!is_empty ())
{
elem_ref (LEFT) *= r;
elem_ref (RIGHT) *= r;
if (r < T (0))
- swap();
+ swap ();
}
return *this;
}
};
-
/**
- inclusion ordering. Crash if not comparable.
- */
+ inclusion ordering. Crash if not comparable.
+*/
template<class T>
-int Interval__compare (const Interval_t<T>&,Interval_t<T> const&);
+int Interval__compare (const Interval_t<T>&, Interval_t<T> const &);
/**
Inclusion ordering. return -2 if not comparable
- */
+*/
template<class T>
int
-_Interval__compare (const Interval_t<T>&a,Interval_t<T> const&b);
-
+_Interval__compare (const Interval_t<T>&a, Interval_t<T> const &b);
/*
INLINE
- */
+*/
#include "compare.hh"
TEMPLATE_INSTANTIATE_COMPARE (Interval_t<T>&, Interval__compare, template<class T>);
-
template<class T>
inline Interval_t<T>
-intersection (Interval_t<T> a, Interval_t<T> const&b)
+intersection (Interval_t<T> a, Interval_t<T> const &b)
{
a.intersect (b);
return a;
-
+
}
template<class T>
inline
-Interval_t<T> operator + (T a,Interval_t<T> i)
+Interval_t<T> operator+ (T a, Interval_t<T> i)
{
i += a;
return i;
template<class T>
inline
-Interval_t<T> operator - (Interval_t<T> i, T a)
+Interval_t<T> operator- (Interval_t<T> i, T a)
{
i += -a;
return i;
template<class T>
inline
-Interval_t<T> operator - (T a,Interval_t<T> i)
+Interval_t<T> operator- (T a, Interval_t<T> i)
{
i.negate ();
i += a;
template<class T>
inline
-Interval_t<T> operator + (Interval_t<T> i,T a){
- return a+i;
+Interval_t<T> operator+ (Interval_t<T> i, T a)
+{
+ return a + i;
}
template<class T>
inline
-Interval_t<T> operator * (T a,Interval_t<T> i)
+Interval_t<T> operator* (T a, Interval_t<T> i)
{
i *= a;
return i;
template<class T>
inline
-Interval_t<T> operator * (Interval_t<T> i,T a){
+Interval_t<T> operator* (Interval_t<T> i, T a)
+{
return a*i;
}
-
template<class T>
inline T
Interval_t<T>::center () const
(c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef INTERVAL_TCC
#define INTERVAL_TCC
-#include <cassert>
+#include <cassert>
#include <cmath>
#include "interval.hh"
#include "string.hh"
-
template<class T>
int
-_Interval__compare (const Interval_t<T>&a,Interval_t<T> const&b)
+_Interval__compare (const Interval_t<T>&a, Interval_t<T> const &b)
{
if (a.elem (LEFT) == b.elem (LEFT) && a.elem (RIGHT) == b.elem (RIGHT))
return 0;
-
+
if (a.elem (LEFT) <= b.elem (LEFT) && a.elem (RIGHT) >= b.elem (RIGHT))
return 1;
}
template<class T>
-bool
-Interval_t<T>::superset (Interval_t<T> const& a) const
+bool
+Interval_t<T>::superset (Interval_t<T> const &a) const
{
int c_i = _Interval__compare (*this, a);
if (c_i == -2)
template<class T>
int
-Interval__compare (Interval_t<T> const& a,Interval_t<T> const& b)
+Interval__compare (Interval_t<T> const &a, Interval_t<T> const &b)
{
- int i = _Interval__compare (a,b);
+ int i = _Interval__compare (a, b);
if (i < -1)
assert (false);
return i;
template<class T>
T
-Interval_t<T>::length () const
+Interval_t<T>::length () const
{
- if (elem (RIGHT) <= elem (LEFT))
+ if (elem (RIGHT) <= elem (LEFT))
return 0;
- else
+ else
return elem (RIGHT) - elem (LEFT);
}
template<class T>
T
-Interval_t<T>::delta () const
+Interval_t<T>::delta () const
{
return elem (RIGHT) - elem (LEFT);
}
if (is_empty ())
return "[empty]";
String s ("[");
-
- return (s + T_to_string (elem (LEFT)) + String ("," )
- + T_to_string (elem (RIGHT) ) + String ("]" ));
+
+ return (s + T_to_string (elem (LEFT)) + String (",")
+ + T_to_string (elem (RIGHT)) + String ("]"));
}
template<class T>
return r >= elem (LEFT) && r <= elem (RIGHT);
}
-#define INTERVAL__INSTANTIATE(T) struct Interval_t<T>;\
-template int Interval__compare (const Interval_t<T>&,Interval_t<T> const&)
+#define INTERVAL__INSTANTIATE(T) struct Interval_t<T>; \
+ template int Interval__compare (const Interval_t<T>&, Interval_t<T> const &)
#endif // INTERVAL_TCC
-/*
+/*
killing-cons.tcc -- declare Killing_cons
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef KILLING_CONS_TCC
#define KILLING_CONS_TCC
}
template<class T>
-void
-copy_killing_cons_list (Cons_list<T> &dest, Cons<T> *src)
+void
+copy_killing_cons_list (Cons_list<T> &dest, Cons<T> *src)
{
- for (; src; src = src->next_)
+ for (; src; src = src->next_)
{
T *t = new T (*src->car_);
- dest.append ( new Killing_cons<T> (t, 0));
+ dest.append (new Killing_cons<T> (t, 0));
}
}
void
clone_killing_cons_list (Cons_list<T> & dest, Cons<T> *src)
{
- for (; src; src = src->next_)
+ for (; src; src = src->next_)
{
T *t = src->car_->clone ();
- dest.append (new Killing_cons<T> (t, 0));
+ dest.append (new Killing_cons<T> (t, 0));
}
}
char *strnupr (char *start, int n);
#if ! HAVE_MEMMEM /* GNU extension. */
-void *memmem (void const* haystack, int haystack_len,
+void *memmem (void const *haystack, int haystack_len,
void const *needle, int needle_len);
#endif /* HAVE_MEMMEM */
#if 1 //! HAVE_FUNOPEN
-#define cookie_io_functions_t le_cookie_io_functions_t
+#define cookie_io_functions_t le_cookie_io_functions_t
typedef struct
{
ssize_t (*read) (void *, char *, size_t);
ssize_t (*write) (void *, char const *, size_t);
int (*seek) (void *, off64_t *, int);
int (*close) (void *);
- } cookie_io_functions_t;
+ }
+ cookie_io_functions_t;
#else
int (*write) (void *, char const *, int);
fpos_t (*seek) (void *, fpos_t, int);
int (*close) (void *);
- } cookie_io_functions_t;
+ }
+ cookie_io_functions_t;
#endif /* ! HAVE_FUNOPEN */
#endif /* ! HAVE_LIBIO_H */
int handle_cookie_io_fprintf (FILE *file, char const *format, ...);
int handle_cookie_io_putc (int c, FILE *file);
-/* FIXME: ttftool uses fclose fopencookie fprintf and putc only. if
- ALIAS_FILE_TO_FILECOOKIE, blondly redefine those functions
- to wrappers that check for and handle Memory_out_stream. */
+ /* FIXME: ttftool uses fclose fopencookie fprintf and putc only. if
+ ALIAS_FILE_TO_FILECOOKIE, blondly redefine those functions
+ to wrappers that check for and handle Memory_out_stream. */
#ifdef ALIAS_FILE_TO_FILECOOKIE
#define fclose handle_cookie_io_fclose
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef MEMORY_STREAM_HH
Offset complex_divide (Offset, Offset);
Offset complex_exp (Offset);
-
/*
-
-This is a mixture a 2D vector. Sometimes it can
-also be convenient to think of 2D vectors as complex numbers
-(ie. x + i y). The naming of some methods reflects that.
-
+ This is a mixture a 2D vector. Sometimes it can
+ also be convenient to think of 2D vectors as complex numbers
+ (ie. x + i y). The naming of some methods reflects that.
*/
-class Offset
+class Offset
{
public:
Real coordinate_a_[NO_AXES];
-
- Real &operator[] (Axis i)
+
+ Real &operator[] (Axis i)
{
return coordinate_a_[i];
}
{
return coordinate_a_[i];
}
-
- Offset& operator+= (Offset o)
+
+ Offset &operator+= (Offset o)
{
(*this)[X_AXIS] += o[X_AXIS];
(*this)[Y_AXIS] += o[Y_AXIS];
return *this;
}
- Offset operator - () const
+ Offset operator- () const
{
Offset o = *this;
-
- o[X_AXIS] = - o[X_AXIS];
- o[Y_AXIS] = - o[Y_AXIS];
+
+ o[X_AXIS] = -o[X_AXIS];
+ o[Y_AXIS] = -o[Y_AXIS];
return o;
}
- Offset& operator-= (Offset o)
+ Offset &operator-= (Offset o)
{
(*this)[X_AXIS] -= o[X_AXIS];
(*this)[Y_AXIS] -= o[Y_AXIS];
return *this;
}
-
- Offset &scale (Offset o)
+
+ Offset &scale (Offset o)
{
(*this)[X_AXIS] *= o[X_AXIS];
(*this)[Y_AXIS] *= o[Y_AXIS];
return *this;
}
- Offset &operator *= (Real a)
+ Offset &operator*= (Real a)
{
(*this)[X_AXIS] *= a;
(*this)[Y_AXIS] *= a;
return *this;
}
-
- Offset (Real ix , Real iy)
+
+ Offset (Real ix, Real iy)
{
coordinate_a_[X_AXIS] =ix;
- coordinate_a_[Y_AXIS] =iy;
+ coordinate_a_[Y_AXIS] =iy;
}
- Offset ()
+ Offset ()
{
coordinate_a_[X_AXIS] = coordinate_a_[Y_AXIS]= 0.0;
}
String to_string () const;
- Offset& mirror (Axis a)
+ Offset &mirror (Axis a)
{
- coordinate_a_[a] = - coordinate_a_[a];
+ coordinate_a_[a] = -coordinate_a_[a];
return *this;
}
-
+
Real arg () const;
Real length () const;
- Offset operator *= (Offset z2)
+ Offset operator*= (Offset z2)
{
*this = complex_multiply (*this, z2);
return *this;
inline
Real
-dot_product (Offset o1, Offset o2)
+dot_product (Offset o1, Offset o2)
{
return o1[X_AXIS] * o2[X_AXIS] + o1[Y_AXIS] * o2[Y_AXIS];
}
-
#endif /* OFFSET_HH */
-
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef PARRAY_HH
#define PARRAY_HH
#include "array.hh"
-
-
/**
- an array of pointers.
+ an array of pointers.
- TODO
- should init to 0.
- */
+ TODO
+ should init to 0.
+*/
template<class T>
class Link_array : private Array<void *>
{
- Link_array (Array<void*> v)
- :Array<void*> (v)
- {
- }
+ Link_array (Array<void *> v)
+ :Array<void *> (v)
+ {
+ }
public:
Link_array ()
- {}
+ {}
- static int default_compare (T *const& p1, T *const&p2)
+ static int default_compare (T *const &p1, T *const &p2)
{
/* can't do p1 -p2, since T might be an incomplete type */
if (p1 < p2)
- return -1 ;
+ return -1;
if (p2 < p1)
return 1;
return 0;
}
- Link_array (T * const *tp, int n)
- : Array<void*> ((void **)tp, n)
- {
- }
+ Link_array (T *const *tp, int n)
+ : Array<void *> ((void **)tp, n)
+ {
+ }
Link_array (Link_array<T> const &src)
- : Array<void*> (src)
- {
- }
+ : Array<void *> (src)
+ {
+ }
/// access element
- T *elem (int i) const
- {
- return elem_ref (i);
- }
+ T *elem (int i) const
+ {
+ return elem_ref (i);
+ }
T *&elem_ref (int i) const
- {
- return (T*&) Array<void*>::elem_ref (i);
- }
+ {
+ return (T *&) Array<void *>::elem_ref (i);
+ }
/// access element
- T* &operator[] (int i)
- {
- return (T*&) Array<void*>::elem_ref (i);
- }
+ T *&operator[] (int i)
+ {
+ return (T *&) Array<void *>::elem_ref (i);
+ }
/// access element
- T *const operator[] (int i) const
- {
- return (T *const) Array<void*>::elem (i);
- }
+ T *const operator[] (int i) const
+ {
+ return (T *const) Array<void *>::elem (i);
+ }
T *pop ()
- {
- return (T*) Array<void*>::pop ();
- }
+ {
+ return (T *) Array<void *>::pop ();
+ }
void insert (T *t, int i)
- {
- Array<void*>::insert (t, i);
- }
- void push (T* t)
- {
- Array<void*>::push (t);
- }
+ {
+ Array<void *>::insert (t, i);
+ }
+ void push (T *t)
+ {
+ Array<void *>::push (t);
+ }
/// return last entry
- T* top (int j=0) const
- {
- return (T*) Array<void*>::top (j);
- }
- T *& top (int i=0)
- {
- return (T*&) Array<void*>::top (i);
- }
- void substitute (T *old, T*new_p)
- {
- int i;
- while ((i = find_index (old)) >=0)
- if (new_p)
- elem_ref (i) =new_p;
- else
- del (i);
- }
- void unordered_substitute (T* old, T * new_p)
- {
- int i;
- while ((i = find_index (old)) >=0)
- if (new_p)
- elem_ref (i) =new_p;
- else {
+ T *top (int j = 0) const
+ {
+ return (T *) Array<void *>::top (j);
+ }
+ T *& top (int i = 0)
+ {
+ return (T *&) Array<void *>::top (i);
+ }
+ void substitute (T *old, T *new_p)
+ {
+ int i;
+ while ((i = find_index (old)) >=0)
+ if (new_p)
+ elem_ref (i) =new_p;
+ else
+ del (i);
+ }
+ void unordered_substitute (T *old, T *new_p)
+ {
+ int i;
+ while ((i = find_index (old)) >=0)
+ if (new_p)
+ elem_ref (i) =new_p;
+ else
+ {
unordered_del (i);
}
-
- }
- void default_sort () {
+
+ }
+ void default_sort ()
+ {
sort (default_compare);
}
// quicksort.
- void sort (int (*compare) (T *const&,T *const&),
+ void sort (int (*compare) (T *const &, T *const &),
int lower = -1, int upper = -1);
-
- void uniq () {
+
+ void uniq ()
+ {
Link_array<T> ls;
- for (int i=0; i < size (); i++)
- if (!i || elem (i-1) != elem (i))
- ls.push (elem (i));
+ for (int i = 0; i < size (); i++)
+ if (!i || elem (i - 1) != elem (i))
+ ls.push (elem (i));
*this = ls;
}
- Array<void*>::del;
- Array<void*>::unordered_del;
- Array<void*>::size;
- Array<void*>::clear;
- Array<void*>::set_size;
- Array<void*>::is_empty;
- Array<void*>::reverse;
- Array<void*>::tighten_maxsize;
+ Array<void *>::del;
+ Array<void *>::unordered_del;
+ Array<void *>::size;
+ Array<void *>::clear;
+ Array<void *>::set_size;
+ Array<void *>::is_empty;
+ Array<void *>::reverse;
+ Array<void *>::tighten_maxsize;
T *& boundary (int d, int i)
{
else
return elem_ref (i);
}
- T * boundary (int d, int i)const
+ T *boundary (int d, int i)const
{
assert (d);
if (d == 1)
return elem_ref (i);
}
-
T ** accesses () const
- {
- return (T**) Array<void*>::accesses ();
- }
- T * get (int i)
- {
- return (T*) Array<void*>::get (i);
- }
+ {
+ return (T **) Array<void *>::accesses ();
+ }
+ T *get (int i)
+ {
+ return (T *) Array<void *>::get (i);
+ }
Link_array<T>
- slice (int l,int u)
- {
- return Array<void*>::slice (l,u);
- }
+ slice (int l, int u)
+ {
+ return Array<void *>::slice (l, u);
+ }
void concat (Link_array<T> const &a2)
- {
- Array<void*>::concat (a2);
- }
- int find_index (T const * t) const {
- for (int i=0; i < size (); i++)
+ {
+ Array<void *>::concat (a2);
+ }
+ int find_index (T const *t) const
+ {
+ for (int i = 0; i < size (); i++)
if (elem (i) == t)
return i;
return -1;
}
T *find (T const *t) const
- {
- int i = find_index (t);
- if (i >= 0)
- return elem (i);
- else
- return 0;
- }
+ {
+ int i = find_index (t);
+ if (i >= 0)
+ return elem (i);
+ else
+ return 0;
+ }
};
-template<class T, class V>
+template < class T, class V>
Link_array<T>
-typecasts (Link_array<V> const &a, T * /* dummy */ )
+typecasts (Link_array<V> const &a, T * /* dummy */)
{
Link_array<T> ret;
- for (int i=a.size (); i-- ; )
- ret.push (dynamic_cast<T*> (a[i])); // ugh?
+ for (int i = a.size (); i--;)
+ ret.push (dynamic_cast<T *> (a[i])); // ugh?
return ret;
}
-
-
template<class T> inline void
-Link_array<T>::sort (int (*compare)(T *const&,T *const&), int lower, int upper)
+Link_array<T>::sort (int (*compare) (T *const &, T *const &), int lower, int upper)
{
- if (lower < 0)
+ if (lower < 0)
{
- lower = 0 ;
+ lower = 0;
upper = size () - 1;
}
if (lower >= upper)
return;
- swap (lower, (lower+upper)/2);
+ swap (lower, (lower + upper) / 2);
int last = lower;
for (int i= lower +1; i <= upper; i++)
if (compare (elem (i), elem (lower)) < 0)
- swap (++last,i);
+ swap (++last, i);
swap (lower, last);
- sort (compare, lower, last-1);
- sort (compare, last+1, upper);
+ sort (compare, lower, last - 1);
+ sort (compare, last + 1, upper);
}
template<class T>
void
junk_pointers (Link_array<T> &a)
{
- for (int i=0; i < a.size (); i++)
+ for (int i = 0; i < a.size (); i++)
{
delete a[i];
}
a.clear ();
}
-
-
/*
lookup with binsearch, return tokencode.
*/
template<class T>
int
-binsearch (Array<T> const &arr, T t, int (*compare) (T const&,T const&))
+binsearch (Array<T> const &arr, T t, int (*compare) (T const &, T const &))
{
int lo;
int hi;
/* binary search */
do
- {
+ {
cmp = (lo + hi) / 2;
result = compare (t, arr[cmp]);
if (result < 0)
- hi = cmp;
+ hi = cmp;
else
- lo = cmp;
+ lo = cmp;
}
while (hi - lo > 1);
if (!compare (t, arr[lo]))
return -1; /* not found */
}
-
template<class T>
int
binsearch_links (Link_array<T> const &arr, T *t,
- int (*compare) (T *const&,T *const&),
- int lo = 0, int hi = -1 )
+ int (*compare) (T *const &, T *const &),
+ int lo = 0, int hi = -1)
{
int cmp;
int result;
if (hi == 0)
return -1;
-
+
/* binary search */
do
- {
+ {
cmp = (lo + hi) / 2;
result = (*compare) (t, arr[cmp]);
if (result < 0)
- hi = cmp;
+ hi = cmp;
else
- lo = cmp;
+ lo = cmp;
}
while (hi - lo > 1);
if (!compare (t, arr[lo]))
return -1; /* not found */
}
-
template<class T>
void
binary_search_bounds (Link_array<T> const &table,
- T const *key, int (*compare) (T * const& , T *const &),
+ T const *key, int (*compare) (T *const &, T *const &),
int *lo,
int *hi)
{
/* binary search */
do
- {
+ {
cmp = (*lo + *hi) / 2;
- result = (*compare) ((T*) key, table[cmp]);
+ result = (*compare) ((T *) key, table[cmp]);
if (result < 0)
- *hi = cmp;
+ *hi = cmp;
else
- *lo = cmp;
+ *lo = cmp;
}
while (*hi - *lo > 1);
}
* (C) 1988, 1989 by Adobe Systems Incorporated. All rights reserved.
*
* This file may be freely copied and redistributed as long as:
- * 1) This entire notice continues to be included in the file,
+ * 1) This entire notice continues to be included in the file,
* 2) If the file has been modified in any way, a notice of such
* modification is conspicuously indicated.
*
* PostScript, Display PostScript, and Adobe are registered trademarks of
* Adobe Systems Incorporated.
- *
+ *
* ************************************************************************
* THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO CHANGE WITHOUT
* NOTICE, AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY ADOBE SYSTEMS
- * INCORPORATED. ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY OR
- * LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO WARRANTY OF ANY
- * KIND (EXPRESS, IMPLIED OR STATUTORY) WITH RESPECT TO THIS INFORMATION,
- * AND EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY,
+ * INCORPORATED. ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY OR
+ * LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO WARRANTY OF ANY
+ * KIND (EXPRESS, IMPLIED OR STATUTORY) WITH RESPECT TO THIS INFORMATION,
+ * AND EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
* ************************************************************************
*/
* Together these files provide the functionality to parse Adobe Font
* Metrics files and store the information in predefined data structures.
* It is intended to work with an application program that needs font metric
- * information. The program can be used as is by making a procedure call to
+ * information. The program can be used as is by making a procedure call to
* parse an AFM file and have the data stored, or an application developer
- * may wish to customize the code.
+ * may wish to customize the code.
*
- * This header file defines the data structures used as well as the key
+ * This header file defines the data structures used as well as the key
* strings that are currently recognized by this version of the AFM parser.
- * This program is based on the document "Adobe Font Metrics Files,
+ * This program is based on the document "Adobe Font Metrics Files,
* Specification Version 2.0".
*
* AFM files are separated into distinct sections of different data. Because
* of this, the parseAFM program can parse a specified file to only save
- * certain sections of information based on the application's needs. A record
+ * certain sections of information based on the application's needs. A record
* containing the requested information will be returned to the application.
- *
+ *
* AFM files are divided into five sections of data:
* 1) The Global Font Information
- * 2) The Character Metrics Information
+ * 2) The Character Metrics Information
* 3) The Track Kerning Data
* 4) The Pair-Wise Kerning Data
* 5) The Composite Character Data
* of what other sections are requested. In addition, in recognizing that
* many applications will want ONLY the x-width of characters and not all
* of the other character metrics information, there is a way to receive
- * only the width information so as not to pay the storage cost for the
- * unwanted data. An application should never request both the
- * "quick and dirty" char metrics (widths only) and the Character Metrics
- * Information since the Character Metrics Information will contain all
+ * only the width information so as not to pay the storage cost for the
+ * unwanted data. An application should never request both the
+ * "quick and dirty" char metrics (widths only) and the Character Metrics
+ * Information since the Character Metrics Information will contain all
* of the character widths as well.
- *
- * There is a procedure in parseAFM.c, called parseFile, that can be
+ *
+ * There is a procedure in parseAFM.c, called parseFile, that can be
* called from any application wishing to get information from the AFM File.
* This procedure expects 3 parameters: a vaild file descriptor, a pointer
- * to a (FontInfo *) variable (for which space will be allocated and then
+ * to a (FontInfo *) variable (for which space will be allocated and then
* will be filled in with the data requested), and a mask specifying
* which data from the AFM File should be saved in the FontInfo structure.
- *
+ *
* The flags that can be used to set the appropriate mask are defined below.
- * In addition, several commonly used masks have already been defined.
- *
+ * In addition, several commonly used masks have already been defined.
+ *
* History:
* original: DSM Thu Oct 20 17:39:59 PDT 1988
* modified: DSM Mon Jul 3 14:17:50 PDT 1989
#define BOOL int
#define FLAGS int
-
-
/* Possible return codes from the parseFile procedure.
- *
+ *
* ok means there were no problems parsing the file.
*
* parseError means that there was some kind of parsing error, but the
* parser went on. This could include problems like the count for any given
* section does not add up to how many entries there actually were, or
* there was a key that was not recognized. The return record may contain
- * vaild data or it may not.
+ * vaild data or it may not.
*
* earlyEOF means that an End of File was encountered before expected. This
* may mean that the AFM file had been truncated, or improperly formed.
- *
+ *
* storageProblem means that there were problems allocating storage for
* the data structures that would have contained the AFM data.
*/
#define AFM_earlyEOF -2
#define AFM_storageProblem -3
-
-
/************************* TYPES *********************************/
/* Below are all of the data structure definitions. These structures
- * try to map as closely as possible to grouping and naming of data
+ * try to map as closely as possible to grouping and naming of data
* in the AFM Files.
*/
-
-/* Bounding box definition. Used for the Font AFM_BBox as well as the
+/* Bounding box definition. Used for the Font AFM_BBox as well as the
* Character AFM_BBox.
*/
typedef struct
-{
- int llx; /* lower left x-position */
- int lly; /* lower left y-position */
- int urx; /* upper right x-position */
- int ury; /* upper right y-position */
-} AFM_BBox;
-
+{
+ int llx; /* lower left x-position */
+ int lly; /* lower left y-position */
+ int urx; /* upper right x-position */
+ int ury; /* upper right y-position */
+}
+ AFM_BBox;
/* Global Font information.
- * The key that each field is associated with is in comments. For an
+ * The key that each field is associated with is in comments. For an
* explanation about each key and its value please refer to the AFM
- * documentation (full title & version given above).
+ * documentation (full title & version given above).
*/
typedef struct
-{
- char *afmVersion; /* key: StartFontMetrics */
- char *fontName; /* key: FontName */
- char *fullName; /* key: FullName */
- char *familyName; /* key: FamilyName */
- char *weight; /* key: Weight */
- float italicAngle; /* key: ItalicAngle */
- BOOL isFixedPitch; /* key: IsFixedPitch */
- AFM_BBox fontBBox; /* key: FontBBox */
- int underlinePosition; /* key: UnderlinePosition */
- int underlineThickness; /* key: UnderlineThickness */
- char *version; /* key: Version */
- char *notice; /* key: Notice */
- char *encodingScheme; /* key: EncodingScheme */
- int capHeight; /* key: CapHeight */
- int xHeight; /* key: XHeight */
- int ascender; /* key: Ascender */
- int descender; /* key: Descender */
-} AFM_GlobalFontInfo;
-
+{
+ char *afmVersion; /* key: StartFontMetrics */
+ char *fontName; /* key: FontName */
+ char *fullName; /* key: FullName */
+ char *familyName; /* key: FamilyName */
+ char *weight; /* key: Weight */
+ float italicAngle; /* key: ItalicAngle */
+ BOOL isFixedPitch; /* key: IsFixedPitch */
+ AFM_BBox fontBBox; /* key: FontBBox */
+ int underlinePosition; /* key: UnderlinePosition */
+ int underlineThickness; /* key: UnderlineThickness */
+ char *version; /* key: Version */
+ char *notice; /* key: Notice */
+ char *encodingScheme; /* key: EncodingScheme */
+ int capHeight; /* key: CapHeight */
+ int xHeight; /* key: XHeight */
+ int ascender; /* key: Ascender */
+ int descender; /* key: Descender */
+}
+ AFM_GlobalFontInfo;
/* Ligature definition is a linked list since any character can have
* any number of ligatures.
*/
typedef struct _t_ligature
{
- char *succ, *lig;
- struct _t_ligature *next;
-} AFM_Ligature;
-
+ char *succ, *lig;
+ struct _t_ligature *next;
+}
+ AFM_Ligature;
-/* Character Metric Information. This structure is used only if ALL
+/* Character Metric Information. This structure is used only if ALL
* character metric information is requested. If only the character
* widths is requested, then only an array of the character x-widths
* is returned.
*
- * The key that each field is associated with is in comments. For an
- * explanation about each key and its value please refer to the
+ * The key that each field is associated with is in comments. For an
+ * explanation about each key and its value please refer to the
* Character Metrics section of the AFM documentation (full title
- * & version given above).
+ * & version given above).
*/
typedef struct
{
- int code, /* key: C */
- wx, /* key: WX */
- wy; /* together wx and wy are associated with key: W */
- char *name; /* key: N */
- AFM_BBox charBBox; /* key: B */
- AFM_Ligature *ligs; /* key: L (linked list; not a fixed number of Ls */
-} AFM_CharMetricInfo;
-
+ int code, /* key: C */
+ wx, /* key: WX */
+ wy; /* together wx and wy are associated with key: W */
+ char *name; /* key: N */
+ AFM_BBox charBBox; /* key: B */
+ AFM_Ligature *ligs; /* key: L (linked list; not a fixed number of Ls */
+}
+ AFM_CharMetricInfo;
/* Track kerning data structure.
- * The fields of this record are the five values associated with every
+ * The fields of this record are the five values associated with every
* TrackKern entry.
- *
- * For an explanation about each value please refer to the
+ *
+ * For an explanation about each value please refer to the
* Track Kerning section of the AFM documentation (full title
- * & version given above).
+ * & version given above).
*/
-typedef struct
+typedef struct
{
- int degree;
- float minPtSize,
- minKernAmt,
- maxPtSize,
- maxKernAmt;
-} AFM_TrackKernData;
-
+ int degree;
+ float minPtSize,
+ minKernAmt,
+ maxPtSize,
+ maxKernAmt;
+}
+ AFM_TrackKernData;
/* Pair Kerning data structure.
* The fields of this record are the four values associated with every
* KP entry. For KPX entries, the yamt will be zero.
*
- * For an explanation about each value please refer to the
+ * For an explanation about each value please refer to the
* Pair Kerning section of the AFM documentation (full title
- * & version given above).
+ * & version given above).
*/
-typedef struct
+typedef struct
{
- char *name1;
- char *name2;
- int xamt,
- yamt;
-} AFM_PairKernData;
-
+ char *name1;
+ char *name2;
+ int xamt,
+ yamt;
+}
+ AFM_PairKernData;
/* AFM_Pcc is a piece of a composite character. This is a sub structure of a
* AFM_CompCharData described below.
* These fields will be filled in with the values from the key AFM_Pcc.
- *
- * For an explanation about each key and its value please refer to the
+ *
+ * For an explanation about each key and its value please refer to the
* Composite Character section of the AFM documentation (full title
- * & version given above).
+ * & version given above).
*/
typedef struct
{
- char *AFM_PccName;
- int deltax,
- deltay;
-} AFM_Pcc;
+ char *AFM_PccName;
+ int deltax,
+ deltay;
+}
+ AFM_Pcc;
-
-/* Composite Character Information data structure.
+/* Composite Character Information data structure.
* The fields ccName and numOfPieces are filled with the values associated
* with the key CC. The field pieces points to an array (size = numOfPieces)
* of information about each of the parts of the composite character. That
* array is filled in with the values from the key AFM_Pcc.
- *
- * For an explanation about each key and its value please refer to the
+ *
+ * For an explanation about each key and its value please refer to the
* Composite Character section of the AFM documentation (full title
- * & version given above).
+ * & version given above).
*/
typedef struct
{
- char *ccName;
- int numOfPieces;
- AFM_Pcc *pieces;
-} AFM_CompCharData;
-
+ char *ccName;
+ int numOfPieces;
+ AFM_Pcc *pieces;
+}
+ AFM_CompCharData;
/* FontInfo
* Record type containing pointers to all of the other data
* parseFile function.
*/
typedef struct
-{
- AFM_GlobalFontInfo *gfi; /* ptr to a AFM_GlobalFontInfo record */
- int *cwi; /* ptr to 256 element array of just char widths */
- int numOfChars; /* number of entries in char metrics array */
- AFM_CharMetricInfo *cmi; /* ptr to char metrics array */
- int numOfTracks; /* number to entries in track kerning array */
- AFM_TrackKernData *tkd; /* ptr to track kerning array */
- int numOfPairs; /* number to entries in pair kerning array */
- AFM_PairKernData *pkd; /* ptr to pair kerning array */
- int numOfComps; /* number to entries in comp char array */
- AFM_CompCharData *ccd; /* ptr to comp char array */
-} AFM_Font_info;
-
+{
+ AFM_GlobalFontInfo *gfi; /* ptr to a AFM_GlobalFontInfo record */
+ int *cwi; /* ptr to 256 element array of just char widths */
+ int numOfChars; /* number of entries in char metrics array */
+ AFM_CharMetricInfo *cmi; /* ptr to char metrics array */
+ int numOfTracks; /* number to entries in track kerning array */
+ AFM_TrackKernData *tkd; /* ptr to track kerning array */
+ int numOfPairs; /* number to entries in pair kerning array */
+ AFM_PairKernData *pkd; /* ptr to pair kerning array */
+ int numOfComps; /* number to entries in comp char array */
+ AFM_CompCharData *ccd; /* ptr to comp char array */
+}
+ AFM_Font_info;
/************************* PROCEDURES ****************************/
*
* "fp" should be a valid file pointer to an AFM file.
*
- * "fi" is a pointer to a pointer to a FontInfo record sturcture
+ * "fi" is a pointer to a pointer to a FontInfo record sturcture
* (defined above). Storage for the FontInfo structure will be
* allocated in parseFile and the structure will be filled in
* with the requested data from the AFM File.
int degree ()const;
/// coefficients
- Array<Real> coefs_;
+ Array<Real> coefs_;
// leading coef
Real &lc ();
// leading coef
Real lc () const;
- void print () const ;
- Real eval (Real) const ;
- void print_sols (Array<Real>) const ;
- void check_sols (Array<Real>) const ;
+ void print () const;
+ Real eval (Real) const;
+ void print_sols (Array<Real>) const;
+ void check_sols (Array<Real>) const;
void check_sol (Real x) const;
- static Polynomial multiply (const Polynomial & p1, const Polynomial & p2);
- static Polynomial power (int exponent, const Polynomial & src);
+ static Polynomial multiply (const Polynomial &p1, const Polynomial &p2);
+ static Polynomial power (int exponent, const Polynomial &src);
/// chop low coefficients
void clean ();
/// eliminate #x# close to zero
void real_clean ();
void scalarmultiply (Real fact);
- void operator *= (Real f) { scalarmultiply (f); }
- void operator /= (Real f) { scalarmultiply (1/f); }
- void operator += (Polynomial const &p2);
- void operator *= (Polynomial const &p2);
- void operator -= (Polynomial const &p2);
+ void operator*= (Real f) { scalarmultiply (f); }
+ void operator/= (Real f) { scalarmultiply (1 / f); }
+ void operator+= (Polynomial const &p2);
+ void operator*= (Polynomial const &p2);
+ void operator-= (Polynomial const &p2);
Polynomial (Real a, Real b =0.0);
Polynomial (){}
- void set_negate (const Polynomial & src);
-
+ void set_negate (const Polynomial &src);
+
/// take the derivative
void differentiate ();
int set_mod (const Polynomial &u, const Polynomial &v);
Array<Real> solve () const;
};
-
-IMPLEMENT_ARITHMETIC_OPERATOR (Polynomial, - );
-IMPLEMENT_ARITHMETIC_OPERATOR (Polynomial, + );
-IMPLEMENT_ARITHMETIC_OPERATOR (Polynomial, * );
+IMPLEMENT_ARITHMETIC_OPERATOR (Polynomial, -);
+IMPLEMENT_ARITHMETIC_OPERATOR (Polynomial, +);
+IMPLEMENT_ARITHMETIC_OPERATOR (Polynomial, *);
inline Polynomial
-operator * (Polynomial p, Real a)
+operator* (Polynomial p, Real a)
{
p *=a;
return p;
}
inline Polynomial
-operator * (Real a,Polynomial p)
+operator* (Real a, Polynomial p)
{
p *=a;
return p;
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef PQUEUE_HH
#define PQUEUE_HH
#include "array.hh"
-
-template<class K, class T>
+template < class K, class T>
struct PQueue_ent
{
- T val;
- K key;
+ T val;
+ K key;
};
-template<class K, class T>
-int compare (PQueue_ent<K,T> const &e1 , PQueue_ent<K,T> const &e2) {
- return compare (e1.key , e2.key);
+template < class K, class T>
+int compare (PQueue_ent < K, T> const &e1, PQueue_ent < K, T> const &e2)
+{
+ return compare (e1.key, e2.key);
}
/**
- Priority queue using a (variable size) in-situ heap.
+ Priority queue using a (variable size) in-situ heap.
- Hungarian postfix pq
-
- TODO: add increase/decrease operations,
- add max () operation
- */
+ Hungarian postfix pq
+
+ TODO: add increase/decrease operations,
+ add max () operation
+*/
template<class T>
-class PQueue {
- Array<T> heap_array_;
- T &elt (int i) {
- return heap_array_[i-1];
- }
- T const&elt (int i) const {
- return heap_array_[i-1];
- }
+class PQueue
+{
+ Array<T> heap_array_;
+ T &elt (int i)
+ {
+ return heap_array_[i - 1];
+ }
+ T const &elt (int i) const
+ {
+ return heap_array_[i - 1];
+ }
public:
- /** acces an heap element. Careful with this, as changing the
+ /** acces an heap element. Careful with this, as changing the
priority might fuck up the invariants
@param 1 <= i < size () */
- T& operator[] (int i) { return heap_array_[i]; }
- T operator[] (int i) const { return heap_array_[i]; }
- void OK () const
- {
+ T &operator[] (int i) { return heap_array_[i]; }
+ T operator[] (int i) const { return heap_array_[i]; }
+ void OK () const
+ {
#ifndef NDEBUG
- for (int i =2; i <= size (); i++)
- assert (compare (elt (i/2), elt (i)) <= 0);
+ for (int i =2; i <= size (); i++)
+ assert (compare (elt (i / 2), elt (i)) <= 0);
#endif
- }
- T front () const { return elt (1); }
- int size () const { return heap_array_.size (); }
- void insert (T v) {
- heap_array_.push (v);
- int i = heap_array_.size ();
- int j = i / 2 ;
- while (j) {
- if (compare (elt (j), v) > 0) {
- elt (i) = elt (j);
- i = j;
- j = i/2;
- } else {
- break;
- }
- }
- elt (i) = v;
- OK ();
- }
- T max () const {
- //int first_leaf_i = size ();
- T max_t;
- return max_t;
- }
- void delmin () {
- assert (size ());
- T last = heap_array_.top ();
-
- int mini=2;
- int lasti=1;
+ }
+ T front () const { return elt (1); }
+ int size () const { return heap_array_.size (); }
+ void insert (T v)
+ {
+ heap_array_.push (v);
+ int i = heap_array_.size ();
+ int j = i / 2;
+ while (j)
+ {
+ if (compare (elt (j), v) > 0)
+ {
+ elt (i) = elt (j);
+ i = j;
+ j = i / 2;
+ }
+ else
- while (mini < size ()) {
- if (compare (elt (mini + 1), elt (mini)) <0)
- mini++;
- if (compare (last,elt (mini)) < 0)
- break;
- elt (lasti) = elt (mini);
- lasti = mini;
- mini *= 2;
- }
- elt (lasti) = last;
- heap_array_.pop ();
- OK ();
- }
- T get () {
- T t = front ();
- delmin ();
- return t;
- }
-};
+ {
+ break;
+ }
+ }
+ elt (i) = v;
+ OK ();
+ }
+ T max () const
+ {
+ //int first_leaf_i = size ();
+ T max_t;
+ return max_t;
+ }
+ void delmin ()
+ {
+ assert (size ());
+ T last = heap_array_.top ();
+ int mini = 2;
+ int lasti = 1;
+
+ while (mini < size ())
+ {
+ if (compare (elt (mini + 1), elt (mini)) <0)
+ mini++;
+ if (compare (last, elt (mini)) < 0)
+ break;
+ elt (lasti) = elt (mini);
+ lasti = mini;
+ mini *= 2;
+ }
+ elt (lasti) = last;
+ heap_array_.pop ();
+ OK ();
+ }
+ T get ()
+ {
+ T t = front ();
+ delmin ();
+ return t;
+ }
+};
#endif // PQUEUE_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef RATIONAL_HH
#define RATIONAL_HH
/**
Rational numbers. Included is support for + and - infinity.
- */
-class Rational {
+*/
+class Rational
+{
/**
Sign of rational.
-2, .. 2
-2,2 is - and + infinity.
-1,1 is negative and positive.
0 if *this is zero.
- */
+ */
int sign_;
unsigned int num_, den_;
void normalise ();
void invert ();
int numerator () const { return sign_ * num_; }
int denominator () const { return den_; }
- int num () const { return numerator(); }
- int den () const { return denominator(); }
+ int num () const { return numerator (); }
+ int den () const { return denominator (); }
Rational trunc_rat () const;
Rational div_rat (Rational) const;
// operator bool () const;
int to_int () const;
operator double () const;
- Rational operator - () const;
+ Rational operator- () const;
/**
- Initialize to 0.
- */
+ Initialize to 0.
+ */
Rational ();
Rational (int);
Rational (int, int);
Rational (double);
- Rational (Rational const&r) { copy (r);}
- Rational &operator = (Rational const &r) {
+ Rational (Rational const &r) { copy (r);}
+ Rational &operator= (Rational const &r)
+ {
copy (r); return *this;
}
- Rational &operator *= (Rational);
- Rational &operator /= (Rational);
- Rational &operator += (Rational);
- Rational &operator -= (Rational);
- Rational &operator %= (Rational);
- static int compare (Rational const&, Rational const&);
+ Rational &operator*= (Rational);
+ Rational &operator/= (Rational);
+ Rational &operator+= (Rational);
+ Rational &operator-= (Rational);
+ Rational &operator%= (Rational);
+ static int compare (Rational const &, Rational const &);
int sign () const;
String to_string () const;
};
-IMPLEMENT_ARITHMETIC_OPERATOR (Rational, / );
-IMPLEMENT_ARITHMETIC_OPERATOR (Rational, + );
-IMPLEMENT_ARITHMETIC_OPERATOR (Rational, * );
-IMPLEMENT_ARITHMETIC_OPERATOR (Rational, - );
-IMPLEMENT_ARITHMETIC_OPERATOR (Rational, % );
+IMPLEMENT_ARITHMETIC_OPERATOR (Rational, /);
+IMPLEMENT_ARITHMETIC_OPERATOR (Rational, +);
+IMPLEMENT_ARITHMETIC_OPERATOR (Rational, *);
+IMPLEMENT_ARITHMETIC_OPERATOR (Rational, -);
+IMPLEMENT_ARITHMETIC_OPERATOR (Rational, %);
-INSTANTIATE_COMPARE (Rational const&, Rational::compare);
+INSTANTIATE_COMPARE (Rational const &, Rational::compare);
-int compare (Rational const&,Rational const&);
+int compare (Rational const &, Rational const &);
int sign (Rational r);
inline void
-Rational::copy (Rational const&r)
+Rational::copy (Rational const &r)
{
sign_ = r.sign_;
num_ = r.num_;
#if 0
ostream &
-operator << (ostream &, Rational);
+operator<< (ostream &, Rational);
#endif
const Rational infinity_rat = INT_MAX;
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef REAL_HH
#define REAL_HH
-
#include <climits>
typedef double Real;
return x*x;
}
-
template<class T> inline T min (T x, T y)
{
return x <? y;
}
inline Real
-distance (Real x,Real y)
+distance (Real x, Real y)
{
- return abs (x-y);
+ return abs (x - y);
}
#endif
/*
PROJECT: FlowerSoft C++ library
FILE : string-convert.hh
-
*/
#ifndef STRING_CONVERT_HH
#include "string.hh"
-
/** The functor String_convert handles all conversions to/from String
- (some time, anyway). The class is quite empty from data view. */
-class String_convert {
- static int hex2bin (String hex_string, String& bin_string_r);
+ (some time, anyway). The class is quite empty from data view. */
+class String_convert
+{
+ static int hex2bin (String hex_string, String &bin_string_r);
static int hex2nibble (Byte byte);
static Byte nibble2hex_byte (Byte byte);
public:
static String char_string (char c, int n);
static int dec2int (String dec_string);
static double dec2double (String dec_string);
- static String double_string (double f, char const* fmt=0);
- static String form_string (char const* format, ...);
- static String vform_string (char const* format, va_list args);
+ static String double_string (double f, char const *fmt = 0);
+ static String form_string (char const *format, ...);
+ static String vform_string (char const *format, va_list args);
static int hex2int (String str);
static unsigned hex2unsigned (String str);
static String hex2bin (String str);
- static String int_string (int i, char const *fmt=0 );
+ static String int_string (int i, char const *fmt = 0);
static String long_string (long);
static String int2hex (int i, int length_i, char ch);
static String unsigned2hex (unsigned u, int length_i, char ch);
static String pointer_string (void const *);
static String precision_string (double x, int n);
static Array<String> split (String str, char c);
- static String i64_string (I64, char const * fmt = 0);
+ static String i64_string (I64, char const *fmt = 0);
};
#endif // __STRING_CONVERT_HH //
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef STRINGDATA_HH
#define STRINGDATA_HH
/**Internal String struct.
the data itself. Handles simple tasks (resizing, resetting)
- */
-class String_data {
- // GNU malloc: storage overhead is 8 bytes anyway.
-
-friend class String_handle;
- int maxlen; // maxlen is arraysize-1
-
- int length_;
- Byte* data_byte_;
- int ref_count_;
-
- /// init to ""
- String_data ();
-
- /// init from src. Conservative allocation.
- String_data (String_data const &src);
-
- ~String_data ();
-
- /** POST: maxlen >= j.
- @param j, maximum stringlength_.
+*/
+class String_data
+{
+ // GNU malloc: storage overhead is 8 bytes anyway.
+
+ friend class String_handle;
+ int maxlen; // maxlen is arraysize-1
+
+ int length_;
+ Byte *data_byte_;
+ int ref_count_;
+
+ /// init to ""
+ String_data ();
+
+ /// init from src. Conservative allocation.
+ String_data (String_data const &src);
+
+ ~String_data ();
+
+ /** POST: maxlen >= j.
+ @param j, maximum stringlength_.
contents thrown away.
- */
- void setmax (int j);
-
- /** POST: maxlen >= j.
+ */
+ void setmax (int j);
+
+ /** POST: maxlen >= j.
@param j, maximum stringlength_.
contents are kept if it grows.
- */
- void remax (int j);
+ */
+ void remax (int j);
+
+ /// check if writeable.
+ void OKW ();
- /// check if writeable.
- void OKW ();
+ /// check state.
+ void OK ();
- /// check state.
- void OK ();
+ /// reduce memory usage.
+ void tighten ();
- /// reduce memory usage.
- void tighten ();
+ // assignment.
+ void set (Byte const *byte, int length_i);
- // assignment.
- void set (Byte const* byte, int length_i);
+ void set (char const *str0);
- void set (char const* str0);
-
- /// concatenation.
- void append (Byte const* byte, int length_i);
+ /// concatenation.
+ void append (Byte const *byte, int length_i);
- void operator += (char const* str0);
+ void operator+= (char const *str0);
- char const* to_str0 () const;
+ char const *to_str0 () const;
- char* get_str0 ();
+ char *get_str0 ();
- Byte const* to_bytes () const;
+ Byte const *to_bytes () const;
- // idem, non const
- Byte* get_bytes ();
+ // idem, non const
+ Byte *get_bytes ();
- void trunc (int j);
+ void trunc (int j);
- /** access element. not really safe. Can alter length_ without
+ /** access element. not really safe. Can alter length_ without
#String_data# knowing it. */
- Byte &operator [] (int j);
- Byte operator [] (int j) const;
- bool is_binary_bo () const;
+ Byte &operator[] (int j);
+ Byte operator[] (int j) const;
+ bool is_binary_bo () const;
};
-
-
#ifdef STRING_UTILS_INLINED
#ifndef INLINE
#define INLINE inline
#endif
-
#endif // STRING_DATA_HH
/* -*-C++-*-
- String_data.inl -- implement String_data
+ String_data.inl -- implement String_data
- source file of Flower lib
+ source file of Flower lib
- (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#ifndef STRINGDATA_INL
#include <memory.h>
#include "string-data.hh"
-const int INITIALMAX=8;
+const int INITIALMAX = 8;
#include <sys/types.h>
-INLINE void
-String_data::OKW ()
+INLINE void
+String_data::OKW ()
{
assert (ref_count_ == 1);
}
-INLINE void
-String_data::OK ()
+INLINE void
+String_data::OK ()
{
assert (maxlen >= length_);
assert (bool (data_byte_));
assert (ref_count_ >= 1);
}
-
INLINE
-String_data::String_data ()
+String_data::String_data ()
{
- ref_count_=0;
+ ref_count_ = 0;
maxlen = INITIALMAX;
data_byte_ = new Byte[maxlen + 1];
data_byte_[0] = 0;
}
INLINE
-String_data::String_data (String_data const &src)
+String_data::String_data (String_data const &src)
{
- ref_count_=0;
- maxlen = length_ = src.length_;
- data_byte_ = new Byte[maxlen+1]; // should calc GNU 8byte overhead.
- memcpy (data_byte_, src.data_byte_, length_ + 1);
+ ref_count_ = 0;
+ maxlen = length_ = src.length_;
+ data_byte_ = new Byte[maxlen + 1]; // should calc GNU 8byte overhead.
+ memcpy (data_byte_, src.data_byte_, length_ + 1);
}
INLINE
-String_data::~String_data ()
+String_data::~String_data ()
{
assert (ref_count_ == 0);
delete[] data_byte_;
}
-INLINE void
-String_data::setmax (int j)
-{
+INLINE void
+String_data::setmax (int j)
+{
OKW ();
- if (j > maxlen)
+ if (j > maxlen)
{
delete[] data_byte_;
maxlen = j;
data_byte_ = new Byte[maxlen + 1];
-
+
data_byte_[0] = 0;
length_ = 0;
}
}
-/* this is all quite hairy:
- update of length_
- update of maxlen
- alloc of buffer
- copying of buffer
- needs blondification:
- split tasks
- define change authority
+/* this is all quite hairy:
+ update of length_
+ update of maxlen
+ alloc of buffer
+ copying of buffer
+ needs blondification:
+ split tasks
+ define change authority
*/
-INLINE void
-String_data::remax (int j)
+INLINE void
+String_data::remax (int j)
{
OKW ();
- if (j > maxlen)
+ if (j > maxlen)
{
- Byte *p = new Byte[j + 1];
- memcpy (p, data_byte_, (maxlen <? length_) + 1 );
+ Byte *p = new Byte[j + 1];
+ memcpy (p, data_byte_, (maxlen <? length_) + 1);
maxlen = j;
delete[] data_byte_;
data_byte_ = p;
}
}
-INLINE void
-String_data::tighten ()
+INLINE void
+String_data::tighten ()
{ // should be dec'd const
maxlen = length_;
- Byte *p = new Byte[maxlen + 1];
- memcpy (p, data_byte_, length_ + 1);
+ Byte *p = new Byte[maxlen + 1];
+ memcpy (p, data_byte_, length_ + 1);
delete[] data_byte_;
- data_byte_ = p;
+ data_byte_ = p;
}
// assignment.
-INLINE void
-String_data::set (Byte const* byte, int length_i)
+INLINE void
+String_data::set (Byte const *byte, int length_i)
{
OKW ();
assert (byte && byte != data_byte_);
length_ = length_i;
- remax (length_); // copies too
+ remax (length_); // copies too
memcpy (data_byte_, byte, length_);
data_byte_[ length_ ] = 0;
}
INLINE
-void
-String_data::set (char const* str0)
+void
+String_data::set (char const *str0)
{
- set ((Byte const*)str0, strlen (str0) );
+ set ((Byte const *)str0, strlen (str0));
}
-
/// concatenation.
-INLINE void
-String_data::append (Byte const* byte, int length_i)
+INLINE void
+String_data::append (Byte const *byte, int length_i)
{
OK ();
OKW ();
int old_i = length_;
-
+
length_ += length_i;
remax (length_);
- memcpy (data_byte_ + old_i, byte, length_i);
+ memcpy (data_byte_ + old_i, byte, length_i);
data_byte_[ length_ ] = 0;
}
INLINE
-void
-String_data::operator += (char const* str0)
+void
+String_data::operator+= (char const *str0)
{
- append ((Byte const*)str0, strlen (str0) );
+ append ((Byte const *)str0, strlen (str0));
}
-
-
INLINE
-char const*
+char const *
String_data::to_str0 () const
{
- return (char const*)data_byte_;
+ return (char const *)data_byte_;
}
-INLINE char*
-String_data::get_str0 ()
-{
- return (char*)data_byte_;
+INLINE char *
+String_data::get_str0 ()
+{
+ return (char *)data_byte_;
}
-INLINE Byte const*
-String_data::to_bytes () const
-{
- return data_byte_;
+INLINE Byte const *
+String_data::to_bytes () const
+{
+ return data_byte_;
}
-INLINE Byte*
-String_data::get_bytes ()
+INLINE Byte *
+String_data::get_bytes ()
{
OKW ();
return data_byte_;
}
INLINE
-void
-String_data::trunc (int j)
+void
+String_data::trunc (int j)
{
- OKW ();
+ OKW ();
assert (j >= 0 && j <= length_);
data_byte_[j] = 0;
length_ = j;
String_data::is_binary_bo () const
{
// return !memchr (data_byte_, length_, 0);
- return ((int)strlen ((char const*)data_byte_) != length_ );
+ return ((int)strlen ((char const *)data_byte_) != length_);
}
-INLINE Byte&
-String_data::operator [] (int j)
+INLINE Byte &
+String_data::operator[] (int j)
{
assert (j >= 0 && j <= length_);
- return data_byte_[j] ;
+ return data_byte_[j];
}
-INLINE Byte
-String_data::operator [] (int j) const
+INLINE Byte
+String_data::operator[] (int j) const
{
assert (j >= 0 && j <= length_);
- return data_byte_[j];
+ return data_byte_[j];
}
-
-
#endif // __STRING_UTIL_CC //
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef STRINGHANDLE_HH
#define STRINGHANDLE_HH
#include "flower-proto.hh"
-
/**
- Reference counting for strings.
-
+ Reference counting for strings.
+
handles ref. counting, and provides a very thin interface using
Byte *
+*/
+class String_handle
+{
+ String_data *data;
- */
-class String_handle {
- String_data* data;
-
/// decrease ref count. Named kind of like a Tanenbaum semafore
void down ();
void up (String_data *d);
-
- /** make sure data has only one reference.
+
+ /** make sure data has only one reference.
POST: data->ref_count_ == 1
*/
void copy ();
-
+
public:
String_handle ();
~String_handle ();
- String_handle (String_handle const & src);
+ String_handle (String_handle const &src);
- Byte const* to_bytes () const;
- char const* to_str0 () const;
- Byte* get_bytes ();
- char* get_str0 ();
+ Byte const *to_bytes () const;
+ char const *to_str0 () const;
+ Byte *get_bytes ();
+ char *get_str0 ();
bool is_binary_bo () const;
- void operator = (String_handle const &src);
- void operator += (char const *s);
+ void operator= (String_handle const &src);
+ void operator+= (char const *s);
Byte operator[] (int j) const;
/** Access elements. WARNING: NOT SAFE
don't use this for loops. Use to_bytes ()
*/
Byte &operator[] (int j);
- void append (Byte const* byte, int length_i);
- void set (Byte const* byte, int length_i);
- void operator = (char const *p);
+ void append (Byte const *byte, int length_i);
+ void set (Byte const *byte, int length_i);
+ void operator= (char const *p);
void trunc (int j);
int length () const;
};
/* we should be resetting INLINE. oh well. */
#endif
-
#endif // STRINGHANDLE_HH
/* -*-c++-*-
-
- stringhandle.inl -- implement String_handle
- source file of Flower lib
+stringhandle.inl -- implement String_handle
- (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+source file of Flower lib
+
+(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#ifndef STRINGHANDLE_INL
#include "string-data.hh"
#include "string-handle.hh"
-INLINE void
-String_handle::down ()
-{
+INLINE void
+String_handle::down ()
+{
if (! (--data->ref_count_))
delete data;
- data = 0;
+ data = 0;
}
/*
THIS does not have to be initialized.
*/
-INLINE void
-String_handle::up (String_data *d)
-{
- data=d;
- data->ref_count_ ++;
+INLINE void
+String_handle::up (String_data *d)
+{
+ data = d;
+ data->ref_count_++;
}
-INLINE void
-String_handle::copy ()
+INLINE void
+String_handle::copy ()
{
if (data->ref_count_ !=1)
{
}
INLINE
-String_handle::String_handle ()
+String_handle::String_handle ()
{
up (new String_data);
}
INLINE
-String_handle::~String_handle ()
-{
+String_handle::~String_handle ()
+{
down ();
-}
+}
INLINE
-String_handle::String_handle (String_handle const & src)
-{
+String_handle::String_handle (String_handle const &src)
+{
up (src.data);
}
-INLINE Byte*
-String_handle::get_bytes ()
+INLINE Byte *
+String_handle::get_bytes ()
{
copy ();
return data->get_bytes ();
}
-INLINE char*
-String_handle::get_str0 ()
+INLINE char *
+String_handle::get_str0 ()
{
copy ();
- return (char*)data->get_bytes ();
+ return (char *)data->get_bytes ();
}
-INLINE Byte
-const* String_handle::to_bytes () const
+INLINE Byte
+const *String_handle::to_bytes () const
{
return data->to_bytes ();
}
-INLINE char const*
-String_handle::to_str0 () const
+INLINE char const *
+String_handle::to_str0 () const
{
- return (char const*)data->to_bytes ();
+ return (char const *)data->to_bytes ();
}
-INLINE void
-String_handle::operator = (String_handle const &src)
+INLINE void
+String_handle::operator= (String_handle const &src)
{
if (this == &src)
return;
up (src.data);
}
-INLINE void
-String_handle::operator += (char const *s)
-{
+INLINE void
+String_handle::operator+= (char const *s)
+{
copy ();
*data += s;
-}
-
+}
-INLINE Byte
-String_handle::operator[] (int j) const
-{
- return (*data)[j];
+INLINE Byte
+String_handle::operator[] (int j) const
+{
+ return (*data)[j];
}
// !NOT SAFE!
// don't use this for loops. Use to_bytes ()
INLINE Byte &
-String_handle::operator[] (int j)
+String_handle::operator[] (int j)
{
copy (); // hmm. Not efficient
return data->get_bytes ()[j];
}
-INLINE void
-String_handle::append (Byte const* byte, int length_i)
+INLINE void
+String_handle::append (Byte const *byte, int length_i)
{
copy ();
data->append (byte, length_i);
}
-
-INLINE void
-String_handle::set (Byte const* byte, int length_i)
+
+INLINE void
+String_handle::set (Byte const *byte, int length_i)
{
copy ();
data->set (byte, length_i);
}
-
-INLINE void
-String_handle::operator = (char const *p)
+
+INLINE void
+String_handle::operator= (char const *p)
{
copy ();
data->set (p);
}
-
-INLINE void
-String_handle::trunc (int j)
+
+INLINE void
+String_handle::trunc (int j)
{
- copy (); data->trunc (j);
+ copy (); data->trunc (j);
}
-INLINE int
-String_handle::length () const
-{
- return data->length_;
+INLINE int
+String_handle::length () const
+{
+ return data->length_;
}
INLINE bool
-String_handle::is_binary_bo () const {
+String_handle::is_binary_bo () const
+{
return data->is_binary_bo ();
}
/*
-
FILE : string.hh -- declare String
-
+
Rehacked by HWN 3/nov/95
removed String & 's
introduced Class String_handle
- */
+*/
#ifndef STRING_HH
#define STRING_HH
-
// too darn slow with gcc3
#ifdef STREAM_SUPPORT
-#if ( __GNUC__ > 2 )
+#if (__GNUC__ > 2)
#include <iostream>
#else
class ostream;
#include "arithmetic-operator.hh"
#include "string-handle.hh"
-/**
-
- Intuitive string class. provides
+/**
+
+Intuitive string class. provides
\begin{itemize}
\item
- ref counting through #String_handle#
+ref counting through #String_handle#
\item
- conversion from bool, int, double, char* , char.
+conversion from bool, int, double, char* , char.
\item
- to be moved to String_convert:
- conversion to int, upcase, downcase
+to be moved to String_convert:
+conversion to int, upcase, downcase
\item
- printable.
+printable.
\item
- indexing (index_i, index_any_i, last_index_i)
+indexing (index_i, index_any_i, last_index_i)
\item
- cutting (left_string, right_string, mid_string)
+cutting (left_string, right_string, mid_string)
\item
- concat (+=, +)
+concat (+=, +)
\item
- signed comparison (<, >, ==, etc)
+signed comparison (<, >, ==, etc)
\item
- No operator[] is provided, since this would be enormously slow. If needed,
- convert to char const* .
+No operator[] is provided, since this would be enormously slow. If needed,
+convert to char const* .
\end{itemize}
-
*/
class String
{
protected:
- String_handle strh_;
+ String_handle strh_;
bool null_terminated ();
-
+
public:
/** init to empty string. This is needed because other
- constructors are provided.*/
+ constructors are provided.*/
String ();
/// String s = "abc";
- String (char const* source);
- String (Byte const* byte, int length_i);
+ String (char const *source);
+ String (Byte const *byte, int length_i);
/// return "new"-ed copy of contents
- Byte* get_copy_byte () const;
- char* get_copy_str0 () const;
+ Byte *get_copy_byte () const;
+ char *get_copy_str0 () const;
- char const* to_str0 () const;
- Byte const* to_bytes () const;
+ char const *to_str0 () const;
+ Byte const *to_bytes () const;
char *get_str0 ();
Byte *get_bytes ();
- String &operator = (String const & source);
+ String &operator= (String const &source);
/// concatenate s
- void operator += (char const* s) { strh_ += s; }
- void operator += (String s);
+ void operator+= (char const *s) { strh_ += s; }
+ void operator+= (String s);
bool is_empty () const;
void prepend (String);
/**
- Return a char. UNSAFE because it may change strlen () result
- */
- char &operator [] (int n);
- char operator [] (int n) const;
+ Return a char. UNSAFE because it may change strlen () result
+ */
+ char &operator[] (int n);
+ char operator[] (int n) const;
/// return n leftmost chars
String left_string (int n) const;
String nomid_string (int index_i, int n) const;
/// signed comparison, analogous to memcmp;
- static int compare (String const & s1,const String& s2);
-
+ static int compare (String const &s1, const String &s2);
+
/// index of rightmost c
int index_last (char c) const;
/// index of rightmost element of string (???)
- int index_last (char const* string) const;
+ int index_last (char const *string) const;
int index (char c) const;
/// index of leftmost occurance of STRING
int index (String) const;
-
int index_any (String) const;
void to_upper ();
/// provide Stream output
void print_on (ostream& os) const;
#endif
-
+
/// the length of the string
int length () const;
};
/*
- better to clutter global namespace, than suffer *ugh, ugh, ugh*
- implicit conversions.
+ better to clutter global namespace, than suffer *ugh, ugh, ugh*
+ implicit conversions.
- it might be cool to have no type-checking at all in a language,
- but once there is, having this silently circumvented is a nightmare.
+ it might be cool to have no type-checking at all in a language,
+ but once there is, having this silently circumvented is a nightmare.
- whenever implicit conversions seem necessary (e.g. operator << ()),
- use Scalar as the generic type iso String.
- */
+ whenever implicit conversions seem necessary (e.g. operator << ()),
+ use Scalar as the generic type iso String.
+*/
/// for completeness (=handy)
inline String to_string (String s) { return s; }
/// "cccc"
String to_string (char c, int n = 1);
-String to_string (int i, char const* format = 0);
-String to_string (double f, char const* format = 0);
-String to_string (long b);
+String to_string (int i, char const *format = 0);
+String to_string (double f, char const *format = 0);
+String to_string (long b);
String to_string (bool b);
-String to_string (char const* format, ... );
+String to_string (char const *format, ...);
/*
technically incorrect, but lets keep it here: this is a
catch all place for this stuff.
- */
-
-#include "international.hh"
+*/
+#include "international.hh"
#include "compare.hh"
INSTANTIATE_COMPARE (String const &, String::compare);
/* we should be resetting INLINE. oh well. */
#endif
-
// because char const* also has an operator ==, this is for safety:
-inline bool operator== (String s1, char const* s2)
+inline bool operator== (String s1, char const *s2)
{
return s1 == String (s2);
}
-inline bool operator== (char const* s1, String s2)
+inline bool operator== (char const *s1, String s2)
{
- return String (s1)==s2;
+ return String (s1) == s2;
}
-inline bool operator!= (String s1, char const* s2 ) {
- return s1!=String (s2);
+inline bool operator!= (String s1, char const *s2)
+{
+ return s1 != String (s2);
}
-inline bool operator!= (char const* s1,String s2) {
+inline bool operator!= (char const *s1, String s2)
+{
return String (s2) !=s1;
}
IMPLEMENT_ARITHMETIC_OPERATOR (String, +);
#ifdef STREAM_SUPPORT
-ostream &operator << (ostream& os, String d);
+ostream &operator<< (ostream& os, String d);
#endif
#endif
-/*
+/*
string.icc -- implement String inlines
-
+
source file of the Flower Library
-
+
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef STRING_ICC
#define STRING_ICC
-
-INLINE
+INLINE
char &
-String::operator [] (int n)
+String::operator[] (int n)
{
- return (char &) strh_[n];
+ return (char &) strh_[n];
}
-INLINE
-char
-String::operator [] (int n) const
+INLINE
+char
+String::operator[] (int n) const
{
- return strh_[n];
+ return strh_[n];
}
-INLINE
-String::String ()
+INLINE
+String::String ()
{
}
INLINE
-String::String (char const* source)
-{
- assert (source);
- strh_ = source;
+String::String (char const *source)
+{
+ assert (source);
+ strh_ = source;
}
-
#endif /* STRING_ICC */
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef VIRTUAL_METHODS_HH
#define VIRTUAL_METHODS_HH
#include <typeinfo>
-#define classname(class_ptr) demangle_classname (typeid (*(class_ptr)))
+#define classname(class_ptr) demangle_classname (typeid (* (class_ptr)))
const char *
demangle_classname (std::type_info const &);
class Foo : Baseclass
{
- VIRTUAL_COPY_CONSTRUCTOR (Baseclass, Foo);
+ VIRTUAL_COPY_CONSTRUCTOR (Baseclass, Foo);
}; */
-#define VIRTUAL_COPY_CONSTRUCTOR(base, name) \
- /* Hack to fix constness: gcc >= 2.95 is correct in defining \
- typeof (*this) in a const member function to be const. */ \
- virtual base* clone_const_helper () \
- { \
- return new name (*this); \
- } \
- virtual base *clone () const \
- { \
- /* return new name (*this); */ \
- base *urg = (base*) this; \
- return urg->clone_const_helper (); \
- }
+#define VIRTUAL_COPY_CONSTRUCTOR(base, name) \
+ /* Hack to fix constness: gcc >= 2.95 is correct in defining \
+ typeof (*this) in a const member function to be const. */ \
+ virtual base* clone_const_helper () \
+ { \
+ return new name (*this); \
+ } \
+ virtual base *clone () const \
+ { \
+ /* return new name (*this); */ \
+ base *urg = (base*) this; \
+ return urg->clone_const_helper (); \
+ }
#endif /* VIRTUAL_METHODS_HH */
-/*
+/*
international.cc -- implement stuff for internationalisation
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
-
- */
+*/
#include "config.hh"
#include "string-convert.hh"
#if !HAVE_GETTEXT
-inline char*
-gettext (char const* s)
+inline char *
+gettext (char const *s)
{
- return (char*)s;
+ return (char *)s;
}
#else
#include <libintl.h>
#endif
-String
+String
_ (char const *ch)
{
return String (gettext (ch));
}
-String
-_f (char const* format, ...)
+String
+_f (char const *format, ...)
{
va_list args;
va_start (args, format);
return str;
}
-String
-_f (char const* format, String s, String s2, String s3)
+String
+_f (char const *format, String s, String s2, String s3)
{
- return String_convert::form_string (gettext (format), s.to_str0 (), s2.to_str0 (),
- s3.to_str0 ());
+ return String_convert::form_string (gettext (format), s.to_str0 (), s2.to_str0 (),
+ s3.to_str0 ());
}
-/*
- interval-set.hh -- implement Interval_set
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
+/*
+ interval-set.hh -- implement Interval_set
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include "interval-set.hh"
void
Interval_set::remove_interval (Interval rm)
{
- for (int i = 0; i < allowed_regions_.size (); )
+ for (int i = 0; i < allowed_regions_.size ();)
{
Interval s = rm;
template<>
Real
-Interval_t<Real>::infinity ()
+Interval_t<Real>::infinity ()
{
return HUGE_VAL;
}
template<>
int
-Interval_t<int>::infinity ()
+Interval_t<int>::infinity ()
{
return INT_MAX;
}
-
template<>
String
Interval_t<int>::T_to_string (int i)
template INTERVAL__INSTANTIATE (int);
template INTERVAL__INSTANTIATE (Real);
-
#include "libc-extension.hh"
-char*
-strnlwr (char* start ,int n)
+char *
+strnlwr (char *start, int n)
{
- char * p = start + n;
- while (--p >= start)
+ char *p = start + n;
+ while (--p >= start)
{
*p = tolower (*p); /* a macro on some compilers */
}
return start;
}
-char*
-strnupr (char* start, int n)
+char *
+strnupr (char *start, int n)
{
- char * p = start + n;
- while (--p >= start)
+ char *p = start + n;
+ while (--p >= start)
{
*p = toupper (*p); /* a macro on some compilers */
}
double
my_round (double x)
{
- return floor (x -0.5)+ 1.0 ;
+ return floor (x -0.5)+ 1.0;
}
#ifndef isinf
int
isinf (double x)
{
- return x && ( x == x/ 2) ;
+ return x && (x == x/ 2);
}
#endif
#endif
unsigned char *
_memmem (unsigned char const *haystack, int haystack_len,
- unsigned char const *needle,int needle_len)
+ unsigned char const *needle, int needle_len)
{
- unsigned char const * end_haystack = haystack + haystack_len - needle_len + 1;
- unsigned char const * end_needle = needle + needle_len ;
+ unsigned char const *end_haystack = haystack + haystack_len - needle_len + 1;
+ unsigned char const *end_needle = needle + needle_len;
/* Ahhh ... Some minimal lowlevel stuff. This *is* nice; Varation
is the spice of life */
- while (haystack < end_haystack)
+ while (haystack < end_haystack)
{
unsigned char const *subneedle = needle;
unsigned char const *subhaystack = haystack;
- while (subneedle < end_needle)
- if (*subneedle++ != *subhaystack++)
+ while (subneedle < end_needle)
+ if (*subneedle++ != *subhaystack++)
goto next;
-
+
/* Completed the needle. Gotcha. */
return (unsigned char *) haystack;
next:
void *
memmem (void const *haystack, int haystack_len,
- void const *needle,int needle_len)
+ void const *needle, int needle_len)
{
- unsigned char const* haystack_byte_c = (unsigned char const*)haystack;
- unsigned char const* needle_byte_c = (unsigned char const*)needle;
+ unsigned char const *haystack_byte_c = (unsigned char const *)haystack;
+ unsigned char const *needle_byte_c = (unsigned char const *)needle;
return _memmem (haystack_byte_c, haystack_len, needle_byte_c, needle_len);
}
memrchr (unsigned char const *p, int n, char c)
{
const unsigned char *q = p + n;
- while (q > p)
+ while (q > p)
{
if (*--q == c)
- return (unsigned char*)q;
+ return (unsigned char *)q;
}
return 0;
}
-
template<class T>
inline void
my_swap (T &t1, T &t2, T &tmp)
unsigned char *left = byte;
unsigned char *right = byte + length;
- while (right > left)
- my_swap (*right--, *left++ , tmp_byte);
+ while (right > left)
+ my_swap (*right--, *left++, tmp_byte);
return byte;
}
#if ! HAVE_SNPRINTF
-int
+int
snprintf (char *str, size_t, char const *format, ...)
{
va_list ap;
#endif
#if ! HAVE_VSNPRINTF
-int
+int
vsnprintf (char *str, size_t, char const *format, va_list args)
{
int i = vsprintf (str, format, args);
#include <assert.h>
extern "C" {
-
+
#if ! HAVE_FOPENCOOKIE
#if HAVE_FUNOPEN
-
+
FILE *
fopencookie (void *cookie, char const *mode, cookie_io_functions_t fun)
{
(void) mode;
-#if 0
+#if 0
return funopen (cookie, fun.read, fun.write, fun.seek, fun.close);
#else
return funopen (cookie,
(int (*) (void *, char const *, int)) fun.write,
(fpos_t (*) (void *, fpos_t, int)) fun.seek,
(int (*) (void *)) fun.close);
-
-#endif
+
+#endif
}
#else /* ! HAVE_FUNOPEN */
static bool
is_memory_stream (void *foo)
{
- Memory_out_stream* cookie = (Memory_out_stream*) foo;
- return dynamic_cast<Memory_out_stream*> (cookie);
+ Memory_out_stream *cookie = (Memory_out_stream *) foo;
+ return dynamic_cast<Memory_out_stream *> (cookie);
}
FILE *
(void) modes;
(void) io_funcs;
if (is_memory_stream (cookie))
- return (FILE*) cookie;
+ return (FILE *) cookie;
assert (false);
return 0;
}
- int
+ int
handle_cookie_io_fclose (FILE *file)
{
if (is_memory_stream (file))
return fclose (file);
}
- int
+ int
handle_cookie_io_fprintf (FILE *file, char const *format, ...)
{
va_list ap;
return i;
}
- int
+ int
handle_cookie_io_putc (int c, FILE *file)
{
if (is_memory_stream (file))
}
return putc (c, file);
}
-
+
#endif /* ! HAVE_FUNOPEN */
#endif /* ! HAVE_FOPENCOOKIE */
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include <assert.h>
#include "memory-stream.hh"
-
/*
TODO: add read support as well.
*/
const int Memory_out_stream::block_size_ = 1024;
cookie_io_functions_t
-Memory_out_stream::functions_ = {
+Memory_out_stream::functions_
+= {
Memory_out_stream::reader,
Memory_out_stream::writer,
Memory_out_stream::seeker,
int
Memory_out_stream::cleaner (void *cookie)
{
- Memory_out_stream *stream = (Memory_out_stream*) cookie;
+ Memory_out_stream *stream = (Memory_out_stream *) cookie;
stream->file_ = 0;
return 0;
size_ = 0;
buffer_ = 0;
buffer_blocks_ = 0;
- file_ = fopencookie ((void*) this, "w", functions_);
+ file_ = fopencookie ((void *) this, "w", functions_);
}
Memory_out_stream::~Memory_out_stream ()
const char *buffer,
size_t size)
{
- Memory_out_stream *stream = (Memory_out_stream*) cookie;
+ Memory_out_stream *stream = (Memory_out_stream *) cookie;
ssize_t newsize = stream->size_ + size;
}
if (change)
- stream->buffer_ = (char*) realloc (stream->buffer_,
- stream->buffer_blocks_ * block_size_);
+ stream->buffer_ = (char *) realloc (stream->buffer_,
+ stream->buffer_blocks_ * block_size_);
memcpy (stream->buffer_ + stream->size_, buffer, size);
stream->size_ = newsize;
Offset::to_string () const
{
String s;
- s = String (" (") + ::to_string (coordinate_a_[X_AXIS]) + ", "
+ s = String (" (") + ::to_string (coordinate_a_[X_AXIS]) + ", "
+ ::to_string (coordinate_a_[Y_AXIS]) + ")";
return s;
}
#endif
-
bool
isinf_b (Real r)
{
/*
free bsd fix by John Galbraith
- */
-
+*/
+
Offset
complex_multiply (Offset z1, Offset z2)
{
Offset z;
if (!isinf_b (z2[Y_AXIS]))
- {
+ {
z[X_AXIS] = z1[X_AXIS] * z2[X_AXIS] - z1[Y_AXIS]*z2[Y_AXIS];
z[Y_AXIS] = z1[X_AXIS] * z2[Y_AXIS] + z1[Y_AXIS] * z2[X_AXIS];
- }
+ }
return z;
}
-
Offset
complex_conjugate (Offset o)
{
- o[Y_AXIS] = - o[Y_AXIS];
+ o[Y_AXIS] = -o[Y_AXIS];
return o;
}
{
z2 = complex_conjugate (z2);
Offset z = complex_multiply (z1, z2);
- z *= 1/z2.length ();
+ z *= 1 / z2.length ();
return z;
}
-
-
Offset
complex_exp (Offset o)
{
Real s = sin (o[Y_AXIS]);
Real c = cos (o[Y_AXIS]);
-
+
Real r = exp (o[X_AXIS]);
return Offset (r*c, r*s);
/**
euclidian vector length / complex modulus
- */
+*/
Real
Offset::length () const
{
2. Leak fix in parseFile.
Morten Welinder <terra@diku.dk> September 1999.
-
*/
/*
#define EOL '\n' /* end-of-line indicator */
#define MAX_NAME 4096 /* max length for identifiers */
-
-
/* Flags that can be AND'ed together to specify exactly what
* information from the AFM file should be saved.
*/
-#define P_G 0x01 /* 0000 0001 */ /* Global Font Info */
-#define P_W 0x02 /* 0000 0010 */ /* Character Widths ONLY */
-#define P_M 0x06 /* 0000 0110 */ /* All Char Metric Info */
-#define P_P 0x08 /* 0000 1000 */ /* Pair Kerning Info */
-#define P_T 0x10 /* 0001 0000 */ /* Track Kerning Info */
-#define P_C 0x20 /* 0010 0000 */ /* Composite Char Info */
-
+#define P_G 0x01 /* 0000 0001 */ /* Global Font Info */
+#define P_W 0x02 /* 0000 0010 */ /* Character Widths ONLY */
+#define P_M 0x06 /* 0000 0110 */ /* All Char Metric Info */
+#define P_P 0x08 /* 0000 1000 */ /* Pair Kerning Info */
+#define P_T 0x10 /* 0001 0000 */ /* Track Kerning Info */
+#define P_C 0x20 /* 0010 0000 */ /* Composite Char Info */
/* Commonly used flags
*/
-#define P_GW\
- (P_G | P_W)
-#define P_GM\
- (P_G | P_M)
-#define P_GMP\
- (P_G | P_M | P_P)
-#define P_GMK\
- (P_G | P_M | P_P | P_T)
-#define P_GALL\
- (P_G | P_M | P_P | P_T | P_C)
+#define P_GW \
+ (P_G | P_W)
+#define P_GM \
+ (P_G | P_M)
+#define P_GMP \
+ (P_G | P_M | P_P)
+#define P_GMK \
+ (P_G | P_M | P_P | P_T)
+#define P_GALL \
+ (P_G | P_M | P_P | P_T | P_C)
#define METATYPE1_BUG /* Parse Metatype1's (version unknown)
'Generated' global tag as comment. */
#define False "false" /* used in string comparison to check the value of */
/* boolean keys (e.g. IsFixedPitch) */
-#define MATCH(A,B) (strncmp ((A), (B), MAX_NAME) == 0)
-
-
+#define MATCH(A, B) (strncmp ((A), (B), MAX_NAME) == 0)
/*************************** GLOBALS ***********************/
static char *ident = NULL; /* storage buffer for keywords */
-
/* "shorts" for fast case statement
* The values of each of these enumerated items correspond to an entry in the
* table of strings defined below. Therefore, if you add a new string as
* "recognize" procedure to calculate how many possible keys there are.
*/
-enum parseKey {
- ASCENDER, CHARBBOX, CODE, COMPCHAR, CAPHEIGHT, COMMENT,
- DESCENDER, ENCODINGSCHEME, ENDCHARMETRICS, ENDCOMPOSITES,
- ENDFONTMETRICS, ENDKERNDATA, ENDKERNPAIRS, ENDTRACKKERN,
- FAMILYNAME, FONTBBOX, FONTNAME, FULLNAME,
+enum parseKey
+ {
+ ASCENDER, CHARBBOX, CODE, COMPCHAR, CAPHEIGHT, COMMENT,
+ DESCENDER, ENCODINGSCHEME, ENDCHARMETRICS, ENDCOMPOSITES,
+ ENDFONTMETRICS, ENDKERNDATA, ENDKERNPAIRS, ENDTRACKKERN,
+ FAMILYNAME, FONTBBOX, FONTNAME, FULLNAME,
#ifdef METATYPE1_BUG
- GENERATED,
+ GENERATED,
#endif
- ISFIXEDPITCH,
- ITALICANGLE, KERNPAIR, KERNPAIRXAMT, LIGATURE, CHARNAME,
- NOTICE, COMPCHARPIECE, STARTCHARMETRICS, STARTCOMPOSITES,
- STARTFONTMETRICS, STARTKERNDATA, STARTKERNPAIRS,
- STARTTRACKKERN, TRACKKERN, UNDERLINEPOSITION,
- UNDERLINETHICKNESS, VERSION, XYWIDTH, XWIDTH, WEIGHT, XHEIGHT,
- NOPE };
+ ISFIXEDPITCH,
+ ITALICANGLE, KERNPAIR, KERNPAIRXAMT, LIGATURE, CHARNAME,
+ NOTICE, COMPCHARPIECE, STARTCHARMETRICS, STARTCOMPOSITES,
+ STARTFONTMETRICS, STARTKERNDATA, STARTKERNPAIRS,
+ STARTTRACKKERN, TRACKKERN, UNDERLINEPOSITION,
+ UNDERLINETHICKNESS, VERSION, XYWIDTH, XWIDTH, WEIGHT, XHEIGHT,
+ NOPE };
/* keywords for the system:
* This a table of all of the current strings that are vaild AFM keys.
* end.
*/
-static char *keyStrings[] = {
+static char *keyStrings[]
+= {
"Ascender", "B", "C", "CC", "CapHeight", "Comment",
"Descender", "EncodingScheme", "EndCharMetrics", "EndComposites",
"EndFontMetrics", "EndKernData", "EndKernPairs", "EndTrackKern",
* reads all tokens until the next end-of-line.
*/
-static char*
+static char *
token (FILE *stream)
{
int ch, idx;
} /* token */
-
/*************************** linetoken *************************/
/* "linetoken" will get read all tokens until the EOL character from
* more than one word (like Comment lines and FullName).
*/
-static char*
+static char *
linetoken (FILE *stream)
{
int ch, idx;
} /* linetoken */
-
/*************************** recognize *************************/
/* This function tries to match a string to a known list of
while ((upper >= lower) && !found)
{
- midpoint = (lower + upper)/2;
+ midpoint = (lower + upper) / 2;
if (keyStrings[midpoint] == NULL)
break;
cmpvalue = strncmp (ident, keyStrings[midpoint], MAX_NAME);
else
if (cmpvalue < 0)
upper = midpoint - 1;
- else
- lower = midpoint + 1;
+ else
+ lower = midpoint + 1;
}
if (found)
return NOPE;
}
-
/************************* parseGlobals *****************************/
/* This function is called by "parseFile". It will parse the AFM File
if (keyword == NULL)
/* Have reached an early and unexpected EOF. */
/* Set flag and stop parsing */
- {
+ {
error = AFM_earlyEOF;
break; /* get out of loop */
- }
+ }
if (!save)
/* get tokens until the end of the Global Font info section */
/* without saving any of the data */
switch (recognize (keyword))
- {
+ {
case STARTCHARMETRICS:
cont = FALSE;
break;
- case ENDFONTMETRICS:
+ case ENDFONTMETRICS:
cont = FALSE;
error = normalEOF;
break;
case COMMENT:
#ifdef METATYPE1_BUG
case GENERATED:
-#endif
+#endif
keyword = linetoken (fp);
break;
case FONTNAME:
} /* parseGlobals */
-
#if 0
/************************* initializeArray ************************/
{
keyword = token (fp);
if (keyword == NULL)
- {
+ {
error = AFM_earlyEOF;
break; /* get out of loop */
- }
+ }
switch (recognize (keyword))
- {
+ {
case COMMENT:
keyword = linetoken (fp);
break;
default:
error = AFM_parseError;
break;
- } /* switch */
+ } /* switch */
} /* while */
if (!found)
/* Have reached an early and unexpected EOF. */
/* Set flag and stop parsing */
if (keyword == NULL)
- {
+ {
error = AFM_earlyEOF;
break; /* get out of loop */
- }
- if (!save)
+ }
+ if (!save)
/* get tokens until the end of the Char Metrics section without */
/* saving any of the data*/
switch (recognize (keyword))
- {
+ {
case ENDCHARMETRICS:
cont = FALSE;
break;
} /* parseCharWidths */
-
/************************* parseCharMetrics ************************/
/* This function is called by parseFile if the caller of parseFile
{
keyword = token (fp);
if (keyword == NULL)
- {
+ {
error = AFM_earlyEOF;
break; /* get out of loop */
- }
+ }
switch (recognize (keyword))
- {
+ {
case COMMENT:
keyword = linetoken (fp);
break;
case XWIDTH:
temp->wx = atoi (token (fp));
break;
-
+
case CHARNAME:
keyword = token (fp);
temp->name = (char *) malloc (strlen (keyword) + 1);
strcpy (temp->name, keyword);
break;
-
+
case CHARBBOX:
temp->charBBox.llx = atoi (token (fp));
temp->charBBox.lly = atoi (token (fp));
temp->charBBox.ury = atoi (token (fp));
break;
- case LIGATURE: {
- AFM_Ligature **tail = & (temp->ligs);
- AFM_Ligature *node = *tail;
+ case LIGATURE:
+ {
+ AFM_Ligature **tail = &(temp->ligs);
+ AFM_Ligature *node = *tail;
- if (*tail != NULL)
- {
- while (node->next != NULL)
- node = node->next;
- tail = & (node->next);
- }
+ if (*tail != NULL)
+ {
+ while (node->next != NULL)
+ node = node->next;
+ tail = &(node->next);
+ }
- *tail = (AFM_Ligature *) calloc (1, sizeof (AFM_Ligature));
- keyword = token (fp);
- (*tail)->succ = (char *) malloc (strlen (keyword) + 1);
- strcpy ((*tail)->succ, keyword);
- keyword = token (fp);
- (*tail)->lig = (char *) malloc (strlen (keyword) + 1);
- strcpy ((*tail)->lig, keyword);
- break; }
+ *tail = (AFM_Ligature *) calloc (1, sizeof (AFM_Ligature));
+ keyword = token (fp);
+ (*tail)->succ = (char *) malloc (strlen (keyword) + 1);
+ strcpy ((*tail)->succ, keyword);
+ keyword = token (fp);
+ (*tail)->lig = (char *) malloc (strlen (keyword) + 1);
+ strcpy ((*tail)->lig, keyword);
+ break; }
case ENDCHARMETRICS:
cont = FALSE;;
break;
case NOPE:
default:
warning ("Unknown token");
-
+
error = AFM_parseError;
break;
- } /* switch */
+ } /* switch */
} /* while */
if ((error == AFM_ok) && (count != fi->numOfChars))
} /* parseCharMetrics */
-
-
/************************* parseAFM_TrackKernData ***********************/
/* This function is called by "parseFile". It will parse the AFM File
keyword = token (fp);
if (keyword == NULL)
- {
+ {
error = AFM_earlyEOF;
break; /* get out of loop */
- }
+ }
if (!save)
/* get tokens until the end of the Track Kerning Data */
/* section without saving any of the data */
switch (recognize (keyword))
{
case COMMENT:
-#ifdef METATYPE1_BUG
+#ifdef METATYPE1_BUG
case GENERATED:
-#endif
+#endif
keyword = linetoken (fp);
break;
case TRACKKERN:
} /* parseAFM_TrackKernData */
-
/************************* parseAFM_PairKernData ************************/
/* This function is called by "parseFile". It will parse the AFM File
keyword = token (fp);
if (keyword == NULL)
- {
+ {
error = AFM_earlyEOF;
break; /* get out of loop */
- }
+ }
if (!save)
/* get tokens until the end of the Pair Kerning Data */
/* section without saving any of the data */
} /* parseAFM_PairKernData */
-
/************************* parseAFM_CompCharData **************************/
/* This function is called by "parseFile". It will parse the AFM File
if (keyword == NULL)
/* Have reached an early and unexpected EOF. */
/* Set flag and stop parsing */
- {
+ {
error = AFM_earlyEOF;
break; /* get out of loop */
- }
+ }
if (ccount > fi->numOfComps)
- {
+ {
error = AFM_parseError;
break; /* get out of loop */
- }
+ }
if (!save)
/* get tokens until the end of the Composite Character info */
/* section without saving any of the data */
} /* parseAFM_CompCharData */
-
-
/*************************** 'PUBLIC' FUNCTION ********************/
void
AFM_free (AFM_Font_info *fi)
{
- if (fi->gfi) {
- free (fi->gfi->afmVersion);
- free (fi->gfi->fontName);
- free (fi->gfi->fullName);
- free (fi->gfi->familyName);
- free (fi->gfi->weight);
- free (fi->gfi->version);
- free (fi->gfi->notice);
- free (fi->gfi->encodingScheme);
- free (fi->gfi);
- }
+ if (fi->gfi)
+ {
+ free (fi->gfi->afmVersion);
+ free (fi->gfi->fontName);
+ free (fi->gfi->fullName);
+ free (fi->gfi->familyName);
+ free (fi->gfi->weight);
+ free (fi->gfi->version);
+ free (fi->gfi->notice);
+ free (fi->gfi->encodingScheme);
+ free (fi->gfi);
+ }
/* This contains just scalars. */
free (fi->cwi);
- if (fi->cmi) {
- int i;
- for (i = 0; i < fi->numOfChars; i++) {
- free (fi->cmi[i].name);
- while (fi->cmi[i].ligs) {
- AFM_Ligature *tmp;
- tmp = fi->cmi[i].ligs;
- free (tmp->succ);
- free (tmp->lig);
- free (tmp);
- fi->cmi[i].ligs = fi->cmi[i].ligs->next;
- }
+ if (fi->cmi)
+ {
+ int i;
+ for (i = 0; i < fi->numOfChars; i++)
+ {
+ free (fi->cmi[i].name);
+ while (fi->cmi[i].ligs)
+ {
+ AFM_Ligature *tmp;
+ tmp = fi->cmi[i].ligs;
+ free (tmp->succ);
+ free (tmp->lig);
+ free (tmp);
+ fi->cmi[i].ligs = fi->cmi[i].ligs->next;
+ }
+ }
+ free (fi->cmi);
}
- free (fi->cmi);
- }
/* This contains just scalars. */
free (fi->tkd);
- if (fi->pkd) {
- int i;
- for (i = 0; i < fi->numOfPairs; i++) {
- free (fi->pkd[i].name1);
- free (fi->pkd[i].name2);
+ if (fi->pkd)
+ {
+ int i;
+ for (i = 0; i < fi->numOfPairs; i++)
+ {
+ free (fi->pkd[i].name1);
+ free (fi->pkd[i].name2);
+ }
+ free (fi->pkd);
}
- free (fi->pkd);
- }
-
- if (fi->ccd) {
- int i, j;
- for (i = 0; i < fi->numOfComps; i++) {
- free (fi->ccd[i].ccName);
- for (j = 0; j < fi->ccd[i].numOfPieces; j++) {
- free (fi->ccd[i].pieces[j].AFM_PccName);
- }
- free (fi->ccd[i].pieces);
+
+ if (fi->ccd)
+ {
+ int i, j;
+ for (i = 0; i < fi->numOfComps; i++)
+ {
+ free (fi->ccd[i].ccName);
+ for (j = 0; j < fi->ccd[i].numOfPieces; j++)
+ {
+ free (fi->ccd[i].pieces[j].AFM_PccName);
+ }
+ free (fi->ccd[i].pieces);
+ }
+ free (fi->ccd);
}
- free (fi->ccd);
- }
free (fi);
}
-
/*************************** parseFile *****************************/
/* parseFile is the only 'public' procedure available. It is called
int code = AFM_ok; /* return code from each of the parsing routines */
int error = AFM_ok; /* used as the return code from this function */
- register char *keyword; /* used to store a token */
+ register char *keyword; /* used to store a token */
-
- /* storage data for the global variable ident */
+ /* storage data for the global variable ident */
if (!ident)
ident = (char *) calloc (MAX_NAME, sizeof (char));
if (ident == NULL)
{
(*fi)->numOfChars = atoi (token (fp));
if (flags & (P_M ^ P_W))
- {
+ {
(*fi)->cmi = (AFM_CharMetricInfo *)
calloc ((*fi)->numOfChars, sizeof (AFM_CharMetricInfo));
if ((*fi)->cmi == NULL)
return error;
}
code = parseCharMetrics (fp, *fi);
- }
+ }
else
- {
+ {
if (flags & P_W)
- {
+ {
(*fi)->cwi = (int *) calloc (256, sizeof (int));
if ((*fi)->cwi == NULL)
- {
+ {
error = AFM_storageProblem;
return (error);
- }
- }
+ }
+ }
/* parse section regardless */
code = parseCharWidths (fp, (*fi)->cwi);
- } /* else */
+ } /* else */
} /* if */
if ((error != AFM_earlyEOF) && (code < 0))
if (keyword == NULL)
/* Have reached an early and unexpected EOF. */
/* Set flag and stop parsing */
- {
+ {
code = AFM_earlyEOF;
break; /* get out of loop */
- }
+ }
switch (recognize (keyword))
- {
+ {
case STARTKERNDATA:
break;
case ENDKERNDATA:
default:
code = AFM_parseError;
break;
- } /* switch */
+ } /* switch */
if ((error != AFM_earlyEOF) && (code < 0))
error = code;
/*
- poly.cc -- routines for manipulation of polynomials in one var
+ poly.cc -- routines for manipulation of polynomials in one var
(c) 1993--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- */
+*/
#include "polynomial.hh"
#include <cmath>
/*
- Een beter milieu begint bij uzelf. Hergebruik!
+ Een beter milieu begint bij uzelf. Hergebruik!
- This was ripped from Rayce, a raytracer I once wrote.
+ This was ripped from Rayce, a raytracer I once wrote.
*/
Real
Real p = 0.0;
// horner's scheme
- for (int i = coefs_.size (); i--; )
+ for (int i = coefs_.size (); i--;)
p = x * p + coefs_[i];
-
+
return p;
}
-
Polynomial
-Polynomial::multiply (const Polynomial & p1, const Polynomial & p2)
+Polynomial::multiply (const Polynomial &p1, const Polynomial &p2)
{
Polynomial dest;
if (i - j <= p2.degree () && j <= p1.degree ())
dest.coefs_.top () += p1.coefs_[j] * p2.coefs_[i - j];
}
-
+
return dest;
}
{
for (int i = 1; i<= degree (); i++)
{
- coefs_[i-1] = coefs_[i] * i;
+ coefs_[i - 1] = coefs_[i] * i;
}
coefs_.pop ();
}
Polynomial
-Polynomial::power (int exponent, const Polynomial & src)
+Polynomial::power (int exponent, const Polynomial &src)
{
int e = exponent;
Polynomial dest (1), base (src);
-
+
/*
classic int power. invariant: src^exponent = dest * src ^ e
greetings go out to Lex Bijlsma & Jaap vd Woude */
while (e > 0)
{
if (e % 2)
- {
+ {
dest = multiply (dest, base);
e--;
- } else
- {
- base = multiply (base, base);
- e /= 2;
- }
+ }
+ else
+
+ {
+ base = multiply (base, base);
+ e /= 2;
+ }
}
- return dest;
+ return dest;
}
static Real const FUDGE = 1e-8;
void
Polynomial::clean ()
{
-/*
- We only do relative comparisons. Absolute comparisons break down in
- degenerate cases. */
- while (degree () > 0 &&
- (fabs (coefs_.top ()) < FUDGE * fabs (coefs_.top (1))
- || !coefs_.top ()))
+ /*
+ We only do relative comparisons. Absolute comparisons break down in
+ degenerate cases. */
+ while (degree () > 0
+ && (fabs (coefs_.top ()) < FUDGE *fabs (coefs_.top (1))
+ || !coefs_.top ()))
coefs_.pop ();
}
-
-
void
-Polynomial::operator += (Polynomial const &p)
+Polynomial::operator+= (Polynomial const &p)
{
- while (degree () < p.degree())
+ while (degree () < p.degree ())
coefs_.push (0.0);
- for (int i = 0; i <= p.degree(); i++)
+ for (int i = 0; i <= p.degree (); i++)
coefs_[i] += p.coefs_[i];
}
-
void
-Polynomial::operator -= (Polynomial const &p)
+Polynomial::operator-= (Polynomial const &p)
{
- while (degree () < p.degree())
+ while (degree () < p.degree ())
coefs_.push (0.0);
- for (int i = 0; i <= p.degree(); i++)
+ for (int i = 0; i <= p.degree (); i++)
coefs_[i] -= p.coefs_[i];
}
-
void
Polynomial::scalarmultiply (Real fact)
{
coefs_[i] *= fact;
}
-
-
void
-Polynomial::set_negate (const Polynomial & src)
+Polynomial::set_negate (const Polynomial &src)
{
for (int i = 0; i <= src.degree (); i++)
coefs_[i] = -src.coefs_[i];
}
/// mod of #u/v#
-int
+int
Polynomial::set_mod (const Polynomial &u, const Polynomial &v)
{
- (*this) = u;
-
- if (v.lc () < 0.0) {
- for (int k = u.degree () - v.degree () - 1; k >= 0; k -= 2)
- coefs_[k] = -coefs_[k];
-
- for (int k = u.degree () - v.degree (); k >= 0; k--)
- for (int j = v.degree () + k - 1; j >= k; j--)
- coefs_[j] = -coefs_[j] - coefs_[v.degree () + k] * v.coefs_[j - k];
- } else {
- for (int k = u.degree () - v.degree (); k >= 0; k--)
- for (int j = v.degree () + k - 1; j >= k; j--)
- coefs_[j] -= coefs_[v.degree () + k] * v.coefs_[j - k];
- }
+ (*this) = u;
+
+ if (v.lc () < 0.0)
+ {
+ for (int k = u.degree () - v.degree () - 1; k >= 0; k -= 2)
+ coefs_[k] = -coefs_[k];
+
+ for (int k = u.degree () - v.degree (); k >= 0; k--)
+ for (int j = v.degree () + k - 1; j >= k; j--)
+ coefs_[j] = -coefs_[j] - coefs_[v.degree () + k] * v.coefs_[j - k];
+ }
+ else
+
+ {
+ for (int k = u.degree () - v.degree (); k >= 0; k--)
+ for (int j = v.degree () + k - 1; j >= k; j--)
+ coefs_[j] -= coefs_[v.degree () + k] * v.coefs_[j - k];
+ }
int k = v.degree () - 1;
while (k >= 0 && coefs_[k] == 0.0)
}
void
-Polynomial::check_sol (Real x) const
+Polynomial::check_sol (Real x) const
{
- Real f=eval (x);
+ Real f = eval (x);
Polynomial p (*this);
p.differentiate ();
Real d = p.eval (x);
-
- if ( abs (f) > abs (d) * FUDGE)
- ;
+
+ if (abs (f) > abs (d) * FUDGE);
/*
warning ("x=%f is not a root of polynomial\n"
"f (x)=%f, f' (x)=%f \n", x, f, d); */
}
-
+
void
Polynomial::check_sols (Array<Real> roots) const
{
- for (int i=0; i< roots.size (); i++)
+ for (int i = 0; i< roots.size (); i++)
check_sol (roots[i]);
}
inline Real cubic_root (Real x)
{
if (x > 0.0)
- return pow (x, 1.0/3.0) ;
+ return pow (x, 1.0 / 3.0);
else if (x < 0.0)
- return -pow (-x, 1.0/3.0);
+ return -pow (-x, 1.0 / 3.0);
else
return 0.0;
}
Polynomial::solve_cubic ()const
{
Array<Real> sol;
-
+
/* normal form: x^3 + Ax^2 + Bx + C = 0 */
Real A = coefs_[2] / coefs_[3];
Real B = coefs_[1] / coefs_[3];
* substitute x = y - A/3 to eliminate quadric term: x^3 +px + q = 0
*/
- Real sq_A = A * A;
+ Real sq_A = A *A;
Real p = 1.0 / 3 * (-1.0 / 3 * sq_A + B);
- Real q = 1.0 / 2 * (2.0 / 27 * A * sq_A - 1.0 / 3 * A * B + C);
+ Real q = 1.0 / 2 * (2.0 / 27 * A *sq_A - 1.0 / 3 * A *B + C);
/* use Cardano's formula */
Real cb = p * p * p;
Real D = q * q + cb;
- if (iszero (D)) {
- if (iszero (q)) { /* one triple solution */
- sol.push (0);
- sol.push (0);
- sol.push (0);
- } else { /* one single and one double solution */
- Real u = cubic_root (-q);
-
- sol.push (2 * u);
- sol.push (-u);
- }
- } else if (D < 0) { /* Casus irreducibilis: three real solutions */
+ if (iszero (D))
+ {
+ if (iszero (q)) { /* one triple solution */
+ sol.push (0);
+ sol.push (0);
+ sol.push (0);
+ } else { /* one single and one double solution */
+ Real u = cubic_root (-q);
+
+ sol.push (2 * u);
+ sol.push (-u);
+ }
+ } else if (D < 0) { /* Casus irreducibilis: three real solutions */
Real phi = 1.0 / 3 * acos (-q / sqrt (-cb));
Real t = 2 * sqrt (-p);
sol.push (t * cos (phi));
sol.push (-t * cos (phi + M_PI / 3));
- sol.push ( -t * cos (phi - M_PI / 3));
+ sol.push (-t * cos (phi - M_PI / 3));
} else { /* one real solution */
Real sqrt_D = sqrt (D);
Real u = cubic_root (sqrt_D - q);
Real v = -cubic_root (sqrt_D + q);
- sol.push ( u + v);
+ sol.push (u + v);
}
/* resubstitute */
sol[i] -= sub;
#ifdef PARANOID
- assert (fabs (eval (sol[i]) ) < 1e-8);
+ assert (fabs (eval (sol[i])) < 1e-8);
#endif
}
-
+
return sol;
}
return coefs_.top ();
}
-Real&
-Polynomial::lc ()
+Real &
+Polynomial::lc ()
{
return coefs_.top ();
}
return coefs_.size () -1;
}
/*
- all roots of quadratic eqn.
- */
+ all roots of quadratic eqn.
+*/
Array<Real>
Polynomial::solve_quadric ()const
{
Real D = p * p - q;
- if (D>0) {
- D = sqrt (D);
+ if (D > 0)
+ {
+ D = sqrt (D);
- sol.push ( D - p);
- sol.push ( -D - p);
- }
- return sol;
+ sol.push (D - p);
+ sol.push (-D - p);
+ }
+ return sol;
}
/* solve linear equation */
{
Array<Real> s;
if (coefs_[1])
- s.push ( -coefs_[0] / coefs_[1]);
+ s.push (-coefs_[0] / coefs_[1]);
return s;
}
-
Array<Real>
Polynomial::solve () const
{
- Polynomial * me = (Polynomial*) this;
+ Polynomial *me = (Polynomial *) this;
me->clean ();
-
+
switch (degree ())
{
case 1:
}
void
-Polynomial:: operator *= (Polynomial const &p2)
+Polynomial:: operator*= (Polynomial const &p2)
{
- *this = multiply (*this,p2);
-}
-
+ *this = multiply (*this, p2);
+}
/*
rational.cc -- implement Rational
-
+
source file of the Flower Library
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
#include <cmath>
#include <cstdlib>
-#include "string-convert.hh"
+#include "string-convert.hh"
#include "libc-extension.hh"
Rational::operator double () const
#ifdef STREAM_SUPPORT
ostream &
-operator << (ostream &o, Rational r)
+operator<< (ostream &o, Rational r)
{
- o << r.string ();
+ o << r.string ();
return o;
}
#endif
-
Rational
Rational::trunc_rat () const
{
return b;
}
-
void
Rational::set_infinite (int s)
{
- sign_ = ::sign (s) * 2;
+ sign_ = ::sign (s) * 2;
}
Rational
-Rational::operator - () const
+Rational::operator- () const
{
Rational r (*this);
r.negate ();
}
else
{
- int g = gcd (num_ , den_);
+ int g = gcd (num_, den_);
num_ /= g;
den_ /= g;
return 0;
else
{
- return r.sign_ * ::sign (int (r.num_ * s.den_) - int (s.num_ * r.den_));
+ return r.sign_ * ::sign (int (r.num_ * s.den_) - int (s.num_ * r.den_));
}
}
int
compare (Rational const &r, Rational const &s)
{
- return Rational::compare (r, s );
+ return Rational::compare (r, s);
}
Rational &
-Rational::operator %= (Rational r)
+Rational::operator%= (Rational r)
{
*this = r.mod_rat (r);
return *this;
}
Rational &
-Rational::operator += (Rational r)
+Rational::operator+= (Rational r)
{
- if (is_infinity ())
- ;
+ if (is_infinity ());
else if (r.is_infinity ())
{
*this = r;
}
- else
+ else
{
int n = sign_ * num_ *r.den_ + r.sign_ * den_ * r.num_;
int d = den_ * r.den_;
- sign_ = ::sign (n) * ::sign (d);
+ sign_ = ::sign (n) * ::sign (d);
num_ = abs (n);
den_ = abs (d);
normalise ();
}
return *this;
}
-
/*
copied from libg++ 2.8.0
- */
+*/
Rational::Rational (double x)
{
if (x != 0.0)
num_ = (unsigned int) (mantissa * FACT);
den_ = (unsigned int) FACT;
- normalise ();
+ normalise ();
if (expt < 0)
den_ <<= -expt;
else
}
}
-
void
Rational::invert ()
{
int r (num_);
- num_ = den_;
+ num_ = den_;
den_ = r;
}
Rational &
-Rational::operator *= (Rational r)
+Rational::operator*= (Rational r)
{
sign_ *= ::sign (r.sign_);
if (r.is_infinity ())
- {
+ {
sign_ = sign () * 2;
goto exit_func;
}
exit_func:
return *this;
}
-
+
Rational &
-Rational::operator /= (Rational r)
+Rational::operator/= (Rational r)
{
r.invert ();
return (*this *= r);
sign_ *= -1;
}
-Rational&
-Rational::operator -= (Rational r)
+Rational &
+Rational::operator-= (Rational r)
{
r.negate ();
return (*this += r);
{
if (is_infinity ())
{
- String s (sign_ > 0 ? "" : "-" );
+ String s (sign_ > 0 ? "" : "-");
return String (s + "infinity");
}
PROJECT: FlowerSoft C++ library
FILE : string-convert.cc
---*/
+ --*/
#include "string-convert.hh"
2e318, this number would have approx 318 zero's in its string.
Should enlarge buff dynamically.
-
+
@see
man 3 snprintf
- */
-static const int STRING_BUFFER_LEN=1024;
+*/
+static const int STRING_BUFFER_LEN = 1024;
String
String_convert::bool_string (bool b)
String_convert::bin2hex (String bin_string)
{
String str;
- Byte const* byte = bin_string.to_bytes ();
- for (int i = 0; i < bin_string.length (); i++)
+ Byte const *byte = bin_string.to_bytes ();
+ for (int i = 0; i < bin_string.length (); i++)
{
str += to_string ((char)nibble2hex_byte (*byte >> 4));
str += to_string ((char)nibble2hex_byte (*byte++));
assert (bin_string.length () <= (int)sizeof (unsigned));
unsigned result_u = 0;
- for (int i = 0; i < bin_string.length (); i++)
+ for (int i = 0; i < bin_string.length (); i++)
{
result_u <<= 8;
result_u += (Byte)bin_string[ i ];
}
String
-String_convert::i64_string (I64 i64, char const* fmt)
+String_convert::i64_string (I64 i64, char const *fmt)
{
char buffer[STRING_BUFFER_LEN];
snprintf (buffer, STRING_BUFFER_LEN,
- (fmt ? fmt : "%Ld"), i64); // assume radix 10
+ (fmt ? fmt : "%Ld"), i64); // assume radix 10
return String (buffer);
}
}
int
-String_convert::hex2bin (String hex_string, String& bin_string_r)
+String_convert::hex2bin (String hex_string, String &bin_string_r)
{
if (hex_string.length () % 2)
hex_string = "0" + hex_string;
bin_string_r = "";
- Byte const* byte= hex_string.to_bytes ();
+ Byte const *byte= hex_string.to_bytes ();
int i = 0;
- while (i < hex_string.length ())
+ while (i < hex_string.length ())
{
int high_i = hex2nibble (*byte++);
int low_i = hex2nibble (*byte++);
if (high_i < 0 || low_i < 0)
return 1; // illegal char
- bin_string_r += to_string ((char) (high_i << 4 | low_i), 1 );
+ bin_string_r += to_string ((char) (high_i << 4 | low_i), 1);
i += 2;
}
return 0;
}
-String
+String
String_convert::hex2bin (String hex_string)
{
String str;
return str;
}
-int
+int
String_convert::hex2nibble (Byte byte)
{
if (byte >= '0' && byte <= '9')
}
// stupido. Should use int_string ()
-String
+String
String_convert::int2dec (int i, int length_i, char ch)
{
char fill_char = ch;
// ugh
String dec_string = to_string (i);
-
+
// ugh
return to_string (fill_char, length_i - dec_string.length ()) + dec_string;
}
-
// stupido. Should use int_string ()
-String
+String
String_convert::unsigned2hex (unsigned u, int length_i, char fill_char)
{
String str;
str = "0";
#if 1 // both go...
- while (u)
+ while (u)
{
- str = to_string ((char) ((u % 16)["0123456789abcdef"] ) ) + str;
+ str = to_string ((char) ((u % 16)["0123456789abcdef"])) + str;
u /= 16;
}
#else
return (byte & 0x0f) - 10 + 'a';
}
/**
- Convert an integer to a string
+ Convert an integer to a string
- @param
- #fmt# is a printf style format, default assumes "%d" as format.
- */
+ @param
+ #fmt# is a printf style format, default assumes "%d" as format.
+*/
String
-String_convert::int_string (int i, char const* fmt)
+String_convert::int_string (int i, char const *fmt)
{
char buffer[STRING_BUFFER_LEN];
snprintf (buffer, STRING_BUFFER_LEN,
- (fmt ? fmt : "%d"), i); // assume radix 10
+ (fmt ? fmt : "%d"), i); // assume radix 10
return String (buffer);
}
String
-String_convert::form_string (char const* format, ...)
+String_convert::form_string (char const *format, ...)
{
va_list args;
va_start (args, format);
return String (buffer);
}
-String
-String_convert::vform_string (char const* format, va_list args)
+String
+String_convert::vform_string (char const *format, va_list args)
{
char buffer[STRING_BUFFER_LEN];
vsnprintf (buffer, STRING_BUFFER_LEN, format, args);
}
/**
- Convert a double to a string.
+ Convert a double to a string.
- @param #fmt# is a printf style format, default assumes "%lf" as format
- */
+ @param #fmt# is a printf style format, default assumes "%lf" as format
+*/
String
-String_convert::double_string (double f, char const* fmt)
+String_convert::double_string (double f, char const *fmt)
{
- char buf[STRING_BUFFER_LEN];
+ char buf[STRING_BUFFER_LEN];
snprintf (buf, STRING_BUFFER_LEN, fmt ? fmt : "%f", f);
return String (buf);
}
/**
-Make a string from a single character.
+ Make a string from a single character.
- @param
- #n# is a repetition count, default value is 1
- */
+ @param
+ #n# is a repetition count, default value is 1
+*/
String
String_convert::char_string (char c, int n)
{
n = n >= 0 ? n : 0;
- char* ch = new char[ n ];
+ char *ch = new char[ n ];
memset (ch, c, n);
- String s ((Byte*)ch, n);
+ String s ((Byte *)ch, n);
delete[] ch;
return s;
}
String
String_convert::rational_string (Rational r)
{
- return r.to_string ();
+ return r.to_string ();
}
String
String_convert::pointer_string (void const *l)
{
char buffer[STRING_BUFFER_LEN];
- snprintf (buffer, STRING_BUFFER_LEN, "%p", l); // assume radix 10
+ snprintf (buffer, STRING_BUFFER_LEN, "%p", l); // assume radix 10
return String (buffer);
}
/**
- Convert a double to a string.
+ Convert a double to a string.
- @param
- #n# is the number of nonzero digits
- */
+ @param
+ #n# is the number of nonzero digits
+*/
String
String_convert::precision_string (double x, int n)
{
{
String s = str.left_string (i);
a.push (s);
- while (str[++i] == c)
- ;
+ while (str[++i] == c);
str = str.cut_string (i, INT_MAX);
i = str.index (c);
}
return a;
}
-
String
String_convert::long_string (long l)
{
char s[STRING_BUFFER_LEN];
- sprintf (s,"%ld", l);
+ sprintf (s, "%ld", l);
return s;
}
/*
+ string.cc - implement String
- string.cc - implement String
-
(c) 1997--2005 Han-Wen Nienhuys & Jan Nieuwenhuizen
-
- */
+*/
#ifndef _GNU_SOURCE // we want memmem
#define _GNU_SOURCE
#include "string-convert.hh"
#ifdef STRING_DEBUG
-void* mymemmove (void* dest, void const* src, size_t n);
+void *mymemmove (void *dest, void const *src, size_t n);
#define memmove mymemmove
#endif
// return array, alloced with new.
-Byte*
+Byte *
String::get_copy_byte () const
{
- Byte const* src = strh_.to_bytes ();
- Byte* dest = new Byte[strh_.length () + 1];
+ Byte const *src = strh_.to_bytes ();
+ Byte *dest = new Byte[strh_.length () + 1];
memcpy (dest, src, strh_.length () + 1);
- return dest;
+ return dest;
}
-char*
+char *
String::get_copy_str0 () const
{
- return (char*)get_copy_byte ();
+ return (char *)get_copy_byte ();
}
\f
/*
copying, constructing.
- */
-String&
-String::operator = (String const&source)
+*/
+String &
+String::operator= (String const &source)
{
strh_ = source.strh_;
return *this;
}
-
-String::String (Byte const* byte, int len_i)
-{
+String::String (Byte const *byte, int len_i)
+{
strh_.set (byte, len_i);
}
/**
- @see
- String_convert::
- */
+ @see
+ String_convert::
+*/
String
to_string (char c, int n)
{
}
String
-to_string (double f, char const* format)
+to_string (double f, char const *format)
{
return String_convert::double_string (f, format);
}
String
-to_string (int i, char const * format)
+to_string (int i, char const *format)
{
return String_convert::int_string (i, format);
}
return String_convert::long_string (b);
}
-String
-to_string (char const* format, ... )
+String
+to_string (char const *format, ...)
{
va_list args;
va_start (args, format);
strh_.append (s.to_bytes (), s.length ());
}
void
-String::operator += (String s)
+String::operator+= (String s)
{
append (s);
}
return strh_.length ();
}
-Byte const*
+Byte const *
String::to_bytes () const
{
return strh_.to_bytes ();
}
-char const*
+char const *
String::to_str0 () const
{
return strh_.to_str0 ();
}
-Byte*
+Byte *
String::get_bytes ()
{
return strh_.get_bytes ();
}
-char*
+char *
String::get_str0 ()
{
return strh_.get_str0 ();
}
-bool
+bool
String::is_empty () const
{
return !length ();
}
/**
- Do a signed comparison, analogous to memcmp;
- */
+ Do a signed comparison, analogous to memcmp;
+*/
int
-String::compare (String const& s1, String const& s2)
+String::compare (String const &s1, String const &s2)
{
- Byte const* p1 = s1.to_bytes ();
- Byte const* p2 = s2.to_bytes ();
+ Byte const *p1 = s1.to_bytes ();
+ Byte const *p2 = s2.to_bytes ();
if (p1 == p2)
return 0;
/*
don't forget the terminating '\0'
- */
+ */
int f = (s1.length () <? s2.length ());
int cmp_length = 1+ f;
int i = memcmp (p1, p2, cmp_length);
int
String::index_last (char const c) const
{
- if (!length ())
+ if (!length ())
return -1;
- char const* me = strh_.to_str0 ();
- char const* p = (char const*)memrchr ((Byte*)me, length (), c);
+ char const *me = strh_.to_str0 ();
+ char const *p = (char const *)memrchr ((Byte *)me, length (), c);
if (p)
return p - me;
return -1;
}
int
-String::index_last (char const* string) const // UGK!
+String::index_last (char const *string) const // UGK!
{
assert (false); // broken
int len = strlen (string); // ugrh
- if (!length () || !len)
+ if (!length () || !len)
return -1;
-
+
int next_i = index (string);
if (next_i == -1)
return -1;
-
+
int index_i = 0;
- while (next_i >= 0)
+ while (next_i >= 0)
{
index_i += next_i;
- next_i = right_string (length () - index_i - len).index (string );
+ next_i = right_string (length () - index_i - len).index (string);
}
return index_i;
}
/** find a character.
- @return
- the index of the leftmost character #c# (0 <= return < length ()),
- or -1 if not found.
+@return
+the index of the leftmost character #c# (0 <= return < length ()),
+or -1 if not found.
- ? should return length ()?, as in string.left_string (index (delimiter))
+? should return length ()?, as in string.left_string (index (delimiter))
*/
int
String::index (char c) const
{
- char const* me = strh_.to_str0 ();
- char const* p = (char const *) memchr (me,c, length ());
+ char const *me = strh_.to_str0 ();
+ char const *p = (char const *) memchr (me, c, length ());
if (p)
return p - me;
return -1;
}
/**
- find a substring.
+ find a substring.
- @return
- index of leftmost occurrence of #searchfor#
- */
+ @return
+ index of leftmost occurrence of #searchfor#
+*/
int
String::index (String searchfor) const
{
- char const* me = strh_.to_str0 ();
+ char const *me = strh_.to_str0 ();
- char const* p = (char const *)
+ char const *p = (char const *)
memmem (me, length (), searchfor.to_str0 (), searchfor.length ());
-
+
if (p)
return p - me;
/** find chars of a set.
- @return
-
- the index of the leftmost occurance of an element of #set#. -1 if
- nothing is found.
-
+@return
+the index of the leftmost occurance of an element of #set#. -1 if
+nothing is found.
*/
int
String::index_any (String set) const
if (!n)
return -1;
- void const * me = (void const *) strh_.to_str0 ();
- for (int i=0; i < set.length (); i++)
+ void const *me = (void const *) strh_.to_str0 ();
+ for (int i = 0; i < set.length (); i++)
{
- char * found= (char*) memchr (me, set[i], n );
- if (found)
+ char *found= (char *) memchr (me, set[i], n);
+ if (found)
{
- return found - (char const*)me;
+ return found - (char const *)me;
}
}
return -1;
if (n >= length ())
return *this;
- String retval;
+ String retval;
if (n < 1)
return retval;
-
+
retval = *this;
retval.strh_.trunc (n);
return retval;
{
if (n > length ())
return *this;
-
+
if (n < 1)
return "";
-
- return String (strh_.to_bytes () + length () - n, n);
-}
+ return String (strh_.to_bytes () + length () - n, n);
+}
String
String::nomid_string (int index_i, int n) const
{
- if (index_i < 0)
+ if (index_i < 0)
{
n += index_i;
index_i = 0;
}
if (n <= 0)
return *this;
-
+
return left_string (index_i) + right_string (length () - index_i - n);
}
String
String::cut_string (int index_i, int n) const
{
- if (index_i <0)
+ if (index_i <0)
{
n += index_i;
- index_i=0;
+ index_i = 0;
}
-
- if (!length () || (index_i < 0) || (index_i >= length () ) || (n < 1 ) )
+
+ if (!length () || (index_i < 0) || (index_i >= length ()) || (n < 1))
return String ();
- if ((n > length ()) || (index_i + n > length () ) )
+ if ((n > length ()) || (index_i + n > length ()))
n = length () - index_i;
return String (to_bytes () + index_i, n);
void
String::to_lower ()
{
- strnlwr (get_str0 (), length ());
+ strnlwr (get_str0 (), length ());
}
-void
+void
String::reverse ()
{
strrev (get_bytes (), length ());
#ifdef STREAM_SUPPORT
ostream &
-operator << (ostream& os, String d)
+operator<< (ostream& os, String d)
{
d.print_on (os);
return os;
/*
- stringutil.cc -- generate non-inline members.
+ stringutil.cc -- generate non-inline members.
This should be in a separate file, because one can include the .icc
only once.
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl> */
-#ifdef STRING_DEBUG
+#ifdef STRING_DEBUG
#define memmove mymemmove
#endif
#ifdef STRING_DEBUG
#include <sys/types.h>
#include <memory.h>
-void*
-mymemmove (void* dest, void const* src, size_t n)
+void *
+mymemmove (void *dest, void const *src, size_t n)
{
- return memcpy (dest, src, n);
+ return memcpy (dest, src, n);
}
#endif
virtual void derived_mark () const;
public:
SCM last_keysig_; // ugh.
-
+
/* Urgh. Since the accidentals depend on lots of variables, we have
- to store all information before we can really create the
- accidentals. */
+ to store all information before we can really create the
+ accidentals. */
Link_array<Grob> left_objects_;
Link_array<Grob> right_objects_;
Link_array<Spanner> ties_;
};
-
/*
TODO:
aren't. eg. localKeySignature is changed at runtime, which means
that references in grobs should always store ly_deep_copy ()s of
those.
- */
+*/
static void
set_property_on_children (Context *trans, char const *sym, SCM val)
void
Accidental_engraver::initialize ()
{
- update_local_key_signature ();
+ update_local_key_signature ();
}
-
/** Calculate the number of accidentals on basis of the current local key
sig (passed as argument)
-
+
* First check step+octave (taking into account barnumbers if necessary).
-
+
* Then check the global signature (only step).
-
+
Return number of accidentals (0, 1 or 2). */
static bool
if (scm_is_number (alteration_def)
|| laziness == SCM_BOOL_T)
return true;
-
+
return (bar_number <= scm_to_int (scm_cdr (alteration_def)) + scm_to_int (laziness));
}
SCM previous_alteration = SCM_BOOL_F;
-
SCM from_same_octave = ly_assoc_get (scm_cons (scm_int2num (o),
- scm_int2num (n)), sig, SCM_BOOL_F);
+ scm_int2num (n)), sig, SCM_BOOL_F);
SCM from_key_signature = ly_assoc_get (scm_int2num (n), sig, SCM_BOOL_F);
SCM from_other_octaves = SCM_BOOL_F;
- for (SCM s = sig ; scm_is_pair (s); s = scm_cdr (s))
+ for (SCM s = sig; scm_is_pair (s); s = scm_cdr (s))
{
SCM entry = scm_car (s);
if (scm_is_pair (scm_car (entry))
&& scm_cdar (entry) == scm_int2num (n))
- from_other_octaves = scm_cdr (entry);
+ from_other_octaves = scm_cdr (entry);
}
-
if (from_same_octave != SCM_BOOL_F
&& recent_enough (bar_number, from_same_octave, laziness))
{
previous_alteration = from_key_signature;
}
-
+
int num = 1;
if (is_tied (previous_alteration))
{
}
else
{
- int prev = extract_alteration (previous_alteration);
+ int prev = extract_alteration (previous_alteration);
int alter = pitch->get_alteration ();
-
+
if (alter == prev)
num = 0;
else if ((abs (alter) < abs (prev) || prev*alter < 0) && alter != 0)
*different = false;
if (scm_is_pair (accidentals) && !scm_is_symbol (scm_car (accidentals)))
- warning (_f ("Accidental typesetting list must begin with context-name: %s",
+ warning (_f ("Accidental typesetting list must begin with context-name: %s",
ly_scm2string (scm_car (accidentals)).to_str0 ()));
-
+
for (; scm_is_pair (accidentals) && origin;
accidentals = scm_cdr (accidentals))
{
SCM type = scm_car (rule);
SCM laziness = scm_cdr (rule);
SCM localsig = origin->get_property ("localKeySignature");
-
- bool same_octave_b =
- scm_is_eq (ly_symbol2scm ("same-octave"), type);
- bool any_octave_b =
- scm_is_eq (ly_symbol2scm ("any-octave"), type);
+
+ bool same_octave_b
+ = scm_is_eq (ly_symbol2scm ("same-octave"), type);
+ bool any_octave_b
+ = scm_is_eq (ly_symbol2scm ("any-octave"), type);
if (same_octave_b || any_octave_b)
{
int n = number_accidentals_from_sig
(&d, localsig, pitch, bar_number, laziness, any_octave_b);
*different = *different || d;
- number = max (number, n);
+ number = max (number, n);
}
else
- warning (_f ("ignoring unknown accidental: %s",
+ warning (_f ("ignoring unknown accidental: %s",
ly_symbol2string (type).to_str0 ()));
}
-
/*
if symbol then it is a context name. Scan parent contexts to find it.
Context *dad = origin;
while (dad && !dad->is_alias (rule))
dad = dad->get_parent_context ();
-
+
if (dad)
origin = dad;
}
- else warning (_f ("Accidental rule must be pair or context-name; Found %s",
+ else warning (_f ("Accidental rule must be pair or context-name; Found %s",
ly_scm2string (rule).to_str0 ()));
}
SCM smp = get_property ("measurePosition");
int bn = robust_scm2int (barnum, 0);
-
- Moment mp = robust_scm2moment (smp, Moment (0));
+
+ Moment mp = robust_scm2moment (smp, Moment (0));
if (mp.main_part_ < Rational (0))
bn--;
-
+
return bn;
}
{
if (accidentals_.size () && !accidentals_.top ().done_)
{
- SCM accidentals = get_property ("autoAccidentals");
- SCM cautionaries = get_property ("autoCautionaries");
+ SCM accidentals = get_property ("autoAccidentals");
+ SCM cautionaries = get_property ("autoCautionaries");
int barnum = get_bar_number ();
-
+
bool extra_natural_b = get_property ("extraNatural") == SCM_BOOL_T;
- for (int i = 0; i < accidentals_.size (); i++)
+ for (int i = 0; i < accidentals_.size (); i++)
{
- if (accidentals_[i].done_ )
+ if (accidentals_[i].done_)
continue;
- accidentals_[i].done_ = true;
+ accidentals_[i].done_ = true;
Grob *support = accidentals_[i].head_;
Music *note = accidentals_[i].melodic_;
Context *origin = accidentals_[i].origin_;
bool different = false;
bool different_caut = false;
-
+
int num = number_accidentals (&different,
pitch, origin,
accidentals, barnum);
cautionaries, barnum);
bool cautionary = to_boolean (note->get_property ("cautionary"));
-
+
if (num_caut > num)
{
num = num_caut;
if (num == 0 && to_boolean (note->get_property ("force-accidental")))
num = 1;
-
/*
Can not look for ties: it's not guaranteed that they reach
us before the notes
- */
-
+ */
+
if (num)
{
/*
We construct the accidentals at the originating Voice
level, so that we get the property settings for
Accidental from the respective Voice.
- */
+ */
Grob *a
= make_item_from_properties (accidentals_[i].origin_trans_,
ly_symbol2scm ("Accidental"),
note->self_scm (),
- "Accidental"
- );
+ "Accidental");
a->set_parent (support, Y_AXIS);
if (!accidental_placement_)
if (cautionary)
a->set_property ("cautionary", SCM_BOOL_T);
-
+
support->set_property ("accidental-grob", a->self_scm ());
a->set_property ("accidentals", accs);
We add the accidentals to the support of the arpeggio,
so it is put left of the accidentals.
*/
- for (int i = 0; i < left_objects_.size (); i++)
+ for (int i = 0; i < left_objects_.size (); i++)
Side_position_interface::add_support (left_objects_[i], a);
- for (int i = 0; i < right_objects_.size (); i++)
+ for (int i = 0; i < right_objects_.size (); i++)
Side_position_interface::add_support (a, right_objects_[i]);
}
}
for (int j = ties_.size (); j--;)
{
Grob *r = Tie::head (ties_[j], RIGHT);
- for (int i = accidentals_.size (); i--;)
+ for (int i = accidentals_.size (); i--;)
if (accidentals_[i].head_ == r)
{
if (Grob *g = accidentals_[i].accidental_)
}
}
- for (int i = accidentals_.size (); i--;)
+ for (int i = accidentals_.size (); i--;)
{
int barnum = get_bar_number ();
Music *note = accidentals_[i].melodic_;
- Context * origin = accidentals_[i].origin_;
+ Context *origin = accidentals_[i].origin_;
Pitch *pitch = unsmob_pitch (note->get_property ("pitch"));
if (!pitch)
&& origin->where_defined (ly_symbol2scm ("localKeySignature")))
{
/*
- huh? we set props all the way to the top?
+ huh? we set props all the way to the top?
*/
SCM localsig = origin->get_property ("localKeySignature");
bool change = false;
&& note->is_mus_type ("note-event")
&& Rhythmic_head::has_interface (info.grob_))
{
- if (to_boolean ( get_property ("harmonicAccidentals"))
+ if (to_boolean (get_property ("harmonicAccidentals"))
|| !ly_c_equal_p (info.grob_->get_property ("style"),
- ly_symbol2scm ("harmonic")))
+ ly_symbol2scm ("harmonic")))
{
-
- Accidental_entry entry ;
+
+ Accidental_entry entry;
entry.head_ = info.grob_;
- entry.origin_trans_ = dynamic_cast<Engraver*> (info.origin_trans_);
+ entry.origin_trans_ = dynamic_cast<Engraver *> (info.origin_trans_);
entry.origin_ = info.origin_trans_->context ();
entry.melodic_ = note;
}
}
else if (Tie::has_interface (info.grob_))
- ties_.push (dynamic_cast<Spanner*> (info.grob_));
+ ties_.push (dynamic_cast<Spanner *> (info.grob_));
else if (Arpeggio::has_interface (info.grob_))
- left_objects_.push (info.grob_);
+ left_objects_.push (info.grob_);
else if (info.grob_
->internal_has_interface (ly_symbol2scm ("finger-interface")))
- left_objects_.push (info.grob_);
+ left_objects_.push (info.grob_);
}
void
}
ADD_TRANSLATOR (Accidental_engraver,
- "Make accidentals. "
- "Catch note heads, ties and notices key-change events. "
- "This engraver usually lives at Staff level, but "
- "reads the settings for Accidental at @code{Voice} level, "
- "so you can @code{\\override} them at @code{Voice}. "
- ,
- "Accidental"
- ,
- ""
- ,
- "arpeggio-interface "
- "finger-interface "
- "rhythmic-head-interface "
- "tie-interface "
- ,
- "autoAccidentals "
- "autoCautionaries "
- "extraNatural "
- "harmonicAccidentals "
- "localKeySignature"
- ,
- "localKeySignature"
- );
+ "Make accidentals. "
+ "Catch note heads, ties and notices key-change events. "
+ "This engraver usually lives at Staff level, but "
+ "reads the settings for Accidental at @code{Voice} level, "
+ "so you can @code{\\override} them at @code{Voice}. ",
+ "Accidental",
+ "",
+ "arpeggio-interface "
+ "finger-interface "
+ "rhythmic-head-interface "
+ "tie-interface ",
+ "autoAccidentals "
+ "autoCautionaries "
+ "extraNatural "
+ "harmonicAccidentals "
+ "localKeySignature",
+ "localKeySignature");
-/*
- accidental-placement.cc -- implement Accidental_placement
-
- source file of the GNU LilyPond music typesetter
+/*
+ accidental-placement.cc -- implement Accidental_placement
- (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ source file of the GNU LilyPond music typesetter
+ (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include <math.h>
-
#include "accidental-placement.hh"
#include "libc-extension.hh" // isinf
#include "skyline.hh"
MAKE_SCHEME_CALLBACK (Accidental_placement, alignment_callback, 2);
SCM
-Accidental_placement::alignment_callback (SCM s, SCM )
+Accidental_placement::alignment_callback (SCM s, SCM)
{
- Grob * me = unsmob_grob (s);
+ Grob *me = unsmob_grob (s);
- Grob * par = me->get_parent (X_AXIS);
+ Grob *par = me->get_parent (X_AXIS);
if (!to_boolean (par->get_property ("positioning-done")))
{
par->set_property ("positioning-done", SCM_BOOL_T);
return scm_int2num (0);
}
-
void
-Accidental_placement::add_accidental (Grob* me, Grob* a)
+Accidental_placement::add_accidental (Grob *me, Grob *a)
{
a->set_parent (me, X_AXIS);
a->add_offset_callback (alignment_callback_proc, X_AXIS);
SCM cause = a->get_parent (Y_AXIS)->get_property ("cause");
- Music *mcause = unsmob_music (cause);
+ Music *mcause = unsmob_music (cause);
if (!mcause)
{
programming_error ("Note head has no music cause!");
- return;
+ return;
}
Pitch *p = unsmob_pitch (mcause->get_property ("pitch"));
entry = scm_cons (a->self_scm (), entry);
- accs = scm_assq_set_x (accs, key, entry);
+ accs = scm_assq_set_x (accs, key, entry);
me->set_property ("accidental-grobs", accs);
}
/*
Split into break reminders.
- */
+*/
void
-Accidental_placement::split_accidentals (Grob * accs,
+Accidental_placement::split_accidentals (Grob *accs,
Link_array<Grob> *break_reminder,
Link_array<Grob> *real_acc)
{
Accidental_placement::split_accidentals (me, &br, &ra);
br.concat (ra);
-
- if (dynamic_cast<Item*>(left_object)->break_status_dir () == RIGHT)
- which = & br;
+
+ if (dynamic_cast<Item *> (left_object)->break_status_dir () == RIGHT)
+ which = &br;
else
- which = & ra;
-
+ which = &ra;
+
Interval extent;
for (int i = 0; i < which->size (); i++)
{
Real p = robust_scm2double (me->get_property ("left-padding"), 0.2);
extent[LEFT] -= p;
}
-
+
return extent;
}
-
-
struct Accidental_placement_entry
{
Array<Skyline_entry> left_skyline_;
Interval vertical_extent_;
Array<Box> extents_;
Link_array<Grob> grobs_;
- Real offset_;
+ Real offset_;
int notename_;
Accidental_placement_entry ()
{
};
static Interval all_accidental_vertical_extent;
-Real ape_priority (Accidental_placement_entry const * a)
+Real ape_priority (Accidental_placement_entry const *a)
{
return a->vertical_extent_[UP];
}
-
-
int ape_compare (Accidental_placement_entry *const &a,
Accidental_placement_entry *const &b)
{
}
int ape_rcompare (Accidental_placement_entry *const &a,
- Accidental_placement_entry *const &b)
+ Accidental_placement_entry *const &b)
{
return -sign (ape_priority (a) - ape_priority (b));
}
-
/*
-
-TODO: should favor
+ TODO: should favor
b
- b
+ b
-placement
-
+ placement
*/
void
stagger_apes (Link_array<Accidental_placement_entry> *apes)
{
Link_array<Accidental_placement_entry> asc = *apes;
-
asc.sort (&ape_compare);
apes->clear ();
int parity = 1;
while (i < asc.size ())
{
- Accidental_placement_entry * a = 0;
+ Accidental_placement_entry *a = 0;
if (parity)
a = asc.pop ();
else
apes->reverse ();
}
-
-
/*
-
This routine computes placements of accidentals. During
add_accidental (), accidentals are already grouped by note, so that
octaves are placed above each other; they form columns. Then the
columns are sorted: the biggest columns go closest to the note.
Then the columns are spaced as closely as possible (using skyline
spacing).
-
-
+
+
TODO: more advanced placement. Typically, the accs should be placed
to form a C shape, like this
-
- ##
- b b
- # #
- b
- b b
- The naturals should be left of the C as well; they should
- be separate accs.
+ ##
+ b b
+ # #
+ b
+ b b
- Note that this placement problem looks NP hard, so we just use a
- simple strategy, not an optimal choice.
+ The naturals should be left of the C as well; they should
+ be separate accs.
+ Note that this placement problem looks NP hard, so we just use a
+ simple strategy, not an optimal choice.
*/
/*
TODO: there should be more space in the following situation
- Natural + downstem
+ Natural + downstem
- |_
- | | X
- |_| |
- | |
-
- */
+ |_
+ | | X
+ |_| |
+ | |
+*/
SCM
-Accidental_placement::position_accidentals (Grob * me)
+Accidental_placement::position_accidentals (Grob *me)
{
if (!me->is_live ())
return SCM_UNSPECIFIED;
-
+
SCM accs = me->get_property ("accidental-grobs");
if (!scm_is_pair (accs))
return SCM_UNSPECIFIED;
-
+
/*
TODO: there is a bug in this code. If two accs are on the same
Y-position, they share an Ape, and will be printed in overstrike.
- */
+ */
Link_array<Accidental_placement_entry> apes;
for (SCM s = accs; scm_is_pair (s); s = scm_cdr (s))
{
Accidental_placement_entry *ape = new Accidental_placement_entry;
ape->notename_ = scm_to_int (scm_caar (s));
-
+
for (SCM t = scm_cdar (s); scm_is_pair (t); t = scm_cdr (t))
ape->grobs_.push (unsmob_grob (scm_car (t)));
/*
First we must extract *all* pointers. We can only determine
extents if we're sure that we've found the right common refpoint
- */
+ */
Link_array<Grob> note_cols, heads;
for (int i = apes.size (); i--;)
- {
- Accidental_placement_entry * ape = apes[i];
+ {
+ Accidental_placement_entry *ape = apes[i];
for (int j = ape->grobs_.size (); j--;)
{
- Grob * a = ape->grobs_[j];
+ Grob *a = ape->grobs_[j];
if (common[Y_AXIS])
common[Y_AXIS] = common[Y_AXIS]->common_refpoint (a, Y_AXIS);
else
common[Y_AXIS] = a;
-
+
Grob *head = a->get_parent (Y_AXIS);
- Grob * col = head->get_parent (X_AXIS);
+ Grob *col = head->get_parent (X_AXIS);
if (Note_column::has_interface (col))
note_cols.push (col);
else
/*
This is a little kludgy: to get all notes, we look if there are
collisions as well.
- */
- for (int i = note_cols.size () ; i--;)
+ */
+ for (int i = note_cols.size (); i--;)
{
Grob *c = note_cols[i]->get_parent (X_AXIS);
if (Note_collision_interface::has_interface (c))
{
- Link_array<Grob> gs =
- extract_grob_array (c, ly_symbol2scm ("elements"));
-
+ Link_array<Grob> gs
+ = extract_grob_array (c, ly_symbol2scm ("elements"));
+
note_cols.concat (gs);
}
}
-
- for (int i = note_cols.size () ; i--;)
+
+ for (int i = note_cols.size (); i--;)
{
heads.concat (extract_grob_array (note_cols[i], ly_symbol2scm ("note-heads")));
}
heads.uniq ();
common[Y_AXIS] = common_refpoint_of_array (heads, common[Y_AXIS], Y_AXIS);
-
for (int i = apes.size (); i--;)
{
- Accidental_placement_entry * ape = apes[i];
+ Accidental_placement_entry *ape = apes[i];
ape->left_skyline_ = empty_skyline (LEFT);
ape->right_skyline_ = empty_skyline (RIGHT);
-
+
for (int j = apes[i]->grobs_.size (); j--;)
{
- Grob * a = apes[i]->grobs_[j];
+ Grob *a = apes[i]->grobs_[j];
Array<Box> boxes = Accidental_interface::accurate_boxes (a, common);
-
+
ape->extents_.concat (boxes);
- for (int j = boxes.size (); j--;)
+ for (int j = boxes.size (); j--;)
{
insert_extent_into_skyline (&ape->left_skyline_, boxes[j], Y_AXIS, LEFT);
- insert_extent_into_skyline (&ape->right_skyline_ , boxes[j], Y_AXIS, RIGHT);
+ insert_extent_into_skyline (&ape->right_skyline_, boxes[j], Y_AXIS, RIGHT);
}
}
}
-
Interval total;
for (int i = apes.size (); i--;)
{
- Interval y ;
-
+ Interval y;
+
for (int j = apes[i]->extents_.size (); j--;)
{
y.unite (apes[i]->extents_[j][Y_AXIS]);
all_accidental_vertical_extent = total;
stagger_apes (&apes);
- Accidental_placement_entry * head_ape = new Accidental_placement_entry;
- common[X_AXIS] = common_refpoint_of_array (heads, common[X_AXIS], X_AXIS);
+ Accidental_placement_entry *head_ape = new Accidental_placement_entry;
+ common[X_AXIS] = common_refpoint_of_array (heads, common[X_AXIS], X_AXIS);
Array<Skyline_entry> head_skyline (empty_skyline (LEFT));
Array<Box> head_extents;
for (int i = heads.size (); i--;)
{
- Box b (heads[i]->extent (common[X_AXIS] , X_AXIS),
- heads[i]->extent (common[Y_AXIS], Y_AXIS));
+ Box b (heads[i]->extent (common[X_AXIS], X_AXIS),
+ heads[i]->extent (common[Y_AXIS], Y_AXIS));
- insert_extent_into_skyline (&head_skyline, b , Y_AXIS, LEFT);
+ insert_extent_into_skyline (&head_skyline, b, Y_AXIS, LEFT);
}
head_ape-> left_skyline_ = head_skyline;
-robust_scm2double (me->get_property ("right-padding"), 0));
/*
Add accs entries right-to-left.
- */
+ */
for (int i = apes.size (); i-- > 0;)
{
- Real offset =
- -skyline_meshing_distance (apes[i]->right_skyline_, left_skyline);
+ Real offset
+ = -skyline_meshing_distance (apes[i]->right_skyline_, left_skyline);
if (isinf (offset))
- offset = (i < apes.size () - 1) ? apes[i+1]->offset_ : 0.0;
+ offset = (i < apes.size () - 1) ? apes[i + 1]->offset_ : 0.0;
else
offset -= padding;
heighten_skyline (&new_left_skyline, apes[i]->offset_);
merge_skyline (&new_left_skyline, left_skyline, LEFT);
left_skyline = new_left_skyline;
- }
+ }
for (int i = apes.size (); i--;)
{
- Accidental_placement_entry* ape = apes[i];
- for (int j = ape->grobs_.size (); j--;)
+ Accidental_placement_entry *ape = apes[i];
+ for (int j = ape->grobs_.size (); j--;)
{
ape->grobs_[j]->translate_axis (ape->offset_, X_AXIS);
}
}
-
Interval left_extent, right_extent;
Accidental_placement_entry *ape = apes[0];
for (int i = ape->extents_.size (); i--;)
- left_extent.unite (ape->offset_ + ape->extents_[i][X_AXIS]);
+ left_extent.unite (ape->offset_ + ape->extents_[i][X_AXIS]);
ape = apes.top ();
for (int i = ape->extents_.size (); i--;)
- right_extent.unite (ape->offset_ + ape->extents_[i][X_AXIS]);
+ right_extent.unite (ape->offset_ + ape->extents_[i][X_AXIS]);
-
left_extent[LEFT] -= robust_scm2double (me->get_property ("left-padding"), 0);
Interval width (left_extent[LEFT], right_extent[RIGHT]);
SCM scm_width = ly_interval2scm (width);
me->set_extent (scm_width, X_AXIS);
-
+
for (int i = apes.size (); i--;)
delete apes[i];
}
ADD_INTERFACE (Accidental_placement,
- "accidental-placement-interface",
- "Resolve accidental collisions.",
- "left-padding padding right-padding accidental-grobs positioning-done")
+ "accidental-placement-interface",
+ "Resolve accidental collisions.",
+ "left-padding padding right-padding accidental-grobs positioning-done")
accidental.cc -- implement Accidental_interface
source file of the GNU LilyPond music typesetter
-
+
(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "pitch.hh"
/*
-
TODO: insert support for smaller cautionaries, tie-break-reminders.
Either here or in new-accidental-engraver.
'accidentals should go, for a single 'accidental property -- see
accidental-placement.cc
-
*/
Stencil
-parenthesize (Grob*me, Stencil m)
+parenthesize (Grob *me, Stencil m)
{
Stencil open = Font_interface::get_default_font (me)->find_by_name ("accidentals.leftparen");
Stencil close = Font_interface::get_default_font (me)->find_by_name ("accidentals.rightparen");
return m;
}
-
MAKE_SCHEME_CALLBACK (Accidental_interface, after_line_breaking, 1);
SCM
Accidental_interface::after_line_breaking (SCM smob)
{
- Grob *me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
Grob *tie = unsmob_grob (me->get_property ("tie"));
if (tie && !tie->original_)
}
Array<Box>
-Accidental_interface::accurate_boxes (Grob *a, Grob**common)
+Accidental_interface::accurate_boxes (Grob *a, Grob **common)
{
Box b;
b[X_AXIS] = a->extent (a, X_AXIS);
b[Y_AXIS] = a->extent (a, Y_AXIS);
Array<Box> boxes;
-
+
bool parens = false;
if (to_boolean (a->get_property ("cautionary")))
{
&& scm_ilength (accs) == 1)
{
switch (scm_to_int (scm_car (accs))
- {
- case FLAT:
{
- Box stem = b;
- Box bulb = b;
+ case FLAT:
+ {
+ Box stem = b;
+ Box bulb = b;
+
+ /*
+ we could make the stem thinner, but that places the flats
+ really close.
+ */
+ stem[X_AXIS][RIGHT] *= .5;
+
+ /*
+ To prevent vertical alignment for 6ths
+ */
+ stem[Y_AXIS] *= 1.1;
+ bulb[Y_AXIS][UP] *= .35;
+
+ boxes.push (bulb);
+ boxes.push (stem);
+ }
+ break;
+ case NATURAL:
+ {
+ Box lstem = b;
+ Box rstem = b;
+ Box belly = b;
+ lstem[Y_AXIS] *= 1.1;
+ rstem[Y_AXIS] *= 1.1;
+
+ belly[Y_AXIS] *= 0.75;
+ lstem[X_AXIS][RIGHT] *= .5;
+ rstem[X_AXIS][LEFT] = lstem[X_AXIS][RIGHT];
+ lstem[Y_AXIS][DOWN] = belly[Y_AXIS][DOWN];
+ rstem[Y_AXIS][UP] = belly[Y_AXIS][UP];
+ boxes.push (belly);
+ boxes.push (lstem);
+ boxes.push (rstem);
+ }
+ break;
/*
- we could make the stem thinner, but that places the flats
- really close.
+ TODO: add support for, double flat.
*/
- stem[X_AXIS][RIGHT] *= .5;
+ }
- /*
- To prevent vertical alignment for 6ths
- */
- stem[Y_AXIS] *= 1.1;
- bulb[Y_AXIS][UP] *= .35;
+ if (!boxes.size ())
+ boxes.push (b);
+
+ Offset o (a->relative_coordinate (common[X_AXIS], X_AXIS),
+ a->relative_coordinate (common[Y_AXIS], Y_AXIS));
+ for (int i = boxes.size (); i--;)
+ {
+ boxes[i].translate (o);
+ }
+
+ return boxes;
+ }
- boxes.push (bulb);
- boxes.push (stem);
- }
- break;
- case NATURAL:
- {
- Box lstem = b;
- Box rstem = b;
- Box belly = b;
-
- lstem[Y_AXIS] *= 1.1;
- rstem[Y_AXIS] *= 1.1;
-
- belly[Y_AXIS] *= 0.75;
- lstem[X_AXIS][RIGHT] *= .5;
- rstem[X_AXIS][LEFT] = lstem[X_AXIS][RIGHT];
- lstem[Y_AXIS][DOWN] = belly[Y_AXIS][DOWN];
- rstem[Y_AXIS][UP] = belly[Y_AXIS][UP];
- boxes.push (belly);
- boxes.push (lstem);
- boxes.push (rstem);
- }
- break;
/*
- TODO: add support for, double flat.
+ * Some styles do not provide all flavours of accidentals, e.g. there
+ * is currently no sharp accidental in vaticana style. In these cases
+ * this function falls back to one of the other styles.
*/
- }
-
- if (!boxes.size ())
- boxes.push (b);
- Offset o (a->relative_coordinate (common[X_AXIS], X_AXIS),
- a->relative_coordinate (common[Y_AXIS], Y_AXIS));
- for (int i = boxes.size (); i--;)
- {
- boxes[i].translate (o);
- }
-
- return boxes;
-}
+ /*
+ todo: this sort of stuff in Scheme. --hwn.
+ */
+ String
+ Accidental_interface::get_fontcharname (String style, int alteration)
+ {
+ if (alteration == DOUBLE_FLAT
+ || alteration == DOUBLE_SHARP)
+ {
+ return to_string (alteration);
+ }
-/*
- * Some styles do not provide all flavours of accidentals, e.g. there
- * is currently no sharp accidental in vaticana style. In these cases
- * this function falls back to one of the other styles.
- */
+ if (style == "hufnagel")
+ switch (alteration)
+ {
+ case FLAT: return "hufnagel-1";
+ case 0: return "vaticana0";
+ case SHARP: return "mensural1";
+ }
+ if (style == "medicaea")
+ switch (alteration)
+ {
+ case FLAT: return "medicaea-1";
+ case 0: return "vaticana0";
+ case SHARP: return "mensural1";
+ }
+ if (style == "vaticana")
+ switch (alteration)
+ {
+ case FLAT: return "vaticana-1";
+ case 0: return "vaticana0";
+ case SHARP: return "mensural1";
+ }
+ if (style == "mensural")
+ switch (alteration)
+ {
+ case FLAT: return "mensural-1";
+ case 0: return "vaticana0";
+ case SHARP: return "mensural1";
+ }
-/*
- todo: this sort of stuff in Scheme. --hwn.
- */
-String
-Accidental_interface::get_fontcharname (String style, int alteration)
-{
- if (alteration == DOUBLE_FLAT
- || alteration == DOUBLE_SHARP)
- {
- return to_string (alteration);
- }
-
- if (style == "hufnagel")
- switch (alteration)
- {
- case FLAT: return "hufnagel-1";
- case 0: return "vaticana0";
- case SHARP: return "mensural1";
- }
- if (style == "medicaea")
- switch (alteration)
- {
- case FLAT: return "medicaea-1";
- case 0: return "vaticana0";
- case SHARP: return "mensural1";
+ if (style == "neomensural")
+ style = ""; // currently same as default
+ if (style == "default")
+ style = "";
+ return style + to_string (alteration);
}
- if (style == "vaticana")
- switch (alteration)
- {
- case FLAT: return "vaticana-1";
- case 0: return "vaticana0";
- case SHARP: return "mensural1";
- }
- if (style == "mensural")
- switch (alteration)
+
+ MAKE_SCHEME_CALLBACK (Accidental_interface, print, 1);
+ SCM
+ Accidental_interface::print (SCM smob)
{
- case FLAT: return "mensural-1";
- case 0: return "vaticana0";
- case SHARP: return "mensural1";
- }
-
- if (style == "neomensural")
- style = ""; // currently same as default
- if (style == "default")
- style = "";
- return style + to_string (alteration);
-}
+ Grob *me = unsmob_grob (smob);
+ bool smaller = false;
+ bool parens = false;
-MAKE_SCHEME_CALLBACK (Accidental_interface, print, 1);
-SCM
-Accidental_interface::print (SCM smob)
-{
- Grob *me = unsmob_grob (smob);
- bool smaller = false;
- bool parens = false;
+ bool caut = to_boolean (me->get_property ("cautionary"));
+ if (caut)
+ {
+ SCM cstyle = me->get_property ("cautionary-style");
+ parens = ly_c_equal_p (cstyle, ly_symbol2scm ("parentheses"));
+ smaller = ly_c_equal_p (cstyle, ly_symbol2scm ("smaller"));
+ }
- bool caut = to_boolean (me->get_property ("cautionary"));
- if (caut)
- {
- SCM cstyle = me->get_property ("cautionary-style");
- parens = ly_c_equal_p (cstyle, ly_symbol2scm ("parentheses"));
- smaller = ly_c_equal_p (cstyle, ly_symbol2scm ("smaller"));
- }
+ SCM scm_style = me->get_property ("style");
+ String style;
+ if (scm_is_symbol (scm_style))
+ {
+ style = ly_symbol2string (scm_style);
+ }
+ else
+ {
+ /*
+ preferably no name for the default style.
+ */
+ style = "";
+ }
- SCM scm_style = me->get_property ("style");
- String style;
- if (scm_is_symbol (scm_style))
- {
- style = ly_symbol2string (scm_style);
- }
- else
- {
- /*
- preferably no name for the default style.
- */
- style = "";
- }
+ Font_metric *fm = 0;
+ if (smaller)
+ {
+ SCM ac = Font_interface::music_font_alist_chain (me);
+ /*
+ TODO: should calc font-size by adding -2 to current font-size
+ */
+ ac = scm_cons (scm_list_1 (scm_cons
+ (ly_symbol2scm ("font-size"),
+ scm_int2num (-2))),
+ ac);
+ fm = select_font (me->get_layout (), ac);
+ }
+ else
+ fm = Font_interface::get_default_font (me);
- Font_metric *fm = 0;
- if (smaller)
- {
- SCM ac = Font_interface::music_font_alist_chain (me);
- /*
- TODO: should calc font-size by adding -2 to current font-size
- */
- ac = scm_cons (scm_list_1 (scm_cons
- (ly_symbol2scm ("font-size"),
- scm_int2num (-2))),
- ac);
- fm = select_font (me->get_layout (), ac);
- }
- else
- fm = Font_interface::get_default_font (me);
+ Stencil mol;
+ for (SCM s = me->get_property ("accidentals");
+ scm_is_pair (s); s = scm_cdr (s))
+ {
+ int alteration = scm_to_int (scm_car (s));
+ String font_char = get_fontcharname (style, alteration);
+ Stencil acc (fm->find_by_name ("accidentals." + font_char));
- Stencil mol;
- for (SCM s = me->get_property ("accidentals");
- scm_is_pair (s); s = scm_cdr (s))
- {
- int alteration = scm_to_int (scm_car (s));
- String font_char = get_fontcharname (style, alteration);
- Stencil acc (fm->find_by_name ("accidentals." + font_char));
-
- if (acc.is_empty ())
- {
- me->warning (_f ("accidental `%s' not found", font_char));
- }
- else
- {
- mol.add_at_edge (X_AXIS, RIGHT, acc, 0.1, 0);
- }
- }
+ if (acc.is_empty ())
+ {
+ me->warning (_f ("accidental `%s' not found", font_char));
+ }
+ else
+ {
+ mol.add_at_edge (X_AXIS, RIGHT, acc, 0.1, 0);
+ }
+ }
- if (parens)
- mol = parenthesize (me, mol);
+ if (parens)
+ mol = parenthesize (me, mol);
- return mol.smobbed_copy ();
-}
+ return mol.smobbed_copy ();
+ }
+ /*
+ TODO: should move inside-slur into item?
-/*
- TODO: should move inside-slur into item?
-
- */
-ADD_INTERFACE (Accidental_interface, "accidental-interface",
- "a single accidental",
- "inside-slur cautionary cautionary-style style tie accidentals");
+ */
+ ADD_INTERFACE (Accidental_interface, "accidental-interface",
+ "a single accidental",
+ "inside-slur cautionary cautionary-style style tie accidentals");
-/*
+/*
afm.cc -- implement Adobe_font_metric
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "afm.hh"
checksum_ = 0;
font_info_ = fi;
design_size_ = 1.0;
-
+
for (int i = 256 >? fi->numOfChars; i--;)
ascii_to_metric_idx_.push (-1);
-
+
for (int i = 0; i < fi->numOfChars; i++)
{
- AFM_CharMetricInfo * c = fi->cmi + i;
+ AFM_CharMetricInfo *c = fi->cmi + i;
/* Some TeX afm files contain code = -1. We don't know why,
- let's ignore it. */
+ let's ignore it. */
if (c->code >= 0)
ascii_to_metric_idx_[c->code] = i;
name_to_metric_dict_[c->name] = i;
{
Adobe_font_metric *fm = new Adobe_font_metric (fi);
fm->checksum_ = checksum;
- fm->design_size_ = design_size;
- return fm->self_scm ();
+ fm->design_size_ = design_size;
+ return fm->self_scm ();
}
-AFM_CharMetricInfo const*
+AFM_CharMetricInfo const *
Adobe_font_metric::find_ascii_metric (int a) const
{
if (ascii_to_metric_idx_[a] >= 0)
return 0;
}
-AFM_CharMetricInfo const*
+AFM_CharMetricInfo const *
Adobe_font_metric::find_char_metric (String nm) const
{
int idx = name_to_index (nm);
int
Adobe_font_metric::name_to_index (String name) const
{
- std::map<String, int>::const_iterator ai = name_to_metric_dict_.find (name);
+ std::map < String, int>::const_iterator ai = name_to_metric_dict_.find (name);
if (ai == name_to_metric_dict_.end ())
return -1;
- return (*ai).second;
+ return (*ai).second;
}
int
AFM_CharMetricInfo const *c = find_ascii_metric (code);
Box b (Interval (0, 0), Interval (0, 0));
if (c)
- b = afm_bbox_to_box (c->charBBox);
+ b = afm_bbox_to_box (c->charBBox);
return b;
}
SCM
read_afm_file (String nm)
{
- FILE *f = fopen (nm.to_str0 () , "r");
+ FILE *f = fopen (nm.to_str0 (), "r");
char s[2048] = "";
char *check_key = "Comment TfmCheckSum";
char *size_key = "Comment DesignSize";
unsigned int cs = 0;
Real ds = 1.0;
-
+
/* Assume check_key in first 10 lines */
for (int i = 0; i < 10; i++)
{
else if (strncmp (s, size_key, strlen (size_key)) == 0)
sscanf (s + strlen (size_key), "%lf", &ds);
}
-
+
rewind (f);
-
+
AFM_Font_info *fi;
int ok = AFM_parseFile (f, &fi, ~0);
Real
Adobe_font_metric::design_size () const
{
- return design_size_;
+ return design_size_;
}
-
-
String
Adobe_font_metric::font_name () const
{
-/*
+/*
align-interface.cc -- implement Align_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "align-interface.hh"
SCM
Align_interface::alignment_callback (SCM element_smob, SCM axis)
{
- Grob * me = unsmob_grob (element_smob);
+ Grob *me = unsmob_grob (element_smob);
Axis ax = (Axis)scm_to_int (axis);
- Grob * par = me->get_parent (ax);
+ Grob *par = me->get_parent (ax);
if (par && !to_boolean (par->get_property ("positioning-done")))
{
Align_interface::align_elements_to_extents (par, ax);
SCM
Align_interface::fixed_distance_alignment_callback (SCM element_smob, SCM axis)
{
- Grob * me = unsmob_grob (element_smob);
+ Grob *me = unsmob_grob (element_smob);
Axis ax = (Axis)scm_to_int (axis);
- Grob * par = me->get_parent (ax);
+ Grob *par = me->get_parent (ax);
if (par && !to_boolean (par->get_property ("positioning-done")))
{
Align_interface::align_to_fixed_distance (par, ax);
}
/*
- merge with align-to-extents?
- */
+ merge with align-to-extents?
+*/
void
-Align_interface::align_to_fixed_distance (Grob *me , Axis a)
+Align_interface::align_to_fixed_distance (Grob *me, Axis a)
{
me->set_property ("positioning-done", SCM_BOOL_T);
-
- SCM d = me->get_property ("stacking-dir");
-
+
+ SCM d = me->get_property ("stacking-dir");
+
Direction stacking_dir = scm_is_number (d) ? to_dir (d) : CENTER;
if (!stacking_dir)
stacking_dir = DOWN;
Real dy = robust_scm2double (me->get_property ("forced-distance"), 0.0);
-
+
Link_array<Grob> elems
= extract_grob_array (me, ly_symbol2scm ("elements"));
Interval v;
v.set_empty ();
Array<Real> translates;
-
- for (int j = elems.size (); j--; )
+
+ for (int j = elems.size (); j--;)
{
/*
This is not very elegant, in that we need special support for
force_hara_kiri_callback () (extent and offset callback) is
such that we might get into a loop if we call extent () or
offset () the elements.
-
-
- */
+
+
+ */
if (a == Y_AXIS
&& Hara_kiri_group_spanner::has_interface (elems[j]))
Hara_kiri_group_spanner::consider_suicide (elems[j]);
/*
TODO: support self-alignment-{Y, X}
- */
+ */
for (int i = 0; i < translates.size (); i++)
{
elems[i]->translate_axis (translates[i] - v.center (), a);
align_to_fixed_distance ().
*/
void
-Align_interface::align_elements_to_extents (Grob * me, Axis a)
+Align_interface::align_elements_to_extents (Grob *me, Axis a)
{
me->set_property ("positioning-done", SCM_BOOL_T);
-
- SCM d = me->get_property ("stacking-dir");
-
+
+ SCM d = me->get_property ("stacking-dir");
+
Direction stacking_dir = scm_is_number (d) ? to_dir (d) : CENTER;
if (!stacking_dir)
stacking_dir = DOWN;
-
+
Interval threshold = robust_scm2interval (me->get_property ("threshold"),
Interval (0, Interval::infinity ()));
-
+
Array<Interval> dims;
Link_array<Grob> elems;
Link_array<Grob> all_grobs
= extract_grob_array (me, ly_symbol2scm ("elements"));
- for (int i = 0; i < all_grobs.size (); i++)
+ for (int i = 0; i < all_grobs.size (); i++)
{
Interval y = all_grobs[i]->extent (me, a);
if (!y.is_empty ())
{
- Grob *e = dynamic_cast<Grob*> (all_grobs[i]);
+ Grob *e = dynamic_cast<Grob *> (all_grobs[i]);
elems.push (e);
- dims.push (y);
+ dims.push (y);
}
}
-
-
+
/*
Read self-alignment-X and self-alignment-Y. This may seem like
code duplication. (and really: it is), but this is necessary to
prevent ugly cyclic dependencies that arise when you combine
self-alignment on a child with alignment of children.
*/
- static SCM prop_syms[2];
+ static SCM prop_syms[2];
if (!prop_syms[0])
{
prop_syms[X_AXIS] = ly_symbol2scm ("self-alignment-X");
prop_syms[Y_AXIS] = ly_symbol2scm ("self-alignment-Y");
}
-
+
SCM align (me->internal_get_property (prop_syms[a]));
-
- Array<Real> translates ;
+
+ Array<Real> translates;
Interval total;
Real where_f = 0;
-
- for (int j = 0 ; j < elems.size (); j++)
+
+ for (int j = 0; j < elems.size (); j++)
{
- Real dy = - dims[j][-stacking_dir];
+ Real dy = -dims[j][-stacking_dir];
if (j)
- dy += dims[j-1][stacking_dir];
-
+ dy += dims[j - 1][stacking_dir];
/*
we want dy to be > 0
- */
- dy *= stacking_dir;
+ */
+ dy *= stacking_dir;
if (j)
{
dy = (dy >? threshold[SMALLER])
}
where_f += stacking_dir * dy;
- total.unite (dims[j] + where_f);
+ total.unite (dims[j] + where_f);
translates.push (where_f);
}
-
Real center_offset = 0.0;
/*
- also move the grobs that were empty, to maintain spatial order.
+ also move the grobs that were empty, to maintain spatial order.
*/
Array<Real> all_translates;
if (translates.size ())
int i = 0;
int j = 0;
Real w = translates[0];
- while (j < all_grobs.size ())
+ while (j < all_grobs.size ())
{
if (i < elems.size () && all_grobs[j] == elems[i])
{
j++;
}
-
/*
FIXME: uncommenting freaks out the Y-alignment of
line-of-score.
- */
+ */
if (scm_is_number (align))
center_offset = total.linear_combination (scm_to_double (align));
- for (int j = 0 ; j < all_grobs.size (); j++)
+ for (int j = 0; j < all_grobs.size (); j++)
all_grobs[j]->translate_axis (all_translates[j] - center_offset, a);
}
}
Axis
-Align_interface::axis (Grob*me)
+Align_interface::axis (Grob *me)
{
- return Axis (scm_to_int (scm_car (me->get_property ("axes"))));
+ return Axis (scm_to_int (scm_car (me->get_property ("axes"))));
}
void
-Align_interface::add_element (Grob*me, Grob* s, SCM cb)
+Align_interface::add_element (Grob *me, Grob *s, SCM cb)
{
s->add_offset_callback (cb, Align_interface::axis (me));
Axis_group_interface::add_element (me, s);
}
void
-Align_interface::set_axis (Grob*me, Axis a)
+Align_interface::set_axis (Grob *me, Axis a)
{
Axis_group_interface::set_axes (me, a, a);
}
-
/*
Find Y-axis parent of G that has a #'forced-distance property. This
has the effect of finding the piano-staff given an object in that
piano staff.
- */
+*/
Grob *
-find_fixed_alignment_parent (Grob *g)
+find_fixed_alignment_parent (Grob *g)
{
while (g)
{
}
-
-
ADD_INTERFACE (Align_interface, "align-interface",
"Order grobs from top to bottom, left to right, right to left or bottom"
- "to top."
- ,
+ "to top.",
"forced-distance stacking-dir align-dir threshold positioning-done "
"center-element elements axes");
-
struct Foobar
{
- bool has_interface (Grob*);
+ bool has_interface (Grob *);
};
/*
all-font-metrics.cc -- implement All_font_metrics
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
otf_dict_ = new Scheme_hash_table;
#if HAVE_PANGO_FT2
- PangoFontMap*pfm = pango_ft2_font_map_new ();
+ PangoFontMap *pfm = pango_ft2_font_map_new ();
- pango_ft2_fontmap_ =
- G_TYPE_CHECK_INSTANCE_CAST(pfm,
- PANGO_TYPE_FT2_FONT_MAP,
- PangoFT2FontMap);
+ pango_ft2_fontmap_
+ = G_TYPE_CHECK_INSTANCE_CAST (pfm,
+ PANGO_TYPE_FT2_FONT_MAP,
+ PangoFT2FontMap);
pango_dpi_ = 1200;
pango_ft2_font_map_set_resolution (pango_ft2_fontmap_,
pango_dpi_, pango_dpi_);
pango_dict_ = new Scheme_hash_table;
#endif
-
+
search_path_.parse_path (path);
}
#endif
}
-All_font_metrics::All_font_metrics (All_font_metrics const&)
+All_font_metrics::All_font_metrics (All_font_metrics const &)
{
}
#if HAVE_PANGO_FT2
Pango_font *
-All_font_metrics::find_pango_font (PangoFontDescription*description,
+All_font_metrics::find_pango_font (PangoFontDescription *description,
Real magnification,
Real output_scale)
{
pango_font_description_set_size (description,
gint (magnification *
pango_font_description_get_size (description)));
-
+
gchar *fn = pango_font_description_to_filename (description);
SCM key = ly_symbol2scm (fn);
pf->description_ = scm_cons (SCM_BOOL_F,
scm_make_real (1.0));
}
- g_free (fn);
- return dynamic_cast<Pango_font*> (unsmob_metrics (val));
+ g_free (fn);
+ return dynamic_cast<Pango_font *> (unsmob_metrics (val));
}
#endif
String
kpathsea_find_file (String name, String ext)
{
- name += "." + ext;
+ name += "." + ext;
String path = global_path.find (name);
- if (path.length() > 0)
+ if (path.length () > 0)
return path;
SCM kpath = ly_lily_module_constant ("ly:kpathsea-find-file");
if (ly_c_procedure_p (kpath))
{
- SCM kp_result = scm_call_1 (kpath, scm_makfrom0str (name.to_str0()));
+ SCM kp_result = scm_call_1 (kpath, scm_makfrom0str (name.to_str0 ()));
if (scm_is_string (kp_result))
return ly_scm2string (kp_result);
}
should include design size when generating an AFM metric.
ugr: copied from find_tfm.
- */
+*/
Adobe_font_metric *
All_font_metrics::find_afm (String name)
{
String file_name;
if (file_name.is_empty ())
- file_name = search_path_.find (name + ".afm");
+ file_name = search_path_.find (name + ".afm");
if (file_name.is_empty ())
{
if (file_name.is_empty ())
return 0;
-
+
if (be_verbose_global)
progress_indication ("[" + file_name);
val = read_afm_file (file_name);
unsmob_metrics (val)->file_name_ = file_name;
-
- unsmob_metrics (val)->description_ = scm_cons (name_string,
+
+ unsmob_metrics (val)->description_ = scm_cons (name_string,
scm_make_real (1.0));
if (be_verbose_global)
scm_gc_unprotect_object (val);
Adobe_font_metric *afm
- = dynamic_cast<Adobe_font_metric*> (unsmob_metrics (val));
+ = dynamic_cast<Adobe_font_metric *> (unsmob_metrics (val));
/* Only check checksums if there is one. We take the risk that
some file has valid checksum 0 */
if (afm->checksum_)
{
- Tex_font_metric * tfm = find_tfm (name);
-
+ Tex_font_metric *tfm = find_tfm (name);
+
/* FIXME: better warning message
(maybe check upon startup for feta16.afm, feta16.tfm?) */
if (tfm && tfm->info ().checksum != afm->checksum_)
s += "\n";
s += _ ("Rerun with -V to show font paths.");
s += "\n";
- s += _("A script for removing font-files is delivered with the source-code:");
+ s += _ ("A script for removing font-files is delivered with the source-code:");
s += "\n";
s += "buildscripts/clean-fonts.sh";
error (s);
}
}
}
-
- return dynamic_cast<Adobe_font_metric*> (unsmob_metrics (val));
+
+ return dynamic_cast<Adobe_font_metric *> (unsmob_metrics (val));
}
-Open_type_font*
+Open_type_font *
All_font_metrics::find_otf (String name)
{
SCM sname = ly_symbol2scm (name.to_str0 ());
if (!otf_dict_->try_retrieve (sname, &val))
{
String file_name;
-
+
if (file_name.is_empty ())
- file_name = search_path_.find (name + ".otf");
+ file_name = search_path_.find (name + ".otf");
if (file_name.is_empty ())
return 0;
if (be_verbose_global)
progress_indication ("[" + file_name);
-
+
val = Open_type_font::make_otf (file_name);
if (be_verbose_global)
scm_gc_unprotect_object (val);
}
- return dynamic_cast<Open_type_font*> (unsmob_metrics (val));
+ return dynamic_cast<Open_type_font *> (unsmob_metrics (val));
}
-Tex_font_metric*
+Tex_font_metric *
All_font_metrics::find_tfm (String name)
{
SCM sname = ly_symbol2scm (name.to_str0 ());
if (!tfm_dict_->try_retrieve (sname, &val))
{
String file_name;
-
+
if (file_name.is_empty ())
{
/* FIXME: should add "cork-" prefix to lm* fonts. How to do
}
if (file_name.is_empty ())
- file_name = search_path_.find (name + ".tfm");
+ file_name = search_path_.find (name + ".tfm");
if (file_name.is_empty ())
return 0;
if (be_verbose_global)
progress_indication ("[" + file_name);
-
+
val = Tex_font_metric::make_tfm (file_name);
if (be_verbose_global)
scm_gc_unprotect_object (val);
}
- return dynamic_cast<Tex_font_metric*> (unsmob_metrics (val));
+ return dynamic_cast<Tex_font_metric *> (unsmob_metrics (val));
}
-Font_metric*
+Font_metric *
All_font_metrics::find_font (String name)
{
Font_metric *f = find_otf (name);
-
- if (!f &&
- (name.left_string (4) == "feta"
- || name.left_string (8) == "parmesan"
- || name.left_string (2) == "lm"))
+
+ if (!f
+ && (name.left_string (4) == "feta"
+ || name.left_string (8) == "parmesan"
+ || name.left_string (2) == "lm"))
{
f = find_afm (name);
if (!f)
warning (_f ("can't find font: `%s'", name.to_str0 ()));
warning (_ ("Loading default font"));
}
-
+
String def_name = default_font_str0_;
/* We're in emergency recovery mode here anyway, so don't try to do
All_font_metrics *all_fonts_global;
-
LY_DEFINE (ly_font_load, "ly:font-load", 1, 0, 0,
(SCM name),
"Load the font @var{name}. ")
source file of the GNU LilyPond music typesetter
(c) 2002--2005 Juergen Reuter <reuter@ipd.uka.de>
-
+
Han-Wen Nienhuys <hanwen@xs4all.nl
-
*/
#include "engraver.hh"
class Ambitus_engraver : public Engraver
{
public:
-TRANSLATOR_DECLARATIONS (Ambitus_engraver);
+ TRANSLATOR_DECLARATIONS (Ambitus_engraver);
virtual void process_music ();
virtual void acknowledge_grob (Grob_info);
virtual void stop_translation_timestep ();
while (flip (&d) != DOWN);
ambitus_->set_parent (heads_[DOWN], X_AXIS);
Axis_group_interface::add_element (group_, ambitus_);
-
- is_typeset_ = false;
-}
+ is_typeset_ = false;
+}
Ambitus_engraver::Ambitus_engraver ()
{
start_c0_ = robust_scm2int (get_property ("middleCPosition"), 0);
start_key_sig_ = get_property ("keySignature");
-
is_typeset_ = true;
}
}
void
Ambitus_engraver::acknowledge_grob (Grob_info info)
{
- Item *item = dynamic_cast <Item *>(info.grob_);
+ Item *item = dynamic_cast<Item *> (info.grob_);
if (item)
{
if (Note_head::has_interface (info.grob_))
{
Pitch p = pitch_interval_[d];
heads_[d]->set_property ("staff-position",
- scm_from_int (start_c0_ +
- p.steps ()));
+ scm_from_int (start_c0_
+ + p.steps ()));
SCM handle = scm_assoc (scm_cons (scm_from_int (p.get_octave ()),
scm_from_int (p.get_notename ())),
if (handle == SCM_BOOL_F)
handle = scm_assoc (scm_from_int (p.get_notename ()),
start_key_sig_);
-
+
int sig_alter = (handle != SCM_BOOL_F) ? scm_to_int (scm_cdr (handle)) : 0;
if (sig_alter == p.get_alteration ())
{
- accidentals_[d]->suicide();
+ accidentals_[d]->suicide ();
heads_[d]->set_property ("accidental-grob", SCM_EOL);
}
else
Direction d = DOWN;
do
{
- accidentals_[d]->suicide();
- heads_[d]->suicide();
- }
+ accidentals_[d]->suicide ();
+ heads_[d]->suicide ();
+ }
while (flip (&d) != DOWN);
- ambitus_->suicide();
+ ambitus_->suicide ();
}
}
ADD_TRANSLATOR (Ambitus_engraver,
-/* descr */ "",
-/* creats*/ "Ambitus AmbitusLine AmbitusNoteHead AmbitusAccidental",
-/* accepts */ "",
-/* acks */ "note-head-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "",
+ /* creats*/ "Ambitus AmbitusLine AmbitusNoteHead AmbitusAccidental",
+ /* accepts */ "",
+ /* acks */ "note-head-interface",
+ /* reads */ "",
+ /* write */ "");
SCM
Ambitus::print (SCM smob)
{
- Item *me = (Item*) unsmob_grob (smob);
+ Item *me = (Item *) unsmob_grob (smob);
Stencil stencil;
// join heads
Link_array<Grob> heads (extract_grob_array (me, ly_symbol2scm ("note-heads")));
if (to_boolean (me->get_property ("join-heads"))
- && heads.size() > 1)
+ && heads.size () > 1)
{
Grob *common
= common_refpoint_of_array (heads.slice (0, 2), me, Y_AXIS);
Grob *minh = heads[0];
Grob *maxh = heads[1];
-
- if (minh->relative_coordinate (common, Y_AXIS) >
- maxh->relative_coordinate (common, Y_AXIS))
+
+ if (minh->relative_coordinate (common, Y_AXIS)
+ > maxh->relative_coordinate (common, Y_AXIS))
{
Grob *t = maxh;
maxh = minh;
Real pad = 0.35;
Real pmax = maxh->extent (common, Y_AXIS)[DOWN] - pad;
Real pmin = minh->extent (common, Y_AXIS)[UP] + pad;
-
+
if (pmin < pmax)
{
Real linethickness = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"))
- * robust_scm2double (me->get_property ("thickness"), 1.0);
+ * robust_scm2double (me->get_property ("thickness"), 1.0);
Real blotdiameter = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
Interval x_extent = 0.5 * linethickness *Interval (-1, 1);
Interval y_extent = Interval (pmin, pmax);
Stencil line = Lookup::round_filled_box (line_box, blotdiameter);
line.translate_axis (- me-> relative_coordinate (common, Y_AXIS),
- Y_AXIS);
+ Y_AXIS);
return line.smobbed_copy ();
}
}
}
ADD_INTERFACE (Ambitus, "ambitus-interface",
- "The line between note heads for a pitch range.",
- "thickness note-heads join-heads");
+ "The line between note heads for a pitch range.",
+ "thickness note-heads join-heads");
-/*
+/*
apply-context-iterator.cc -- implement Apply_context_iterator
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "simple-music-iterator.hh"
#include "input.hh"
/**
- Iterate a property.
- */
+ Iterate a property.
+*/
class Apply_context_iterator : public Simple_music_iterator
{
public:
virtual void process (Moment);
};
-
void
Apply_context_iterator::process (Moment m)
{
if (ly_c_procedure_p (proc))
scm_call_1 (proc, get_outlet ()->self_scm ());
else
- get_music ()->origin ()->warning (_("\\applycontext argument is not a procedure"));
-
+ get_music ()->origin ()->warning (_ ("\\applycontext argument is not a procedure"));
+
Simple_music_iterator::process (m);
}
IMPLEMENT_CTOR_CALLBACK (Apply_context_iterator);
-
+
-/*
+/*
arpeggio-engraver.cc -- implement Arpeggio_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#include "engraver.hh"
#include "group-interface.hh"
{
public:
TRANSLATOR_DECLARATIONS (Arpeggio_engraver);
-
+
protected:
virtual void acknowledge_grob (Grob_info);
virtual void process_music ();
virtual void stop_translation_timestep ();
virtual bool try_music (Music *);
private:
- Item *arpeggio_;
+ Item *arpeggio_;
Music *arpeggio_req_;
};
{
if (Stem::has_interface (info.grob_))
{
- if (!arpeggio_->get_parent (Y_AXIS))
+ if (!arpeggio_->get_parent (Y_AXIS))
arpeggio_->set_parent (info.grob_, Y_AXIS);
-
+
Pointer_group_interface::add_grob (arpeggio_,
ly_symbol2scm ("stems"),
info.grob_);
}
-
+
/*
We can't catch local key items (accidentals) from Voice context,
see Local_key_engraver
{
Side_position_interface::add_support (arpeggio_, info.grob_);
}
- else if (Note_column::has_interface (info.grob_ ))
+ else if (Note_column::has_interface (info.grob_))
{
info.grob_->set_property ("arpeggio", arpeggio_->self_scm ());
}
}
ADD_TRANSLATOR (Arpeggio_engraver,
-/* descr */ "Generate an Arpeggio from a Arpeggio_req",
-/* creats*/ "Arpeggio",
-/* accepts */ "arpeggio-event",
-/* acks */ "stem-interface rhythmic-head-interface note-column-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Generate an Arpeggio from a Arpeggio_req",
+ /* creats*/ "Arpeggio",
+ /* accepts */ "arpeggio-event",
+ /* acks */ "stem-interface rhythmic-head-interface note-column-interface",
+ /* reads */ "",
+ /* write */ "");
-/*
+/*
arpeggio.cc -- implement Arpeggio
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#include "arpeggio.hh"
#include "font-interface.hh"
#include "lookup.hh"
-
MAKE_SCHEME_CALLBACK (Arpeggio, print, 1);
-SCM
-Arpeggio::print (SCM smob)
+SCM
+Arpeggio::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
-
- Grob * common = me;
+
+ Grob *common = me;
for (SCM s = me->get_property ("stems"); scm_is_pair (s); s = scm_cdr (s))
{
- Grob * stem = unsmob_grob (scm_car (s));
- common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem),
- Y_AXIS);
+ Grob *stem = unsmob_grob (scm_car (s));
+ common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem),
+ Y_AXIS);
}
/*
TODO:
-
+
Using stems here is not very convenient; should store noteheads
instead, and also put them into the support. Now we will mess up
in vicinity of a collision.
*/
Interval heads;
Real my_y = me->relative_coordinate (common, Y_AXIS);
-
+
for (SCM s = me->get_property ("stems"); scm_is_pair (s); s = scm_cdr (s))
{
- Grob * stem = unsmob_grob (scm_car (s));
- Grob * ss = Staff_symbol_referencer::get_staff_symbol (stem);
+ Grob *stem = unsmob_grob (scm_car (s));
+ Grob *ss = Staff_symbol_referencer::get_staff_symbol (stem);
Interval iv = Stem::head_positions (stem);
- iv *= Staff_symbol::staff_space (ss)/2.0;
-
+ iv *= Staff_symbol::staff_space (ss) / 2.0;
+
heads.unite (iv + ss->relative_coordinate (common, Y_AXIS)
- my_y);
}
Dumb blonde error
:-)
- */
+ */
programming_error ("Huh, no heads for arpeggio found.");
return SCM_EOL;
}
{
dir = to_dir (ad);
}
-
+
Stencil mol;
Font_metric *fm = Font_interface::get_default_font (me);
Stencil squiggle = fm->find_by_name ("scripts.arpeggio");
- Stencil arrow ;
+ Stencil arrow;
if (dir)
{
arrow = fm->find_by_name ("scripts.arpeggio.arrow." + to_string (dir));
heads[dir] -= dir * arrow.extent (Y_AXIS).length ();
}
-
- for (Real y = heads[LEFT] ; y < heads[RIGHT];
+
+ for (Real y = heads[LEFT]; y < heads[RIGHT];
y+= squiggle. extent (Y_AXIS).length ())
- mol.add_at_edge (Y_AXIS, UP, squiggle, 0.0, 0);
+ mol.add_at_edge (Y_AXIS, UP, squiggle, 0.0, 0);
mol.translate_axis (heads[LEFT], Y_AXIS);
if (dir)
mol.add_at_edge (Y_AXIS, dir, arrow, 0, 0);
-
- return mol.smobbed_copy () ;
+
+ return mol.smobbed_copy ();
}
-/* Draws a vertical bracket to the left of a chord
+/* Draws a vertical bracket to the left of a chord
Chris Jackson <chris@fluffhouse.org.uk> */
MAKE_SCHEME_CALLBACK (Arpeggio, brew_chord_bracket, 1);
-SCM
-Arpeggio::brew_chord_bracket (SCM smob)
+SCM
+Arpeggio::brew_chord_bracket (SCM smob)
{
Grob *me = unsmob_grob (smob);
-
- Grob * common = me;
+
+ Grob *common = me;
for (SCM s = me->get_property ("stems"); scm_is_pair (s); s = scm_cdr (s))
{
- Grob * stem = unsmob_grob (scm_car (s));
- common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem),
- Y_AXIS);
+ Grob *stem = unsmob_grob (scm_car (s));
+ common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem),
+ Y_AXIS);
}
Interval heads;
Real my_y = me->relative_coordinate (common, Y_AXIS);
-
+
for (SCM s = me->get_property ("stems"); scm_is_pair (s); s = scm_cdr (s))
{
- Grob * stem = unsmob_grob (scm_car (s));
- Grob * ss = Staff_symbol_referencer::get_staff_symbol (stem);
+ Grob *stem = unsmob_grob (scm_car (s));
+ Grob *ss = Staff_symbol_referencer::get_staff_symbol (stem);
Interval iv = Stem::head_positions (stem);
- iv *= Staff_symbol::staff_space (ss)/2.0;
- heads.unite (iv + ss->relative_coordinate (common, Y_AXIS) - my_y);
+ iv *= Staff_symbol::staff_space (ss) / 2.0;
+ heads.unite (iv + ss->relative_coordinate (common, Y_AXIS) - my_y);
}
- Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
+ Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
Real sp = 1.5 * Staff_symbol_referencer::staff_space (me);
Real dy = heads.length () + sp;
Real x = 0.7;
Stencil mol (Lookup::bracket (Y_AXIS, Interval (0, dy), lt, x, lt));
- mol.translate_axis (heads[LEFT] - sp/2.0, Y_AXIS);
+ mol.translate_axis (heads[LEFT] - sp / 2.0, Y_AXIS);
return mol.smobbed_copy ();
}
-
/*
We have to do a callback, because print () triggers a
vertical alignment if it is cross-staff.
SCM
Arpeggio::width_callback (SCM smob, SCM axis)
{
- Grob * me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
Axis a = (Axis)scm_to_int (axis);
assert (a == X_AXIS);
Stencil arpeggio = Font_interface::get_default_font (me)->find_by_name ("scripts.arpeggio");
return ly_interval2scm (arpeggio.extent (X_AXIS));
}
-
ADD_INTERFACE (Arpeggio, "arpeggio-interface",
- "Functions and settings for drawing an arpeggio symbol (a wavy line left to noteheads.",
- "stems arpeggio-direction");
+ "Functions and settings for drawing an arpeggio symbol (a wavy line left to noteheads.",
+ "stems arpeggio-direction");
source file of the GNU LilyPond music typesetter
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#include "audio-column.hh"
}
void
-Audio_column::add_audio_item (Audio_item* l)
+Audio_column::add_audio_item (Audio_item *l)
{
audio_items_.push (l);
- l->audio_column_ = this;
+ l->audio_column_ = this;
}
Moment
return at_mom_;
}
-
#include "translator-group.hh"
#include "context.hh"
-Audio_element_info::Audio_element_info (Audio_element*s, Music *r)
+Audio_element_info::Audio_element_info (Audio_element *s, Music *r)
{
elem_ = s;
origin_trans_ = 0;
event_ = r;
}
-
Audio_element_info::Audio_element_info ()
{
elem_ = 0;
origin_trans_ = 0;
}
-
Link_array<Context>
-Audio_element_info::origin_contexts (Translator* end) const
+Audio_element_info::origin_contexts (Translator *end) const
{
- Context * t = origin_trans_->context ();
+ Context *t = origin_trans_->context ();
Link_array<Context> r;
- do {
- r.push (t);
- t = t->get_parent_context ();
- } while (t && t != end->context ());
-
+ do
+ {
+ r.push (t);
+ t = t->get_parent_context ();
+ }
+ while (t && t != end->context ());
+
return r;
}
{
}
-char const *
+char const *
Audio_element::name () const
{
return classname (this);
}
void
-Audio_note::tie_to (Audio_note* t)
+Audio_note::tie_to (Audio_note *t)
{
tied_ = t;
- Audio_note* first = t;
+ Audio_note *first = t;
while (first->tied_)
first = first->tied_;
first->length_mom_ += length_mom_;
length_mom_ = 0;
}
-
Audio_key::Audio_key (int acc, bool major)
{
accidentals_ = acc;
source file of the GNU LilyPond music typesetter
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#include "audio-staff.hh"
#include "midi-walker.hh"
void
-Audio_staff::add_audio_item (Audio_item* l)
+Audio_staff::add_audio_item (Audio_item *l)
{
audio_items_.push (l);
}
-
void
-Audio_staff::output (Midi_stream& midi_stream_r, int track_i)
+Audio_staff::output (Midi_stream &midi_stream_r, int track_i)
{
Midi_track midi_track;
midi_track.number_ = track_i;
midi_stream_r << midi_track;
}
-
-/*
+/*
auto-beam-engraver.cc -- implement Auto_beam_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Jan Nieuwenhuizen <janneke@gnu.org>
-
- */
+*/
#include "engraver.hh"
#include "beaming.hh"
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
virtual void process_music ();
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void finalize ();
virtual void acknowledge_grob (Grob_info);
virtual void process_acknowledged_grobs ();
bool test_moment (Direction, Moment);
void consider_begin (Moment);
void consider_end (Moment);
- Spanner* create_beam ();
+ Spanner *create_beam ();
void begin_beam ();
void end_beam ();
void junk_beam ();
- bool is_same_grace_state (Grob* e);
+ bool is_same_grace_state (Grob *e);
void typeset_beam ();
Music *forbid_;
/*
shortest_mom is the shortest note in the beam.
- */
+ */
Moment shortest_mom_;
Spanner *finished_beam_;
Link_array<Item>* stems_;
-
int count_;
Moment last_add_mom_;
/*
Projected ending of the beam we're working on.
- */
+ */
Moment extend_mom_;
Moment beam_start_moment_;
Moment beam_start_location_;
bool subdivide_beams_;
Moment beat_length_;
-
+
// We act as if beam were created, and start a grouping anyway.
- Beaming_info_list*grouping_;
- SCM beam_settings_ ; // ugh. should protect ?
-
- Beaming_info_list*finished_grouping_;
+ Beaming_info_list *grouping_;
+ SCM beam_settings_; // ugh. should protect ?
+
+ Beaming_info_list *finished_grouping_;
};
void
}
}
-
Auto_beam_engraver::Auto_beam_engraver ()
{
forbid_ = 0;
finished_beam_ = 0;
finished_grouping_ = 0;
grouping_ = 0;
- beam_settings_ = SCM_EOL;
+ beam_settings_ = SCM_EOL;
}
-
bool
-Auto_beam_engraver::try_music (Music*m)
+Auto_beam_engraver::try_music (Music *m)
{
- if (m->is_mus_type ("beam-forbid-event"))
+ if (m->is_mus_type ("beam-forbid-event"))
{
forbid_ = m;
return true;
/*
Determine end moment for auto beaming (or begin moment, but mostly
0== anywhere) In order of increasing priority:
-
+
i. begin anywhere, end at every beat
ii. end * <num> <den>
iii. end <type> <num> <den>
-
+
iv. end * * *
v. end <type> * *
-
-
+
+
Rationale:
-
+
[to be defined in config file]
i. easy catch-all rule
ii. exceptions for time signature
iii. exceptions for time signature, for specific duration type
-
+
[user override]
iv. generic override
v. override for specific duration type
-
*/
bool
Auto_beam_engraver::test_moment (Direction dir, Moment test_mom)
{
return false;
}
-
+
SCM wild = scm_list_n (ly_symbol2scm ("*"), ly_symbol2scm ("*"), SCM_UNDEFINED);
SCM function;
if (dir == START)
function = scm_list_n (ly_symbol2scm ("begin"), SCM_UNDEFINED);
else
function = scm_list_n (ly_symbol2scm ("end"), SCM_UNDEFINED);
-
+
Moment beat_length (1, 4);
- if (Moment * m = unsmob_moment (get_property ("beatLength")))
+ if (Moment *m = unsmob_moment (get_property ("beatLength")))
{
beat_length = *m;
}
Moment measure_length (1, 1);
int num = 4;
- if (Moment* m = unsmob_moment (get_property ("measureLength")))
+ if (Moment *m = unsmob_moment (get_property ("measureLength")))
{
num = int ((*m / beat_length).main_part_);
}
-
+
int den = beat_length.den ();
SCM time = scm_list_n (scm_int2num (num), scm_int2num (den), SCM_UNDEFINED);
SCM type = scm_list_n (scm_int2num (test_mom.num ()),
- scm_int2num (test_mom.den ()), SCM_UNDEFINED);
+ scm_int2num (test_mom.den ()), SCM_UNDEFINED);
/*
UGH UGH.
settings aren't grob-properties.
- */
+ */
SCM settings = get_property ("autoBeamSettings");
-
+
/* first guess */
-
+
/* begin beam at any position
- (and fallback for end) */
+ (and fallback for end) */
Moment moment (0);
-
+
/* end beam at end of beat */
if (dir == STOP)
{
/* second guess: property generic time exception */
SCM m = scm_assoc (ly_append3 (function, wild, time), settings);
-
+
if (m != SCM_BOOL_F && unsmob_moment (scm_cdr (m)))
- moment = * unsmob_moment (scm_cdr (m));
+ moment = *unsmob_moment (scm_cdr (m));
/* third guess: property time exception, specific for duration type */
m = scm_assoc (ly_append3 (function, type, time), settings);
if (m != SCM_BOOL_F && unsmob_moment (scm_cdr (m)))
- moment = * unsmob_moment (scm_cdr (m));
+ moment = *unsmob_moment (scm_cdr (m));
/* fourth guess [user override]: property plain generic */
m = scm_assoc (ly_append3 (function, wild, wild), settings);
if (m != SCM_BOOL_F && unsmob_moment (scm_cdr (m)))
- moment = * unsmob_moment (scm_cdr (m));
+ moment = *unsmob_moment (scm_cdr (m));
/* fifth guess [user override]: property plain, specific for duration type */
m = scm_assoc (ly_append3 (function, type, wild), settings);
if (m != SCM_BOOL_F && unsmob_moment (scm_cdr (m)))
- moment = * unsmob_moment (scm_cdr (m));
-
+ moment = *unsmob_moment (scm_cdr (m));
+
Rational r;
if (moment.to_bool ())
{
/* Ugh? measurePosition can be negative, when \partial
We may have to fix this elsewhere (timing translator)
- r = unsmob_moment (get_property ("measurePosition"))->mod_rat (moment);
+ r = unsmob_moment (get_property ("measurePosition"))->mod_rat (moment);
*/
Moment pos (0);
- if (Moment *m = unsmob_moment (get_property ("measurePosition")))
+ if (Moment *m = unsmob_moment (get_property ("measurePosition")))
{
pos = *m;
}
-
+
if (pos < Moment (0))
{
- Moment length(1);
+ Moment length (1);
- if ( Moment *m = unsmob_moment (get_property ("measureLength")))
+ if (Moment *m = unsmob_moment (get_property ("measureLength")))
{
length = *m;
}
{
if (to_boolean (get_property ("skipTypesetting")))
return 0;
-
+
Spanner *beam = new Spanner (beam_settings_, context ()->get_grob_key ("Beam"));
for (int i = 0; i < stems_->size (); i++)
{
/*
watch out for stem tremolos and abbreviation beams
- */
+ */
if (Stem::get_beam ((*stems_)[i]))
{
scm_gc_unprotect_object (beam->self_scm ());
}
Beam::add_stem (beam, (*stems_)[i]);
}
-
+
announce_grob (beam, (*stems_)[0]->self_scm ());
return beam;
void
Auto_beam_engraver::begin_beam ()
{
- if (stems_ || grouping_ )
+ if (stems_ || grouping_)
{
programming_error ("already have autobeam");
- return;
+ return;
}
-
+
stems_ = new Link_array<Item>;
grouping_ = new Beaming_info_list;
beam_settings_ = updated_grob_properties (context (), ly_symbol2scm ("Beam"));
-
+
beam_start_moment_ = now_mom ();
- beam_start_location_ =
- robust_scm2moment (get_property ("measurePosition"), Moment(0));
+ beam_start_location_
+ = robust_scm2moment (get_property ("measurePosition"), Moment (0));
subdivide_beams_ = ly_scm2bool (get_property ("subdivideBeams"));
- beat_length_ = robust_scm2moment (get_property ("beatLength"), Moment(1, 4));
+ beat_length_ = robust_scm2moment (get_property ("beatLength"), Moment (1, 4));
}
void
-Auto_beam_engraver::junk_beam ()
+Auto_beam_engraver::junk_beam ()
{
if (!stems_)
- return ;
-
+ return;
+
delete stems_;
stems_ = 0;
delete grouping_;
grouping_ = 0;
beam_settings_ = SCM_EOL;
-
+
shortest_mom_ = Moment (Rational (1, 8));
}
finished_grouping_->beamify (beat_length_, subdivide_beams_);
Beam::set_beaming (finished_beam_, finished_grouping_);
finished_beam_ = 0;
-
+
delete finished_grouping_;
finished_grouping_ = 0;
}
count_ = 0;
/*
don't beam over skips
- */
+ */
if (stems_)
{
Moment now = now_mom ();
junk_beam ();
}
-
void
Auto_beam_engraver::acknowledge_grob (Grob_info info)
{
/*
Duplicated from process_music(), since
Repeat_acknowledge_engraver::process_music() may also set whichBar
- */
+ */
if (scm_is_string (get_property ("whichBar"))
- && beam_start_moment_ < now_mom())
+ && beam_start_moment_ < now_mom ())
{
consider_end (shortest_mom_);
junk_beam ();
}
-
+
if (stems_)
{
if (Beam::has_interface (info.grob_))
end_beam ();
}
}
-
+
if (Stem::has_interface (info.grob_))
{
- Item* stem = dynamic_cast<Item *> (info.grob_);
- Music* m = info.music_cause ();
+ Item *stem = dynamic_cast<Item *> (info.grob_);
+ Music *m = info.music_cause ();
if (!m->is_mus_type ("rhythmic-event"))
{
programming_error ("Stem must have rhythmic structure");
return;
}
-
+
/*
Don't (start) auto-beam over empty stems; skips or rests
- */
+ */
if (!Stem::head_count (stem))
{
if (stems_)
{
if (stems_)
junk_beam ();
- return ;
+ return;
}
-
- int durlog = unsmob_duration (m->get_property ("duration"))->duration_log ();
-
+
+ int durlog = unsmob_duration (m->get_property ("duration"))->duration_log ();
+
if (durlog <= 2)
{
if (stems_)
return;
}
-
/*
ignore grace notes.
- */
+ */
if (bool (beam_start_location_.grace_part_) != bool (now_mom ().grace_part_))
- return ;
-
-
+ return;
+
Moment dur = unsmob_duration (m->get_property ("duration"))->get_length ();
/* FIXME:
- This comment has been here since long:
+ This comment has been here since long:
- if shortest duration would change
- consider ending and beginning beam first.
+ if shortest duration would change
+ consider ending and beginning beam first.
- but the code didn't match: */
+ but the code didn't match: */
#if 1
consider_end (dur);
consider_begin (dur);
if (!stems_)
return;
-
+
Moment now = now_mom ();
-
+
grouping_->add_stem (now - beam_start_moment_ + beam_start_location_,
- durlog - 2);
+ durlog - 2);
stems_->push (stem);
last_add_mom_ = now;
extend_mom_ = (extend_mom_ >? now) + m->get_length ();
{
junk_beam ();
}
- }
+ }
}
-
- count_ ++;
+
+ count_++;
}
ADD_TRANSLATOR (Auto_beam_engraver,
-/* descr */ "Generate beams based on measure characteristics and observed "
-"Stems. Uses beatLength, measureLength and measurePosition to decide "
-"when to start and stop a beam. Overriding beaming is done through "
-"@ref{Stem_engraver} properties @code{stemLeftBeamCount} and "
-"@code{stemRightBeamCount}. "
-,
-/* creats*/ "Beam",
-/* accepts */ "beam-forbid-event",
-/* acks */ "stem-interface rest-interface beam-interface bar-line-interface",
-/* reads */ "autoBeaming autoBeamSettings beatLength subdivideBeams",
-/* write */ "");
+ /* descr */ "Generate beams based on measure characteristics and observed "
+ "Stems. Uses beatLength, measureLength and measurePosition to decide "
+ "when to start and stop a beam. Overriding beaming is done through "
+ "@ref{Stem_engraver} properties @code{stemLeftBeamCount} and "
+ "@code{stemRightBeamCount}. ",
+ /* creats*/ "Beam",
+ /* accepts */ "beam-forbid-event",
+ /* acks */ "stem-interface rest-interface beam-interface bar-line-interface",
+ /* reads */ "autoBeaming autoBeamSettings beatLength subdivideBeams",
+ /* write */ "");
-/*
+/*
auto-change-iterator.cc -- implement Auto_change_iterator
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "context.hh"
#include "event.hh"
{
public:
DECLARE_SCHEME_CALLBACK (constructor, ());
-
+
Auto_change_iterator ();
protected:
virtual void do_quit ();
virtual void construct_children ();
- virtual void process (Moment);
+ virtual void process (Moment);
Array<Pitch> pending_pitch (Moment) const;
private:
SCM split_list_;
Direction where_dir_;
- void change_to (Music_iterator* , SCM, String);
+ void change_to (Music_iterator *, SCM, String);
Moment start_moment_;
Interpretation_context_handle up_;
};
-
-
void
Auto_change_iterator::change_to (Music_iterator *it, SCM to_type_sym,
String to_id)
{
- Context * current = it->get_outlet ();
- Context * last = 0;
+ Context *current = it->get_outlet ();
+ Context *last = 0;
/*
Cut & Paste from Change_iterator (ugh).
- TODO: abstract this function
- */
-
+ TODO: abstract this function
+ */
+
/* find the type of translator that we're changing.
-
- If \translator Staff = bass, then look for Staff = *
- */
+
+ If \translator Staff = bass, then look for Staff = *
+ */
while (current && !current->is_alias (to_type_sym))
{
last = current;
String msg;
msg += _ ("Can't switch translators, I'm there already");
}
-
- if (current)
+
+ if (current)
if (last)
{
- Context * dest =
- it->get_outlet ()->find_create_context (to_type_sym, to_id, SCM_EOL);
+ Context *dest
+ = it->get_outlet ()->find_create_context (to_type_sym, to_id, SCM_EOL);
current->remove_context (last);
dest->add_context (last);
}
else
{
/*
- We could change the current translator's id, but that would make
+ We could change the current translator's id, but that would make
errors hard to catch
-
+
*/
}
- else
- ;
+ else;
}
Auto_change_iterator::process (Moment m)
{
Music_wrapper_iterator::process (m);
-
+
Moment now = get_outlet ()->now_mom ();
Moment *splitm = 0;
-
+
for (; scm_is_pair (split_list_); split_list_ = scm_cdr (split_list_))
{
splitm = unsmob_moment (scm_caar (split_list_));
if ((*splitm + start_moment_) > now)
- break ;
+ break;
SCM tag = scm_cdar (split_list_);
- Direction d = to_dir (tag);
-
+ Direction d = to_dir (tag);
+
if (d && d != where_dir_)
{
where_dir_ = d;
- String to_id = (d >= 0) ? "up" : "down";
+ String to_id = (d >= 0) ? "up" : "down";
change_to (child_iter_,
ly_symbol2scm ("Staff"),
to_id);
void
Auto_change_iterator::construct_children ()
{
- split_list_ = get_music ()->get_property ("split-list");
+ split_list_ = get_music ()->get_property ("split-list");
start_moment_ = get_outlet ()->now_mom ();
- SCM props = get_outlet()->get_property ("trebleStaffProperties");
- Context *up = get_outlet()->find_create_context (ly_symbol2scm ("Staff"),
- "up", props);
+ SCM props = get_outlet ()->get_property ("trebleStaffProperties");
+ Context *up = get_outlet ()->find_create_context (ly_symbol2scm ("Staff"),
+ "up", props);
+
+ props = get_outlet ()->get_property ("bassStaffProperties");
+ Context *down = get_outlet ()->find_create_context (ly_symbol2scm ("Staff"),
+ "down", props);
- props = get_outlet()->get_property ("bassStaffProperties");
- Context *down = get_outlet()->find_create_context (ly_symbol2scm ("Staff"),
- "down", props);
-
up_.set_context (up);
down_.set_context (down);
Context *voice = up->find_create_context (ly_symbol2scm ("Voice"),
- "", SCM_EOL);
+ "", SCM_EOL);
set_context (voice);
Music_wrapper_iterator::construct_children ();
}
void
-Auto_change_iterator::do_quit()
+Auto_change_iterator::do_quit ()
{
up_.set_context (0);
down_.set_context (0);
-
+
}
IMPLEMENT_CTOR_CALLBACK (Auto_change_iterator);
-/*
+/*
axis-group-engraver.cc -- implement Axis_group_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- */
+*/
#include "spanner.hh"
#include "paper-column.hh"
/**
Put stuff in a Spanner with an Axis_group_interface.
- Use as last element of a context.
- */
+ Use as last element of a context.
+*/
class Axis_group_engraver : public Engraver
{
protected:
virtual void finalize ();
virtual void acknowledge_grob (Grob_info);
virtual void process_acknowledged_grobs ();
- virtual Spanner* get_spanner () ;
- virtual void add_element (Grob*) ;
-public:
+ virtual Spanner *get_spanner ();
+ virtual void add_element (Grob *);
+public:
TRANSLATOR_DECLARATIONS (Axis_group_engraver);
};
if (!staffline_)
{
staffline_ = get_spanner ();
- Grob * it = unsmob_grob (get_property ("currentCommandColumn"));
+ Grob *it = unsmob_grob (get_property ("currentCommandColumn"));
staffline_->set_bound (LEFT, it);
}
-}
+}
-Spanner*
-Axis_group_engraver::get_spanner ()
+Spanner *
+Axis_group_engraver::get_spanner ()
{
return make_spanner ("VerticalAxisGroup", SCM_EOL);
}
/*
- TODO: should we junk minimumVerticalExtent/extraVerticalExtent ?
- */
+ TODO: should we junk minimumVerticalExtent/extraVerticalExtent ?
+*/
void
Axis_group_engraver::finalize ()
{
if (!staffline_)
- return ;
-
+ return;
+
String type = context ()->context_name ();
SCM dims = get_property ("verticalExtent");
-
+
if (is_number_pair (dims))
staffline_->set_extent (dims, Y_AXIS);
dims = get_property ("minimumVerticalExtent");
- if (is_number_pair (dims) )
+ if (is_number_pair (dims))
staffline_->set_property ("minimum-Y-extent", dims);
dims = get_property ("extraVerticalExtent");
if (is_number_pair (dims))
staffline_->set_property ("extra-Y-extent", dims);
- Grob * it = unsmob_grob (get_property ("currentCommandColumn"));
+ Grob *it = unsmob_grob (get_property ("currentCommandColumn"));
staffline_->set_bound (RIGHT, it);
void
Axis_group_engraver::process_acknowledged_grobs ()
{
- if (!staffline_)
- return ;
-
+ if (!staffline_)
+ return;
+
for (int i = 0; i < elts_.size (); i++)
{
- if (!unsmob_grob (elts_[i]->get_property ("axis-group-parent-Y")))
+ if (!unsmob_grob (elts_[i]->get_property ("axis-group-parent-Y")))
{
if (staffline_->get_parent (Y_AXIS)
&& staffline_->get_parent (Y_AXIS) == elts_[i])
{
- String msg = _("Axis_group_engraver: vertical group already has a parent.\n"
- "Do you have two Axis_group_engravers?\n"
- "Killing this vertical group.");
+ String msg = _ ("Axis_group_engraver: vertical group already has a parent.\n"
+ "Do you have two Axis_group_engravers?\n"
+ "Killing this vertical group.");
staffline_->warning (msg);
staffline_->suicide ();
staffline_ = 0;
- break ;
+ break;
}
else if (elts_[i]->is_empty (Y_AXIS))
{
/*
We have to do _something_, otherwise staff objects will
- end up with System as parent.
-
+ end up with System as parent.
+
*/
elts_[i]->set_parent (staffline_, Y_AXIS);
}
}
void
-Axis_group_engraver::add_element (Grob*e)
+Axis_group_engraver::add_element (Grob *e)
{
Axis_group_interface::add_element (staffline_, e);
}
/****************************************************************/
/*
-
- maybenot such a good idea after all., to put class declarations in
- .cc
-
+ maybenot such a good idea after all., to put class declarations in
+ .cc
*/
#include "hara-kiri-group-spanner.hh"
class Hara_kiri_engraver : public Axis_group_engraver
{
protected:
- virtual Spanner*get_spanner ();
+ virtual Spanner *get_spanner ();
virtual void acknowledge_grob (Grob_info);
virtual void add_element (Grob *e);
public:
};
void
-Hara_kiri_engraver::add_element (Grob*e)
+Hara_kiri_engraver::add_element (Grob *e)
{
Hara_kiri_group_spanner::add_element (staffline_, e);
}
-
-Spanner*
-Hara_kiri_engraver::get_spanner ()
+Spanner *
+Hara_kiri_engraver::get_spanner ()
{
- Spanner * sp = make_spanner ("RemoveEmptyVerticalGroup", SCM_EOL);
-
+ Spanner *sp = make_spanner ("RemoveEmptyVerticalGroup", SCM_EOL);
+
return sp;
}
Axis_group_engraver::acknowledge_grob (i);
if (staffline_
&& (i.grob_->internal_has_interface (ly_symbol2scm ("rhythmic-grob-interface"))
- || i.grob_->internal_has_interface (ly_symbol2scm ("lyric-interface")))
- )
+ || i.grob_->internal_has_interface (ly_symbol2scm ("lyric-interface"))))
{
Hara_kiri_group_spanner::add_interesting_item (staffline_, i.grob_);
}
}
-
Hara_kiri_engraver::Hara_kiri_engraver ()
{
}
ADD_TRANSLATOR (Hara_kiri_engraver,
-/* descr */ "Like Axis_group_engraver, but make a hara-kiri spanner, and add "
-"interesting items (ie. note heads, lyric syllables and normal rests) ",
-/* creats*/ "RemoveEmptyVerticalGroup",
-/* accepts */ "",
-/* acks */ "grob-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Like Axis_group_engraver, but make a hara-kiri spanner, and add "
+ "interesting items (ie. note heads, lyric syllables and normal rests) ",
+ /* creats*/ "RemoveEmptyVerticalGroup",
+ /* accepts */ "",
+ /* acks */ "grob-interface",
+ /* reads */ "",
+ /* write */ "");
ADD_TRANSLATOR (Axis_group_engraver,
-/* descr */ "Group all objects created in this context in a VerticalAxisGroup spanner.",
-/* creats*/ "VerticalAxisGroup",
-/* accepts */ "",
-/* acks */ "grob-interface",
-/* reads */ "verticalExtent minimumVerticalExtent extraVerticalExtent",
-/* write */ "");
+ /* descr */ "Group all objects created in this context in a VerticalAxisGroup spanner.",
+ /* creats*/ "VerticalAxisGroup",
+ /* accepts */ "",
+ /* acks */ "grob-interface",
+ /* reads */ "verticalExtent minimumVerticalExtent extraVerticalExtent",
+ /* write */ "");
-/*
+/*
axis-group-interface.cc -- implement Axis_group_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "axis-group-interface.hh"
#include "hara-kiri-group-spanner.hh"
void
-Axis_group_interface::add_element (Grob*me, Grob *e)
+Axis_group_interface::add_element (Grob *me, Grob *e)
{
- for (SCM ax = me->get_property ("axes"); ax != SCM_EOL ; ax = scm_cdr (ax))
+ for (SCM ax = me->get_property ("axes"); ax != SCM_EOL; ax = scm_cdr (ax))
{
Axis a = (Axis) scm_to_int (scm_car (ax));
-
+
if (!e->get_parent (a))
e->set_parent (me, a);
e->internal_set_property ((a == X_AXIS)
? ly_symbol2scm ("axis-group-parent-X")
: ly_symbol2scm ("axis-group-parent-Y"),
- me->self_scm ()
- );
+ me->self_scm ());
}
-
+
Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), e);
me->add_dependency (e);
}
bool
-Axis_group_interface::has_axis (Grob*me, Axis a)
+Axis_group_interface::has_axis (Grob *me, Axis a)
{
/*
urg. FIXME, check for Hara_kiri_group_spanner shouldn't be necessary?
- */
- return me->has_extent_callback (group_extent_callback_proc, a) ||
- (me->has_extent_callback (Hara_kiri_group_spanner::y_extent_proc, a));
+ */
+ return me->has_extent_callback (group_extent_callback_proc, a)
+ || (me->has_extent_callback (Hara_kiri_group_spanner::y_extent_proc, a));
}
Interval
Interval r;
for (SCM s = elts; scm_is_pair (s); s = scm_cdr (s))
{
- Grob * se = unsmob_grob (scm_car (s));
+ Grob *se = unsmob_grob (scm_car (s));
Interval dims = se->extent (common, a);
if (!dims.is_empty ())
r.unite (dims);
Axis a = (Axis) scm_to_int (scm_axis);
SCM elts = me->get_property ("elements");
- Grob * common = common_refpoint_of_list (elts, me, a);
+ Grob *common = common_refpoint_of_list (elts, me, a);
Real my_coord = me->relative_coordinate (common, a);
Interval r (relative_group_extent (a, common, elts));
}
void
-Axis_group_interface::set_axes (Grob*me, Axis a1, Axis a2)
+Axis_group_interface::set_axes (Grob *me, Axis a1, Axis a2)
{
SCM sa1= scm_int2num (a1);
SCM sa2 = scm_int2num (a2);
SCM axes = me->get_property ("axes");
-
+
if (!scm_is_pair (axes)
|| scm_c_memq (sa1, axes) == SCM_BOOL_F
|| scm_c_memq (sa2, axes) == SCM_BOOL_F)
me->set_extent (SCM_EOL, Y_AXIS);
/*
- why so convoluted ? (fixme/documentme?)
- */
+ why so convoluted ? (fixme/documentme?)
+ */
if (me->has_extent_callback (Grob::stencil_extent_proc, a1))
me->set_extent_callback (Axis_group_interface::group_extent_callback_proc, a1);
if (me->has_extent_callback (Grob::stencil_extent_proc, a2))
me->set_extent_callback (Axis_group_interface::group_extent_callback_proc, a2);
}
-Link_array<Grob>
-Axis_group_interface::get_children (Grob*me)
+Link_array<Grob>
+Axis_group_interface::get_children (Grob *me)
{
Link_array<Grob> childs;
- childs.push (me) ;
+ childs.push (me);
if (!has_interface (me))
return childs;
-
+
for (SCM ep = me->get_property ("elements"); scm_is_pair (ep); ep = scm_cdr (ep))
{
- Grob* e = unsmob_grob (scm_car (ep));
+ Grob *e = unsmob_grob (scm_car (ep));
if (e)
childs.concat (Axis_group_interface::get_children (e));
}
-
+
return childs;
}
-
-
ADD_INTERFACE (Axis_group_interface, "axis-group-interface",
- "An object that groups other layout objects.",
- "axes elements");
+ "An object that groups other layout objects.",
+ "axes elements");
{
public:
DECLARE_SCHEME_CALLBACK (print, (SCM));
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
};
MAKE_SCHEME_CALLBACK (Balloon_interface, print, 1);
SCM
-Balloon_interface::print (SCM smob)
+Balloon_interface::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
Stencil fr = Lookup::frame (box_extent, 0.1, 0.05);
fr.add_stencil (*s);
-
+
SCM bt = me->get_property ("balloon-text");
SCM chain = Font_interface::text_font_alist_chain (me);
chain = scm_cons (me->get_property ("balloon-text-props"), chain);
SCM text = Text_interface::interpret_markup (me->get_layout ()->self_scm (),
- chain, bt);
+ chain, bt);
Stencil *text_stil = unsmob_stencil (text);
-
+
Offset z1;
for (int i = X_AXIS; i < NO_AXES; i++)
{
}
Offset z2 = z1 + off;
-
+
fr.add_stencil (Line_interface::line (me, z1, z2));
text_stil->translate (z2);
fr.add_stencil (*text_stil);
-
+
fr = Stencil (orig_extent, fr.expr ());
return fr.smobbed_copy ();
}
-/*
+/*
bar-check-iterator.cc -- implement Bar_check_iterator
source file of the GNU LilyPond music typesetter
/*
Check bar checks. We do this outside the engravers so that you can
race through the score using skipTypesetting to correct durations.
- */
+*/
class Bar_check_iterator : Simple_music_iterator
{
public:
virtual void process (Moment);
- Bar_check_iterator ( );
+ Bar_check_iterator ();
DECLARE_SCHEME_CALLBACK (constructor, ());
};
SCM mp = tr->get_property ("measurePosition");
SCM sync = tr->get_property ("barCheckSynchronize");
- Moment * where = unsmob_moment (mp);
+ Moment *where = unsmob_moment (mp);
if (!where)
return;
-
+
if (where->main_part_)
{
bool warn = true;
}
if (warn)
- get_music ()->origin ()->warning (_f ("barcheck failed at: %s",
- where->to_string ()));
+ get_music ()->origin ()->warning (_f ("barcheck failed at: %s",
+ where->to_string ()));
}
}
-}
+}
/*
generate bars. Either user ("|:"), or default (new measure)
-
- */
+*/
class Bar_engraver : public Engraver
{
public:
TRANSLATOR_DECLARATIONS (Bar_engraver);
void request_bar (String type_string);
-
+
protected:
virtual void finalize ();
virtual void stop_translation_timestep ();
void typeset_bar ();
void create_bar ();
- Item * bar_;
+ Item *bar_;
};
Bar_engraver::Bar_engraver ()
bar_ = make_item ("BarLine", SCM_EOL);
SCM gl = get_property ("whichBar");
if (scm_equal_p (gl, bar_->get_property ("glyph")) != SCM_BOOL_T)
- bar_->set_property ("glyph", gl);
+ bar_->set_property ("glyph", gl);
}
}
}
/*
- Bar_engraver should come *after* any engravers that
+ Bar_engraver should come *after* any engravers that
modify whichBar
This is a little hairy : whichBar may be set by
context. This means that grobs could should be created after
process_music. We do stuff process_acknowledged_grobs (), just to be
on the safe side.
-
*/
void
}
/*
- lines may only be broken if there is a barline in all staves
+ lines may only be broken if there is a barline in all staves
*/
-void
+void
Bar_engraver::stop_translation_timestep ()
{
if (!bar_)
typeset_bar ();
}
-
ADD_TRANSLATOR (Bar_engraver,
-/* descr */ "Create barlines. This engraver is controlled through the "
-"@code{whichBar} property. If it has no bar line to create, it will forbid a linebreak at this point",
-/* creats*/ "BarLine",
-/* accepts */ "",
-/* acks */ "",
-/* reads */ "whichBar",
-/* write */ "");
+ /* descr */ "Create barlines. This engraver is controlled through the "
+ "@code{whichBar} property. If it has no bar line to create, it will forbid a linebreak at this point",
+ /* creats*/ "BarLine",
+ /* accepts */ "",
+ /* acks */ "",
+ /* reads */ "whichBar",
+ /* write */ "");
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#include <math.h>
#include "bar-line.hh"
MAKE_SCHEME_CALLBACK (Bar_line, print, 1);
-SCM
-Bar_line::print (SCM smob)
+SCM
+Bar_line::print (SCM smob)
{
- Grob * me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
SCM s = me->get_property ("glyph");
SCM barsiz_proc = me->get_property ("bar-size-procedure");
if (scm_is_string (s) && ly_c_procedure_p (barsiz_proc))
{
- String str = ly_scm2string (s);
+ String str = ly_scm2string (s);
SCM siz = scm_call_1 (barsiz_proc, me->self_scm ());
Real sz = robust_scm2double (siz, 0);
if (sz <= 0)
return SCM_EOL;
-
+
return compound_barline (me, str, sz).smobbed_copy ();
}
return SCM_EOL;
}
-
Stencil
-Bar_line::compound_barline (Grob*me, String str, Real h)
+Bar_line::compound_barline (Grob *me, String str, Real h)
{
Real kern = robust_scm2double (me->get_property ("kern"), 1);
Real thinkern = robust_scm2double (me->get_property ("thin-kern"), 1);
Stencil dot = Font_interface::get_default_font (me)->find_by_name ("dots.dot");
int lines = Staff_symbol_referencer::line_count (me);
- Real dist
+ Real dist
= ((lines & 1 || lines == 0)
? 1
- : (staff_space < 2 ? 2 : .5) ) * staff_space;
+ : (staff_space < 2 ? 2 : .5)) * staff_space;
Stencil colon (dot);
colon.translate_axis (dist, Y_AXIS);
colon.add_stencil (dot);
- colon.translate_axis (-dist/2, Y_AXIS);
+ colon.translate_axis (-dist / 2, Y_AXIS);
Stencil m;
if (str == "||:")
str = "|:";
-
+
if (str == "")
{
- return Lookup::blank (Box (Interval (0, 0), Interval (-h/2, h/2)));
+ return Lookup::blank (Box (Interval (0, 0), Interval (-h / 2, h / 2)));
}
else if (str == "|")
{
}
else if (str == "|." || (h == 0 && str == ":|"))
{
- m.add_at_edge (X_AXIS, LEFT, thick, 0, 0);
- m.add_at_edge (X_AXIS, LEFT, thin, kern, 0 );
+ m.add_at_edge (X_AXIS, LEFT, thick, 0, 0);
+ m.add_at_edge (X_AXIS, LEFT, thin, kern, 0);
}
else if (str == ".|" || (h == 0 && str == "|:"))
{
{
m.add_at_edge (X_AXIS, LEFT, thick, 0, 0);
m.add_at_edge (X_AXIS, LEFT, thin, kern, 0);
- m.add_at_edge (X_AXIS, LEFT, colon, kern, 0);
+ m.add_at_edge (X_AXIS, LEFT, colon, kern, 0);
}
else if (str == "|:")
{
m.add_at_edge (X_AXIS, RIGHT, thick, 0, 0);
m.add_at_edge (X_AXIS, RIGHT, thin, kern, 0);
- m.add_at_edge (X_AXIS, RIGHT, colon, kern, 0);
+ m.add_at_edge (X_AXIS, RIGHT, colon, kern, 0);
}
else if (str == ":|:")
{
m.add_at_edge (X_AXIS, LEFT, thick, thinkern, 0);
m.add_at_edge (X_AXIS, LEFT, colon, kern, 0);
m.add_at_edge (X_AXIS, RIGHT, thick, kern, 0);
- m.add_at_edge (X_AXIS, RIGHT, colon, kern, 0);
+ m.add_at_edge (X_AXIS, RIGHT, colon, kern, 0);
}
else if (str == ".|.")
{
else if (str == ":")
{
int c = (Staff_symbol_referencer::line_count (me));
-
- for (int i = 0 ; i < c - 1; i++)
+
+ for (int i = 0; i < c - 1; i++)
{
- Real y = (- (c-1.0) / 2 + 0.5 + i * staff_space);
+ Real y = (- (c - 1.0) / 2 + 0.5 + i * staff_space);
Stencil d (dot);
d. translate_axis (y, Y_AXIS);
Stencil
Bar_line::simple_barline (Grob *me,
Real w,
- Real h)
+ Real h)
{
Real blot = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
-
- return Lookup::round_filled_box (Box (Interval (0, w), Interval (-h/2, h/2)), blot);
+
+ return Lookup::round_filled_box (Box (Interval (0, w), Interval (-h / 2, h / 2)), blot);
}
-MAKE_SCHEME_CALLBACK (Bar_line, before_line_breaking , 1);
+MAKE_SCHEME_CALLBACK (Bar_line, before_line_breaking, 1);
SCM
Bar_line::before_line_breaking (SCM smob)
{
- Grob*me = unsmob_grob (smob);
- Item * item = dynamic_cast<Item*> (me);
-
+ Grob *me = unsmob_grob (smob);
+ Item *item = dynamic_cast<Item *> (me);
+
SCM g = me->get_property ("glyph");
SCM orig = g;
Direction bsd = item->break_status_dir ();
SCM proc = me->get_property ("break-glyph-function");
g = scm_call_2 (proc, g, scm_int2num (bsd));
}
-
+
if (!scm_is_string (g))
{
me->set_property ("print-function", SCM_EOL);
return SCM_UNSPECIFIED;
}
-
-
MAKE_SCHEME_CALLBACK (Bar_line, get_staff_bar_size, 1);
SCM
-Bar_line::get_staff_bar_size (SCM smob)
+Bar_line::get_staff_bar_size (SCM smob)
{
- Grob*me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
Real ss = Staff_symbol_referencer::staff_space (me);
SCM size = me->get_property ("bar-size");
if (scm_is_number (size))
barline so we return 0.0 in the next alternative.
*/
Real ysize = (Staff_symbol_referencer::line_count (me) -1);
- ysize = ysize * ss + Staff_symbol_referencer::line_thickness (me);
+ ysize = ysize * ss + Staff_symbol_referencer::line_thickness (me);
return scm_make_real (ysize);
}
else
return scm_int2num (0);
}
-
-
ADD_INTERFACE (Bar_line, "bar-line-interface",
- "Bar line.\n"
-"\n"
-"Print a special bar symbol. It replaces the \n"
-"regular bar symbol with a special\n"
-"symbol. The argument @var{bartype} is a string which specifies the\n"
-"kind of bar to print. Options are @code{:|}, \n"
-"@code{|:}, @code{:|:},\n"
-"@code{||}, @code{|.},\n"
-"@code{.|}, and @code{.|.}. \n"
-"\n"
-"These produce, respectively, a right repeat, a left repeat, a double\n"
-"repeat, a double bar, a start bar, an end bar, and a thick double bar.\n"
-"If @var{bartype} is set to @code{empty} then nothing is printed,\n"
-"but a line break is allowed at that spot.\n",
- "bar-size-procedure kern thin-kern hair-thickness thick-thickness glyph bar-size break-glyph-function");
+ "Bar line.\n"
+ "\n"
+ "Print a special bar symbol. It replaces the \n"
+ "regular bar symbol with a special\n"
+ "symbol. The argument @var{bartype} is a string which specifies the\n"
+ "kind of bar to print. Options are @code{:|}, \n"
+ "@code{|:}, @code{:|:},\n"
+ "@code{||}, @code{|.},\n"
+ "@code{.|}, and @code{.|.}. \n"
+ "\n"
+ "These produce, respectively, a right repeat, a left repeat, a double\n"
+ "repeat, a double bar, a start bar, an end bar, and a thick double bar.\n"
+ "If @var{bartype} is set to @code{empty} then nothing is printed,\n"
+ "but a line break is allowed at that spot.\n",
+ "bar-size-procedure kern thin-kern hair-thickness thick-thickness glyph bar-size break-glyph-function");
#include "context.hh"
/*
-
-TODO: detect the top staff (stavesFound), and acknowledge staff-group
-system-start-delims. If we find these, and the top staff is in the
-staff-group, add padding to the bar number.
-
+ TODO: detect the top staff (stavesFound), and acknowledge staff-group
+ system-start-delims. If we find these, and the top staff is in the
+ staff-group, add padding to the bar number.
*/
-
class Bar_number_engraver : public Engraver
{
protected:
- Item* text_;
+ Item *text_;
protected:
virtual void stop_translation_timestep ();
virtual void acknowledge_grob (Grob_info);
virtual void process_music ();
void create_items ();
- TRANSLATOR_DECLARATIONS (Bar_number_engraver );
+ TRANSLATOR_DECLARATIONS (Bar_number_engraver);
};
-
void
Bar_number_engraver::process_music ()
{
// todo include (&&!time->cadenza_b_)
SCM wb = get_property ("whichBar");
-
+
if (scm_is_string (wb))
{
Moment mp (robust_scm2moment (get_property ("measurePosition"), Moment (0)));
SCM bn = get_property ("currentBarNumber");
SCM proc = get_property ("barNumberVisibility");
if (scm_is_number (bn) && ly_c_procedure_p (proc)
- && to_boolean (scm_call_1(proc, bn)))
+ && to_boolean (scm_call_1 (proc, bn)))
{
create_items ();
// guh.
}
-
-
Bar_number_engraver::Bar_number_engraver ()
{
text_ = 0;
}
-
void
Bar_number_engraver::acknowledge_grob (Grob_info inf)
{
- Grob * s = inf.grob_;
+ Grob *s = inf.grob_;
if (text_
- && dynamic_cast<Item*> (s)
+ && dynamic_cast<Item *> (s)
&& s->get_property ("break-align-symbol") == ly_symbol2scm ("left-edge"))
{
/*
}
}
-void
+void
Bar_number_engraver::stop_translation_timestep ()
{
if (text_)
{
text_->set_property ("side-support-elements", get_property ("stavesFound"));
-
+
text_ = 0;
}
}
-
void
Bar_number_engraver::create_items ()
{
}
ADD_TRANSLATOR (Bar_number_engraver,
-/* descr */ "A bar number is created whenever measurePosition is zero. It is\n"
- "put on top of all staves, and appears only at left side of the staff. "
- "The staves are taken from @code{stavesFound}, which is maintained by "
- "@code{@ref{Staff_collecting_engraver}}. "
- ,
-
-/* creats*/ "BarNumber",
-/* accepts */ "",
-/* acks */ "break-aligned-interface",
-/* reads */ "currentBarNumber stavesFound barNumberVisibility" ,
-/* write */ "");
+ /* descr */ "A bar number is created whenever measurePosition is zero. It is\n"
+ "put on top of all staves, and appears only at left side of the staff. "
+ "The staves are taken from @code{stavesFound}, which is maintained by "
+ "@code{@ref{Staff_collecting_engraver}}. ",
+
+ /* creats*/ "BarNumber",
+ /* accepts */ "",
+ /* acks */ "break-aligned-interface",
+ /* reads */ "currentBarNumber stavesFound barNumberVisibility",
+ /* write */ "");
/*
- Determine whether a beam is concave.
- */
+ Determine whether a beam is concave.
+*/
#include <math.h>
bool above = false;
bool below = false;
bool concave = false;
-
+
/*
notes above and below the interval covered by 1st and last note.
- */
+ */
for (int i = 1; i < positions.size () - 1; i++)
{
above = above || (positions[i] > covering[UP]);
below = below || (positions[i] < covering[DOWN]);
}
-
concave = concave || (above && below);
/*
A note as close or closer to the beam than begin and end, but the
note is reached in the opposite direction as the last-first dy
- */
- int dy = positions.top() - positions[0];
- int closest = (beam_dir * positions.top()) >? (beam_dir *positions[0]);
+ */
+ int dy = positions.top () - positions[0];
+ int closest = (beam_dir * positions.top ()) >? (beam_dir *positions[0]);
for (int i = 2; !concave && i < positions.size () - 1; i++)
{
- int inner_dy = positions[i] - positions[i-1];
+ int inner_dy = positions[i] - positions[i - 1];
if (sign (inner_dy) != sign (dy)
&& (beam_dir * positions[i] >= closest
- || beam_dir * positions[i-1] >= closest))
+ || beam_dir * positions[i - 1] >= closest))
concave = true;
}
-
- bool all_closer = true;
- for (int i = 1; all_closer && i < positions.size ()-1; i++)
+
+ bool all_closer = true;
+ for (int i = 1; all_closer && i < positions.size () - 1; i++)
{
- all_closer = all_closer &&
- (beam_dir * positions[i] > closest);
+ all_closer = all_closer
+ && (beam_dir * positions[i] > closest);
}
concave = concave || all_closer;
calc_concaveness (Array<int> const &positions, Direction beam_dir)
{
Real dy = positions.top () - positions[0];
- Real slope = dy / Real (positions.size() - 1);
+ Real slope = dy / Real (positions.size () - 1);
Real concaveness = 0.0;
- for (int i = 1; i < positions.size() - 1; i++)
+ for (int i = 1; i < positions.size () - 1; i++)
{
Real line_y = slope * i + positions[0];
concaveness += (beam_dir * (positions[i] - line_y)) >? 0.0;
}
- concaveness /= positions.size () ;
+ concaveness /= positions.size ();
/*
Normalize. For dy = 0, the slope ends up as 0 anyway, so the
{
Grob *me = unsmob_grob (smob);
- Link_array<Grob> stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
if (is_knee (me))
return SCM_UNSPECIFIED;
-
+
Direction beam_dir = CENTER;
- for (int i = stems.size (); i--; )
+ for (int i = stems.size (); i--;)
{
if (Stem::is_invisible (stems[i]))
stems.del (i);
beam_dir = dir;
}
}
-
+
if (stems.size () <= 2)
return SCM_UNSPECIFIED;
-
Array<int> close_positions;
Array<int> far_positions;
for (int i = 0; i < stems.size (); i++)
Hmmm.. wait, for the beams in the last measure of morgenlied,
this doesn't look so good. Let's try the heads farthest from
the beam.
-
- */
+
+ */
Interval posns = Stem::head_positions (stems[i]);
-
+
close_positions.push ((int) rint (posns[beam_dir]));
far_positions.push ((int) rint (posns[-beam_dir]));
}
- if (is_concave_single_notes (far_positions, beam_dir))
+ if (is_concave_single_notes (far_positions, beam_dir))
{
Drul_array<Real> pos = ly_scm2interval (me->get_property ("positions"));
Real r = linear_combination (pos, 0.0);
else
{
Real concaveness = (calc_concaveness (far_positions, beam_dir)
- + calc_concaveness (close_positions, beam_dir))/2;
-
+ + calc_concaveness (close_positions, beam_dir)) / 2;
me->set_property ("concaveness", scm_from_double (concaveness));
}
-
+
return SCM_UNSPECIFIED;
}
-/*
+/*
beam-engraver.cc -- implement Beam_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "engraver.hh"
#include "beam.hh"
class Beam_engraver : public Engraver
{
-protected:
- Music * start_ev_;
-
+protected:
+ Music *start_ev_;
+
Spanner *finished_beam_;
Spanner *beam_;
- Music * prev_start_ev_;
+ Music *prev_start_ev_;
+
+ Music *now_stop_ev_;
- Music * now_stop_ev_;
-
- Beaming_info_list * beam_info_;
- Beaming_info_list * finished_beam_info_;
+ Beaming_info_list *beam_info_;
+ Beaming_info_list *finished_beam_info_;
/// location within measure where beam started.
Moment beam_start_location_;
virtual void finalize ();
virtual void acknowledge_grob (Grob_info);
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void process_music ();
virtual bool valid_start_point ();
virtual bool valid_end_point ();
-
+
public:
TRANSLATOR_DECLARATIONS (Beam_engraver);
};
-
/*
Hmm. this isn't necessary, since grace beams and normal beams are
always nested.
- */
+*/
bool
Beam_engraver::valid_start_point ()
{
beam_start_location_ = mp;
beam_start_mom_ = now_mom ();
-
+
beam_info_ = new Beaming_info_list;
-
+
/* urg, must copy to Auto_beam_engraver too */
}
}
-
void
Beam_engraver::typeset_beam ()
{
{
finished_beam_info_->beamify (beat_length_, subdivide_beams_);
Beam::set_beaming (finished_beam_, finished_beam_info_);
-
+
delete finished_beam_info_;
finished_beam_info_ = 0;
finished_beam_ = 0;
Beam_engraver::start_translation_timestep ()
{
start_ev_ = 0;
-
+
if (beam_)
{
set_melisma (true);
-
+
subdivide_beams_ = to_boolean (get_property ("subdivideBeams"));
beat_length_ = robust_scm2moment (get_property ("beatLength"), Moment (1, 4));
}
Beam_engraver::stop_translation_timestep ()
{
typeset_beam ();
- if (now_stop_ev_ )
+ if (now_stop_ev_)
{
finished_beam_ = beam_;
finished_beam_info_ = beam_info_;
Moment now = now_mom ();
if (!valid_start_point ())
- return ;
-
- Item *stem = dynamic_cast<Item*> (info.grob_);
+ return;
+
+ Item *stem = dynamic_cast<Item *> (info.grob_);
if (Stem::get_beam (stem))
return;
- Music* m = info.music_cause ();
+ Music *m = info.music_cause ();
if (!m->is_mus_type ("rhythmic-event"))
{
String s = _ ("stem must have Rhythmic structure");
info.music_cause ()->origin ()->warning (s);
else
::warning (s);
-
+
return;
}
-
last_stem_added_at_ = now;
- int durlog = unsmob_duration (m->get_property ("duration"))-> duration_log ();
+ int durlog = unsmob_duration (m->get_property ("duration"))-> duration_log ();
if (durlog <= 2)
{
m->origin ()->warning (_ ("stem doesn't fit in beam"));
}
stem->set_property ("duration-log",
- scm_int2num (durlog));
+ scm_int2num (durlog));
Moment stem_location = now - beam_start_mom_ + beam_start_location_;
beam_info_->add_stem (stem_location,
- (durlog- 2) >? 0);
+ (durlog- 2) >? 0);
Beam::add_stem (beam_, stem);
}
}
}
-
-
-
ADD_TRANSLATOR (Beam_engraver,
-/* descr */ "Handles Beam events by engraving Beams. If omitted, then notes will be "
-"printed with flags instead of beams.",
-/* creats*/ "Beam",
-/* accepts */ "beam-event",
-/* acks */ "stem-interface rest-interface",
-/* reads */ "beamMelismaBusy beatLength subdivideBeams",
-/* write */ "");
-
+ /* descr */ "Handles Beam events by engraving Beams. If omitted, then notes will be "
+ "printed with flags instead of beams.",
+ /* creats*/ "Beam",
+ /* accepts */ "beam-event",
+ /* acks */ "stem-interface rest-interface",
+ /* reads */ "beamMelismaBusy beatLength subdivideBeams",
+ /* write */ "");
class Grace_beam_engraver : public Beam_engraver
{
public:
- TRANSLATOR_DECLARATIONS (Grace_beam_engraver);
+ TRANSLATOR_DECLARATIONS (Grace_beam_engraver);
protected:
virtual bool valid_start_point ();
return n.grace_part_ != Rational (0);
}
-
bool
Grace_beam_engraver::valid_end_point ()
{
return beam_ && valid_start_point ();
}
-
-
ADD_TRANSLATOR (Grace_beam_engraver,
-/* descr */ "Handles Beam events by engraving Beams. If omitted, then notes will "
-"be printed with flags instead of beams. Only engraves beams when we "
-" are at grace points in time. "
-,
-/* creats*/ "Beam",
-/* accepts */ "beam-event",
-/* acks */ "stem-interface rest-interface",
-/* reads */ "beamMelismaBusy beatLength allowBeamBreak subdivideBeams",
-/* write */ "");
+ /* descr */ "Handles Beam events by engraving Beams. If omitted, then notes will "
+ "be printed with flags instead of beams. Only engraves beams when we "
+ " are at grace points in time. ",
+ /* creats*/ "Beam",
+ /* accepts */ "beam-event",
+ /* acks */ "stem-interface rest-interface",
+ /* reads */ "beamMelismaBusy beatLength allowBeamBreak subdivideBeams",
+ /* write */ "");
source file of the GNU LilyPond music typesetter
(c) 1996--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#include "performer.hh"
#include "audio-item.hh"
#include "global-context.hh"
#include "warn.hh"
-class Beam_performer : public Performer {
+class Beam_performer : public Performer
+{
public:
TRANSLATOR_DECLARATIONS (Beam_performer);
-
+
protected:
- virtual bool try_music (Music *ev) ;
+ virtual bool try_music (Music *ev);
virtual void start_translation_timestep ();
virtual void process_music ();
void set_melisma (bool);
now_stop_ev_ = 0;
}
-void
+void
Beam_performer::process_music ()
{
if (now_stop_ev_)
}
}
-
void
Beam_performer::set_melisma (bool ml)
{
SCM b = get_property ("autoBeaming");
if (!to_boolean (b))
-context ()->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F);
+ context ()->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F);
}
void
start_ev_ = 0;
now_stop_ev_ = 0;
}
-
+
bool
Beam_performer::try_music (Music *m)
{
}
ADD_TRANSLATOR (Beam_performer, "", "",
- "beam-event", "", "", "");
+ "beam-event", "", "", "");
/*
beam-quanting.cc -- implement Beam quanting functions
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
Jan Nieuwenhuizen <janneke@gnu.org>
-
*/
#include <math.h>
#include "align-interface.hh"
const int INTER_QUANT_PENALTY = 1000;
-const Real SECONDARY_BEAM_DEMERIT = 10.0;
+const Real SECONDARY_BEAM_DEMERIT = 10.0;
const int STEM_LENGTH_DEMERIT_FACTOR = 5;
/*
threshold to combat rounding errors.
- */
-const Real BEAM_EPS = 1e-3;
+*/
+const Real BEAM_EPS = 1e-3;
// possibly ridiculous, but too short stems just won't do
const int STEM_LENGTH_LIMIT_PENALTY = 5000;
return fabs (x) * ((x < 0) ? fac : 1.0);
}
-
struct Quant_score
{
Real yl;
#endif
};
-
/*
TODO:
-
- - Make all demerits customisable
- - One sensible check per demerit (what's this --hwn)
+ - Make all demerits customisable
- - Add demerits for quants per se, as to forbid a specific quant
- entirely
+ - One sensible check per demerit (what's this --hwn)
+ - Add demerits for quants per se, as to forbid a specific quant
+ entirely
*/
int
-best_quant_score_idx (Array<Quant_score> const & qscores)
+best_quant_score_idx (Array<Quant_score> const &qscores)
{
Real best = 1e6;
int best_idx = -1;
{
if (qscores[i].demerits < best)
{
- best = qscores [i].demerits ;
+ best = qscores [i].demerits;
best_idx = i;
}
}
programming_error ("Huh? No best beam quant score?");
best_idx = 0;
}
-
-
+
return best_idx;
}
-
+
MAKE_SCHEME_CALLBACK (Beam, quanting, 1);
SCM
Beam::quanting (SCM smob)
Real yl = scm_to_double (scm_car (s));
Real yr = scm_to_double (scm_cdr (s));
-
/*
Calculations are relative to a unit-scaled staff, i.e. the quants are
divided by the current staff_space.
-
- */
+
+ */
Real ss = Staff_symbol_referencer::staff_space (me);
- Real thickness = Beam::get_thickness (me) / ss ;
+ Real thickness = Beam::get_thickness (me) / ss;
Real slt = Staff_symbol_referencer::line_thickness (me) / ss;
Real dy_mus = robust_scm2double (me->get_property ("least-squares-dy"), 0);
Real hang = 1.0 - (thickness - slt) / 2;
Real quants [] = {straddle, sit, inter, hang };
-
-
- int num_quants = int (sizeof (quants)/sizeof (Real));
+ int num_quants = int (sizeof (quants) / sizeof (Real));
Array<Real> quantsl;
Array<Real> quantsr;
wtk1-fugue2.
- (result indexes between 70 and 575) ? --hwn.
+ (result indexes between 70 and 575) ? --hwn.
*/
-
-
/*
Do stem computations. These depend on YL and YR linearly, so we can
precompute for every stem 2 factors.
- */
- Link_array<Grob> stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
+ */
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
Array<Stem_info> stem_infos;
Array<Real> base_lengths;
- Array<Real> stem_xposns;
+ Array<Real> stem_xposns;
Drul_array<bool> dirs_found (0, 0);
Grob *common[2];
for (int a = 2; a--;)
common[a] = common_refpoint_of_array (stems, me, Axis (a));
- Grob * fvs = first_visible_stem (me);
+ Grob *fvs = first_visible_stem (me);
Grob *lvs = last_visible_stem (me);
Real xl = fvs ? fvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0;
Real xr = fvs ? lvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0;
Sometimes my head is screwed on backwards. The stemlength are
AFFINE linear in YL and YR. If YL == YR == 0, then we might have
stem_y != 0.0, when we're cross staff.
-
- */
+
+ */
for (int i = 0; i < stems.size (); i++)
{
- Grob*s = stems[i];
+ Grob *s = stems[i];
Stem_info si (Stem::get_stem_info (s));
si.scale (1 / ss);
dirs_found[stem_infos.top ().dir_] = true;
bool f = to_boolean (s->get_property ("french-beaming"))
- && s != lvs && s != fvs;
+ && s != lvs && s != fvs;
base_lengths.push (calc_stem_y (me, s, common, xl, xr,
Interval (0, 0), f) / ss);
Grob *commony = fvs->common_refpoint (lvs, Y_AXIS);
xstaff = Align_interface::has_interface (commony);
}
-
+
Direction ldir = Direction (stem_infos[0].dir_);
Direction rdir = Direction (stem_infos.top ().dir_);
bool is_knee = dirs_found[LEFT] && dirs_found[RIGHT];
-
int region_size = REGION_SIZE;
/*
- Knees are harder, lets try some more possibilities for knees.
- */
+ Knees are harder, lets try some more possibilities for knees.
+ */
if (is_knee)
region_size += 2;
/*
Asymetry ? should run to <= region_size ?
- */
- for (int i = -region_size ; i < region_size; i++)
+ */
+ for (int i = -region_size; i < region_size; i++)
for (int j = 0; j < num_quants; j++)
{
quantsl.push (i + quants[j] + int (yl));
}
Array<Quant_score> qscores;
-
- for (int l = 0; l < quantsl.size (); l++)
+
+ for (int l = 0; l < quantsl.size (); l++)
for (int r = 0; r < quantsr.size (); r++)
{
Quant_score qs;
qs.yl = quantsl[l];
qs.yr = quantsr[r];
qs.demerits = 0.0;
-
+
qscores.push (qs);
}
parameters outside of the loop, we can save a lot of time. */
for (int i = qscores.size (); i--;)
{
- Real d = score_slopes_dy (qscores[i].yl, qscores[i].yr,
- dy_mus, yr- yl,
- xr - xl,
- xstaff);
+ Real d = score_slopes_dy (qscores[i].yl, qscores[i].yr,
+ dy_mus, yr- yl,
+ xr - xl,
+ xstaff);
qscores[i].demerits += d;
#if DEBUG_QUANTING
Real rad = Staff_symbol_referencer::staff_radius (me);
Drul_array<int> edge_beam_counts
- (Stem::beam_multiplicity (stems[0]).length () + 1,
- Stem::beam_multiplicity (stems.top ()).length () + 1);
-
+ (Stem::beam_multiplicity (stems[0]).length () + 1,
+ Stem::beam_multiplicity (stems.top ()).length () + 1);
+
Real beam_translation = get_beam_translation (me) / ss;
Real reasonable_score = (is_knee) ? 200000 : 100;
{
Real d = score_forbidden_quants (qscores[i].yl, qscores[i].yr,
rad, slt, thickness, beam_translation,
- edge_beam_counts, ldir, rdir);
+ edge_beam_counts, ldir, rdir);
qscores[i].demerits += d;
#if DEBUG_QUANTING
if (qscores[i].demerits < reasonable_score)
{
Real d = score_stem_lengths (stems, stem_infos,
- base_lengths, stem_xposns,
- xl, xr,
- is_knee,
- qscores[i].yl, qscores[i].yr);
- qscores[i].demerits += d;
+ base_lengths, stem_xposns,
+ xl, xr,
+ is_knee,
+ qscores[i].yl, qscores[i].yr);
+ qscores[i].demerits += d;
#if DEBUG_QUANTING
qscores[i].score_card_ += to_string (" L %.2f", d);
int i = 0;
Real mindist = 1e6;
- for (; i < qscores.size (); i ++)
+ for (; i < qscores.size (); i++)
{
Real d = fabs (qscores[i].yl- ins[LEFT]) + fabs (qscores[i].yr - ins[RIGHT]);
if (d < mindist)
programming_error ("Could not find quant.");
}
#endif
-
+
me->set_property ("positions",
ly_interval2scm (Drul_array<Real> (qscores[best_idx].yl,
qscores[best_idx].yr)));
if (to_boolean (me->get_layout ()->lookup_variable (ly_symbol2scm ("debug-beam-quanting"))))
{
qscores[best_idx].score_card_ += to_string ("i%d", best_idx);
-
+
// debug quanting
me->set_property ("quant-score",
scm_makfrom0str (qscores[best_idx].score_card_.to_str0 ()));
Array<Stem_info> const &stem_infos,
Array<Real> const &base_stem_ys,
Array<Real> const &stem_xs,
- Real xl, Real xr,
- bool knee,
+ Real xl, Real xr,
+ bool knee,
Real yl, Real yr)
{
Real limit_penalty = STEM_LENGTH_LIMIT_PENALTY;
Drul_array<Real> score (0, 0);
Drul_array<int> count (0, 0);
-
+
for (int i = 0; i < stems.size (); i++)
{
- Grob* s = stems[i];
+ Grob *s = stems[i];
if (Stem::is_invisible (s))
continue;
Real x = stem_xs[i];
- Real dx = xr-xl;
- Real beam_y = dx ? yr *(x - xl)/dx + yl * ( xr - x)/dx : (yr + yl)/2;
+ Real dx = xr - xl;
+ Real beam_y = dx ? yr * (x - xl) / dx + yl * (xr - x) / dx : (yr + yl) / 2;
Real current_y = beam_y + base_stem_ys[i];
Real length_pen = STEM_LENGTH_DEMERIT_FACTOR;
-
+
Stem_info info = stem_infos[i];
Direction d = info.dir_;
score[d] += limit_penalty * (0 >? (d * (info.shortest_y_ - current_y)));
-
+
Real ideal_diff = d * (current_y - info.ideal_y_);
Real ideal_score = shrink_extra_weight (ideal_diff, 1.5);
-
+
/* We introduce a power, to make the scoring strictly
convex. Otherwise a symmetric knee beam (up/down/up/down)
does not have an optimum in the middle. */
if (knee)
ideal_score = pow (ideal_score, 1.1);
-
+
score[d] += length_pen * ideal_score;
- count[d] ++;
+ count[d]++;
}
Direction d = DOWN;
do
- {
+ {
score[d] /= (count[d] >? 1);
}
while (flip (&d) != DOWN);
- return score[LEFT]+score[RIGHT];
+ return score[LEFT] + score[RIGHT];
}
Real
TODO: find a way to incorporate the complexity of the beam in this
penalty.
- */
- if (fabs (dy/dx) > ROUND_TO_ZERO_SLOPE
+ */
+ if (fabs (dy / dx) > ROUND_TO_ZERO_SLOPE
&& sign (dy_damp) != sign (dy))
{
dem += DAMPING_DIRECTION_PENALTY;
}
- dem += MUSICAL_DIRECTION_FACTOR * (0 >? (fabs (dy) - fabs (dy_mus)));
-
+ dem += MUSICAL_DIRECTION_FACTOR *(0 >? (fabs (dy) - fabs (dy_mus)));
- Real slope_penalty = IDEAL_SLOPE_FACTOR;
+ Real slope_penalty = IDEAL_SLOPE_FACTOR;
- /* Xstaff beams tend to use extreme slopes to get short stems. We
- put in a penalty here. */
- if (xstaff)
- slope_penalty *= 10;
+ /* Xstaff beams tend to use extreme slopes to get short stems. We
+ put in a penalty here. */
+ if (xstaff)
+ slope_penalty *= 10;
- /* Huh, why would a too steep beam be better than a too flat one ? */
- dem += shrink_extra_weight (fabs (dy_damp) - fabs (dy), 1.5)
- * slope_penalty;
+ /* Huh, why would a too steep beam be better than a too flat one ? */
+ dem += shrink_extra_weight (fabs (dy_damp) - fabs (dy), 1.5)
+ * slope_penalty;
- return dem;
+ return dem;
}
-
static Real
my_modf (Real x)
{
return x - floor (x);
}
-
/*
TODO: The fixed value SECONDARY_BEAM_DEMERIT is probably flawed:
- because for 32nd and 64th beams the forbidden quants are relatively
- more important than stem lengths.
+ because for 32nd and 64th beams the forbidden quants are relatively
+ more important than stem lengths.
*/
Real
Beam::score_forbidden_quants (Real yl, Real yr,
Real dy = yr - yl;
Drul_array<Real> y (yl, yr);
Drul_array<Direction> dirs (ldir, rdir);
-
+
Real extra_demerit = SECONDARY_BEAM_DEMERIT / (beam_counts[LEFT] >? beam_counts[RIGHT]);
Direction d = LEFT;
Real dem = 0.0;
-
do
{
will be in the gap of the (2, sit) quant, leading to a
false demerit.
*/
- Real gap1 = y[d] - stem_dir * ((j-1) * beam_translation + thickness / 2 - slt/2.2 );
- Real gap2 = y[d] - stem_dir * (j * beam_translation - thickness / 2 + slt/2.2);
+ Real gap1 = y[d] - stem_dir * ((j - 1) * beam_translation + thickness / 2 - slt / 2.2);
+ Real gap2 = y[d] - stem_dir * (j * beam_translation - thickness / 2 + slt / 2.2);
Interval gap;
gap.add_point (gap1);
gap.add_point (gap2);
- for (Real k = - radius ;
- k <= radius + BEAM_EPS; k += 1.0)
+ for (Real k = -radius;
+ k <= radius + BEAM_EPS; k += 1.0)
if (gap.contains (k))
{
- Real dist = fabs (gap[UP]-k) <? fabs (gap[DOWN] - k);
+ Real dist = fabs (gap[UP] - k) <? fabs (gap[DOWN] - k);
/*
this parameter is tuned to grace-stem-length.ly
*/
Real fixed_demerit = 0.4;
-
+
dem += extra_demerit
- * (fixed_demerit +
- (1-fixed_demerit) * (dist / gap.length())* 2);
+ * (fixed_demerit
+ + (1 - fixed_demerit) * (dist / gap.length ())* 2);
}
}
}
- while ((flip (&d))!= LEFT);
-
+ while ((flip (&d))!= LEFT);
if ((beam_counts[LEFT] >? beam_counts[RIGHT]) >= 2)
{
Real inter = 0.5;
Real hang = 1.0 - (thickness - slt) / 2;
-
Direction d = LEFT;
do
{
if (dirs[d] == UP && dy <= BEAM_EPS
&& fabs (my_modf (y[d]) - sit) < BEAM_EPS)
dem += extra_demerit;
-
+
if (dirs[d] == DOWN && dy >= BEAM_EPS
&& fabs (my_modf (y[d]) - hang) < BEAM_EPS)
dem += extra_demerit;
if (dirs[d] == UP && dy <= BEAM_EPS
&& fabs (my_modf (y[d]) - straddle) < BEAM_EPS)
dem += extra_demerit;
-
+
if (dirs[d] == DOWN && dy >= BEAM_EPS
&& fabs (my_modf (y[d]) - straddle) < BEAM_EPS)
dem += extra_demerit;
}
while (flip (&d) != LEFT);
}
-
+
return dem;
}
-
/*
beam.cc -- implement Beam
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
Jan Nieuwenhuizen <janneke@gnu.org>
*/
/*
-TODO:
+ TODO:
- Determine auto knees based on positions if it's set by the user.
- the code is littered with * and / staff_space calls for
- #'positions. Consider moving to real-world coordinates?
+ #'positions. Consider moving to real-world coordinates?
- Problematic issue is user tweaks (user tweaks are in staff-coordinates.)
-
-Notes:
+ Problematic issue is user tweaks (user tweaks are in staff-coordinates.)
- - Stems run to the Y-center of the beam.
-
- - beam_translation is the offset between Y centers of the beam.
-
-*/
+ Notes:
+ - Stems run to the Y-center of the beam.
+ - beam_translation is the offset between Y centers of the beam.
+*/
#include <math.h> // tanh.
#include "spanner.hh"
#include "warn.hh"
-
#if DEBUG_QUANTING
-#include "text-item.hh" // debug output.
-#include "font-interface.hh" // debug output.
+#include "text-item.hh" // debug output.
+#include "font-interface.hh" // debug output.
#endif
-
void
Beam::add_stem (Grob *me, Grob *s)
{
Pointer_group_interface::add_grob (me, ly_symbol2scm ("stems"), s);
-
+
s->add_dependency (me);
assert (!Stem::get_beam (s));
s->set_property ("beam", me->self_scm ());
- add_bound_item (dynamic_cast<Spanner*> (me), dynamic_cast<Item*> (s));
+ add_bound_item (dynamic_cast<Spanner *> (me), dynamic_cast<Item *> (s));
}
-
Real
-Beam::get_thickness (Grob * me)
+Beam::get_thickness (Grob *me)
{
return robust_scm2double (me->get_property ("thickness"), 0)
* Staff_symbol_referencer::staff_space (me);
/* Maximum beam_count. */
int
-Beam::get_beam_count (Grob *me)
+Beam::get_beam_count (Grob *me)
{
int m = 0;
for (SCM s = me->get_property ("stems"); scm_is_pair (s); s = scm_cdr (s))
return m;
}
-
/*
Space return space between beams.
- */
+*/
MAKE_SCHEME_CALLBACK (Beam, space_function, 2);
SCM
Beam::space_function (SCM smob, SCM beam_count)
{
Grob *me = unsmob_grob (smob);
-
+
Real staff_space = Staff_symbol_referencer::staff_space (me);
Real line = Staff_symbol_referencer::line_thickness (me);
Real thickness = get_thickness (me);
-
+
Real beam_translation = scm_to_int (beam_count) < 4
? (2*staff_space + line - thickness) / 2.0
: (3*staff_space + line - thickness) / 3.0;
-
+
return scm_make_real (beam_translation);
}
-
/* After pre-processing all directions should be set.
Several post-processing routines (stem, slur, script) need stem/beam
direction.
SCM
Beam::before_line_breaking (SCM smob)
{
- Grob *me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
/* Beams with less than 2 two stems don't make much sense, but could happen
when you do
-
+
[r8 c8 r8].
-
- For a beam that only has one stem, we try to do some disappearance magic:
- we revert the flag, and move on to The Eternal Engraving Fields. */
+
+ For a beam that only has one stem, we try to do some disappearance magic:
+ we revert the flag, and move on to The Eternal Engraving Fields. */
int count = visible_stem_count (me);
if (count < 2)
else if (scm_ilength (stems) == 0)
{
me->suicide ();
- return SCM_UNSPECIFIED;
+ return SCM_UNSPECIFIED;
}
}
if (count >= 1)
return SCM_EOL;
}
-
/*
We want a maximal number of shared beams, but if there is choice, we
take the one that is closest to the end of the stem. This is for situations like
- x
- |
- |
+ x
+ |
+ |
|===|
|=
|
x
-
-
- */
+*/
int
position_with_maximal_common_beams (SCM left_beaming, SCM right_beaming,
Direction left_dir,
int best_count = 0;
int best_start = 0;
for (int i = lslice[-left_dir];
- (i - lslice[left_dir])* left_dir <= 0 ; i+= left_dir)
+ (i - lslice[left_dir])* left_dir <= 0; i+= left_dir)
{
int count = 0;
- for ( SCM s = scm_car (right_beaming); scm_is_pair (s); s = scm_cdr (s))
+ for (SCM s = scm_car (right_beaming); scm_is_pair (s); s = scm_cdr (s))
{
- int k = - right_dir * scm_to_int (scm_car (s)) + i;
+ int k = -right_dir * scm_to_int (scm_car (s)) + i;
if (scm_c_memq (scm_int2num (k), left_beaming) != SCM_BOOL_F)
- count ++;
+ count++;
}
if (count >= best_count)
{
- best_count = count;
+ best_count = count;
best_start = i;
}
}
void
Beam::connect_beams (Grob *me)
{
- Link_array<Grob> stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
Slice last_int;
last_int.set_empty ();
int start_point = position_with_maximal_common_beams
(last_beaming, this_beaming,
last_dir, this_dir);
-
+
Direction d = LEFT;
- Slice new_slice ;
+ Slice new_slice;
do
{
- if (d == RIGHT && i == stems.size ()-1)
+ if (d == RIGHT && i == stems.size () - 1)
continue;
-
+
new_slice.set_empty ();
SCM s = index_get_cell (this_beaming, d);
for (; scm_is_pair (s); s = scm_cdr (s))
{
- int new_beam_pos =
- start_point - this_dir * scm_to_int (scm_car (s));
+ int new_beam_pos
+ = start_point - this_dir * scm_to_int (scm_car (s));
new_slice.add_point (new_beam_pos);
scm_set_car_x (s, scm_int2num (new_beam_pos));
}
-
}
while (flip (&d) != LEFT);
if (!new_slice.is_empty ())
- last_int = new_slice;
+ last_int = new_slice;
}
else
{
- scm_set_car_x ( this_beaming, SCM_EOL);
+ scm_set_car_x (this_beaming, SCM_EOL);
SCM s = scm_cdr (this_beaming);
for (; scm_is_pair (s); s = scm_cdr (s))
{
- int np = - this_dir * scm_to_int (scm_car (s));
+ int np = -this_dir * scm_to_int (scm_car (s));
scm_set_car_x (s, scm_int2num (np));
last_int.add_point (np);
}
last_dir = this_dir;
}
}
- }
-
+}
/*
TODO: should not make beams per stem, but per Y-level.
- */
+*/
MAKE_SCHEME_CALLBACK (Beam, print, 1);
SCM
Beam::print (SCM grob)
{
Spanner *me = unsmob_spanner (grob);
position_beam (me);
-
- Link_array<Grob> stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
- Grob* xcommon = common_refpoint_of_array (stems, me, X_AXIS);
+
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
+ Grob *xcommon = common_refpoint_of_array (stems, me, X_AXIS);
xcommon = me->get_bound (LEFT)->common_refpoint (xcommon, X_AXIS);
xcommon = me->get_bound (RIGHT)->common_refpoint (xcommon, X_AXIS);
else
pos = ly_scm2realdrul (posns);
- scale_drul (&pos, Staff_symbol_referencer::staff_space (me));
-
+ scale_drul (&pos, Staff_symbol_referencer::staff_space (me));
+
Real dy = pos[RIGHT] - pos[LEFT];
- Real slope = (dy && dx) ? dy/dx : 0;
-
+ Real slope = (dy && dx) ? dy / dx : 0;
+
Real thick = get_thickness (me);
Real bdy = get_beam_translation (me);
SCM last_beaming = SCM_EOL;
Real last_xposn = -1;
- Real last_stem_width = -1 ;
+ Real last_stem_width = -1;
Real gap_length = robust_scm2double (me->get_property ("gap"), 0.0);
-
+
Stencil the_beam;
Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
-
+
for (int i = 0; i<= stems.size (); i++)
{
- Grob * st = (i < stems.size ()) ? stems[i] : 0;
-
+ Grob *st = (i < stems.size ()) ? stems[i] : 0;
+
SCM this_beaming = st ? st->get_property ("beaming") : SCM_EOL;
Real xposn = st ? st->relative_coordinate (xcommon, X_AXIS) : 0.0;
- Real stem_width = st ? robust_scm2double (st->get_property ("thickness"), 1.0) *lt : 0 ;
+ Real stem_width = st ? robust_scm2double (st->get_property ("thickness"), 1.0) *lt : 0;
Direction stem_dir = st ? to_dir (st->get_property ("direction")) : CENTER;
/*
We do the space left of ST, with lfliebertjes pointing to the
right from the left stem, and rfliebertjes pointing left from
right stem.
- */
+ */
SCM left = (i > 0) ? scm_cdr (last_beaming) : SCM_EOL;
SCM right = st ? scm_car (this_beaming) : SCM_EOL;
Array<int> full_beams;
Array<int> lfliebertjes;
- Array<int> rfliebertjes;
+ Array<int> rfliebertjes;
for (SCM s = left;
scm_is_pair (s); s = scm_cdr (s))
}
else
{
- lfliebertjes.push (b);
+ lfliebertjes.push (b);
}
}
for (SCM s = right;
/*
how much to stick out for beams across linebreaks
- */
+ */
Real break_overshoot = 3.0;
Real w = (i > 0 && st) ? (xposn - last_xposn) : break_overshoot;
}
if (st)
- w += stem_width/ 2 ;
-
+ w += stem_width/ 2;
Real blot = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
Stencil whole = Lookup::beam (slope, w, thick, blot);
for (int j = full_beams.size (); j--;)
{
Stencil b (whole);
-
+
if (k++ < gap_count)
{
b = gapped;
b.translate_axis (gap_length, X_AXIS);
}
- b.translate_axis (last_xposn - x0 + stem_offset, X_AXIS);
+ b.translate_axis (last_xposn - x0 + stem_offset, X_AXIS);
b.translate_axis (slope * (last_xposn - x0) + bdy * full_beams[j], Y_AXIS);
- the_beam.add_stencil (b);
+ the_beam.add_stencil (b);
}
-
+
if (lfliebertjes.size () || rfliebertjes.size ())
{
Real nw_f;
if (st)
{
- int t = Stem::duration_log (st);
+ int t = Stem::duration_log (st);
SCM proc = me->get_property ("flag-width-function");
SCM result = scm_call_1 (proc, scm_int2num (t));
}
else
nw_f = break_overshoot / 2;
-
+
/* Half beam should be one note-width,
but let's make sure two half-beams never touch */
Real lw = nw_f;
Real rw = nw_f;
if (i > 0)
- rw = nw_f <? ( (xposn - last_xposn) / 2);
+ rw = nw_f <? ((xposn - last_xposn) / 2);
else
/*
TODO: 0.5 is a guess.
*/
rw = xposn - me->get_bound (LEFT)->extent (xcommon, X_AXIS)[RIGHT]
- 0.5;
-
+
if (st)
- lw = nw_f <? ( (xposn - last_xposn) / 2);
+ lw = nw_f <? ((xposn - last_xposn) / 2);
else
lw = me->get_bound (RIGHT)->relative_coordinate (xcommon, X_AXIS)
- last_xposn;
for (int j = lfliebertjes.size (); j--;)
{
Stencil b (lhalf);
- b.translate_axis (last_xposn - x0, X_AXIS);
- b.translate_axis (slope * (last_xposn-x0) + bdy * lfliebertjes[j], Y_AXIS);
- the_beam.add_stencil (b);
+ b.translate_axis (last_xposn - x0, X_AXIS);
+ b.translate_axis (slope * (last_xposn - x0) + bdy * lfliebertjes[j], Y_AXIS);
+ the_beam.add_stencil (b);
}
for (int j = rfliebertjes.size (); j--;)
{
Stencil b (rhalf);
- b.translate_axis (xposn - x0 - rw , X_AXIS);
- b.translate_axis (slope * (xposn-x0 -rw) + bdy * rfliebertjes[j], Y_AXIS);
- the_beam.add_stencil (b);
+ b.translate_axis (xposn - x0 - rw, X_AXIS);
+ b.translate_axis (slope * (xposn - x0 -rw) + bdy * rfliebertjes[j], Y_AXIS);
+ the_beam.add_stencil (b);
}
}
-
last_xposn = xposn;
last_stem_width = stem_width;
last_beaming = this_beaming;
if (to_boolean (me->get_layout ()->lookup_variable (ly_symbol2scm ("debug-beam-quanting")))
&& scm_is_string (quant_score))
{
-
+
/*
This code prints the demerits for each beam. Perhaps this
should be switchable for those who want to twiddle with the
String str;
SCM properties = Font_interface::text_font_alist_chain (me);
- Direction stem_dir = stems.size() ? to_dir (stems[0]->get_property ("direction")) : UP;
-
+ Direction stem_dir = stems.size () ? to_dir (stems[0]->get_property ("direction")) : UP;
+
Stencil tm = *unsmob_stencil (Text_interface::interpret_markup
- (me->get_layout ()->self_scm (), properties, quant_score));
+ (me->get_layout ()->self_scm (), properties, quant_score));
the_beam.add_at_edge (Y_AXIS, stem_dir, tm, 1.0, 0);
}
#endif
-
+
return the_beam.smobbed_copy ();
}
-
-
Direction
-Beam::get_default_dir (Grob *me)
+Beam::get_default_dir (Grob *me)
{
Drul_array<int> total;
- total[UP] = total[DOWN] = 0;
- Drul_array<int> count;
- count[UP] = count[DOWN] = 0;
+ total[UP] = total[DOWN] = 0;
+ Drul_array<int> count;
+ count[UP] = count[DOWN] = 0;
Direction d = DOWN;
- Link_array<Grob> stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
for (int i = 0; i < stems.size (); i++)
- do {
- Grob *s = stems[i];
- Direction sd = get_grob_direction (s);
-
- int center_distance = int (- d * Stem::head_positions (s) [-d]) >? 0;
- int current = sd ? (1 + d * sd)/2 : center_distance;
+ do
+ {
+ Grob *s = stems[i];
+ Direction sd = get_grob_direction (s);
+
+ int center_distance = int (- d * Stem::head_positions (s) [-d]) >? 0;
+ int current = sd ? (1 + d * sd) / 2 : center_distance;
+
+ if (current)
+ {
+ total[d] += current;
+ count[d]++;
+ }
+ }
+ while (flip (&d) != DOWN);
- if (current)
- {
- total[d] += current;
- count[d] ++;
- }
- } while (flip (&d) != DOWN);
-
SCM func = me->get_property ("dir-function");
SCM s = scm_call_2 (func,
- scm_cons (scm_int2num (count[UP]),
- scm_int2num (count[DOWN])),
- scm_cons (scm_int2num (total[UP]),
- scm_int2num (total[DOWN])));
+ scm_cons (scm_int2num (count[UP]),
+ scm_int2num (count[DOWN])),
+ scm_cons (scm_int2num (total[UP]),
+ scm_int2num (total[DOWN])));
if (scm_is_number (s) && scm_to_int (s))
return to_dir (s);
-
+
/* If dir is not determined: get default */
return to_dir (me->get_property ("neutral-direction"));
}
-
/* Set all stems with non-forced direction to beam direction.
Urg: non-forced should become `without/with unforced' direction,
once stem gets cleaned-up. */
{
Link_array<Grob> stems
= extract_grob_array (me, ly_symbol2scm ("stems"));
-
+
for (int i = 0; i <stems.size (); i++)
{
Grob *s = stems[i];
-
+
SCM forcedir = s->get_property ("direction");
if (!to_dir (forcedir))
- set_grob_direction (s, d);
+ set_grob_direction (s, d);
}
}
anything else is possible here, since we don't know funky-beaming
settings, or X-distances (slopes!) People that want sloped
knee-beams, should set the directions manually.
- */
+*/
void
-Beam::consider_auto_knees (Grob* me)
+Beam::consider_auto_knees (Grob *me)
{
SCM scm = me->get_property ("auto-knee-gap");
if (!scm_is_number (scm))
- return ;
+ return;
Interval_set gaps;
gaps.set_full ();
- Link_array<Grob> stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
-
- Grob *common = common_refpoint_of_array (stems, me, Y_AXIS);
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
+
+ Grob *common = common_refpoint_of_array (stems, me, Y_AXIS);
Real staff_space = Staff_symbol_referencer::staff_space (me);
-
- Array<Interval> head_positions_array;
+
+ Array<Interval> head_positions_array;
for (int i = 0; i < stems.size (); i++)
{
- Grob* stem = stems[i];
+ Grob *stem = stems[i];
if (Stem::is_invisible (stem))
continue;
if (!head_positions.is_empty ())
{
head_positions[LEFT] += -1;
- head_positions[RIGHT] += 1;
- head_positions *= staff_space * 0.5 ;
+ head_positions[RIGHT] += 1;
+ head_positions *= staff_space * 0.5;
/*
We could subtract beam Y position, but this routine only
sets stem directions, a constant shift does not have an
influence.
- */
+ */
head_positions += stem->relative_coordinate (common, Y_AXIS);
if (to_dir (stem->get_property ("direction")))
{
Direction stemdir = to_dir (stem->get_property ("direction"));
- head_positions[-stemdir] = - stemdir * infinity_f;
+ head_positions[-stemdir] = -stemdir * infinity_f;
}
}
head_positions_array.push (head_positions);
Interval max_gap;
Real max_gap_len = 0.0;
- for (int i = gaps.allowed_regions_.size () -1; i >= 0 ; i--)
+ for (int i = gaps.allowed_regions_.size () -1; i >= 0; i--)
{
Interval gap = gaps.allowed_regions_[i];
/*
the outer gaps are not knees.
- */
+ */
if (isinf (gap[LEFT]) || isinf (gap[RIGHT]))
continue;
-
+
if (gap.length () >= max_gap_len)
{
max_gap_len = gap.length ();
Real beam_translation = get_beam_translation (me);
Real beam_thickness = Beam::get_thickness (me);
- int beam_count = Beam::get_beam_count (me);
+ int beam_count = Beam::get_beam_count (me);
Real height_of_beams = beam_thickness / 2
+ (beam_count - 1) * beam_translation;
- Real threshold = scm_to_double (scm) + height_of_beams;
-
+ Real threshold = scm_to_double (scm) + height_of_beams;
+
if (max_gap_len > threshold)
{
int j = 0;
for (int i = 0; i < stems.size (); i++)
{
- Grob* stem = stems[i];
+ Grob *stem = stems[i];
if (Stem::is_invisible (stem))
continue;
Interval head_positions = head_positions_array[j++];
+ Direction d = (head_positions.center () < max_gap.center ()) ?
+ UP : DOWN;
- Direction d = (head_positions.center () < max_gap.center ()) ?
- UP : DOWN ;
-
stem->set_property ("direction", scm_int2num (d));
-
+
head_positions.intersect (max_gap);
- assert (head_positions.is_empty () || head_positions.length () < 1e-6 );
+ assert (head_positions.is_empty () || head_positions.length () < 1e-6);
}
}
}
-
-
/* Set stem's shorten property if unset.
- TODO:
- take some y-position (chord/beam/nearest?) into account
- scmify forced-fraction
-
- This is done in beam because the shorten has to be uniform over the
- entire beam.
+TODO:
+take some y-position (chord/beam/nearest?) into account
+scmify forced-fraction
+This is done in beam because the shorten has to be uniform over the
+entire beam.
*/
void
Beam::set_stem_shorten (Grob *me)
{
/*
shortening looks silly for x staff beams
- */
+ */
if (is_knee (me))
- return ;
-
+ return;
+
Real forced_fraction = 1.0 * forced_stem_count (me)
/ visible_stem_count (me);
return;
Real staff_space = Staff_symbol_referencer::staff_space (me);
-
- SCM shorten_elt =
- robust_list_ref (beam_count -1, shorten_list);
+
+ SCM shorten_elt
+ = robust_list_ref (beam_count -1, shorten_list);
Real shorten_f = scm_to_double (shorten_elt) * staff_space;
/* your similar cute comment here */
/* Call list of y-dy-callbacks, that handle setting of
grob-properties
-
*/
MAKE_SCHEME_CALLBACK (Beam, after_line_breaking, 1);
SCM
Beam::position_beam (Grob *me)
{
if (!me->is_live ())
- return ;
+ return;
if (to_boolean (me->get_property ("positioning-done")))
- return ;
+ return;
me->set_property ("positioning-done", SCM_BOOL_T);
scm_call_1 (scm_car (i), me->self_scm ());
}
- set_stem_lengths (me);
+ set_stem_lengths (me);
}
-
void
-set_minimum_dy (Grob *me, Real * dy)
+set_minimum_dy (Grob *me, Real *dy)
{
if (*dy)
{
/*
If dy is smaller than the smallest quant, we
- get absurd direction-sign penalties.
+ get absurd direction-sign penalties.
*/
-
+
Real ss = Staff_symbol_referencer::staff_space (me);
- Real thickness = Beam::get_thickness (me) / ss ;
+ Real thickness = Beam::get_thickness (me) / ss;
Real slt = Staff_symbol_referencer::line_thickness (me) / ss;
Real sit = (thickness - slt) / 2;
Real inter = 0.5;
Real hang = 1.0 - (thickness - slt) / 2;
-
+
*dy = sign (*dy) * (fabs (*dy)
- >?
- (sit <? inter <? hang));
+ >?
+ (sit <? inter <? hang));
}
}
/*
Compute a first approximation to the beam slope.
- */
+*/
MAKE_SCHEME_CALLBACK (Beam, least_squares, 1);
SCM
Beam::least_squares (SCM smob)
int count = visible_stem_count (me);
Interval pos (0, 0);
-
+
if (count < 1)
{
me->set_property ("positions", ly_interval2scm (pos));
return SCM_UNSPECIFIED;
}
-
- Array<Real> x_posns ;
- Link_array<Grob> stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
+ Array<Real> x_posns;
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
Grob *commonx = common_refpoint_of_array (stems, me, X_AXIS);
- Grob *commony = common_refpoint_of_array (stems, me, Y_AXIS);
+ Grob *commony = common_refpoint_of_array (stems, me, Y_AXIS);
Real my_y = me->relative_coordinate (commony, Y_AXIS);
-
- Grob *fvs = first_visible_stem (me);
- Grob *lvs = last_visible_stem (me);
-
+
+ Grob *fvs = first_visible_stem (me);
+ Grob *lvs = last_visible_stem (me);
+
Interval ideal (Stem::get_stem_info (fvs).ideal_y_
+ fvs->relative_coordinate (commony, Y_AXIS) -my_y,
Stem::get_stem_info (lvs).ideal_y_
+ lvs->relative_coordinate (commony, Y_AXIS) - my_y);
-
+
Real x0 = first_visible_stem (me)->relative_coordinate (commonx, X_AXIS);
for (int i = 0; i < stems.size (); i++)
{
- Grob* s = stems[i];
+ Grob *s = stems[i];
Real x = s->relative_coordinate (commonx, X_AXIS) - x0;
x_posns.push (x);
}
Real dx = last_visible_stem (me)->relative_coordinate (commonx, X_AXIS) - x0;
-
- Real y = 0;
+ Real y = 0;
Real slope = 0;
Real dy = 0;
-
+
if (!ideal.delta ())
{
Interval chord (Stem::chord_start_y (first_visible_stem (me)),
/* Simple beams (2 stems) on middle line should be allowed to be
slightly sloped.
-
+
However, if both stems reach middle line,
ideal[LEFT] == ideal[RIGHT] and ideal.delta () == 0.
/* FIXME. -> UP */
Direction d = (Direction) (sign (chord.delta ()) * UP);
pos[d] = get_thickness (me) / 2;
- pos[-d] = - pos[d];
+ pos[-d] = -pos[d];
}
else
{
Array<Offset> ideals;
for (int i = 0; i < stems.size (); i++)
{
- Grob* s = stems[i];
+ Grob *s = stems[i];
if (Stem::is_invisible (s))
continue;
ideals.push (Offset (x_posns[i],
+ s->relative_coordinate (commony, Y_AXIS)
- my_y));
}
-
+
minimise_least_squares (&slope, &y, ideals);
dy = slope * dx;
set_minimum_dy (me, &dy);
me->set_property ("least-squares-dy", scm_make_real (dy));
- pos = Interval (y, (y+dy));
+ pos = Interval (y, (y + dy));
}
/*
"position" is relative to the staff.
- */
- scale_drul (&pos, 1/ Staff_symbol_referencer::staff_space (me));
-
+ */
+ scale_drul (&pos, 1/ Staff_symbol_referencer::staff_space (me));
+
me->set_property ("positions", ly_interval2scm (pos));
-
+
return SCM_UNSPECIFIED;
}
-
/*
We can't combine with previous function, since check concave and
slope damping comes first.
TODO: we should use the concaveness to control the amount of damping
applied.
-
*/
MAKE_SCHEME_CALLBACK (Beam, shift_region_to_valid, 1);
SCM
Grob *me = unsmob_grob (grob);
/*
Code dup.
- */
- Array<Real> x_posns ;
- Link_array<Grob> stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
+ */
+ Array<Real> x_posns;
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
Grob *commonx = common_refpoint_of_array (stems, me, X_AXIS);
- Grob *commony = common_refpoint_of_array (stems, me, Y_AXIS);
+ Grob *commony = common_refpoint_of_array (stems, me, Y_AXIS);
Grob *fvs = first_visible_stem (me);
if (!fvs)
return SCM_UNSPECIFIED;
-
+
Real x0 = fvs->relative_coordinate (commonx, X_AXIS);
for (int i = 0; i < stems.size (); i++)
{
- Grob* s = stems[i];
+ Grob *s = stems[i];
Real x = s->relative_coordinate (commonx, X_AXIS) - x0;
x_posns.push (x);
Grob *lvs = last_visible_stem (me);
if (!lvs)
return SCM_UNSPECIFIED;
-
+
Real dx = lvs->relative_coordinate (commonx, X_AXIS) - x0;
- Drul_array<Real> pos = ly_scm2interval ( me->get_property ("positions"));
+ Drul_array<Real> pos = ly_scm2interval (me->get_property ("positions"));
+
+ scale_drul (&pos, Staff_symbol_referencer::staff_space (me));
- scale_drul (&pos, Staff_symbol_referencer::staff_space (me));
-
Real dy = pos[RIGHT] - pos[LEFT];
Real y = pos[LEFT];
- Real slope = dy/dx;
+ Real slope = dy / dx;
-
/*
Shift the positions so that we have a chance of finding good
quants (i.e. no short stem failures.)
- */
+ */
Interval feasible_left_point;
feasible_left_point.set_full ();
for (int i = 0; i < stems.size (); i++)
{
- Grob* s = stems[i];
+ Grob *s = stems[i];
if (Stem::is_invisible (s))
continue;
Direction d = Stem::get_direction (s);
- Real left_y =
- Stem::get_stem_info (s).shortest_y_
+ Real left_y
+ = Stem::get_stem_info (s).shortest_y_
- slope * x_posns [i];
/*
left_y is now relative to the stem S. We want relative to
ourselves, so translate:
- */
- left_y +=
- + s->relative_coordinate (commony, Y_AXIS)
+ */
+ left_y
+ += + s->relative_coordinate (commony, Y_AXIS)
- me->relative_coordinate (commony, Y_AXIS);
- Interval flp ;
+ Interval flp;
flp.set_full ();
flp[-d] = left_y;
feasible_left_point.intersect (flp);
}
-
+
if (feasible_left_point.is_empty ())
warning (_ ("no viable initial configuration found: may not find good beam slope"));
else if (!feasible_left_point.contains (y))
else
y = feasible_left_point.center ();
}
-
- pos = Drul_array<Real> (y, (y+dy));
+
+ pos = Drul_array<Real> (y, (y + dy));
scale_drul (&pos, 1/ Staff_symbol_referencer::staff_space (me));
-
+
me->set_property ("positions", ly_interval2scm (pos));
return SCM_UNSPECIFIED;
}
if (visible_stem_count (me) <= 1)
return SCM_UNSPECIFIED;
- SCM s = me->get_property ("damping");
+ SCM s = me->get_property ("damping");
Real damping = scm_to_double (s);
if (damping)
{
Drul_array<Real> pos = ly_scm2interval (me->get_property ("positions"));
- scale_drul (&pos, Staff_symbol_referencer::staff_space (me));
-
+ scale_drul (&pos, Staff_symbol_referencer::staff_space (me));
+
Real dy = pos[RIGHT] - pos[LEFT];
- Grob *fvs = first_visible_stem (me);
- Grob *lvs = last_visible_stem (me);
+ Grob *fvs = first_visible_stem (me);
+ Grob *lvs = last_visible_stem (me);
Grob *commonx = fvs->common_refpoint (lvs, X_AXIS);
-
Real dx = last_visible_stem (me)->relative_coordinate (commonx, X_AXIS)
- first_visible_stem (me)->relative_coordinate (commonx, X_AXIS);
- Real slope = dy && dx ? dy/dx : 0;
+ Real slope = dy && dx ? dy / dx : 0;
Real concaveness = robust_scm2double (me->get_property ("concaveness"), 0.0);
-
+
slope = 0.6 * tanh (slope) / (damping + concaveness);
Real damped_dy = slope * dx;
set_minimum_dy (me, &damped_dy);
-
+
pos[LEFT] += (dy - damped_dy) / 2;
pos[RIGHT] -= (dy - damped_dy) / 2;
- scale_drul (&pos, 1/Staff_symbol_referencer::staff_space (me));
-
+ scale_drul (&pos, 1 / Staff_symbol_referencer::staff_space (me));
+
me->set_property ("positions", ly_interval2scm (pos));
}
return SCM_UNSPECIFIED;
/*
Report slice containing the numbers that are both in (car BEAMING)
and (cdr BEAMING)
- */
+*/
Slice
where_are_the_whole_beams (SCM beaming)
{
- Slice l;
-
- for ( SCM s = scm_car (beaming); scm_is_pair (s) ; s = scm_cdr (s))
+ Slice l;
+
+ for (SCM s = scm_car (beaming); scm_is_pair (s); s = scm_cdr (s))
{
if (scm_c_memq (scm_car (s), scm_cdr (beaming)) != SCM_BOOL_F)
-
+
l.add_point (scm_to_int (scm_car (s)));
}
/* Return the Y position of the stem-end, given the Y-left, Y-right
in POS for stem S. This Y position is relative to S. */
Real
-Beam::calc_stem_y (Grob *me, Grob* s, Grob ** common,
+Beam::calc_stem_y (Grob *me, Grob *s, Grob ** common,
Real xl, Real xr,
- Drul_array<Real> pos, bool french)
+ Drul_array<Real> pos, bool french)
{
Real beam_translation = get_beam_translation (me);
-
Real r = s->relative_coordinate (common[X_AXIS], X_AXIS) - xl;
Real dy = pos[RIGHT] - pos[LEFT];
Real dx = xr - xl;
? r / dx
* dy
: 0) + pos[LEFT];
-
+
Direction my_dir = get_grob_direction (s);
SCM beaming = s->get_property ("beaming");
-
+
Real stem_y = stem_y_beam0;
if (french)
{
if (!bm.is_empty ())
stem_y += bm[my_dir] * beam_translation;
}
-
+
Real id = me->relative_coordinate (common[Y_AXIS], Y_AXIS)
- s->relative_coordinate (common[Y_AXIS], Y_AXIS);
-
+
return stem_y + id;
}
void
Beam::set_stem_lengths (Grob *me)
{
- Link_array<Grob> stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
if (!stems.size ())
return;
-
+
Grob *common[2];
for (int a = 2; a--;)
common[a] = common_refpoint_of_array (stems, me, Axis (a));
-
+
Drul_array<Real> pos = ly_scm2realdrul (me->get_property ("positions"));
Real staff_space = Staff_symbol_referencer::staff_space (me);
- scale_drul (&pos, staff_space);
+ scale_drul (&pos, staff_space);
bool gap = false;
Real thick = 0.0;
gap = true;
thick = get_thickness (me);
}
-
+
// ugh -> use commonx
- Grob * fvs = first_visible_stem (me);
+ Grob *fvs = first_visible_stem (me);
Grob *lvs = last_visible_stem (me);
-
+
Real xl = fvs ? fvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0;
Real xr = lvs ? lvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0;
-
+
for (int i = 0; i < stems.size (); i++)
{
- Grob* s = stems[i];
+ Grob *s = stems[i];
if (Stem::is_invisible (s))
continue;
/*
Make the stems go up to the end of the beam. This doesn't matter
for normal beams, but for tremolo beams it looks silly otherwise.
- */
+ */
if (gap)
stem_y += thick * 0.5 * get_grob_direction (s);
void
Beam::set_beaming (Grob *me, Beaming_info_list *beaming)
{
- Link_array<Grob> stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
-
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
+
Direction d = LEFT;
- for (int i = 0; i < stems.size (); i++)
+ for (int i = 0; i < stems.size (); i++)
{
/*
Don't overwrite user settings.
- */
-
+ */
+
do
{
- /* Don't set beaming for outside of outer stems */
- if ( (d == LEFT && i == 0)
+ /* Don't set beaming for outside of outer stems */
+ if ((d == LEFT && i == 0)
|| (d == RIGHT && i == stems.size () -1))
continue;
- Grob *st = stems[i];
+ Grob *st = stems[i];
SCM beaming_prop = st->get_property ("beaming");
- if (beaming_prop == SCM_EOL ||
- index_get_cell (beaming_prop, d) == SCM_EOL)
+ if (beaming_prop == SCM_EOL
+ || index_get_cell (beaming_prop, d) == SCM_EOL)
{
int b = beaming->infos_.elem (i).beams_i_drul_[d];
- if (i>0
+ if (i > 0
&& i < stems.size () -1
&& Stem::is_invisible (st))
b = b <? beaming->infos_.elem (i).beams_i_drul_[-d];
-
+
Stem::set_beaming (st, b, d);
}
}
}
int
-Beam::forced_stem_count (Grob *me)
+Beam::forced_stem_count (Grob *me)
{
- Link_array<Grob>stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
int f = 0;
for (int i = 0; i < stems.size (); i++)
{
/* I can imagine counting those boundaries as a half forced stem,
but let's count them full for now. */
if (abs (Stem::chord_start_y (s)) > 0.1
- && (Stem::get_direction (s) != Stem::get_default_dir (s)))
- f++;
+ && (Stem::get_direction (s) != Stem::get_default_dir (s)))
+ f++;
}
return f;
}
-
-
int
-Beam::visible_stem_count (Grob *me)
+Beam::visible_stem_count (Grob *me)
{
- Link_array<Grob>stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
int c = 0;
for (int i = stems.size (); i--;)
{
if (!Stem::is_invisible (stems[i]))
- c++;
+ c++;
}
return c;
}
-Grob*
-Beam::first_visible_stem (Grob *me)
+Grob *
+Beam::first_visible_stem (Grob *me)
{
- Link_array<Grob>stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
-
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
+
for (int i = 0; i < stems.size (); i++)
{
if (!Stem::is_invisible (stems[i]))
- return stems[i];
+ return stems[i];
}
return 0;
}
-Grob*
-Beam::last_visible_stem (Grob *me)
+Grob *
+Beam::last_visible_stem (Grob *me)
{
- Link_array<Grob>stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
for (int i = stems.size (); i--;)
{
if (!Stem::is_invisible (stems[i]))
- return stems[i];
+ return stems[i];
}
return 0;
}
-
/*
[TODO]
-
+
handle rest under beam (do_post: beams are calculated now)
what about combination of collisions and rest under beam.
Should lookup
-
- rest -> stem -> beam -> interpolate_y_position ()
+
+ rest -> stem -> beam -> interpolate_y_position ()
*/
MAKE_SCHEME_CALLBACK (Beam, rest_collision_callback, 2);
SCM
if (scm_is_number (rest->get_property ("staff-position")))
return scm_int2num (0);
-
+
assert (a == Y_AXIS);
Grob *st = unsmob_grob (rest->get_property ("stem"));
Real staff_space = Staff_symbol_referencer::staff_space (rest);
scale_drul (&pos, staff_space);
-
Real dy = pos[RIGHT] - pos[LEFT];
-
+
// ugh -> use commonx
Real x0 = first_visible_stem (beam)->relative_coordinate (0, X_AXIS);
Real dx = last_visible_stem (beam)->relative_coordinate (0, X_AXIS) - x0;
- Real slope = dy && dx ? dy/dx : 0;
-
+ Real slope = dy && dx ? dy / dx : 0;
+
Direction d = Stem::get_direction (stem);
Real stem_y = pos[LEFT] + (stem->relative_coordinate (0, X_AXIS) - x0) * slope;
-
+
Real beam_translation = get_beam_translation (beam);
Real beam_thickness = Beam::get_thickness (beam);
/*
- TODO: this is not strictly correct for 16th knee beams.
- */
- int beam_count =
- Stem::beam_multiplicity (stem).length() + 1;
-
+ TODO: this is not strictly correct for 16th knee beams.
+ */
+ int beam_count
+ = Stem::beam_multiplicity (stem).length () + 1;
+
Real height_of_my_beams = beam_thickness / 2
+ (beam_count - 1) * beam_translation;
Real beam_y = stem_y - d * height_of_my_beams;
Grob *common_y = rest->common_refpoint (beam, Y_AXIS);
Real rest_dim = rest->extent (common_y, Y_AXIS)[d];
- Real minimum_distance =
- + staff_space * (robust_scm2double (stem->get_property ("stemlet-length"), 0.0)
- + robust_scm2double (rest->get_property ("minimum-distance"), 0.0));
+ Real minimum_distance
+ = + staff_space * (robust_scm2double (stem->get_property ("stemlet-length"), 0.0)
+ + robust_scm2double (rest->get_property ("minimum-distance"), 0.0));
- Real shift = d * ( ((beam_y - d * minimum_distance) - rest_dim) * d <? 0.0);
+ Real shift = d * (((beam_y - d * minimum_distance) - rest_dim) * d <? 0.0);
shift /= staff_space;
Real rad = Staff_symbol_referencer::line_count (rest) * staff_space / 2;
shift = ceil (fabs (shift * 2.0)) / 2.0 * sign (shift);
/* Inside staff, move by whole spaces*/
- if ( (rest->extent (common_y, Y_AXIS)[d] + staff_space * shift) * d
+ if ((rest->extent (common_y, Y_AXIS)[d] + staff_space * shift) * d
< rad
|| (rest->extent (common_y, Y_AXIS)[-d] + staff_space * shift) * -d
< rad)
}
bool
-Beam::is_knee (Grob* me)
+Beam::is_knee (Grob *me)
{
SCM k = me->get_property ("knee");
if (scm_is_bool (k))
}
d = dir;
}
-
+
me->set_property ("knee", ly_bool2scm (knee));
return knee;
}
int
-Beam::get_direction_beam_count (Grob *me, Direction d )
+Beam::get_direction_beam_count (Grob *me, Direction d)
{
- Link_array<Grob>stems =
- extract_grob_array (me, ly_symbol2scm ("stems"));
+ Link_array<Grob> stems
+ = extract_grob_array (me, ly_symbol2scm ("stems"));
int bc = 0;
-
+
for (int i = stems.size (); i--;)
{
/*
Should we take invisible stems into account?
- */
+ */
if (Stem::get_direction (stems[i]) == d)
- bc = bc >? (Stem::beam_multiplicity (stems[i]).length () + 1);
+ bc = bc >? (Stem::beam_multiplicity (stems[i]).length () + 1);
}
return bc;
}
-
ADD_INTERFACE (Beam, "beam-interface",
"A beam. \n\n"
"The @code{thickness} property is the weight of beams, and is measured "
- "in staffspace"
- ,
+ "in staffspace",
"knee positioning-done position-callbacks "
"concaveness dir-function quant-score auto-knee-gap gap "
"gap-count chord-tremolo beamed-stem-shorten shorten least-squares-dy "
"damping inspect-quants flag-width-function neutral-direction positions space-function "
"thickness");
-
-/*
- beaming-info.cc -- implement Beaming_info, Beaming_info_list
-
+/*
+ beaming-info.cc -- implement Beaming_info, Beaming_info_list
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "beaming.hh"
{
start_mom_ = 0;
beams_i_drul_[LEFT] = 0;
- beams_i_drul_[RIGHT] = 0;
+ beams_i_drul_[RIGHT] = 0;
}
Beaming_info::Beaming_info (Moment m, int i)
{
start_mom_ = m;
beams_i_drul_[LEFT] = i;
- beams_i_drul_[RIGHT] = i;
+ beams_i_drul_[RIGHT] = i;
}
const int infinity_i = INT_MAX; // guh.
{
beat_pos = infos_[i].start_mom_ / beat_length;
int den = beat_pos.den ();
- if (infos_[i].beams_i_drul_[LEFT] == infos_[i-1].beams_i_drul_[RIGHT] && !subdivide)
+ if (infos_[i].beams_i_drul_[LEFT] == infos_[i - 1].beams_i_drul_[RIGHT] && !subdivide)
den *= 2;
if (den < minden)
{
}
}
- return minidx|(minden ==1 && subdivide ? at_beat : 0);
+ return minidx| (minden ==1 && subdivide ? at_beat : 0);
}
int
if (infos_.size () == 1)
return infos_[0].beams_i_drul_[d];
- Beaming_info thisbeam = infos_.boundary (d, 0);
- Beaming_info next = infos_.boundary (d, 1);
-
+ Beaming_info thisbeam = infos_.boundary (d, 0);
+ Beaming_info next = infos_.boundary (d, 1);
+
return thisbeam.beams_i_drul_[-d] <? next.beams_i_drul_[d];
}
{
if (infos_.size () <= 1)
return;
-
+
Drul_array<Beaming_info_list> splits;
int m = best_splitpoint_index (beat_length, subdivide);
- bool split = subdivide && (m & at_beat); m = m & ~at_beat;
+ bool split = subdivide && (m & at_beat); m = m & ~at_beat;
splits[LEFT].infos_ = infos_.slice (0, m);
splits[RIGHT].infos_ = infos_.slice (m, infos_.size ());
Direction d = LEFT;
-
+
do
{
splits[d].beamify (beat_length, subdivide);
#include "misc.hh"
#include "bezier.hh"
-
static Real
F0_1 (Real x)
{
- return 2 / M_PI * atan (M_PI * x / 2);
+ return 2 / M_PI *atan (M_PI *x / 2);
}
Real
return F0_1 (width * r_0 / h_inf) * h_inf;
}
- /*
-
-
- ^ x x
+/*
+ ^ x x
|
-height <indent>
+ height <indent>
|
v x x
-
-
+
+
For small w, the height should be proportional to w, for w ->
infinity, the height should rise to a limit asymptotically.
h = h_infinity * F (x * r_0 / h_infinity)
-
+
Examples:
* F (x) = 2/pi * atan (pi x/2)
w -> 0, G(w) -> .33 w
-
+
(due to derivative constraints, we cannot have indent > len/3)
w -> inf, G(w) -> 2*h_inf
solve from
- G(w) = r + p/(w+q)
+ G(w) = r + p/(w+q)
yields
- G(w) = 2 h_inf - max_fraction * q^2/ (w + q)
+ G(w) = 2 h_inf - max_fraction * q^2/ (w + q)
- with q = 2 h_inf
-
-
- */
+ with q = 2 h_inf
+*/
void
get_slur_indent_height (Real *indent, Real *height,
Real width, Real h_inf, Real r_0)
{
Real max_fraction = 1.0 / 3.1;
- *height = slur_height (width, h_inf, r_0);
+ *height = slur_height (width, h_inf, r_0);
- Real q = 2 * h_inf / max_fraction;
- *indent =
- 2 *h_inf - sqr (q) * max_fraction / (width + q);
+ Real q = 2 * h_inf / max_fraction;
+ *indent
+ = 2 *h_inf - sqr (q) * max_fraction / (width + q);
}
Bezier
{
Real indent;
Real height;
-
+
get_slur_indent_height (&indent, &height,
- width, h_inf, r_0);
+ width, h_inf, r_0);
Bezier curve;
curve.control_[0] = Offset (0, 0);
#include "libc-extension.hh"
Real
-binomial_coefficient (Real over , int under)
+binomial_coefficient (Real over, int under)
{
Real x = 1.0;
{
x *= over / Real (under);
- over -= 1.0;
- under --;
+ over -= 1.0;
+ under--;
}
return x;
}
void
-scale (Array<Offset>* array, Real x , Real y)
+scale (Array<Offset>* array, Real x, Real y)
{
for (int i = 0; i < array->size (); i++)
{
}
/*
-
Formula of the bezier 3-spline
sum_{j = 0}^3 (3 over j) z_j (1-t)^ (3-j) t^j
A is the axis of X coordinate.
- */
+*/
Real
-Bezier::get_other_coordinate (Axis a, Real x) const
+Bezier::get_other_coordinate (Axis a, Real x) const
{
Axis other = Axis ((a +1)%NO_AXES);
Array<Real> ts = solve_point (a, x);
programming_error ("No solution found for Bezier intersection.");
return 0.0;
}
-
+
Offset c = curve_point (ts[0]);
if (fabs (c[a] - x) > 1e-8)
programming_error ("Bezier intersection not correct?");
-
+
return c[other];
}
-
Offset
Bezier::curve_point (Real t) const
{
Real tj = 1;
- Real one_min_tj = (1-t)* (1-t)* (1-t);
+ Real one_min_tj = (1 - t)* (1 - t)* (1 - t);
Offset o;
- for (int j = 0 ; j < 4; j++)
+ for (int j = 0; j < 4; j++)
{
o += control_[j] * binomial_coefficient (3, j)
- * pow (t, j) * pow (1-t, 3-j);
+ * pow (t, j) * pow (1 - t, 3 - j);
tj *= t;
- if (1-t)
- one_min_tj /= (1-t);
+ if (1 - t)
+ one_min_tj /= (1 - t);
}
#ifdef PARANOID
assert (fabs (o[X_AXIS] - polynomial (X_AXIS).eval (t))< 1e-8);
assert (fabs (o[Y_AXIS] - polynomial (Y_AXIS).eval (t))< 1e-8);
#endif
-
+
return o;
}
-
Polynomial
Bezier::polynomial (Axis a) const
{
Polynomial p (0.0);
for (int j = 0; j <= 3; j++)
{
- p +=
- (control_[j][a] * binomial_coefficient (3, j))
+ p
+ += (control_[j][a] * binomial_coefficient (3, j))
* Polynomial::power (j, Polynomial (0, 1))
* Polynomial::power (3 - j, Polynomial (1, -1));
}
/**
Remove all numbers outside [0, 1] from SOL
- */
+*/
Array<Real>
filter_solutions (Array<Real> sol)
{
/**
find t such that derivative is proportional to DERIV
- */
+*/
Array<Real>
Bezier::solve_derivative (Offset deriv) const
{
Polynomial yp = polynomial (Y_AXIS);
xp.differentiate ();
yp.differentiate ();
-
+
Polynomial combine = xp * deriv[Y_AXIS] - yp * deriv [X_AXIS];
return filter_solutions (combine.solve ());
}
-
/*
Find t such that curve_point (t)[AX] == COORDINATE
*/
-Array<Real>
+Array<Real>
Bezier::solve_point (Axis ax, Real coordinate) const
{
Polynomial p (polynomial (ax));
p.coefs_[0] -= coordinate;
-
+
Array<Real> sol (p.solve ());
return filter_solutions (sol);
}
/**
Compute the bounding box dimensions in direction of A.
- */
+*/
Interval
Bezier::extent (Axis a) const
{
- int o = (a+1)%NO_AXES;
+ int o = (a + 1)%NO_AXES;
Offset d;
d[Axis (o)] =1.0;
Interval iv;
Array<Real> sols (solve_derivative (d));
sols.push (1.0);
- sols.push (0.0);
+ sols.push (0.0);
for (int i = sols.size (); i--;)
{
Offset o (curve_point (sols[i]));
/**
Flip around axis A
- */
+*/
void
Bezier::scale (Real x, Real y)
{
{
Bezier b2;
for (int i = 0; i < CONTROL_COUNT; i++)
- b2.control_[CONTROL_COUNT-i-1] = control_[i];
+ b2.control_[CONTROL_COUNT - i - 1] = control_[i];
*this = b2;
}
#include "binary-source-file.hh"
#include "string-convert.hh"
-Binary_source_file::Binary_source_file (String& file_name_string)
+Binary_source_file::Binary_source_file (String &file_name_string)
: Source_file (file_name_string)
{
}
}
String
-Binary_source_file::error_string (char const* pos_str0) const
+Binary_source_file::error_string (char const *pos_str0) const
{
assert (this);
if (!contains (pos_str0))
return "";
- char const* begin_str0 = pos_str0 - 8 >? to_str0 ();
- char const* end_str0 = pos_str0 + 7 <? to_str0 () + length ();
+ char const *begin_str0 = pos_str0 - 8 >? to_str0 ();
+ char const *end_str0 = pos_str0 + 7 <? to_str0 () + length ();
- String pre_string ((Byte const*)begin_str0, pos_str0 - begin_str0);
+ String pre_string ((Byte const *)begin_str0, pos_str0 - begin_str0);
pre_string = String_convert::bin2hex (pre_string);
for (int i = 2; i < pre_string.length (); i += 3)
pre_string = pre_string.left_string (i) + " " + pre_string.cut_string (i, INT_MAX);
- String post_string ((Byte const*)pos_str0, end_str0 - pos_str0);
+ String post_string ((Byte const *)pos_str0, end_str0 - pos_str0);
post_string = String_convert::bin2hex (post_string);
for (int i = 2; i < post_string.length (); i += 3)
post_string = post_string.left_string (i) + " " + post_string.cut_string (i, INT_MAX);
/*
naming is wrong. This is a UNIX-endian-32 (as opposed to xinu or ixun)
- */
+*/
U32
Binary_source_file::get_U32 ()
{
U32 b;
-
+
b = get_U8 () << 24;
b |= get_U8 () << 16;
b |= get_U8 () << 8;
return b;
}
-
#include "score.hh"
#include "ly-module.hh"
-LY_DEFINE(ly_make_book, "ly:make-book",
- 2, 0, 1, (SCM paper, SCM header, SCM scores),
- "Make a \\book of @var{paper} and @var{header} (which may be #f as well) "
- "containing @code{\\scores}.")
+LY_DEFINE (ly_make_book, "ly:make-book",
+ 2, 0, 1, (SCM paper, SCM header, SCM scores),
+ "Make a \\book of @var{paper} and @var{header} (which may be #f as well) "
+ "containing @code{\\scores}.")
{
- Output_def * odef = unsmob_output_def (paper);
+ Output_def *odef = unsmob_output_def (paper);
SCM_ASSERT_TYPE (odef, paper,
SCM_ARG1, __FUNCTION__, "Output_def");
SCM
Book::mark_smob (SCM s)
{
- Book *book = (Book*) SCM_CELL_WORD_1 (s);
+ Book *book = (Book *) SCM_CELL_WORD_1 (s);
#if 0
if (book->key_)
- scm_gc_mark (book->key_->self_scm());
+ scm_gc_mark (book->key_->self_scm ());
#endif
if (book->paper_)
Paper_book *paper_book = new Paper_book ();
Real scale = scm_to_double (paper_->c_variable ("outputscale"));
- Output_def * scaled_bookdef = scale_output_def (paper_, scale);
+ Output_def *scaled_bookdef = scale_output_def (paper_, scale);
- Object_key * key = new Lilypond_general_key (0, user_key_, 0);
- SCM scm_key = key->self_scm();
+ Object_key *key = new Lilypond_general_key (0, user_key_, 0);
+ SCM scm_key = key->self_scm ();
scm_gc_unprotect_object (scm_key);
-
+
paper_book->paper_ = scaled_bookdef;
- scm_gc_unprotect_object (scaled_bookdef->self_scm());
-
+ scm_gc_unprotect_object (scaled_bookdef->self_scm ());
+
paper_book->header_ = header_;
/* Render in order of parsing. */
{
SCM systems = score
->book_rendering (outname, paper_book->paper_, default_def, key);
-
+
/* If the score is empty, generate no output. Should we do
titling? */
if (scm_is_vector (systems))
}
/**
- Initialize to empty.
- */
+ Initialize to empty.
+*/
Box::Box ()
-{
+{
}
void
Box::set_empty ()
{
interval_a_[X_AXIS].set_empty ();
- interval_a_[Y_AXIS].set_empty ();
+ interval_a_[Y_AXIS].set_empty ();
}
Box::Box (Interval ix, Interval iy)
Box::add_point (Offset o)
{
interval_a_[X_AXIS].add_point (o[X_AXIS]);
- interval_a_[Y_AXIS].add_point (o[Y_AXIS]);
+ interval_a_[Y_AXIS].add_point (o[Y_AXIS]);
}
Offset
Box::center () const
{
return Offset (interval_a_[X_AXIS].center (),
- interval_a_[Y_AXIS].center ());
+ interval_a_[Y_AXIS].center ());
}
void
return retval;
}
-Simple_spacer_wrapper*
+Simple_spacer_wrapper *
Break_algorithm::generate_spacing_problem (Link_array<Grob> const &curline,
Interval line) const
{
- Simple_spacer_wrapper * spw = new Simple_spacer_wrapper;
- Simple_spacer * sp = spw->spacer_;
-
+ Simple_spacer_wrapper *spw = new Simple_spacer_wrapper;
+ Simple_spacer *sp = spw->spacer_;
+
/*
this is hardcoded, but this shouldn't happen anyway.
- used to be get_dimension (ly_symbol2scm ("loose_column_distance"));
- */
+ used to be get_dimension (ly_symbol2scm ("loose_column_distance"));
+ */
sp->default_space_ = 1.0;
sp->indent_ = line[LEFT];
/*
sort out how interfacing this should work;
- */
+ */
if (line.is_empty ())
{
- sp->line_len_ = -1;
+ sp->line_len_ = -1;
}
else
sp->line_len_ = line.length ();
-
+
spw->add_columns (curline);
return spw;
}
}
void
-Break_algorithm::set_pscore (Paper_score*s)
+Break_algorithm::set_pscore (Paper_score *s)
{
pscore_ = s;
linewidth_ = s->layout_->get_dimension (ly_symbol2scm ("linewidth"));
Break_algorithm::solve () const
{
Array<Column_x_positions> h= do_solve ();
-
+
return h;
}
-/*
+/*
break-align-engraver.cc -- implement Break_align_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "engraver.hh"
#include "protected-scm.hh"
#include "break-align-interface.hh"
SCM column_alist_;
Item *left_edge_;
- void add_to_group (SCM, Item*);
+ void add_to_group (SCM, Item *);
protected:
virtual void acknowledge_grob (Grob_info i);
virtual void stop_translation_timestep ();
virtual void derived_mark () const;
void add_column (SCM);
-
+
public:
TRANSLATOR_DECLARATIONS (Break_align_engraver);
};
void
Break_align_engraver::add_column (SCM smob)
{
- Grob * e = unsmob_grob (smob);
+ Grob *e = unsmob_grob (smob);
Break_align_interface::add_element (align_, e);
-
+
}
void
left_edge_ = 0;
}
-
Break_align_engraver::Break_align_engraver ()
{
column_alist_ = SCM_EOL;
void
Break_align_engraver::acknowledge_grob (Grob_info inf)
{
- if (Item * item = dynamic_cast <Item *> (inf.grob_))
+ if (Item *item = dynamic_cast<Item *> (inf.grob_))
{
/*
Removed check for item->empty (X_AXIS). --hwn 20/1/04
- */
+ */
if (item->get_parent (X_AXIS))
return;
SCM bp = item->get_property ("breakable");
bool breakable = (to_boolean (bp));
if (!breakable)
- return ;
+ return;
SCM align_name = item->get_property ("break-align-symbol");
if (!scm_is_symbol (align_name))
- return ;
+ return;
if (!align_)
{
align_ = make_item ("BreakAlignment", SCM_EOL);
- Context*origin = inf.origin_contexts (this)[0];
- left_edge_ = make_item_from_properties (dynamic_cast<Engraver*> (origin->implementation ()),
+ Context *origin = inf.origin_contexts (this)[0];
+ left_edge_ = make_item_from_properties (dynamic_cast<Engraver *> (origin->implementation ()),
ly_symbol2scm ("LeftEdge"),
SCM_EOL,
"LeftEdge");
add_to_group (left_edge_->get_property ("break-align-symbol"),
left_edge_);
}
-
+
add_to_group (align_name, item);
}
}
void
-Break_align_engraver::add_to_group (SCM align_name, Item*item)
+Break_align_engraver::add_to_group (SCM align_name, Item *item)
{
SCM s = scm_assoc (align_name, column_alist_);
- Item * group = 0;
+ Item *group = 0;
if (s != SCM_BOOL_F)
{
- Grob *e = unsmob_grob (scm_cdr (s));
- group = dynamic_cast<Item*> (e);
+ Grob *e = unsmob_grob (scm_cdr (s));
+ group = dynamic_cast<Item *> (e);
}
else
{
- group = make_item ("BreakAlignGroup", item->self_scm () );
+ group = make_item ("BreakAlignGroup", item->self_scm ());
group->set_property ("break-align-symbol", align_name);
group->set_parent (align_, Y_AXIS);
-
+
column_alist_ = scm_assoc_set_x (column_alist_, align_name, group->self_scm ());
}
}
ADD_TRANSLATOR (Break_align_engraver,
- "Align grobs with corresponding @code{break-align-symbols} into "
- "groups, and order the groups according to @code{breakAlignOrder}. "
- "The left edge of the alignment gets a separate group, with a symbol @code{left-edge}. "
- ,
- /* creats*/ "BreakAlignment BreakAlignGroup LeftEdge",
- /* accepts */ "",
- /* acks */ "break-aligned-interface",
- /* reads */ "",
- /* write */ "");
+ "Align grobs with corresponding @code{break-align-symbols} into "
+ "groups, and order the groups according to @code{breakAlignOrder}. "
+ "The left edge of the alignment gets a separate group, with a symbol @code{left-edge}. ",
+ /* creats*/ "BreakAlignment BreakAlignGroup LeftEdge",
+ /* accepts */ "",
+ /* acks */ "break-aligned-interface",
+ /* reads */ "",
+ /* write */ "");
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#include <math.h>
#include "break-align-interface.hh"
Axis a = (Axis) scm_to_int (axis);
assert (a == X_AXIS);
- Item* item = dynamic_cast<Item*> (me);
+ Item *item = dynamic_cast<Item *> (me);
Direction bsd = item->break_status_dir ();
if (bsd == LEFT)
{
/*
Force break alignment itself to be done first, in the case
- */
+ */
return Self_alignment_interface::aligned_on_self (element_smob, axis);
}
-
/*
This is tricky: we cannot modify 'elements, since callers are
iterating the same list. Reordering the list in-place, or resetting
'elements will skip elements in the loops of callers.
So we return the correct order as an array.
- */
+*/
Link_array<Grob>
Break_align_interface::ordered_elements (Grob *grob)
{
- Item *me = dynamic_cast<Item*> (grob);
+ Item *me = dynamic_cast<Item *> (grob);
SCM elts = me->get_property ("elements");
SCM order_vec = me->get_property ("break-align-orders");
if (!scm_is_vector (order_vec)
|| scm_c_vector_length (order_vec) < 3)
- return extract_grob_array (me, ly_symbol2scm ("elements"));
+ return extract_grob_array (me, ly_symbol2scm ("elements"));
SCM order = scm_vector_ref (order_vec,
scm_int2num (me->break_status_dir () + 1));
-
/*
Copy in order specified in BREAK-ALIGN-ORDER.
*/
void
Break_align_interface::do_alignment (Grob *grob)
{
- Item * me = dynamic_cast<Item*> (grob);
-
+ Item *me = dynamic_cast<Item *> (grob);
Link_array<Grob> elems = ordered_elements (me);
Array<Interval> extents;
last_nonempty = i;
}
- int idx = 0;
- while (idx < extents.size () && extents[idx].is_empty ())
+ int idx = 0;
+ while (idx < extents.size () && extents[idx].is_empty ())
idx++;
Array<Real> offsets;
offsets.set_size (elems.size ());
- for (int i = 0; i < offsets.size ();i ++)
+ for (int i = 0; i < offsets.size ();i++)
offsets[i] = 0.0;
-
Real extra_right_space = 0.0;
int edge_idx = -1;
while (idx < elems.size ())
{
- int next_idx = idx+1;
- while (next_idx < elems.size () &&
- extents[next_idx].is_empty () )
+ int next_idx = idx + 1;
+ while (next_idx < elems.size ()
+ && extents[next_idx].is_empty ())
next_idx++;
Grob *l = elems[idx];
SCM alist = SCM_EOL;
-
/*
Find the first grob with a space-alist entry.
- */
+ */
for (SCM s = l->get_property ("elements");
- scm_is_pair (s) ; s = scm_cdr (s))
- {
- Grob *elt = unsmob_grob (scm_car (s));
-
- if (edge_idx < 0
- && elt->get_property ("break-align-symbol")
- == ly_symbol2scm ( "left-edge"))
- edge_idx = idx;
-
- SCM l = elt->get_property ("space-alist");
- if (scm_is_pair (l))
- {
- alist = l;
- break;
- }
- }
+ scm_is_pair (s); s = scm_cdr (s))
+ {
+ Grob *elt = unsmob_grob (scm_car (s));
+
+ if (edge_idx < 0
+ && elt->get_property ("break-align-symbol")
+ == ly_symbol2scm ("left-edge"))
+ edge_idx = idx;
+
+ SCM l = elt->get_property ("space-alist");
+ if (scm_is_pair (l))
+ {
+ alist = l;
+ break;
+ }
+ }
SCM rsym = r ? SCM_EOL : ly_symbol2scm ("right-edge");
for (SCM s = r ? r->get_property ("elements") : SCM_EOL;
!scm_is_symbol (rsym) && scm_is_pair (s); s = scm_cdr (s))
{
- Grob * elt = unsmob_grob (scm_car (s));
+ Grob *elt = unsmob_grob (scm_car (s));
rsym = elt->get_property ("break-align-symbol");
}
- if (rsym == ly_symbol2scm ("left-edge"))
+ if (rsym == ly_symbol2scm ("left-edge"))
edge_idx = next_idx;
SCM entry = SCM_EOL;
if (scm_is_symbol (rsym))
sym_string = ly_symbol2string (rsym);
- String orig_string ;
+ String orig_string;
if (unsmob_grob (l->get_property ("cause")))
orig_string = unsmob_grob (l->get_property ("cause"))->name ();
programming_error (_f ("No spacing entry from %s to `%s'",
- orig_string.to_str0 (),
- sym_string.to_str0 ()));
+ orig_string.to_str0 (),
+ sym_string.to_str0 ()));
}
Real distance = 1.0;
entry = scm_cdr (entry);
distance = scm_to_double (scm_cdr (entry));
- type = scm_car (entry) ;
+ type = scm_car (entry);
}
if (r)
Interval total_extent;
Real alignment_off = 0.0;
- for (int i = 0 ; i < offsets.size (); i++)
+ for (int i = 0; i < offsets.size (); i++)
{
here += offsets[i];
if (i == edge_idx)
total_extent.unite (extents[i] + here);
}
-
if (me->break_status_dir () == LEFT)
{
- alignment_off = - total_extent[RIGHT] - extra_right_space;
+ alignment_off = -total_extent[RIGHT] - extra_right_space;
}
else if (edge_idx < 0)
alignment_off = -total_extent[LEFT];
here = alignment_off;
- for (int i = 0 ; i < offsets.size (); i++)
+ for (int i = 0; i < offsets.size (); i++)
{
here += offsets[i];
elems[i]->translate_axis (here, X_AXIS);
}
}
-
ADD_INTERFACE (Break_aligned_interface, "break-aligned-interface",
"Items that are aligned in prefatory matter.\n"
"\n"
"The object that performs break aligment. See @ref{break-aligned-interface}.",
"positioning-done break-align-orders");
-
-
#include "item.hh"
#include "system.hh"
-static SCM break_criterion;
+static SCM break_criterion;
void
set_break_subsititution (SCM criterion)
{
}
/*
- Perform the substitution for a single grob.
- */
+ Perform the substitution for a single grob.
+*/
SCM
substitute_grob (Grob *sc)
{
if (scm_is_integer (break_criterion))
{
- Item * i = dynamic_cast<Item*> (sc);
+ Item *i = dynamic_cast<Item *> (sc);
Direction d = to_dir (break_criterion);
if (i && i->break_status_dir () != d)
{
}
else
{
- System * line
- = dynamic_cast<System*> (unsmob_grob (break_criterion));
+ System *line
+ = dynamic_cast<System *> (unsmob_grob (break_criterion));
if (sc->get_system () != line)
{
sc = sc->find_broken_piece (line);
}
-
+
/* now: !sc || (sc && sc->get_system () == line) */
if (!sc)
return SCM_UNDEFINED;
- it forces us to mark the parents of a grob, leading to
a huge recursion in the GC routine.
- */
+ */
if (sc->common_refpoint (line, X_AXIS)
&& sc->common_refpoint (line, Y_AXIS))
return sc->self_scm ();
}
-
-
/*
Do break substitution in S, using CRITERION. Return new value.
CRITERION is either a SMOB pointer to the desired line, or a number
do_break_substitution (SCM src)
{
again:
-
+
if (unsmob_grob (src))
return substitute_grob (unsmob_grob (src));
else if (scm_is_vector (src))
{
SCM si = scm_int2num (i);
scm_vector_set_x (nv, si,
- do_break_substitution (scm_vector_ref (src, si)));
+ do_break_substitution (scm_vector_ref (src, si)));
}
}
- else if (scm_is_pair (src))
+ else if (scm_is_pair (src))
{
/*
UGH! breaks on circular lists.
*/
SCM newcar = do_break_substitution (scm_car (src));
SCM oldcdr = scm_cdr (src);
-
+
if (newcar == SCM_UNDEFINED
&& (scm_is_pair (oldcdr) || oldcdr == SCM_EOL))
{
/*
- This is tail-recursion, ie.
-
+ This is tail-recursion, ie.
+
return do_break_substution (cdr);
We don't want to rely on the compiler to do this. Without
tail-recursion, this easily crashes with a stack overflow. */
- src = oldcdr;
+ src = oldcdr;
goto again;
}
return src;
}
-
/*
Perform substitution on GROB_LIST using a constant amount of stack.
- */
+*/
SCM
substitute_grob_list (SCM grob_list)
{
SCM l = SCM_EOL;
- SCM * tail = &l;
+ SCM *tail = &l;
- for (SCM s = grob_list; scm_is_pair (s); s = scm_cdr (s))
+ for (SCM s = grob_list; scm_is_pair (s); s = scm_cdr (s))
{
SCM n = substitute_grob (unsmob_grob (scm_car (s)));
We don't do
forall b in broken-childs:
- forall p in properties:
- forall g in p (if grob-list):
- g := substitute (g)
+ forall p in properties:
+ forall g in p (if grob-list):
+ g := substitute (g)
for spanners since this is O (SYSTEMCOUNT * GROBCOUNT), and SYSTEMCOUNT =
O (GROBCOUNT), we have a quadratic algorithm. --for a single spanner
significant; especially all-elements in System, can become huge. For
a typical 50 page score, it requires running through a 100k list 50
times.
-
+
Instead:
forall p in properties:
- (if grob list)
+ (if grob list)
- put grob list in array,
+ put grob list in array,
- reorder array so spanners are separate -- O (grobcount)
-
- find first and last indexes of grobs on a specific system
+ reorder array so spanners are separate -- O (grobcount)
- for items this is O (itemcount)
+ find first and last indexes of grobs on a specific system
- for spanners this is O (sum-of spanner-system-ranges)
+ for items this is O (itemcount)
- perform the substitution O (sum-of spanner-system-ranges)
+ for spanners this is O (sum-of spanner-system-ranges)
+
+ perform the substitution O (sum-of spanner-system-ranges)
The complexity is harder to determine, but should be subquadratic;
For the situation above, we run through the entire 100k list once,
and also (more or less) once through the item part of the 100k (say
- 98k elements) of the list.
+ 98k elements) of the list.
-These timings were measured without -O2.
+ These timings were measured without -O2.
- lehre, before 28.98 seconds, after: 27.91 seconds, 3.5 %.
+ lehre, before 28.98 seconds, after: 27.91 seconds, 3.5 %.
coriolan, before 2:30, after: 1:59. Increase of 20%.
moz-k498-p1, before 24.10, after: 19.790s, Increase of 18%
-
-
*/
-
Slice
-spanner_system_range (Spanner* sp)
+spanner_system_range (Spanner *sp)
{
Slice rv;
-
- if (System*st = sp->get_system ())
+
+ if (System *st = sp->get_system ())
{
rv = Slice (st->rank_, st->rank_);
}
- else
+ else
{
if (sp->broken_intos_.size ())
rv = Slice (sp->broken_intos_[0]->get_system ()->rank_,
}
Slice
-item_system_range (Item* it)
+item_system_range (Item *it)
{
- if (System*st = it->get_system ())
+ if (System *st = it->get_system ())
return Slice (st->rank_, st->rank_);
Slice sr;
sr.add_point (bi->get_system ()->rank_);
}
while (flip (&d)!= LEFT);
-
+
return sr;
}
Slice
grob_system_range (Grob *g)
{
- if (Spanner*s = dynamic_cast<Spanner*>(g))
- return spanner_system_range (s);
- else if (Item* it = dynamic_cast<Item*> (g))
- return item_system_range (it);
- else
- return Slice ();
+ if (Spanner *s = dynamic_cast<Spanner *> (g))
+ return spanner_system_range (s);
+ else if (Item *it = dynamic_cast<Item *> (g))
+ return item_system_range (it);
+ else
+ return Slice ();
}
-
-
struct Substitution_entry
{
- Grob * grob_;
+ Grob *grob_;
short left_;
short right_;
-
- void set (Grob*g, Slice sr)
+
+ void set (Grob *g, Slice sr)
{
grob_ = g;
/*
{
/*
overflow if we don't treat this specially.
- */
+ */
left_ = 1;
right_ = -1;
}
grob_ = 0;
left_ = right_ = -2;
}
-
- int length () { return right_ - left_ ; }
+
+ int length () { return right_ - left_; }
static int
- item_compare (void const * a , void const * b)
+ item_compare (void const *a, void const *b)
{
- return ((Substitution_entry*)a)->left_ -
- ((Substitution_entry*)b)->left_;
+ return ((Substitution_entry *)a)->left_
+ - ((Substitution_entry *)b)->left_;
}
-
+
static int
- spanner_compare (void const * a , void const * b)
+ spanner_compare (void const *a, void const *b)
{
- return ((Substitution_entry*)a)->length () -
- ((Substitution_entry*)b)->length ();
+ return ((Substitution_entry *)a)->length ()
+ - ((Substitution_entry *)b)->length ();
}
};
-
-
bool
Spanner::fast_fubstitute_grob_list (SCM sym,
SCM grob_list)
Only do this complicated thing for large lists. This has the added
advantage that we won't screw up the ordering for elements in
alignments (which typically don't have more than 10 grobs.)
- */
-
+ */
+
if (len < 300)
return false;
-
/*
- TODO : should not free it some time?
- */
- static Substitution_entry * vec;
+ TODO : should not free it some time?
+ */
+ static Substitution_entry *vec;
static int vec_room;
if (vec_room < len)
{
- vec = (Substitution_entry*) realloc (vec, sizeof (Substitution_entry) * len);
+ vec = (Substitution_entry *) realloc (vec, sizeof (Substitution_entry) * len);
vec_room = len;
}
-
+
Slice system_range = spanner_system_range (this);
Array<Slice> it_indices;
it_indices.push (Slice (len, 0));
sp_indices.push (Slice (len, 0));
}
-
-
+
int sp_index = len;
int it_index = 0;
for (SCM s = grob_list; scm_is_pair (s); s = scm_cdr (s))
{
- Grob * g = unsmob_grob (scm_car (s));
+ Grob *g = unsmob_grob (scm_car (s));
Slice sr = grob_system_range (g);
sr.intersect (system_range);
int idx = 0;
- if (dynamic_cast<Spanner*>(g))
+ if (dynamic_cast<Spanner *> (g))
{
idx =--sp_index;
}
- else if (dynamic_cast<Item*> (g))
+ else if (dynamic_cast<Item *> (g))
{
idx = it_index++;
}
qsort (vec, it_index,
sizeof (Substitution_entry), &Substitution_entry::item_compare);
- Array<Slice> *arrs[] = {
- &it_indices, &sp_indices
- };
-
- for (int i = 0; i < it_index ;i++)
- {
- for (int j = vec[i].left_; j <= vec[i].right_; j++)
- {
- it_indices[j - system_range[LEFT]].add_point (i);
- }
- }
-
- /*
- sorting vec[sp_index.. len]
- is a waste of time -- the staff-spanners screw up the
- ordering, since they go across the entire score.
- */
- for (int i = sp_indices.size (); i--;)
- sp_indices[i]= Slice (sp_index, len-1);
-
-
+ Array<Slice> *arrs[]
+ = {
+ &it_indices, &sp_indices
+ };
+
+ for (int i = 0; i < it_index;i++)
+ {
+ for (int j = vec[i].left_; j <= vec[i].right_; j++)
+ {
+ it_indices[j - system_range[LEFT]].add_point (i);
+ }
+ }
+
+ /*
+ sorting vec[sp_index.. len]
+ is a waste of time -- the staff-spanners screw up the
+ ordering, since they go across the entire score.
+ */
+ for (int i = sp_indices.size (); i--;)
+ sp_indices[i]= Slice (sp_index, len - 1);
+
assert (it_index <= sp_index);
- assert (broken_intos_.size () == system_range.length () + 1);
+ assert (broken_intos_.size () == system_range.length () + 1);
for (int i = 0; i < broken_intos_.size (); i++)
{
- Grob * sc = broken_intos_[i];
- System * l = sc->get_system ();
+ Grob *sc = broken_intos_[i];
+ System *l = sc->get_system ();
set_break_subsititution (l ? l->self_scm (): SCM_UNDEFINED);
SCM newval = SCM_EOL;
- SCM * tail = &newval;
+ SCM *tail = &newval;
- for (int k = 0; k < 2;k++)
+ for (int k = 0; k < 2;k++)
for (int j = (*arrs[k])[i][LEFT]; j <= (*arrs[k])[i][RIGHT]; j++)
{
SCM subs = substitute_grob (vec[j].grob_);
if (subs!= SCM_UNDEFINED)
{
*tail = scm_cons (subs, SCM_EOL);
-
+
tail = SCM_CDRLOC (*tail);
}
}
-
+
#ifdef PARANOIA
-
+
printf ("%d (%d), sp %d (%d)\n",
it_indices [i].length (), it_index,
- sp_indices[i].length () , len -sp_index);
-
+ sp_indices[i].length (), len -sp_index);
+
{
SCM l1 = substitute_grob_list (grob_list);
assert (scm_ilength (l1) == scm_ilength (newval));
/*
see below.
- */
+ */
if (sym == ly_symbol2scm ("all-elements"))
- sc->mutable_property_alist_
- = scm_assq_remove_x (sc->mutable_property_alist_,
- ly_symbol2scm ("all-elements"));
-
+ sc->mutable_property_alist_
+ = scm_assq_remove_x (sc->mutable_property_alist_,
+ ly_symbol2scm ("all-elements"));
+
sc->mutable_property_alist_ = scm_acons (sym, newval,
sc->mutable_property_alist_);
}
return true;
}
-
/*
Although the substitution can be written as
This becomes a problem if lily is linked against guile with
pthreads. pthreads impose small limits on the stack size.
- */
+*/
SCM
substitute_mutable_property_alist (SCM alist)
{
else
val = do_break_substitution (val);
-
if (val != SCM_UNDEFINED)
{
/*
for ly:grob? properties, SCM_UNDEFINED could leak out
through ly:grob-property
- */
+ */
*tail = scm_cons (scm_cons (sym, val), SCM_EOL);
tail = SCM_CDRLOC (*tail);
}
return l;
}
-
void
Spanner::substitute_one_mutable_property (SCM sym,
SCM val)
{
SCM type = scm_object_property (sym, ly_symbol2scm ("backend-type?"));
- Spanner*s = this;
-
+ Spanner *s = this;
+
bool fast_done = false;
SCM grob_list_p = ly_lily_module_constant ("grob-list?");
if (type == grob_list_p)
fast_done = s->fast_fubstitute_grob_list (sym, val);
- if (!fast_done)
+ if (!fast_done)
for (int i = 0; i < s->broken_intos_ .size (); i++)
{
- Grob * sc = s->broken_intos_[i];
- System * l = sc->get_system ();
+ Grob *sc = s->broken_intos_[i];
+ System *l = sc->get_system ();
set_break_subsititution (l ? l->self_scm () : SCM_UNDEFINED);
SCM newval = (type == grob_list_p)
if (sym == ly_symbol2scm ("all-elements"))
sc->mutable_property_alist_
= scm_assq_remove_x (sc->mutable_property_alist_,
- ly_symbol2scm ("all-elements"));
-
+ ly_symbol2scm ("all-elements"));
+
sc->mutable_property_alist_ = scm_cons (scm_cons (sym, newval),
sc->mutable_property_alist_);
}
}
-
+
written for the GNU LilyPond music typesetter
-TODO:
+ TODO:
. Cancel any beams running through the breathing sign
- ([e8 \breathe f e f] should become [e8] \breathe [f e f])
+ ([e8 \breathe f e f] should become [e8] \breathe [f e f])
. Spacing is not yet completely pretty
-
*/
#include "staff-symbol-referencer.hh"
#include "engraver-group-engraver.hh"
#include "item.hh"
-
-class Breathing_sign_engraver : public Engraver {
+class Breathing_sign_engraver : public Engraver
+{
public:
TRANSLATOR_DECLARATIONS (Breathing_sign_engraver);
-
+
protected:
virtual bool try_music (Music *req);
virtual void process_acknowledged_grobs ();
virtual void stop_translation_timestep ();
private:
- Music * breathing_sign_req_;
- Grob * breathing_sign_;
+ Music *breathing_sign_req_;
+ Grob *breathing_sign_;
};
Breathing_sign_engraver::Breathing_sign_engraver ()
}
bool
-Breathing_sign_engraver::try_music (Music*r)
+Breathing_sign_engraver::try_music (Music *r)
{
breathing_sign_req_ = r;
return true;
}
}
-void
+void
Breathing_sign_engraver::stop_translation_timestep ()
{
breathing_sign_ = 0;
breathing_sign_req_ = 0;
}
-
ADD_TRANSLATOR (Breathing_sign_engraver,
-/* descr */ "",
-/* creats*/ "BreathingSign",
-/* accepts */ "breathing-event",
-/* acks */ "",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "",
+ /* creats*/ "BreathingSign",
+ /* accepts */ "breathing-event",
+ /* acks */ "",
+ /* reads */ "",
+ /* write */ "");
/*
TODO: thickness should be a grob property (unit: linethickness)
- rather than hardwired to (staff_space / 6).
- */
-
-
+ rather than hardwired to (staff_space / 6).
+*/
/*
UGH : this is full of C&P code. Consolidate! --hwn
/*
Gregorian chant divisio minima. (Actually, this was the original
breathing sign by Michael. -- jr)
- */
+*/
MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_minima, 1);
-SCM
+SCM
Breathing_sign::divisio_minima (SCM smob)
{
Grob *me = unsmob_grob (smob);
/*
Gregorian chant divisio maior.
- */
+*/
MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_maior, 1);
-SCM
+SCM
Breathing_sign::divisio_maior (SCM smob)
{
Grob *me = unsmob_grob (smob);
/*
Gregorian chant divisio maxima.
- */
+*/
MAKE_SCHEME_CALLBACK (Breathing_sign, divisio_maxima, 1);
-SCM
+SCM
Breathing_sign::divisio_maxima (SCM smob)
{
Grob *me = unsmob_grob (smob);
/*
Gregorian chant finalis.
- */
+*/
MAKE_SCHEME_CALLBACK (Breathing_sign, finalis, 1);
-SCM
+SCM
Breathing_sign::finalis (SCM smob)
{
Grob *me = unsmob_grob (smob);
Breathing_sign::offset_callback (SCM element_smob, SCM)
{
Grob *me = unsmob_grob (element_smob);
-
+
Direction d = get_grob_direction (me);
if (!d)
{
set_grob_direction (me, d);
}
- Real inter_f = Staff_symbol_referencer::staff_space (me)/2;
- int sz = Staff_symbol_referencer::line_count (me)-1;
+ Real inter_f = Staff_symbol_referencer::staff_space (me) / 2;
+ int sz = Staff_symbol_referencer::line_count (me) - 1;
return scm_make_real (inter_f * sz * d);
}
ADD_INTERFACE (Breathing_sign, "breathing-sign-interface",
- "A breathing sign.",
- "direction");
+ "A breathing sign.",
+ "direction");
String to_type = ly_symbol2string (get_music ()->get_property ("change-to-type"));
String to_id = ly_scm2string (get_music ()->get_property ("change-to-id"));
- String warn1 = _f ("can't change `%s' to `%s'", to_type, to_id)
+ String warn1 = _f ("can't change `%s' to `%s'", to_type, to_id)
+ ": " + reason;
/*
GUHG!
- */
- String warn2= "Change_iterator::process (): "
+ */
+ String warn2= "Change_iterator::process (): "
+ get_outlet ()->context_name () + " = `"
+ get_outlet ()->id_string () + "': ";
warning (warn2);
/*
move to construct_children ?
- */
+*/
void
Change_iterator::process (Moment m)
{
- Context * current = get_outlet ();
- Context * last = 0;
+ Context *current = get_outlet ();
+ Context *last = 0;
SCM to_type = get_music ()->get_property ("change-to-type");
- String to_id = ly_scm2string (get_music ()->get_property ("change-to-id"));
-
+ String to_id = ly_scm2string (get_music ()->get_property ("change-to-id"));
/* find the type of translator that we're changing.
-
- If \translator Staff = bass, then look for Staff = *
- */
+
+ If \translator Staff = bass, then look for Staff = *
+ */
while (current && !current->is_alias (to_type))
{
last = current;
String msg;
msg += _ ("Can't switch translators, I'm there already");
}
-
- if (current)
+
+ if (current)
if (last)
{
- Context * dest = 0;
- Context * where = get_outlet ();
+ Context *dest = 0;
+ Context *where = get_outlet ();
while (!dest && where)
{
dest = find_context_below (where, to_type, to_id);
where = where->get_parent_context ();
}
-
+
if (dest)
{
current->remove_context (last);
}
else
{
- get_music ()->origin ()->warning ("could not find context to switch to.");
+ get_music ()->origin ()->warning ("could not find context to switch to.");
}
}
else
{
/*
- We could change the current translator's id, but that would make
+ We could change the current translator's id, but that would make
errors hard to catch
-
- last->translator_id_string () = get_change ()->change_to_id_string ();
+
+ last->translator_id_string () = get_change ()->change_to_id_string ();
*/
error (_ ("I'm one myself"));
}
Simple_music_iterator::process (m);
}
-
-
IMPLEMENT_CTOR_CALLBACK (Change_iterator);
#include "context.hh"
#include "warn.hh"
-class Chord_name_engraver : public Engraver
+class Chord_name_engraver : public Engraver
{
- TRANSLATOR_DECLARATIONS ( Chord_name_engraver);
+ TRANSLATOR_DECLARATIONS (Chord_name_engraver);
protected:
virtual void stop_translation_timestep ();
virtual void process_music ();
virtual void derived_mark () const;
private:
void add_note (Music *);
-
- Item* chord_name_;
+
+ Item *chord_name_;
Link_array<Music> notes_;
-
+
SCM last_chord_;
};
-
-
void
Chord_name_engraver::finalize ()
{
}
void
-Chord_name_engraver::derived_mark() const
+Chord_name_engraver::derived_mark () const
{
scm_gc_mark (last_chord_);
}
}
void
-Chord_name_engraver::add_note (Music * n)
+Chord_name_engraver::add_note (Music *n)
{
notes_.push (n);
}
void
Chord_name_engraver::process_music ()
{
- if (!notes_.size () )
+ if (!notes_.size ())
return;
-
+
SCM bass = SCM_EOL;
SCM inversion = SCM_EOL;
SCM pitches = SCM_EOL;
- Music* inversion_event = 0;
- for (int i = 0 ; i < notes_.size (); i++)
+ Music *inversion_event = 0;
+ for (int i = 0; i < notes_.size (); i++)
{
Music *n = notes_[i];
SCM p = n->get_property ("pitch");
if (!unsmob_pitch (p))
continue;
-
+
if (n->get_property ("inversion") == SCM_BOOL_T)
{
inversion_event = n;
if (scm_is_number (oct))
{
Pitch *p = unsmob_pitch (inversion_event->get_property ("pitch"));
- int octavation = scm_to_int (oct);
+ int octavation = scm_to_int (oct);
Pitch orig = p->transposed (Pitch (-octavation, 0, 0));
-
+
pitches = scm_cons (orig.smobbed_copy (), pitches);
}
else
context ()->self_scm ());
/*
- Ugh.
- */
+ Ugh.
+ */
SCM chord_as_scm = scm_cons (pitches, scm_cons (bass, inversion));
-
+
chord_name_ = make_item ("ChordName", notes_[0]->self_scm ());
chord_name_->set_property ("text", markup);
SCM s = get_property ("chordChanges");
- if (to_boolean (s) && scm_is_pair (last_chord_)
+ if (to_boolean (s) && scm_is_pair (last_chord_)
&& ly_c_equal_p (chord_as_scm, last_chord_))
chord_name_->set_property ("begin-of-line-visible", SCM_BOOL_T);
}
bool
-Chord_name_engraver::try_music (Music* m)
+Chord_name_engraver::try_music (Music *m)
{
/*
- hmm. Should check?
- */
+ hmm. Should check?
+ */
if (m->is_mus_type ("note-event"))
{
add_note (m);
which properties are read depend on the chord naming function active.
*/
ADD_TRANSLATOR (Chord_name_engraver,
-/* descr */ "Catch note-events "
-"and generate the appropriate chordname.",
-/* creats*/ "ChordName",
-/* accepts */ "note-event",
-/* acks */ "",
-/* reads */ "chordChanges chordNameExceptions chordNameFunction "
-"chordNoteNamer chordRootNamer chordNameExceptions majorSevenSymbol",
-/* write */ "");
+ /* descr */ "Catch note-events "
+ "and generate the appropriate chordname.",
+ /* creats*/ "ChordName",
+ /* accepts */ "note-event",
+ /* acks */ "",
+ /* reads */ "chordChanges chordNameExceptions chordNameFunction "
+ "chordNoteNamer chordRootNamer chordNameExceptions majorSevenSymbol",
+ /* write */ "");
SCM
Chord_name::after_line_breaking (SCM smob)
{
- Item* me = unsmob_item (smob);
+ Item *me = unsmob_item (smob);
assert (me);
-
+
SCM s = me->get_property ("begin-of-line-visible");
if (to_boolean (s))
{
- if (Paper_column::get_rank (me->get_column ()) -
- me->get_system ()->spanned_rank_iv ()[LEFT] > 1)
+ if (Paper_column::get_rank (me->get_column ())
+ - me->get_system ()->spanned_rank_iv ()[LEFT] > 1)
me->suicide ();
}
return SCM_UNSPECIFIED;
}
ADD_INTERFACE (Chord_name, "chord-name-interface",
- "A chord name.",
- "begin-of-line-visible");
+ "A chord name.",
+ "begin-of-line-visible");
-/*
- chord-tremolo-engraver.cc -- implement Chord_tremolo_engraver
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
+/*
+ chord-tremolo-engraver.cc -- implement Chord_tremolo_engraver
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "beam.hh"
#include "item.hh"
#include "chord-tremolo-iterator.hh"
#include "stem-tremolo.hh"
-#include "math.h" // ceil
+#include "math.h" // ceil
/**
- create dots if appropriate.
- create TremoloBeam iso Beam?
-
*/
class Chord_tremolo_engraver : public Engraver
{
void typeset_beam ();
TRANSLATOR_DECLARATIONS (Chord_tremolo_engraver);
protected:
- Music * repeat_;
+ Music *repeat_;
/// moment (global time) where beam started.
Moment start_mom_;
Moment stop_mom_;
- int flags_ ;
+ int flags_;
int total_duration_flags_;
-
+
/// location within measure where beam started.
Moment beam_start_location_;
bool body_is_sequential_;
- Spanner * beam_;
- Spanner * finished_beam_;
- Item * stem_tremolo_;
+ Spanner *beam_;
+ Spanner *finished_beam_;
+ Item *stem_tremolo_;
protected:
virtual void finalize ();
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void acknowledge_grob (Grob_info);
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
Chord_tremolo_engraver::Chord_tremolo_engraver ()
{
- beam_ = finished_beam_ = 0;
+ beam_ = finished_beam_ = 0;
repeat_ = 0;
flags_ = 0;
stem_tremolo_ = 0;
}
bool
-Chord_tremolo_engraver::try_music (Music * m)
+Chord_tremolo_engraver::try_music (Music *m)
{
if (m->is_mus_type ("repeated-music")
&& m->get_property ("iterator-ctor") == Chord_tremolo_iterator::constructor_proc
- && !repeat_)
+ && !repeat_)
{
Moment l = m->get_length ();
repeat_ = m;
start_mom_ = now_mom ();
stop_mom_ = start_mom_ + l;
-
Music *body = Repeated_music::body (m);
body_is_sequential_ = body->is_mus_type ("sequential-music");
if (elt_count <= 0)
elt_count = 1;
-
+
Rational total_dur = l.main_part_;
Rational note_dur = total_dur / Rational (elt_count * Repeated_music::repeat_count (repeat_));
total_duration_flags_ = 0 >? (intlog2 (total_dur.den ()) - 2);
-
- flags_ = intlog2 (note_dur.den ()) -2 ;
-
+
+ flags_ = intlog2 (note_dur.den ()) -2;
+
return true;
}
{
if (beam_ && Stem::has_interface (info.grob_))
{
- Grob * s = info.grob_;
+ Grob *s = info.grob_;
if (start_mom_ == now_mom ())
Stem::set_beaming (s, flags_, RIGHT);
else
Stem::set_beaming (s, flags_, LEFT);
-
+
if (Stem::duration_log (s) != 1)
{
beam_->set_property ("gap-count", scm_int2num (flags_ - total_duration_flags_));
::warning (s);
}
}
- else if (repeat_ &&
- flags_ && !body_is_sequential_ && Stem::has_interface (info.grob_))
+ else if (repeat_
+ && flags_ && !body_is_sequential_ && Stem::has_interface (info.grob_))
{
stem_tremolo_ = make_item ("StemTremolo", repeat_->self_scm ());
stem_tremolo_->set_property ("flag-count",
}
}
-
void
Chord_tremolo_engraver::start_translation_timestep ()
{
}
}
-
void
Chord_tremolo_engraver::stop_translation_timestep ()
{
typeset_beam ();
}
-
-
ADD_TRANSLATOR (Chord_tremolo_engraver,
-/* descr */ "Generates beams for tremolo repeats.",
-/* creats*/ "Beam",
-/* accepts */ "repeated-music",
-/* acks */ "stem-interface note-head-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Generates beams for tremolo repeats.",
+ /* creats*/ "Beam",
+ /* accepts */ "repeated-music",
+ /* acks */ "stem-interface note-head-interface",
+ /* reads */ "",
+ /* write */ "");
-/*
+/*
chord-tremolo-iterator.cc -- implement Chord_tremolo_iterator
-
+
source file of the GNU LilyPond music typesetter
-
- (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
/*
this is culled from various other iterators, but sharing code by
subclassing proved to be too difficult.
- */
+*/
#include "chord-tremolo-iterator.hh"
void
Chord_tremolo_iterator::construct_children ()
{
- Music *m = get_music();
-
- factor_ = Moment (Rational (1, 1));
+ Music *m = get_music ();
+
+ factor_ = Moment (Rational (1, 1));
child_iter_ = unsmob_iterator (get_iterator (Repeated_music::body (m)));
}
}
void
-Chord_tremolo_iterator::derived_substitute (Context *f, Context *t)
+Chord_tremolo_iterator::derived_substitute (Context *f, Context *t)
{
if (child_iter_)
child_iter_->substitute_outlet (f, t);
void
Chord_tremolo_iterator::process (Moment m)
{
- if (!m.to_bool () )
+ if (!m.to_bool ())
{
Music_iterator *yeah = try_music (get_music ());
if (yeah)
return child_iter_ && child_iter_->ok ();
}
-Music_iterator*
-Chord_tremolo_iterator::try_music_in_children (Music *m) const
+Music_iterator *
+Chord_tremolo_iterator::try_music_in_children (Music *m) const
{
return child_iter_->try_music (m);
}
#include "direction.hh"
#include "side-position-interface.hh"
-class Clef_engraver : public Engraver
+class Clef_engraver : public Engraver
{
public:
TRANSLATOR_DECLARATIONS (Clef_engraver);
virtual void process_music ();
virtual void acknowledge_grob (Grob_info);
private:
- Item * clef_;
- Item * octavate_;
+ Item *clef_;
+ Item *octavate_;
SCM prev_glyph_;
SCM prev_cpos_;
/*
will trigger a clef at the start since #f != ' ()
- */
+ */
prev_cpos_ = prev_glyph_ = SCM_BOOL_F;
}
SCM glyph = get_property ("clefGlyph");
SCM basic = ly_symbol2scm ("Clef");
-
+
execute_pushpop_property (context (), basic, glyph_sym, SCM_UNDEFINED);
execute_pushpop_property (context (), basic, glyph_sym, glyph);
}
-/**
- Generate a clef at the start of a measure. (when you see a Bar,
- ie. a breakpoint)
- */
+/**
+ Generate a clef at the start of a measure. (when you see a Bar,
+ ie. a breakpoint)
+*/
void
Clef_engraver::acknowledge_grob (Grob_info info)
{
- Item * item = dynamic_cast <Item *> (info.grob_);
+ Item *item = dynamic_cast<Item *> (info.grob_);
if (item)
{
if (Bar_line::has_interface (info.grob_)
&& scm_is_string (get_property ("clefGlyph")))
create_clef ();
- }
+ }
}
void
if (!clef_)
{
Item *c = make_item ("Clef", SCM_EOL);
-
clef_ = c;
SCM cpos = get_property ("clefPosition");
if (scm_is_number (cpos))
clef_->set_property ("staff-position", cpos);
- SCM oct = get_property ("clefOctavation");
+ SCM oct = get_property ("clefOctavation");
if (scm_is_number (oct) && scm_to_int (oct))
{
- Item * g = make_item ("OctavateEight", SCM_EOL);
+ Item *g = make_item ("OctavateEight", SCM_EOL);
- int abs_oct = scm_to_int (oct) ;
+ int abs_oct = scm_to_int (oct);
int dir = sign (abs_oct);
- abs_oct = abs (abs_oct) + 1;
+ abs_oct = abs (abs_oct) + 1;
SCM txt = scm_number_to_string (scm_int2num (abs_oct),
scm_from_int (10));
g->set_property ("text",
scm_list_n (ly_lily_module_constant ("vcenter-markup"),
- txt, SCM_UNDEFINED));
- Side_position_interface::add_support (g, clef_);
+ txt, SCM_UNDEFINED));
+ Side_position_interface::add_support (g, clef_);
g->set_parent (clef_, Y_AXIS);
g->set_parent (clef_, X_AXIS);
g->set_property ("direction", scm_int2num (dir));
octavate_ = g;
-
+
}
}
}
SCM clefpos = get_property ("clefPosition");
SCM octavation = get_property ("clefOctavation");
SCM force_clef = get_property ("forceClef");
-
+
if (clefpos == SCM_EOL
|| scm_equal_p (glyph, prev_glyph_) == SCM_BOOL_F
|| scm_equal_p (clefpos, prev_cpos_) == SCM_BOOL_F
if (to_boolean (force_clef))
{
- Context * w = context ()->where_defined (ly_symbol2scm ("forceClef"));
+ Context *w = context ()->where_defined (ly_symbol2scm ("forceClef"));
w->set_property ("forceClef", SCM_EOL);
}
}
-
void
Clef_engraver::stop_translation_timestep ()
{
if (clef_)
{
- SCM vis = 0;
+ SCM vis = 0;
if (to_boolean (clef_->get_property ("non-default")))
{
vis = get_property ("explicitClefVisibility");
}
}
-
+
clef_ = 0;
octavate_ = 0;
}
}
-
-
ADD_TRANSLATOR (Clef_engraver,
-/* descr */ "Determine and set reference point for pitches",
-/* creats*/ "Clef OctavateEight",
-/* accepts */ "",
-/* acks */ "bar-line-interface",
-/* reads */ "clefPosition clefGlyph middleCPosition clefOctavation explicitClefVisibility forceClef",
-/* write */ "");
+ /* descr */ "Determine and set reference point for pitches",
+ /* creats*/ "Clef OctavateEight",
+ /* accepts */ "",
+ /* acks */ "bar-line-interface",
+ /* reads */ "clefPosition clefGlyph middleCPosition clefOctavation explicitClefVisibility forceClef",
+ /* write */ "");
#include "font-interface.hh"
/*
- FIXME: should use symbol for #'style.
+ FIXME: should use symbol for #'style.
*/
MAKE_SCHEME_CALLBACK (Clef, before_line_breaking, 1);
SCM
&& !to_boolean (s->get_property ("full-size-change")))
{
str += "_change";
- s->set_property ("glyph-name", scm_makfrom0str (str.to_str0 ()));
+ s->set_property ("glyph-name", scm_makfrom0str (str.to_str0 ()));
}
}
}
MAKE_SCHEME_CALLBACK (Clef, print, 1)
-SCM
+ SCM
Clef::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
}
ADD_INTERFACE (Clef, "clef-interface",
- "A clef sign",
- "non-default full-size-change glyph-name");
+ "A clef sign",
+ "non-default full-size-change glyph-name");
protected:
TRANSLATOR_DECLARATIONS (Cluster_spanner_engraver);
virtual bool try_music (Music *);
- virtual void process_music ();
+ virtual void process_music ();
virtual void acknowledge_grob (Grob_info);
virtual void stop_translation_timestep ();
virtual void finalize ();
private:
Link_array<Music> cluster_notes_;
- Item* beacon_;
+ Item *beacon_;
void typeset_grobs ();
Spanner *spanner_;
- Spanner *finished_spanner_ ;
+ Spanner *finished_spanner_;
};
Cluster_spanner_engraver::Cluster_spanner_engraver ()
}
else if (m->is_mus_type ("busy-playing-event"))
return cluster_notes_.size ();
-
+
return false;
}
{
SCM c0scm = get_property ("middleCPosition");
- int c0 = scm_is_number (c0scm) ? scm_to_int (c0scm) : 0;
+ int c0 = scm_is_number (c0scm) ? scm_to_int (c0scm) : 0;
int pmax = INT_MIN;
int pmin = INT_MAX;
-
+
for (int i = 0; i <cluster_notes_.size (); i++)
{
Pitch *pit = unsmob_pitch (cluster_notes_[i]->get_property ("pitch"));
- int p =( pit ? pit->steps () : 0) + c0;
+ int p = (pit ? pit->steps () : 0) + c0;
pmax = pmax >? p;
pmin = pmin <? p;
}
-
+
beacon_ = make_item ("ClusterSpannerBeacon", cluster_notes_[0]->self_scm ());
beacon_->set_property ("positions",
- scm_cons (scm_int2num (pmin),
- scm_int2num (pmax)));
+ scm_cons (scm_int2num (pmin),
+ scm_int2num (pmax)));
}
if (beacon_ && !spanner_)
- {
- spanner_ = make_spanner ("ClusterSpanner", cluster_notes_[0]->self_scm () );
+ {
+ spanner_ = make_spanner ("ClusterSpanner", cluster_notes_[0]->self_scm ());
}
-
+
if (beacon_ && spanner_)
{
add_bound_item (spanner_, beacon_);
}
}
-
void
Cluster_spanner_engraver::stop_translation_timestep ()
{
}
ADD_TRANSLATOR (Cluster_spanner_engraver,
-/* descr */ "Engraves a cluster using Spanner notation ",
-/* creats*/ "ClusterSpanner ClusterSpannerBeacon",
-/* accepts */ "cluster-note-event busy-playing-event",
-/* acks */ "note-column-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Engraves a cluster using Spanner notation ",
+ /* creats*/ "ClusterSpanner ClusterSpannerBeacon",
+ /* accepts */ "cluster-note-event busy-playing-event",
+ /* acks */ "note-column-interface",
+ /* reads */ "",
+ /* write */ "");
(c) 2002--2005 Juergen Reuter <reuter@ipd.uka.de>
Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
*/
#include "cluster.hh"
#include "output-def.hh"
#include "warn.hh"
-
/*
- TODO: Add support for cubic spline segments.
-
- */
+ TODO: Add support for cubic spline segments.
+*/
Stencil
brew_cluster_piece (Grob *me, Array<Offset> bottom_points, Array<Offset> top_points)
{
- Real blotdiameter = Staff_symbol_referencer::staff_space (me)/2;
+ Real blotdiameter = Staff_symbol_referencer::staff_space (me) / 2;
- Real padding = robust_scm2double ( me->get_property ("padding"), 0.0);
+ Real padding = robust_scm2double (me->get_property ("padding"), 0.0);
Offset vpadding = Offset (0, padding);
Offset hpadding = Offset (0.5 * blotdiameter, 0);
{
programming_error ("#'style should be symbol.");
me->suicide ();
- return Stencil ();
+ return Stencil ();
}
-
Stencil out;
Array<Offset> points;
points.clear ();
Box box;
box.add_point (bottom_points[i] - hvpadding);
box.add_point (Offset (top_points[i + 1][X_AXIS],
- top_points[i][Y_AXIS]) + hvpadding);
+ top_points[i][Y_AXIS]) + hvpadding);
out.add_stencil (Lookup::round_filled_box (box, blotdiameter));
}
}
{
Box box;
box.add_point (Offset (bottom_points[i][X_AXIS],
- bottom_points[i + 1][Y_AXIS]) - hvpadding);
+ bottom_points[i + 1][Y_AXIS]) - hvpadding);
box.add_point (top_points[i + 1] + hvpadding);
out.add_stencil (Lookup::round_filled_box (box, blotdiameter));
}
Real left_xmid = bottom_points[0][X_AXIS];
for (int i = 0; i < size - 1; i++)
{
- Real right_xmid =
- 0.5 * (bottom_points[i][X_AXIS] + bottom_points[i + 1][X_AXIS]);
+ Real right_xmid
+ = 0.5 * (bottom_points[i][X_AXIS] + bottom_points[i + 1][X_AXIS]);
Box box;
- box.add_point (Offset (left_xmid, bottom_points[i][Y_AXIS]) -
- hvpadding);
- box.add_point (Offset (right_xmid, top_points[i][Y_AXIS]) +
- hvpadding);
+ box.add_point (Offset (left_xmid, bottom_points[i][Y_AXIS])
+ - hvpadding);
+ box.add_point (Offset (right_xmid, top_points[i][Y_AXIS])
+ + hvpadding);
out.add_stencil (Lookup::round_filled_box (box, blotdiameter));
left_xmid = right_xmid;
}
Real right_xmid = bottom_points[size - 1][X_AXIS];
Box box;
- box.add_point (Offset (left_xmid, bottom_points[size - 1][Y_AXIS]) -
- hvpadding);
- box.add_point (Offset (right_xmid, top_points[size - 1][Y_AXIS]) +
- hvpadding);
+ box.add_point (Offset (left_xmid, bottom_points[size - 1][Y_AXIS])
+ - hvpadding);
+ box.add_point (Offset (right_xmid, top_points[size - 1][Y_AXIS])
+ + hvpadding);
out.add_stencil (Lookup::round_filled_box (box, blotdiameter));
}
else if (String::compare (shape, "ramp") == 0)
{
Grob *me = unsmob_grob (smob);
- Spanner *spanner = dynamic_cast<Spanner*> (me);
+ Spanner *spanner = dynamic_cast<Spanner *> (me);
if (!spanner)
{
me->programming_error ("Cluster::print (): not a spanner");
Item *right_bound = spanner->get_bound (RIGHT);
Grob *commonx = left_bound->common_refpoint (right_bound, X_AXIS);
- SCM cols = me->get_property ("columns");
+ SCM cols = me->get_property ("columns");
if (!scm_is_pair (cols))
{
me->warning ("junking empty cluster");
me->suicide ();
-
+
return SCM_EOL;
}
-
+
commonx = common_refpoint_of_list (cols, commonx, X_AXIS);
- Grob * commony = common_refpoint_of_list (cols, me, Y_AXIS);
+ Grob *commony = common_refpoint_of_list (cols, me, Y_AXIS);
Array<Offset> bottom_points;
Array<Offset> top_points;
-
Real left_coord = left_bound->relative_coordinate (commonx, X_AXIS);
/*
TODO: should we move the cluster a little to the right to be in
line with the center of the note heads?
-
- */
+
+ */
for (SCM s = cols; scm_is_pair (s); s = scm_cdr (s))
{
- Grob * col = unsmob_grob (scm_car (s));
+ Grob *col = unsmob_grob (scm_car (s));
Interval yext = col->extent (commony, Y_AXIS);
Real x = col->relative_coordinate (commonx, X_AXIS) - left_coord;
/*
Across a line break we anticipate on the next pitches.
- */
+ */
if (spanner->original_)
{
- Spanner *orig = dynamic_cast<Spanner*> (spanner->original_);
-
- if (spanner->get_break_index () < orig->broken_intos_.size ()-1)
+ Spanner *orig = dynamic_cast<Spanner *> (spanner->original_);
+
+ if (spanner->get_break_index () < orig->broken_intos_.size () - 1)
{
- Spanner * next = orig->broken_intos_[spanner->get_break_index () + 1];
+ Spanner *next = orig->broken_intos_[spanner->get_break_index () + 1];
SCM cols = next->get_property ("columns");
if (scm_is_pair (cols))
{
Grob *next_commony = common_refpoint_of_list (cols, next, Y_AXIS);
- Grob * col = unsmob_grob (scm_car (scm_last_pair (cols)));
+ Grob *col = unsmob_grob (scm_car (scm_last_pair (cols)));
Interval v = col->extent (next_commony, Y_AXIS);
Real x = right_bound->relative_coordinate (commonx, X_AXIS) - left_coord;
-
+
bottom_points.insert (Offset (x, v[DOWN]), 0);
top_points.insert (Offset (x, v[UP]), 0);
}
}
ADD_INTERFACE (Cluster, "cluster-interface",
- "A graphically drawn musical cluster. "
+ "A graphically drawn musical cluster. "
"\n\n"
"@code{padding} adds to the vertical extent of the shape (top and "
"bottom). \n\n"
"The property @code{style} controls the shape of cluster segments. Valid values "
"include @code{leftsided-stairs}, @code{rightsided-stairs}, @code{centered-stairs}, "
- "and @code{ramp}.\n"
-,
- "style padding columns");
-
-
+ "and @code{ramp}.\n",
+ "style padding columns");
struct Cluster_beacon
{
return ly_interval2scm (Staff_symbol_referencer::staff_space (me) * 0.5 * v);
}
-
-
-ADD_INTERFACE(Cluster_beacon,
- "cluster-beacon-interface",
- "A place holder for the cluster spanner to determine the vertical "
- "extents of a cluster spanner at this X position.",
- "positions");
+ADD_INTERFACE (Cluster_beacon,
+ "cluster-beacon-interface",
+ "A place holder for the cluster spanner to determine the vertical "
+ "extents of a cluster spanner at this X position.",
+ "positions");
/*
coherent-ligature-engraver.cc -- implement Coherent_ligature_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2003--2005 Juergen Reuter <reuter@ipd.uka.de>
- */
+*/
#include "coherent-ligature-engraver.hh"
* add it to the spacing spanner code.
*/
#if 0 // experimental code to collapse spacing after ligature
- SCM incr_scm = lc->get_property ("forced-spacing");
- if (incr_scm != SCM_EOL) /* (Paper_column::is_musical (l)) */
- {
- me->warning (_f ("gotcha: ptr=%ul", lc));//debug
- ly_display_scm (lc->self_scm ());
- Real distance;
- if (incr_scm != SCM_EOL)
- {
- distance = scm_to_double (incr_scm);
- }
- else
- {
- me->warning ("distance undefined, assuming 0.1");
- distance = 0.1;
- }
- me->warning (_f ("distance=%f", distance));//debug
- Real strength = 1.0;
- Spaceable_grob::add_spring (lc, rc, distance, strength);
- if (Item *rb = r->find_prebroken_piece (LEFT))
- Spaceable_grob::add_spring (lc, rb, distance, strength);
+SCM incr_scm = lc->get_property ("forced-spacing");
+if (incr_scm != SCM_EOL) /* (Paper_column::is_musical (l)) */
+ {
+ me->warning (_f ("gotcha: ptr=%ul", lc));//debug
+ ly_display_scm (lc->self_scm ());
+ Real distance;
+ if (incr_scm != SCM_EOL)
+ {
+ distance = scm_to_double (incr_scm);
+ }
+ else
+ {
+ me->warning ("distance undefined, assuming 0.1");
+ distance = 0.1;
+ }
+ me->warning (_f ("distance=%f", distance));//debug
+ Real strength = 1.0;
+ Spaceable_grob::add_spring (lc, rc, distance, strength);
+ if (Item *rb = r->find_prebroken_piece (LEFT))
+ Spaceable_grob::add_spring (lc, rb, distance, strength);
- continue;
- }
+ continue;
+ }
#endif
Coherent_ligature_engraver::Coherent_ligature_engraver ()
void
Coherent_ligature_engraver::get_set_column (Item *item, Paper_column *column)
{
- Item *parent = dynamic_cast<Item*> (item->get_parent (X_AXIS));
+ Item *parent = dynamic_cast<Item *> (item->get_parent (X_AXIS));
if (!parent)
{
programming_error ("failed tweaking paper column in ligature");
tail = scm_cdr (tail))
{
Item *sibling = unsmob_item (scm_car (tail));
- if ((sibling) &&
- (Staff_symbol_referencer::get_staff_symbol (sibling) == sl))
+ if ((sibling)
+ && (Staff_symbol_referencer::get_staff_symbol (sibling) == sl))
{
#if 0 // experimental code to collapse spacing after ligature
Grob *sibling_parent = sibling->get_parent (X_AXIS);
"setting `spacing-increment="
"0.01': ptr=%ul", parent));
sibling_parent->set_property ("forced-spacing",
- scm_make_real (0.01));
+ scm_make_real (0.01));
#endif
sibling->set_parent (column, X_AXIS);
}
int prev_pitch = 0;
int delta_pitch = 0;
Item *prev_primitive = 0, *primitive = 0;
- for (int i = 0; i < primitives.size (); i++) {
- primitive = dynamic_cast<Item*> (primitives[i].grob_);
- Music *music_cause = primitives[i].music_cause ();
- int pitch =
- unsmob_pitch (music_cause->get_property ("pitch"))->steps ();
- if (prev_primitive)
- {
- delta_pitch = pitch - prev_pitch;
- prev_primitive->set_property ("delta-pitch",
- scm_int2num (delta_pitch));
- }
- prev_pitch = pitch;
- prev_primitive = primitive;
- }
+ for (int i = 0; i < primitives.size (); i++)
+ {
+ primitive = dynamic_cast<Item *> (primitives[i].grob_);
+ Music *music_cause = primitives[i].music_cause ();
+ int pitch
+ = unsmob_pitch (music_cause->get_property ("pitch"))->steps ();
+ if (prev_primitive)
+ {
+ delta_pitch = pitch - prev_pitch;
+ prev_primitive->set_property ("delta-pitch",
+ scm_int2num (delta_pitch));
+ }
+ prev_pitch = pitch;
+ prev_primitive = primitive;
+ }
primitive->set_property ("delta-pitch", scm_int2num (0));
}
}
ADD_TRANSLATOR (Coherent_ligature_engraver,
-/* descr */ "This is an abstract class. Subclasses such as Gregorian_ligature_engraver handle ligatures by glueing special ligature heads together.",
-/* creats*/ "",
-/* accepts */ "ligature-event",
-/* acks */ "note-head-interface rest-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "This is an abstract class. Subclasses such as Gregorian_ligature_engraver handle ligatures by glueing special ligature heads together.",
+ /* creats*/ "",
+ /* accepts */ "ligature-event",
+ /* acks */ "note-head-interface rest-interface",
+ /* reads */ "",
+ /* write */ "");
class Collision_engraver : public Engraver
{
- Item * col_;
+ Item *col_;
Link_array<Grob> note_columns_;
protected:
TRANSLATOR_DECLARATIONS (Collision_engraver);
};
-
void
Collision_engraver::process_acknowledged_grobs ()
{
if (col_ || note_columns_.size () < 2)
- return ;
- if (!col_)
+ return;
+ if (!col_)
{
col_ = make_item ("NoteCollision", SCM_EOL);
-
+
}
-
+
for (int i = 0; i< note_columns_.size (); i++)
Note_collision_interface::add_column (col_, note_columns_[i]);
}
{
/*should check Y axis? */
if (Note_column::has_rests (i.grob_) || i.grob_->get_parent (X_AXIS))
- return ;
+ return;
note_columns_.push (i.grob_);
}
}
-
-
ADD_TRANSLATOR (Collision_engraver,
-/* descr */ "Collect NoteColumns, and as soon as there are two or more, put them in a NoteCollision object.",
-/* creats*/ "NoteCollision",
-/* accepts */ "",
-/* acks */ "note-column-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Collect NoteColumns, and as soon as there are two or more, put them in a NoteCollision object.",
+ /* creats*/ "NoteCollision",
+ /* accepts */ "",
+ /* acks */ "note-column-interface",
+ /* reads */ "",
+ /* write */ "");
#include "global-context.hh"
/*
-TODO: make matching rest engraver.
+ TODO: make matching rest engraver.
*/
/*
-
How does this work?
When we catch the note, we predict the end of the note. We keep the
figure out how long the note to typeset should be. It should be no
longer than what's specified, than what is left to do and it should
not cross barlines.
-
+
We copy the reqs into scratch note reqs, to make sure that we get
all durations exactly right.
*/
Link_array<Item> notes_;
Link_array<Item> prev_notes_;
Link_array<Grob> ties_;
-
+
Link_array<Item> dots_;
Link_array<Music> note_reqs_;
Link_array<Music> scratch_note_reqs_;
bool is_first_;
Rational left_to_do_;
Rational do_nothing_until_;
-
+
Moment next_barline_moment ();
Duration find_nearest_duration (Rational length);
-
+
public:
TRANSLATOR_DECLARATIONS (Completion_heads_engraver);
protected:
virtual void initialize ();
virtual void start_translation_timestep ();
- virtual bool try_music (Music *req) ;
+ virtual bool try_music (Music *req);
virtual void process_music ();
virtual void stop_translation_timestep ();
};
}
bool
-Completion_heads_engraver::try_music (Music *m)
+Completion_heads_engraver::try_music (Music *m)
{
if (m->is_mus_type ("note-event"))
{
if (now_mom ().grace_part_)
{
- musiclen.grace_part_ = musiclen.main_part_ ;
+ musiclen.grace_part_ = musiclen.main_part_;
musiclen.main_part_ = Rational (0, 1);
}
- note_end_mom_ = note_end_mom_ >? (now + musiclen);
+ note_end_mom_ = note_end_mom_ >? (now + musiclen);
do_nothing_until_ = Rational (0, 0);
-
+
return true;
}
- else if (m->is_mus_type ("busy-playing-event"))
+ else if (m->is_mus_type ("busy-playing-event"))
{
- return note_reqs_.size() && is_first_;
+ return note_reqs_.size () && is_first_;
}
-
+
return false;
-
+
}
/*
The duration _until_ the next barline.
- */
+*/
Moment
-Completion_heads_engraver::next_barline_moment ( )
+Completion_heads_engraver::next_barline_moment ()
{
Moment *e = unsmob_moment (get_property ("measurePosition"));
Moment *l = unsmob_moment (get_property ("measureLength"));
return (*l - *e);
}
-Duration
+Duration
Completion_heads_engraver::find_nearest_duration (Rational length)
{
int log_limit = 6;
// scale up.
d = d.compressed (length / d.get_length ());
}
-
+
return d;
}
Completion_heads_engraver::process_music ()
{
if (!is_first_ && !left_to_do_)
- return ;
-
+ return;
+
is_first_ = false;
- Moment now = now_mom ();
+ Moment now = now_mom ();
if (do_nothing_until_ > now.main_part_)
- return ;
-
+ return;
+
Duration note_dur;
Duration *orig = 0;
if (left_to_do_)
Moment next = now;
next.main_part_ += note_dur.get_length ();
-
+
get_global_context ()->add_moment_to_process (next);
do_nothing_until_ = next.main_part_;
}
if (!scratch_note_reqs_.size ())
for (int i = 0; i < note_reqs_.size (); i++)
{
- Music * m = note_reqs_[i]->clone ();
+ Music *m = note_reqs_[i]->clone ();
scratch_note_reqs_.push (m);
}
}
-
for (int i = 0;
left_to_do_ && i < note_reqs_.size (); i++)
{
- Music * req = note_reqs_[i];
+ Music *req = note_reqs_[i];
if (scratch_note_reqs_.size ())
{
req = scratch_note_reqs_[i];
SCM pits = note_reqs_[i]->get_property ("pitch");
req->set_property ("pitch", pits);
}
-
+
req->set_property ("duration", note_dur.smobbed_copy ());
- Item *note = make_item ("NoteHead", req->self_scm ());
+ Item *note = make_item ("NoteHead", req->self_scm ());
note->set_property ("duration-log",
scm_int2num (note_dur.duration_log ()));
-
+
int dots = note_dur.dot_count ();
if (dots)
{
- Item * d = make_item ("Dots", SCM_EOL);
+ Item *d = make_item ("Dots", SCM_EOL);
Rhythmic_head::set_dots (note, d);
/*
- measly attempt to save an eeny-weenie bit of memory.
+ measly attempt to save an eeny-weenie bit of memory.
*/
if (dots != scm_to_int (d->get_property ("dot-count")))
d->set_property ("dot-count", scm_int2num (dots));
if (scm_is_number (c0))
pos += scm_to_int (c0);
- note->set_property ("staff-position", scm_int2num (pos));
+ note->set_property ("staff-position", scm_int2num (pos));
notes_.push (note);
}
-
+
if (prev_notes_.size () == notes_.size ())
{
for (int i = 0; i < notes_.size (); i++)
{
- Grob * p = make_spanner ("Tie", SCM_EOL);
+ Grob *p = make_spanner ("Tie", SCM_EOL);
Tie::set_interface (p); // cannot remove yet!
-
+
Tie::set_head (p, LEFT, prev_notes_[i]);
Tie::set_head (p, RIGHT, notes_[i]);
-
+
ties_.push (p);
-
+
}
}
/*
don't do complicated arithmetic with grace notes.
- */
+ */
if (orig
- && now_mom ().grace_part_ )
+ && now_mom ().grace_part_)
{
left_to_do_ = Rational (0, 0);
}
}
-
+
void
Completion_heads_engraver::stop_translation_timestep ()
{
ties_.clear ();
-
+
if (notes_.size ())
prev_notes_ = notes_;
notes_.clear ();
-
+
dots_.clear ();
for (int i = scratch_note_reqs_.size (); i--;)
{
- scm_gc_unprotect_object (scratch_note_reqs_[i]->self_scm () );
+ scm_gc_unprotect_object (scratch_note_reqs_[i]->self_scm ());
}
-
+
scratch_note_reqs_.clear ();
}
}
ADD_TRANSLATOR (Completion_heads_engraver,
-/* descr */ "This engraver replaces "
-"@code{Note_heads_engraver}. It plays some trickery to "
-"break long notes and automatically tie them into the next measure.",
-/* creats*/ "NoteHead Dots Tie",
-/* accepts */ "busy-playing-event note-event",
-/* acks */ "",
-/* reads */ "middleCPosition measurePosition measureLength",
-/* write */ "");
+ /* descr */ "This engraver replaces "
+ "@code{Note_heads_engraver}. It plays some trickery to "
+ "break long notes and automatically tie them into the next measure.",
+ /* creats*/ "NoteHead Dots Tie",
+ /* accepts */ "busy-playing-event note-event",
+ /* acks */ "",
+ /* reads */ "middleCPosition measurePosition measureLength",
+ /* write */ "");
-/*
+/*
translator-def.cc -- implement Context_def
source file of the GNU LilyPond music typesetter
context_name_ = ly_symbol2scm ("");
}
-Context_def::Context_def (Context_def const & s)
+Context_def::Context_def (Context_def const &s)
: Input (s)
{
context_aliases_ = SCM_EOL;
translator_group_type_ = SCM_EOL;
- accept_mods_ = SCM_EOL;
+ accept_mods_ = SCM_EOL;
translator_mods_ = SCM_EOL;
property_ops_ = SCM_EOL;
context_name_ = SCM_EOL;
description_ = SCM_EOL;
-
+
smobify_self ();
description_ = s.description_;
int
Context_def::print_smob (SCM smob, SCM port, scm_print_state*)
{
- Context_def* me = (Context_def*) SCM_CELL_WORD_1 (smob);
+ Context_def *me = (Context_def *) SCM_CELL_WORD_1 (smob);
scm_puts ("#<Context_def ", port);
scm_display (me->context_name_, port);
SCM
Context_def::mark_smob (SCM smob)
{
- Context_def* me = (Context_def*) SCM_CELL_WORD_1 (smob);
+ Context_def *me = (Context_def *) SCM_CELL_WORD_1 (smob);
scm_gc_mark (me->description_);
scm_gc_mark (me->context_aliases_);
scm_gc_mark (me->accept_mods_);
scm_gc_mark (me->translator_mods_);
- scm_gc_mark (me->property_ops_);
+ scm_gc_mark (me->property_ops_);
scm_gc_mark (me->translator_group_type_);
return me->context_name_;
SCM sym = scm_cadr (mod);
if (scm_is_string (sym))
sym = scm_string_to_symbol (sym);
-
+
if (ly_symbol2scm ("consists") == tag
|| ly_symbol2scm ("consists-end") == tag
|| ly_symbol2scm ("remove") == tag)
}
else if (ly_symbol2scm ("accepts") == tag
|| ly_symbol2scm ("denies") == tag)
- accept_mods_ = scm_cons (scm_list_2 (tag, sym), accept_mods_);
+ accept_mods_ = scm_cons (scm_list_2 (tag, sym), accept_mods_);
else if (ly_symbol2scm ("poppush") == tag
|| ly_symbol2scm ("pop") == tag
|| ly_symbol2scm ("push") == tag
property_ops_ = scm_cons (mod, property_ops_);
else if (ly_symbol2scm ("alias") == tag)
context_aliases_ = scm_cons (sym, context_aliases_);
- else if (ly_symbol2scm ("translator-type") == tag)
+ else if (ly_symbol2scm ("translator-type") == tag)
translator_group_type_ = sym;
- else if (ly_symbol2scm ("context-name") == tag)
+ else if (ly_symbol2scm ("context-name") == tag)
context_name_ = sym;
else
programming_error ("Unknown context mod tag.");
Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef) const
{
assert (scm_is_symbol (type_sym));
-
+
SCM accepted = get_accepted (SCM_EOL);
Link_array<Context_def> accepteds;
int best_depth = INT_MAX;
for (int i = 0; i < accepteds.size (); i++)
{
- Context_def * g = accepteds[i];
+ Context_def *g = accepteds[i];
Link_array<Context_def> result
= g->path_to_acceptable_context (type_sym, odef);
SCM l1 = SCM_EOL;
SCM mods = scm_reverse_x (scm_list_copy (translator_mods_), user_mod);
-
+
for (SCM s = mods; scm_is_pair (s); s = scm_cdr (s))
{
SCM tag = scm_caar (s);
if (scm_is_string (arg))
arg = scm_string_to_symbol (arg);
-
+
if (ly_symbol2scm ("consists") == tag)
l1 = scm_cons (arg, l1);
else if (ly_symbol2scm ("remove") == tag)
{
for (SCM *tail = ℓ scm_is_pair (*tail); tail = SCM_CDRLOC (*tail))
{
- if (dynamic_cast<Performer*> (unsmob_translator (scm_car (*tail))))
+ if (dynamic_cast<Performer *> (unsmob_translator (scm_car (*tail))))
{
*tail = scm_cdr (*tail);
if (!scm_is_pair (*tail))
- break ;
+ break;
}
}
return ell;
SCM
filter_engravers (SCM ell)
{
- SCM *tail = ℓ
- for (; scm_is_pair (*tail) ; tail = SCM_CDRLOC (*tail))
+ SCM *tail = ℓ
+ for (; scm_is_pair (*tail); tail = SCM_CDRLOC (*tail))
{
- if (dynamic_cast<Engraver*> (unsmob_translator (scm_car (*tail))))
+ if (dynamic_cast<Engraver *> (unsmob_translator (scm_car (*tail))))
{
*tail = scm_cdr (*tail);
if (!scm_is_pair (*tail))
- break ;
+ break;
}
}
return ell;
}
-
Context *
Context_def::instantiate (SCM ops, Object_key const *key)
{
- Context *tg = 0;
+ Context *tg = 0;
if (context_name_ == ly_symbol2scm ("Score"))
tg = new Score_context (key);
tg->definition_ = self_scm ();
- SCM trans_names = get_translator_names (ops);
+ SCM trans_names = get_translator_names (ops);
- Translator_group *g = dynamic_cast<Translator_group*>
+ Translator_group *g = dynamic_cast<Translator_group *>
(get_translator (translator_group_type_));
- g = dynamic_cast<Translator_group*> (g->clone ());
+ g = dynamic_cast<Translator_group *> (g->clone ());
SCM trans_list = SCM_EOL;
-
- for (SCM s = trans_names; scm_is_pair (s) ; s = scm_cdr (s))
+
+ for (SCM s = trans_names; scm_is_pair (s); s = scm_cdr (s))
{
Translator *t = get_translator (scm_car (s));
if (!t)
scm_gc_unprotect_object (str);
}
}
-
- g->simple_trans_list_ = trans_list;
+
+ g->simple_trans_list_ = trans_list;
tg->implementation_ = g->self_scm ();
- if (dynamic_cast<Engraver*> (g))
+ if (dynamic_cast<Engraver *> (g))
g->simple_trans_list_ = filter_performers (g->simple_trans_list_);
- else if (dynamic_cast<Performer*> (g))
+ else if (dynamic_cast<Performer *> (g))
g->simple_trans_list_ = filter_engravers (g->simple_trans_list_);
-
+
g->daddy_context_ = tg;
- tg->aliases_ = context_aliases_ ;
-
+ tg->aliases_ = context_aliases_;
+
scm_gc_unprotect_object (g->self_scm ());
-
+
tg->accepts_list_ = get_accepted (ops);
return tg;
if (scm_is_symbol (translator_group_type_))
ell = scm_cons (scm_cons (ly_symbol2scm ("group-type"),
- translator_group_type_), ell);
- return ell;
+ translator_group_type_), ell);
+ return ell;
}
-/*
+/*
interpretation-context-handle.cc -- implement Interpretation_context_handle
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- */
+*/
#include "interpretation-context-handle.hh"
#include "context.hh"
outlet_ = 0;
}
-Interpretation_context_handle::Interpretation_context_handle (Interpretation_context_handle const&s)
+Interpretation_context_handle::Interpretation_context_handle (Interpretation_context_handle const &s)
{
outlet_ = 0;
if (s.outlet_)
up (s.outlet_);
}
-
Interpretation_context_handle::~Interpretation_context_handle ()
{
/*
Don't do
if (outlet_)
- down ();
+ down ();
with GC, this is asynchronous.
- */
+ */
}
void
Interpretation_context_handle::up (Context *t)
{
outlet_ = t;
- t->iterator_count_ ++;
+ t->iterator_count_++;
}
void
Interpretation_context_handle::down ()
{
- outlet_->iterator_count_ --;
+ outlet_->iterator_count_--;
outlet_ = 0;
}
{
if (outlet_)
{
- outlet_->iterator_count_ --;
+ outlet_->iterator_count_--;
outlet_ = 0;
}
}
}
void
-Interpretation_context_handle::operator = (Interpretation_context_handle const &s)
+Interpretation_context_handle::operator= (Interpretation_context_handle const &s)
{
set_context (s.outlet_);
}
Context *
Interpretation_context_handle::get_outlet () const
{
-
+
return outlet_;
}
int
Interpretation_context_handle::get_count () const
{
- return outlet_->iterator_count_ ;
+ return outlet_->iterator_count_;
}
/*
- context-property.cc -- implement manipulation of immutable Grob
- property lists.
+ context-property.cc -- implement manipulation of immutable Grob
+ property lists.
- source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
- (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include "context.hh"
represented as a (ALIST . BASED-ON) pair, where BASED-ON is the
alist defined in a parent context. BASED-ON should always be a tail
of ALIST.
-
- */
+*/
/*
Push or pop (depending on value of VAL) a single entry (ELTPROP . VAL)
entry from a translator property list by name of PROP
*/
-
void
-execute_pushpop_property (Context * trg,
+execute_pushpop_property (Context *trg,
SCM prop, SCM eltprop, SCM val)
{
if (scm_is_symbol (prop) && scm_is_symbol (eltprop))
if (val != SCM_UNDEFINED)
{
SCM prev = SCM_EOL;
- Context * where = trg->where_defined (prop);
+ Context *where = trg->where_defined (prop);
/*
Don't mess with MIDI.
- */
+ */
if (!where)
- return ;
-
+ return;
+
if (where != trg)
{
SCM base = updated_grob_properties (trg, prop);
- prev = scm_cons (base, base);
+ prev = scm_cons (base, base);
trg->internal_set_property (prop, prev);
}
else
prev = trg->internal_get_property (prop);
-
+
if (!scm_is_pair (prev))
{
programming_error ("Grob definition should be cons.");
- return ;
+ return;
}
SCM prev_alist = scm_car (prev);
-
+
if (scm_is_pair (prev_alist) || prev_alist == SCM_EOL)
{
bool ok = type_check_assignment (eltprop, val, ly_symbol2scm ("backend-type?"));
/*
- tack onto alist:
+ tack onto alist:
*/
if (ok)
scm_set_car_x (prev, scm_acons (eltprop, val, prev_alist));
SCM prev = trg->internal_get_property (prop);
SCM prev_alist = scm_car (prev);
SCM daddy = scm_cdr (prev);
-
+
SCM new_alist = SCM_EOL;
SCM *tail = &new_alist;
if (ly_c_equal_p (scm_caar (prev_alist), eltprop))
{
prev_alist = scm_cdr (prev_alist);
- break ;
+ break;
}
-
*tail = scm_cons (scm_car (prev_alist), SCM_EOL);
tail = SCM_CDRLOC (*tail);
prev_alist = scm_cdr (prev_alist);
/*
PRE_INIT_OPS is in the order specified, and hence must be reversed.
- */
+*/
void
apply_property_operations (Context *tg, SCM pre_init_ops)
{
{
SCM entry = scm_car (s);
SCM type = scm_car (entry);
- entry = scm_cdr (entry);
-
+ entry = scm_cdr (entry);
+
if (type == ly_symbol2scm ("push") || type == ly_symbol2scm ("poppush"))
{
SCM val = scm_cddr (entry);
/*
Return the object alist for SYM, checking if its base in enclosing
- contexts has changed. The alist is updated if necessary.
- */
+ contexts has changed. The alist is updated if necessary.
+*/
SCM
-updated_grob_properties (Context * tg, SCM sym)
+updated_grob_properties (Context *tg, SCM sym)
{
assert (scm_is_symbol (sym));
-
+
tg = tg->where_defined (sym);
if (!tg)
return SCM_EOL;
-
+
SCM daddy_props
= (tg->get_parent_context ())
? updated_grob_properties (tg->get_parent_context (), sym)
: SCM_EOL;
-
- SCM props = tg->internal_get_property (sym);
+
+ SCM props = tg->internal_get_property (sym);
if (!scm_is_pair (props))
{
SCM copy = daddy_props;
SCM *tail = ©
SCM p = scm_car (props);
- while (p != based_on)
+ while (p != based_on)
{
*tail = scm_cons (scm_car (p), daddy_props);
tail = SCM_CDRLOC (*tail);
p = scm_cdr (p);
}
-
+
scm_set_car_x (props, copy);
scm_set_cdr_x (props, daddy_props);
}
Item *
-make_item_from_properties (Engraver *tr, SCM x, SCM cause, const char * name)
+make_item_from_properties (Engraver *tr, SCM x, SCM cause, const char *name)
{
Context *context = tr->context ();
-
+
SCM props = updated_grob_properties (context, x);
- Object_key const*key = context->get_grob_key (name);
+ Object_key const *key = context->get_grob_key (name);
Item *it = new Item (props, key);
- dynamic_cast<Engraver*>(tr)->announce_grob (it, cause);
+ dynamic_cast<Engraver *> (tr)->announce_grob (it, cause);
return it;
}
-Spanner*
+Spanner *
make_spanner_from_properties (Engraver *tr, SCM x, SCM cause, const char *name)
{
Context *context = tr->context ();
SCM props = updated_grob_properties (context, x);
Spanner *it = new Spanner (props, context->get_grob_key (name));
- dynamic_cast<Engraver*>(tr)->announce_grob (it, cause);
+ dynamic_cast<Engraver *> (tr)->announce_grob (it, cause);
return it;
}
source file of the GNU LilyPond music typesetter
(c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "context.hh"
LY_DEFINE (ly_context_id, "ly:context-id",
1, 0, 0, (SCM context),
- "Return the id string of @var{context}, "
+ "Return the id string of @var{context}, "
"i.e. for @code{\\context Voice = one .. } "
"return the string @code{one}.")
{
{
Context *tr = unsmob_context (context);
SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context");
- return ly_symbol2scm (tr->context_name ().to_str0 ());
+ return ly_symbol2scm (tr->context_name ().to_str0 ());
}
LY_DEFINE (ly_context_grob_definition, "ly:context-grob-definition",
SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context");
SCM_ASSERT_TYPE (scm_is_symbol (name), name, SCM_ARG2, __FUNCTION__, "symbol");
-
return updated_grob_properties (tr, name);
}
-
LY_DEFINE (ly_context_pushpop_property, "ly:context-pushpop-property",
3, 1, 0, (SCM context, SCM grob, SCM eltprop, SCM val),
"Do a single @code{\\override} or @code{\\revert} operation "
LY_DEFINE (ly_context_property, "ly:context-property",
2, 0, 0, (SCM c, SCM name),
- "Return the value of @var{name} from context @var{c}")
+ "Return the value of @var{name} from context @var{c}")
{
Context *t = unsmob_context (c);
- Context * tr = (t);
+ Context *tr = (t);
SCM_ASSERT_TYPE (tr, c, SCM_ARG1, __FUNCTION__, "Translator group");
SCM_ASSERT_TYPE (scm_is_symbol (name), name, SCM_ARG2, __FUNCTION__, "symbol");
Context *tr = unsmob_context (context);
SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "Context");
- tr = tr->get_parent_context () ;
+ tr = tr->get_parent_context ();
if (tr)
return tr->self_scm ();
else
Context *tr = unsmob_context (context);
SCM_ASSERT_TYPE (tr, context, SCM_ARG1, __FUNCTION__, "context");
SCM_ASSERT_TYPE (scm_is_symbol (name), name, SCM_ARG2, __FUNCTION__, "symbol");
-
+
while (tr)
{
if (tr->is_alias (name))
return tr->self_scm ();
- tr = tr->get_parent_context () ;
+ tr = tr->get_parent_context ();
}
-
+
return SCM_BOOL_F;
}
-
-/*
+/*
context-specced-music-iterator.cc -- implement
- Context_specced_music_iterator
+ Context_specced_music_iterator
source file of the GNU LilyPond music typesetter
(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
*/
#include "music-wrapper-iterator.hh"
if (scm_is_string (ci))
c_id = ly_scm2string (ci);
SCM ops = get_music ()->get_property ("property-operations");
-
- Context * a = 0;
+
+ Context *a = 0;
if (c_id == "$uniqueContextId")
a = get_outlet ()->create_unique_context (ct, ops);
a = get_outlet ()->find_create_context (ct, c_id, ops);
if (a
- && to_boolean (get_music ()->get_property ("descend-only"))
+ && to_boolean (get_music ()->get_property ("descend-only"))
&& !is_child_context (get_outlet (), a))
a = 0;
-
+
if (a)
set_context (a);
-/*
+/*
context.cc -- implement Context
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "context.hh"
bool
Context::is_removable () const
{
- return context_list_ == SCM_EOL && ! iterator_count_ &&
- !dynamic_cast<Score_context const*> (this);
+ return context_list_ == SCM_EOL && ! iterator_count_
+ && !dynamic_cast < Score_context const *> (this);
}
void
}
}
-Context::Context (Context const&)
+Context::Context (Context const &)
{
assert (false);
}
SCM ts = t->self_scm ();
context_list_ = ly_append2 (context_list_,
scm_cons (ts, SCM_EOL));
-
+
t->daddy_context_ = this;
if (!t->init_)
{
}
}
-Object_key const*
+Object_key const *
Context::get_key () const
{
return key_;
}
-Context::Context (Object_key const* key)
+Context::Context (Object_key const *key)
{
key_ = key;
daddy_context_ = 0;
init_ = false;
aliases_ = SCM_EOL;
- iterator_count_ = 0;
+ iterator_count_ = 0;
implementation_ = SCM_EOL;
properties_scm_ = SCM_EOL;
accepts_list_ = SCM_EOL;
context_list_ = SCM_EOL;
definition_ = SCM_EOL;
-
+
smobify_self ();
properties_scm_ = (new Scheme_hash_table)->self_scm ();
scm_gc_unprotect_object (properties_scm_);
/*
TODO: this shares code with find_create_context().
- */
-Context*
+*/
+Context *
Context::create_unique_context (SCM n, SCM operations)
{
/*
Don't create multiple score contexts.
- */
- if (dynamic_cast<Global_context*> (this)
- && dynamic_cast<Global_context*> (this)->get_score_context ())
+ */
+ if (dynamic_cast<Global_context *> (this)
+ && dynamic_cast<Global_context *> (this)->get_score_context ())
return get_score_context ()->create_unique_context (n, operations);
/*
TODO: use accepts_list_.
- */
+ */
Link_array<Context_def> path
= unsmob_context_def (definition_)->path_to_acceptable_context (n, get_output_def ());
if (path.size ())
{
- Context * current = this;
+ Context *current = this;
// start at 1. The first one (index 0) will be us.
for (int i = 0; i < path.size (); i++)
current = current->create_context (path[i],
"\\new",
- ops);
+ ops);
}
return current;
/*
Don't go up to Global_context, because global goes down to
Score_context
- */
+ */
Context *ret = 0;
- if (daddy_context_ && !dynamic_cast<Global_context*> (daddy_context_))
+ if (daddy_context_ && !dynamic_cast<Global_context *> (daddy_context_))
ret = daddy_context_->create_unique_context (n, operations);
else
{
return ret;
}
-
Context *
Context::find_create_context (SCM n, String id, SCM operations)
{
/*
Don't create multiple score contexts.
- */
- if (dynamic_cast<Global_context*> (this)
- && dynamic_cast<Global_context*> (this)->get_score_context ())
+ */
+ if (dynamic_cast<Global_context *> (this)
+ && dynamic_cast<Global_context *> (this)->get_score_context ())
return get_score_context ()->find_create_context (n, id, operations);
if (Context *existing = find_context_below (this, n, id))
if (n == ly_symbol2scm ("Bottom"))
{
- Context* tg = get_default_interpreter ();
+ Context *tg = get_default_interpreter ();
return tg;
}
/*
TODO: use accepts_list_.
- */
+ */
Link_array<Context_def> path
= unsmob_context_def (definition_)->path_to_acceptable_context (n, get_output_def ());
if (path.size ())
{
- Context * current = this;
+ Context *current = this;
// start at 1. The first one (index 0) will be us.
for (int i = 0; i < path.size (); i++)
this_id = id;
}
-
current = current->create_context (path[i],
this_id,
- ops);
+ ops);
}
return current;
/*
Don't go up to Global_context, because global goes down to
Score_context
- */
+ */
Context *ret = 0;
- if (daddy_context_ && !dynamic_cast<Global_context*> (daddy_context_))
+ if (daddy_context_ && !dynamic_cast<Global_context *> (daddy_context_))
ret = daddy_context_->find_create_context (n, id, operations);
else
{
return ret;
}
-
-Context*
-Context::create_context (Context_def * cdef,
+Context *
+Context::create_context (Context_def *cdef,
String id,
SCM ops)
{
- String type = ly_symbol2string (cdef->get_context_name());
+ String type = ly_symbol2string (cdef->get_context_name ());
Object_key const *key = get_context_key (type, id);
- Context * new_group
+ Context *new_group
= cdef->instantiate (ops, key);
-
+
new_group->id_string_ = id;
add_context (new_group);
apply_property_operations (new_group, ops);
return new_group;
}
-
-
-Object_key const*
+Object_key const *
Context::get_context_key (String type, String id)
{
String now_key = type + "@" + id;
}
context_counts_[now_key] = disambiguation_count + 1;
-
-
+
return new Lilypond_context_key (get_key (),
- now_mom(),
+ now_mom (),
type, id,
disambiguation_count);
}
-Object_key const*
-Context::get_grob_key (String name)
+Object_key const *
+Context::get_grob_key (String name)
{
int disambiguation_count = 0;
if (grob_counts_.find (name) != grob_counts_.end ())
}
grob_counts_[name] = disambiguation_count + 1;
- Object_key * k = new Lilypond_grob_key (get_key(),
- now_mom(),
- name,
- disambiguation_count);
+ Object_key *k = new Lilypond_grob_key (get_key (),
+ now_mom (),
+ name,
+ disambiguation_count);
- return k;
+ return k;
}
-
-
/*
Default child context as a SCM string, or something else if there is
none.
: SCM_EOL;
}
-
bool
Context::is_bottom_context () const
{
return !scm_is_symbol (default_child_context_name ());
}
-Context*
+Context *
Context::get_default_interpreter ()
{
if (!is_bottom_context ())
/*
PROPERTIES
- */
-Context*
+*/
+Context *
Context::where_defined (SCM sym) const
{
if (properties_dict ()->contains (sym))
{
- return (Context*)this;
+ return (Context *)this;
}
return (daddy_context_) ? daddy_context_->where_defined (sym) : 0;
if (daddy_context_)
return daddy_context_->internal_get_property (sym);
-
+
return val;
}
return true;
if (sym == unsmob_context_def (definition_)->get_context_name ())
return true;
-
+
return scm_c_memq (sym, aliases_) != SCM_BOOL_F;
}
aliases_ = scm_cons (sym, aliases_);
}
-
-
void
Context::internal_set_property (SCM sym, SCM val)
{
if (do_internal_type_checking_global)
assert (type_check_assignment (sym, val, ly_symbol2scm ("translation-type?")));
#endif
-
+
properties_dict ()->set (sym, val);
}
/*
- TODO: look up to check whether we have inherited var?
- */
+ TODO: look up to check whether we have inherited var?
+*/
void
Context::unset_property (SCM sym)
{
/**
Remove a context from the hierarchy.
- */
+*/
Context *
-Context::remove_context (Context*trans)
+Context::remove_context (Context *trans)
{
assert (trans);
/*
ID == "" means accept any ID.
- */
+*/
Context *
-find_context_below (Context * where,
+find_context_below (Context *where,
SCM type, String id)
{
if (where->is_alias (type))
if (id == "" || where->id_string () == id)
return where;
}
-
+
Context *found = 0;
for (SCM s = where->children_contexts ();
!found && scm_is_pair (s); s = scm_cdr (s))
found = find_context_below (tr, type, id);
}
- return found;
+ return found;
}
SCM
return ly_symbol2string (context_name_symbol ());
}
-Score_context*
+Score_context *
Context::get_score_context () const
{
- if (Score_context *sc = dynamic_cast<Score_context*> ((Context*) this))
+ if (Score_context *sc = dynamic_cast<Score_context *> ((Context *) this))
return sc;
else if (daddy_context_)
return daddy_context_->get_score_context ();
Context::~Context ()
{
-
+
}
Moment
Context::print_smob (SCM s, SCM port, scm_print_state *)
{
Context *sc = (Context *) SCM_CELL_WORD_1 (s);
-
+
scm_puts ("#<", port);
scm_puts (classname (sc), port);
if (Context_def *d = unsmob_context_def (sc->definition_))
scm_puts ("=", port);
scm_puts (td->id_string_.to_str0 (), port);
}
-
scm_puts (" ", port);
scm_display (sc->context_list_, port);
scm_puts (" >", port);
-
+
return 1;
}
SCM
Context::mark_smob (SCM sm)
{
- Context *me = (Context*) SCM_CELL_WORD_1 (sm);
- scm_gc_mark (me->key_->self_scm ());
+ Context *me = (Context *) SCM_CELL_WORD_1 (sm);
+ scm_gc_mark (me->key_->self_scm ());
scm_gc_mark (me->context_list_);
scm_gc_mark (me->aliases_);
- scm_gc_mark (me->definition_);
- scm_gc_mark (me->properties_scm_);
+ scm_gc_mark (me->definition_);
+ scm_gc_mark (me->properties_scm_);
scm_gc_mark (me->accepts_list_);
scm_gc_mark (me->implementation_);
IMPLEMENT_TYPE_P (Context, "ly:context?");
bool
-Context::try_music (Music* m)
+Context::try_music (Music *m)
{
- Translator* t = implementation ();
+ Translator *t = implementation ();
if (!t)
return false;
-
+
bool b = t->try_music (m);
if (!b && daddy_context_)
b = daddy_context_->try_music (m);
return b;
}
-
-Global_context*
+Global_context *
Context::get_global_context () const
{
- if (dynamic_cast<Global_context *>((Context*) this))
- return dynamic_cast<Global_context *> ((Context*) this);
+ if (dynamic_cast<Global_context *> ((Context *) this))
+ return dynamic_cast<Global_context *> ((Context *) this);
if (daddy_context_)
return daddy_context_->get_global_context ();
return 0;
}
-Context*
+Context *
Context::get_parent_context () const
{
return daddy_context_;
}
-Translator_group*
+Translator_group *
Context::implementation () const
{
- return dynamic_cast<Translator_group*> (unsmob_translator (implementation_));
+ return dynamic_cast<Translator_group *> (unsmob_translator (implementation_));
}
void
Context::clear_key_disambiguations ()
{
- grob_counts_.clear();
- context_counts_.clear();
+ grob_counts_.clear ();
+ context_counts_.clear ();
for (SCM s = context_list_; scm_is_pair (s); s = scm_cdr (s))
{
- unsmob_context (scm_car (s))->clear_key_disambiguations();
+ unsmob_context (scm_car (s))->clear_key_disambiguations ();
}
}
source file of the GNU LilyPond music typesetter
(c) 2000--2005 Juergen Reuter <reuter@ipd.uka.de>,
- Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "engraver.hh"
virtual void stop_translation_timestep ();
virtual void finalize ();
-
private:
- Item * create_custos ();
+ Item *create_custos ();
bool custos_permitted;
Link_array<Grob> custodes_;
Array<Pitch> pitches_;
custos_permitted = false;
}
-
void
Custos_engraver::stop_translation_timestep ()
{
/*
delay typeset until we're at the next moment, so we can silence custodes at the end of the piece.
- */
+ */
pitches_.clear ();
custos_permitted = false;
custodes_.clear ();
}
-
void
Custos_engraver::acknowledge_grob (Grob_info info)
{
- Item *item = dynamic_cast <Item *> (info.grob_);
+ Item *item = dynamic_cast<Item *> (info.grob_);
if (item)
{
- Music * m = info.music_cause ();
+ Music *m = info.music_cause ();
if (Bar_line::has_interface (info.grob_))
custos_permitted = true;
else if (Note_head::has_interface (info.grob_)
don't look at the staff-position, since we can't be sure
whether Clef_engraver already applied a vertical shift.
*/
- pitches_.push (*unsmob_pitch (m->get_property ("pitch")));
+ pitches_.push (*unsmob_pitch (m->get_property ("pitch")));
}
}
}
{
if (scm_is_string (get_property ("whichBar")))
custos_permitted = true;
-
+
if (custos_permitted)
{
for (int i = pitches_.size (); i--;)
if (scm_is_number (c0))
p += scm_to_int (c0);
-
c->set_property ("staff-position",
- scm_int2num (p));
-
+ scm_int2num (p));
+
}
pitches_.clear ();
}
}
-Item*
+Item *
Custos_engraver::create_custos ()
{
- Item* custos = make_item ("Custos", SCM_EOL);
-
-
+ Item *custos = make_item ("Custos", SCM_EOL);
+
custodes_.push (custos);
-
+
return custos;
}
custodes_.clear ();
}
-
-
ADD_TRANSLATOR (Custos_engraver,
-/* descr */ "",
-/* creats*/ "Custos",
-/* accepts */ "",
-/* acks */ "bar-line-interface note-head-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "",
+ /* creats*/ "Custos",
+ /* accepts */ "",
+ /* acks */ "bar-line-interface note-head-interface",
+ /* reads */ "",
+ /* write */ "");
/* TODO:
- - do not show if a clef change immediately follows in the next line
-
- - decide: do or do not print custos if the next line starts with a rest
+- do not show if a clef change immediately follows in the next line
+- decide: do or do not print custos if the next line starts with a rest
*/
#include <cstdio>
* staffline or not, or shall we use individual font characters
* for both cases?
*/
- bool adjust = true;
+ bool adjust = true;
int neutral_pos = robust_scm2int (me->get_property ("neutral-position"), 0);
- Direction neutral_direction =
- to_dir (me->get_property ("neutral-direction"));
+ Direction neutral_direction
+ = to_dir (me->get_property ("neutral-direction"));
int pos = Staff_symbol_referencer::get_rounded_position (me);
- int sz = Staff_symbol_referencer::line_count (me)-1;
+ int sz = Staff_symbol_referencer::line_count (me) - 1;
String font_char = "custodes." + style + ".";
if (pos < neutral_pos)
}
ADD_INTERFACE (Custos, "custos-interface",
- "A custos object.",
- "style neutral-position neutral-direction");
+ "A custos object.",
+ "style neutral-position neutral-direction");
-/*
+/*
dimension-cache.cc -- implement Dimension_cache
-
+
source file of the GNU LilyPond music typesetter
-
- (c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- */
+ (c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#include <math.h>
offset_ = d.offset_;
offset_callbacks_ = d.offset_callbacks_;
offsets_left_ = d.offsets_left_;
- parent_ = d.parent_;
+ parent_ = d.parent_;
}
Dimension_cache::Dimension_cache ()
Dimension_cache::init ()
{
dimension_ = SCM_EOL;
- dimension_callback_ = SCM_EOL;
+ dimension_callback_ = SCM_EOL;
offsets_left_ = 0;
offset_callbacks_ = SCM_EOL;
offset_ = 0.0;
-
+
parent_ = 0;
}
-
-
-
-
source file of the GNU LilyPond music typesetter
(c) 1997--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "lily-guile.hh"
#include "warn.hh"
LY_DEFINE (ly_pt, "ly:pt",
- 1, 0, 0, (SCM num),
- "@var{num} printer points")
+ 1, 0, 0, (SCM num),
+ "@var{num} printer points")
{
- SCM_ASSERT_TYPE(scm_is_number (num), num, SCM_ARG1, __FUNCTION__,
- "number");
+ SCM_ASSERT_TYPE (scm_is_number (num), num, SCM_ARG1, __FUNCTION__,
+ "number");
return scm_from_double (point_constant
* scm_to_double (num));
}
LY_DEFINE (ly_cm, "ly:cm",
- 1, 0, 0, (SCM num),
- "@var{num} cm")
+ 1, 0, 0, (SCM num),
+ "@var{num} cm")
{
- SCM_ASSERT_TYPE(scm_is_number (num), num, SCM_ARG1, __FUNCTION__,
- "number");
+ SCM_ASSERT_TYPE (scm_is_number (num), num, SCM_ARG1, __FUNCTION__,
+ "number");
return scm_from_double (cm_constant
* scm_to_double (num));
}
LY_DEFINE (ly_inch, "ly:inch",
- 1, 0, 0, (SCM num),
- "@var{num} inches")
+ 1, 0, 0, (SCM num),
+ "@var{num} inches")
{
- SCM_ASSERT_TYPE(scm_is_number (num), num, SCM_ARG1, __FUNCTION__,
- "number");
+ SCM_ASSERT_TYPE (scm_is_number (num), num, SCM_ARG1, __FUNCTION__,
+ "number");
return scm_from_double (inch_constant
* scm_to_double (num));
}
LY_DEFINE (ly_mm, "ly:mm",
- 1, 0, 0, (SCM num),
- "@var{num} mm")
+ 1, 0, 0, (SCM num),
+ "@var{num} mm")
{
- SCM_ASSERT_TYPE(scm_is_number (num), num, SCM_ARG1, __FUNCTION__,
- "number");
+ SCM_ASSERT_TYPE (scm_is_number (num), num, SCM_ARG1, __FUNCTION__,
+ "number");
return scm_from_double (mm_constant
* scm_to_double (num));
}
LY_DEFINE (ly_bp, "ly:bp",
- 1, 0, 0, (SCM num),
- "@var{num} bigpoints (1/72th inch)")
+ 1, 0, 0, (SCM num),
+ "@var{num} bigpoints (1/72th inch)")
{
- SCM_ASSERT_TYPE(scm_is_number (num), num, SCM_ARG1, __FUNCTION__,
- "number");
+ SCM_ASSERT_TYPE (scm_is_number (num), num, SCM_ARG1, __FUNCTION__,
+ "number");
return scm_from_double (bigpoint_constant
* scm_to_double (num));
}
-/*
+/*
directional-element-interface.cc -- implement Directional_element
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "directional-element-interface.hh"
Direction
-get_grob_direction (Grob*me)
+get_grob_direction (Grob *me)
{
SCM d = me->get_property ("direction");
if (!is_direction (d))
return CENTER;
-
+
return to_dir (d);
}
void
-set_grob_direction (Grob*me, Direction d)
+set_grob_direction (Grob *me, Direction d)
{
SCM sd = scm_int2num (d);
me->set_property ("direction", sd);
-/*
+/*
dot-column-engraver.cc -- implement Dot_column_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "rhythmic-head.hh"
#include "dot-column.hh"
class Dot_column_engraver : public Engraver
{
- Grob *dotcol_ ;
- Grob * stem_;
+ Grob *dotcol_;
+ Grob *stem_;
Link_array<Item> heads_;
public:
- TRANSLATOR_DECLARATIONS (Dot_column_engraver );
-
+ TRANSLATOR_DECLARATIONS (Dot_column_engraver);
+
protected:
virtual void acknowledge_grob (Grob_info);
- virtual void stop_translation_timestep ();
+ virtual void stop_translation_timestep ();
};
-
Dot_column_engraver::Dot_column_engraver ()
{
dotcol_ = 0;
*/
if (stem_ && dotcol_)
dotcol_->set_property ("stem", stem_->self_scm ());
-
+
dotcol_ = 0;
heads_.clear ();
stem_ = 0;
if (!dotcol_)
{
dotcol_ = make_item ("DotColumn", SCM_EOL);
-
+
}
Dot_column::add_head (dotcol_, info.grob_);
}
-
-
ADD_TRANSLATOR (Dot_column_engraver,
-/* descr */ "Engraves dots on dotted notes shifted to the right of the note.\n"
-"If omitted, then dots appear on top of the notes.",
-/* creats*/ "DotColumn",
-/* accepts */ "",
-/* acks */ "rhythmic-head-interface dot-column-interface stem-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Engraves dots on dotted notes shifted to the right of the note.\n"
+ "If omitted, then dots appear on top of the notes.",
+ /* creats*/ "DotColumn",
+ /* accepts */ "",
+ /* acks */ "rhythmic-head-interface dot-column-interface stem-interface",
+ /* reads */ "",
+ /* write */ "");
/*
TODO: let Dot_column communicate with stem via Note_column.
- */
+*/
MAKE_SCHEME_CALLBACK (Dot_column, force_shift_callback, 2);
SCM
if (!to_boolean (me->get_property ("positioning-done")))
{
me->set_property ("positioning-done", SCM_BOOL_T);
-
+
do_shifts (me);
}
return scm_make_real (0.0);
Axis a = (Axis) scm_to_int (axis);
assert (a == X_AXIS);
- Grob * stem = unsmob_grob (me->get_property ("stem"));
+ Grob *stem = unsmob_grob (me->get_property ("stem"));
if (stem
&& !Stem::get_beam (stem)
&& Stem::duration_log (stem) > 2
- && !Stem::is_invisible (stem)
- )
+ && !Stem::is_invisible (stem))
{
/*
trigger stem end & direction calculation.
This will add the stem to the support if a flag collision happens.
- */
- Stem::stem_end_position (stem);
+ */
+ Stem::stem_end_position (stem);
}
return Side_position_interface::aligned_side (element_smob, axis);
}
-
-
struct Dot_position
{
int pos_;
Grob *dot_;
bool extremal_head_;
-
Dot_position ()
{
dot_ = 0;
}
};
-
-typedef std::map<int, Dot_position> Dot_configuration;
+typedef std::map < int, Dot_position> Dot_configuration;
/*
Value CFG according.
-
*/
int
-dot_config_badness (Dot_configuration const &cfg)
+dot_config_badness (Dot_configuration const &cfg)
{
int t = 0;
for (Dot_configuration::const_iterator i (cfg.begin ());
if (i->second.extremal_head_)
{
if (i->second.dir_
- && dot_move_dir != i->second.dir_)
+ && dot_move_dir != i->second.dir_)
demerit += 3;
else if (dot_move_dir != UP)
demerit += 2;
}
else if (dot_move_dir != UP)
demerit += 1;
-
+
t += demerit;
}
- return t;
+ return t;
}
void
printf ("dotconf { ");
for (Dot_configuration::const_iterator i (cfg.begin ());
i != cfg.end (); i++)
- printf ("%d, " , i->first);
+ printf ("%d, ", i->first);
printf ("} \n");
}
Shift K and following (preceding) entries up (down) as necessary to
prevent staffline collisions if D is up (down).
- If K is in CFG, then do nothing.
+ If K is in CFG, then do nothing.
*/
Dot_configuration
{
Dot_configuration new_cfg;
int offset = 0;
-
+
if (d > 0)
{
for (Dot_configuration::const_iterator i (cfg.begin ());
if (p == k)
{
if (Staff_symbol_referencer::on_staffline (i->second.dot_, p))
- p += d ;
+ p += d;
else
p += 2* d;
offset = 2*d;
- new_cfg[p] = i->second;
+ new_cfg[p] = i->second;
}
else
{
Dot_configuration::const_iterator i (cfg.end ());
do
{
- i --;
+ i--;
int p = i->first;
if (p == k)
{
if (Staff_symbol_referencer::on_staffline (i->second.dot_, p))
- p += d ;
+ p += d;
else
p += 2* d;
offset = 2*d;
- new_cfg[p] = i->second;
+ new_cfg[p] = i->second;
}
else
{
}
while (i != cfg.begin ());
}
-
+
return new_cfg;
}
/*
Remove the collision in CFG either by shifting up or down, whichever
is best.
- */
+*/
void
remove_collision (Dot_configuration &cfg, int p)
{
{
Dot_configuration cfg_up = shift_one (cfg, p, UP);
Dot_configuration cfg_down = shift_one (cfg, p, DOWN);
-
- int b_up = dot_config_badness (cfg_up);
+
+ int b_up = dot_config_badness (cfg_up);
int b_down = dot_config_badness (cfg_down);
- cfg = (b_up < b_down) ? cfg_up : cfg_down;
+ cfg = (b_up < b_down) ? cfg_up : cfg_down;
}
}
SCM
-Dot_column::do_shifts (Grob*me)
+Dot_column::do_shifts (Grob *me)
{
- Link_array<Grob> dots =
- extract_grob_array (me, ly_symbol2scm ("dots"));
+ Link_array<Grob> dots
+ = extract_grob_array (me, ly_symbol2scm ("dots"));
{ /*
Trigger note collision resolution first, since that may kill off
dots when merging.
- */
- Grob * c = 0;
- for (int i = dots.size (); i-- ; )
+ */
+ Grob *c = 0;
+ for (int i = dots.size (); i--;)
{
- Grob * n = dots[i]->get_parent (Y_AXIS);
+ Grob *n = dots[i]->get_parent (Y_AXIS);
if (c)
c = n->common_refpoint (c, X_AXIS);
else
c = n;
}
- for (int i = dots.size (); i-- ; )
+ for (int i = dots.size (); i--;)
{
- Grob * n = dots[i]->get_parent (Y_AXIS);
- n->relative_coordinate (c , X_AXIS);
+ Grob *n = dots[i]->get_parent (Y_AXIS);
+ n->relative_coordinate (c, X_AXIS);
}
}
-
+
dots.sort (compare_position);
for (int i = dots.size (); i--;)
if (!dots[i]->is_live ())
dots.del (i);
-
+
Dot_configuration cfg;
for (int i = 0;i < dots.size (); i++)
{
Dot_position dp;
dp.dot_ = dots[i];
- Grob * note = dots[i]->get_parent (Y_AXIS);
+ Grob *note = dots[i]->get_parent (Y_AXIS);
if (note)
{
Grob *stem = unsmob_grob (note->get_property ("stem"));
if (stem)
dp.extremal_head_ = Stem::first_head (stem) == note;
}
-
+
int p = Staff_symbol_referencer::get_rounded_position (dp.dot_);
dp.pos_ = p;
if (dp.extremal_head_)
- dp.dir_ = to_dir (dp.dot_->get_property ("direction"));
+ dp.dir_ = to_dir (dp.dot_->get_property ("direction"));
remove_collision (cfg, p);
cfg[p] = dp;
for (Dot_configuration::const_iterator i (cfg.begin ());
i != cfg.end (); i++)
{
- Staff_symbol_referencer::set_position (i->second.dot_, i->first);
+ Staff_symbol_referencer::set_position (i->second.dot_, i->first);
}
return SCM_UNSPECIFIED;
}
void
-Dot_column::add_head (Grob * me, Grob *rh)
+Dot_column::add_head (Grob *me, Grob *rh)
{
- Grob * d = unsmob_grob (rh->get_property ("dot"));
+ Grob *d = unsmob_grob (rh->get_property ("dot"));
if (d)
{
Side_position_interface::add_support (me, rh);
Pointer_group_interface::add_grob (me, ly_symbol2scm ("dots"), d);
- d->add_offset_callback (Dot_column::force_shift_callback_proc , Y_AXIS);
+ d->add_offset_callback (Dot_column::force_shift_callback_proc, Y_AXIS);
Axis_group_interface::add_element (me, d);
}
}
-
-
ADD_INTERFACE (Dot_column, "dot-column-interface",
"Groups dot objects so they form a column, and position dots so they do not "
- "clash with staff lines "
- ,
+ "clash with staff lines ",
"positioning-done direction stem");
#include "directional-element-interface.hh"
MAKE_SCHEME_CALLBACK (Dots, print, 1);
-SCM
+SCM
Dots::print (SCM d)
{
Grob *sc = unsmob_grob (d);
Stencil mol;
-
+
SCM c = sc->get_property ("dot-count");
if (scm_is_number (c))
{
Stencil d = Font_interface::get_default_font (sc)->find_by_name (String ("dots.dot"));
Real dw = d.extent (X_AXIS).length ();
-
/*
we need to add a real blank box, to assure that
/*
TODO: this should be handled by side-position padding.
- */
+ */
mol = Lookup::blank (Box (Interval (0, 0),
Interval (0, 0)));
-
+
for (int i = scm_to_int (c); i--;)
{
d.translate_axis (2*dw, X_AXIS);
}
-
-
ADD_INTERFACE (Dots, "dots-interface",
"The dots to go with a notehead or rest."
"@code{direction} sets the preferred direction to move in case of staff "
"line collisions.",
"direction dot-count");
-
/*
drum-note-engraver.cc
-
+
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
TRANSLATOR_DECLARATIONS (Drum_notes_engraver);
protected:
- virtual bool try_music (Music *ev) ;
+ virtual bool try_music (Music *ev);
virtual void process_music ();
- virtual void acknowledge_grob (Grob_info);
+ virtual void acknowledge_grob (Grob_info);
virtual void stop_translation_timestep ();
};
}
bool
-Drum_notes_engraver::try_music (Music *m)
+Drum_notes_engraver::try_music (Music *m)
{
if (m->is_mus_type ("note-event"))
{
}
else if (m->is_mus_type ("busy-playing-event"))
return events_.size ();
-
+
return false;
}
-
void
Drum_notes_engraver::process_music ()
{
{
if (!tab)
tab = get_property ("drumStyleTable");
-
- Music * ev = events_[i];
+
+ Music *ev = events_[i];
Item *note = make_item ("NoteHead", ev->self_scm ());
-
+
Duration dur = *unsmob_duration (ev->get_property ("duration"));
note->set_property ("duration-log", scm_int2num (dur.duration_log ()));
if (dur.dot_count ())
{
- Item * d = make_item ("Dots", ev->self_scm ());
+ Item *d = make_item ("Dots", ev->self_scm ());
Rhythmic_head::set_dots (note, d);
-
+
if (dur.dot_count ()
!= robust_scm2int (d->get_property ("dot-count"), 0))
d->set_property ("dot-count", scm_int2num (dur.dot_count ()));
d->set_parent (note, Y_AXIS);
-
+
dots_.push (d);
}
- SCM drum_type = ev->get_property ("drum-type");
+ SCM drum_type = ev->get_property ("drum-type");
SCM defn = SCM_EOL;
if (scm_hash_table_p (tab) == SCM_BOOL_T)
defn = scm_hashq_ref (tab, drum_type, SCM_EOL);
-
+
if (scm_is_pair (defn))
{
SCM pos = scm_caddr (defn);
SCM style = scm_car (defn);
SCM script = scm_cadr (defn);
-
+
if (scm_integer_p (pos) == SCM_BOOL_T)
note->set_property ("staff-position", pos);
if (scm_is_symbol (style))
if (scm_is_string (script))
{
- Item *p = make_item ("Script", ev->self_scm ());
+ Item *p = make_item ("Script", ev->self_scm ());
bool follow;
make_script_from_event (p, &follow,
context (), script,
if (p->get_property ("follow-into-staff"))
p->set_property ("staff-padding", SCM_EOL);
-
p->set_parent (note, Y_AXIS);
- Side_position_interface::add_support (p, note);
+ Side_position_interface::add_support (p, note);
scripts_.push (p);
}
}
{
for (int i = 0; i < scripts_.size (); i++)
{
- Grob*e = scripts_[i];
+ Grob *e = scripts_[i];
if (to_dir (e->get_property ("side-relative-direction")))
e->set_property ("direction-source", inf.grob_->self_scm ());
/*
- add dep ?
- */
+ add dep ?
+ */
e->add_dependency (inf.grob_);
Side_position_interface::add_support (e, inf.grob_);
}
}
- else if (Note_column::has_interface (inf.grob_))
+ else if (Note_column::has_interface (inf.grob_))
{
for (int i = 0; i < scripts_.size (); i++)
{
Grob *e = scripts_[i];
-
- if (!e->get_parent (X_AXIS) &&
- Side_position_interface::get_axis (e) == Y_AXIS)
+
+ if (!e->get_parent (X_AXIS)
+ && Side_position_interface::get_axis (e) == Y_AXIS)
{
e->set_parent (inf.grob_, X_AXIS);
}
}
-
void
Drum_notes_engraver::stop_translation_timestep ()
{
notes_.clear ();
dots_.clear ();
scripts_.clear ();
-
+
events_.clear ();
}
-
-
ADD_TRANSLATOR (Drum_notes_engraver,
-/* descr */ "Generate noteheads.",
-/* creats*/ "NoteHead Dots Script",
-/* accepts */ "note-event busy-playing-event",
-/* acks */ "stem-interface note-column-interface",
-/* reads */ "drumStyleTable",
-/* write */ "");
+ /* descr */ "Generate noteheads.",
+ /* creats*/ "NoteHead Dots Script",
+ /* accepts */ "note-event busy-playing-event",
+ /* acks */ "stem-interface note-column-interface",
+ /* reads */ "drumStyleTable",
+ /* write */ "");
source file of the GNU LilyPond music typesetter
(c) 1996--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#include "performer.hh"
#include "audio-item.hh"
#include "global-context.hh"
#include "warn.hh"
-class Drum_note_performer : public Performer {
+class Drum_note_performer : public Performer
+{
public:
TRANSLATOR_DECLARATIONS (Drum_note_performer);
-
+
protected:
- virtual bool try_music (Music *ev) ;
+ virtual bool try_music (Music *ev);
virtual void stop_translation_timestep ();
virtual void create_audio_elements ();
Link_array<Audio_note> notes_;
};
-void
+void
Drum_note_performer::create_audio_elements ()
{
SCM tab = 0;
if (!tab) tab = get_property ("drumPitchTable");
-
+
while (note_evs_.size ())
{
- Music* n = note_evs_.pop ();
+ Music *n = note_evs_.pop ();
SCM sym = n->get_property ("drum-type");
SCM defn = SCM_EOL;
if (scm_is_symbol (sym)
- && (scm_hash_table_p (tab) == SCM_BOOL_T))
+ && (scm_hash_table_p (tab) == SCM_BOOL_T))
defn = scm_hashq_ref (tab, sym, SCM_EOL);
-
- if (Pitch * pit = unsmob_pitch (defn))
+
+ if (Pitch *pit = unsmob_pitch (defn))
{
- Audio_note* p = new Audio_note (*pit, n->get_length (), 0);
+ Audio_note *p = new Audio_note (*pit, n->get_length (), 0);
Audio_element_info info (p, n);
announce_element (info);
notes_.push (p);
}
}
-
+
note_evs_.clear ();
}
notes_.clear ();
note_evs_.clear ();
}
-
+
bool
-Drum_note_performer::try_music (Music* ev)
+Drum_note_performer::try_music (Music *ev)
{
if (ev->is_mus_type ("note-event"))
{
}
else if (ev->is_mus_type ("busy-playing-event"))
return note_evs_.size ();
-
+
return false;
}
ADD_TRANSLATOR (Drum_note_performer,
- "Play drum notes.", "",
- "note-event busy-playing-event", "", "", "");
+ "Play drum notes.", "",
+ "note-event busy-playing-event", "", "", "");
Drum_note_performer::Drum_note_performer ()
{
source file of the LilyPond music typesetter
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
+ Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "duration.hh"
LY_DEFINE (ly_duration_less_p, "ly:duration<?",
2, 0, 0, (SCM p1, SCM p2),
- "Is @var{p1} shorter than @var{p2}?")
+ "Is @var{p1} shorter than @var{p2}?")
{
Duration *a = unsmob_duration (p1);
Duration *b = unsmob_duration (p2);
LY_DEFINE (ly_duration_log, "ly:duration-log",
1, 0, 0, (SCM dur),
- "Extract the duration log from @var{dur}")
+ "Extract the duration log from @var{dur}")
{
SCM_ASSERT_TYPE (unsmob_duration (dur), dur, SCM_ARG1, __FUNCTION__, "duration");
return scm_int2num (unsmob_duration (dur)->duration_log ());
LY_DEFINE (ly_duration_dot_count, "ly:duration-dot-count",
1, 0, 0, (SCM dur),
- "Extract the dot count from @var{dur}")
+ "Extract the dot count from @var{dur}")
{
SCM_ASSERT_TYPE (unsmob_duration (dur), dur, SCM_ARG1, __FUNCTION__, "duration");
return scm_int2num (unsmob_duration (dur)->dot_count ());
LY_DEFINE (ly_intlog2, "ly:intlog2",
1, 0, 0, (SCM d),
- "The 2-logarithm of 1/@var{d}.")
+ "The 2-logarithm of 1/@var{d}.")
{
SCM_ASSERT_TYPE (scm_is_number (d), d, SCM_ARG1, __FUNCTION__, "integer");
int log = intlog2 (scm_to_int (d));
LY_DEFINE (ly_duration_factor, "ly:duration-factor",
1, 0, 0, (SCM dur),
- "Extract the compression factor from @var{dur}. Return as a pair.")
+ "Extract the compression factor from @var{dur}. Return as a pair.")
{
SCM_ASSERT_TYPE (unsmob_duration (dur), dur, SCM_ARG1, __FUNCTION__, "duration");
Rational r = unsmob_duration (dur)->factor ();
source file of the LilyPond music typesetter
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
+ Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "duration.hh"
{
String s;
- if (durlog_ < 0 )
- s = "log = " + ::to_string (durlog_);
+ if (durlog_ < 0)
+ s = "log = " + ::to_string (durlog_);
else
s = ::to_string (1 << durlog_);
return s;
}
-
IMPLEMENT_TYPE_P (Duration, "ly:duration?");
SCM
int
Duration::print_smob (SCM s, SCM port, scm_print_state *)
{
- Duration *r = (Duration *) SCM_CELL_WORD_1 (s);
+ Duration *r = (Duration *) SCM_CELL_WORD_1 (s);
scm_puts ("#<Duration ", port);
scm_display (scm_makfrom0str (r->to_string ().to_str0 ()), port);
}
SCM
-Duration::equal_p (SCM a , SCM b)
+Duration::equal_p (SCM a, SCM b)
{
- Duration *p = (Duration *) SCM_CELL_WORD_1 (a);
- Duration *q = (Duration *) SCM_CELL_WORD_1 (b);
+ Duration *p = (Duration *) SCM_CELL_WORD_1 (a);
+ Duration *q = (Duration *) SCM_CELL_WORD_1 (b);
bool eq = p->dots_ == q->dots_
&& p->durlog_ == q->durlog_
return eq ? SCM_BOOL_T : SCM_BOOL_F;
}
-
int
Duration::duration_log () const
{
- TODO: the line-spanner is not killed after the (de)crescs are
finished.
-
*/
/**
print text & hairpin dynamics.
- */
+*/
class Dynamic_engraver : public Engraver
{
Item *script_;
Music *script_ev_;
Music *current_cresc_ev_;
-
- Drul_array<Music*> accepted_spanreqs_drul_;
+
+ Drul_array<Music *> accepted_spanreqs_drul_;
Link_array<Note_column> pending_columns_;
Link_array<Grob> pending_elements_;
-
+
void typeset_all ();
TRANSLATOR_DECLARATIONS (Dynamic_engraver);
-
+
protected:
virtual void finalize ();
virtual void acknowledge_grob (Grob_info);
virtual bool try_music (Music *req);
virtual void stop_translation_timestep ();
- virtual void process_music ();
+ virtual void process_music ();
};
-
-
Dynamic_engraver::Dynamic_engraver ()
{
script_ = 0;
{
if (!line_spanner_)
{
- Music * rq = accepted_spanreqs_drul_[START];
- line_spanner_ = make_spanner ("DynamicLineSpanner", rq ? rq->self_scm (): SCM_EOL );
+ Music *rq = accepted_spanreqs_drul_[START];
+ line_spanner_ = make_spanner ("DynamicLineSpanner", rq ? rq->self_scm (): SCM_EOL);
if (script_ev_)
- rq = script_ev_;
+ rq = script_ev_;
}
}
-
+
/*
During a (de)crescendo, pending event will not be cleared,
and a line-spanner will always be created, as \< \! are already
Note: line-spanner must always have at least same duration
as (de)crecsendo, b.o. line-breaking.
*/
-
/*
maybe we should leave dynamic texts to the text-engraver and
script_->set_property ("text",
script_ev_->get_property ("text"));
-
if (Direction d = to_dir (script_ev_->get_property ("direction")))
set_grob_direction (line_spanner_, d);
/*
finish side position alignment if the (de)cresc ends here, and
there are no new dynamics.
- */
-
+ */
if (cresc_)
{
assert (!finished_cresc_ && cresc_);
cresc_->set_bound (RIGHT, script_
- ? script_
- : unsmob_grob (get_property ("currentMusicalColumn")));
+ ? script_
+ : unsmob_grob (get_property ("currentMusicalColumn")));
add_bound_item (line_spanner_, cresc_->get_bound (RIGHT));
-
finished_cresc_ = cresc_;
cresc_ = 0;
accepted_spanreqs_drul_[STOP]->origin ()->warning (_ ("can't find start of (de)crescendo"));
stop_ev = 0;
}
-
+
}
-
+
if (accepted_spanreqs_drul_[START])
{
if (current_cresc_ev_)
msg = _ ("already have a crescendo");
accepted_spanreqs_drul_[START]->origin ()->warning (msg);
- current_cresc_ev_->origin ()->warning (_("Cresc started here"));
+ current_cresc_ev_->origin ()->warning (_ ("Cresc started here"));
}
else
{
TODO: Use symbols.
*/
- String start_type =
- ly_symbol2string (current_cresc_ev_->get_property ("name"));
+ String start_type
+ = ly_symbol2string (current_cresc_ev_->get_property ("name"));
/*
ugh. Use push/pop?
start_type = "decrescendo";
else if (start_type == "CrescendoEvent")
start_type = "crescendo";
-
+
SCM s = get_property ((start_type + "Spanner").to_str0 ());
if (!scm_is_symbol (s) || s == ly_symbol2scm ("hairpin"))
{
- cresc_ = make_spanner ("Hairpin", accepted_spanreqs_drul_[START]->self_scm ());
+ cresc_ = make_spanner ("Hairpin", accepted_spanreqs_drul_[START]->self_scm ());
if (finished_cresc_)
{
Pointer_group_interface::add_grob (finished_cresc_,
ly_symbol2scm ("adjacent-hairpins"),
cresc_);
-
+
Pointer_group_interface::add_grob (cresc_,
ly_symbol2scm ("adjacent-hairpins"),
finished_cresc_);
cresc_->set_property ("grow-direction",
scm_int2num ((start_type == "crescendo")
? BIGGER : SMALLER));
-
+
}
-
/*
This is a convenient (and legacy) interface to TextSpanners
for use in (de)crescendi.
*/
else
{
- cresc_ = make_spanner ("DynamicTextSpanner", accepted_spanreqs_drul_[START]->self_scm ());
+ cresc_ = make_spanner ("DynamicTextSpanner", accepted_spanreqs_drul_[START]->self_scm ());
cresc_->set_property ("style", s);
context ()->set_property ((start_type
+ "Spanner").to_str0 (), SCM_EOL);
cresc_->set_bound (LEFT, script_);
add_bound_item (line_spanner_, cresc_->get_bound (LEFT));
}
-
+
Axis_group_interface::add_element (line_spanner_, cresc_);
}
}
cresc_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn")));
add_bound_item (line_spanner_, cresc_->get_bound (LEFT));
}
-
+
script_ev_ = 0;
accepted_spanreqs_drul_[START] = 0;
accepted_spanreqs_drul_[STOP] = 0;
Dynamic_engraver::finalize ()
{
typeset_all ();
-
+
if (line_spanner_
&& !line_spanner_->is_live ())
line_spanner_ = 0;
finished_cresc_->set_bound (RIGHT, script_
? script_
: unsmob_grob (get_property ("currentMusicalColumn")));
-
+
if (finished_line_spanner_)
add_bound_item (finished_line_spanner_,
finished_cresc_->get_bound (RIGHT));
}
finished_cresc_ = 0;
}
-
+
script_ = 0;
if (finished_line_spanner_)
{
/*
We used to have
-
- extend-spanner-over-elements (finished_line_spanner_);
+
+ extend-spanner-over-elements (finished_line_spanner_);
but this is rather kludgy, since finished_line_spanner_
typically has a staff-symbol field set , extending it over the
*/
- Grob * l = finished_line_spanner_->get_bound (LEFT);
- Grob * r = finished_line_spanner_->get_bound (RIGHT);
+ Grob *l = finished_line_spanner_->get_bound (LEFT);
+ Grob *r = finished_line_spanner_->get_bound (RIGHT);
if (!r && l)
finished_line_spanner_->set_bound (RIGHT, l);
else if (!l && r)
/*
This is a isolated dynamic apparently, and does not even have
any interesting support item.
- */
- Grob * cc = unsmob_grob (get_property ("currentMusicalColumn"));
- Item * ci = dynamic_cast<Item*>(cc);
+ */
+ Grob *cc = unsmob_grob (get_property ("currentMusicalColumn"));
+ Item *ci = dynamic_cast<Item *> (cc);
finished_line_spanner_->set_bound (RIGHT, ci);
- finished_line_spanner_->set_bound (LEFT, ci);
+ finished_line_spanner_->set_bound (LEFT, ci);
}
-
+
finished_line_spanner_ = 0;
}
}
&& line_spanner_->is_live ())
{
Side_position_interface::add_support (line_spanner_, info.grob_);
- add_bound_item (line_spanner_, dynamic_cast<Item*> (info.grob_));
+ add_bound_item (line_spanner_, dynamic_cast<Item *> (info.grob_));
}
if (script_ && !script_->get_parent (X_AXIS))
{
SCM head = scm_last_pair (info.grob_->get_property ("note-heads"));
if (scm_is_pair (head))
- script_->set_parent (unsmob_grob (scm_car (head)), X_AXIS);
+ script_->set_parent (unsmob_grob (scm_car (head)), X_AXIS);
}
-
-
if (cresc_ && !cresc_->get_bound (LEFT))
{
cresc_->set_bound (LEFT, info.grob_);
add_bound_item (line_spanner_, cresc_->get_bound (LEFT));
}
-
+
}
else if (Script_interface::has_interface (info.grob_) && script_)
{
UGH.
DynamicText doesn't really have a script-priority field.
- */
+ */
if (scm_is_number (p)
&& scm_to_int (p)
< scm_to_int (script_->get_property ("script-priority")))
}
ADD_TRANSLATOR (Dynamic_engraver,
-/* descr */
-"This engraver creates hairpins, dynamic texts, and their vertical\n"
-"alignments. The symbols are collected onto a DynamicLineSpanner grob\n"
-"which takes care of vertical positioning. "
-,
-
-/* creats*/ "DynamicLineSpanner DynamicText Hairpin TextSpanner",
-/* accepts */ "absolute-dynamic-event crescendo-event decrescendo-event",
-/* acks */ "note-column-interface script-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */
+ "This engraver creates hairpins, dynamic texts, and their vertical\n"
+ "alignments. The symbols are collected onto a DynamicLineSpanner grob\n"
+ "which takes care of vertical positioning. ",
+
+ /* creats*/ "DynamicLineSpanner DynamicText Hairpin TextSpanner",
+ /* accepts */ "absolute-dynamic-event crescendo-event decrescendo-event",
+ /* acks */ "note-column-interface script-interface",
+ /* reads */ "",
+ /* write */ "");
/*
TODO:
-
- handle multiple events
- perform absolute (text) dynamics
- */
+ handle multiple events
+
+ perform absolute (text) dynamics
+*/
class Dynamic_performer : public Performer
{
public:
TRANSLATOR_DECLARATIONS (Dynamic_performer);
protected:
- virtual bool try_music (Music* req);
+ virtual bool try_music (Music *req);
virtual void stop_translation_timestep ();
virtual void create_audio_elements ();
private:
- Music* script_req_;
- Audio_dynamic* audio_;
+ Music *script_req_;
+ Audio_dynamic *audio_;
};
Dynamic_performer::Dynamic_performer ()
{
SCM proc = get_property ("dynamicAbsoluteVolumeFunction");
- SCM svolume = SCM_EOL;
+ SCM svolume = SCM_EOL;
if (ly_c_procedure_p (proc))
{
// urg
svolume = scm_call_1 (proc, script_req_->get_property ("text"));
}
- Real volume = robust_scm2double (svolume, 0.5);
+ Real volume = robust_scm2double (svolume, 0.5);
/*
properties override default equaliser setting
- */
+ */
SCM min = get_property ("midiMinimumVolume");
SCM max = get_property ("midiMaximumVolume");
if (scm_is_number (min) || scm_is_number (max))
urg, code duplication:: staff_performer
*/
SCM s = get_property ("midiInstrument");
-
+
if (!scm_is_string (s))
s = get_property ("instrument");
-
+
if (!scm_is_string (s))
s = scm_makfrom0str ("piano");
-
-
+
SCM eq = get_property ("instrumentEqualizer");
if (ly_c_procedure_p (eq))
{
volume = iv[MIN] + iv.length () * volume;
}
}
-
+
audio_ = new Audio_dynamic (volume);
Audio_element_info info (audio_, script_req_);
announce_element (info);
}
bool
-Dynamic_performer::try_music (Music* r)
+Dynamic_performer::try_music (Music *r)
{
if (!script_req_)
{
}
ADD_TRANSLATOR (Dynamic_performer,
- /*descr*/ "",
- /* creats*/ "",
- /* accepts */ "absolute-dynamic-event",
- /* acks */ "",
- /*reads */"dynamicAbsoluteVolumeFunction midiMaximumVolume midiMinimumVolume midiInstrument instrumentEqualizer",
- /*writes*/"");
+ /*descr*/ "",
+ /* creats*/ "",
+ /* accepts */ "absolute-dynamic-event",
+ /* acks */ "",
+ /*reads */"dynamicAbsoluteVolumeFunction midiMaximumVolume midiMinimumVolume midiInstrument instrumentEqualizer",
+ /*writes*/"");
-
/*
crescendo-text-spanner.cc -- implement Text_spanner
(c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- Revised over good by Han-Wen.
+ Revised over good by Han-Wen.
*/
#include "text-item.hh"
#include "paper-column.hh"
-
class Dynamic_text_spanner
{
public:
DECLARE_SCHEME_CALLBACK (print, (SCM));
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
};
-
/*
This is a partial C&P from text-spanner.cc
* does not require bracket functionality.
* should make room for spanning points (mf/f/mp texts).
-
+
* In the future, we should support
- cresc - - - - poco - - - a - - - - poco - - -
+ cresc - - - - poco - - - a - - - - poco - - -
as well
The cut & paste is rather inelegant, but text-spanner was a failed
and buggy attempt at being generic.
-
-
*/
MAKE_SCHEME_CALLBACK (Dynamic_text_spanner, print, 1);
SCM
-Dynamic_text_spanner::print (SCM smob)
+Dynamic_text_spanner::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
- Spanner *spanner = dynamic_cast<Spanner*> (me);
+ Spanner *spanner = dynamic_cast<Spanner *> (me);
Grob *common = spanner->get_bound (LEFT)->common_refpoint (spanner->get_bound (RIGHT), X_AXIS);
- Output_def * layout = me->get_layout ();
+ Output_def *layout = me->get_layout ();
Interval span_points;
Drul_array<bool> broken;
encl = -d;
}
- Interval ext = b->extent (common, X_AXIS);
- span_points[d] = -d * pad
+ Interval ext = b->extent (common, X_AXIS);
+ span_points[d] = -d * pad
+ robust_relative_extent (b, common, X_AXIS)
.linear_combination (encl);
}
}
while (flip (&d) != LEFT);
-
Stencil m;
SCM properties = Font_interface::text_font_alist_chain (me);
SCM edge_text = me->get_property ("edge-text");
{
if (broken[d])
continue;
-
+
SCM text = index_get_cell (edge_text, d);
- if (Text_interface::markup_p (text))
+ if (Text_interface::markup_p (text))
edge[d] = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (), properties, text));
-
+
if (!edge[d].is_empty ())
edge[d].align_to (Y_AXIS, CENTER);
}
do
{
Interval ext = edge[d].extent (X_AXIS);
- Real pad = robust_scm2double (me->get_property ("bound-padding"), 0.0);
+ Real pad = robust_scm2double (me->get_property ("bound-padding"), 0.0);
if (!ext.is_empty ())
{
edge[d].translate_axis (span_points[d], X_AXIS);
m.add_stencil (edge[d]);
- span_points[d] += -d * (ext[-d] + pad);
+ span_points[d] += -d * (ext[-d] + pad);
}
}
while (flip (&d) != LEFT);
-
if (!span_points.is_empty ())
{
Stencil l = Line_spanner::line_stencil (me,
- Offset (span_points[LEFT], 0),
- Offset (span_points[RIGHT], 0));
+ Offset (span_points[LEFT], 0),
+ Offset (span_points[RIGHT], 0));
m.add_stencil (l);
}
m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
/*
engraver-group-engraver.cc -- implement Engraver_group_engraver
-
+
source file of the GNU LilyPond music typesetter
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
get_daddy_engraver ()->announce_grob (info);
}
-
SCM find_acknowledge_engravers (SCM gravlist, SCM meta);
SCM find_accept_engravers (SCM gravlist, SCM music_descr);
Engraver_group_engraver::acknowledge_grobs ()
{
if (!announce_infos_.size ())
- return ;
-
+ return;
+
SCM tab = get_property ("acknowledgeHashTable");
SCM name_sym = ly_symbol2scm ("name");
- SCM meta_sym = ly_symbol2scm ("meta");
+ SCM meta_sym = ly_symbol2scm ("meta");
-
for (int j = 0; j < announce_infos_.size (); j++)
{
Grob_info info = announce_infos_[j];
-
+
SCM meta = info.grob_->internal_get_property (meta_sym);
SCM nm = scm_assoc (name_sym, meta);
if (scm_is_pair (nm))
We ignore the grob anyway. He who has no name, shall not
be helped. */
-
+
continue;
}
-
+
SCM acklist = scm_hashq_ref (tab, nm, SCM_UNDEFINED);
if (acklist == SCM_BOOL_F)
{
for (SCM p = acklist; scm_is_pair (p); p = scm_cdr (p))
{
- Translator * t = unsmob_translator (scm_car (p));
- Engraver * eng = dynamic_cast<Engraver*> (t);
+ Translator *t = unsmob_translator (scm_car (p));
+ Engraver *eng = dynamic_cast<Engraver *> (t);
if (eng && eng != info.origin_trans_)
eng->acknowledge_grob (info);
}
}
}
-
/*
Ugh. This is slightly expensive. We could/should cache the value of
the group count?
- */
+*/
int
Engraver_group_engraver::pending_grob_count () const
{
scm_is_pair (s); s = scm_cdr (s))
{
Context *c = unsmob_context (scm_car (s));
- Engraver_group_engraver * group
- = dynamic_cast<Engraver_group_engraver*> (c->implementation ());
+ Engraver_group_engraver *group
+ = dynamic_cast<Engraver_group_engraver *> (c->implementation ());
if (group)
- count += group->pending_grob_count ();
+ count += group->pending_grob_count ();
}
- return count;
+ return count;
}
void
Engraver_group_engraver::do_announces ()
{
- do {
- for (SCM s = context ()->children_contexts ();
- scm_is_pair (s); s = scm_cdr (s))
- {
- Context *c = unsmob_context (scm_car (s));
- Engraver_group_engraver * group
- = dynamic_cast<Engraver_group_engraver*> (c->implementation ());
- if (group)
- group->do_announces ();
- }
-
- do
- {
- engraver_each (get_simple_trans_list (),
- &Engraver::process_acknowledged_grobs);
-
-
- if (announce_infos_.size () == 0)
- break;
-
- acknowledge_grobs ();
- announce_infos_.clear ();
- }
- while (1);
-
- } while (pending_grob_count () > 0);
-}
+ do
+ {
+ for (SCM s = context ()->children_contexts ();
+ scm_is_pair (s); s = scm_cdr (s))
+ {
+ Context *c = unsmob_context (scm_car (s));
+ Engraver_group_engraver *group
+ = dynamic_cast<Engraver_group_engraver *> (c->implementation ());
+ if (group)
+ group->do_announces ();
+ }
+ do
+ {
+ engraver_each (get_simple_trans_list (),
+ &Engraver::process_acknowledged_grobs);
+ if (announce_infos_.size () == 0)
+ break;
+
+ acknowledge_grobs ();
+ announce_infos_.clear ();
+ }
+ while (1);
+
+ }
+ while (pending_grob_count () > 0);
+
+}
void
Engraver_group_engraver::initialize ()
Engraver_group_engraver::Engraver_group_engraver () {}
ADD_TRANSLATOR (Engraver_group_engraver,
-/* descr */ "A group of engravers taken together",
-/* creats*/ "",
-/* accepts */ "",
-/* acks */ "",
-/* reads */ "",
-/* write */ "");
-
-
+ /* descr */ "A group of engravers taken together",
+ /* creats*/ "",
+ /* accepts */ "",
+ /* acks */ "",
+ /* reads */ "",
+ /* write */ "");
/*****************/
-
bool
-engraver_valid (Translator*tr, SCM ifaces)
+engraver_valid (Translator *tr, SCM ifaces)
{
SCM ack_ifs = scm_assoc (ly_symbol2scm ("interfaces-acked"), tr->translator_description ());
ack_ifs = scm_cdr (ack_ifs);
return false;
}
-
-
SCM
find_acknowledge_engravers (SCM gravlist, SCM meta_alist)
{
SCM ifaces = scm_cdr (scm_assoc (ly_symbol2scm ("interfaces"), meta_alist));
SCM l = SCM_EOL;
- for (SCM s = gravlist; scm_is_pair (s); s = scm_cdr (s))
+ for (SCM s = gravlist; scm_is_pair (s); s = scm_cdr (s))
{
- Translator* tr = unsmob_translator (scm_car (s));
+ Translator *tr = unsmob_translator (scm_car (s));
if (engraver_valid (tr, ifaces))
- l = scm_cons (tr->self_scm (), l);
+ l = scm_cons (tr->self_scm (), l);
}
l = scm_reverse_x (l, SCM_EOL);
return l;
}
-
/* c&p engraver-group.cc */
void
-recurse_down_engravers (Context * c, Engraver_method ptr, bool context_first)
+recurse_down_engravers (Context *c, Engraver_method ptr, bool context_first)
{
- Engraver_group_engraver * tg
- = dynamic_cast<Engraver_group_engraver*> (c->implementation ());
-
+ Engraver_group_engraver *tg
+ = dynamic_cast<Engraver_group_engraver *> (c->implementation ());
if (!context_first)
{
(tg->*ptr) ();
}
- for (SCM s = c->children_contexts () ; scm_is_pair (s);
+ for (SCM s = c->children_contexts (); scm_is_pair (s);
s = scm_cdr (s))
{
recurse_down_engravers (unsmob_context (scm_car (s)), ptr, context_first);
}
}
-
void
engraver_each (SCM list, Engraver_method method)
{
for (SCM p = list; scm_is_pair (p); p = scm_cdr (p))
{
- Engraver * e = dynamic_cast<Engraver*>(unsmob_translator (scm_car (p)));
+ Engraver *e = dynamic_cast<Engraver *> (unsmob_translator (scm_car (p)));
if (e)
(e->*method) ();
}
#include "score-context.hh"
#include "lilypond-key.hh"
-Engraver_group_engraver*
+Engraver_group_engraver *
Engraver::get_daddy_engraver () const
{
- return dynamic_cast<Engraver_group_engraver*> (get_daddy_translator ());
+ return dynamic_cast<Engraver_group_engraver *> (get_daddy_translator ());
}
void
get_daddy_engraver ()->announce_grob (inf);
}
-
/*
CAUSE is the object (typically a Music object) that
was the reason for making E.
- */
+*/
void
-Engraver::announce_grob (Grob* e, SCM cause)
+Engraver::announce_grob (Grob *e, SCM cause)
{
if (unsmob_music (cause) || unsmob_grob (cause))
e->set_property ("cause", cause);
if (!i.origin_trans_)
i.origin_trans_ = this;
- Engraver * g = get_daddy_engraver ();
+ Engraver *g = get_daddy_engraver ();
if (g)
g->announce_grob (i);
}
-
-
-
Engraver::Engraver ()
{
}
-
-Score_engraver*
+Score_engraver *
Engraver::get_score_engraver () const
{
- return dynamic_cast<Score_engraver*> (get_score_context ()->implementation ());
+ return dynamic_cast<Score_engraver *> (get_score_context ()->implementation ());
}
-
ADD_TRANSLATOR (Engraver,
- "", "",
- "",
- "", "", "");
+ "", "",
+ "",
+ "", "", "");
get_req_translator ();
}
-Event_chord*
+Event_chord *
Event_chord_iterator::get_elt () const
{
- return (Event_chord*) get_music ();
+ return (Event_chord *) get_music ();
}
-
void
Event_chord_iterator::process (Moment m)
{
if (last_processed_mom_ < Moment (0))
{
for (SCM s = get_music ()->get_property ("elements");
- scm_is_pair (s); s = scm_cdr (s))
+ scm_is_pair (s); s = scm_cdr (s))
{
Music *mus = unsmob_music (scm_car (s));
#include "event.hh"
#include "warn.hh"
-MAKE_SCHEME_CALLBACK(Event, length_callback, 1);
+MAKE_SCHEME_CALLBACK (Event, length_callback, 1);
SCM
Event::length_callback (SCM m)
{
- Music* me = unsmob_music (m);
+ Music *me = unsmob_music (m);
Duration *d = unsmob_duration (me->get_property ("duration"));
Moment mom;
{
mom = d->get_length ();
}
- return mom.smobbed_copy();
+ return mom.smobbed_copy ();
}
-
+
Event::Event (SCM i)
: Music (i)
{
ADD_MUSIC (Event);
-
-
extender-engraver.cc -- implement Extender_engraver
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Glen Prideaux <glenprideaux@iname.com>,
- Han-Wen Nienhuys <hanwen@cs.uu.nl>,
- Jan Nieuwenhuizen <janneke@gnu.org>
+ Han-Wen Nienhuys <hanwen@cs.uu.nl>,
+ Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "context.hh"
protected:
virtual void acknowledge_grob (Grob_info);
virtual void finalize ();
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void stop_translation_timestep ();
virtual void process_music ();
};
-
Extender_engraver::Extender_engraver ()
{
extender_ = 0;
void
Extender_engraver::acknowledge_grob (Grob_info i)
{
- Item *item = dynamic_cast<Item*> (i.grob_);
+ Item *item = dynamic_cast<Item *> (i.grob_);
if (item
&& item->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
Pointer_group_interface::add_grob (extender_,
ly_symbol2scm ("heads"), h);
}
-
+
if (pending_extender_)
{
Pointer_group_interface::add_grob (pending_extender_,
ly_symbol2scm ("heads"), h);
}
}
-
+
if (extender_)
{
pending_extender_ = extender_;
SCM heads = sp->get_property ("heads");
if (scm_is_pair (heads))
{
- Item *it = dynamic_cast<Item*> (unsmob_grob (scm_car (heads)));
+ Item *it = dynamic_cast<Item *> (unsmob_grob (scm_car (heads)));
if (it)
sp->set_bound (RIGHT, it);
}
}
}
-
ADD_TRANSLATOR (Extender_engraver,
-/* descr */ "Create lyric extenders",
-/* creats*/ "LyricExtender",
-/* accepts */ "extender-event",
-/* acks */ "lyric-syllable-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Create lyric extenders",
+ /* creats*/ "LyricExtender",
+ /* accepts */ "extender-event",
+ /* acks */ "lyric-syllable-interface",
+ /* reads */ "",
+ /* write */ "");
-/*
-figured-bass-engraver.cc -- implement Figured_bass_engraver
+/*
+ figured-bass-engraver.cc -- implement Figured_bass_engraver
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#include "engraver.hh"
#include "text-item.hh"
TRANSLATOR_DECLARATIONS (Figured_bass_engraver);
protected:
Link_array<Music> figures_;
- Music * rest_req_;
+ Music *rest_req_;
+
+ Grob *figure_;
- Grob * figure_;
-
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void stop_translation_timestep ();
virtual void process_music ();
};
-
Figured_bass_engraver::Figured_bass_engraver ()
{
figure_ = 0;
}
bool
-Figured_bass_engraver::try_music (Music*m)
+Figured_bass_engraver::try_music (Music *m)
{
if (m->is_mus_type ("bass-figure-event"))
{
if (rest_req_)
{
figure_ = make_item ("BassFigure", rest_req_->self_scm ());
- figure_->set_property ("text" , scm_makfrom0str ("-"));
+ figure_->set_property ("text", scm_makfrom0str ("-"));
}
else if (figures_.size ())
{
SCM proc = get_property ("bassFigureFormatFunction");
- if (ly_c_procedure_p (proc))
+ if (ly_c_procedure_p (proc))
{
SCM l = SCM_EOL;
- SCM * t = &l;
+ SCM *t = &l;
for (int i = 0; i < figures_.size (); i++)
{
*t = scm_cons (figures_[i]->self_scm (), SCM_EOL);
}
}
-
ADD_TRANSLATOR (Figured_bass_engraver,
-/* descr */ "Make figured bass numbers.",
-/* creats*/ "BassFigure",
-/* accepts */ "rest-event bass-figure-event",
-/* acks */ "",
-/* reads */ "bassFigureFormatFunction",
-/* write */ "");
+ /* descr */ "Make figured bass numbers.",
+ /* creats*/ "BassFigure",
+ /* accepts */ "rest-event bass-figure-event",
+ /* acks */ "",
+ /* reads */ "bassFigureFormatFunction",
+ /* write */ "");
-/*
+/*
fingering-engraver.cc -- implement Fingering_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "engraver.hh"
#include "side-position-interface.hh"
public:
TRANSLATOR_DECLARATIONS (Fingering_engraver);
protected:
- virtual bool try_music (Music* m);
+ virtual bool try_music (Music *m);
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
virtual void process_music ();
virtual void acknowledge_grob (Grob_info);
private:
- void make_script (Direction, Music*, int);
+ void make_script (Direction, Music *, int);
};
bool
{
for (int i = 0; i < fingerings_.size (); i++)
{
- Grob*t = fingerings_[i];
+ Grob *t = fingerings_[i];
Side_position_interface::add_support (t, inf.grob_);
if (!t->get_parent (X_AXIS))
t->set_parent (inf.grob_, X_AXIS);
}
}
-
void
Fingering_engraver::make_script (Direction d, Music *r, int i)
{
Huh, what's this for? --hwn.
junkme.
- */
+ */
SCM pitch = r->get_property ("pitch");
if (unsmob_pitch (pitch))
fingering->set_property ("pitch", pitch);
/*
We can't fold these definitions into define-grobs since
- fingerings for chords need different settings.
+ fingerings for chords need different settings.
*/
Side_position_interface::set_axis (fingering, a);
fingering->add_offset_callback (Self_alignment_interface::aligned_on_self_proc, other);
SCM s = fingering->get_property ("script-priority");
if (scm_is_number (s))
priority = scm_to_int (s);
-
+
/* See script-engraver.cc */
priority += i;
fingering->set_property ("script-priority", scm_int2num (priority));
-
if (!is_direction (fingering->get_property ("direction")))
{
if (d)
fingering->set_property ("direction", scm_int2num (d));
else
- fingering->set_property ("direction", scm_int2num (RIGHT));
+ fingering->set_property ("direction", scm_int2num (RIGHT));
}
- SCM dig = r->get_property ("digit");
+ SCM dig = r->get_property ("digit");
fingering->set_property ("text", scm_number_to_string (dig, scm_int2num (10)));
fingerings_.push (fingering);
{
if (!fingerings_.size ())
return;
-
+
fingerings_.clear ();
}
}
ADD_TRANSLATOR (Fingering_engraver,
-/* descr */ "Create fingering-scripts",
-/* creats*/ "Fingering",
-/* accepts */ "fingering-event",
-/* acks */ "rhythmic-head-interface stem-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Create fingering-scripts",
+ /* creats*/ "Fingering",
+ /* accepts */ "fingering-event",
+ /* acks */ "rhythmic-head-interface stem-interface",
+ /* reads */ "",
+ /* write */ "");
-/*
- folded-repeat-iterator.cc -- implement Folded_repeat_iterator
-
+/*
+ folded-repeat-iterator.cc -- implement Folded_repeat_iterator
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "folded-repeat-iterator.hh"
void
Folded_repeat_iterator::construct_children ()
{
- Music *mus = get_music ();
+ Music *mus = get_music ();
main_iter_ = unsmob_iterator (get_iterator (Repeated_music::body (mus)));
if (!main_iter_->ok ())
{
void
Folded_repeat_iterator::process (Moment m)
{
- if (!m.to_bool () )
+ if (!m.to_bool ())
{
bool success = try_music (get_music ());
if (!success)
get_music ()->origin ()->warning (_ ("no one to print a repeat brace"));
}
-
+
if (main_iter_)
{
main_iter_->process (m);
{
enter_alternative ();
}
-
+
if (alternative_iter_)
{
alternative_iter_->process (m - main_length_mom_);
main_iter_->quit ();
main_iter_ = 0;
- main_length_mom_ += Repeated_music::body (mus)->get_length ();
+ main_length_mom_ += Repeated_music::body (mus)->get_length ();
}
void
Folded_repeat_iterator::enter_alternative ()
{
- Music *mus = get_music ();
+ Music *mus = get_music ();
if (scm_is_pair (Repeated_music::alternatives (mus)))
{
/*
ugh.
- */
- Simultaneous_music_iterator * s = new Simultaneous_music_iterator;
+ */
+ Simultaneous_music_iterator *s = new Simultaneous_music_iterator;
s->create_separate_contexts_ = true;
s->init_translator (mus, get_outlet ());
-
+
alternative_iter_ = s;
alternative_iter_->construct_children ();
}
}
-
-Music_iterator*
-Folded_repeat_iterator::try_music_in_children (Music * m) const
+Music_iterator *
+Folded_repeat_iterator::try_music_in_children (Music *m) const
{
if (main_iter_)
{
}
void
-Folded_repeat_iterator::derived_substitute (Context *f, Context *t)
+Folded_repeat_iterator::derived_substitute (Context *f, Context *t)
{
if (main_iter_)
main_iter_->substitute_outlet (f, t);
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "config.hh"
dirs.push (prefix_directory + "/mf/out/");
dirs.push (prefix_directory + "/fonts/type1/");
dirs.push (prefix_directory + "/fonts/cff/");
-
+
for (int i = 0; i < dirs.size (); i++)
{
String dir = dirs[i];
- if (!FcConfigAppFontAddDir (fcc, (FcChar8*)dir.to_str0 ()))
+ if (!FcConfigAppFontAddDir (fcc, (FcChar8 *)dir.to_str0 ()))
error (_f ("Failed to add lilypond directory %s", dir));
- }
+ }
}
#else
/*
font-interface.cc -- implement Font_interface
-
+
source file of the GNU LilyPond music typesetter
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
if (!fm)
{
SCM chain = music_font_alist_chain (me);
-
+
fm = select_font (me->get_layout (), chain);
me->set_property ("font", fm->self_scm ());
}
-
+
return fm;
}
LY_DEFINE (ly_font_interface_get_default_font, "ly:get-default-font",
- 1 , 0, 0, (SCM grob),
- "Return the default font for grob @var{gr}.")
+ 1, 0, 0, (SCM grob),
+ "Return the default font for grob @var{gr}.")
{
Grob *gr = unsmob_grob (grob);
SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "grob");
return Font_interface::get_default_font (gr)->self_scm ();
}
-
SCM
Font_interface::music_font_alist_chain (Grob *g)
{
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "stencil.hh"
LY_DEFINE (ly_font_get_glyph, "ly:font-get-glyph",
2, 0, 0,
- (SCM font, SCM name),
+ (SCM font, SCM name),
"Return a Stencil from @var{font} for the glyph named @var{name}. "
"@var{font} must be available as an AFM file. If the glyph "
"is not available, return @code{#f}.")
LY_DEFINE (ly_get_glyph, "ly:get-glyph",
2, 0, 0,
- (SCM font, SCM index),
+ (SCM font, SCM index),
"Retrieve a Stencil for the glyph numbered @var{index} "
"in @var{font}.")
{
LY_DEFINE (ly_font_glyph_name_to_index, "ly:font-glyph-name-to-index",
2, 0, 0,
- (SCM font, SCM name),
+ (SCM font, SCM name),
"Return the index for @var{name} in @var{font}.")
{
Font_metric *fm = unsmob_metrics (font);
LY_DEFINE (ly_font_index_to_charcode, "ly:font-index-to-charcode",
2, 0, 0,
- (SCM font, SCM index),
+ (SCM font, SCM index),
"Return the character code for @var{index} @var{font}.")
{
Font_metric *fm = unsmob_metrics (font);
LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode",
2, 0, 0,
- (SCM font, SCM name),
+ (SCM font, SCM name),
"Return the character code for glyph @var{name} in @var{font}.")
{
Font_metric *fm = unsmob_metrics (font);
LY_DEFINE (ly_text_dimension, "ly:text-dimension",
2, 0, 0,
- (SCM font, SCM text),
- "Given the font metric in @var{font} and the string @var{text}, "
+ (SCM font, SCM text),
+ "Given the font metric in @var{font} and the string @var{text}, "
"compute the extents of that text in that font. "
"The return value is a pair of number-pairs.")
{
Box b;
- Modified_font_metric*fm = dynamic_cast<Modified_font_metric*>
+ Modified_font_metric *fm = dynamic_cast<Modified_font_metric *>
(unsmob_metrics (font));
-
+
SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "modified font metric");
SCM_ASSERT_TYPE (scm_is_string (text), text, SCM_ARG2, __FUNCTION__, "string");
Stencil stc (fm->text_stencil (ly_scm2string (text)));
{
Font_metric *fm = unsmob_metrics (font);
SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
- return fm->font_file_name();
+ return fm->font_file_name ();
}
-
LY_DEFINE (ly_font_name, "ly:font-name",
1, 0, 0,
(SCM font),
"return the corresponding name.")
{
Font_metric *fm = unsmob_metrics (font);
-
+
SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
- return scm_makfrom0str (fm->font_name().to_str0 ());
+ return scm_makfrom0str (fm->font_name ().to_str0 ());
}
LY_DEFINE (ly_font_magnification, "ly:font-magnification", 1, 0, 0,
- (SCM font),
+ (SCM font),
"Given the font metric @var{font}, return the "
"magnification, relative to the current outputscale.")
{
}
LY_DEFINE (ly_font_design_size, "ly:font-design-size", 1, 0, 0,
- (SCM font),
+ (SCM font),
"Given the font metric @var{font}, return the "
"design size, relative to the current outputscale.")
{
-/*
+/*
font-metric.cc -- implement Font_metric
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Mats Bengtsson <matsb@s3.kth.se> (the ugly TeX parsing in text_dimension)
+ Mats Bengtsson <matsb@s3.kth.se> (the ugly TeX parsing in text_dimension)
*/
#include "font-metric.hh"
return 1.0 * point_constant;
}
-
Stencil
Font_metric::find_by_name (String s) const
{
s.substitute_char ('-', "M");
int idx = name_to_index (s);
Box b;
-
+
SCM expr = SCM_EOL;
if (idx >= 0)
{
expr = scm_list_3 (ly_symbol2scm ("named-glyph"),
self_scm (),
- scm_makfrom0str (s.to_str0 ())
- );
+ scm_makfrom0str (s.to_str0 ()));
b = get_indexed_char (idx);
}
-
+
Stencil q (b, expr);
return q;
}
{
}
-
Font_metric::~Font_metric ()
{
}
return 0;
}
-Box
+Box
Font_metric::get_ascii_char (int) const
{
return Box (Interval (0, 0), Interval (0, 0));
}
-Box
+Box
Font_metric::get_indexed_char (int k) const
{
return get_ascii_char (k);
SCM
Font_metric::mark_smob (SCM s)
{
- Font_metric *m = (Font_metric*) SCM_CELL_WORD_1 (s);
+ Font_metric *m = (Font_metric *) SCM_CELL_WORD_1 (s);
m->derived_mark ();
return m->description_;
}
return 1;
}
-
-
IMPLEMENT_SMOBS (Font_metric);
IMPLEMENT_DEFAULT_EQUAL_P (Font_metric);
IMPLEMENT_TYPE_P (Font_metric, "ly:font-metric?");
-
-SCM
+SCM
Font_metric::font_file_name () const
{
return scm_car (description_);
#include "afm.hh"
-
int
Font_metric::index_to_ascii (int i) const
{
return Stencil (b, at);
}
-
Offset
Font_metric::attachment_point (String) const
{
SCM lst = scm_list_3 (ly_symbol2scm ("text"),
this->self_scm (),
scm_makfrom0str (str.to_str0 ()));
-
+
Box b = text_dimension (str);
return Stencil (b, lst);
}
/*
- font-select.cc -- implement property -> font_metric routines.
+ font-select.cc -- implement property -> font_metric routines.
source file of the GNU LilyPond music typesetter
#include "pango-font.hh"
#include "main.hh"
-
Font_metric *
get_font_by_design_size (Output_def *layout, Real requested,
SCM font_vector)
for (; i < n; i++)
{
SCM entry = scm_c_vector_ref (font_vector, i);
-
+
if (scm_promise_p (entry) == SCM_BOOL_T)
{
Font_metric *fm = unsmob_metrics (scm_force (entry));
= scm_cdr (entry);
}
#endif
-
+
if (size > requested)
break;
last_size = size;
pango_description_string = last_pango_description_string;
}
}
-
+
Font_metric *fm = 0;
if (scm_is_string (pango_description_string))
{
pango_description_string,
requested / size);
#else
- error ("Trying to retrieve pango font without HAVE_PANGO_FT2.");
+ error ("Trying to retrieve pango font without HAVE_PANGO_FT2.");
#endif
}
else
? robust_scm2double (scm_cdr (mag), 1.0)
: 1);
Font_metric *fm = all_fonts_global->find_font (ly_scm2string (name));
-
+
return find_scaled_font (layout, fm, rmag);
}
else if (scm_instance_p (name))
{
- SCM base_size = scm_slot_ref (name, ly_symbol2scm ("default-size"));
+ SCM base_size = scm_slot_ref (name, ly_symbol2scm ("default-size"));
SCM vec = scm_slot_ref (name, ly_symbol2scm ("size-vector"));
SCM font_size = ly_chain_assoc (ly_symbol2scm ("font-size"), chain);
-/*
+/*
font-size-engraver.cc -- implement Font_size_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "grob.hh"
#include "engraver.hh"
class Font_size_engraver : public Engraver
{
-
+
TRANSLATOR_DECLARATIONS (Font_size_engraver);
protected:
virtual void acknowledge_grob (Grob_info gi);
private:
};
-
Font_size_engraver::Font_size_engraver ()
{
/*
We only want to process a grob once.
- */
+ */
if (gi.origin_trans_->context () != context ())
- return ;
-
+ return;
+
if (scm_is_number (sz) && scm_to_double (sz))
{
Real font_size = scm_to_double (sz);
-
- font_size += robust_scm2double (gi.grob_->get_property ("font-size"), 0);
+
+ font_size += robust_scm2double (gi.grob_->get_property ("font-size"), 0);
gi.grob_->set_property ("font-size", scm_make_real (font_size));
}
}
-
ADD_TRANSLATOR (Font_size_engraver,
-/* descr */ "Puts fontSize into font-relative-size grob property.",
-/* creats*/ "",
-/* accepts */ "",
-/* acks */ "font-interface",
-/* reads */ "fontSize",
-/* write */ "");
+ /* descr */ "Puts fontSize into font-relative-size grob property.",
+ /* creats*/ "",
+ /* accepts */ "",
+ /* acks */ "font-interface",
+ /* reads */ "fontSize",
+ /* write */ "");
source file of the GNU LilyPond music typesetter
(c) 2002--_2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "rhythmic-head.hh"
#include "grob.hh"
{
/*
Check for running note heads. This should probably be done elsewhere.
- */
+ */
SCM busy = get_property ("busyGrobs");
Moment now = now_mom ();
while (scm_is_pair (busy) && unsmob_moment (scm_caar (busy))->main_part_ == now.main_part_)
busy = scm_cdr (busy);
-
while (scm_is_pair (busy))
{
Grob *g = unsmob_grob (scm_cdar (busy));
}
}
-
ADD_TRANSLATOR (Forbid_line_break_engraver,
-/* descr */ "Forbid line breaks when note heads are still playing at some point.",
-/* creats*/ "",
-/* accepts */ "",
-/* acks */ "",
-/* reads */ "busyGrobs",
-/* write */ "");
+ /* descr */ "Forbid line breaks when note heads are still playing at some point.",
+ /* creats*/ "",
+ /* accepts */ "",
+ /* acks */ "",
+ /* reads */ "busyGrobs",
+ /* write */ "");
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "freetype.hh"
FT_Library freetype2_library;
-
void
-init_freetype()
+init_freetype ()
{
- int errorcode = FT_Init_FreeType( &freetype2_library );
+ int errorcode = FT_Init_FreeType (&freetype2_library);
if (errorcode)
{
- error("Could not initialize freetype");
+ error ("Could not initialize freetype");
}
}
-/*
+/*
function-documentation.cc -- Scheme doc strings.
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include <cstring>
#include "protected-scm.hh"
#include "string.hh"
-static Protected_scm doc_hash_table ;
+static Protected_scm doc_hash_table;
void ly_add_function_documentation (SCM func,
- char const * fname,
- char const * varlist,
- char const * doc)
+ char const *fname,
+ char const *varlist,
+ char const *doc)
{
if (!strlen (doc))
return;
-
+
if (!scm_is_vector (doc_hash_table))
doc_hash_table = scm_make_vector (scm_int2num (59), SCM_EOL);
String s = String (" - ") + "LilyPond procedure: " + fname + " " + varlist
- + "\n" + doc ;
+ + "\n" + doc;
scm_set_procedure_property_x (func, ly_symbol2scm ("documentation"),
scm_makfrom0str (s.to_str0 ()));
scm_hashq_set_x (doc_hash_table, ly_symbol2scm (fname), entry);
}
-
LY_DEFINE (ly_get_all_function_documentation, "ly:get-all-function-documentation",
- 0, 0, 0, (),
- "Get a hash table with all lilypond Scheme extension functions.")
+ 0, 0, 0, (),
+ "Get a hash table with all lilypond Scheme extension functions.")
{
return doc_hash_table;
}
#include "paper-column.hh"
extern "C" {
-// thanks to GDBs wonderful casting abilities, we need these:
-Item*
-to_item (Grob* g)
-{
- return dynamic_cast<Item*> (g);
-}
-Spanner*
-to_spanner (Grob*g)
-{
- return dynamic_cast<Spanner*> (g);
-}
+ // thanks to GDBs wonderful casting abilities, we need these:
+ Item *
+ to_item (Grob *g)
+ {
+ return dynamic_cast<Item *> (g);
+ }
+ Spanner *
+ to_spanner (Grob *g)
+ {
+ return dynamic_cast<Spanner *> (g);
+ }
-Paper_column*
-to_pc (Grob* g)
-{
- return dynamic_cast<Paper_column*> (g);
-}
+ Paper_column *
+ to_pc (Grob *g)
+ {
+ return dynamic_cast<Paper_column *> (g);
+ }
}
source file of the GNU LilyPond music typesetter
(c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "config.hh"
inline int my_isnan (Real r) { return isnan (r); }
#endif
-
-
LY_DEFINE (ly_find_file, "ly:find-file",
1, 0, 0, (SCM name),
"Return the absolute file name of @var{name}, "
String file_name = global_path.find (nm);
if (file_name.is_empty ())
return SCM_BOOL_F;
-
+
return scm_makfrom0str (file_name.to_str0 ());
}
/*
Ugh. Gulped file is copied twice. (maybe thrice if you count stdio
buffering.)
- */
+*/
LY_DEFINE (ly_gulp_file, "ly:gulp-file",
1, 0, 0, (SCM name),
"Read the file @var{name}, and return its contents in a string. "
LY_DEFINE (ly_dir_p, "ly:dir?",
1, 0, 0, (SCM s),
- "type predicate. A direction is @code{-1}, @code{0} or "
+ "type predicate. A direction is @code{-1}, @code{0} or "
"@code{1}, where @code{-1} represents "
- "left or down and @code{1} represents right or up.")
+ "left or down and @code{1} represents right or up.")
{
if (scm_is_number (s))
{
int i = scm_to_int (s);
- return (i>= -1 && i <= 1) ? SCM_BOOL_T : SCM_BOOL_F;
+ return (i>= -1 && i <= 1) ? SCM_BOOL_T : SCM_BOOL_F;
}
return SCM_BOOL_F;
}
if (default_value == SCM_UNDEFINED)
default_value = SCM_BOOL_F;
-
+
if (scm_is_pair (handle))
return scm_cdr (handle);
else
#ifdef __APPLE__
if (my_isinf (r) || my_isnan (r))
#else
- if (isinf (r) || isnan (r))
+ if (isinf (r) || isnan (r))
#endif
- {
- programming_error ("Infinity or NaN encountered while converting Real number; setting to zero.");
- r = 0.0;
- }
+ {
+ programming_error ("Infinity or NaN encountered while converting Real number; setting to zero.");
+ r = 0.0;
+ }
snprintf (str, sizeof (str), "%08.4f", r);
}
}
LY_DEFINE (ly_version, "ly:version", 0, 0, 0, (),
- "Return the current lilypond version as a list, e.g. @code{(1 3 127 uu1)}. ")
+ "Return the current lilypond version as a list, e.g. @code{(1 3 127 uu1)}. ")
{
- char const* vs = "\'(" MAJOR_VERSION " " MINOR_VERSION " " PATCH_LEVEL " " MY_PATCH_LEVEL ")" ;
-
- return scm_c_eval_string ((char*)vs);
+ char const *vs = "\'(" MAJOR_VERSION " " MINOR_VERSION " " PATCH_LEVEL " " MY_PATCH_LEVEL ")";
+
+ return scm_c_eval_string ((char *)vs);
}
LY_DEFINE (ly_unit, "ly:unit", 0, 0, 0, (),
- "Return the unit used for lengths as a string.")
+ "Return the unit used for lengths as a string.")
{
return scm_makfrom0str (INTERNAL_UNIT);
}
LY_DEFINE (ly_dimension_p, "ly:dimension?", 1, 0, 0, (SCM d),
- "Return @var{d} is a number. Used to distinguish length "
- "variables from normal numbers.")
+ "Return @var{d} is a number. Used to distinguish length "
+ "variables from normal numbers.")
{
return scm_number_p (d);
}
/*
Debugging mem leaks:
- */
+*/
LY_DEFINE (ly_protects, "ly:protects",
0, 0, 0, (),
- "Return hash of protected objects.")
+ "Return hash of protected objects.")
{
return scm_protects;
}
}
LY_DEFINE (ly_output_backend, "ly:output-backend",
- 0, 0, 0, (),
- "Return name of output backend.")
+ 0, 0, 0, (),
+ "Return name of output backend.")
{
return scm_makfrom0str (output_backend_global.to_str0 ());
}
LY_DEFINE (ly_output_formats, "ly:output-formats",
- 0, 0, 0, (),
- "Formats passed to --format as a list of strings, "
- "used for the output.")
+ 0, 0, 0, (),
+ "Formats passed to --format as a list of strings, "
+ "used for the output.")
{
Array<String> output_formats = split_string (output_format_global, ',');
-/*
+/*
note-head-line-engraver.cc -- implement Note_head_line_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#include "warn.hh"
#include "spanner.hh"
virtual bool try_music (Music *);
virtual void process_music ();
private:
- Spanner *line_;
- Spanner *last_line_;
- Music* event_;
+ Spanner *line_;
+ Spanner *last_line_;
+ Music *event_;
};
Glissando_engraver::Glissando_engraver ()
}
bool
-Glissando_engraver::try_music (Music* m)
+Glissando_engraver::try_music (Music *m)
{
if (!event_)
{
}
}
-
void
Glissando_engraver::acknowledge_grob (Grob_info info)
{
if (Rhythmic_head::has_interface (info.grob_))
{
- Grob * g = info.grob_;
+ Grob *g = info.grob_;
if (line_)
line_->set_bound (LEFT, g);
if (last_line_)
last_line_->set_bound (RIGHT, g);
- }
+ }
}
-
void
Glissando_engraver::stop_translation_timestep ()
{
}
if (line_)
{
- if ( last_line_)
+ if (last_line_)
programming_error ("Overwriting glissando.");
last_line_ = line_;
}
{
if (line_)
{
- String msg = _("Unterminated glissando.");
-
+ String msg = _ ("Unterminated glissando.");
+
if (event_)
event_->origin ()->warning (msg);
else
warning (msg);
-
+
line_->suicide ();
line_ = 0;
}
}
-
-
ADD_TRANSLATOR (Glissando_engraver,
-/* descr */ "Engrave a glissandi",
-/* creats*/ "Glissando",
-/* accepts */ "glissando-event",
-/* acks */ "rhythmic-head-interface",
-/* reads */ "followVoice",
-/* write */ "");
+ /* descr */ "Engrave a glissandi",
+ /* creats*/ "Glissando",
+ /* accepts */ "glissando-event",
+ /* acks */ "rhythmic-head-interface",
+ /* reads */ "followVoice",
+ /* write */ "");
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "warn.hh"
LY_DEFINE (ly_format_output, "ly:format-output",
2, 0, 0, (SCM context, SCM outname),
"Given a Global context in its final state, "
- "process it and return the (rendered) result.")
+ "process it and return the (rendered) result.")
{
- Global_context *g = dynamic_cast<Global_context*> (unsmob_context (context));
+ Global_context *g = dynamic_cast<Global_context *> (unsmob_context (context));
SCM_ASSERT_TYPE (g, context, SCM_ARG1, __FUNCTION__, "Global context");
SCM_ASSERT_TYPE (scm_is_string (outname), outname, SCM_ARG2, __FUNCTION__, "output file name");
return output->process (ly_scm2string (outname));
}
-
-LY_DEFINE (ly_run_translator, "ly:run-translator",
+LY_DEFINE (ly_run_translator, "ly:run-translator",
2, 1, 0, (SCM mus, SCM output_def, SCM key),
"Process @var{mus} according to @var{output_def}. \n"
"An interpretation context is set up,\n"
warning (_ ("Need music in a score"));
return SCM_BOOL_F;
}
-
+
SCM_ASSERT_TYPE (music, mus, SCM_ARG1,
__FUNCTION__, "Music");
SCM_ASSERT_TYPE (odef, output_def, SCM_ARG2, __FUNCTION__,
"Output definition");
-
+
Cpu_timer timer;
-
- Global_context *trans = new Global_context (odef, music->get_length (), unsmob_key (key) );
+
+ Global_context *trans = new Global_context (odef, music->get_length (), unsmob_key (key));
if (!trans)
{
programming_error ("no toplevel translator");
}
progress_indication (_ ("Interpreting music... "));
-
+
SCM protected_iter = Music_iterator::get_static_get_iterator (music);
- Music_iterator * iter = unsmob_iterator (protected_iter);
+ Music_iterator *iter = unsmob_iterator (protected_iter);
iter->init_translator (music, trans);
iter->construct_children ();
trans->finish ();
if (be_verbose_global)
- progress_indication (_f ("elapsed time: %.2f seconds", timer.read ()));
-
+ progress_indication (_f ("elapsed time: %.2f seconds", timer.read ()));
+
return scm_gc_unprotect_object (trans->self_scm ());
}
#include "lilypond-key.hh"
Global_context::Global_context (Output_def *o, Moment final, Object_key *key)
- : Context (new Lilypond_context_key(key,
- Moment(0),
- "Global", "", 0))
+ : Context (new Lilypond_context_key (key,
+ Moment (0),
+ "Global", "", 0))
{
output_def_ = o;
final_mom_ = final;
definition_ = find_context_def (o, ly_symbol2scm ("Global"));
- Context_def *globaldef = unsmob_context_def (definition_);
+ Context_def *globaldef = unsmob_context_def (definition_);
if (!globaldef)
{
programming_error ("No `Global' context found.");
accepts_list_ = scm_list_1 (ly_symbol2scm ("Score"));
}
-Output_def*
+Output_def *
Global_context::get_output_def () const
{
return output_def_;
if (m < now_mom_)
programming_error ("Trying to freeze in time.");
-
- for (int i = 0; i < extra_mom_pq_.size (); i++)
+
+ for (int i = 0; i < extra_mom_pq_.size (); i++)
if (extra_mom_pq_[i] == m)
return;
extra_mom_pq_.insert (m);
void
Global_context::prepare (Moment m)
{
- prev_mom_ = now_mom_;
+ prev_mom_ = now_mom_;
now_mom_ = m;
clear_key_disambiguations ();
if (get_score_context ())
get_score_context ()->prepare (m);
-
+
}
Moment
return now_mom_;
}
-Score_context*
+Score_context *
Global_context::get_score_context () const
{
return (scm_is_pair (context_list_))
- ? dynamic_cast<Score_context*> (unsmob_context (scm_car (context_list_)))
+ ? dynamic_cast<Score_context *> (unsmob_context (scm_car (context_list_)))
: 0;
}
-Music_output*
+Music_output *
Global_context::get_output ()
{
return get_score_context ()->get_output ();
}
void
-Global_context::run_iterator_on_me (Music_iterator * iter)
+Global_context::run_iterator_on_me (Music_iterator *iter)
{
if (iter-> ok ())
prev_mom_ = now_mom_ = iter->pending_moment ();
w = sneaky_insert_extra_moment (w);
if (w.main_part_.is_infinity ())
- break ;
-
+ break;
+
if (first)
- {
+ {
/*
Need this to get grace notes at start of a piece correct.
- */
- first = false;
- set_property ("measurePosition", w.smobbed_copy ());
- }
-
+ */
+ first = false;
+ set_property ("measurePosition", w.smobbed_copy ());
+ }
prepare (w);
if (iter->ok ())
iter->process (w);
- if (!get_score_context ())
+ if (!get_score_context ())
{
SCM sym = ly_symbol2scm ("Score");
- Context_def * t = unsmob_context_def (find_context_def (get_output_def (), sym));
+ Context_def *t = unsmob_context_def (find_context_def (get_output_def (), sym));
if (!t)
error (_f ("can't find `%s' context", "Score"));
Context *c = t->instantiate (SCM_EOL, key);
add_context (c);
- Score_context *sc = dynamic_cast<Score_context*> (c);
+ Score_context *sc = dynamic_cast<Score_context *> (c);
sc->prepare (w);
}
-
+
one_time_step ();
}
}
{
SCM lst = get_property ("finalizations");
lst = scm_cons (x, lst);
- set_property ("finalizations", lst);
+ set_property ("finalizations", lst);
}
Moment
-/*
+/*
global-ctor.cc -- implement global constructors
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "global-ctor.hh"
const int HAPPY_DOTS_I = 3;
/**
- Helper to trace back an optimal path
- */
-struct Break_node {
+ Helper to trace back an optimal path
+*/
+struct Break_node
+{
/** this was the previous. If negative, this break should not be
- considered: this path has infinite energy
-
- */
+ considered: this path has infinite energy
+
+ */
int prev_break_;
/**
Which system number so far?
- */
+ */
int line_;
Real demerits_;
Column_x_positions line_config_;
-
- Break_node ()
+
+ Break_node ()
{
prev_break_ = -1;
line_ = 0;
};
void
-print_break_nodes (Array<Break_node> const & arr)
+print_break_nodes (Array<Break_node> const &arr)
{
for (int i = 0; i < arr.size (); i++)
{
- printf ( "node %d: ", i);
+ printf ("node %d: ", i);
arr[i].print ();
- }
+ }
}
/**
- This algorithms is adapted from the OSU Tech report on breaking lines.
+ This algorithms is adapted from the OSU Tech report on breaking lines.
- this function is longish, but not very complicated.
+ this function is longish, but not very complicated.
- TODO: should rewrite. See the function in scm/page-layout.scm for
- inspiration.
-
- */
+ TODO: should rewrite. See the function in scm/page-layout.scm for
+ inspiration.
+*/
Array<Column_x_positions>
Gourlay_breaking::do_solve () const
{
Array<Break_node> optimal_paths;
- Link_array<Grob> all =
- pscore_->system_->columns ();
-
+ Link_array<Grob> all
+ = pscore_->system_->columns ();
+
Array<int> breaks = find_break_indices ();
-
- Break_node first_node ;
+
+ Break_node first_node;
optimal_paths.push (first_node);
bool ragged_right = to_boolean (pscore_->layout_->c_variable ("raggedright"));
bool ragged_last = to_boolean (pscore_->layout_->c_variable ("raggedlast"));
Real worst_force = 0.0;
- for (int break_idx = 1; break_idx< breaks.size (); break_idx++)
+ for (int break_idx = 1; break_idx< breaks.size (); break_idx++)
{
/*
- start with a short line, add measures. At some point
- the line becomes infeasible. Then we don't try to add more
- */
+ start with a short line, add measures. At some point
+ the line becomes infeasible. Then we don't try to add more
+ */
int minimal_start_idx = -1;
Column_x_positions minimal_sol;
Column_x_positions backup_sol;
-
+
Real minimal_demerits = infinity_f;
for (int start_idx = break_idx; start_idx--;)
{
- Link_array<Grob> line = all.slice (breaks[start_idx], breaks[break_idx]+1);
-
- line[0] = dynamic_cast<Item*> (line[0])->find_prebroken_piece (RIGHT);
- line.top () = dynamic_cast<Item*> (line.top ())->find_prebroken_piece (LEFT);
-
+ Link_array<Grob> line = all.slice (breaks[start_idx], breaks[break_idx] + 1);
+
+ line[0] = dynamic_cast<Item *> (line[0])->find_prebroken_piece (RIGHT);
+ line.top () = dynamic_cast<Item *> (line.top ())->find_prebroken_piece (LEFT);
+
Column_x_positions cp;
cp.cols_ = line;
Interval line_dims
= line_dimensions_int (pscore_->layout_, optimal_paths[start_idx].line_);
- Simple_spacer_wrapper * sp = generate_spacing_problem (line, line_dims);
- bool last_line = break_idx == breaks.size ()-1;
+ Simple_spacer_wrapper *sp = generate_spacing_problem (line, line_dims);
+ bool last_line = break_idx == breaks.size () - 1;
bool ragged = ragged_right
|| (last_line && ragged_last);
-
+
sp->solve (&cp, ragged);
-
+
delete sp;
if (ragged && last_line)
cp.force_ = 0.0;
-
+
if (fabs (cp.force_) > worst_force)
worst_force = fabs (cp.force_);
solution", in case everything fucks up. */
if (start_idx == break_idx - 1)
backup_sol = cp;
-
+
Real this_demerits;
if (optimal_paths[start_idx].demerits_ >= infinity_f)
this_demerits = combine_demerits (optimal_paths[start_idx].line_config_, cp)
+ optimal_paths[start_idx].demerits_;
- if (this_demerits < minimal_demerits)
+ if (this_demerits < minimal_demerits)
{
minimal_start_idx = start_idx;
minimal_sol = cp;
if we add more columns, so we get on with the next one
*/
if (!cp.satisfies_constraints_)
- break ;
+ break;
}
-
Break_node bnod;
- if (minimal_start_idx < 0)
+ if (minimal_start_idx < 0)
{
bnod.demerits_ = infinity_f;
bnod.line_config_ = backup_sol;
- bnod.prev_break_ = break_idx - 1;
+ bnod.prev_break_ = break_idx - 1;
}
- else
+ else
{
bnod.prev_break_ = minimal_start_idx;
bnod.demerits_ = minimal_demerits;
}
bnod.line_ = optimal_paths[bnod.prev_break_].line_ + 1;
optimal_paths.push (bnod);
-
+
if (! (break_idx % HAPPY_DOTS_I))
progress_indication (String ("[") + to_string (break_idx) + "]");
}
/* do the last one */
if (breaks.size () % HAPPY_DOTS_I)
- progress_indication (String ("[") + to_string (breaks.size ()) + "]");
+ progress_indication (String ("[") + to_string (breaks.size ()) + "]");
progress_indication ("\n");
Array<Column_x_positions> lines;
/* skip 0-th element, since it is a "dummy" elt*/
- for (int i = optimal_paths.size ()-1; i> 0;)
+ for (int i = optimal_paths.size () - 1; i> 0;)
{
final_breaks.push (i);
int prev = optimal_paths[i].prev_break_;
progress_indication (_f ("Optimal demerits: %f",
optimal_paths.top ().demerits_) + "\n");
}
-
+
if (optimal_paths.top ().demerits_ >= infinity_f)
warning (_ ("No feasible line breaking found"));
-
+
for (int i = final_breaks.size (); i--;)
{
Column_x_positions cp (optimal_paths[final_breaks[i]].line_config_);
-
+
lines.push (cp);
if (!cp.satisfies_constraints_)
warning ("Could not find line breaking that satisfies constraints.");
return lines;
}
-
Gourlay_breaking::Gourlay_breaking ()
{
}
-
-
/*
TODO: uniformity parameter to control rel. importance of spacing differences.
TODO:
mixing break penalties and constraint-failing solutions is confusing.
- */
+*/
Real
Gourlay_breaking::combine_demerits (Column_x_positions const &prev,
Column_x_positions const &this_one) const
{
Real break_penalties = 0.0;
- Grob * pc = this_one.cols_.top ();
+ Grob *pc = this_one.cols_.top ();
if (pc->original_)
{
SCM pen = pc->get_property ("penalty");
becoming denser, the uniformity requirement makes lines go from
cramped to even more cramped (because going from cramped
3meas/line to relatively loose 2meas/line is such a big step.
-
- */
- Real demerit = abs (this_one.force_) + abs (prev.force_ - this_one.force_)
+ */
+
+ Real demerit = abs (this_one.force_) + abs (prev.force_ - this_one.force_)
+ break_penalties;
-
+
if (!this_one.satisfies_constraints_)
- {
- /*
- If it doesn't satisfy constraints, we make this one
- really unattractive.
-
- add 20000 to the demerits, so that a break penalty
- of -10000 won't change the result */
- demerit = (demerit + 20000) >? 2000;
-
- demerit *= 10;
- }
-
- return demerit;
+ {
+ /*
+ If it doesn't satisfy constraints, we make this one
+ really unattractive.
+
+ add 20000 to the demerits, so that a break penalty
+ of -10000 won't change the result */
+ demerit = (demerit + 20000) >? 2000;
+
+ demerit *= 10;
+ }
+
+ return demerit;
}
-/*
+/*
grace-engraver.cc -- implement Grace_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "engraver.hh"
protected:
virtual void start_translation_timestep ();
virtual void derived_mark ();
-
+
TRANSLATOR_DECLARATIONS (Grace_engraver);
Moment last_moment_;
SCM grace_settings_;
public:
};
-
-Grace_engraver::Grace_engraver()
+Grace_engraver::Grace_engraver ()
{
grace_settings_ = SCM_EOL;
}
SCM val = scm_cadr (scm_cddr (entry));
Context *c = context ();
- while (c
+ while (c
&& c->context_name_symbol () != context_name)
{
- c = c->get_parent_context ();
+ c = c->get_parent_context ();
}
- if (c)
+ if (c)
{
execute_pushpop_property (c,
grob, sym, val);
grace_settings_
- = scm_cons (scm_cons (c->self_scm(), entry), grace_settings_);
+ = scm_cons (scm_cons (c->self_scm (), entry), grace_settings_);
}
else
{
programming_error ("Cannot find context");
- scm_display (context_name, scm_current_error_port());
+ scm_display (context_name, scm_current_error_port ());
}
}
}
last_moment_ = now;
}
-
ADD_TRANSLATOR (Grace_engraver,
- /* descr */ "Set font size and other properties for grace notes.",
- /* creats*/ "",
- /* accepts */ "",
- /* acks */ "",
- /* reads */ "graceSettings",
- /* write */ "");
+ /* descr */ "Set font size and other properties for grace notes.",
+ /* creats*/ "",
+ /* accepts */ "",
+ /* acks */ "",
+ /* reads */ "graceSettings",
+ /* write */ "");
-/*
+/*
grace-music.cc -- implement Grace_music
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "grace-iterator.hh"
#include "global-context.hh"
Grace_iterator::process (Moment m)
{
Moment main;
- main.main_part_ = - start_mom_.grace_part_ + m.grace_part_;
+ main.main_part_ = -start_mom_.grace_part_ + m.grace_part_;
Music_wrapper_iterator::process (main);
/* We can safely do this, since \grace should always be inside
Moment cp = Music_wrapper_iterator::pending_moment ();
Moment pending;
- pending.grace_part_ = start_mom_.grace_part_ + cp.main_part_;
+ pending.grace_part_ = start_mom_.grace_part_ + cp.main_part_;
return pending;
}
-
IMPLEMENT_CTOR_CALLBACK (Grace_iterator);
-/*
- grace-music.cc -- implement Grace_music
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
+/*
+ grace-music.cc -- implement Grace_music
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "music.hh"
class Grace_music
{
public:
- DECLARE_SCHEME_CALLBACK(start_callback, (SCM));
+ DECLARE_SCHEME_CALLBACK (start_callback, (SCM));
};
-MAKE_SCHEME_CALLBACK(Grace_music, start_callback, 1);
+MAKE_SCHEME_CALLBACK (Grace_music, start_callback, 1);
SCM
-Grace_music::start_callback (SCM m)
+Grace_music::start_callback (SCM m)
{
Moment *l = unsmob_moment (Music_wrapper::length_callback (m));
Moment gl;
- gl.grace_part_ = -(l->main_part_ + l->grace_part_ );
+ gl.grace_part_ = -(l->main_part_ + l->grace_part_);
return gl.smobbed_copy ();
}
/*
gregorian-ligature-engraver.cc -- implement Gregorian_ligature_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2003--2005 Juergen Reuter <reuter@ipd.uka.de>
- */
+*/
#include "gregorian-ligature-engraver.hh"
/* Check for illegal head modifier combinations */
for (int i = 0; i < primitives.size (); i++)
{
- Grob *primitive = primitives[i].grob_;
+ Grob *primitive = primitives[i].grob_;
- /* compute head prefix set by inspecting primitive grob properties */
- int prefix_set =
- (VIRGA * to_boolean (primitive->get_property ("virga"))) |
- (STROPHA * to_boolean (primitive->get_property ("stropha"))) |
- (INCLINATUM * to_boolean (primitive->get_property ("inclinatum"))) |
- (AUCTUM * to_boolean (primitive->get_property ("auctum"))) |
- (DESCENDENS * to_boolean (primitive->get_property ("descendens"))) |
- (ASCENDENS * to_boolean (primitive->get_property ("ascendens"))) |
- (ORISCUS * to_boolean (primitive->get_property ("oriscus"))) |
- (QUILISMA * to_boolean (primitive->get_property ("quilisma"))) |
- (DEMINUTUM * to_boolean (primitive->get_property ("deminutum"))) |
- (CAVUM * to_boolean (primitive->get_property ("cavum"))) |
- (LINEA * to_boolean (primitive->get_property ("linea"))) |
- (PES_OR_FLEXA * to_boolean (primitive->get_property ("pes-or-flexa")));
+ /* compute head prefix set by inspecting primitive grob properties */
+ int prefix_set
+ = (VIRGA *to_boolean (primitive->get_property ("virga"))) |
+ (STROPHA *to_boolean (primitive->get_property ("stropha"))) |
+ (INCLINATUM *to_boolean (primitive->get_property ("inclinatum"))) |
+ (AUCTUM *to_boolean (primitive->get_property ("auctum"))) |
+ (DESCENDENS *to_boolean (primitive->get_property ("descendens"))) |
+ (ASCENDENS *to_boolean (primitive->get_property ("ascendens"))) |
+ (ORISCUS *to_boolean (primitive->get_property ("oriscus"))) |
+ (QUILISMA *to_boolean (primitive->get_property ("quilisma"))) |
+ (DEMINUTUM *to_boolean (primitive->get_property ("deminutum"))) |
+ (CAVUM *to_boolean (primitive->get_property ("cavum"))) |
+ (LINEA *to_boolean (primitive->get_property ("linea"))) |
+ (PES_OR_FLEXA *to_boolean (primitive->get_property ("pes-or-flexa")));
- /* check: ascendens and descendens exclude each other; same with
- auctum and deminutum */
- if (prefix_set & DESCENDENS)
- {
- fix_prefix_set (&prefix_set,
- prefix_set & ~ASCENDENS,
- prefix_set & ~ASCENDENS,
- primitive);
- }
- if (prefix_set & AUCTUM)
- {
- fix_prefix_set (&prefix_set,
- prefix_set & ~DEMINUTUM,
- prefix_set & ~DEMINUTUM,
- primitive);
- }
-
- /* check: virga, quilisma and oriscus can not be combined with any
- other prefix, but may be part of a pes or flexa */
- if (prefix_set & VIRGA)
- {
- fix_prefix_set (&prefix_set,
- VIRGA,
- VIRGA | PES_OR_FLEXA,
- primitive);
- }
- if (prefix_set & QUILISMA)
- {
- fix_prefix_set (&prefix_set,
- QUILISMA,
- QUILISMA | PES_OR_FLEXA,
- primitive);
- }
- if (prefix_set & ORISCUS)
- {
- fix_prefix_set (&prefix_set,
- ORISCUS,
- ORISCUS | PES_OR_FLEXA,
- primitive);
- }
+ /* check: ascendens and descendens exclude each other; same with
+ auctum and deminutum */
+ if (prefix_set & DESCENDENS)
+ {
+ fix_prefix_set (&prefix_set,
+ prefix_set & ~ASCENDENS,
+ prefix_set & ~ASCENDENS,
+ primitive);
+ }
+ if (prefix_set & AUCTUM)
+ {
+ fix_prefix_set (&prefix_set,
+ prefix_set & ~DEMINUTUM,
+ prefix_set & ~DEMINUTUM,
+ primitive);
+ }
- /* check: auctum is the only valid optional prefix for stropha */
- if (prefix_set & STROPHA)
- {
- fix_prefix_set (&prefix_set,
- STROPHA,
- STROPHA | AUCTUM,
- primitive);
- }
+ /* check: virga, quilisma and oriscus can not be combined with any
+ other prefix, but may be part of a pes or flexa */
+ if (prefix_set & VIRGA)
+ {
+ fix_prefix_set (&prefix_set,
+ VIRGA,
+ VIRGA | PES_OR_FLEXA,
+ primitive);
+ }
+ if (prefix_set & QUILISMA)
+ {
+ fix_prefix_set (&prefix_set,
+ QUILISMA,
+ QUILISMA | PES_OR_FLEXA,
+ primitive);
+ }
+ if (prefix_set & ORISCUS)
+ {
+ fix_prefix_set (&prefix_set,
+ ORISCUS,
+ ORISCUS | PES_OR_FLEXA,
+ primitive);
+ }
+ /* check: auctum is the only valid optional prefix for stropha */
+ if (prefix_set & STROPHA)
+ {
+ fix_prefix_set (&prefix_set,
+ STROPHA,
+ STROPHA | AUCTUM,
+ primitive);
+ }
- /* check: inclinatum may be prefixed with auctum or deminutum only */
- if (prefix_set & INCLINATUM)
- {
- fix_prefix_set (&prefix_set,
- INCLINATUM,
- INCLINATUM | AUCTUM | DEMINUTUM,
- primitive);
- }
- /* check: semivocalis (deminutum but not inclinatum) must occur in
- combination with and only with pes or flexa */
- else if (prefix_set & DEMINUTUM)
- {
- fix_prefix_set (&prefix_set,
- DEMINUTUM | PES_OR_FLEXA,
- DEMINUTUM | PES_OR_FLEXA,
- primitive);
- }
+ /* check: inclinatum may be prefixed with auctum or deminutum only */
+ if (prefix_set & INCLINATUM)
+ {
+ fix_prefix_set (&prefix_set,
+ INCLINATUM,
+ INCLINATUM | AUCTUM | DEMINUTUM,
+ primitive);
+ }
+ /* check: semivocalis (deminutum but not inclinatum) must occur in
+ combination with and only with pes or flexa */
+ else if (prefix_set & DEMINUTUM)
+ {
+ fix_prefix_set (&prefix_set,
+ DEMINUTUM | PES_OR_FLEXA,
+ DEMINUTUM | PES_OR_FLEXA,
+ primitive);
+ }
- /* check: cavum and linea (either or both) may be applied only
- upon core punctum */
- if (prefix_set & (CAVUM | LINEA))
- {
- fix_prefix_set (&prefix_set,
- 0,
- CAVUM | LINEA,
- primitive);
- }
+ /* check: cavum and linea (either or both) may be applied only
+ upon core punctum */
+ if (prefix_set & (CAVUM | LINEA))
+ {
+ fix_prefix_set (&prefix_set,
+ 0,
+ CAVUM | LINEA,
+ primitive);
+ }
- /* all other combinations should be valid (unless I made a
- mistake) */
+ /* all other combinations should be valid (unless I made a
+ mistake) */
- primitive->set_property ("prefix-set", scm_int2num (prefix_set));
- }
+ primitive->set_property ("prefix-set", scm_int2num (prefix_set));
+ }
}
/*
int prev_prefix_set = 0;
int prev_context_info = 0;
int prev_pitch = 0;
- for (int i = 0; i < primitives.size (); i++) {
- Grob *primitive = primitives[i].grob_;
- Music *music_cause = primitives[i].music_cause ();
- int context_info = 0;
- int pitch = unsmob_pitch (music_cause->get_property ("pitch"))->steps ();
- int prefix_set = scm_to_int (primitive->get_property ("prefix-set"));
+ for (int i = 0; i < primitives.size (); i++)
+ {
+ Grob *primitive = primitives[i].grob_;
+ Music *music_cause = primitives[i].music_cause ();
+ int context_info = 0;
+ int pitch = unsmob_pitch (music_cause->get_property ("pitch"))->steps ();
+ int prefix_set = scm_to_int (primitive->get_property ("prefix-set"));
- if (prefix_set & PES_OR_FLEXA)
- if (!i) // ligature may not start with 2nd head of pes or flexa
+ if (prefix_set & PES_OR_FLEXA)
+ if (!i) // ligature may not start with 2nd head of pes or flexa
{
primitive->warning ("may not apply `\\~' on first head of "
"ligature; ignoring `\\~'");
}
- else if (pitch > prev_pitch) // pes
- {
- prev_context_info |= PES_LOWER;
- context_info |= PES_UPPER;
- }
- else if (pitch < prev_pitch) // flexa
- {
- prev_context_info |= FLEXA_LEFT;
- context_info |= FLEXA_RIGHT;
- }
- else // (pitch == prev_pitch)
+ else if (pitch > prev_pitch) // pes
+ {
+ prev_context_info |= PES_LOWER;
+ context_info |= PES_UPPER;
+ }
+ else if (pitch < prev_pitch) // flexa
+ {
+ prev_context_info |= FLEXA_LEFT;
+ context_info |= FLEXA_RIGHT;
+ }
+ else // (pitch == prev_pitch)
+ {
+ primitive->warning ("may not apply `\\~' on heads with "
+ "identical pitch; ignoring `\\~'");
+ }
+ if (prev_prefix_set & DEMINUTUM)
{
- primitive->warning ("may not apply `\\~' on heads with "
- "identical pitch; ignoring `\\~'");
+ context_info |= AFTER_DEMINUTUM;
}
- if (prev_prefix_set & DEMINUTUM)
- {
- context_info |= AFTER_DEMINUTUM;
- }
- if (prev_primitive)
- prev_primitive->set_property ("context-info",
- scm_int2num (prev_context_info));
- prev_primitive = primitive;
- prev_prefix_set = prefix_set;
- prev_context_info = context_info;
- prev_pitch = pitch;
- }
+ if (prev_primitive)
+ prev_primitive->set_property ("context-info",
+ scm_int2num (prev_context_info));
+ prev_primitive = primitive;
+ prev_prefix_set = prefix_set;
+ prev_context_info = context_info;
+ prev_pitch = pitch;
+ }
if (prev_primitive)
prev_primitive->set_property ("context-info",
- scm_int2num (prev_context_info));
+ scm_int2num (prev_context_info));
}
void
}
ADD_TRANSLATOR (Gregorian_ligature_engraver,
-/* descr */ "This is an abstract class. Subclasses such as Vaticana_ligature_engraver handle ligatures by glueing special ligature heads together.",
-/* creats*/ "",
-/* accepts */ "ligature-event",
-/* acks */ "note-head-interface rest-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "This is an abstract class. Subclasses such as Vaticana_ligature_engraver handle ligatures by glueing special ligature heads together.",
+ /* creats*/ "",
+ /* accepts */ "ligature-event",
+ /* acks */ "note-head-interface rest-interface",
+ /* reads */ "",
+ /* write */ "");
-/*
+/*
gregorian-ligature.cc -- implement Gregorian_ligature
source file of the GNU LilyPond music typesetter
Gregorian_ligature::prefixes_to_str (Grob *primitive)
{
String str;
- int prefix_set =
- scm_to_int (primitive->get_property ("prefix-set"));
+ int prefix_set
+ = scm_to_int (primitive->get_property ("prefix-set"));
check_prefix ("virga", VIRGA, prefix_set, &str);
check_prefix ("stropha", STROPHA, prefix_set, &str);
check_prefix ("inclinatum", INCLINATUM, prefix_set, &str);
by code of GregorianLigatureEngraver that is virtually invoked by a
subclass like VaticanaLigatureEngraver. The property is lateron
read by the associated item class, such as VaticanaLigature.--jr
- */
+*/
ADD_INTERFACE (Gregorian_ligature, "gregorian-ligature-interface",
"A gregorian ligature",
"virga stropha inclinatum auctum descendens ascendens "
origin_trans_ = 0;
}
-Music*
+Music *
Grob_info::music_cause ()
{
- SCM cause = grob_->get_property ("cause");
+ SCM cause = grob_->get_property ("cause");
return unsmob_music (cause);
}
Link_array<Context>
-Grob_info::origin_contexts (Translator* end) const
+Grob_info::origin_contexts (Translator *end) const
{
- Context * t = origin_trans_->context ();
+ Context *t = origin_trans_->context ();
Link_array<Context> r;
- do {
- r.push (t);
- t = t->get_parent_context ();
- } while (t && t != end->context ());
-
+ do
+ {
+ r.push (t);
+ t = t->get_parent_context ();
+ }
+ while (t && t != end->context ());
+
return r;
}
-
+
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "lily-guile.hh"
Protected_scm all_ifaces;
LY_DEFINE (ly_add_interface, "ly:add-interface", 3, 0, 0, (SCM a, SCM b, SCM c),
- "Add an interface description.")
+ "Add an interface description.")
{
SCM_ASSERT_TYPE (scm_is_symbol (a), a, SCM_ARG1, __FUNCTION__, "symbol");
- SCM_ASSERT_TYPE (scm_is_string (b), b, SCM_ARG2, __FUNCTION__, "string");
+ SCM_ASSERT_TYPE (scm_is_string (b), b, SCM_ARG2, __FUNCTION__, "string");
SCM_ASSERT_TYPE (ly_c_list_p (c), c, SCM_ARG3, __FUNCTION__, "list of syms");
if (!scm_is_vector (all_ifaces))
all_ifaces = scm_make_vector (scm_int2num (40), SCM_EOL);
return SCM_UNSPECIFIED;
}
-
LY_DEFINE (ly_all_grob_interfaces, "ly:all-grob-interfaces",
- 0, 0, 0, (),
- "Get a hash table with all interface descriptions.")
+ 0, 0, 0, (),
+ "Get a hash table with all interface descriptions.")
{
return all_ifaces;
}
#include "grob.hh"
#include "warn.hh"
-void add_interface (const char * symbol,
- const char * descr,
- const char * vars)
+void add_interface (const char *symbol,
+ const char *descr,
+ const char *vars)
{
SCM s = ly_symbol2scm (symbol);
SCM d = scm_makfrom0str (descr);
ly_add_interface (s, d, l);
}
-
-
void
check_interfaces_for_property (Grob const *me, SCM sym)
{
{
/*
otherwise we get in a nasty recursion loop.
- */
- return ;
+ */
+ return;
}
SCM ifs = me->get_property ("interfaces");
bool found = false;
for (; !found && scm_is_pair (ifs); ifs = scm_cdr (ifs))
{
- SCM iface = scm_hashq_ref (all_ifaces , scm_car (ifs), SCM_BOOL_F);
+ SCM iface = scm_hashq_ref (all_ifaces, scm_car (ifs), SCM_BOOL_F);
if (iface == SCM_BOOL_F)
{
String msg = to_string (_f ("Unknown interface `%s'",
-/*
-grob-pitch-tuple.cc -- implement Grob_pitch_tuple
-
-source file of the GNU LilyPond music typesetter
+/*
+ grob-pitch-tuple.cc -- implement Grob_pitch_tuple
-(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ source file of the GNU LilyPond music typesetter
- */
+ (c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#include "grob-pitch-tuple.hh"
}
-
-
Grob_pitch_tuple::Grob_pitch_tuple ()
{
head_ = 0;
}
/*
- signed compare, should use pitch<?
- */
+ signed compare, should use pitch<?
+*/
int
Grob_pitch_tuple::pitch_compare (Grob_pitch_tuple const &h1,
- Grob_pitch_tuple const &h2)
+ Grob_pitch_tuple const &h2)
{
return Pitch::compare (h1.pitch_, h2.pitch_);
}
int
-Grob_pitch_tuple::time_compare (Grob_pitch_tuple const&h1,
- Grob_pitch_tuple const &h2)
+Grob_pitch_tuple::time_compare (Grob_pitch_tuple const &h1,
+ Grob_pitch_tuple const &h2)
{
- return Moment::compare (h1.end_, h2.end_);
+ return Moment::compare (h1.end_, h2.end_);
}
-/*
+/*
grob-pq-engraver.cc -- implement Grob_pq_engraver
source file of the GNU LilyPond music typesetter
virtual void stop_translation_timestep ();
};
-
Grob_pq_engraver::Grob_pq_engraver ()
{
}
void
Grob_pq_engraver::initialize ()
{
- context ()->set_property ("busyGrobs", SCM_EOL);
+ context ()->set_property ("busyGrobs", SCM_EOL);
}
LY_DEFINE (ly_grob_pq_less_p, "ly:grob-pq-less?",
- 2, 0 , 0, (SCM a, SCM b),
- "Compare 2 grob priority queue entries. Internal")
+ 2, 0, 0, (SCM a, SCM b),
+ "Compare 2 grob priority queue entries. Internal")
{
if (Moment::compare (*unsmob_moment (scm_car (a)),
*unsmob_moment (scm_car (b))) < 0)
else
return SCM_BOOL_F;
}
-
+
void
Grob_pq_engraver::acknowledge_grob (Grob_info gi)
{
- Music * m = gi.music_cause ();
+ Music *m = gi.music_cause ();
if (m
&& !gi.grob_->internal_has_interface (ly_symbol2scm ("multi-measure-interface")))
Moment l = m->get_length ();
if (!l.to_bool ())
- return ;
-
+ return;
+
if (n.grace_part_)
{
l.grace_part_ = l.main_part_;
Moment end = n + l;
SCM lst = scm_acons (end.smobbed_copy (),
- gi.grob_->self_scm (),
- SCM_EOL);
+ gi.grob_->self_scm (),
+ SCM_EOL);
SCM busy = get_property ("busyGrobs");
busy = scm_merge_x (lst, busy, ly_grob_pq_less_p_proc);
}
}
-
void
Grob_pq_engraver::stop_translation_timestep ()
{
/*
The grob-pq-engraver is not water tight, and stuff like
tupletSpannerDuration confuses it.
- */
+ */
busy = scm_cdr (busy);
}
context ()->set_property ("busyGrobs", busy);
}
-
ADD_TRANSLATOR (Grob_pq_engraver,
-/* descr */ "Administrate when certain grobs (eg. note heads) stop playing; this \
+ /* descr */ "Administrate when certain grobs (eg. note heads) stop playing; this \
engraver is a sort-of a failure, since it doesn't handle all sorts of \
borderline cases very well. \
-", \
-
-/* creats*/ "", \
-/* accepts */ "", \
-/* acks */ "grob-interface", \
-/* reads */ "busyGrobs", \
-/* write */ "busyGrobs");
+",
+
+ /* creats*/ "",\
+ /* accepts */ "",\
+ /* acks */ "grob-interface",\
+ /* reads */ "busyGrobs",\
+ /* write */ "busyGrobs");
/*
Implement storage and manipulation of grob properties.
- */
+*/
#include <cstring>
#include <math.h>
#include "misc.hh"
#include "item.hh"
-
SCM
Grob::get_property_alist_chain (SCM def) const
{
SCM_UNDEFINED);
}
-
-
/*
This special add_thing routine is slightly more efficient than
- set_prop (name, cons (thing, get_prop (name)))
+ set_prop (name, cons (thing, get_prop (name)))
since it can reuse the handle returned by scm_assq ().
*/
void
-Grob::add_to_list_property (SCM sym, SCM thing)
+Grob::add_to_list_property (SCM sym, SCM thing)
{
SCM handle
- = scm_sloppy_assq (sym, mutable_property_alist_)
- ;
+ = scm_sloppy_assq (sym, mutable_property_alist_);
if (handle != SCM_BOOL_F)
{
SCM val = scm_cons (thing, tail);
mutable_property_alist_ = scm_cons (scm_cons (sym, val),
- mutable_property_alist_);
+ mutable_property_alist_);
}
}
-
extern void check_interfaces_for_property (Grob const *me, SCM sym);
void
mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, s, v);
}
-
SCM
Grob::internal_get_property (SCM sym) const
{
return scm_cdr (s);
s = scm_sloppy_assq (sym, immutable_property_alist_);
-
+
if (do_internal_type_checking_global && scm_is_pair (s))
{
if (!type_check_assignment (sym, scm_cdr (s),
check_interfaces_for_property (this, sym);
}
- return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s);
+ return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s);
}
void
mutable_property_alist_ = substitute_mutable_property_alist (orig);
}
-
bool
Grob::is_live () const
{
source file of the GNU LilyPond music typesetter
(c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "warn.hh"
LY_DEFINE (ly_grob_property, "ly:grob-property",
2, 0, 0, (SCM grob, SCM sym),
- "Return the value of a value in grob @var{g} of property @var{sym}. "
+ "Return the value of a value in grob @var{g} of property @var{sym}. "
"It will return @code{' ()} (end-of-list) "
"if @var{sym} is undefined in @var{g}."
- "\n\n"
- )
+ "\n\n")
{
Grob *sc = unsmob_grob (grob);
SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
"Get one of the bounds of @var{spanner}. @var{dir} is @code{-1} "
"for left, and @code{1} for right.")
{
- Spanner * sl = dynamic_cast<Spanner*> (unsmob_grob (slur));
+ Spanner *sl = dynamic_cast<Spanner *> (unsmob_grob (slur));
SCM_ASSERT_TYPE (sl, slur, SCM_ARG1, __FUNCTION__, "spanner grob");
SCM_ASSERT_TYPE (is_direction (dir), slur, SCM_ARG2, __FUNCTION__, "dir");
return sl->get_bound (to_dir (dir))->self_scm ();
1, 0, 0, (SCM g),
"Get @code{\\layout} definition from grob @var{g}.")
{
- Grob * sc = unsmob_grob (g);
+ Grob *sc = unsmob_grob (g);
SCM_ASSERT_TYPE (sc, g, SCM_ARG1, __FUNCTION__, "grob");
return sc->get_layout ()->self_scm ();
SCM_ASSERT_TYPE (ref, refp, SCM_ARG2, __FUNCTION__, "grob");
SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
- return ly_interval2scm ( sc->extent (ref, Axis (scm_to_int (axis))));
+ return ly_interval2scm (sc->extent (ref, Axis (scm_to_int (axis))));
}
LY_DEFINE (ly_grob_parent, "ly:grob-parent",
1, 0, 0, (SCM spanner),
"Return broken-into list for @var{spanner}.")
{
- Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (spanner));
+ Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (spanner));
SCM_ASSERT_TYPE (me, spanner, SCM_ARG1, __FUNCTION__, "spanner");
SCM s = SCM_EOL;
"Is @var{g} a spanner object?")
{
Grob *me = unsmob_grob (g);
- bool b = dynamic_cast<Spanner*> (me);
+ bool b = dynamic_cast<Spanner *> (me);
return ly_bool2scm (b);
}
"Is @var{g} an @code{Item} object?")
{
Grob *me = unsmob_grob (g);
- bool b = dynamic_cast<Item*> (me);
+ bool b = dynamic_cast<Item *> (me);
return ly_bool2scm (b);
}
"The break status dir of item @var{it}. @code{-1} is end of "
"line, @code{0} unbroken, and @code{1} begin of line.")
{
- Item *me = dynamic_cast<Item*> (unsmob_grob (it));
+ Item *me = dynamic_cast<Item *> (unsmob_grob (it));
SCM_ASSERT_TYPE (me, it, SCM_ARG1, __FUNCTION__, "Item");
return scm_int2num (me->break_status_dir ());
}
-
-LY_DEFINE(ly_grob_key, "ly:grob-key",
- 1, 0, 0,
- (SCM grob),
- "Return the object-key for @var{grob}."
- )
+LY_DEFINE (ly_grob_key, "ly:grob-key",
+ 1, 0, 0,
+ (SCM grob),
+ "Return the object-key for @var{grob}.")
{
Grob *me = unsmob_grob (grob);
SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "Grob");
#include "ly-smobs.icc"
-Grob *
+Grob *
Grob::clone (int count) const
{
return new Grob (*this, count);
/* TODO:
- - remove dynamic_cast<Spanner, Item> and put this code into respective
- subclass. */
+- remove dynamic_cast<Spanner, Item> and put this code into respective
+subclass. */
#define HASH_SIZE 3
#define INFINITY_MSG "Infinity or NaN encountered"
Grob::Grob (SCM basicprops,
- Object_key const* key)
+ Object_key const *key)
{
key_ = key;
/* FIXME: default should be no callback. */
pscore_ = 0;
status_ = 0;
original_ = 0;
- immutable_property_alist_ = basicprops;
+ immutable_property_alist_ = basicprops;
mutable_property_alist_ = SCM_EOL;
/* We do smobify_self () as the first step. Since the object lives
/*
We always get a new key object for a new grob.
- */
+ */
scm_gc_unprotect_object (key_->self_scm ());
SCM meta = get_property ("meta");
if (scm_is_pair (meta))
/* TODO:
- - destill this into a function, so we can re-init the immutable
- properties with a new BASICPROPS value after
- creation. Convenient eg. when using \override with
- StaffSymbol. */
+ - destill this into a function, so we can re-init the immutable
+ properties with a new BASICPROPS value after
+ creation. Convenient eg. when using \override with
+ StaffSymbol. */
- char const*onames[] = {"X-offset-callbacks", "Y-offset-callbacks"};
- char const*xnames[] = {"X-extent", "Y-extent"};
- char const*enames[] = {"X-extent-callback", "Y-extent-callback"};
+ char const *onames[] = {"X-offset-callbacks", "Y-offset-callbacks"};
+ char const *xnames[] = {"X-extent", "Y-extent"};
+ char const *enames[] = {"X-extent-callback", "Y-extent-callback"};
for (int a = X_AXIS; a <= Y_AXIS; a++)
{
{
dim_cache_[a].dimension_ = SCM_BOOL_F;
}
-
+
SCM xt = get_property (xnames[a]);
if (is_number_pair (xt))
{
}
Grob::Grob (Grob const &s, int copy_index)
- : dim_cache_ (s.dim_cache_)
+ : dim_cache_ (s.dim_cache_)
{
key_ = new Copied_key (s.key_, copy_index);
- original_ = (Grob*) &s;
+ original_ = (Grob *) &s;
self_scm_ = SCM_EOL;
immutable_property_alist_ = s.immutable_property_alist_;
return ly_interval2scm (e);
}
-
Interval
-robust_relative_extent (Grob*me, Grob*refp, Axis a)
+robust_relative_extent (Grob *me, Grob *refp, Axis a)
{
- Interval ext = me->extent (refp, a);
- if (ext.is_empty())
+ Interval ext = me->extent (refp, a);
+ if (ext.is_empty ())
{
ext.add_point (me->relative_coordinate (refp, a));
}
- return ext;
+ return ext;
}
Output_def *
Grob::get_layout () const
{
- return pscore_ ? pscore_->layout_ : 0;
+ return pscore_ ? pscore_->layout_ : 0;
}
-
/* Recursively track all dependencies of this Grob. The status_ field
is used as a mark-field. It is marked with BUSY during execution
of this function, and marked with FINAL when finished.
}
Stencil *
-Grob::get_stencil () const
+Grob::get_stencil () const
{
if (!is_live ())
return 0;
stil = get_uncached_stencil ();
if (is_live ())
{
- Grob *me = (Grob*) this;
+ Grob *me = (Grob *) this;
me->set_property ("stencil", stil);
}
stil = scm_apply_0 (proc, scm_list_n (this->self_scm (), SCM_UNDEFINED));
if (Stencil *m = unsmob_stencil (stil))
- {
+ {
if (to_boolean (get_property ("transparent")))
stil = Stencil (m->extent_box (), SCM_EOL).smobbed_copy ();
else
{
- SCM expr = scm_list_3 (ly_symbol2scm ("grob-cause"), self_scm(),
+ SCM expr = scm_list_3 (ly_symbol2scm ("grob-cause"), self_scm (),
m->expr ());
stil = Stencil (m->extent_box (), expr). smobbed_copy ();
}
color,
m->expr ());
- stil = Stencil (m->extent_box (), expr).smobbed_copy();
+ stil = Stencil (m->extent_box (), expr).smobbed_copy ();
}
- }
+ }
return stil;
}
/*
VIRTUAL STUBS
- */
+*/
void
Grob::do_break_processing ()
{
void
Grob::handle_broken_dependencies ()
{
- Spanner *sp = dynamic_cast<Spanner*> (this);
+ Spanner *sp = dynamic_cast<Spanner *> (this);
if (original_ && sp)
return;
substitute_mutable_properties (system
? system->self_scm () : SCM_UNDEFINED,
mutable_property_alist_);
- else if (dynamic_cast <System*> (this))
+ else if (dynamic_cast<System *> (this))
substitute_mutable_properties (SCM_UNDEFINED, mutable_property_alist_);
else
/* THIS element is `invalid'; it has been removed from all
mutable_property_alist_ centralized. */
if (original_)
{
- Item *it = dynamic_cast<Item*> (this);
+ Item *it = dynamic_cast<Item *> (this);
substitute_mutable_properties (scm_int2num (it->break_status_dir ()),
original_->mutable_property_alist_);
}
dim_cache_[a].offset_ += y;
}
-
/* Find the offset relative to D. If D equals THIS, then it is 0.
Otherwise, it recursively defd as
Real
Grob::get_offset (Axis a) const
{
- Grob *me = (Grob*) this;
+ Grob *me = (Grob *) this;
while (dim_cache_[a].offsets_left_)
{
int l = --me->dim_cache_[a].offsets_left_;
SCM cb = scm_list_ref (dim_cache_[a].offset_callbacks_, scm_int2num (l));
SCM retval = scm_call_2 (cb, self_scm (), scm_int2num (a));
- Real r = scm_to_double (retval);
+ Real r = scm_to_double (retval);
if (isinf (r) || isnan (r))
{
programming_error (INFINITY_MSG);
void
Grob::flush_extent_cache (Axis axis)
{
- Dimension_cache * d = &dim_cache_[axis];
+ Dimension_cache *d = &dim_cache_[axis];
if (ly_c_procedure_p (d->dimension_callback_)
&& scm_is_pair (d->dimension_))
{
d->dimension_ = SCM_EOL;
-
if (get_parent (axis))
- get_parent(axis)->flush_extent_cache (axis);
+ get_parent (axis)->flush_extent_cache (axis);
}
}
Interval ext;
SCM dimpair = d->dimension_;
- if (scm_is_pair (dimpair))
- ;
+ if (scm_is_pair (dimpair));
else if (ly_c_procedure_p (d->dimension_callback_)
&& d->dimension_ == SCM_EOL)
d->dimension_ = scm_call_2 (d->dimension_callback_, self_scm (), scm_int2num (a));
for (Grob const *c = this; c; c = c->dim_cache_[a].parent_)
for (Grob const *d = s; d; d = d->dim_cache_[a].parent_)
if (d == c)
- return (Grob*) d;
+ return (Grob *) d;
return 0;
}
Grob *
common_refpoint_of_array (Link_array<Grob> const &arr, Grob *common, Axis a)
{
- for (int i = arr.size (); i--; )
+ for (int i = arr.size (); i--;)
if (Grob *s = arr[i])
{
if (common)
Grob::add_offset_callback (SCM cb, Axis a)
{
if (!has_offset_callback (cb, a))
- {
- dim_cache_[a].offset_callbacks_
- = scm_cons (cb, dim_cache_[a].offset_callbacks_);
- dim_cache_[a].offsets_left_ ++;
- }
+ {
+ dim_cache_[a].offset_callbacks_
+ = scm_cons (cb, dim_cache_[a].offset_callbacks_);
+ dim_cache_[a].offsets_left_++;
+ }
}
bool
Grob::fixup_refpoint (SCM smob)
{
Grob *me = unsmob_grob (smob);
- for (int a = X_AXIS; a < NO_AXES; a ++)
+ for (int a = X_AXIS; a < NO_AXES; a++)
{
Axis ax = (Axis)a;
Grob *parent = me->get_parent (ax);
me->set_parent (newparent, ax);
}
- if (Item *i = dynamic_cast<Item*> (me))
+ if (Item *i = dynamic_cast<Item *> (me))
{
- Item *parenti = dynamic_cast<Item*> (parent);
+ Item *parenti = dynamic_cast<Item *> (parent);
if (parenti && i)
{
- Direction my_dir = i->break_status_dir () ;
+ Direction my_dir = i->break_status_dir ();
if (my_dir!= parenti->break_status_dir ())
{
Item *newparent = parenti->find_prebroken_piece (my_dir);
warning (s);
}
-
/****************************************************
SMOB funcs
- ****************************************************/
+****************************************************/
IMPLEMENT_SMOBS (Grob);
IMPLEMENT_DEFAULT_EQUAL_P (Grob);
SCM
Grob::mark_smob (SCM ses)
{
- Grob *s = (Grob*) SCM_CELL_WORD_1 (ses);
+ Grob *s = (Grob *) SCM_CELL_WORD_1 (ses);
scm_gc_mark (s->immutable_property_alist_);
scm_gc_mark (s->key_->self_scm ());
- for (int a = 0 ; a < 2; a++)
+ for (int a = 0; a < 2; a++)
{
scm_gc_mark (s->dim_cache_[a].offset_callbacks_);
scm_gc_mark (s->dim_cache_[a].dimension_);
return scm_c_memq (k, ifs) != SCM_BOOL_F;
}
-Grob*
+Grob *
Grob::get_parent (Axis a) const
{
return dim_cache_[a].parent_;
}
-
/** Return Array of Grobs in SCM list LST */
Link_array<Grob>
ly_scm2grobs (SCM lst)
{
SCM s = SCM_EOL;
for (int i = a.size (); i; i--)
- s = scm_cons (a[i-1]->self_scm (), s);
+ s = scm_cons (a[i - 1]->self_scm (), s);
return s;
}
-
IMPLEMENT_TYPE_P (Grob, "ly:grob?");
ADD_INTERFACE (Grob, "grob-interface",
"A grob represents a piece of music notation\n"
"\n"
-"All grobs have an X and Y-position on the page. These X and Y positions\n"
-"are stored in a relative format, so they can easily be combined by\n"
-"stacking them, hanging one grob to the side of another, and coupling\n"
-"them into a grouping objects.\n"
-"\n"
-"Each grob has a reference point (a.k.a. parent): the position of a grob\n"
-"is stored relative to that reference point. For example the X-reference\n"
-"point of a staccato dot usually is the note head that it applies\n"
-"to. When the note head is moved, the staccato dot moves along\n"
-"automatically.\n"
-"\n"
-"A grob is often associated with a symbol, but some grobs do not print\n"
-"any symbols. They take care of grouping objects. For example, there is a\n"
-"separate grob that stacks staves vertically. The @ref{NoteCollision}\n"
-"is also an abstract grob: it only moves around chords, but doesn't print\n"
-"anything.\n"
-"\n"
+ "All grobs have an X and Y-position on the page. These X and Y positions\n"
+ "are stored in a relative format, so they can easily be combined by\n"
+ "stacking them, hanging one grob to the side of another, and coupling\n"
+ "them into a grouping objects.\n"
+ "\n"
+ "Each grob has a reference point (a.k.a. parent): the position of a grob\n"
+ "is stored relative to that reference point. For example the X-reference\n"
+ "point of a staccato dot usually is the note head that it applies\n"
+ "to. When the note head is moved, the staccato dot moves along\n"
+ "automatically.\n"
+ "\n"
+ "A grob is often associated with a symbol, but some grobs do not print\n"
+ "any symbols. They take care of grouping objects. For example, there is a\n"
+ "separate grob that stacks staves vertically. The @ref{NoteCollision}\n"
+ "is also an abstract grob: it only moves around chords, but doesn't print\n"
+ "anything.\n"
+ "\n"
"Grobs have a properties: Scheme variables, that can be read and set. "
"They have two types. Immutable variables "
"define the default style and behavior. They are shared between many objects. "
"Mutable properties are variables that are specific to one grob. Typically, "
"lists of other objects, or results from computations are stored in"
"mutable properties: every call to set-grob-property (or its C++ equivalent) "
- "sets a mutable property. "
-
-,
+ "sets a mutable property. ",
"X-offset-callbacks Y-offset-callbacks X-extent-callback stencil cause "
"Y-extent-callback print-function extra-offset spacing-procedure "
"context staff-symbol interfaces dependencies X-extent Y-extent extra-X-extent "
"axis-group-parent-X "
"axis-group-parent-Y "
"after-line-breaking-callback extra-Y-extent minimum-X-extent "
- "minimum-Y-extent transparent tweak-count tweak-rank"
- );
-
-
+ "minimum-Y-extent transparent tweak-count tweak-rank");
-/*
+/*
group-interface.cc -- implement Group_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "group-interface.hh"
#include "item.hh"
void
-Group_interface::add_thing (Grob*me, SCM sym, SCM thing)
+Group_interface::add_thing (Grob *me, SCM sym, SCM thing)
{
me->add_to_list_property (sym, thing);
}
-
int
Group_interface::count (Grob *me, SCM sym)
{
return scm_ilength (me->internal_get_property (sym));
}
-
void
-Pointer_group_interface::add_grob (Grob*me, SCM name, Grob*p)
+Pointer_group_interface::add_grob (Grob *me, SCM name, Grob *p)
{
Group_interface::add_thing (me, name, p->self_scm ());
}
-
-
Link_array<Grob>
extract_grob_array (Grob const *elt, SCM symbol)
{
return arr;
}
-
Link_array<Item>
extract_item_array (Grob const *elt, SCM symbol)
{
for (SCM s = elt->internal_get_property (symbol); scm_is_pair (s); s = scm_cdr (s))
{
SCM e = scm_car (s);
- arr.push (dynamic_cast<Item*> (unsmob_grob (e)));
+ arr.push (dynamic_cast<Item *> (unsmob_grob (e)));
}
arr.reverse ();
MAKE_SCHEME_CALLBACK (Hairpin, print, 1);
SCM
-Hairpin::print (SCM smob)
+Hairpin::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
- Spanner *spanner = dynamic_cast<Spanner*> (me);
+ Spanner *spanner = dynamic_cast<Spanner *> (me);
SCM s = me->get_property ("grow-direction");
if (!is_direction (s))
me->suicide ();
return SCM_EOL;
}
-
+
Direction grow_dir = to_dir (s);
Real padding = robust_scm2double (me->get_property ("bound-padding"), 0.5);
Drul_array<bool> broken;
- Drul_array<Item*> bounds ;
+ Drul_array<Item *> bounds;
Direction d = LEFT;
do
{
while (flip (&d) != LEFT);
Grob *common = bounds[LEFT]->common_refpoint (bounds[RIGHT], X_AXIS);
- Drul_array<Real> x_points ;
-
+ Drul_array<Real> x_points;
+
do
{
Item *b = bounds[d];
if (broken [d])
{
if (d == LEFT)
- x_points[d] = b->extent (common, X_AXIS)[RIGHT] ;
+ x_points[d] = b->extent (common, X_AXIS)[RIGHT];
}
else
{
else
{
bool neighbor_found = false;
- for (SCM adj = me->get_property ("adjacent-hairpins");
+ for (SCM adj = me->get_property ("adjacent-hairpins");
scm_is_pair (adj); adj = scm_cdr (adj))
{
/*
notes in other voices. Need to look at note-columns
in the current staff/voice.
*/
-
+
Spanner *pin = unsmob_spanner (scm_car (adj));
if (pin
- && (pin->get_bound (LEFT)->get_column() == b->get_column ()
- || pin->get_bound (RIGHT)->get_column() == b->get_column() ))
- neighbor_found = true;
+ && (pin->get_bound (LEFT)->get_column () == b->get_column ()
+ || pin->get_bound (RIGHT)->get_column () == b->get_column ()))
+ neighbor_found = true;
}
-
+
/*
If we're hung on a paper column, that means we're not
adjacent to a text-dynamic, and we may move closer. We
make the padding a little smaller, here.
*/
Interval e = robust_relative_extent (b, common, X_AXIS);
- x_points[d] =
- neighbor_found ? e.center() - d * padding / 3 : e[d];
+ x_points[d]
+ = neighbor_found ? e.center () - d * padding / 3 : e[d];
}
}
}
while (flip (&d) != LEFT);
-
Real width = x_points[RIGHT] - x_points[LEFT];
if (width < 0)
{
if (grow_dir < 0)
{
starth = height;
- endh = continued ? height/2 : 0.0;
+ endh = continued ? height / 2 : 0.0;
}
else
{
- starth = continued ? height/2 : 0.0;
+ starth = continued ? height / 2 : 0.0;
endh = height;
}
*/
Stencil mol;
- mol = Line_interface::line (me, Offset (0, starth), Offset (width, endh));
+ mol = Line_interface::line (me, Offset (0, starth), Offset (width, endh));
mol.add_stencil (Line_interface::line (me,
Offset (0, -starth),
Offset (width, -endh)));
return mol.smobbed_copy ();
}
-
-
ADD_INTERFACE (Hairpin, "hairpin-interface",
- "A hairpin (de)crescendo.",
- "grow-direction height bound-padding adjacent-hairpins");
+ "A hairpin (de)crescendo.",
+ "grow-direction height bound-padding adjacent-hairpins");
assert (a == Y_AXIS);
consider_suicide (me);
- return Axis_group_interface::group_extent_callback (me->self_scm (), scm_axis);
+ return Axis_group_interface::group_extent_callback (me->self_scm (), scm_axis);
}
-
void
-Hara_kiri_group_spanner::consider_suicide (Grob*me)
+Hara_kiri_group_spanner::consider_suicide (Grob *me)
{
- Spanner*sp = dynamic_cast<Spanner*> (me);
+ Spanner *sp = dynamic_cast<Spanner *> (me);
SCM worth = me->get_property ("items-worth-living");
if (scm_is_pair (worth))
- return ;
+ return;
if (!to_boolean (me->get_property ("remove-first"))
&& broken_spanner_index (sp) == 0)
{
- return ;
+ return;
}
-
+
Link_array<Grob> childs = Axis_group_interface::get_children (me);
for (int i = 0; i < childs.size (); i++)
childs[i]->suicide ();
-
/*
very appropriate name here :-)
- */
+ */
me->suicide ();
}
-
-
/*
We can't rely on offsets and dimensions of elements in a hara-kiri
group. Use a callback to make sure that hara-kiri has been done
return scm_make_real (0.0);
}
-
MAKE_SCHEME_CALLBACK (Hara_kiri_group_spanner, force_hara_kiri_in_parent_callback, 2);
SCM
Hara_kiri_group_spanner::force_hara_kiri_in_parent_callback (SCM element_smob, SCM axis)
}
void
-Hara_kiri_group_spanner::add_element (Grob * me, Grob *e)
+Hara_kiri_group_spanner::add_element (Grob *me, Grob *e)
{
// e->add_offset_callback (force_hara_kiri_in_parent_callback, Y_AXIS);
Axis_group_interface::add_element (me, e);
}
-
-
-
-void
-Hara_kiri_group_spanner::add_interesting_item (Grob* me, Grob* n)
+void
+Hara_kiri_group_spanner::add_interesting_item (Grob *me, Grob *n)
{
me->add_dependency (n);
Pointer_group_interface::add_grob (me, ly_symbol2scm ("items-worth-living"), n);
}
-
ADD_INTERFACE (Hara_kiri_group_spanner, "hara-kiri-group-interface",
"A group spanner that keeps track of interesting items. If it "
"doesn't contain any after linebreaking, then it "
- "will remove itself and all its children."
- ,
+ "will remove itself and all its children.",
"items-worth-living remove-first");
-/*
+/*
horizontal-bracket-engraver.cc -- implement
- Horizontal_bracket_engraver
+ Horizontal_bracket_engraver
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#include "engraver.hh"
#include "side-position-interface.hh"
int pop_count_;
int push_count_;
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void stop_translation_timestep ();
- virtual void process_music ();
- virtual void acknowledge_grob (Grob_info);
+ virtual void process_music ();
+ virtual void acknowledge_grob (Grob_info);
};
ADD_TRANSLATOR (Horizontal_bracket_engraver,
- "Create horizontal brackets over notes for musical analysis purposes.",
- "HorizontalBracket",
- "note-grouping-event",
- "note-column-interface",
- "",
- "");
+ "Create horizontal brackets over notes for musical analysis purposes.",
+ "HorizontalBracket",
+ "note-grouping-event",
+ "note-column-interface",
+ "",
+ "");
Horizontal_bracket_engraver::Horizontal_bracket_engraver ()
{
push_count_ = 0;
}
-
bool
Horizontal_bracket_engraver::try_music (Music *m)
{
if (m->is_mus_type ("note-grouping-event"))
{
Direction d = to_dir (m->get_property ("span-direction"));
-
+
if (d == STOP)
{
- pop_count_ ++;
+ pop_count_++;
if (pop_count_ > bracket_stack_.size ())
- m->origin ()->warning (_("Don't have that many brackets."));
+ m->origin ()->warning (_ ("Don't have that many brackets."));
}
else
{
push_count_++;
events_.push (m);
}
-
+
if (pop_count_ && push_count_)
- m->origin ()->warning (_("Conflicting note group events."));
+ m->origin ()->warning (_ ("Conflicting note group events."));
return true;
}
{
if (Note_column::has_interface (gi.grob_))
{
- for (int i = 0; i < bracket_stack_.size (); i++)
+ for (int i = 0; i < bracket_stack_.size (); i++)
{
Side_position_interface::add_support (bracket_stack_[i], gi.grob_);
Pointer_group_interface::add_grob (bracket_stack_[i],
ly_symbol2scm ("columns"), gi.grob_);
add_bound_item (bracket_stack_[i],
- gi.grob_);
+ gi.grob_);
}
}
}
void
Horizontal_bracket_engraver::process_music ()
{
- for (int k = 0; k < push_count_; k++)
+ for (int k = 0; k < push_count_; k++)
{
- Spanner * sp = make_spanner ("HorizontalBracket", events_[k]->self_scm ());
+ Spanner *sp = make_spanner ("HorizontalBracket", events_[k]->self_scm ());
for (int i = 0; i < bracket_stack_.size (); i++)
{
/*
sp is the smallest, it should be added to the bigger brackets.
- */
+ */
Side_position_interface::add_support (bracket_stack_[i], sp);
}
bracket_stack_.push (sp);
}
}
-
void
Horizontal_bracket_engraver::stop_translation_timestep ()
{
push_count_ = 0;
}
-
-/*
+/*
horizontal-bracket.cc -- implement Horizontal_bracket
source file of the GNU LilyPond music typesetter
-(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#include "side-position-interface.hh"
#include "lookup.hh"
struct Horizontal_bracket
{
DECLARE_SCHEME_CALLBACK (print, (SCM));
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
};
-
/*
TODO:
SCM
Horizontal_bracket::print (SCM smob)
{
- Grob * me = unsmob_grob (smob);
- Spanner *sp = dynamic_cast<Spanner*> (me);
+ Grob *me = unsmob_grob (smob);
+ Spanner *sp = dynamic_cast<Spanner *> (me);
Link_array<Grob> gs = extract_grob_array (me, ly_symbol2scm ("columns"));
if (!gs.size ())
me->suicide ();
return SCM_EOL;
}
- Grob * cx = common_refpoint_of_array (gs, me, X_AXIS);
+ Grob *cx = common_refpoint_of_array (gs, me, X_AXIS);
cx = cx->common_refpoint (sp->get_bound (LEFT), X_AXIS);
cx = cx->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
Interval (1.0, 1.0));
-
Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"),
Interval (0, 0));
Stencil b
= Tuplet_bracket::make_bracket (me, Y_AXIS, Offset (ext.length (), 0),
edge_height, empty, flare, shorten);
-
+
b.translate_axis (ext[LEFT] - sp->get_bound (LEFT)->relative_coordinate (cx, X_AXIS), X_AXIS);
- return b.smobbed_copy ();
+ return b.smobbed_copy ();
}
ADD_INTERFACE (Horizontal_bracket, "horizontal-bracket-interface",
- "A horizontal bracket encompassing notes.",
- "columns bracket-flare shorten-pair edge-height");
+ "A horizontal bracket encompassing notes.",
+ "columns bracket-flare shorten-pair edge-height");
hyphen-engraver.cc -- implement Hyphen_engraver
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Glen Prideaux <glenprideaux@iname.com>,
- Han-Wen Nienhuys <hanwen@cs.uu.nl>,
- Jan Nieuwenhuizen <janneke@gnu.org>
+ Han-Wen Nienhuys <hanwen@cs.uu.nl>,
+ Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "warn.hh"
{
Music *ev_;
Spanner *hyphen_;
- Spanner *finished_hyphen_;
+ Spanner *finished_hyphen_;
public:
TRANSLATOR_DECLARATIONS (Hyphen_engraver);
protected:
virtual void acknowledge_grob (Grob_info);
virtual void finalize ();
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void stop_translation_timestep ();
virtual void process_music ();
private:
};
-
-
Hyphen_engraver::Hyphen_engraver ()
{
hyphen_ = 0;
void
Hyphen_engraver::acknowledge_grob (Grob_info i)
{
- Item * item = dynamic_cast<Item*> (i.grob_);
+ Item *item = dynamic_cast<Item *> (i.grob_);
// -> Text_item
if (item && item->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
{
}
}
-
bool
-Hyphen_engraver::try_music (Music* r)
+Hyphen_engraver::try_music (Music *r)
{
if (ev_)
return false;
}
void
-completize_hyphen (Spanner* sp)
+completize_hyphen (Spanner *sp)
{
if (!sp->get_bound (RIGHT))
{
SCM heads = sp->get_property ("heads");
if (scm_is_pair (heads))
{
- Item* it = dynamic_cast<Item*> (unsmob_grob (scm_car (heads)));
+ Item *it = dynamic_cast<Item *> (unsmob_grob (scm_car (heads)));
if (it)
sp->set_bound (RIGHT, it);
}
}
}
-
-
void
Hyphen_engraver::finalize ()
{
if (!finished_hyphen_->get_bound (RIGHT))
{
- finished_hyphen_->warning (_("unterminated hyphen; removing"));
+ finished_hyphen_->warning (_ ("unterminated hyphen; removing"));
finished_hyphen_->suicide ();
}
finished_hyphen_ = 0;
{
if (ev_)
{
- hyphen_ = make_spanner ("LyricHyphen", ev_->self_scm ()
-);
+ hyphen_ = make_spanner ("LyricHyphen", ev_->self_scm ());
}
}
-
void
Hyphen_engraver::stop_translation_timestep ()
{
programming_error ("Haven't finished hyphen yet.");
finished_hyphen_ = 0;
}
-
+
if (hyphen_)
finished_hyphen_ = hyphen_;
hyphen_ = 0;
}
-
-
ADD_TRANSLATOR (Hyphen_engraver,
-/* descr */ "Create lyric hyphens",
-/* creats*/ "LyricHyphen",
-/* accepts */ "hyphen-event",
-/* acks */ "lyric-syllable-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Create lyric hyphens",
+ /* creats*/ "LyricHyphen",
+ /* accepts */ "hyphen-event",
+ /* acks */ "lyric-syllable-interface",
+ /* reads */ "",
+ /* write */ "");
{
if (SCM_IMP (box) || SCM_CELL_TYPE (box) != package_tag)
return SCM_UNDEFINED;
-
+
return SCM_CELL_OBJECT_1 (box);
}
scm_set_smob_print (package_tag, print_box);
}
-ADD_SCM_INIT_FUNC (package, init_box_type);
+ADD_SCM_INIT_FUNC (package, init_box_type);
#endif
#ifndef YY_START
-#define YY_START\
- ((yy_start - 1) / 2)
+#define YY_START \
+ ((yy_start - 1) / 2)
#define YYSTATE YY_START
#endif
/* Flex >= 2.5.29 has include stack; but we don't use that yet. */
#if !HAVE_FLEXLEXER_YY_CURRENT_BUFFER
-#define yy_current_buffer \
+#define yy_current_buffer \
(yy_buffer_stack != 0 ? yy_buffer_stack[yy_buffer_stack_top] : 0)
#endif
LexerError (_ ("include files are not allowed in safe mode").to_str0 ());
return;
}
-
+
Source_file *file = sources->get_file (name);
if (!file)
{
if (be_verbose_global)
progress_indication (String ("[") + name);
-
+
include_stack_.push (file);
/* Ugh. We'd want to create a buffer from the bytes directly.
- Whoops. The size argument to yy_create_buffer is not the
- filelength but a BUFFERSIZE. Maybe this is why reading stdin fucks up. */
+ Whoops. The size argument to yy_create_buffer is not the
+ filelength but a BUFFERSIZE. Maybe this is why reading stdin fucks up. */
yy_switch_to_buffer (yy_create_buffer (file->get_istream (), YY_BUF_SIZE));
}
}
/** pop the inputstack. conceptually this is a destructor, but it
- does not destruct the Source_file that Includable_lexer::new_input
- creates. */
+ does not destruct the Source_file that Includable_lexer::new_input
+ creates. */
bool
Includable_lexer::close_input ()
{
if (be_verbose_global)
progress_indication ("]");
yy_delete_buffer (yy_current_buffer);
-#if HAVE_FLEXLEXER_YY_CURRENT_BUFFER
+#if HAVE_FLEXLEXER_YY_CURRENT_BUFFER
yy_current_buffer = 0;
-#endif
+#endif
if (state_stack_.is_empty ())
{
-#if HAVE_FLEXLEXER_YY_CURRENT_BUFFER
+#if HAVE_FLEXLEXER_YY_CURRENT_BUFFER
yy_current_buffer = 0;
-#endif
+#endif
return false;
}
yy_switch_to_buffer (state_stack_.pop ());
return true;
}
-char const*
+char const *
Includable_lexer::here_str0 () const
{
if (include_stack_.is_empty ())
}
}
-Source_file*
+Source_file *
Includable_lexer::get_source_file () const
{
if (include_stack_.is_empty ())
/*
accidental-interface.hh -- declare Accidental_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "lily-guile.hh"
#include "lily-proto.hh"
-
class Accidental_interface
{
public:
DECLARE_SCHEME_CALLBACK (print, (SCM));
- DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
- static bool has_interface (Grob*);
-
- static String get_fontcharname(String style, int alteration);
- static Array<Box> Accidental_interface::accurate_boxes (Grob *me, Grob**common);
-};
+ DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
+ static bool has_interface (Grob *);
+ static String get_fontcharname (String style, int alteration);
+ static Array<Box> Accidental_interface::accurate_boxes (Grob *me, Grob **common);
+};
#endif
-/*
-accidental-placement.hh -- declare Accidental_placement
+/*
+ accidental-placement.hh -- declare Accidental_placement
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#ifndef ACCIDENTAL_PLACEMENT_HH
#define ACCIDENTAL_PLACEMENT_HH
{
public:
DECLARE_SCHEME_CALLBACK (alignment_callback, (SCM element, SCM axis));
- static void add_accidental (Grob *, Grob* );
+ static void add_accidental (Grob *, Grob *);
static Interval get_relevant_accidental_extent (Grob *me,
Item *item_col,
Grob *acc);
- static void split_accidentals (Grob * accs,
- Link_array<Grob> *break_reminder,
- Link_array<Grob> *real_acc);
-
- static SCM position_accidentals (Grob* );
- static bool has_interface (Grob*);
+ static void split_accidentals (Grob *accs,
+ Link_array<Grob> *break_reminder,
+ Link_array<Grob> *real_acc);
+
+ static SCM position_accidentals (Grob *);
+ static bool has_interface (Grob *);
};
#endif /* ACCIDENTAL_PLACEMENT_HH */
-/*
+/*
afm.hh -- declare Adobe_font_metric
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef AFM_HH
#define AFM_HH
virtual Box get_ascii_char (int) const;
virtual Box get_indexed_char (int) const;
virtual Offset get_indexed_wxwy (int) const;
- static SCM make_afm (AFM_Font_info*, unsigned, Real);
+ static SCM make_afm (AFM_Font_info *, unsigned, Real);
virtual Real design_size () const;
- virtual String font_name () const;
+ virtual String font_name () const;
protected:
AFM_CharMetricInfo const *find_char_metric (String name) const;
- AFM_CharMetricInfo const *find_ascii_metric (int) const;
+ AFM_CharMetricInfo const *find_ascii_metric (int) const;
Array<int> ascii_to_metric_idx_;
- std::map<String, int> name_to_metric_dict_;
+ std::map < String, int> name_to_metric_dict_;
- Adobe_font_metric (AFM_Font_info*);
+ Adobe_font_metric (AFM_Font_info *);
};
SCM read_afm_file (String);
Box afm_bbox_to_box (AFM_BBox);
-
+
#endif /* AFM_HH */
/*
align-interface.hh -- declare Align_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef ALIGN_INTERFACE_HH
#define ALIGN_INTERFACE_HH
#include "lily-proto.hh"
#include "lily-guile.hh"
-struct Align_interface {
+struct Align_interface
+{
DECLARE_SCHEME_CALLBACK (alignment_callback, (SCM element, SCM axis));
DECLARE_SCHEME_CALLBACK (fixed_distance_alignment_callback, (SCM element, SCM axis));
- static void align_to_fixed_distance (Grob*, Axis a);
- static void align_elements_to_extents (Grob*, Axis a);
- static void set_axis (Grob*, Axis);
- static Axis axis (Grob*) ;
- static void add_element (Grob*, Grob*, SCM callback);
- static int get_count (Grob*, Grob*);
-
- static bool has_interface (Grob*);
+ static void align_to_fixed_distance (Grob *, Axis a);
+ static void align_elements_to_extents (Grob *, Axis a);
+ static void set_axis (Grob *, Axis);
+ static Axis axis (Grob *);
+ static void add_element (Grob *, Grob *, SCM callback);
+ static int get_count (Grob *, Grob *);
+
+ static bool has_interface (Grob *);
};
-Grob *find_fixed_alignment_parent (Grob *g);
-
+Grob *find_fixed_alignment_parent (Grob *g);
#endif /* ALIGN_INTERFACE_HH */
-/*
+/*
all-fonts.hh -- declare All_font_metrics
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef ALL_FONTS_HH
#define ALL_FONTS_HH
/**
Interface to all .afm files living in the filesystem.
- */
+*/
class All_font_metrics
{
Scheme_hash_table *afm_dict_;
Scheme_hash_table *pango_dict_;
int pango_dpi_;
#endif
-
- All_font_metrics (All_font_metrics const&);
+
+ All_font_metrics (All_font_metrics const &);
public:
All_font_metrics (String search_path);
~All_font_metrics ();
-
+
#ifdef HAVE_PANGO_FT2
- Pango_font *find_pango_font (PangoFontDescription*description,
+ Pango_font *find_pango_font (PangoFontDescription *description,
Real magnification,
Real scale);
#endif
-
+
Adobe_font_metric *find_afm (String name);
Tex_font_metric *find_tfm (String);
- Font_metric *find_font (String name);
- Open_type_font *find_otf (String name);
+ Font_metric *find_font (String name);
+ Open_type_font *find_otf (String name);
SCM font_descriptions () const;
};
struct Ambitus
{
DECLARE_SCHEME_CALLBACK (print, (SCM smob));
- static bool has_interface (Grob*);
- static Slice get_positions (Grob*);
- static Interval head_width (Grob* me, Grob * common);
+ static bool has_interface (Grob *);
+ static Slice get_positions (Grob *);
+ static Interval head_width (Grob *me, Grob *common);
};
#endif // AMBITUS_HH
/*
arpegio.hh -- declare Arpeggio
-
+
source file of the GNU LilyPond music typesetter
(c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (brew_chord_bracket, (SCM));
DECLARE_SCHEME_CALLBACK (width_callback, (SCM, SCM));
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
};
#endif /* ARPEGGIO_HH */
audio-column.hh -- declare Audio_column
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#ifndef AUDIO_COLUMN_HH
#define AUDIO_COLUMN_HH
#include "audio-element.hh"
/**
- generic audio grouped vertically.
- */
+ generic audio grouped vertically.
+*/
-class Audio_column : public Audio_element {
+class Audio_column : public Audio_element
+{
public:
Audio_column (Moment at_mom);
- void add_audio_item (Audio_item* i);
+ void add_audio_item (Audio_item *i);
Moment at_mom () const;
Link_array<Audio_item> audio_items_;
private:
- Audio_column (Audio_column const&);
+ Audio_column (Audio_column const &);
Moment at_mom_;
};
-
#endif // AUDIO_COLUMN_HH
-/*
+/*
audio-item-info.hh -- declare Audio_item_info
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef AUDIO_ITEM_INFO_HH
#define AUDIO_ITEM_INFO_HH
#include "parray.hh"
/**
- Data container for broadcasts
- */
-class Audio_element_info {
+ Data container for broadcasts
+*/
+class Audio_element_info
+{
public:
- Audio_element * elem_;
+ Audio_element *elem_;
Music *event_;
Translator *origin_trans_;
- Link_array<Context> origin_contexts (Translator*) const;
+ Link_array<Context> origin_contexts (Translator *) const;
- Audio_element_info (Audio_element*, Music*);
+ Audio_element_info (Audio_element *, Music *);
Audio_element_info ();
};
-
#endif
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef AUDIO_ELEMENT_HH
#define AUDIO_ELEMENT_HH
public:
Audio_element ();
virtual ~Audio_element ();
- virtual const char* name () const;
+ virtual const char *name () const;
protected:
};
audio-item.hh -- declare Audio_items
(c) 1996--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#ifndef AUDIO_ITEM_HH
#define AUDIO_ITEM_HH
#include "pitch.hh"
/**
-
- Any piece of audio information. We need virtual constructors, let's
- try decentralised factory for specific audio implemenations.
- */
+
+Any piece of audio information. We need virtual constructors, let's
+try decentralised factory for specific audio implemenations.
+*/
class Audio_item : public Audio_element
{
public:
Audio_item ();
- Audio_column* audio_column_;
-
+ Audio_column *audio_column_;
+
private:
- Audio_item (Audio_item const&);
- Audio_item& operator = ( Audio_item const&);
+ Audio_item (Audio_item const &);
+ Audio_item &operator= (Audio_item const &);
};
class Audio_dynamic : public Audio_item
String str_;
};
-
+
class Audio_note : public Audio_item
{
-public:
+public:
Audio_note (Pitch p, Moment m, int transposing_i = 0);
- void tie_to (Audio_note*);
+ void tie_to (Audio_note *);
Pitch pitch_;
Moment length_mom_;
int transposing_;
- Audio_note* tied_;
+ Audio_note *tied_;
};
class Audio_piano_pedal : public Audio_item
class Audio_text : public Audio_item
{
public:
- enum Type {
- TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC,
- MARKER, CUE_POINT
- };
-
+ enum Type
+ {
+ TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC,
+ MARKER, CUE_POINT
+ };
+
Audio_text (Audio_text::Type type, String text_string);
Type type_;
audio-staff.hh -- declare Audio_staff
(c) 1996--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#ifndef AUDIO_STAFF_HH
#define AUDIO_STAFF_HH
struct Audio_staff : public Audio_element
{
- void add_audio_item (Audio_item* l);
- void output (Midi_stream& midi_stream_r, int track_i);
+ void add_audio_item (Audio_item *l);
+ void output (Midi_stream &midi_stream_r, int track_i);
Link_array<Audio_item> audio_items_;
int channel_;
-/*
+/*
axis-group-interface.hh -- declare Axis_group_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef AXIS_GROUP_INTERFACE_HH
#define AXIS_GROUP_INTERFACE_HH
#include "group-interface.hh"
/**
-
-*/
-struct Axis_group_interface
+ */
+struct Axis_group_interface
{
DECLARE_SCHEME_CALLBACK (group_extent_callback, (SCM smob, SCM axis));
- static Interval relative_group_extent (Axis, Grob * common, SCM list);
-
- static void add_element (Grob* me, Grob*);
- static void set_axes (Grob*, Axis, Axis);
- static bool has_axis (Grob*, Axis);
- static Link_array<Grob> get_children (Grob*);
- static bool has_interface (Grob*);
-
-
+ static Interval relative_group_extent (Axis, Grob *common, SCM list);
+
+ static void add_element (Grob *me, Grob *);
+ static void set_axes (Grob *, Axis, Axis);
+ static bool has_axis (Grob *, Axis);
+ static Link_array<Grob> get_children (Grob *);
+ static bool has_interface (Grob *);
+
};
#endif /* AXIS_GROUP_INTERFACE_HH */
#include "lily-proto.hh"
/**
- A vertical bar.
- */
+ A vertical bar.
+*/
class Bar_line
{
public:
- static bool has_interface (Grob*);
-
- static Stencil compound_barline (Grob*, String, Real height) ;
- static Stencil simple_barline (Grob*, Real wid, Real height) ;
- DECLARE_SCHEME_CALLBACK (get_staff_bar_size, (SCM ));
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
- DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM ));
+ static bool has_interface (Grob *);
+
+ static Stencil compound_barline (Grob *, String, Real height);
+ static Stencil simple_barline (Grob *, Real wid, Real height);
+ DECLARE_SCHEME_CALLBACK (get_staff_bar_size, (SCM));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
};
#endif // BAR_HH
#include "lily-proto.hh"
/**
- A vertical bar.
- */
+ A vertical bar.
+*/
class Bar
{
public:
- static bool has_interface (Grob*);
-
- static Stencil compound_barline (Grob*, String, Real height) ;
- static Stencil simple_barline (Grob*, Real wid, Real height) ;
- DECLARE_SCHEME_CALLBACK (get_staff_bar_size, (SCM ));
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
- DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM ));
+ static bool has_interface (Grob *);
+
+ static Stencil compound_barline (Grob *, String, Real height);
+ static Stencil simple_barline (Grob *, Real wid, Real height);
+ DECLARE_SCHEME_CALLBACK (get_staff_bar_size, (SCM));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
};
#endif // BAR_HH
#include "lily-guile.hh"
#include "stem-info.hh"
-
class Beam
{
public:
- static int visible_stem_count (Grob*);
- static Grob* first_visible_stem (Grob*);
- static Grob* last_visible_stem (Grob*);
- static bool has_interface (Grob*);
+ static int visible_stem_count (Grob *);
+ static Grob *first_visible_stem (Grob *);
+ static Grob *last_visible_stem (Grob *);
+ static bool has_interface (Grob *);
DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM axis));
Beam (SCM);
- static void add_stem (Grob*, Grob*);
- static bool is_knee (Grob*);
- static void set_beaming (Grob*, Beaming_info_list *);
- static void set_stemlens (Grob*);
- static int get_beam_count (Grob*me);
- static void position_beam (Grob* me);
- static Real get_beam_translation (Grob*me);
- static Real get_thickness (Grob*me);
+ static void add_stem (Grob *, Grob *);
+ static bool is_knee (Grob *);
+ static void set_beaming (Grob *, Beaming_info_list *);
+ static void set_stemlens (Grob *);
+ static int get_beam_count (Grob *me);
+ static void position_beam (Grob *me);
+ static Real get_beam_translation (Grob *me);
+ static Real get_thickness (Grob *me);
- static void connect_beams (Grob*me);
+ static void connect_beams (Grob *me);
DECLARE_SCHEME_CALLBACK (space_function, (SCM, SCM));
DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
-
+
/* position callbacks */
DECLARE_SCHEME_CALLBACK (least_squares, (SCM));
DECLARE_SCHEME_CALLBACK (check_concave, (SCM));
DECLARE_SCHEME_CALLBACK (slope_damping, (SCM));
- DECLARE_SCHEME_CALLBACK (shift_region_to_valid, (SCM));
+ DECLARE_SCHEME_CALLBACK (shift_region_to_valid, (SCM));
DECLARE_SCHEME_CALLBACK (quanting, (SCM));
static Real score_slopes_dy (Real, Real, Real, Real, Real, bool);
Array<Stem_info> const &stem_infos,
Array<Real> const &base_stem_ys,
Array<Real> const &stem_xs,
- Real xl, Real xr,
- bool knee,
+ Real xl, Real xr,
+ bool knee,
Real yl, Real yr);
static Real score_forbidden_quants (Real, Real,
Real, Real, Real, Real,
Drul_array<int>, Direction, Direction);
-
static int get_direction_beam_count (Grob *me, Direction d);
private:
- static Direction get_default_dir (Grob*);
- static void set_stem_directions (Grob*, Direction );
- static void consider_auto_knees (Grob*);
- static void set_stem_shorten (Grob*);
- static Real calc_stem_y (Grob*, Grob* s, Grob**c,
+ static Direction get_default_dir (Grob *);
+ static void set_stem_directions (Grob *, Direction);
+ static void consider_auto_knees (Grob *);
+ static void set_stem_shorten (Grob *);
+ static Real calc_stem_y (Grob *, Grob *s, Grob **c,
Real, Real,
Drul_array<Real> pos, bool french);
- static void set_stem_lengths (Grob*);
- static int forced_stem_count (Grob*);
+ static void set_stem_lengths (Grob *);
+ static int forced_stem_count (Grob *);
};
const int REGION_SIZE = 2;
-/*
+/*
beaming.hh -- declare beaming.hh
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef BEAMING_HH
#define BEAMING_HH
void add_stem (Moment d, int beams);
};
-
#endif /* BEAMING_HH */
#ifndef BEZIER_HH
#define BEZIER_HH
-
#include "interval.hh"
#include "offset.hh"
#include "polynomial.hh"
/**
- Simple bezier curve
- */
+ Simple bezier curve
+*/
class Bezier
{
public:
Array<> gives unnecessary overhead, and makes debugging a royal
pain. */
-
Offset control_[4];
};
void rotate (Array<Offset>* array, Real phi);
void translate (Array<Offset>* array, Offset o);
-
-
Bezier slur_shape (Real width, Real height_limit,
Real height_proportion);
-Real slur_height (Real width, Real height_limit, Real height_proportion);
-void get_slur_indent_height (Real * indent, Real *height, Real width, Real h_inf, Real r_0);
+Real slur_height (Real width, Real height_limit, Real height_proportion);
+void get_slur_indent_height (Real *indent, Real *height, Real width, Real h_inf, Real r_0);
#endif // BEZIER_HH
class Binary_source_file : public Source_file
{
public:
- Binary_source_file (String& file_name_string );
+ Binary_source_file (String &file_name_string);
virtual ~Binary_source_file ();
- U8 get_U8 ();
+ U8 get_U8 ();
U16 get_U16 ();
U32 get_U32 ();
Byte get_Byte () {return get_U8 (); }
int get_int () { return get_U32 (); }
-
- virtual String error_string (char const* pos_str0 ) const;
- virtual int get_line (char const* pos_str0 ) const;
+
+ virtual String error_string (char const *pos_str0) const;
+ virtual int get_line (char const *pos_str0) const;
};
#endif // BINARY_SOURCE_FILE_HH
Book ();
void add_score (SCM);
- Paper_book* process (String, Output_def*);
+ Paper_book *process (String, Output_def *);
void set_keys ();
};
/*
- some 2D geometrical concepts
+ some 2D geometrical concepts
*/
#ifndef BOXES_HH
struct Box
{
Interval interval_a_[NO_AXES];
-
+
Interval &x () {return interval_a_[X_AXIS]; }
Interval &y (){ return interval_a_[Y_AXIS]; }
Interval x () const{ return interval_a_[X_AXIS]; }
Interval &operator[] (Axis a);
Offset center () const;
-
+
void translate (Offset o);
/// smallest box enclosing #b#
void set_empty ();
Box (Interval ix, Interval iy);
};
-
#endif
(c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef BREAK_HH
#define BREAK_HH
#include "interval.hh"
#include "column-x-positions.hh"
-
/** Class representation of an algorithm which decides where to put
- the column, and where to break lines.
+ the column, and where to break lines.
- JUNKME.
-
- */
-class Break_algorithm {
+ JUNKME.
+*/
+class Break_algorithm
+{
protected:
Paper_score *pscore_;
Real linewidth_;
Link_array<Grob> find_breaks () const;
Array<int> find_break_indices () const;
- void solve_line (Column_x_positions*) const;
+ void solve_line (Column_x_positions *) const;
bool feasible (Link_array<Grob> const &) const;
- Simple_spacer_wrapper* generate_spacing_problem (Link_array<Grob> const &, Interval) const;
+ Simple_spacer_wrapper *generate_spacing_problem (Link_array<Grob> const &, Interval) const;
virtual Array<Column_x_positions> do_solve () const = 0;
public:
- Simple_spacer* (*get_line_spacer) ();
+ Simple_spacer *(*get_line_spacer) ();
Break_algorithm ();
- void set_pscore (Paper_score*);
+ void set_pscore (Paper_score *);
Array<Column_x_positions> solve () const;
};
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef BREAK_ALIGN_INTERFACE_HH
#define BREAK_ALIGN_INTERFACE_HH
class Break_align_interface
{
public:
- static void do_alignment (Grob*);
+ static void do_alignment (Grob *);
static Link_array<Grob> ordered_elements (Grob *me);
- static bool has_interface (Grob*);
- static void add_element (Grob*me, Grob*add);
+ static bool has_interface (Grob *);
+ static void add_element (Grob *me, Grob *add);
DECLARE_SCHEME_CALLBACK (alignment_callback, (SCM element, SCM axis));
DECLARE_SCHEME_CALLBACK (self_align_callback, (SCM element, SCM axis));
-
+
};
struct Break_aligned_interface
{
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
};
-
#endif // BREAK_ALIGN_INTERFACE_HH
Copyright (c) 1999--2005 Michael Krause
written for the GNU LilyPond music typesetter
-
*/
#ifndef BREATHING_SIGN_HH
class Breathing_sign
{
public:
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
- DECLARE_SCHEME_CALLBACK (railtracks, (SCM ));
- DECLARE_SCHEME_CALLBACK (divisio_minima, (SCM ));
- DECLARE_SCHEME_CALLBACK (divisio_maior, (SCM ));
- DECLARE_SCHEME_CALLBACK (divisio_maxima, (SCM ));
- DECLARE_SCHEME_CALLBACK (finalis, (SCM ));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ DECLARE_SCHEME_CALLBACK (railtracks, (SCM));
+ DECLARE_SCHEME_CALLBACK (divisio_minima, (SCM));
+ DECLARE_SCHEME_CALLBACK (divisio_maior, (SCM));
+ DECLARE_SCHEME_CALLBACK (divisio_maxima, (SCM));
+ DECLARE_SCHEME_CALLBACK (finalis, (SCM));
DECLARE_SCHEME_CALLBACK (offset_callback, (SCM element, SCM axis));
-
- static bool has_interface (Grob*);
+
+ static bool has_interface (Grob *);
};
#endif // BREATHING_SIGN_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef CHANGE_ITERATOR_HH
#define CHANGE_ITERATOR_HH
#include "simple-music-iterator.hh"
-
class Change_iterator : public Simple_music_iterator
{
public:
/* constructor is public */
virtual void process (Moment);
- DECLARE_SCHEME_CALLBACK(constructor, ());
+ DECLARE_SCHEME_CALLBACK (constructor, ());
private:
- void error (String);
+ void error (String);
};
#endif
#include "stencil.hh"
-
class Chord_name
{
public:
- DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM ));
- static bool has_interface (Grob*);
+ DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
+ static bool has_interface (Grob *);
};
#endif // CHORD_NAME_HH
-/*
+/*
chord-tremolo-iterator.hh -- declare Chord_tremolo_iterator
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef CHORD_TREMOLO_ITERATOR_HH
#define CHORD_TREMOLO_ITERATOR_HH
class Chord_tremolo_iterator : public Music_iterator
{
public:
- DECLARE_SCHEME_CALLBACK(constructor, ());
+ DECLARE_SCHEME_CALLBACK (constructor, ());
Chord_tremolo_iterator ();
- Chord_tremolo_iterator (Chord_tremolo_iterator const & );
+ Chord_tremolo_iterator (Chord_tremolo_iterator const &);
protected:
- virtual void derived_substitute (Context *f, Context *t) ;
+ virtual void derived_substitute (Context *f, Context *t);
virtual void derived_mark () const;
virtual Moment pending_moment () const;
- virtual void do_quit();
- virtual void construct_children () ;
+ virtual void do_quit ();
+ virtual void construct_children ();
virtual bool ok () const;
- virtual void process (Moment) ;
+ virtual void process (Moment);
virtual Music_iterator *try_music_in_children (Music *) const;
private:
Moment factor_;
- Music_iterator * child_iter_;
+ Music_iterator *child_iter_;
};
-
#endif /* CHORD_TREMOLO_ITERATOR_HH */
-/*
+/*
clef.hh -- declare Clef
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef CLEF_HH
#define CLEF_HH
#include "lily-guile.hh"
#include "lily-proto.hh"
-struct Clef
+struct Clef
{
- DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM ));
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
- static bool has_interface (Grob*);
+ DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ static bool has_interface (Grob *);
};
-
#endif /* CLEF_HH */
class Cluster
{
public:
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
// DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
static bool has_interface (Grob *);
// DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM ));
-/*
+/*
coherent-ligature-engraver.hh -- declare Coherent_ligature_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2003--2005 Juergen Reuter <reuter@ipd.uka.de>
-
- */
+*/
#ifndef COHERENT_LIGATURE_ENGRAVER_HH
#define COHERENT_LIGATURE_ENGRAVER_HH
class Coherent_ligature_engraver : public Ligature_engraver
{
public:
- TRANSLATOR_DECLARATIONS(Coherent_ligature_engraver);
+ TRANSLATOR_DECLARATIONS (Coherent_ligature_engraver);
protected:
virtual void build_ligature (Spanner *ligature,
#include "parray.hh"
#include "lily-proto.hh"
-
struct Column_x_positions
{
Link_array<Grob> cols_;
Link_array<Grob> loose_cols_;
-
+
Array<Real> config_;
Real force_;
bool satisfies_constraints_;
Column_x_positions ();
};
-
#endif // COLUMN_X_POSITIONS_HH
-/*
+/*
context-def.hh -- declare Context_def
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef CONTEXT_DEF_HH
#define CONTEXT_DEF_HH
SCM context_name_;
SCM context_aliases_;
SCM translator_group_type_;
-
+
public:
void add_context_mod (SCM);
SCM default_child_context_name ();
void set_acceptor (SCM accepts, bool add);
Link_array<Context_def> path_to_acceptable_context (SCM type_string,
- Output_def*) const;
- Context * instantiate (SCM extra_ops, Object_key const*);
+ Output_def *) const;
+ Context *instantiate (SCM extra_ops, Object_key const *);
SCM to_alist () const;
static SCM make_scm ();
SCM clone_scm () const;
- void apply_default_property_operations (Context*);
+ void apply_default_property_operations (Context *);
private:
DECLARE_SMOBS (Context_def, foo);
Context_def ();
- Context_def (Context_def const&);
+ Context_def (Context_def const &);
};
DECLARE_UNSMOB (Context_def, context_def);
/*
context.hh -- declare Context
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include "moment.hh"
#include "lily-proto.hh"
-
class Context
{
Scheme_hash_table *properties_dict () const;
Context (Context const &src);
-
+
DECLARE_SMOBS (Context, dummy);
void terminate ();
int iterator_count_;
bool init_;
- std::map<String, int> grob_counts_;
- std::map<String, int> context_counts_;
+ std::map < String, int> grob_counts_;
+ std::map < String, int> context_counts_;
protected:
- Object_key const * key_;
- Context * daddy_context_;
+ Object_key const *key_;
+ Context *daddy_context_;
SCM definition_;
SCM properties_scm_;
SCM context_list_;
Object_key const *get_grob_key (String);
Object_key const *get_context_key (String, String);
- Context *create_context (Context_def*, String, SCM);
- String id_string () const { return id_string_; }
+ Context *create_context (Context_def *, String, SCM);
+ String id_string () const { return id_string_; }
SCM children_contexts () const { return context_list_; }
SCM default_child_context_name () const;
- Translator_group* implementation () const;
+ Translator_group *implementation () const;
Context *get_parent_context () const;
- Context (Object_key const*);
-
+ Context (Object_key const *);
+
/* properties: */
void execute_pushpop_property (SCM prop, SCM sym, SCM val);
SCM internal_get_property (SCM name_sym) const;
SCM properties_as_alist () const;
- void internal_set_property (SCM var_sym, SCM value);
+ void internal_set_property (SCM var_sym, SCM value);
Context *where_defined (SCM name_sym) const;
void unset_property (SCM var_sym);
-
Context *remove_context (Context *trans);
void check_removal ();
String context_name () const;
SCM context_name_symbol () const;
Global_context *get_global_context () const;
-
- virtual Score_context * get_score_context () const;
+
+ virtual Score_context *get_score_context () const;
virtual Output_def *get_output_def () const;
virtual Moment now_mom () const;
virtual Context *get_default_interpreter ();
bool is_alias (SCM) const;
- void add_alias (SCM);
+ void add_alias (SCM);
void add_context (Context *trans);
bool is_bottom_context () const;
bool is_removable () const;
Context *find_create_context (SCM context_name,
String id, SCM ops);
Context *create_unique_context (SCM context_name,
- SCM ops);
+ SCM ops);
Link_array<Context> path_to_acceptable_context (SCM alias,
- Output_def*) const;
+ Output_def *) const;
};
/*
- Context arg?
- */
+ Context arg?
+*/
void apply_property_operations (Context *tg, SCM pre_init_ops);
void execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, SCM val);
SCM updated_grob_properties (Context *tg, SCM sym);
Context *find_context_below (Context *where,
- SCM type_sym, String id);
+ SCM type_sym, String id);
bool melisma_busy (Context *);
Context *get_voice_to_lyrics (Context *lyrics);
Grob *get_current_note_head (Context *voice);
Grob *get_current_rest (Context *voice);
-DECLARE_UNSMOB(Context, context);
+DECLARE_UNSMOB (Context, context);
#endif /* CONTEXT_HH */
struct Custos
{
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
- static bool has_interface (Grob*);
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ static bool has_interface (Grob *);
private:
- static void add_streepjes (Grob* me, int pos, int interspaces, Stencil* custos_);
- static Stencil create_ledger_line (Interval x_extent, Grob *me) ;
+ static void add_streepjes (Grob *me, int pos, int interspaces, Stencil *custos_);
+ static Stencil create_ledger_line (Interval x_extent, Grob *me);
};
-/*
- dimension-cache-callback.hh -- declare
-
+/*
+ dimension-cache-callback.hh -- declare
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef DIMENSION_CACHE_CALLBACK_HH
#define DIMENSION_CACHE_CALLBACK_HH
-/*
+/*
dimension-cache.hh -- declare Dimension_cache
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef DIMENSION_CACHE_HH
#define DIMENSION_CACHE_HH
#include "lily-guile.hh"
/**
- Adminstration of offset dimension info.
+ Adminstration of offset dimension info.
*/
struct Dimension_cache
{
/*
Multi typed:
- - cons: interval
- - procedure: callback
- - else: empty
- */
+ - cons: interval
+ - procedure: callback
+ - else: empty
+ */
SCM dimension_;
SCM dimension_callback_;
/**
- The offset wrt. to the center of #parent_#
- */
+ The offset wrt. to the center of #parent_#
+ */
Real offset_;
SCM offset_callbacks_;
-
+
char offsets_left_;
/**
- What to call to find extent. Nil means empty.
- */
- Grob * parent_;
+ What to call to find extent. Nil means empty.
+ */
+ Grob *parent_;
- Dimension_cache (Dimension_cache const&);
+ Dimension_cache (Dimension_cache const &);
Dimension_cache ();
void init ();
};
-
#endif /* DIMENSION_CACHE_HH */
#include "real.hh"
class String;
-
const Real INCH_TO_PT = 72.270;
const Real CM_TO_PT = (INCH_TO_PT / 2.54);
const Real MM_TO_PT = (CM_TO_PT / 10);
#define INTERNAL_UNIT "pt"
-#define PT * (PT_TO_PT)
-#define MM * (MM_TO_PT)
-#define CM * (CM_TO_PT)
-#define INCH * (INCH_TO_PT)
-#define BIGPOINT * (BIGPOINT_TO_POINT)
-#define CHAR * (CHAR_TO_PT)
+#define PT *(PT_TO_PT)
+#define MM *(MM_TO_PT)
+#define CM *(CM_TO_PT)
+#define INCH *(INCH_TO_PT)
+#define BIGPOINT *(BIGPOINT_TO_POINT)
+#define CHAR *(CHAR_TO_PT)
-#else // mm
+#else // mm
#define INTERNAL_UNIT "mm"
-#define PT * (PT_TO_PT * PT_TO_MM)
-#define MM * (MM_TO_PT * PT_TO_MM)
-#define CM * (CM_TO_PT *PT_TO_MM)
-#define INCH * (INCH_TO_PT * PT_TO_MM)
-#define BIGPOINT * (BIGPOINT_TO_POINT * PT_TO_MM)
-#define CHAR * (CHAR_TO_PT * PT_TO_MM)
+#define PT *(PT_TO_PT *PT_TO_MM)
+#define MM *(MM_TO_PT *PT_TO_MM)
+#define CM *(CM_TO_PT *PT_TO_MM)
+#define INCH *(INCH_TO_PT *PT_TO_MM)
+#define BIGPOINT *(BIGPOINT_TO_POINT *PT_TO_MM)
+#define CHAR *(CHAR_TO_PT *PT_TO_MM)
#endif
-/*
+/*
directional-element.hh -- declare Directional_element
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef DIRECTIONAL_ELEMENT_HH
#define DIRECTIONAL_ELEMENT_HH
#include "grob.hh"
// what is the advantage not having these two as STATICs of GROB -- jcn
-void set_grob_direction (Grob*, Direction);
-Direction get_grob_direction (Grob*);
+void set_grob_direction (Grob *, Direction);
+Direction get_grob_direction (Grob *);
#endif /* DIRECTIONAL_ELEMENT_HH */
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef DOT_COLUMN_HH
#define DOT_COLUMN_HH
class Grob;
/**
- Group dots. This is needed because, the dots have to be aligned per voice
- */
-class Dot_column // interface
+ Group dots. This is needed because, the dots have to be aligned per voice
+*/
+class Dot_column // interface
{
public:
- static int compare (Grob * const&, Grob * const&);
- static void add_head (Grob * dotcol, Grob* rh );
+ static int compare (Grob *const &, Grob *const &);
+ static void add_head (Grob *dotcol, Grob *rh);
- static bool has_interface (Grob*);
- DECLARE_SCHEME_CALLBACK (force_shift_callback, (SCM , SCM));
- DECLARE_SCHEME_CALLBACK (side_position, (SCM , SCM));
- static SCM do_shifts (Grob*);
+ static bool has_interface (Grob *);
+ DECLARE_SCHEME_CALLBACK (force_shift_callback, (SCM, SCM));
+ DECLARE_SCHEME_CALLBACK (side_position, (SCM, SCM));
+ static SCM do_shifts (Grob *);
};
#endif // DOT_COLUMN_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef DOTS_HH
#define DOTS_HH
#include "lily-proto.hh"
#include "lily-guile.hh"
-
-
class Dots
{
public:
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
- bool has_interface (Grob*);
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ bool has_interface (Grob *);
};
#endif // DOTS_HH
/*
duration.hh -- declare Duration
-
+
source file of the LilyPond music typesetter
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
-
*/
#ifndef DURATION_HH
/**
A musical duration.
- */
-struct Duration {
+*/
+struct Duration
+{
public:
-
+
Duration ();
Duration (int, int);
String to_string () const;
Duration compressed (Rational) const;
- Rational get_length () const ;
+ Rational get_length () const;
Rational factor () const { return factor_; }
int duration_log () const;
int dot_count () const;
- static int compare (Duration const&, Duration const&);
+ static int compare (Duration const &, Duration const &);
DECLARE_SCHEME_CALLBACK (less_p, (SCM a, SCM b));
- DECLARE_SIMPLE_SMOBS (Duration, );
+ DECLARE_SIMPLE_SMOBS (Duration,);
private:
/// Logarithm of the base duration.
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef ENGRAVERGROUP_HH
#define ENGRAVERGROUP_HH
#include "engraver.hh"
#include "translator-group.hh"
-
class Engraver_group_engraver : public virtual Engraver,
public virtual Translator_group
{
protected:
Array<Grob_info> announce_infos_;
-
+
public:
- TRANSLATOR_DECLARATIONS(Engraver_group_engraver);
+ TRANSLATOR_DECLARATIONS (Engraver_group_engraver);
virtual void initialize ();
virtual void do_announces ();
(c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef ENGRAVER_HH
#define ENGRAVER_HH
#include "translator.hh"
/**
- a struct which processes events, and creates the #Grob#s.
- It may use derived classes.
- */
-class Engraver : public virtual Translator {
-
+ a struct which processes events, and creates the #Grob#s.
+ It may use derived classes.
+*/
+class Engraver : public virtual Translator
+{
+
friend class Engraver_group_engraver;
protected:
/*
put item in spanner. Adjust local key; etc.
Default: ignore the info
- */
+ */
virtual void acknowledge_grob (Grob_info) {}
/** Do things with stuff found in acknowledge_grob. Ugh. Should
- be looped with acknowledge_grob.
-
- */
+ be looped with acknowledge_grob.
+
+ */
virtual void process_acknowledged_grobs () {}
virtual void announce_grob (Grob_info);
- Engraver_group_engraver*get_daddy_engraver () const;
-
+ Engraver_group_engraver *get_daddy_engraver () const;
+
public:
/**
- Announce element. Default: pass on to daddy. Utility
- */
- void announce_grob (Grob*, SCM cause);
-
- Score_engraver * get_score_engraver () const;
+ Announce element. Default: pass on to daddy. Utility
+ */
+ void announce_grob (Grob *, SCM cause);
+
+ Score_engraver *get_score_engraver () const;
/**
- override other ctor
- */
- TRANSLATOR_DECLARATIONS(Engraver);
+ override other ctor
+ */
+ TRANSLATOR_DECLARATIONS (Engraver);
};
#define make_item(x, cause) make_item_from_properties (this, ly_symbol2scm (x), cause, x)
#define make_spanner(x, cause) make_spanner_from_properties (this, ly_symbol2scm (x), cause, x)
-Item* make_item_from_properties (Engraver * tg, SCM x, SCM cause, const char *name);
-Spanner* make_spanner_from_properties (Engraver * tg, SCM x, SCM cause, const char*name);
-
-
+Item *make_item_from_properties (Engraver *tg, SCM x, SCM cause, const char *name);
+Spanner *make_spanner_from_properties (Engraver *tg, SCM x, SCM cause, const char *name);
#endif // ENGRAVER_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef EVENT_ITER_HH
#define EVENT_ITER_HH
/**
Walk through a Event_chord
- */
+*/
class Event_chord_iterator : public Simple_music_iterator
{
- Event_chord * get_elt () const;
+ Event_chord *get_elt () const;
/**
Find a bottom notation context to deliver events to.
- */
- virtual Context * get_req_translator ();
-
+ */
+ virtual Context *get_req_translator ();
/*
Since Event_chord_iterator has no list-cursor internally, we
must use a status variable to adminstrate where we are */
-
- enum { NONE_DONE, START_DONE, END_DONE } status_;
+
+ enum { NONE_DONE, START_DONE, END_DONE }
+ status_;
+
public:
- DECLARE_SCHEME_CALLBACK(constructor, ());
+ DECLARE_SCHEME_CALLBACK (constructor, ());
Event_chord_iterator ();
- Event_chord_iterator (Event_chord_iterator const&);
+ Event_chord_iterator (Event_chord_iterator const &);
protected:
virtual void process (Moment);
virtual void construct_children ();
};
-
#endif // EVENT_ITER_HH
#ifndef EVENT_HH
#define EVENT_HH
-
#include "input.hh"
#include "music.hh"
#include "duration.hh"
#include "pitch.hh"
/* An atom of musical information. This is an abstract class for any
- piece of music that does not contain other Music. */
+ piece of music that does not contain other Music. */
class Event : public Music
{
public:
Event (SCM);
VIRTUAL_COPY_CONSTRUCTOR (Music, Event);
- DECLARE_SCHEME_CALLBACK(length_callback, (SCM));
+ DECLARE_SCHEME_CALLBACK (length_callback, (SCM));
};
-
-
-
#endif
-/*
+/*
folded-repeat-iterator.hh -- declare Folded_repeat_iterator
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef FOLDED_REPEAT_ITERATOR_HH
#define FOLDED_REPEAT_ITERATOR_HH
/**
Iterate through a repeated section: first do the body, then
all alternatives in parallel.
- */
+*/
class Folded_repeat_iterator : public Music_iterator
{
public:
- DECLARE_SCHEME_CALLBACK(constructor, ());
+ DECLARE_SCHEME_CALLBACK (constructor, ());
Folded_repeat_iterator (Folded_repeat_iterator const &src);
Folded_repeat_iterator ();
virtual void derived_mark () const;
- virtual void derived_substitute (Context *f, Context *t) ;
-
+ virtual void derived_substitute (Context *f, Context *t);
virtual void construct_children ();
virtual Moment pending_moment () const;
- virtual void do_quit();
+ virtual void do_quit ();
virtual bool ok () const;
protected:
void enter_alternative ();
void leave_body ();
-
+
virtual void process (Moment);
virtual Music_iterator *try_music_in_children (Music *) const;
private:
- Music_iterator * main_iter_;
- Music_iterator * alternative_iter_;
+ Music_iterator *main_iter_;
+ Music_iterator *alternative_iter_;
Moment main_length_mom_;
};
-/*
+/*
font-interface.hh -- declare Font_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef FONT_INTERFACE_HH
#define FONT_INTERFACE_HH
struct Font_interface
{
- static SCM text_font_alist_chain (Grob*);
- static SCM music_font_alist_chain (Grob*);
- static Font_metric * get_default_font (Grob*);
- static bool has_interface (Grob*);
+ static SCM text_font_alist_chain (Grob *);
+ static SCM music_font_alist_chain (Grob *);
+ static Font_metric *get_default_font (Grob *);
+ static bool has_interface (Grob *);
};
#endif /* FONT_INTERFACE_HH */
/*
-
font-metric.hh -- declare Font_metric
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
*/
#ifndef FONT_METRIC_HH
virtual Stencil get_indexed_char_stencil (int k) const;
virtual Stencil get_ascii_char_stencil (int k) const;
virtual SCM sub_fonts () const;
- virtual SCM font_file_name () const;
- DECLARE_SMOBS (Font_metric, );
+ virtual SCM font_file_name () const;
+ DECLARE_SMOBS (Font_metric,);
private:
/* No copying, no implicit copy constructor. */
- Font_metric (Font_metric const&);
+ Font_metric (Font_metric const &);
protected:
virtual void derived_mark () const;
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef FREETYPE_HH
#define FREETYPE_HH
#include <ft2build.h>
-#include FT_FREETYPE_H
+#include FT_FREETYPE_H
-void init_freetype();
+void init_freetype ();
extern FT_Library freetype2_library;
#endif /* FREETYPE_HH */
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef GLOBAL_CONTEXT_HH
#define GLOBAL_CONTEXT_HH
class Global_context : public virtual Context
{
PQueue<Moment> extra_mom_pq_;
- Output_def* output_def_;
-
+ Output_def *output_def_;
+
friend class Output_def;
public:
- Global_context (Output_def*, Moment final, Object_key *key);
+ Global_context (Output_def *, Moment final, Object_key *key);
int get_moments_left () const;
Moment sneaky_insert_extra_moment (Moment);
void add_moment_to_process (Moment);
- void run_iterator_on_me (Music_iterator*);
- virtual Score_context*get_score_context () const;
-
+ void run_iterator_on_me (Music_iterator *);
+ virtual Score_context *get_score_context () const;
+
void apply_finalizations ();
void add_finalization (SCM);
- virtual Music_output *get_output ();
+ virtual Music_output *get_output ();
virtual void prepare (Moment);
virtual void one_time_step ();
virtual void finish ();
- virtual Output_def* get_output_def () const;
+ virtual Output_def *get_output_def () const;
virtual Moment now_mom () const;
virtual Context *get_default_interpreter ();
-
Moment previous_moment () const;
protected:
Moment final_mom_;
-/*
+/*
global-ctor.hh -- declare Global construction stuff.
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef GLOBAL_CTOR_HH
#define GLOBAL_CTOR_HH
-
-#define ADD_GLOBAL_CTOR_WITHNAME(y, x)\
-class Global_ctor_ ## y \
-{\
-public: \
- Global_ctor_ ## y () { \
- add_constructor (x); \
- } \
-} _ ## y ## _ctor_init; \
-
+#define ADD_GLOBAL_CTOR_WITHNAME(y, x) \
+ class Global_ctor_ ## y \
+ { \
+ public: \
+ Global_ctor_ ## y () \
+ { \
+ add_constructor (x); \
+ } \
+ } \
+ _ ## y ## _ctor_init;
#define ADD_GLOBAL_CTOR(x) ADD_GLOBAL_CTOR_WITHNAME (x, x);
-
-typedef void (* Global_ctor ) ();
+typedef void (* Global_ctor) ();
void add_constructor (Global_ctor ctor);
void call_constructors ();
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef GOURLAY_BREAKING_HH
#define GOURLAY_BREAKING_HH
#include "break-algorithm.hh"
/**
- A dynamic programming solution to breaking scores into lines
- */
+ A dynamic programming solution to breaking scores into lines
+*/
struct Gourlay_breaking : public Break_algorithm
{
Array<Column_x_positions> do_solve () const;
Gourlay_breaking ();
- Real combine_demerits (Column_x_positions const&, Column_x_positions const&) const;
+ Real combine_demerits (Column_x_positions const &, Column_x_positions const &) const;
};
#endif // GOURLAY_BREAKING_HH
-/*
- grace-fixup.hh -- declare Grace_fixup
-
- source file of the GNU LilyPond music typesetter
+/*
+ grace-fixup.hh -- declare Grace_fixup
- (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ source file of the GNU LilyPond music typesetter
+ (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#ifndef GRACE_FIXUP_HH
#include "moment.hh"
/*
-
This is a lookahead list for grace notes.
- { ... X \grace Y Z ... }
+ { ... X \grace Y Z ... }
- normally, the ending of X is the start of Z. In case of a grace
- note, we take off a little at the end of X. What is stored: START
- (start point of X), LENGTH (length of X), GRACE_START (start_music
- of Y), and the next fixup element.
+ normally, the ending of X is the start of Z. In case of a grace
+ note, we take off a little at the end of X. What is stored: START
+ (start point of X), LENGTH (length of X), GRACE_START (start_music
+ of Y), and the next fixup element.
This is also done for nested musics, i.e.
voiceB = \notes { c'2 \voiceA }
the iterator for voiceB will contain a fixup entry with (START = 0/1,
- LENGTH =2/1, GRACE_START =(0G-1/16) )
-
+ LENGTH =2/1, GRACE_START =(0G-1/16) )
+
Graces at the start of a sequential music iterator are handled
by initting here_mom_ with Music::start_music (); no fixups are needed.
-
*/
-struct Grace_fixup
+struct Grace_fixup
{
Moment start_;
Moment length_;
Rational grace_start_;
- Grace_fixup * next_;
+ Grace_fixup *next_;
};
#endif /* GRACE_FIXUP_HH */
-/*
+/*
grace-iterator.hh -- declare Grace_iterator
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef NEWGRACE_ITERATOR_HH
#define NEWGRACE_ITERATOR_HH
{
public:
virtual void process (Moment);
- DECLARE_SCHEME_CALLBACK(constructor, ());
+ DECLARE_SCHEME_CALLBACK (constructor, ());
Moment pending_moment () const;
};
-
-
#endif /* GRACE_ITERATOR_HH */
-
-/*
+/*
gregorian-ligature-engraver.hh -- declare Gregorian_ligature_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2003--2005 Juergen Reuter <reuter@ipd.uka.de>
-
- */
+*/
#ifndef GREGORIAN_LIGATURE_ENGRAVER_HH
#define GREGORIAN_LIGATURE_ENGRAVER_HH
Music *pes_or_flexa_req_;
public:
- TRANSLATOR_DECLARATIONS(Gregorian_ligature_engraver);
+ TRANSLATOR_DECLARATIONS (Gregorian_ligature_engraver);
protected:
virtual bool try_music (Music *);
gregorian-ligature.hh -- part of GNU LilyPond
source file of the GNU LilyPond music typesetter
-
+
(c) 2003--2005 Juergen Reuter <reuter@ipd.uka.de>
*/
class Grob;
class String;
-class Gregorian_ligature {
+class Gregorian_ligature
+{
public:
static bool has_interface (Grob *);
static String prefixes_to_str (Grob *);
* treated like a prefix for the head that follows the operator, but
* does not affect the head that precedes the operator, if any.
*/
-#define VIRGA 0x0001 // attribute "\virga"
-#define STROPHA 0x0002 // attribute "\stropha"
-#define INCLINATUM 0x0004 // attribute "\inclinatum"
-#define AUCTUM 0x0008 // attribute "\auctum"
-#define DESCENDENS 0x0010 // attribute "\descendens"
-#define ASCENDENS 0x0020 // attribute "\ascendens"
-#define ORISCUS 0x0040 // attribute "\oriscus"
-#define QUILISMA 0x0080 // attribute "\quilisma"
-#define DEMINUTUM 0x0100 // attribute "\deminutum"
-#define CAVUM 0x0200 // attribute "\cavum"
-#define LINEA 0x0400 // attribute "\linea"
+#define VIRGA 0x0001 // attribute "\virga"
+#define STROPHA 0x0002 // attribute "\stropha"
+#define INCLINATUM 0x0004 // attribute "\inclinatum"
+#define AUCTUM 0x0008 // attribute "\auctum"
+#define DESCENDENS 0x0010 // attribute "\descendens"
+#define ASCENDENS 0x0020 // attribute "\ascendens"
+#define ORISCUS 0x0040 // attribute "\oriscus"
+#define QUILISMA 0x0080 // attribute "\quilisma"
+#define DEMINUTUM 0x0100 // attribute "\deminutum"
+#define CAVUM 0x0200 // attribute "\cavum"
+#define LINEA 0x0400 // attribute "\linea"
#define PES_OR_FLEXA 0x0800 // operator "\~"
/*
* These definitions may be extended by more specific Gregorian
* ligatures such as vaticana-ligature.hh.
*/
-#define PES_LOWER 0x0001 // this is a head before "\~" in an
- // ascending melody
-#define PES_UPPER 0x0002 // this is a head after "\~" in an
- // ascending melody
-#define FLEXA_LEFT 0x0004 // this is a head before "\~" in a
- // descending melody
-#define FLEXA_RIGHT 0x0008 // this is a head after "\~" in a
- // descending melody
+#define PES_LOWER 0x0001 // this is a head before "\~" in an
+ // ascending melody
+#define PES_UPPER 0x0002 // this is a head after "\~" in an
+ // ascending melody
+#define FLEXA_LEFT 0x0004 // this is a head before "\~" in a
+// descending melody
+#define FLEXA_RIGHT 0x0008 // this is a head after "\~" in a
+// descending melody
#define AFTER_DEMINUTUM 0x0020 // previous head was a deminutum
#endif /* GREGORIAN_LIGATURE_HH */
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef STAFFELEMINFO_HH
#define STAFFELEMINFO_HH
/*
Data container for broadcasts.
- */
-struct Grob_info {
- Translator * origin_trans_;
+*/
+struct Grob_info
+{
+ Translator *origin_trans_;
friend class Engraver;
- Grob * grob_;
+ Grob *grob_;
public:
- Music * music_cause ();
- Link_array<Context> origin_contexts (Translator*) const;
+ Music *music_cause ();
+ Link_array<Context> origin_contexts (Translator *) const;
Grob_info ();
};
-/*
- interface.hh -- declare Interface
+/*
+ interface.hh -- declare Interface
source file of the GNU LilyPond music typesetter
(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef INTERFACE_HH
#define INTERFACE_HH
#include <libguile.h> /* SCM */
-
-
-#define ADD_INTERFACE(cl, a, b, c) \
-bool cl::has_interface(Grob*me)\
-{\
- return me->internal_has_interface (ly_symbol2scm (a));\
-}\
-void cl ## _init_ifaces() {\
- add_interface(a, b, c);\
-}\
-ADD_SCM_INIT_FUNC(cl ## ifaces, cl ## _init_ifaces);\
-
-
-
-void add_interface (const char * symbol,
- const char * descr,
- const char * vars);
-
-SCM ly_add_interface (SCM, SCM, SCM);
-SCM ly_all_grob_interfaces();
+#define ADD_INTERFACE(cl, a, b, c) \
+ bool cl::has_interface (Grob *me) \
+ { \
+ return me->internal_has_interface (ly_symbol2scm (a)); \
+ } \
+ void cl ## _init_ifaces () \
+ { \
+ add_interface (a, b, c); \
+ } \
+ ADD_SCM_INIT_FUNC (cl ## ifaces, cl ## _init_ifaces);
+
+void add_interface (const char *symbol,
+ const char *descr,
+ const char *vars);
+
+SCM ly_add_interface (SCM, SCM, SCM);
+SCM ly_all_grob_interfaces ();
#endif /* INTERFACE_HH */
-/*
-grob-pitch-tuple.hh -- declare Grob_pitch_tuple
+/*
+ grob-pitch-tuple.hh -- declare Grob_pitch_tuple
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ (c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#ifndef GROB_PITCH_TUPLE_HH
#define GROB_PITCH_TUPLE_HH
#include "pitch.hh"
#include "moment.hh"
-struct Grob_pitch_tuple {
+struct Grob_pitch_tuple
+{
Pitch pitch_;
Grob *head_;
Moment end_;
Grob_pitch_tuple ();
- Grob_pitch_tuple (Grob*, Music*, Moment);
+ Grob_pitch_tuple (Grob *, Music *, Moment);
static int pitch_compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &);
- static int time_compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &);
+ static int time_compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &);
};
-int compare (Grob_pitch_tuple const &, Grob_pitch_tuple const&);
-
+int compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &);
#endif /* GROB_PITCH_TUPLE_HH */
grob.hh -- declare Grob
source file of the LilyPond music typesetter
-
+
(c) 1996--2005 Han-Wen Nienhuys
*/
/**
for administration of what was done already
*/
-enum Grob_status {
- ORPHAN = 0, // not yet added to Paper_score
- PRECALCING,
- PRECALCED, // calcs before spacing done
- POSTCALCING, // busy calculating. This is used to trap cyclic deps.
- POSTCALCED, // after spacing calcs done
-};
+enum Grob_status
+ {
+ ORPHAN = 0, // not yet added to Paper_score
+ PRECALCING,
+ PRECALCED, // calcs before spacing done
+ POSTCALCING, // busy calculating. This is used to trap cyclic deps.
+ POSTCALCED, // after spacing calcs done
+ };
typedef void (Grob::*Grob_method_pointer) (void);
**/
class Grob
{
-private:
+private:
DECLARE_SMOBS (Grob, foo);
void init ();
protected:
- Object_key const * key_;
+ Object_key const *key_;
SCM immutable_property_alist_;
SCM mutable_property_alist_;
-
+
/* BARF */
friend class Spanner;
friend SCM ly_grob_properties (SCM);
friend SCM ly_grob_basic_properties (SCM);
-
+
void substitute_mutable_properties (SCM, SCM);
char status_;
-
+
public:
Object_key const *get_key () const;
-
+
Grob *original_;
/* TODO: junk this member. */
Dimension_cache dim_cache_[NO_AXES];
Grob (SCM basic_props, Object_key const *);
- Grob (Grob const&, int copy_count);
+ Grob (Grob const &, int copy_count);
virtual Grob *clone (int count) const;
DECLARE_SCHEME_CALLBACK (stencil_extent, (SCM smob, SCM axis));
-
+
String name () const;
/*
Properties
- */
+ */
SCM internal_get_property (SCM) const;
void internal_set_property (SCM, SCM val);
void add_to_list_property (SCM, SCM);
SCM get_property_alist_chain (SCM) const;
static SCM ly_grob_set_property (SCM, SCM, SCM);
- static SCM ly_grob_property (SCM, SCM);
+ static SCM ly_grob_property (SCM, SCM);
void warning (String) const;
void programming_error (String) const;
-
+
Output_def *get_layout () const;
- void add_dependency (Grob*);
+ void add_dependency (Grob *);
virtual System *get_system () const;
void calculate_dependencies (int final, int busy, SCM funcname);
-
virtual void do_break_processing ();
- virtual Grob *find_broken_piece (System*) const;
+ virtual Grob *find_broken_piece (System *) const;
virtual void discretionary_processing ();
virtual SCM do_derived_mark () const;
void suicide ();
bool is_live () const;
bool is_empty (Axis a) const;
-
+
bool internal_has_interface (SCM intf);
static bool has_interface (Grob *me);
virtual void handle_broken_dependencies ();
virtual void handle_prebroken_dependencies ();
- Interval extent (Grob * refpoint, Axis) const;
-
+ Interval extent (Grob *refpoint, Axis) const;
+
void translate_axis (Real, Axis);
Real relative_coordinate (Grob const *refp, Axis) const;
Grob *common_refpoint (Grob const *s, Axis a) const;
void set_extent (SCM, Axis);
void set_extent_callback (SCM, Axis);
Real get_offset (Axis a) const;
-
- void set_parent (Grob* e, Axis);
+
+ void set_parent (Grob *e, Axis);
// URG
Grob *get_parent (Axis a) const;
Item *unsmob_item (SCM);
Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a);
-Grob *common_refpoint_of_array (Link_array<Grob> const&, Grob *, Axis a);
+Grob *common_refpoint_of_array (Link_array<Grob> const &, Grob *, Axis a);
void set_break_subsititution (SCM criterion);
SCM substitute_mutable_property_alist (SCM alist);
Link_array<Grob> ly_scm2grobs (SCM ell);
SCM ly_grobs2scm (Link_array<Grob> a);
-Interval robust_relative_extent (Grob*, Grob*, Axis);
+Interval robust_relative_extent (Grob *, Grob *, Axis);
#endif /* GROB_HH */
-/*
+/*
group-interface.hh -- declare Group_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef GROUP_INTERFACE_HH
#define GROUP_INTERFACE_HH
struct Group_interface
{
public:
- static int count (Grob*, SCM);
- static void add_thing (Grob*, SCM, SCM);
+ static int count (Grob *, SCM);
+ static void add_thing (Grob *, SCM, SCM);
};
-struct Pointer_group_interface : public Group_interface {
+struct Pointer_group_interface : public Group_interface
+{
public:
- static void add_grob (Grob*, SCM nm, Grob*e);
+ static void add_grob (Grob *, SCM nm, Grob *e);
};
Link_array<Grob> extract_grob_array (Grob const *elt, SCM symbol);
Link_array<Item> extract_item_array (Grob const *elt, SCM symbol);
-
-
#endif /* GROUP_INTERFACE_HH */
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef HAIRPIN_HH
#define HAIRPIN_HH
#include "lily-guile.hh"
#include "lily-proto.hh"
/**
- The hairpin symbol.
- */
+ The hairpin symbol.
+*/
struct Hairpin
{
public:
DECLARE_SCHEME_CALLBACK (print, (SCM));
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
};
#endif // HAIRPIN_HH
(c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
*/
-
#ifndef HARA_KIRI_VERTICAL_GROUP_SPANNER_HH
#define HARA_KIRI_VERTICAL_GROUP_SPANNER_HH
#include "lily-guile.hh"
#include "lily-proto.hh"
-class Hara_kiri_group_spanner
+class Hara_kiri_group_spanner
{
public:
- DECLARE_SCHEME_CALLBACK (force_hara_kiri_callback, (SCM , SCM));
+ DECLARE_SCHEME_CALLBACK (force_hara_kiri_callback, (SCM, SCM));
DECLARE_SCHEME_CALLBACK (y_extent, (SCM smob, SCM axis));
- DECLARE_SCHEME_CALLBACK (force_hara_kiri_in_parent_callback, (SCM , SCM));
+ DECLARE_SCHEME_CALLBACK (force_hara_kiri_in_parent_callback, (SCM, SCM));
static void add_element (Grob *me, Grob *e);
- static bool has_interface (Grob*);
- static void consider_suicide (Grob*me);
- static void add_interesting_item (Grob * me , Grob* n);
+ static bool has_interface (Grob *);
+ static void consider_suicide (Grob *me);
+ static void add_interesting_item (Grob *me, Grob *n);
};
-
#endif // HARA_KIRI_VERTICAL_GROUP_SPANNER_HH
-/*
-identifier-smob.hh -- declare identifier smob.
+/*
+ identifier-smob.hh -- declare identifier smob.
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#ifndef IDENTIFIER_SMOB_HH
#define IDENTIFIER_SMOB_HH
#include "lily-guile.hh"
-
SCM package_identifier (SCM);
bool identifier_smob_p (SCM);
SCM unpack_identifier (SCM);
typedef struct yy_buffer_state *YY_BUFFER_STATE;
/**
- an yyFlexLexer child with provisions for inclusion.
- */
-class Includable_lexer : public yyFlexLexer
+ an yyFlexLexer child with provisions for inclusion.
+*/
+class Includable_lexer : public yyFlexLexer
{
Array<YY_BUFFER_STATE> state_stack_;
protected:
- bool close_input ();
+ bool close_input ();
Link_array<Source_file> include_stack_;
Array<int> char_count_stack_;
public:
bool allow_includes_b_;
-
+
Includable_lexer ();
~Includable_lexer ();
/// store dependencies for Makefile stuff.
Array<String> file_name_strings_;
- Source_file* get_source_file () const;
- void new_input (String s, Sources*);
- void new_input (String name, String data, Sources*);
+ Source_file *get_source_file () const;
+ void new_input (String s, Sources *);
+ void new_input (String name, String data, Sources *);
- char const * here_str0 () const;
+ char const *here_str0 () const;
};
-
#endif // INCLUDABLE_LEXER_HH
-/*
+/*
input-smob.hh -- declare input smob
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef INPUT_SMOB_HH
#define INPUT_SMOB_HH
#include "smobs.hh"
SCM make_input (Input spot);
-Input *unsmob_input(SCM);
+Input *unsmob_input (SCM);
extern Input dummy_input_global;
#include "flower-proto.hh"
/**
- Base class for anything that records its poisition in the parse file.
- */
-class Input {
+ Base class for anything that records its poisition in the parse file.
+*/
+class Input
+{
public:
char const *start_;
char const *end_;
- Source_file * source_file_;
-
+ Source_file *source_file_;
+
void warning (String) const; // should use member func?
void non_fatal_error (String) const;
void error (String) const;
String location_string () const;
String line_number_string () const;
-
String file_string ()const;
int line_number ()const;
int column_number ()const;
int end_line_number ()const;
int end_column_number ()const;
-
Input (Input const &i);
Input ();
};
-/*
+/*
interpretation-context-handle.hh -- declare Interpretation_context_handle
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef INTERPRETATION_CONTEXT_HANDLE_HH
#define INTERPRETATION_CONTEXT_HANDLE_HH
#include "lily-proto.hh"
/*
-RENAME ME to Context_handle.
+ RENAME ME to Context_handle.
*/
-
+
class Interpretation_context_handle
{
public:
void set_context (Context *);
bool try_music (Music *);
- void operator = (Interpretation_context_handle const&);
- Interpretation_context_handle (Interpretation_context_handle const&);
- Context * get_outlet () const;
+ void operator= (Interpretation_context_handle const &);
+ Interpretation_context_handle (Interpretation_context_handle const &);
+ Context *get_outlet () const;
int get_count () const;
void quit ();
private:
- Context * outlet_;
+ Context *outlet_;
void down ();
void up (Context *);
};
#ifndef ITEM_HH
#define ITEM_HH
-
#include "box.hh"
#include "grob.hh"
-
/**
- A horizontally fixed size element of the score.
-
- Item is the datastructure for printables whose width is known
- before the spacing is calculated
+ A horizontally fixed size element of the score.
+ Item is the datastructure for printables whose width is known
+ before the spacing is calculated
*/
class Item : public Grob
{
- Drul_array<Item*> broken_to_drul_;
+ Drul_array<Item *> broken_to_drul_;
public:
- Item (SCM, Object_key const*);
+ Item (SCM, Object_key const *);
Item (Item const &, int count);
-
+
virtual Grob *clone (int count) const;
static bool is_breakable (Grob *);
bool is_broken () const;
-
+
Direction break_status_dir () const;
-
+
Item *find_prebroken_piece (Direction) const;
- Grob *find_broken_piece (System *) const;
+ Grob *find_broken_piece (System *) const;
virtual System *get_system () const;
virtual Paper_column *get_column () const;
virtual void handle_prebroken_dependencies ();
virtual SCM do_derived_mark () const;
};
-
-
#endif
struct Keyword_ent
{
char const *name_;
- int tokcode_;
+ int tokcode_;
};
/*
junkme, use hash table.
- */
+*/
struct Keyword_table
{
Array<Keyword_ent> table_;
Keyword_table (Keyword_ent *);
- int lookup (char const *s) const;
+ int lookup (char const *s) const;
};
-
#endif // KEYWORD_HH
-/*
+/*
kpath.hh -- declare kpathsea functions.
source file of the GNU LilyPond music typesetter
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef KPATH_HH
#define KPATH_HH
#include "array.hh"
#include "offset.hh"
-
/**
- Least squares minimisation in 2 variables.
- */
-void minimise_least_squares (Real * coef, Real * offset, Array<Offset> const &);
+ Least squares minimisation in 2 variables.
+*/
+void minimise_least_squares (Real *coef, Real *offset, Array<Offset> const &);
#endif // LEASTSQUARE_HH
-/*
+/*
ligature-engraver.hh -- declare Ligature_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2002--2005 Juergen Reuter <reuter@ipd.uka.de>
-
- */
+*/
#ifndef LIGATURE_ENGRAVER_HH
#define LIGATURE_ENGRAVER_HH
virtual void finalize ();
virtual void acknowledge_grob (Grob_info);
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void process_music ();
virtual Spanner *create_ligature_spanner (); /* abstract method */
virtual void typeset_ligature (Spanner *ligature,
SCM brew_ligature_primitive_proc;
public:
- TRANSLATOR_DECLARATIONS(Ligature_engraver);
+ TRANSLATOR_DECLARATIONS (Ligature_engraver);
private:
- Drul_array<Music*> reqs_drul_;
-
+ Drul_array<Music *> reqs_drul_;
+
Spanner *ligature_;
Array<Grob_info> primitives_;
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef LILY_GUILE_MACROS_HH
#define SCM_UNPACK(x) (x)
#endif
-
#if (__GNUC__ > 2)
/* Unreliable with gcc-2.x
FIXME: should add check for x86 as well? */
#ifdef CACHE_SYMBOLS
/* Using this trick we cache the value of scm_str2symbol ("fooo") where
- "fooo" is a constant string. This is done at the cost of one static
- variable per ly_symbol2scm() use, and one boolean evaluation for
- every call.
-
- The overall speedup of lily is about 5% on a run of wtk1-fugue2. */
-#define ly_symbol2scm(x) \
-({ \
- static SCM cached; \
- /* We store this one locally, since G++ -O2 fucks up else */ \
- SCM value = cached; \
- if ( __builtin_constant_p ((x))) \
- { \
- if (!cached) \
- value = cached = scm_gc_protect_object (scm_str2symbol ((x))); \
- } \
- else \
- value = scm_str2symbol ((char*) (x)); \
- value; \
-})
+ "fooo" is a constant string. This is done at the cost of one static
+ variable per ly_symbol2scm() use, and one boolean evaluation for
+ every call.
+
+ The overall speedup of lily is about 5% on a run of wtk1-fugue2. */
+#define ly_symbol2scm(x) \
+ ({ \
+ static SCM cached; \
+ /* We store this one locally, since G++ -O2 fucks up else */ \
+ SCM value = cached; \
+ if (__builtin_constant_p ((x))) \
+ { \
+ if (!cached) \
+ value = cached = scm_gc_protect_object (scm_str2symbol ((x))); \
+ } \
+ else \
+ value = scm_str2symbol ((char *) (x)); \
+ value; \
+ })
#else
-inline SCM ly_symbol2scm(char const* x) { return scm_str2symbol ((x)); }
+inline SCM ly_symbol2scm (char const *x) { return scm_str2symbol ((x)); }
#endif
-
/*
TODO: rename me to ly_c_lily_module_eval
- */
-#define ly_lily_module_constant(x) \
-({ \
- static SCM cached; \
- /* We store this one locally, since G++ -O2 fucks up else */ \
- SCM value = cached; \
- if ( __builtin_constant_p ((x))) \
- { \
- if (!cached) \
- value = cached = scm_gc_protect_object (scm_eval (scm_str2symbol (x), \
- global_lily_module)); \
- } \
- else \
- value = scm_eval (scm_str2symbol (x), global_lily_module); \
- value; \
-})
-
-
+*/
+#define ly_lily_module_constant(x) \
+ ({ \
+ static SCM cached; \
+ /* We store this one locally, since G++ -O2 fucks up else */ \
+ SCM value = cached; \
+ if (__builtin_constant_p ((x))) \
+ { \
+ if (!cached) \
+ value = cached = scm_gc_protect_object (scm_eval (scm_str2symbol (x), \
+ global_lily_module)); \
+ } \
+ else \
+ value = scm_eval (scm_str2symbol (x), global_lily_module); \
+ value; \
+ })
/*
Adds the NAME as a Scheme function, and a variable to store the SCM
version of the function in the static variable NAME_proc
- */
-#define DECLARE_SCHEME_CALLBACK(NAME, ARGS) \
- static SCM NAME ARGS; \
- static SCM NAME ## _proc
+*/
+#define DECLARE_SCHEME_CALLBACK(NAME, ARGS) \
+ static SCM NAME ARGS; \
+ static SCM NAME ## _proc
/*
Make TYPE::FUNC available as a Scheme function.
- */
-#define MAKE_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT) \
-SCM TYPE :: FUNC ## _proc; \
-void \
-TYPE ## _ ## FUNC ## _init_functions () \
-{ \
- TYPE :: FUNC ## _proc = scm_c_define_gsubr (#TYPE "::" #FUNC, \
- (ARGCOUNT), 0, 0, \
- (Scheme_function_unknown)TYPE :: FUNC); \
- scm_c_export (#TYPE "::" #FUNC, NULL); \
-} \
- \
-ADD_SCM_INIT_FUNC (TYPE ## _ ## FUNC ## _callback, \
- TYPE ## _ ## FUNC ## _init_functions);
-
+*/
+#define MAKE_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT) \
+ SCM TYPE :: FUNC ## _proc; \
+ void \
+ TYPE ## _ ## FUNC ## _init_functions () \
+ { \
+ TYPE :: FUNC ## _proc = scm_c_define_gsubr (#TYPE "::" #FUNC, \
+ (ARGCOUNT), 0, 0, \
+ (Scheme_function_unknown)TYPE :: FUNC); \
+ scm_c_export (#TYPE "::" #FUNC, NULL); \
+ } \
+ \
+ ADD_SCM_INIT_FUNC (TYPE ## _ ## FUNC ## _callback, \
+ TYPE ## _ ## FUNC ## _init_functions);
void
ly_add_function_documentation (SCM proc, char const *fname,
char const *varlist,
char const *doc);
-#define ADD_SCM_INIT_FUNC(name, func) \
-class name ## _scm_initter \
-{ \
-public: \
- name ## _scm_initter () \
- { \
- add_scm_init_func (func); \
- } \
-} _ ## name ## _scm_initter; \
+#define ADD_SCM_INIT_FUNC(name, func) \
+ class name ## _scm_initter \
+ { \
+ public: \
+ name ## _scm_initter () \
+ { \
+ add_scm_init_func (func); \
+ } \
+ } \
+ _ ## name ## _scm_initter;
+
/* end define */
#define LY_DEFINE_WITHOUT_DECL(INITPREFIX, FNAME, PRIMNAME, REQ, OPT, VAR, \
- ARGLIST, DOCSTRING) \
-SCM FNAME ## _proc; \
-void \
-INITPREFIX ## init () \
-{ \
- FNAME ## _proc = scm_c_define_gsubr (PRIMNAME, REQ, OPT, VAR, \
- (Scheme_function_unknown) FNAME); \
- ly_add_function_documentation (FNAME ## _proc, PRIMNAME, #ARGLIST, \
- DOCSTRING); \
- scm_c_export (PRIMNAME, NULL); \
-} \
-ADD_SCM_INIT_FUNC (INITPREFIX ## init_unique_prefix, INITPREFIX ## init); \
-SCM \
-FNAME ARGLIST
-
-
-#define LY_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \
-SCM FNAME ARGLIST; \
-LY_DEFINE_WITHOUT_DECL (FNAME, FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, \
- DOCSTRING)
+ ARGLIST, DOCSTRING) \
+ SCM FNAME ## _proc; \
+ void \
+ INITPREFIX ## init () \
+ { \
+ FNAME ## _proc = scm_c_define_gsubr (PRIMNAME, REQ, OPT, VAR, \
+ (Scheme_function_unknown) FNAME); \
+ ly_add_function_documentation (FNAME ## _proc, PRIMNAME, #ARGLIST, \
+ DOCSTRING); \
+ scm_c_export (PRIMNAME, NULL); \
+ } \
+ ADD_SCM_INIT_FUNC (INITPREFIX ## init_unique_prefix, INITPREFIX ## init); \
+ SCM \
+ FNAME ARGLIST
+
+#define LY_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \
+ SCM FNAME ARGLIST; \
+ LY_DEFINE_WITHOUT_DECL (FNAME, FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, \
+ DOCSTRING)
#define LY_DEFINE_MEMBER_FUNCTION(CLASS, FNAME, PRIMNAME, REQ, OPT, VAR, \
- ARGLIST, DOCSTRING) \
-SCM FNAME ARGLIST; \
-LY_DEFINE_WITHOUT_DECL (CLASS ## FNAME, CLASS::FNAME, PRIMNAME, REQ, OPT, \
- VAR, ARGLIST, DOCSTRING)
+ ARGLIST, DOCSTRING) \
+ SCM FNAME ARGLIST; \
+ LY_DEFINE_WITHOUT_DECL (CLASS ## FNAME, CLASS::FNAME, PRIMNAME, REQ, OPT, \
+ VAR, ARGLIST, DOCSTRING)
#define get_property(x) internal_get_property (ly_symbol2scm (x))
#define set_property(x, y) internal_set_property (ly_symbol2scm (x), y)
#include "lily-guile-macros.hh"
#include "ly-module.hh"
-
/** Conversion functions follow the GUILE naming convention, i.e.
A ly_B2A (B b); */
Offset robust_scm2offset (SCM, Offset);
SCM ly_quote_scm (SCM s);
-bool type_check_assignment (SCM val, SCM sym, SCM type_symbol) ;
+bool type_check_assignment (SCM val, SCM sym, SCM type_symbol);
String print_scm_val (SCM val);
SCM ly_number2string (SCM s);
SCM parse_symbol_list (char const *);
-SCM robust_list_ref(int i, SCM l);
+SCM robust_list_ref (int i, SCM l);
SCM alist_to_hashq (SCM);
SCM ly_alist_vals (SCM alist);
SCM ly_hash2alist (SCM tab);
/* inserts at front, removing dublicates */
-inline SCM ly_assoc_front_x(SCM alist, SCM key, SCM val)
+inline SCM ly_assoc_front_x (SCM alist, SCM key, SCM val)
{
- return scm_acons(key, val, scm_assoc_remove_x (alist, key));
+ return scm_acons (key, val, scm_assoc_remove_x (alist, key));
}
inline bool ly_c_list_p (SCM x) { return SCM_NFALSEP (scm_list_p (x)); }
inline bool ly_c_procedure_p (SCM x) { return SCM_NFALSEP (scm_procedure_p (x)); }
-inline bool ly_c_equal_p (SCM x, SCM y) {
+inline bool ly_c_equal_p (SCM x, SCM y)
+{
return SCM_NFALSEP (scm_equal_p (x, y));
}
-
inline bool ly_scm2bool (SCM x) { return SCM_NFALSEP (x); }
-inline char ly_scm2char (SCM x) { return SCM_CHAR(x); }
-inline unsigned long ly_length (SCM x) {
+inline char ly_scm2char (SCM x) { return SCM_CHAR (x); }
+inline unsigned long ly_length (SCM x)
+{
return scm_num2ulong (scm_length (x), 0, "ly_length");
}
inline SCM ly_bool2scm (bool x) { return SCM_BOOL (x); }
-inline SCM ly_append2 (SCM x1, SCM x2) {
+inline SCM ly_append2 (SCM x1, SCM x2)
+{
return scm_append (scm_listify (x1, x2, SCM_UNDEFINED));
}
-inline SCM ly_append3 (SCM x1, SCM x2, SCM x3) {
+inline SCM ly_append3 (SCM x1, SCM x2, SCM x3)
+{
return scm_append (scm_listify (x1, x2, x3, SCM_UNDEFINED));
}
-inline SCM ly_append4 (SCM x1, SCM x2, SCM x3, SCM x4) {
+inline SCM ly_append4 (SCM x1, SCM x2, SCM x3, SCM x4)
+{
return scm_append (scm_listify (x1, x2, x3, x4, SCM_UNDEFINED));
}
/*
display and print newline.
- */
+*/
extern "C" {
-void ly_display_scm (SCM s);
+ void ly_display_scm (SCM s);
}
void read_lily_scm_file (String);
SCM ly_unique (SCM lst);
SCM ly_list_qsort_uniq_x (SCM lst);
-SCM ly_output_formats();
+SCM ly_output_formats ();
SCM ly_kpathsea_find_file (SCM);
/*
snarfing.
- */
+*/
void add_scm_init_func (void (*) ());
extern "C" {
-typedef SCM (*Scheme_function_unknown) ();
+ typedef SCM (*Scheme_function_unknown) ();
}
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
typedef SCM (*Scheme_function_0) ();
typedef SCM (*Scheme_function_1) (SCM);
-typedef SCM (*Scheme_function_2) (SCM, SCM);
-typedef SCM (*Scheme_function_3) (SCM, SCM, SCM);
+typedef SCM (*Scheme_function_2) (SCM, SCM);
+typedef SCM (*Scheme_function_3) (SCM, SCM, SCM);
#else
typedef SCM (*Scheme_function_0) (...);
typedef SCM (*Scheme_function_1) (...);
void kill_lexer ();
void set_lexer ();
-class Lily_lexer : public Includable_lexer
+class Lily_lexer : public Includable_lexer
{
- DECLARE_SMOBS(Lily_lexer, );
+ DECLARE_SMOBS (Lily_lexer,);
public:
SCM scopes_;
-
+
private:
int lookup_keyword (String);
int scan_bare_word (String);
void *lexval;
Input *lexloc;
bool is_main_input_;
-
- Sources *sources_;
+
+ Sources *sources_;
/* Scheme hash tables with (oct name acc) values, and symbol keys. */
SCM chordmodifier_tab_;
int error_level_;
Input last_input_;
- Lily_lexer (Sources*);
- Lily_lexer (Lily_lexer const&);
+ Lily_lexer (Sources *);
+ Lily_lexer (Lily_lexer const &);
int yylex ();
void add_lexed_char (int);
void prepare_for_next_token ();
- int try_special_identifiers (SCM* , SCM);
+ int try_special_identifiers (SCM *, SCM);
Input here_input () const;
-
+
void add_scope (SCM);
SCM remove_scope ();
-
+
void start_main_input ();
SCM lookup_identifier (String s);
TODO: interface is too complicated
*/
-class Lily_parser
+class Lily_parser
{
- DECLARE_SMOBS (Lily_parser, );
- friend int yyparse (void*);
+ DECLARE_SMOBS (Lily_parser,);
+ friend int yyparse (void *);
Array<Input> define_spots_;
- char const* here_str0 () const;
+ char const *here_str0 () const;
Simultaneous_music *get_chord (Pitch tonic,
Array<Pitch> *adds, Array<Pitch> *subs,
- Pitch *inversion, Pitch* bass, Duration d);
+ Pitch *inversion, Pitch *bass, Duration d);
void set_chord_tremolo (int type_i);
void set_last_duration (Duration const *);
void set_last_pitch (Pitch const *);
SCM last_beam_start_;
Lily_parser (Sources *sources);
- Lily_parser (Lily_parser const&);
+ Lily_parser (Lily_parser const &);
DECLARE_SCHEME_CALLBACK (layout_description, ());
- void beam_check (SCM);
+ void beam_check (SCM);
void do_init_file ();
void do_yyparse ();
void parse_file (String init, String name, String out_name);
void parse_string (String ly_code);
void parser_error (String);
- void parser_error (Input const&, String);
+ void parser_error (Input const &, String);
void set_yydebug (bool);
};
/*
- lily-proto.hh -- declare class names.
+ lily-proto.hh -- declare class names.
- source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "flower-proto.hh"
-
-
class Adobe_font_metric;
class All_font_metrics;
class Audio_column;
-/*
+/*
lily-version.hh -- declare version strings
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Jan Nieuwenhuizen <janneke@gnu.org>
-
- */
+*/
#ifndef LILY_VERSION_HH
#define LILY_VERSION_HH
source file of the GNU LilyPond music typesetter
(c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
-
*/
#ifndef LILYPOND_VERSION_HH
#include "string.hh"
-struct Lilypond_version
+struct Lilypond_version
{
Lilypond_version (int major, int minor, int patch);
Lilypond_version (String str);
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef LILYPOND_KEY_HH
static Object_key *from_scheme (SCM);
protected:
virtual int get_type () const;
- virtual void derived_mark () const;
- virtual int do_compare (Object_key const* a) const;
+ virtual void derived_mark () const;
+ virtual int do_compare (Object_key const *a) const;
virtual SCM as_scheme () const;
};
int disambiguation_count_;
public:
- Lilypond_context_key (Object_key const * parent,
+ Lilypond_context_key (Object_key const *parent,
Moment start,
String type,
String id,
- int count);
+ int count);
static Object_key *from_scheme (SCM);
protected:
virtual int get_type () const;
- virtual int do_compare (Object_key const* a) const;
- virtual void derived_mark () const;
+ virtual int do_compare (Object_key const *a) const;
+ virtual void derived_mark () const;
virtual SCM as_scheme () const;
};
static Object_key *from_scheme (SCM);
protected:
virtual int get_type () const;
- virtual int do_compare (Object_key const* a) const;
- virtual void derived_mark () const;
+ virtual int do_compare (Object_key const *a) const;
+ virtual void derived_mark () const;
virtual SCM as_scheme () const;
};
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef LINE_GROUP_GRAV_HH
#define LINE_GROUP_GRAV_HH
#include "engraver-group-engraver.hh"
/**
- Engravers put elements on the same or lowel level in a line.
+ Engravers put elements on the same or lowel level in a line.
- DEPRECATED.
- */
+ DEPRECATED.
+*/
class Line_group_engraver_group : public Engraver_group_engraver
{
protected:
- Spanner *staffline_;
+ Spanner *staffline_;
virtual void create_line_spanner ();
virtual void initialize ();
virtual void finalize ();
public:
- TRANSLATOR_DECLARATIONS(Line_group_engraver_group);
+ TRANSLATOR_DECLARATIONS (Line_group_engraver_group);
};
-
#endif // LINE_GROUP_GRAV_HH
-/*
-line-interface.hh -- declare
+/*
+ line-interface.hh -- declare
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
- */
+ (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+*/
#ifndef LINE_INTERFACE_HH
#define LINE_INTERFACE_HH
struct Line_interface
{
static Stencil line (Grob *me, Offset from, Offset to);
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
static Stencil make_dashed_line (Real th, Offset from, Offset to, Real, Real);
static Stencil make_line (Real th, Offset from, Offset to);
};
#endif /* LINE_INTERFACE_HH */
-
(c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
*/
-
#ifndef LINE_SPANNER_HH
#define LINE_SPANNER_HH
{
public:
DECLARE_SCHEME_CALLBACK (print, (SCM));
- DECLARE_SCHEME_CALLBACK(after_line_breaking, (SCM));
- static Stencil line_stencil (Grob* me, Offset f, Offset t);
- static bool has_interface (Grob*);
+ DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
+ static Stencil line_stencil (Grob *me, Offset f, Offset t);
+ static bool has_interface (Grob *);
private:
static Offset get_broken_offset (Grob *me, Direction dir);
{
static Stencil dot (Offset p, Real radius);
static Stencil bracket (Axis a, Interval iv, Real thick, Real protude, Real blot);
- static Stencil accordion (SCM arg, Real interline_f, Font_metric*fm);
+ static Stencil accordion (SCM arg, Real interline_f, Font_metric *fm);
static Stencil round_filled_polygon (Array<Offset> points, Real blotdiameter);
static Stencil frame (Box b, Real thick, Real blot);
static Stencil slur (Bezier controls, Real cthick, Real thick);
/*
- ly-module.hh -- declare module related helper functions
+ ly-module.hh -- declare module related helper functions
source file of the GNU LilyPond music typesetter
- (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- */
+ (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#ifndef LY_MODULE_HH
#define LY_MODULE_HH
SCM ly_module_lookup (SCM module, SCM sym);
SCM ly_modules_lookup (SCM modules, SCM sym, SCM);
SCM ly_module_symbols (SCM mod);
-void ly_reexport_module (SCM mod);
-inline bool ly_c_module_p (SCM x) { return SCM_MODULEP(x); }
+void ly_reexport_module (SCM mod);
+inline bool ly_c_module_p (SCM x) { return SCM_MODULEP (x); }
void ly_clear_anonymous_modules ();
SCM ly_use_module (SCM mod, SCM used);
source file of the GNU LilyPond music typesetter
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- */
+*/
#ifndef LY_SMOBS_ICC
#define LY_SMOBS_ICC
#include "smobs.hh"
-#define IMPLEMENT_TYPE_P(CL, FUNCNAME) \
-SCM CL ## _type_p_proc; \
-void init_type_ ## CL () \
-{ \
- SCM subr = scm_c_define_gsubr (FUNCNAME, 1, 0, 0, \
- (Scheme_function_unknown) CL::smob_p); \
- CL ## _type_p_proc = subr; \
- ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", \
- "Is @var{x} a @code{" #CL "} object?"); \
- scm_c_export (FUNCNAME, NULL); \
-} \
-ADD_SCM_INIT_FUNC (init_type_ ## CL, init_type_ ## CL)
+#define IMPLEMENT_TYPE_P(CL, FUNCNAME) \
+ SCM CL ## _type_p_proc; \
+ void init_type_ ## CL () \
+ { \
+ SCM subr = scm_c_define_gsubr (FUNCNAME, 1, 0, 0, \
+ (Scheme_function_unknown) CL::smob_p); \
+ CL ## _type_p_proc = subr; \
+ ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", \
+ "Is @var{x} a @code{" #CL "} object?"); \
+ scm_c_export (FUNCNAME, NULL); \
+ } \
+ ADD_SCM_INIT_FUNC (init_type_ ## CL, init_type_ ## CL)
+#define IMPLEMENT_BASE_SMOBS(CL) \
+ scm_t_bits CL::smob_tag_; \
+ SCM \
+ CL::smob_p (SCM s) \
+ { \
+ if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \
+ return SCM_BOOL_T; \
+ else \
+ return SCM_BOOL_F; \
+ \
+ } \
+ \
+ void \
+ CL::init_smobs () \
+ { \
+ smob_tag_ = scm_make_smob_type (#CL, 0); \
+ scm_set_smob_mark (smob_tag_, CL::mark_smob); \
+ scm_set_smob_free (smob_tag_, CL::free_smob); \
+ scm_set_smob_print (smob_tag_, CL::print_smob); \
+ scm_set_smob_equalp (smob_tag_, CL::equal_p); \
+ } \
+ \
+ size_t \
+ CL::free_smob (SCM ses) \
+ { \
+ CL *s = (CL *) SCM_CELL_WORD_1 (ses); \
+ delete s; \
+ scm_gc_unregister_collectable_memory (s, sizeof (CL), #CL " smob"); \
+ return SMOB_FREE_RETURN_VAL (CL); \
+ } \
+ \
+ ADD_SCM_INIT_FUNC (CL, CL::init_smobs)
-#define IMPLEMENT_BASE_SMOBS(CL) \
-scm_t_bits CL::smob_tag_; \
-SCM \
-CL::smob_p (SCM s) \
-{ \
- if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \
- return SCM_BOOL_T; \
- else \
- return SCM_BOOL_F; \
- \
-} \
- \
-void \
-CL::init_smobs () \
-{ \
- smob_tag_ = scm_make_smob_type (#CL, 0); \
- scm_set_smob_mark (smob_tag_, CL::mark_smob); \
- scm_set_smob_free (smob_tag_, CL::free_smob); \
- scm_set_smob_print (smob_tag_, CL::print_smob); \
- scm_set_smob_equalp (smob_tag_, CL::equal_p); \
-} \
- \
-size_t \
-CL::free_smob (SCM ses) \
-{ \
- CL *s = (CL*) SCM_CELL_WORD_1 (ses); \
- delete s; \
- scm_gc_unregister_collectable_memory (s, sizeof (CL), #CL " smob"); \
- return SMOB_FREE_RETURN_VAL(CL); \
-} \
- \
-ADD_SCM_INIT_FUNC (CL, CL::init_smobs)
+#define IMPLEMENT_SIMPLE_SMOBS(CL) \
+ IMPLEMENT_BASE_SMOBS (CL); \
+ SCM CL::smobbed_copy () const \
+ { \
+ CL *ptr = new CL (*this); \
+ SCM s; \
+ s = scm_cons (SCM_PACK (CL::smob_tag_), SCM_PACK (ptr)); \
+ scm_gc_register_collectable_memory ((CL *)this, sizeof (CL), #CL " smob"); \
+ \
+ return s; \
+ }
-#define IMPLEMENT_SIMPLE_SMOBS(CL) \
-IMPLEMENT_BASE_SMOBS(CL); \
-SCM CL::smobbed_copy () const \
-{ \
- CL *ptr = new CL (*this); \
- SCM s; \
- s = scm_cons (SCM_PACK (CL::smob_tag_), SCM_PACK (ptr)); \
- scm_gc_register_collectable_memory ((CL*)this, sizeof (CL), #CL " smob"); \
- \
- return s; \
-} \
-
-
-#define IMPLEMENT_SMOBS(CL) \
-IMPLEMENT_BASE_SMOBS (CL) \
-void \
-CL::smobify_self () \
-{ \
- SCM s = unprotected_smobify_self (); \
- scm_gc_protect_object (s); \
-} \
- \
-SCM \
-CL::unprotected_smobify_self () \
-{ \
- /* \
- This is local. We don't assign to self_scm_ directly, to assure \
- that S isn't GC-ed from under us. \
- \
- We don't use smobbed_self () to ensure that mark_smob () doesn't have to \
- deal half-initialized objects: scm_done_malloc ( ) might trigger GC. \
- the warning in smobs.hh is just to be doubleplus goodly sure \
- */ \
- SCM s; \
- SCM_NEWSMOB (s, CL::smob_tag_, this); \
- self_scm_ = s; \
- scm_gc_register_collectable_memory (this, sizeof (CL), #CL " smob"); \
- return s; \
-}
-
-#define IMPLEMENT_DEFAULT_EQUAL_P(CL) \
-SCM \
-CL::equal_p (SCM a , SCM b) \
-{ \
- return a == b ? SCM_BOOL_T : SCM_BOOL_F; \
-} \
+#define IMPLEMENT_SMOBS(CL) \
+ IMPLEMENT_BASE_SMOBS (CL) \
+ void \
+ CL::smobify_self () \
+ { \
+ SCM s = unprotected_smobify_self (); \
+ scm_gc_protect_object (s); \
+ } \
+ \
+ SCM \
+ CL::unprotected_smobify_self () \
+ { \
+ /* \
+ This is local. We don't assign to self_scm_ directly, to assure \
+ that S isn't GC-ed from under us. \
+ \
+ We don't use smobbed_self () to ensure that mark_smob () doesn't have to \
+ deal half-initialized objects: scm_done_malloc ( ) might trigger GC. \
+ the warning in smobs.hh is just to be doubleplus goodly sure \
+ */ \
+ SCM s; \
+ SCM_NEWSMOB (s, CL::smob_tag_, this); \
+ self_scm_ = s; \
+ scm_gc_register_collectable_memory (this, sizeof (CL), #CL " smob"); \
+ return s; \
+ }
+#define IMPLEMENT_DEFAULT_EQUAL_P(CL) \
+ SCM \
+ CL::equal_p (SCM a, SCM b) \
+ { \
+ return a == b ? SCM_BOOL_T : SCM_BOOL_F; \
+ }
#endif /* LY_SMOBS_ICC */
-
#include "spanner.hh"
/*
-
Extenders must be entered manually for now.
Although it would be possible for Lily to determine where to
for on a word's last syllable. The extender should be aligned
with the left side of the last note of the melissima, and not
extend beond, lasting the whole duration of the melissima
-
- */
+*/
class Lyric_extender
{
public:
- static bool has_interface (Grob*);
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
+ static bool has_interface (Grob *);
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
};
#endif // EXTENDER_SPANNER_HH
#include "spanner.hh"
-struct Hyphen_spanner
+struct Hyphen_spanner
{
public:
- DECLARE_SCHEME_CALLBACK(set_spacing_rods, (SCM));
- bool has_interface (Grob*);
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
+ DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM));
+ bool has_interface (Grob *);
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
};
#endif // HYPHEN_SPANNER_HH
void set_debug (bool);
void do_scores ();
void clear_scores ();
-void add_score (Score* s);
+void add_score (Score *s);
void set_default_output (String s);
String find_file (String);
void call_constructors ();
Array<String> get_inclusion_names ();
void set_inclusion_names (Array<String>);
-
extern String init_name_global;
/* options */
extern String prefix_directory;
/*
- todo: collect in Output_option struct?
- */
+ todo: collect in Output_option struct?
+*/
extern String output_format_global;
extern bool make_preview;
/*
Debugging options
- */
+*/
#ifndef NDEBUG
#define DEBUG_SLUR_SCORING 1
-/*
-measure-grouping-spanner.hh -- declare
+/*
+ measure-grouping-spanner.hh -- declare
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#ifndef MEASURE_GROUPING_SPANNER_HH
#define MEASURE_GROUPING_SPANNER_HH
class Measure_grouping
{
public:
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
-
- static bool has_interface (Grob*);
-};
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ static bool has_interface (Grob *);
+};
#endif /* MEASURE_GROUPING_SPANNER_HH */
mensural-ligature.hh -- part of GNU LilyPond
source file of the GNU LilyPond music typesetter
-
+
(c) 2002--2005 Juergen Reuter <reuter@ipd.uka.de>,
- Pal Benko <benkop@freestart.hu>
+ Pal Benko <benkop@freestart.hu>
*/
#ifndef MENSURAL_LIGATURE_HH
* These are all possible mensural ligature primitives.
*/
-#define MLP_NONE 0x00 // no output
-#define MLP_UP 0x01 // ligatura ascendens
-#define MLP_DOWN 0x02 // ligatura descendens
-#define MLP_BREVIS 0x04 // mensural brevis head
-#define MLP_LONGA 0x08 // mensural brevis head with right cauda
-#define MLP_MAXIMA 0x10 // mensural maxima head without stem
-#define MLP_FLEXA 0x20
+#define MLP_NONE 0x00 // no output
+#define MLP_UP 0x01 // ligatura ascendens
+#define MLP_DOWN 0x02 // ligatura descendens
+#define MLP_BREVIS 0x04 // mensural brevis head
+#define MLP_LONGA 0x08 // mensural brevis head with right cauda
+#define MLP_MAXIMA 0x10 // mensural maxima head without stem
+#define MLP_FLEXA 0x20
-#define MLP_STEM (MLP_UP | MLP_DOWN)
-#define MLP_SINGLE_HEAD (MLP_BREVIS | MLP_LONGA | MLP_MAXIMA)
-#define MLP_ANY (MLP_FLEXA | MLP_SINGLE_HEAD)
+#define MLP_STEM (MLP_UP | MLP_DOWN)
+#define MLP_SINGLE_HEAD (MLP_BREVIS | MLP_LONGA | MLP_MAXIMA)
+#define MLP_ANY (MLP_FLEXA | MLP_SINGLE_HEAD)
struct Mensural_ligature
{
- DECLARE_SCHEME_CALLBACK (brew_ligature_primitive, (SCM ));
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
- static bool has_interface (Grob*);
+ DECLARE_SCHEME_CALLBACK (brew_ligature_primitive, (SCM));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ static bool has_interface (Grob *);
};
#endif /* MENSURAL_LIGATURE_HH */
midi-item.hh -- declare Midi items
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#ifndef MIDI_ITEM_HH
#define MIDI_ITEM_HH
#include "audio-item.hh"
/**
- Any piece of midi information.
+ Any piece of midi information.
- Maybe use base classes for RIFF files?
- */
+ Maybe use base classes for RIFF files?
+*/
class Midi_item
{
public:
virtual ~Midi_item ();
/// factory
- static Midi_item* get_midi (Audio_item* a);
+ static Midi_item *get_midi (Audio_item *a);
static String i2varint_string (int i);
};
/**
- timed MIDI event
- */
+ timed MIDI event
+*/
class Midi_event
{
public:
- Midi_event (Moment delta_mom, Midi_item* midi);
+ Midi_event (Moment delta_mom, Midi_item *midi);
Moment delta_mom_;
- Midi_item* midi_;
+ Midi_item *midi_;
String to_string () const;
};
/**
- variable sized MIDI data
- */
+ variable sized MIDI data
+*/
class Midi_chunk : public Midi_item
{
public:
};
/**
- Change instrument event
- */
+ Change instrument event
+*/
class Midi_instrument : public Midi_item
{
public:
- Midi_instrument (Audio_instrument*);
+ Midi_instrument (Audio_instrument *);
virtual String to_string () const;
- Audio_instrument* audio_;
+ Audio_instrument *audio_;
};
-
class Midi_key : public Midi_item
{
public:
- Midi_key (Audio_key*);
-
+ Midi_key (Audio_key *);
+
virtual String to_string () const;
- Audio_key* audio_;
+ Audio_key *audio_;
};
class Midi_time_signature : public Midi_item
{
public:
- Midi_time_signature (Audio_time_signature*);
-
+ Midi_time_signature (Audio_time_signature *);
+
virtual String to_string () const;
- Audio_time_signature* audio_;
+ Audio_time_signature *audio_;
int clocks_per_1_;
};
/**
- Turn a note on.
- */
+ Turn a note on.
+*/
class Midi_note : public Midi_item
{
public:
- Midi_note (Audio_note*);
+ Midi_note (Audio_note *);
Moment get_length () const;
int get_pitch () const;
int get_fine_tuning () const;
virtual String to_string () const;
- Audio_note* audio_;
+ Audio_note *audio_;
static int const c0_pitch_i_ = 60;
Byte dynamic_byte_;
};
/**
- Turn a note off
- */
+ Turn a note off
+*/
class Midi_note_off : public Midi_note
{
public:
- Midi_note_off (Midi_note*);
+ Midi_note_off (Midi_note *);
virtual String to_string () const;
- Midi_note* on_;
+ Midi_note *on_;
Byte aftertouch_byte_;
};
class Midi_text : public Midi_item
{
public:
- enum Type {
- TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC,
- MARKER, CUE_POINT
- };
+ enum Type
+ {
+ TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC,
+ MARKER, CUE_POINT
+ };
+
+ Midi_text (Audio_text *);
- Midi_text (Audio_text*);
-
virtual String to_string () const;
- Audio_text* audio_;
+ Audio_text *audio_;
};
class Midi_dynamic : public Midi_item
{
public:
- Midi_dynamic (Audio_dynamic*);
-
+ Midi_dynamic (Audio_dynamic *);
+
virtual String to_string () const;
- Audio_dynamic* audio_;
+ Audio_dynamic *audio_;
};
class Midi_piano_pedal : public Midi_item
{
public:
- Midi_piano_pedal (Audio_piano_pedal*);
-
+ Midi_piano_pedal (Audio_piano_pedal *);
+
virtual String to_string () const;
- Audio_piano_pedal* audio_;
+ Audio_piano_pedal *audio_;
};
class Midi_tempo : public Midi_item
{
public:
- Midi_tempo (Audio_tempo*);
-
+ Midi_tempo (Audio_tempo *);
+
virtual String to_string () const;
- Audio_tempo* audio_;
+ Audio_tempo *audio_;
};
class Midi_track : public Midi_chunk
/*
Compensate for starting grace notes.
- */
+ */
Cons_list<Midi_event> event_p_list_;
-
+
Midi_track ();
- void add (Moment delta_time_mom, Midi_item* midi);
+ void add (Moment delta_time_mom, Midi_item *midi);
virtual String data_string () const;
};
midi-stream.hh -- declare Midi_stream
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#ifndef MIDI_STREAM_HH
#define MIDI_STREAM_HH
class Midi_item;
/// Midi outputfile
-struct Midi_stream {
+struct Midi_stream
+{
Midi_stream (String file_name_string);
~Midi_stream ();
- Midi_stream& operator << ( String str);
- Midi_stream& operator << ( Midi_item const& midi_c_r);
- Midi_stream& operator << ( int i);
+ Midi_stream &operator<< (String str);
+ Midi_stream &operator<< (Midi_item const &midi_c_r);
+ Midi_stream &operator<< (int i);
void open ();
midi-walker.hh -- declare Midi_walker
(c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
- */
+ Jan Nieuwenhuizen <janneke@gnu.org>
+*/
#ifndef MIDI_WALKER_HH
#define MIDI_WALKER_HH
#include "lily-proto.hh"
#include "moment.hh"
-struct Midi_note_event : PQueue_ent<Moment, Midi_note*>
+struct Midi_note_event : PQueue_ent < Moment, Midi_note *>
{
bool ignore_b_;
Midi_note_event ();
};
-int compare (Midi_note_event const& left, Midi_note_event const& right);
+int compare (Midi_note_event const &left, Midi_note_event const &right);
/**
- walk audio and output midi
- */
+ walk audio and output midi
+*/
class Midi_walker
{
public:
- Midi_walker (Audio_staff* audio_staff, Midi_track* midi_track);
+ Midi_walker (Audio_staff *audio_staff, Midi_track *midi_track);
~Midi_walker ();
void process ();
- void operator ++ (int);
+ void operator++ (int);
bool ok () const;
private:
- void do_start_note (Midi_note* note);
+ void do_start_note (Midi_note *note);
void do_stop_notes (Moment now_mom);
- void output_event (Moment now_mom, Midi_item* l);
-
- Midi_track* track_;
- Audio_staff* staff_;
+ void output_event (Moment now_mom, Midi_item *l);
+
+ Midi_track *track_;
+ Audio_staff *staff_;
int index_;
Link_array<Audio_item> * items_;
PQueue<Midi_note_event> stop_note_queue;
Moment last_mom_;
};
-
#endif // MIDI_WALKER_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef MINTERVAL_HH
#define MINTERVAL_HH
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef MISC_HH
#include "array.hh"
#include "interval.hh"
-double log_2 (double x) ;
+double log_2 (double x);
int intlog2 (int d);
inline int
sign (int i)
{
- if (i<0)
+ if (i < 0)
return -1;
else if (i)
return 1;
Array<String> split_string (String s, char c);
inline Real
-linear_interpolate (Real x, Real x1, Real x2, Real y1, Real y2)
+linear_interpolate (Real x, Real x1, Real x2, Real y1, Real y2)
{
- return (x2 - x) / (x2 - x1) * y1 +
- (x - x1) / (x2 - x1) * y2 ;
+ return (x2 - x) / (x2 - x1) * y1
+ + (x - x1) / (x2 - x1) * y2;
}
#endif
-/*
+/*
modified-font-metric.hh -- declare Font_metric
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
public:
virtual Box text_dimension (String) const;
virtual Stencil text_stencil (String) const;
-
+
static SCM make_scaled_font_metric (Font_metric *fm, Real magnification);
virtual int count () const;
virtual Offset get_indexed_wxwy (int) const;
virtual Offset attachment_point (String) const;
virtual int name_to_index (String) const;
virtual unsigned index_to_charcode (int) const;
- Font_metric*original_font () const;
-
+ Font_metric *original_font () const;
+
protected:
Font_metric *orig_;
Real magnification_;
-
+
Modified_font_metric (Font_metric *fm, Real magnification);
virtual SCM sub_fonts () const;
virtual String font_name () const;
virtual Real design_size () const;
- virtual void derived_mark () const;
+ virtual void derived_mark () const;
virtual Box get_indexed_char (int) const;
virtual int index_to_ascii (int) const;
virtual Box get_ascii_char (int) const;
-/*
+/*
moment.hh -- declare Moment
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef MOMENT_HH
#define MOMENT_HH
*/
class Moment
{
- DECLARE_SIMPLE_SMOBS (Moment, );
+ DECLARE_SIMPLE_SMOBS (Moment,);
public:
Moment ();
Moment (int m);
Moment (Rational, Rational);
Moment (Rational m);
- Moment operator - () const;
-
- void operator += (Moment const &m);
- void operator -= (Moment const &m);
+ Moment operator- () const;
- void operator *= (Moment const &m);
- void operator /= (Moment const &m);
+ void operator+= (Moment const &m);
+ void operator-= (Moment const &m);
+
+ void operator*= (Moment const &m);
+ void operator/= (Moment const &m);
Rational main_part_;
Rational grace_part_;
int num () const;
/*
Deliver a copy of THIS as a smobified SCM
- */
+ */
String to_string () const;
- static int compare (Moment const&, Moment const&);
+ static int compare (Moment const &, Moment const &);
SCM as_scheme () const;
};
-IMPLEMENT_ARITHMETIC_OPERATOR (Moment, + );
-IMPLEMENT_ARITHMETIC_OPERATOR (Moment, - );
-IMPLEMENT_ARITHMETIC_OPERATOR (Moment, / );
-IMPLEMENT_ARITHMETIC_OPERATOR (Moment, * );
-
+IMPLEMENT_ARITHMETIC_OPERATOR (Moment, +);
+IMPLEMENT_ARITHMETIC_OPERATOR (Moment, -);
+IMPLEMENT_ARITHMETIC_OPERATOR (Moment, /);
+IMPLEMENT_ARITHMETIC_OPERATOR (Moment, *);
-DECLARE_UNSMOB(Moment, moment);
-int compare (Moment const&, Moment const&);
-INSTANTIATE_COMPARE (Moment const&, Moment::compare);
+DECLARE_UNSMOB (Moment, moment);
+int compare (Moment const &, Moment const &);
+INSTANTIATE_COMPARE (Moment const &, Moment::compare);
Moment robust_scm2moment (SCM, Moment);
#ifdef STREAM_SUPPORT
-std::ostream & operator << (std::ostream &, Moment const &);
+std::ostream & operator<< (std::ostream &, Moment const &);
#endif
bool moment_less (SCM a, SCM b);
-/*
+/*
multi-measure-rest.hh -- declare Multi_measure_rest
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
-
- */
+*/
#ifndef MULTI_MEASURE_REST_HH
#define MULTI_MEASURE_REST_HH
class Multi_measure_rest
{
public:
- static bool has_interface (Grob*);
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
+ static bool has_interface (Grob *);
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (percent, (SCM));
- static void add_column (Grob*, Item*);
- DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM ));
- DECLARE_SCHEME_CALLBACK (centered_stencil, (SCM ));
-
- static Stencil big_rest (Grob*, Real);
- static Stencil symbol_stencil (Grob*, Real);
- static Stencil church_rest (Grob*, Font_metric*, int, Real);
+ static void add_column (Grob *, Item *);
+ DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM));
+ DECLARE_SCHEME_CALLBACK (centered_stencil, (SCM));
+
+ static Stencil big_rest (Grob *, Real);
+ static Stencil symbol_stencil (Grob *, Real);
+ static Stencil church_rest (Grob *, Font_metric *, int, Real);
};
#endif /* MULTI_MEASURE_REST_HH */
-/*
+/*
music-constructor.hh -- declare Music_constructor
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef MUSIC_CONSTRUCTOR_HH
#define MUSIC_CONSTRUCTOR_HH
#include "string.hh"
#include "global-ctor.hh"
-#define ADD_MUSIC(type) \
-Music * _ ## type ## _ctor (SCM init)\
-{\
- return new type (init);\
-}\
-static void _ ## type ## _adder () {\
- add_music_ctor (#type, & _ ## type ## _ctor);\
-}\
-ADD_SCM_INIT_FUNC( _ ## type ## _adder_prefix, _ ## type ## _adder);
+#define ADD_MUSIC(type) \
+ Music *_ ## type ## _ctor (SCM init) \
+ { \
+ return new type (init); \
+ } \
+ static void _ ## type ## _adder () \
+ { \
+ add_music_ctor (#type, & _ ## type ## _ctor); \
+ } \
+ ADD_SCM_INIT_FUNC (_ ## type ## _adder_prefix, _ ## type ## _adder);
typedef Music *(*Music_ctor) (SCM);
void add_music_ctor (String, Music_ctor);
-Music*make_music (String, SCM);
-
-
-
+Music *make_music (String, SCM);
#endif /* MUSIC_CONSTRUCTOR_HH */
-/*
+/*
music-head.hh -- declare music_function
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef MUSIC_FUNCTION_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef MUSIC_ITERATOR_HH
#define MUSIC_ITERATOR_HH
---
-
- Conceptually a music-iterator operates on a queue of musical events
- that are pending. This queue does not actually exist, but it is a
- way of viewing and traversing music-expressions.
-
- ok () -- events left ?
+ Conceptually a music-iterator operates on a queue of musical events
+ that are pending. This queue does not actually exist, but it is a
+ way of viewing and traversing music-expressions.
+
+
+ ok () -- events left ?
+
+ pending_mom () -- time tag of the next event to be processed.
+ PRECONDITION: this->ok () holds.
- pending_mom () -- time tag of the next event to be processed.
- PRECONDITION: this->ok () holds.
-
- process (M) -- process all at M (Precondition: no events exist
- before M, this->ok () holds). Side-effects:
-
- * This removes all events at M from the pending queue.
+ process (M) -- process all at M (Precondition: no events exist
+ before M, this->ok () holds). Side-effects:
- * Typically this reports the music to an interpretation context,
- thus changing the state of the interpretation context.
+ * This removes all events at M from the pending queue.
+ * Typically this reports the music to an interpretation context,
+ thus changing the state of the interpretation context.
- TODO:
- merge pending_moment and process?
-
+ TODO:
+
+ merge pending_moment and process?
*/
class Music_iterator
{
Moment start_mom_;
DECLARE_SMOBS (Music_iterator, dummy);
- Music_iterator (Music_iterator const&);
+ Music_iterator (Music_iterator const &);
public:
-
+
Moment music_get_length () const;
Moment music_start_mom () const;
Music_iterator ();
Do the reporting. Will try MUSIC_L_ in its own translator first,
then its children. Returns the iterator that succeeded
*/
- Music_iterator * try_music (Music *) const;
-
+ Music_iterator *try_music (Music *) const;
+
/**
- The translation unit that we this iterator is reporting to now.
- */
- Context * get_outlet () const;
+ The translation unit that we this iterator is reporting to now.
+ */
+ Context *get_outlet () const;
void set_context (Context *);
-
+
/** Get an iterator matching the type of MUS, and use TRANS to find
- an accompanying translation unit
- */
- static SCM get_static_get_iterator (Music * mus);
- void init_translator (Music *, Context *);
+ an accompanying translation unit
+ */
+ static SCM get_static_get_iterator (Music *mus);
+ void init_translator (Music *, Context *);
void quit ();
- void substitute_outlet (Context * from, Context *to);
+ void substitute_outlet (Context *from, Context *to);
virtual void derived_substitute (Context *, Context *);
virtual Moment pending_moment () const;
virtual bool ok () const;
- virtual bool run_always () const;
+ virtual bool run_always () const;
virtual void process (Moment until);
virtual void derived_mark () const;
virtual void construct_children ();
-
+
/**
- Construct sub-iterators, and set the translator to
- report to.
- */
+ Construct sub-iterators, and set the translator to
+ report to.
+ */
+
+ DECLARE_SCHEME_CALLBACK (constructor, ());
- DECLARE_SCHEME_CALLBACK(constructor, ());
-
/**
- Get an iterator for MUS, inheriting the translation unit from THIS.
- */
+ Get an iterator for MUS, inheriting the translation unit from THIS.
+ */
SCM get_iterator (Music *) const;
- virtual Music_iterator* try_music_in_children (Music *) const;
+ virtual Music_iterator *try_music_in_children (Music *) const;
- Music * get_music () const;
+ Music *get_music () const;
protected:
- virtual void do_quit();
- void descend_to_child (Context*);
+ virtual void do_quit ();
+ void descend_to_child (Context *);
private:
Interpretation_context_handle handle_;
- Music * music_;
+ Music *music_;
};
bool is_child_context (Context *me, Context *child);
-#define IMPLEMENT_CTOR_CALLBACK(Class) \
-LY_DEFINE_MEMBER_FUNCTION(Class, constructor, #Class "::constructor", \
- 0, 0, 0, \
- (), \
- "")\
-{ \
- SCM val = (new Class)->self_scm(); \
- scm_gc_unprotect_object (val);\
- return val ; \
-} \
-
-DECLARE_UNSMOB(Music_iterator, iterator);
+#define IMPLEMENT_CTOR_CALLBACK(Class) \
+ LY_DEFINE_MEMBER_FUNCTION (Class, constructor, #Class "::constructor", \
+ 0, 0, 0, \
+ (), \
+ "") \
+ { \
+ SCM val = (new Class)->self_scm (); \
+ scm_gc_unprotect_object (val); \
+ return val; \
+ }
+
+DECLARE_UNSMOB (Music_iterator, iterator);
#endif // MUSIC_ITERATOR_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef MUSIC_OUTPUT_HH
#define MUSIC_OUTPUT_HH
#include "lily-proto.hh"
#include "protected-scm.hh"
-class Music_output
+class Music_output
{
public:
virtual SCM process (String) {return SCM_EOL;}
-/*
+/*
music-sequence.hh -- declare Music_sequence
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef MUSIC_SEQUENCE_HH
#define MUSIC_SEQUENCE_HH
struct Music_sequence
{
public:
- DECLARE_SCHEME_CALLBACK(cumulative_length_callback, (SCM));
- DECLARE_SCHEME_CALLBACK(maximum_length_callback, (SCM));
- DECLARE_SCHEME_CALLBACK(minimum_start_callback, (SCM));
- DECLARE_SCHEME_CALLBACK(first_start_callback, (SCM));
- DECLARE_SCHEME_CALLBACK(simultaneous_relative_callback, (SCM, SCM));
- DECLARE_SCHEME_CALLBACK(event_chord_relative_callback, (SCM, SCM));
-
+ DECLARE_SCHEME_CALLBACK (cumulative_length_callback, (SCM));
+ DECLARE_SCHEME_CALLBACK (maximum_length_callback, (SCM));
+ DECLARE_SCHEME_CALLBACK (minimum_start_callback, (SCM));
+ DECLARE_SCHEME_CALLBACK (first_start_callback, (SCM));
+ DECLARE_SCHEME_CALLBACK (simultaneous_relative_callback, (SCM, SCM));
+ DECLARE_SCHEME_CALLBACK (event_chord_relative_callback, (SCM, SCM));
+
Pitch do_relative_octave (Pitch p, bool b);
-
- static Moment cumulative_length (SCM) ;
- static Moment maximum_length (SCM) ;
- static Moment first_start (SCM list) ;
+
+ static Moment cumulative_length (SCM);
+ static Moment maximum_length (SCM);
+ static Moment first_start (SCM list);
static Moment minimum_start (SCM list);
};
SCM ly_transpose_key_alist (SCM l, SCM pit);
Pitch music_list_to_relative (SCM l, Pitch p, bool ret_first);
-void transpose_music_list (SCM , Pitch);
+void transpose_music_list (SCM, Pitch);
void compress_music_list (SCM, Moment);
#endif
-/*
+/*
music-wrapper-iterator.hh -- declare Music_wrapper_iterator
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef MUSIC_WRAPPER_ITERATOR_HH
#define MUSIC_WRAPPER_ITERATOR_HH
#include "music.hh"
#include "music-iterator.hh"
-/**
- The iterator for a #Music_wrapper#. Since #Music_wrapper# essentially
- does nothing, this iterator creates a child iterator and delegates
- all work to that child.
- */
+/**
+ The iterator for a #Music_wrapper#. Since #Music_wrapper# essentially
+ does nothing, this iterator creates a child iterator and delegates
+ all work to that child.
+*/
class Music_wrapper_iterator : public Music_iterator
{
public:
- DECLARE_SCHEME_CALLBACK(constructor, ());
+ DECLARE_SCHEME_CALLBACK (constructor, ());
Music_wrapper_iterator ();
- virtual void derived_substitute (Context *f, Context *t) ;
+ virtual void derived_substitute (Context *f, Context *t);
virtual void derived_mark () const;
- virtual void construct_children () ;
+ virtual void construct_children ();
virtual Moment pending_moment () const;
- virtual void do_quit();
+ virtual void do_quit ();
virtual bool ok () const;
virtual bool run_always () const;
protected:
#endif /* MUSIC_WRAPPER_ITERATOR_HH */
-
-
-/*
+/*
music-wrapper.hh -- declare Music_wrapper
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef MUSIC_WRAPPER_HH
#define MUSIC_WRAPPER_HH
#include "pitch.hh"
/** A Music that modifies an existing Music. This data structure
- corresponds to a production that takes a single Music argument,
-
- Music: STUFF Music
+ corresponds to a production that takes a single Music argument,
- */
+ Music: STUFF Music
+*/
class Music_wrapper : public Music
{
public:
Music_wrapper (SCM);
VIRTUAL_COPY_CONSTRUCTOR (Music, Music_wrapper);
- DECLARE_SCHEME_CALLBACK(length_callback, (SCM));
- DECLARE_SCHEME_CALLBACK(start_callback, (SCM));
-
+ DECLARE_SCHEME_CALLBACK (length_callback, (SCM));
+ DECLARE_SCHEME_CALLBACK (start_callback, (SCM));
+
Music *element () const;
};
#define is_mus_type(x) internal_is_music_type (ly_symbol2scm (x))
-
class Music
{
public:
Music (Music const &m);
VIRTUAL_COPY_CONSTRUCTOR (Music, Music);
- Input *origin () const;
+ Input *origin () const;
void set_spot (Input);
SCM internal_get_property (SCM) const;
- void internal_set_property (SCM , SCM val);
+ void internal_set_property (SCM, SCM val);
SCM get_property_alist (bool mutble) const;
bool internal_is_music_type (SCM) const;
int duration_log () const;
-
- DECLARE_SCHEME_CALLBACK(relative_callback, (SCM, SCM));
+
+ DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM));
Pitch to_relative_octave (Pitch);
- Pitch generic_to_relative_octave (Pitch);
+ Pitch generic_to_relative_octave (Pitch);
String name () const;
Moment get_length () const;
Moment start_mom () const;
/// Transpose, with the interval central C to #p#
void transpose (Pitch p);
-
+
/// Scale the music in time by #factor#.
void compress (Moment factor);
-
+
protected:
- DECLARE_SMOBS (Music, );
+ DECLARE_SMOBS (Music,);
SCM immutable_property_alist_;
SCM mutable_property_alist_;
protected:
friend SCM ly_extended_make_music (SCM, SCM);
};
-DECLARE_TYPE_P(Music);
-DECLARE_UNSMOB(Music, music);
+DECLARE_TYPE_P (Music);
+DECLARE_UNSMOB (Music, music);
Music *make_music_by_name (SCM sym);
SCM ly_music_deep_copy (SCM);
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef COLLISION_HH
#define COLLISION_HH
#include "parray.hh"
/**
- Resolve conflicts between various Note_columns (chords).
-
- TODO
+ Resolve conflicts between various Note_columns (chords).
- * multistaff support (see Chlapik: equal noteheads should be on the
- same hpos.)
+ TODO
- * Make interface of this, similar to align-interface.
-
-*/
+ * multistaff support (see Chlapik: equal noteheads should be on the
+ same hpos.)
+
+ * Make interface of this, similar to align-interface.
+ */
class Note_collision_interface
{
public:
- static SCM automatic_shift (Grob*, Drul_array< Link_array <Grob> >);
- static SCM forced_shift (Grob*);
-
- static Drul_array< Link_array <Grob> > get_clash_groups (Grob *me);
+ static SCM automatic_shift (Grob *, Drul_array< Link_array<Grob> >);
+ static SCM forced_shift (Grob *);
+
+ static Drul_array< Link_array<Grob> > get_clash_groups (Grob *me);
DECLARE_SCHEME_CALLBACK (force_shift_callback, (SCM element, SCM axis));
- static void do_shifts (Grob*);
- static void add_column (Grob*me, Grob*ncol);
- static bool has_interface(Grob*);
+ static void do_shifts (Grob *);
+ static void add_column (Grob *me, Grob *ncol);
+ static bool has_interface (Grob *);
};
#endif // COLLISION_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef NOTE_COLUMN_HH
#define NOTE_COLUMN_HH
#include "item.hh"
/** a struct for treating a group of noteheads (noteheads, stem
- (chord) and scripts) as a single entity.
-
- UGR. Junkme. refpoint should be the notehead, dir should come from stem.
+ (chord) and scripts) as a single entity.
+ UGR. Junkme. refpoint should be the notehead, dir should come from stem.
*/
class Note_column
{
public:
- static int shift_compare (Grob *const &, Grob*const&);
- static Direction dir (Grob*me);
- static Grob * accidentals (Grob*me);
- static Slice head_positions_interval (Grob* me);
- static Direction static_dir (Grob*);
- static void translate_rests (Grob*me, int dy);
- static Grob *first_head (Grob*me);
- static Grob *get_rest (Grob*me);
- static void set_stem (Grob*me, Grob*);
- static void set_dotcol (Grob*me, Grob*);
- static void add_head (Grob*me, Grob*);
- static bool has_rests (Grob*me);
- static bool has_interface (Grob*);
-
- static Item *get_stem (Grob*);
+ static int shift_compare (Grob *const &, Grob *const &);
+ static Direction dir (Grob *me);
+ static Grob *accidentals (Grob *me);
+ static Slice head_positions_interval (Grob *me);
+ static Direction static_dir (Grob *);
+ static void translate_rests (Grob *me, int dy);
+ static Grob *first_head (Grob *me);
+ static Grob *get_rest (Grob *me);
+ static void set_stem (Grob *me, Grob *);
+ static void set_dotcol (Grob *me, Grob *);
+ static void add_head (Grob *me, Grob *);
+ static bool has_rests (Grob *me);
+ static bool has_interface (Grob *);
+
+ static Item *get_stem (Grob *);
};
#endif // NOTE_COLUMN_HH
/** ball at the end of the stem. Also takes care of ledger lines.
- NoteHead is a kind of RhythmicHead, see there.
+NoteHead is a kind of RhythmicHead, see there.
- Read-only:
+Read-only:
*/
-class Note_head
+class Note_head
{
public:
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (brew_ez_stencil, (SCM));
DECLARE_SCHEME_CALLBACK (extent, (SCM, SCM));
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
static Real stem_attachment_coordinate (Grob *, Axis a);
- static int get_balltype (Grob*) ;
+ static int get_balltype (Grob *);
};
#endif // NOTEHEAD_HH
-/*
-note-spacing.hh -- declare Note_spacing
+/*
+ note-spacing.hh -- declare Note_spacing
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ (c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#ifndef NOTE_SPACING_HH
#define NOTE_SPACING_HH
class Note_spacing
{
public:
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
- static void get_spacing (Grob *me, Item* , Real, Real, Real*, Real*);
- static void stem_dir_correction (Grob *me, Item * next_col, Real incr,
- Real*, Real*);
- static Item * right_column (Grob*);
- static Item * left_column (Grob*);
+ static void get_spacing (Grob *me, Item *, Real, Real, Real *, Real *);
+ static void stem_dir_correction (Grob *me, Item *next_col, Real incr,
+ Real *, Real *);
+ static Item *right_column (Grob *);
+ static Item *left_column (Grob *);
};
#endif /* NOTE_SPACING_HH */
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef OBJECT_KEY_DUMPER_HH
#include "object-key.hh"
-typedef std::map<Object_key const*, Object_key const*, Object_key_less> Key_to_key_map;
-typedef std::map<Object_key const*, int> Pointer_to_int_map;
-typedef std::map<int, Object_key const *> Int_to_key_map;
+typedef std::map < Object_key const *, Object_key const *, Object_key_less> Key_to_key_map;
+typedef std::map < Object_key const *, int> Pointer_to_int_map;
+typedef std::map < int, Object_key const *> Int_to_key_map;
class Object_key_dumper
{
Key_to_key_map serialized_keys_;
Pointer_to_int_map key_serial_numbers_;
int next_available_;
-
+
SCM key_serial (int);
SCM serialize_key (Object_key const *);
- DECLARE_SMOBS (Object_key_dumper, );
+ DECLARE_SMOBS (Object_key_dumper,);
public:
- Object_key_dumper ();
+ Object_key_dumper ();
SCM get_file_contents () const;
SCM dump_key (Object_key const *);
};
-DECLARE_UNSMOB(Object_key_dumper, key_dumper);
+DECLARE_UNSMOB (Object_key_dumper, key_dumper);
#endif /* OBJECT_KEY_DUMPER_HH */
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef OBJECT_KEY_UNDUMPER_HH
#define OBJECT_KEY_UNDUMPER_HH
#include <map>
-#include "object-key.hh"
+#include "object-key.hh"
-typedef std::map<int, Object_key const *> Int_to_key_map;
+typedef std::map < int, Object_key const *> Int_to_key_map;
struct Object_key_undumper
{
- DECLARE_SMOBS(Object_key_undumper, );
+ DECLARE_SMOBS (Object_key_undumper,);
Int_to_key_map keys_;
public:
void parse_contents (SCM);
Object_key_undumper ();
Object_key const *get_key (int k);
};
-DECLARE_UNSMOB(Object_key_undumper, key_undumper);
+DECLARE_UNSMOB (Object_key_undumper, key_undumper);
#endif
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef OBJECT_KEY_HH
In the future, they might also act as handles for external processes
requesting notation to be drawn.
- */
+*/
class Object_key
{
- DECLARE_SMOBS(Object_key, );
+ DECLARE_SMOBS (Object_key,);
protected:
- Object_key();
+ Object_key ();
virtual void derived_mark () const;
virtual int get_type () const;
- virtual int do_compare (Object_key const * other) const;
+ virtual int do_compare (Object_key const *other) const;
virtual SCM as_scheme () const;
public:
static Object_key *from_scheme (SCM);
SCM dump () const;
};
-enum Object_key_type {
- BASE_KEY,
- COPIED_KEY,
- GENERAL_KEY,
- GROB_KEY,
- CONTEXT_KEY,
- KEY_COUNT,
-};
+enum Object_key_type
+ {
+ BASE_KEY,
+ COPIED_KEY,
+ GENERAL_KEY,
+ GROB_KEY,
+ CONTEXT_KEY,
+ KEY_COUNT,
+ };
class Copied_key : public Object_key
{
private:
- Object_key const * original_;
+ Object_key const *original_;
int copy_count_;
protected:
virtual void derived_mark () const;
virtual int get_type () const;
- virtual int do_compare (Object_key const * other) const;
+ virtual int do_compare (Object_key const *other) const;
virtual SCM as_scheme () const;
public:
static Object_key *from_scheme (SCM);
- Copied_key (Object_key const*, int);
+ Copied_key (Object_key const *, int);
};
-DECLARE_UNSMOB(Object_key, key);
+DECLARE_UNSMOB (Object_key, key);
-struct Object_key_less {
- bool operator () (Object_key const *const &t1, Object_key const *const &t2) const
+struct Object_key_less
+{
+ bool operator() (Object_key const *const &t1, Object_key const *const &t2) const
{
return t1->compare (t2);
}
};
-
#endif /* OBJECT_KEY_HH */
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef OPEN_TYPE_FONT_HH
#include "freetype.hh"
#include "font-metric.hh"
-typedef std::map<FT_UInt, FT_ULong> Index_to_charcode_map;
+typedef std::map < FT_UInt, FT_ULong> Index_to_charcode_map;
Index_to_charcode_map make_index_to_charcode_map (FT_Face face);
class Open_type_font : public Font_metric
{
- /* handle to face object */
+ /* handle to face object */
FT_Face face_;
- SCM lily_subfonts_;
- SCM lily_character_table_;
+ SCM lily_subfonts_;
+ SCM lily_character_table_;
SCM lily_global_table_;
Index_to_charcode_map index_to_charcode_map_;
Open_type_font (FT_Face);
SCM get_subfonts () const;
SCM get_global_table () const;
SCM get_char_table () const;
-
+
static SCM make_otf (String);
virtual String font_name () const;
- virtual ~Open_type_font();
+ virtual ~Open_type_font ();
virtual Offset attachment_point (String) const;
virtual int count () const;
virtual Box get_indexed_char (int) const;
class Pango_font : public Font_metric
{
PangoContext *context_;
- PangoFontDescription *pango_description_;
+ PangoFontDescription *pango_description_;
PangoAttrList *attribute_list_;
Real scale_;
SCM physical_font_tab_;
public:
- SCM physical_font_tab () const;
+ SCM physical_font_tab () const;
Pango_font (PangoFT2FontMap *,
Direction leftright,
PangoFontDescription *,
SCM font_file_name () const;
void register_font_file (String, String);
Stencil text_stencil (String) const;
- Stencil pango_item_string_stencil (PangoItem*, String, Real) const;
+ Stencil pango_item_string_stencil (PangoItem *, String, Real) const;
virtual void derived_mark () const;
};
class Paper_book
{
- DECLARE_SMOBS (Paper_book, );
+ DECLARE_SMOBS (Paper_book,);
SCM systems_;
SCM pages_;
SCM header_0_;
SCM scores_;
Output_def *paper_;
-
+
Paper_book ();
void add_score (SCM);
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef PAPER_COLUMN_HH
#define PAPER_COLUMN_HH
#include "item.hh"
#include "rod.hh"
-
class Paper_column : public Item
-{
+{
public:
- int rank_;
+ int rank_;
/// if lines are broken then this column is in #line#
System *system_;
- Paper_column (SCM, Object_key const*);
- Paper_column (Paper_column const&, int count);
-
+ Paper_column (SCM, Object_key const *);
+ Paper_column (Paper_column const &, int count);
+
virtual Grob *clone (int count) const;
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
virtual void do_break_processing ();
virtual Paper_column *get_column () const;
virtual System *get_system () const;
-
- static int get_rank (Grob*);
-
+
+ static int get_rank (Grob *);
+
DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
-
+
static bool is_musical (Grob *);
- static Moment when_mom (Grob*);
+ static Moment when_mom (Grob *);
- static bool is_used (Grob*) ;
+ static bool is_used (Grob *);
void set_rank (int);
};
-
+
#endif // PAPER_COLUMN_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef PAPER_OUTPUTTER_HH
#define PAPER_OUTPUTTER_HH
String file_name_;
SCM file_;
-
public:
- DECLARE_SMOBS (Paper_outputter, );
+ DECLARE_SMOBS (Paper_outputter,);
public:
SCM file ();
Paper_outputter (String nm, String format);
SCM scheme_to_string (SCM);
void output_stencil (Stencil);
- void close();
+ void close ();
};
Paper_outputter *get_paper_outputter (String, String);
Paper_score ();
int find_col_idx (Paper_column const *) const;
- Link_array<Item> broken_col_range (Item const*, Item const*) const;
- void typeset_line (System*);
+ Link_array<Item> broken_col_range (Item const *, Item const *) const;
+ void typeset_line (System *);
void output ();
protected:
To save memory, we don't keep around the System grobs, but put the
formatted content of the grob is put into a
Paper_system. Page-breaking handles Paper_system objects.
-
- */
+*/
class Paper_system
{
- DECLARE_SMOBS (Paper_system, );
+ DECLARE_SMOBS (Paper_system,);
Stencil stencil_;
bool is_title_;
public:
int number_;
Paper_system (Stencil, bool);
-
+
Stencil to_stencil () const;
SCM stencils () const;
bool is_title () const;
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
*/
#ifndef PARSE_SCM_HH
struct Parse_start
{
- char const* str;
+ char const *str;
int nchars;
Input start_location_;
bool safe_;
-/*
+/*
percent-repeat-item.hh -- declare Percent_repeat_item_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef PERCENT_REPEAT_ITEM_HH
#define PERCENT_REPEAT_ITEM_HH
class Percent_repeat_item_interface
{
public:
- static bool has_interface (Grob*);
- DECLARE_SCHEME_CALLBACK (beat_slash, (SCM ));
- DECLARE_SCHEME_CALLBACK (double_percent, (SCM ));
- static Stencil x_percent (Grob*, int, Real, Real );
- static Stencil brew_slash (Grob*);
+ static bool has_interface (Grob *);
+ DECLARE_SCHEME_CALLBACK (beat_slash, (SCM));
+ DECLARE_SCHEME_CALLBACK (double_percent, (SCM));
+ static Stencil x_percent (Grob *, int, Real, Real);
+ static Stencil brew_slash (Grob *);
};
#endif /* PERCENT_REPEAT_ITEM_HH */
-/*
+/*
percent-repeat-iterator.hh -- declare Percent_repeat_iterator
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef PERCENT_REPEAT_ITERATOR_HH
#define PERCENT_REPEAT_ITERATOR_HH
class Percent_repeat_iterator : public Music_iterator
{
public:
- DECLARE_SCHEME_CALLBACK(constructor, ());
+ DECLARE_SCHEME_CALLBACK (constructor, ());
Percent_repeat_iterator ();
protected:
- virtual void derived_substitute (Context *f, Context *t) ;
+ virtual void derived_substitute (Context *f, Context *t);
virtual void derived_mark () const;
virtual Moment pending_moment () const;
- virtual void do_quit();
- virtual void construct_children () ;
+ virtual void do_quit ();
+ virtual void construct_children ();
virtual bool ok () const;
- virtual void process (Moment) ;
+ virtual void process (Moment);
virtual Music_iterator *try_music_in_children (Music *) const;
private:
- Music_iterator * child_iter_;
+ Music_iterator *child_iter_;
Moment finish_mom_;
};
-
#endif /* PERCENT_REPEAT_ITERATOR_HH */
performance.hh -- declare Performance
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#ifndef PERFORMANCE_HH
#define PERFORMANCE_HH
Performance ();
~Performance ();
- void add_element (Audio_element*p);
-
- void output (Midi_stream& midi_stream_r);
- void output_header_track (Midi_stream& midi_stream_r);
+ void add_element (Audio_element *p);
+
+ void output (Midi_stream &midi_stream_r);
+ void output_header_track (Midi_stream &midi_stream_r);
void print () const;
SCM process (String);
performer-group-performer.hh -- declare Performer_group_performer
(c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
- */
+ Jan Nieuwenhuizen <janneke@gnu.org>
+*/
#ifndef PERFORMER_GROUP_PERFORMER_HH
#define PERFORMER_GROUP_PERFORMER_HH
typedef void (Performer::*Performer_method) (void);
-class Performer_group_performer : public Performer, public virtual Translator_group {
+class Performer_group_performer : public Performer, public virtual Translator_group
+{
public:
- TRANSLATOR_DECLARATIONS(Performer_group_performer);
-
+ TRANSLATOR_DECLARATIONS (Performer_group_performer);
+
virtual void do_announces ();
virtual void announce_element (Audio_element_info);
protected:
performer.hh -- declare Performer
(c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
- */
+ Jan Nieuwenhuizen <janneke@gnu.org>
+*/
#ifndef PERFORMER_HH
#define PERFORMER_HH
{
public:
VIRTUAL_COPY_CONSTRUCTOR (Translator, Performer);
- friend class Performer_group_performer;
- Performer_group_performer* get_daddy_performer () const;
+ friend class Performer_group_performer;
+ Performer_group_performer *get_daddy_performer () const;
protected:
virtual void announce_element (Audio_element_info);
virtual void acknowledge_audio_element (Audio_element_info);
virtual void create_audio_elements ();
virtual int get_tempo () const;
- virtual void play_element (Audio_element * elem );
+ virtual void play_element (Audio_element *elem);
};
-
#endif /* PERFORMER_HH */
-/*
+/*
pitch-interval.hh -- declare Pitch_interval
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef PITCH_INTERVAL_HH
#include "pitch.hh"
-class Pitch_interval : public Drul_array<Pitch>
+class Pitch_interval : public Drul_array<Pitch>
{
public:
- Pitch_interval();
- Pitch_interval(Pitch, Pitch);
+ Pitch_interval ();
+ Pitch_interval (Pitch, Pitch);
void add_point (Pitch);
bool is_empty () const;
};
-/*
+/*
pitch.hh -- declare Pitch
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef MUSICAL_PITCH_HH
#define MUSICAL_PITCH_HH
#include "smobs.hh"
/** A "tonal" pitch. This is a pitch used in diatonal western music
- (24 quartertones in an octave), as opposed to a frequency in Hz or a
- integer number of semitones.
+ (24 quartertones in an octave), as opposed to a frequency in Hz or a
+ integer number of semitones.
- Pitch is lexicographically ordered by (octave, notename,
- alteration).
-
+ Pitch is lexicographically ordered by (octave, notename,
+ alteration).
- TODO:
- - add indeterminate octaves, so it can be used as a key in keySigature
+ TODO:
+ - add indeterminate octaves, so it can be used as a key in keySigature
*/
class Pitch
{
private: // fixme
/*
TODO: use SCM
- */
+ */
int notename_;
int alteration_;
int octave_;
-
+
void transpose (Pitch);
void up_to (int);
void down_to (int);
void normalise ();
public:
-
+
int get_octave () const;
int get_notename () const;
int get_alteration () const;
Pitch transposed (Pitch) const;
Pitch to_relative_octave (Pitch) const;
- static int compare (Pitch const&, Pitch const&);
+ static int compare (Pitch const &, Pitch const &);
int steps () const;
- int semitone_pitch () const;
- int quartertone_pitch () const;
+ int semitone_pitch () const;
+ int quartertone_pitch () const;
String to_string () const;
DECLARE_SCHEME_CALLBACK (less_p, (SCM a, SCM b));
- DECLARE_SIMPLE_SMOBS (Pitch, );
-};
-
-enum {
- DOUBLE_FLAT = -4,
- THREE_Q_FLAT,
- FLAT ,
- SEMI_FLAT,
- NATURAL,
- SEMI_SHARP,
- SHARP ,
- THREE_Q_SHARP,
- DOUBLE_SHARP,
+ DECLARE_SIMPLE_SMOBS (Pitch,);
};
-SCM ly_pitch_diff (SCM pitch, SCM root);
+enum
+ {
+ DOUBLE_FLAT = -4,
+ THREE_Q_FLAT,
+ FLAT,
+ SEMI_FLAT,
+ NATURAL,
+ SEMI_SHARP,
+ SHARP,
+ THREE_Q_SHARP,
+ DOUBLE_SHARP,
+ };
+
+SCM ly_pitch_diff (SCM pitch, SCM root);
SCM ly_pitch_transpose (SCM p, SCM delta);
-DECLARE_UNSMOB(Pitch, pitch);
+DECLARE_UNSMOB (Pitch, pitch);
INSTANTIATE_COMPARE (Pitch, Pitch::compare);
int compare (Array<Pitch>*, Array<Pitch>*);
extern SCM pitch_less_proc;
-Pitch pitch_interval (Pitch const & from , Pitch const & to );
+Pitch pitch_interval (Pitch const &from, Pitch const &to);
#endif /* MUSICAL_PITCH_HH */
-
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef PROPERTY_ITERATOR_HH
#define PROPERTY_ITERATOR_HH
#include "simple-music-iterator.hh"
-
-
/**
- Iterate a property.
- */
+ Iterate a property.
+*/
class Property_iterator : public Simple_music_iterator
{
public:
- DECLARE_SCHEME_CALLBACK(constructor, ());
- DECLARE_SCHEME_CALLBACK(once_finalization, (SCM, SCM ));
+ DECLARE_SCHEME_CALLBACK (constructor, ());
+ DECLARE_SCHEME_CALLBACK (once_finalization, (SCM, SCM));
protected:
- virtual void do_quit();
+ virtual void do_quit ();
virtual void process (Moment);
};
-
-
/**
- Iterate a property.
- */
+ Iterate a property.
+*/
class Property_unset_iterator : public Simple_music_iterator
{
public:
- DECLARE_SCHEME_CALLBACK(constructor, ());
+ DECLARE_SCHEME_CALLBACK (constructor, ());
protected:
virtual void process (Moment);
};
class Push_property_iterator : public Simple_music_iterator
{
public:
- DECLARE_SCHEME_CALLBACK(constructor, ());
- DECLARE_SCHEME_CALLBACK(once_finalization, (SCM, SCM));
+ DECLARE_SCHEME_CALLBACK (constructor, ());
+ DECLARE_SCHEME_CALLBACK (once_finalization, (SCM, SCM));
protected:
virtual void process (Moment);
- virtual void do_quit();
+ virtual void do_quit ();
};
class Pop_property_iterator : public Simple_music_iterator
{
public:
- DECLARE_SCHEME_CALLBACK(constructor, ());
+ DECLARE_SCHEME_CALLBACK (constructor, ());
protected:
virtual void process (Moment);
};
-
#endif // PROPERTY_ITERATOR_HH
-/*
+/*
protected-scm.hh -- declare Protected_scm
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef PROTECTED_SCM_HH
#define PROTECTED_SCM_HH
-
#include "lily-guile.hh"
/*
- Mix GUILE GC with C++ ctors and dtors.
- */
+ Mix GUILE GC with C++ ctors and dtors.
+*/
class Protected_scm
{
SCM object_;
Protected_scm (SCM);
Protected_scm (Protected_scm const &);
~Protected_scm ();
- Protected_scm &operator = (SCM);
- Protected_scm &operator = ( Protected_scm const&);
+ Protected_scm &operator= (SCM);
+ Protected_scm &operator= (Protected_scm const &);
operator SCM () const;
SCM to_SCM () const;
};
-/*
+/*
repeated-music.hh -- declare Repeated_music
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef REPEATED_MUSIC_HH
#define REPEATED_MUSIC_HH
#include "music.hh"
-
/**
Musical repeats.
There are three modes of representing this music:
BODY A
- B
- C
+ B
+ C
is called "folded". Mostly used for lyrics.
-
+
BODY A B C
is called volta. This is common notation
If the number of repeats is bigger than the number of alternatives, then
the first alternative is assumed to be repeated.
-
*/
class Repeated_music
{
public:
- static Music *body (Music*);
- static SCM alternatives (Music*);
+ static Music *body (Music *);
+ static SCM alternatives (Music *);
/* How often do we repeat? */
- static int repeat_count (Music*);
- DECLARE_SCHEME_CALLBACK(relative_callback, (SCM, SCM));
+ static int repeat_count (Music *);
+ DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM));
- static Moment body_get_length (Music*);
+ static Moment body_get_length (Music *);
static Moment alternatives_get_length (Music *, bool fold);
- static Moment alternatives_volta_get_length (Music *);
+ static Moment alternatives_volta_get_length (Music *);
DECLARE_SCHEME_CALLBACK (unfolded_music_length, (SCM));
DECLARE_SCHEME_CALLBACK (volta_music_length, (SCM));
- DECLARE_SCHEME_CALLBACK (folded_music_length, (SCM));
+ DECLARE_SCHEME_CALLBACK (folded_music_length, (SCM));
DECLARE_SCHEME_CALLBACK (minimum_start, (SCM));
- DECLARE_SCHEME_CALLBACK (first_start, (SCM));
+ DECLARE_SCHEME_CALLBACK (first_start, (SCM));
};
-
#endif /* REPEATED_MUSIC_HH */
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef REST_COLLISION_HH
#define REST_COLLISION_HH
#include "lily-guile.hh"
-
-
class Rest_collision
{
public:
- static void add_column (Grob*me, Grob*);
-
- static bool has_interface (Grob*);
+ static void add_column (Grob *me, Grob *);
+
+ static bool has_interface (Grob *);
DECLARE_SCHEME_CALLBACK (force_shift_callback, (SCM element, SCM axis));
DECLARE_SCHEME_CALLBACK (force_shift_callback_rest, (SCM element, SCM axis));
- static SCM do_shift (Grob*);
+ static SCM do_shift (Grob *);
};
#endif // REST_COLLISION_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef REST_HH
#define REST_HH
class Grob;
-class Rest
+class Rest
{
public:
- DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM ));
- static bool has_interface (Grob*);
- static String glyph_name (Grob*, int, String, bool);
+ DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
+ static bool has_interface (Grob *);
+ static String glyph_name (Grob *, int, String, bool);
static SCM brew_internal_stencil (SCM, bool);
DECLARE_SCHEME_CALLBACK (extent_callback, (SCM, SCM));
DECLARE_SCHEME_CALLBACK (polyphonic_offset_callback, (SCM, SCM));
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
};
#endif // REST_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef RHYTHMIC_HEAD_HH
#define RHYTHMIC_HEAD_HH
class Rhythmic_head
{
public:
- static int duration_log (Grob*);
- static void set_dots (Grob*, Item *);
- static Item * get_stem (Grob*) ;
- static Item * get_dots (Grob*) ;
- static int dot_count (Grob*) ;
- DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM ));
- static bool has_interface (Grob*);
-
+ static int duration_log (Grob *);
+ static void set_dots (Grob *, Item *);
+ static Item *get_stem (Grob *);
+ static Item *get_dots (Grob *);
+ static int dot_count (Grob *);
+ DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
+ static bool has_interface (Grob *);
+
};
#endif // RHYTHMIC_HEAD_HH
-/*
+/*
rod.hh -- declare Rod, Column_rod
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef ROD_HH
#define ROD_HH
struct Rod
{
- Drul_array <Item*> item_drul_;
+ Drul_array<Item *> item_drul_;
Real distance_;
/**
- translate the rod so as to refer to Paper_columns
- */
+ translate the rod so as to refer to Paper_columns
+ */
void columnize ();
-
+
void add_to_cols ();
Rod ();
-/*
+/*
scm-hash.hh -- declare Scheme hasher.
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef SCM_HASH_HH
#define SCM_HASH_HH
-
#include "smobs.hh"
-
/**
- auto resizing hash table.
+ auto resizing hash table.
1. ALWAYS USE THIS AS VIA A POINTER, i.e.
class Foo {
- Scheme_hash_table * tab;
+ Scheme_hash_table * tab;
};
and NOT
class Foo {
- Scheme_hash_table tab;
+ Scheme_hash_table tab;
}
2. UPON DESTRUCTION, DO
scm_gc_unprotect_object (tab->self_scm_);
-
- */
+*/
class Scheme_hash_table
-{
+{
public:
bool try_retrieve (SCM key, SCM *val);
bool contains (SCM key) const;
WARNING: putting something in assumes responsibility for cleaning
up. */
void set (SCM k, SCM v);
- SCM get (SCM k) const;
+ SCM get (SCM k) const;
void remove (SCM k);
Scheme_hash_table ();
- void operator = (Scheme_hash_table const &);
+ void operator= (Scheme_hash_table const &);
Scheme_hash_table (Scheme_hash_table const &);
SCM to_alist () const;
private:
SCM hash_tab_;
unsigned elt_count_;
-
+
DECLARE_SMOBS (Scheme_hash_table, foo);
};
-
#endif /* SCM_HASH_HH */
/*
score-context.hh -- declare Score_context
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#ifndef SCORE_CONTEXT_HH
class Score_context : public Context
{
- public:
- Score_context (Object_key const*);
-
- virtual Music_output *get_output ();
+public:
+ Score_context (Object_key const *);
+
+ virtual Music_output *get_output ();
virtual void prepare (Moment);
virtual void finish ();
virtual void one_time_step ();
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef SCORE_ENGRAVER_HH
#define SCORE_ENGRAVER_HH
{
System *system_;
int breaks_; // used for stat printing
-
+
Link_array<Grob> elems_;
- Paper_column* command_column_;
- Paper_column* musical_column_;
- Paper_score * pscore_;
+ Paper_column *command_column_;
+ Paper_column *musical_column_;
+ Paper_score *pscore_;
void make_columns ();
- void set_columns (Paper_column*, Paper_column*);
+ void set_columns (Paper_column *, Paper_column *);
void typeset_all ();
protected:
/* Score_translator */
virtual void finish ();
virtual void prepare (Moment);
virtual void one_time_step ();
-
+
/* Engraver_group_engraver interface */
virtual void acknowledge_grob (Grob_info);
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void initialize ();
virtual void finalize ();
virtual void announce_grob (Grob_info);
virtual void stop_translation_timestep ();
public:
- TRANSLATOR_DECLARATIONS(Score_engraver);
+ TRANSLATOR_DECLARATIONS (Score_engraver);
void forbid_breaks ();
- virtual Music_output *get_output ();
+ virtual Music_output *get_output ();
};
#endif /* SCORE_ENGRAVER_HH */
score-performer.hh -- declare Score_performer
(c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
- */
+ Jan Nieuwenhuizen <janneke@gnu.org>
+*/
#ifndef SCORE_PERFORMER_HH
#define SCORE_PERFORMER_HH
#include "score-translator.hh"
/**
- Top level performer. Completely takes care of MIDI output
- */
+ Top level performer. Completely takes care of MIDI output
+*/
class Score_performer : public Score_translator, public virtual Performer_group_performer
{
public:
- TRANSLATOR_DECLARATIONS(Score_performer);
+ TRANSLATOR_DECLARATIONS (Score_performer);
~Score_performer ();
Performance *performance_;
-
+
protected:
virtual void prepare (Moment mom);
virtual void finish ();
virtual void initialize ();
virtual void announce_element (Audio_element_info);
virtual int get_tempo () const;
- virtual void play_element (Audio_element* p);
+ virtual void play_element (Audio_element *p);
virtual Music_output *get_output ();
private:
- void header (Midi_stream&);
+ void header (Midi_stream &);
- Audio_column* audio_column_;
+ Audio_column *audio_column_;
};
#endif // SCORE_PERFORMER_HH
-/*
+/*
score-translator.hh -- declare Score_translator
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
- */
+ (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+*/
#ifndef SCORE_TRANSLATOR_HH
#define SCORE_TRANSLATOR_HH
-#include "translator-group.hh"
+#include "translator-group.hh"
-class Score_translator : public virtual Translator_group
+class Score_translator : public virtual Translator_group
{
friend class Score_context;
- protected:
- virtual Music_output* get_output ();
+protected:
+ virtual Music_output *get_output ();
virtual void prepare (Moment);
virtual void finish ();
virtual void one_time_step ();
};
-
#endif /* SCORE_TRANSLATOR_HH */
-
SCM header_;
SCM texts_;
bool error_found_;
-
+
Score ();
- Score (Score const&);
+ Score (Score const &);
SCM get_music () const;
void set_music (SCM music, SCM parser);
- SCM book_rendering (String, Output_def*, Output_def*, Object_key*);
+ SCM book_rendering (String, Output_def *, Output_def *, Object_key *);
};
DECLARE_UNSMOB (Score, score);
-/*
+/*
g-script-column.hh -- declare Script_column
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef Script_COLUMN_HH
#define Script_COLUMN_HH
class Script_column
{
public:
- static void add_staff_sided (Grob*, Item*);
- DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM ));
- static bool has_interface (Grob*);
+ static void add_staff_sided (Grob *, Item *);
+ DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
+ static bool has_interface (Grob *);
};
-
#endif /* Script_COLUMN_HH */
-
-/*
- script-interface.hh --
+/*
+ script-interface.hh --
source file of the GNU LilyPond music typesetter
public:
static Stencil get_stencil (Grob *, Direction d);
static bool has_interface (Grob *);
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
};
-/*
+/*
side-position-interface.hh -- declare Side_position_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef SELF_ALIGNMENT_INTERFACE_HH
#define SELF_ALIGNMENT_INTERFACE_HH
struct Self_alignment_interface
{
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
DECLARE_SCHEME_CALLBACK (aligned_on_self, (SCM element, SCM axis));
DECLARE_SCHEME_CALLBACK (centered_on_parent, (SCM element, SCM axis));
DECLARE_SCHEME_CALLBACK (aligned_on_parent, (SCM element, SCM axis));
-/*
+/*
separating-group-spanner.hh -- declare Separating_group_spanner
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef SEPARATING_GROUP_SPANNER_HH
#define SEPARATING_GROUP_SPANNER_HH
class Separating_group_spanner
{
- static void find_rods (Item*, SCM, Real);
+ static void find_rods (Item *, SCM, Real);
public:
- static void add_spacing_unit (Grob*me, Item*);
-
- static bool has_interface (Grob*);
- DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM ));
+ static void add_spacing_unit (Grob *me, Item *);
+
+ static bool has_interface (Grob *);
+ DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM));
};
#endif /* SEPARATING_GROUP_SPANNER_HH */
-/*
+/*
single-malt-grouping-item.hh -- declare Separation_item
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef SINGLE_MALT_GROUPING_ITEM_HH
#define SINGLE_MALT_GROUPING_ITEM_HH
struct Separation_item
{
- static bool has_interface (Grob*);
- static Interval conditional_width (Grob*, Grob*) ;
- static Interval width (Grob*) ;
- static Interval relative_width (Grob*, Grob*) ;
- static Grob*extremal_break_aligned_grob (Grob*, Direction, Interval*);
- static void add_item (Grob*, Item*);
- static void add_conditional_item (Grob*, Grob*);
+ static bool has_interface (Grob *);
+ static Interval conditional_width (Grob *, Grob *);
+ static Interval width (Grob *);
+ static Interval relative_width (Grob *, Grob *);
+ static Grob *extremal_break_aligned_grob (Grob *, Direction, Interval *);
+ static void add_item (Grob *, Item *);
+ static void add_conditional_item (Grob *, Grob *);
};
#endif /* SINGLE_MALT_GROUPING_ITEM_HH */
-/*
+/*
sequential-iterator.hh -- declare Sequential_iterator
source file of the GNU LilyPond music typesetter
#include "music-iterator.hh"
#include "protected-scm.hh"
-
/** Sequential_music iteration: walk each element in turn, and
- construct an iterator for every element.
-
- */
-class Sequential_iterator : public Music_iterator
+ construct an iterator for every element.
+*/
+class Sequential_iterator : public Music_iterator
{
public:
- DECLARE_SCHEME_CALLBACK(constructor, ());
+ DECLARE_SCHEME_CALLBACK (constructor, ());
Sequential_iterator ();
- Sequential_iterator (Sequential_iterator const&);
- virtual void derived_substitute (Context *f, Context *t) ;
+ Sequential_iterator (Sequential_iterator const &);
+ virtual void derived_substitute (Context *f, Context *t);
virtual void derived_mark () const;
virtual void construct_children ();
virtual Moment pending_moment () const;
- virtual void do_quit();
+ virtual void do_quit ();
virtual bool ok () const;
protected:
virtual Music_iterator *try_music_in_children (Music *) const;
virtual bool run_always () const;
protected:
- Music_iterator * iter_;
+ Music_iterator *iter_;
virtual SCM get_music_list ()const;
virtual void next_element (bool side_effect);
-
Grace_fixup *get_grace_fixup () const;
void next_grace_fixup ();
-
+
private:
Moment last_mom_;
Moment here_mom_;
SCM cursor_;
- Grace_fixup * grace_fixups_;
-
+ Grace_fixup *grace_fixups_;
+
};
#endif /* SEQUENTIAL_ITERATOR_HH */
#include "sequential-iterator.hh"
/** Sequential_music iteration: walk each element in turn, and
- construct an iterator for every element.
-
- */
-class Sequential_music_iterator : public Sequential_iterator
+ construct an iterator for every element.
+*/
+class Sequential_music_iterator : public Sequential_iterator
{
public:
- DECLARE_SCHEME_CALLBACK(constructor, ());
+ DECLARE_SCHEME_CALLBACK (constructor, ());
private:
- virtual SCM get_music_list()const;
+ virtual SCM get_music_list ()const;
};
#endif // SEQUENTIAL_MUSIC_ITERATOR_HH
-/*
+/*
side-position-interface.hh -- declare Side_position_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef SIDE_POSITION_INTERFACE_HH
#define SIDE_POSITION_INTERFACE_HH
public:
DECLARE_SCHEME_CALLBACK (aligned_on_support_extents, (SCM element, SCM axis));
DECLARE_SCHEME_CALLBACK (aligned_on_support_refpoints, (SCM element, SCM axis));
-
- DECLARE_SCHEME_CALLBACK (aligned_side, (SCM element, SCM axis));
+
+ DECLARE_SCHEME_CALLBACK (aligned_side, (SCM element, SCM axis));
DECLARE_SCHEME_CALLBACK (quantised_position, (SCM element, SCM axis));
- static SCM general_side_position (Grob*, Axis, bool);
- static Axis get_axis (Grob*) ;
- static void set_axis (Grob*, Axis) ;
- static bool has_interface (Grob*) ;
- static void add_support (Grob*, Grob*);
- static void add_staff_support (Grob*);
- static Direction get_direction (Grob*);
+ static SCM general_side_position (Grob *, Axis, bool);
+ static Axis get_axis (Grob *);
+ static void set_axis (Grob *, Axis);
+ static bool has_interface (Grob *);
+ static void add_support (Grob *, Grob *);
+ static void add_staff_support (Grob *);
+ static Direction get_direction (Grob *);
};
-
-
#endif /* SIDE_POSITION_INTERFACE_HH */
-/*
+/*
simple-music-iterator.hh -- declare Simple_music_iterator
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- */
+*/
#ifndef SIMPLE_MUSIC_ITERATOR_HH
#define SIMPLE_MUSIC_ITERATOR_HH
/*
Iterator for atomic music objects: events are generated at the
beginning and at the end of the music.
-
- */
+*/
class Simple_music_iterator : public Music_iterator
{
protected:
Moment last_processed_mom_;
public:
- DECLARE_SCHEME_CALLBACK(constructor, ());
+ DECLARE_SCHEME_CALLBACK (constructor, ());
Simple_music_iterator ();
virtual void process (Moment);
virtual bool ok ()const;
-/*
+/*
simple-spacer.hh -- declare Simple_spacer
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef SIMPLE_SPACER_HH
#define SIMPLE_SPACER_HH
int active_count_;
Simple_spacer ();
-
-
+
void my_solve_linelen ();
void my_solve_natural_len ();
Real active_springs_stiffness () const;
void set_active_states ();
bool is_active () const;
- DECLARE_SIMPLE_SMOBS(Simple_spacer, );
+ DECLARE_SIMPLE_SMOBS (Simple_spacer,);
};
-
struct Simple_spacer_wrapper
{
Simple_spacer *spacer_;
Simple_spacer_wrapper ();
void add_columns (Link_array<Grob> const &);
void solve (Column_x_positions *, bool);
- ~Simple_spacer_wrapper();
+ ~Simple_spacer_wrapper ();
private:
- Simple_spacer_wrapper(Simple_spacer_wrapper const&);
+ Simple_spacer_wrapper (Simple_spacer_wrapper const &);
};
#endif /* SIMPLE_SPACER_HH */
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef SIMULTANEOUS_MUSIC_ITERATOR_HH
#define SIMULTANEOUS_MUSIC_ITERATOR_HH
{
public:
Simultaneous_music_iterator ();
- Simultaneous_music_iterator (Simultaneous_music_iterator const&);
- virtual void derived_substitute (Context *f, Context *t) ;
+ Simultaneous_music_iterator (Simultaneous_music_iterator const &);
+ virtual void derived_substitute (Context *f, Context *t);
virtual void derived_mark () const;
- DECLARE_SCHEME_CALLBACK(constructor, ());
-
+ DECLARE_SCHEME_CALLBACK (constructor, ());
+
/// make a new context for every child.
bool create_separate_contexts_;
virtual void construct_children ();
virtual Moment pending_moment () const;
- virtual void do_quit();
+ virtual void do_quit ();
virtual bool ok () const;
virtual bool run_always () const;
-
+
protected:
virtual void process (Moment);
virtual Music_iterator *try_music_in_children (Music *) const;
-/*
+/*
skyline.hh -- declare Skyline_entry and funcbs.
source file of the GNU LilyPond music typesetter
{
Interval width_;
Real height_;
- Skyline_entry();
+ Skyline_entry ();
Skyline_entry (Interval, Real);
};
-
-
void
-merge_skyline (Array<Skyline_entry> *a1, Array<Skyline_entry> const & a2,
+merge_skyline (Array<Skyline_entry> *a1, Array<Skyline_entry> const &a2,
Direction);
void insert_extent_into_skyline (Array<Skyline_entry> *line, Box b, Axis line_axis,
Direction d);
Array<Skyline_entry>
-extents_to_skyline (Array<Box> const & extents, Axis a, Direction d);
+extents_to_skyline (Array<Box> const &extents, Axis a, Direction d);
Array<Skyline_entry> empty_skyline (Direction d);
void heighten_skyline (Array<Skyline_entry> *buildings, Real ground);
Real
skyline_meshing_distance (Array<Skyline_entry> const &buildings,
Array<Skyline_entry> const &clouds);
-
#endif /* SKYLINE_HH */
-/*
+/*
slur-configuration.hh -- declare Slur_configuration
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef SLUR_CONFIGURATION_HH
Real score_;
Bezier curve_;
Real height_;
-
+
int index_;
-
+
#if DEBUG_SLUR_SCORING
String score_card_;
#endif
Slur_configuration ();
void generate_curve (Slur_score_state const &state, Real r0, Real h_inf);
- void score (Slur_score_state const&);
+ void score (Slur_score_state const &);
protected:
- void score_extra_encompass (Slur_score_state const&);
- void score_slopes (Slur_score_state const&);
- void score_edges (Slur_score_state const&);
- void score_encompass (Slur_score_state const&);
+ void score_extra_encompass (Slur_score_state const &);
+ void score_slopes (Slur_score_state const &);
+ void score_edges (Slur_score_state const &);
+ void score_encompass (Slur_score_state const &);
};
#endif /* SLUR_CONFIGURATION_HH */
-/*
+/*
slur-scoring.hh -- declare Slur_score_parameters
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef SLUR_SCORING_HH
void fill (Grob *him);
};
-
-
struct Extra_collision_info
{
Real idx_;
Box extents_;
Real penalty_;
- Grob * grob_;
+ Grob *grob_;
Extra_collision_info (Grob *g, Real idx, Interval x, Interval y, Real p)
{
}
};
-
struct Encompass_info
{
Real x_;
bool edge_has_beams_;
bool is_broken_;
bool has_same_beam_;
-
+
Real musical_dy_;
Link_array<Grob> columns_;
Array<Encompass_info> encompass_infos_;
Array<Extra_collision_info> extra_encompass_infos_;
-
+
Direction dir_;
Slur_score_parameters parameters_;
Drul_array<Bound_info> extremes_;
Link_array<Slur_configuration> configurations_;
Real staff_space_;
Real thickness_;
-
- Slur_score_state();
- ~Slur_score_state();
+
+ Slur_score_state ();
+ ~Slur_score_state ();
Bezier get_best_curve ();
- void fill (Grob*);
+ void fill (Grob *);
void set_next_direction ();
-
+
Drul_array<Bound_info> get_bound_info () const;
- void generate_curves () const;
+ void generate_curves () const;
Link_array<Slur_configuration> enumerate_attachments (Drul_array<Real> end_ys) const;
- Drul_array<Offset> get_base_attachments() const;
- Drul_array<Real> get_y_attachment_range() const;
+ Drul_array<Offset> get_base_attachments () const;
+ Drul_array<Real> get_y_attachment_range () const;
Encompass_info get_encompass_info (Grob *col) const;
Array<Extra_collision_info> get_extra_encompass_infos () const;
Real move_away_from_staffline (Real y, Grob *on_staff) const;
int get_closest_index (SCM inspect_quants) const;
};
-
void set_slur_control_points (Grob *me);
#endif /* SLUR_SCORING_HH */
/*
slur.hh -- declare Slur
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
DECLARE_SCHEME_CALLBACK (height, (SCM, SCM));
DECLARE_SCHEME_CALLBACK (outside_slur_callback, (SCM, SCM));
static bool has_interface (Grob *);
- static Bezier get_curve (Grob*me);
+ static Bezier get_curve (Grob *me);
};
#endif /* SLUR_HH */
-/*
+/*
smobs.hh -- declare smob related stuff.
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef SMOBS_HH
#define SMOBS_HH
#include "lily-guile.hh"
-
/*
Smobs are GUILEs mechanism of exporting C(++) objects to the Scheme
world. They are documented in the GUILE manual.
There are two types of smob objects.
1. Simple smobs are intended for simple objects like numbers:
- immutable objects that can be copied without change of meaning.
+ immutable objects that can be copied without change of meaning.
- To obtain an SCM version of a simple smob, use the member function
- SCM smobbed_copy ().
+ To obtain an SCM version of a simple smob, use the member function
+ SCM smobbed_copy ().
- Simple smobs are created by adding the
- DECLARE_SIMPLE_SMOBS(Classname, ) to the declaration
+ Simple smobs are created by adding the
+ DECLARE_SIMPLE_SMOBS(Classname, ) to the declaration
2. Complex smobs are objects that have an identity. These objects
- carry this identity in the form of a self_scm () method, which is a
- SCM pointer to the object itself.
+ carry this identity in the form of a self_scm () method, which is a
+ SCM pointer to the object itself.
+
+ The constructor for a complex smob should have 3 steps:
+
+ * initialize all SCM members to a non-immediate value (like SCM_EOL)
+
+ * call smobify_self ()
+
+ * initialize SCM members
- The constructor for a complex smob should have 3 steps:
+ For example,
- * initialize all SCM members to a non-immediate value (like SCM_EOL)
+ Complex_smob::Complex_smob () {
+ scm_member_ = SCM_EOL;
+ smobify_self ();
+ scm_member_ = <..what you want to store..>
+ }
- * call smobify_self ()
+ after construction, the self_scm () field of a complex smob is
+ protected from Garbage Collection. This protection should be
+ removed once the object is put into another (reachable) Scheme data
+ structure, i.e.
- * initialize SCM members
+ Complex_smob *p = new Complex_smob;
+ list = scm_cons (p->self_scm (), list);
+ scm_gc_unprotect_object (p->self_scm ());
- For example,
+ Complex smobs are made with DECLARE_SMOBS (Classname, ) in the class
+ declaration.
- Complex_smob::Complex_smob () {
- scm_member_ = SCM_EOL;
- smobify_self ();
- scm_member_ = <..what you want to store..>
- }
-
- after construction, the self_scm () field of a complex smob is
- protected from Garbage Collection. This protection should be
- removed once the object is put into another (reachable) Scheme data
- structure, i.e.
+ CALLING INTERFACE
- Complex_smob *p = new Complex_smob;
- list = scm_cons (p->self_scm (), list);
- scm_gc_unprotect_object (p->self_scm ());
+ Common public methods to C++ smob objects:
- Complex smobs are made with DECLARE_SMOBS (Classname, ) in the class
- declaration.
+ unsmob (SCM x) - unpacks X and returns pointer to the C++ object, or 0
+ if it has the wrong type.
- CALLING INTERFACE
-
- Common public methods to C++ smob objects:
+ SCM equal_p (SCM a, SCM b) - compare A and B. Returns a Scheme boolean
- unsmob (SCM x) - unpacks X and returns pointer to the C++ object, or 0
- if it has the wrong type.
- SCM equal_p (SCM a, SCM b) - compare A and B. Returns a Scheme boolean
+ IMPLEMENTATION
-
- IMPLEMENTATION
-
- For implementating a class, the following should be provided
+ For implementating a class, the following should be provided
- - an equal_p () function (a default is in the
- IMPLEMENT_DEFAULT_EQUAL_P macro in ly-smobs.icc)
+ - an equal_p () function (a default is in the
+ IMPLEMENT_DEFAULT_EQUAL_P macro in ly-smobs.icc)
- - mark_smob () function, that calls scm_gc_mark () on all Scheme
- objects in the class
+ - mark_smob () function, that calls scm_gc_mark () on all Scheme
+ objects in the class
- - a print_smob () function, that displays a representation for
- debugging purposes
+ - a print_smob () function, that displays a representation for
+ debugging purposes
- - A call to one of the IMPLEMENT_SMOBS or IMPLEMENT_SIMPLE_SMOBS macros
- from file "ly-smobs.icc"
+ - A call to one of the IMPLEMENT_SMOBS or IMPLEMENT_SIMPLE_SMOBS macros
+ from file "ly-smobs.icc"
*/
-#define DECLARE_SIMPLE_SMOBS(CL, dummy) \
-public: \
- SCM smobbed_copy () const; \
-DECLARE_BASE_SMOBS(CL)
-
-
-#define DECLARE_BASE_SMOBS(CL) \
- friend class Non_existent_class; \
-private: \
- static scm_t_bits smob_tag_; \
- static SCM mark_smob (SCM); \
- static size_t free_smob (SCM s); \
- static int print_smob (SCM s, SCM p, scm_print_state*); \
-public: \
- static SCM equal_p (SCM a, SCM b);\
- static CL * unsmob (SCM s){\
- if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \
- return (CL*) SCM_CELL_WORD_1 (s); \
- else \
- return 0; \
-} \
- static SCM smob_p (SCM);\
- static void init_smobs (); \
-private:
-
-
-#define DECLARE_SMOBS(CL, dummy) \
- DECLARE_BASE_SMOBS (CL) \
-protected:\
- virtual ~CL ();\
- SCM unprotected_smobify_self ();\
-private: \
- void smobify_self (); \
- SCM self_scm_; \
-public: \
- SCM self_scm () const { return self_scm_; } \
-private:
-
-#define DECLARE_UNSMOB(CL, name) \
-inline CL * \
-unsmob_ ## name (SCM s) \
-{ \
-return CL::unsmob (s); \
-}
+#define DECLARE_SIMPLE_SMOBS(CL, dummy) \
+ public: \
+ SCM smobbed_copy () const; \
+ DECLARE_BASE_SMOBS (CL)
+
+#define DECLARE_BASE_SMOBS(CL) \
+ friend class Non_existent_class; \
+ private: \
+ static scm_t_bits smob_tag_; \
+ static SCM mark_smob (SCM); \
+ static size_t free_smob (SCM s); \
+ static int print_smob (SCM s, SCM p, scm_print_state*); \
+ public: \
+ static SCM equal_p (SCM a, SCM b); \
+ static CL *unsmob (SCM s) \
+ { \
+ if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \
+ return (CL *) SCM_CELL_WORD_1 (s); \
+ else \
+ return 0; \
+ } \
+ static SCM smob_p (SCM); \
+ static void init_smobs (); \
+ private:
+
+#define DECLARE_SMOBS(CL, dummy) \
+ DECLARE_BASE_SMOBS (CL) \
+ protected: \
+ virtual ~CL (); \
+ SCM unprotected_smobify_self (); \
+ private: \
+ void smobify_self (); \
+ SCM self_scm_; \
+ public: \
+ SCM self_scm () const { return self_scm_; } \
+ private:
+
+#define DECLARE_UNSMOB(CL, name) \
+ inline CL * \
+ unsmob_ ## name (SCM s) \
+ { \
+ return CL::unsmob (s); \
+ }
#define DECLARE_TYPE_P(CL) extern SCM CL ## _type_p_proc
-/*
+/*
source-file.hh -- declare Source_file
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "parray.hh"
/**
- class for reading and mapping a file.
+ class for reading and mapping a file.
- duplicates a lot of Data_file and Text_stream.
- should look at including Data_file's functionality:
- get_line (), get_word () here.
+ duplicates a lot of Data_file and Text_stream.
+ should look at including Data_file's functionality:
+ get_line (), get_word () here.
*/
class Source_file
{
public:
Source_file (String fn);
- Source_file (String, String );
+ Source_file (String, String);
virtual ~Source_file ();
- char const* to_str0 () const;
- virtual String error_string (char const* pos_str0 ) const;
+ char const *to_str0 () const;
+ virtual String error_string (char const *pos_str0) const;
std::istream * get_istream ();
- bool contains (char const* pos_str0 ) const;
+ bool contains (char const *pos_str0) const;
int length () const;
- virtual int get_line (char const* pos_str0 ) const;
+ virtual int get_line (char const *pos_str0) const;
String name_string () const;
- String file_line_column_string (char const* str0 ) const;
+ String file_line_column_string (char const *str0) const;
// return start + n
- char const* seek_str0 (int n);
+ char const *seek_str0 (int n);
int tell () const;
// return here + n bytes
- char const* forward_str0 (int n);
- char const* pos_str0 () { return pos_str0_; }
+ char const *forward_str0 (int n);
+ char const *pos_str0 () { return pos_str0_; }
String get_string (int n);
- void set_pos (char const * pos_str0);
+ void set_pos (char const *pos_str0);
public:
- Slice line_slice (char const* pos_str0) const;
- String line_string (char const* pos_str0) const;
- int get_column (char const* pos_str0) const;
- int get_char (char const* pos_str0) const;
+ Slice line_slice (char const *pos_str0) const;
+ String line_string (char const *pos_str0) const;
+ int get_column (char const *pos_str0) const;
+ int get_char (char const *pos_str0) const;
/*
JUNKME.
This thing doubles as a file-storage/file-iterator object.
- */
- char const* pos_str0_;
+ */
+ char const *pos_str0_;
SCM get_port () const { return str_port_; }
String name_;
private:
- Link_array<char> newline_locations_;
+ Link_array<char> newline_locations_;
std::istream* istream_;
- char * contents_str0_;
+ char *contents_str0_;
int length_;
void load_stdin ();
void init_port ();
-
+
Protected_scm str_port_;
};
#include "flower-proto.hh"
/* A set of sourcefiles. */
-class Sources
+class Sources
{
- Sources (Sources const&) {}
+ Sources (Sources const &) {}
Cons<Source_file> *sourcefile_list_;
bool is_binary_;
Sources ();
~Sources ();
- Source_file *get_file (String &file_name );
- Source_file *get_sourcefile (char const*);
- void add (Source_file* sourcefile );
- void set_path (File_path*);
+ Source_file *get_file (String &file_name);
+ Source_file *get_sourcefile (char const *);
+ void add (Source_file *sourcefile);
+ void set_path (File_path *);
void set_binary (bool);
const File_path *path_;
};
-
-
#endif /* SOURCE_HH */
-/*
+/*
spaceable-grob.hh -- declare Spaceable_grob
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef SPACEABLE_GROB_HH
#define SPACEABLE_GROB_HH
struct Spaceable_grob
{
/// set a minimum distance
- static void add_rod (Grob*me, Grob * to, Real distance);
- static void add_spring (Grob*me, Grob * to, Real dist, Real strength);
- static bool has_interface (Grob*);
- static void remove_interface (Grob*);
- static SCM get_minimum_distances (Grob*);
- static SCM get_ideal_distances (Grob*);
+ static void add_rod (Grob *me, Grob *to, Real distance);
+ static void add_spring (Grob *me, Grob *to, Real dist, Real strength);
+ static bool has_interface (Grob *);
+ static void remove_interface (Grob *);
+ static SCM get_minimum_distances (Grob *);
+ static SCM get_ideal_distances (Grob *);
};
#endif /* SPACEABLE_GROB_HH */
-/*
+/*
spacing-interface.hh -- declare Spacing_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
-struct Spacing_interface {
- static bool has_interface (Grob*);
+struct Spacing_interface
+{
+ static bool has_interface (Grob *);
};
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef SPAN_BAR_HH
#define SPAN_BAR_HH
class Span_bar
{
public:
-
- static bool has_interface (Grob*);
- static Interval get_spanned_interval (Grob*);
- static void add_bar (Grob*, Grob*);
- static void evaluate_glyph (Grob*);
- static void evaluate_empty (Grob*);
+
+ static bool has_interface (Grob *);
+ static Interval get_spanned_interval (Grob *);
+ static void add_bar (Grob *, Grob *);
+ static void evaluate_glyph (Grob *);
+ static void evaluate_empty (Grob *);
DECLARE_SCHEME_CALLBACK (width_callback, (SCM smob, SCM axis));
- DECLARE_SCHEME_CALLBACK (get_bar_size, (SCM ));
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
- DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM ));
+ DECLARE_SCHEME_CALLBACK (get_bar_size, (SCM));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
DECLARE_SCHEME_CALLBACK (center_on_spanned_callback, (SCM element, SCM axis));
};
#include "rod.hh"
/** A symbol which is attached between two columns. A spanner is a
- symbol which spans across several columns, so its final appearance
- can only be calculated after the breaking problem is solved.
+ symbol which spans across several columns, so its final appearance
+ can only be calculated after the breaking problem is solved.
- Examples
+ Examples
- * (de)crescendo
- * slur
- * beam
- * bracket
+ * (de)crescendo
+ * slur
+ * beam
+ * bracket
- Spanner should know about the items which it should consider:
- e.g. slurs should be steep enough to "enclose" all those items. This
- is absolutely necessary for beams, since they have to adjust the
- length of stems of notes they encompass.
-
- */
-class Spanner : public Grob {
- Drul_array<Item*> spanned_drul_;
+ Spanner should know about the items which it should consider:
+ e.g. slurs should be steep enough to "enclose" all those items. This
+ is absolutely necessary for beams, since they have to adjust the
+ length of stems of notes they encompass.
+*/
+class Spanner : public Grob
+{
+ Drul_array<Item *> spanned_drul_;
int break_index_;
-
+
public:
DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM));
-
+
Link_array<Spanner> broken_intos_;
int get_break_index () const;
// todo: move to somewhere else.
Real get_broken_left_end_align () const;
- void substitute_one_mutable_property (SCM sym, SCM val) ;
+ void substitute_one_mutable_property (SCM sym, SCM val);
bool fast_fubstitute_grob_list (SCM sym, SCM grob_list);
// TODO: make virtual and do this for Items as well.
Interval_t<int> spanned_rank_iv ();
- void set_bound (Direction d, Grob*);
+ void set_bound (Direction d, Grob *);
Item *get_bound (Direction d) const;
-
- Spanner (SCM, Object_key const*);
+
+ Spanner (SCM, Object_key const *);
Spanner (Spanner const &, int copy_count);
bool is_broken () const;
void do_break ();
Real spanner_length () const;
- static int compare (Spanner * const &, Spanner * const &);
- virtual Grob* find_broken_piece (System*) const;
+ static int compare (Spanner *const &, Spanner *const &);
+ virtual Grob *find_broken_piece (System *) const;
virtual SCM do_derived_mark () const;
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
virtual System *get_system () const;
protected:
virtual void do_break_processing ();
};
-void add_bound_item (Spanner*, Grob*);
+void add_bound_item (Spanner *, Grob *);
-bool spanner_less ( Spanner *s1, Spanner* s2);
-int broken_spanner_index (Spanner * sp);
+bool spanner_less (Spanner *s1, Spanner *s2);
+int broken_spanner_index (Spanner *sp);
#endif
-/*
+/*
spring.hh -- declare Spring, Column_spring
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef SPRING_HH
#define SPRING_HH
Real distance_;
bool expand_only_b_;
Real strength_;
-
- DECLARE_SIMPLE_SMOBS(Spring_smob, dummy);
+
+ DECLARE_SIMPLE_SMOBS (Spring_smob, dummy);
public:
- Spring_smob();
+ Spring_smob ();
};
-DECLARE_UNSMOB(Spring_smob, spring);
+DECLARE_UNSMOB (Spring_smob, spring);
struct Spring
{
- Drul_array<Item*> item_drul_;
+ Drul_array<Item *> item_drul_;
Real distance_;
bool expand_only_b_;
Spring ();
};
-
#endif /* SPRING_HH */
-/*
-staff-spacing.hh -- declare Staff_spacing
+/*
+ staff-spacing.hh -- declare Staff_spacing
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ (c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#ifndef STAFF_SPACING_HH
#define STAFF_SPACING_HH
class Staff_spacing
{
public:
- static Real next_notes_correction (Grob*, Grob*);
- static Real next_note_correction (Grob*, Grob*, Interval);
- static bool has_interface (Grob*);
- static void get_spacing_params (Grob*, Real*, Real*);
+ static Real next_notes_correction (Grob *, Grob *);
+ static Real next_note_correction (Grob *, Grob *, Interval);
+ static bool has_interface (Grob *);
+ static void get_spacing_params (Grob *, Real *, Real *);
- static Interval bar_y_positions (Grob*);
+ static Interval bar_y_positions (Grob *);
};
#endif /* STAFF_SPACING_HH */
-/*
- staff-sym-referencer.hh -- declare staff_symbol_referencer
-
- source file of the GNU LilyPond music typesetter
-
+/*
+ staff-sym-referencer.hh -- declare staff_symbol_referencer
+
+ source file of the GNU LilyPond music typesetter
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef STAFF_SYMBOL_REFERENCER_HH
#define STAFF_SYMBOL_REFERENCER_HH
#include "grob.hh"
-
/**
- A notation object that needs access to variables of the staff (no
- lines, leading).
-
- */
-class Staff_symbol_referencer
+ A notation object that needs access to variables of the staff (no
+ lines, leading).
+*/
+class Staff_symbol_referencer
{
public:
- static bool has_interface (Grob*);
- static bool ugly_hack (Grob*);
- static void set_position (Grob*, Real);
+ static bool has_interface (Grob *);
+ static bool ugly_hack (Grob *);
+ static void set_position (Grob *, Real);
DECLARE_SCHEME_CALLBACK (callback, (SCM element, SCM axis));
/**
Leading are the lead strips between the sticks (lines) of
typeface. ie. leading is vertical space.
*/
- static Real line_thickness (Grob*);
- static Real staff_space (Grob*);
- static Grob *get_staff_symbol (Grob*);
- static bool on_staffline (Grob*);
- static bool on_staffline (Grob*, int);
- static int line_count (Grob*);
- static Real get_position (Grob*);
- static Real staff_radius (Grob*);
- static int get_rounded_position (Grob*);
+ static Real line_thickness (Grob *);
+ static Real staff_space (Grob *);
+ static Grob *get_staff_symbol (Grob *);
+ static bool on_staffline (Grob *);
+ static bool on_staffline (Grob *, int);
+ static int line_count (Grob *);
+ static Real get_position (Grob *);
+ static Real staff_radius (Grob *);
+ static int get_rounded_position (Grob *);
};
-int compare_position (Grob *const&, Grob *const&);
+int compare_position (Grob *const &, Grob *const &);
#endif /* STAFF_SYMBOL_REFERENCER_HH */
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef STAFF_SYMBOL_HH
#define STAFF_SYMBOL_HH
#include "lily-proto.hh"
/**
- TODO: add linethickness as parameter.
- */
-class Staff_symbol
+ TODO: add linethickness as parameter.
+*/
+class Staff_symbol
{
public:
- static Real staff_space (Grob*) ;
- static Real get_line_thickness (Grob*);
- static Real get_ledger_line_thickness (Grob*);
-
- static int get_steps (Grob*) ;
- static int line_count (Grob*);
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
- static bool has_interface (Grob*);
-
+ static Real staff_space (Grob *);
+ static Real get_line_thickness (Grob *);
+ static Real get_ledger_line_thickness (Grob *);
+
+ static int get_steps (Grob *);
+ static int line_count (Grob *);
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ static bool has_interface (Grob *);
+
};
#endif // STAFF_SYMBOL_HH
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
*/
-
#ifndef STEM_INFO_HH
#define STEM_INFO_HH
/*
Parameters for a stem, (multiply with stemdirection, to get real values
for a downstem.)
- */
-struct Stem_info
+*/
+struct Stem_info
{
Direction dir_;
Real ideal_y_;
Real shortest_y_;
- Stem_info();
-void scale (Real);
+ Stem_info ();
+ void scale (Real);
};
#endif // STEM_INFO_HH
-/*
+/*
stem-tremolo.hh -- declare Abbreviation
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef ABBREV_HH
#define ABBREV_HH
class Stem_tremolo
{
public:
-
- static bool has_interface (Grob*);
+
+ static bool has_interface (Grob *);
DECLARE_SCHEME_CALLBACK (dim_callback, (SCM smob, SCM axis));
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (height, (SCM, SCM));
- static Stencil raw_stencil (Grob*);
+ static Stencil raw_stencil (Grob *);
};
#endif /* ABBREV_HH */
#include "lily-guile.hh"
#include "stem-info.hh"
-class Stem
+class Stem
{
public:
static Array<int> note_head_positions (Grob *);
static Spanner *get_beam (Grob *);
static Grob *first_head (Grob *);
static Grob *last_head (Grob *);
- static Drul_array<Grob*> extremal_heads (Grob *);
- static Grob *support_head (Grob *) ;
+ static Drul_array<Grob *> extremal_heads (Grob *);
+ static Grob *support_head (Grob *);
static void add_head (Grob *me, Grob *n);
static Stem_info get_stem_info (Grob *);
static Real chord_start_y (Grob *);
static void set_stemend (Grob *, Real);
static Direction get_default_dir (Grob *);
static Slice Stem::beam_multiplicity (Grob *);
- static Real thickness (Grob*);
+ static Real thickness (Grob *);
static int head_count (Grob *);
- static bool is_invisible (Grob *) ;
+ static bool is_invisible (Grob *);
static Interval head_positions (Grob *);
- static Real get_default_stem_end_position (Grob*me);
+ static Real get_default_stem_end_position (Grob *me);
static void position_noteheads (Grob *);
static Real stem_end_position (Grob *);
static Stencil flag (Grob *);
static bool has_interface (Grob *);
static void set_spacing_hints (Grob *);
-
+
DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (offset_callback, (SCM element, SCM axis));
DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
It is implemented as a "tree" of scheme expressions, as in
- Expr = combine Expr-list
- | translate Offset Expr
- | origin (ORIGIN) Expr
- | no-origin Expr
- | (SCHEME)
- ;
+ Expr = combine Expr-list
+ | translate Offset Expr
+ | origin (ORIGIN) Expr
+ | no-origin Expr
+ | (SCHEME)
+ ;
SCHEME is a Scheme expression that --when eval'd-- produces the
- desired output.
+ desired output.
Notes:
-
+
* Because of the way that Stencil is implemented, it is the most
efficient to add "fresh" stencils to what you're going to build.
* Do not create Stencil objects on the heap. That includes passing
around Stencil* which are produced by unsmob_stencil(). Either
copy Stencil objects, or use SCM references.
-
+
* Empty stencils have empty dimensions. If add_at_edge is used to
init the stencil, we assume that
- DIMENSIONS = (Interval (0, 0), Interval (0, 0)
+ DIMENSIONS = (Interval (0, 0), Interval (0, 0)
*/
class Stencil
{
This provides the reference point of the symbol, for example with
characters, it is on the base line of the character. Usually,
ORIGIN is inside DIM_
- */
+ */
Offset origin_;
Box dim_;
SCM expr_;
-
- DECLARE_SIMPLE_SMOBS (Stencil, );
+
+ DECLARE_SIMPLE_SMOBS (Stencil,);
public:
Stencil (Box, SCM s);
Stencil ();
-
+
Offset origin () const;
SCM expr () const;
void translate (Offset);
void align_to (Axis a, Real x);
void translate_axis (Real, Axis);
-
+
Interval extent (Axis) const;
Box extent_box () const;
bool is_empty () const;
static SCM ly_stencil_combined_at_edge (SCM, SCM, SCM, SCM, SCM);
};
-
-DECLARE_UNSMOB(Stencil, stencil);
-SCM fontify_atom (Font_metric const*, SCM atom);
+DECLARE_UNSMOB (Stencil, stencil);
+SCM fontify_atom (Font_metric const *, SCM atom);
void interpret_stencil_expression (SCM expr,
- void (*func) (void*, SCM),
- void *func_arg,
- Offset o);
+ void (*func) (void *, SCM),
+ void *func_arg,
+ Offset o);
Stencil create_stencil (SCM print);
SCM find_expression_fonts (SCM expr);
-/*
-stream.hh -- declare compatibility glue for gcc 3.
+/*
+ stream.hh -- declare compatibility glue for gcc 3.
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ (c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#ifndef STREAM_HH
#define STREAM_HH
#endif
void close_file_stream (std::ostream *os);
-
#endif /* STREAM_HH */
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef SWALLOW_PERF_HH
#define SWALLOW_PERF_HH
{
public:
VIRTUAL_COPY_CONS (Translator);
-
+
protected:
- virtual bool try_music (Music*) { return true; }
+ virtual bool try_music (Music *) { return true; }
};
#endif // SWALLOW_PERF_HH
-/*
+/*
System-start-delimiter.hh -- declare System_start_delimiter
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef SYSTEM_START_DELIMITER_HH
#define SYSTEM_START_DELIMITER_HH
/*
Braces/brackets across staves.
- */
+*/
class System_start_delimiter
{
public:
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
-
-
- static bool has_interface (Grob*);
- DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM ));
- static void try_collapse (Grob*);
- static Stencil staff_bracket (Grob*, Real) ;
- static Stencil staff_brace (Grob*, Real) ;
- static Stencil simple_bar (Grob*, Real) ;
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+
+ static bool has_interface (Grob *);
+ DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
+ static void try_collapse (Grob *);
+ static Stencil staff_bracket (Grob *, Real);
+ static Stencil staff_brace (Grob *, Real);
+ static Stencil simple_bar (Grob *, Real);
};
#endif /* SYSTEM_START_DELIMITER_HH */
#ifndef SYSTEM_HH
#define SYSTEM_HH
-
#include "column-x-positions.hh"
#include "spanner.hh"
/*
If you keep following offset reference points, you will always end
-up at the root object. This root object is called @ref{System}, and it
-represents a system (i.e. a line of music).
-
-
- */
+ up at the root object. This root object is called @ref{System}, and it
+ represents a system (i.e. a line of music).
+*/
class System : public Spanner
{
public:
SCM get_line ();
SCM get_lines ();
- System (SCM, Object_key const*);
- System (System const&, int);
+ System (SCM, Object_key const *);
+ System (System const &, int);
virtual Grob *clone (int count) const;
-
+
int element_count () const;
int spanner_count () const;
- void break_into_pieces (Array<Column_x_positions> const&);
- static bool has_interface (Grob*);
-
- Link_array<Item> broken_col_range (Item const*, Item const*) const;
+ void break_into_pieces (Array<Column_x_positions> const &);
+ static bool has_interface (Grob *);
+
+ Link_array<Item> broken_col_range (Item const *, Item const *) const;
Link_array<Grob> columns () const;
-
- void add_column (Paper_column*);
- void typeset_grob (Grob*);
+
+ void add_column (Paper_column *);
+ void typeset_grob (Grob *);
void pre_processing ();
protected:
};
-
-void set_loose_columns (System* which, Column_x_positions const *posns);
+void set_loose_columns (System *which, Column_x_positions const *posns);
#endif /* SYSTEM_HH */
-/*
+/*
text-item.hh -- declare markup functions
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#ifndef TEXT_ITEM
#define TEXT_ITEM
-
#include "stencil.hh"
class Text_interface
DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (interpret_markup, (SCM, SCM, SCM));
DECLARE_SCHEME_CALLBACK (interpret_string, (SCM, SCM, SCM));
- static bool has_interface (Grob*);
- static bool markup_p (SCM) ;
+ static bool has_interface (Grob *);
+ static bool markup_p (SCM);
};
#endif /* TEXT_ITEM */
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef TEXT_METRICS_HH
void try_load_text_metrics (String);
SCM ly_load_text_dimensions (SCM);
Box lookup_tex_text_dimension (Font_metric *font,
- SCM text);
+ SCM text);
#endif /* TEXT_METRICS_HH */
(c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
*/
-
#ifndef TEXT_SPANNER_HH
#define TEXT_SPANNER_HH
{
public:
DECLARE_SCHEME_CALLBACK (print, (SCM));
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
};
#endif /* TEXT_SPANNER_HH */
-/*
+/*
tfm-reader.hh -- declare Tex_font_metric_reader
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Jan Nieuwenhuizen <janneke@gnu.org>
revamped code from GNU Fontutils-0.6
-
- */
+*/
#ifndef TFM_READER_HH
#define TFM_READER_HH
Tex_font_char_metric read_char_metric (Char_code code);
Tex_font_char_metric read_char ();
void read_lig_kern_program (Array<Tfm_ligature>* ligatures,
- Array <Tfm_kern>* kerns);
+ Array<Tfm_kern>* kerns);
Binary_source_file input_;
public:
- Tex_font_metric_reader ( String name);
+ Tex_font_metric_reader (String name);
Tfm_info info_;
Tfm_header header_;
-/*
+/*
tfm.hh -- declare Tex_font_metric
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Jan Nieuwenhuizen <janneke@gnu.org>
revamped code from GNU Fontutils-0.6
-
- */
+*/
/*
TODO: aren't there standard libs? Ideally it is better to just link
Tex_font_char_metric ();
- Box dimensions () const;
+ Box dimensions () const;
};
-
class Tex_font_metric : public Simple_font_metric
{
public:
virtual String font_name () const;
Tfm_info const &info () const;
-
+
protected:
Tfm_info info_;
Tfm_header header_;
Tex_font_metric ();
};
-
#endif /* TFM_HH */
-/*
+/*
tie-column.hh -- declare Tie_column
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef TIE_COLUMN_HH
#define TIE_COLUMN_HH
class Tie_column
{
public:
- static bool has_interface (Grob*);
- static void add_tie (Grob*me, Grob*);
+ static bool has_interface (Grob *);
+ static void add_tie (Grob *me, Grob *);
DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
- static void set_directions (Grob*me);
- static void werner_directions (Grob*me);
+ static void set_directions (Grob *me);
+ static void werner_directions (Grob *me);
};
#endif /* TIE_COLUMN_HH */
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef TIE_HH
#define TIE_HH
#include "lily-guile.hh"
#include "lily-proto.hh"
-
class Tie
{
public:
- static void set_head (Grob*, Direction, Grob*head);
- static void set_interface (Grob*);
- static bool has_interface (Grob*);
- static void set_direction (Grob*);
- static Grob *head (Grob*, Direction) ;
- static int get_column_rank (Grob*, Direction);
- static Real get_position (Grob*) ;
- static Direction get_default_dir (Grob*) ;
+ static void set_head (Grob *, Direction, Grob *head);
+ static void set_interface (Grob *);
+ static bool has_interface (Grob *);
+ static void set_direction (Grob *);
+ static Grob *head (Grob *, Direction);
+ static int get_column_rank (Grob *, Direction);
+ static Real get_position (Grob *);
+ static Direction get_default_dir (Grob *);
static SCM get_control_points (SCM);
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
- DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM ));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM));
};
#endif // TIE_HH
-/*
+/*
compressed-music-iterator.hh -- declare Time_scaled_music_iterator
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#ifndef Time_scaled_music_ITERATOR_HH
#define Time_scaled_music_ITERATOR_HH
class Time_scaled_music_iterator : public Music_wrapper_iterator
{
-public:
- DECLARE_SCHEME_CALLBACK(constructor, ());
+public:
+ DECLARE_SCHEME_CALLBACK (constructor, ());
/* construction */
protected:
virtual void process (Moment);
};
-
#endif /* Time_scaled_music_ITERATOR_HH */
TODO:
2+3+2/8 time_signatures
-
- */
+*/
struct Time_signature
{
- static bool has_interface (Grob*);
- static Stencil special_time_signature (Grob*, SCM, int, int) ;
- static Stencil numbered_time_signature (Grob*, int, int);
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
+ static bool has_interface (Grob *);
+ static Stencil special_time_signature (Grob *, SCM, int, int);
+ static Stencil numbered_time_signature (Grob *, int, int);
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
};
#endif // METER_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef TIMING_TRANSLATOR_HH
#define TIMING_TRANSLATOR_HH
class Timing_translator : public virtual Translator
{
public:
- TRANSLATOR_DECLARATIONS(Timing_translator);
-
+ TRANSLATOR_DECLARATIONS (Timing_translator);
-protected:
+protected:
virtual void initialize ();
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
public:
Moment measure_position () const;
- Rational measure_length () const;
+ Rational measure_length () const;
};
#endif // TIMING_TRANSLATOR_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef TRANSLATOR_GROUP_HH
#define TRANSLATOR_GROUP_HH
{
public:
VIRTUAL_COPY_CONSTRUCTOR (Translator, Translator_group);
- virtual Translator_group* get_daddy_translator ()const;
+ virtual Translator_group *get_daddy_translator ()const;
virtual SCM get_simple_trans_list ();
- virtual bool try_music (Music* req);
+ virtual bool try_music (Music *req);
virtual void initialize ();
Translator_group ();
virtual void derived_mark () const;
};
-SCM names_to_translators (SCM namelist, Context*tg);
-void recurse_over_translators (Context * c, Translator_method ptr, Direction);
+SCM names_to_translators (SCM namelist, Context *tg);
+void recurse_over_translators (Context *c, Translator_method ptr, Direction);
void translator_each (SCM list, Translator_method method);
-
#endif // TRANSLATOR_GROUP_HH
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef TRANSLATOR_HH
#define TRANSLATOR_HH
#endif
#define TRANSLATOR_DECLARATIONS(NAME) \
-public: \
+ public: \
NAME (); \
VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME); \
static SCM static_description_; \
public:
bool must_be_last () const;
-
- Context * context () const { return daddy_context_; }
-
+
+ Context *context () const { return daddy_context_; }
+
Translator (Translator const &);
SCM internal_get_property (SCM symbol) const;
-
+
virtual Output_def *get_output_def () const;
- virtual Translator_group* get_daddy_translator ()const;
- virtual Moment now_mom () const;
+ virtual Translator_group *get_daddy_translator ()const;
+ virtual Moment now_mom () const;
virtual bool try_music (Music *req);
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
- virtual void initialize () ;
+ virtual void initialize ();
virtual void process_music ();
virtual void do_announces ();
virtual void finalize ();
-
- Score_context * get_score_context () const;
- Global_context * get_global_context () const;
-
- TRANSLATOR_DECLARATIONS(Translator);
+ Score_context *get_score_context () const;
+ Global_context *get_global_context () const;
+
+ TRANSLATOR_DECLARATIONS (Translator);
DECLARE_SMOBS (Translator, dummy);
protected: // should be private.
- Context * daddy_context_ ;
+ Context *daddy_context_;
virtual void derived_mark () const;
-
+
friend class Context_def;
friend class Context;
};
/**
- A macro to automate administration of translators.
- */
-#define ADD_THIS_TRANSLATOR(T) \
-SCM T::static_description_ = SCM_EOL;\
-static void _ ## T ## _adder () {\
- T *t = new T;\
- T::static_description_ = t->static_translator_description ();\
- scm_permanent_object (T::static_description_);\
- add_translator (t);\
-}\
-SCM T::translator_description() const\
-{ \
- return static_description_;\
-}\
-ADD_GLOBAL_CTOR (_ ## T ## _adder);
-
-
-
-
-#define ADD_TRANSLATOR(classname, desc, grobs, accepted, acked, read, write) \
-ADD_THIS_TRANSLATOR (classname);\
-SCM \
-classname::static_translator_description () const \
-{ \
- SCM static_properties = SCM_EOL; \
- /* static_properties = acons (name , gh_str02scm (Translator::name (self_scm ())), \
- static_properties_); \
- */ \
- static_properties = scm_acons (ly_symbol2scm ("grobs-created"), \
- parse_symbol_list (grobs), static_properties); \
- \
- static_properties = scm_acons (ly_symbol2scm ("description"), \
- scm_makfrom0str (desc), static_properties); \
- \
- static_properties = scm_acons (ly_symbol2scm ("interfaces-acked"), \
- parse_symbol_list (acked), static_properties); \
- static_properties = scm_acons (ly_symbol2scm ("events-accepted"), \
- parse_symbol_list (accepted), static_properties); \
- \
- static_properties = scm_acons (ly_symbol2scm ("properties-read"), \
- parse_symbol_list (read), static_properties); \
- \
- static_properties = scm_acons (ly_symbol2scm ("properties-written"), \
- parse_symbol_list (write), static_properties); \
- \
- return static_properties; \
-}
-
-
-
-void add_translator (Translator*trans);
-
-Translator*get_translator (SCM s);
-DECLARE_UNSMOB(Translator, translator);
+ A macro to automate administration of translators.
+*/
+#define ADD_THIS_TRANSLATOR(T) \
+ SCM T::static_description_ = SCM_EOL; \
+ static void _ ## T ## _adder () \
+ { \
+ T *t = new T; \
+ T::static_description_ = t->static_translator_description (); \
+ scm_permanent_object (T::static_description_); \
+ add_translator (t); \
+ } \
+ SCM T::translator_description () const \
+ { \
+ return static_description_; \
+ } \
+ ADD_GLOBAL_CTOR (_ ## T ## _adder);
+
+
+#define ADD_TRANSLATOR(classname, desc, grobs, accepted, acked, read, write) \
+ ADD_THIS_TRANSLATOR (classname); \
+ SCM \
+ classname::static_translator_description () const \
+ { \
+ SCM static_properties = SCM_EOL; \
+ /* static_properties = acons (name , gh_str02scm (Translator::name (self_scm ())), \
+ static_properties_); \
+ */ \
+ static_properties = scm_acons (ly_symbol2scm ("grobs-created"), \
+ parse_symbol_list (grobs), static_properties); \
+ \
+ static_properties = scm_acons (ly_symbol2scm ("description"), \
+ scm_makfrom0str (desc), static_properties); \
+ \
+ static_properties = scm_acons (ly_symbol2scm ("interfaces-acked"), \
+ parse_symbol_list (acked), static_properties); \
+ static_properties = scm_acons (ly_symbol2scm ("events-accepted"), \
+ parse_symbol_list (accepted), static_properties); \
+ \
+ static_properties = scm_acons (ly_symbol2scm ("properties-read"), \
+ parse_symbol_list (read), static_properties); \
+ \
+ static_properties = scm_acons (ly_symbol2scm ("properties-written"), \
+ parse_symbol_list (write), static_properties); \
+ \
+ return static_properties; \
+ }
+
+void add_translator (Translator *trans);
+
+Translator *get_translator (SCM s);
+DECLARE_UNSMOB (Translator, translator);
#endif // TRANSLATOR_HH
class Tuplet_bracket
{
public:
- DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM ));
- DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM ));
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
-
- static bool has_interface (Grob*);
- static void add_column (Grob*me, Item*);
- static void add_beam (Grob*me, Grob*);
- static Grob *parallel_beam (Grob *me, Link_array<Grob> const&cols, bool *equally_long);
- static void calc_position_and_height (Grob*, Real*, Real *dy);
- static Stencil make_bracket (Grob *me, Axis protusion_axis,
- Offset dz, Drul_array<Real> height,
- Interval gap, Drul_array<Real> widen,
- Drul_array<Real> shorten);
- static Direction get_default_dir (Grob*);
+ DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
+ DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+
+ static bool has_interface (Grob *);
+ static void add_column (Grob *me, Item *);
+ static void add_beam (Grob *me, Grob *);
+ static Grob *parallel_beam (Grob *me, Link_array<Grob> const &cols, bool *equally_long);
+ static void calc_position_and_height (Grob *, Real *, Real *dy);
+ static Stencil make_bracket (Grob *me, Axis protusion_axis,
+ Offset dz, Drul_array<Real> height,
+ Interval gap, Drul_array<Real> widen,
+ Drul_array<Real> shorten);
+ static Direction get_default_dir (Grob *);
};
#endif // Tuplet_bracket_HH
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#ifndef TWEAK_REGISTRATION_HH
#define TWEAK_REGISTRATION_HH
-#include <map>
+#include <map>
#include "lily-proto.hh"
#include "object-key.hh"
-typedef std::map<Object_key const*, SCM, Object_key_less> Tweak_map;
+typedef std::map < Object_key const *, SCM, Object_key_less> Tweak_map;
class Tweak_registry
{
Tweak_map tweaks_;
Object_key_undumper *undumper_;
- DECLARE_SMOBS(Tweak_registry, );
-
+ DECLARE_SMOBS (Tweak_registry,);
+
public:
Tweak_registry ();
- Object_key_undumper *undumper() const;
+ Object_key_undumper *undumper () const;
void clear ();
- void insert_grob_tweak (Grob*, SCM);
- void replace_grob_tweak (Grob*, SCM);
+ void insert_grob_tweak (Grob *, SCM);
+ void replace_grob_tweak (Grob *, SCM);
SCM get_tweaks (Grob *);
SCM list_tweaks ();
void insert_tweak_from_file (SCM);
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef TYPESWALLOW_GRAV_HH
#define TYPESWALLOW_GRAV_HH
#include "translator.hh"
/** eat a certain type of event
- (Duh, it's good for your skin)
- */
+ (Duh, it's good for your skin)
+*/
class Type_swallow_translator : public virtual Translator
{
protected:
String swallow_string_;
- bool try_music (Music*);
-public:
+ bool try_music (Music *);
+public:
VIRTUAL_COPY_CONS (Translator);
};
#define DECLARE_EVENT_SWALLOWER(TYPE) \
-struct TYPE ## _swallow_translator : public Type_swallow_translator { \
- TRANSLATOR_DECLARATIONS (TYPE ## _swallow_translator); \
-}; \
- TYPE ## _swallow_translator :: TYPE ## _swallow_translator() {\
- swallow_string_ = #TYPE; \
+ struct TYPE ## _swallow_translator : public Type_swallow_translator \
+ { \
+ TRANSLATOR_DECLARATIONS (TYPE ## _swallow_translator); \
+ }; \
+ TYPE ## _swallow_translator :: TYPE ## _swallow_translator () \
+ { \
+ swallow_string_ = #TYPE; \
} \
-ADD_TRANSLATOR(TYPE ## _swallow_translator, \
- "Swallow events of " #TYPE " type.", \
- "", \
- "general-music", \
- "", \
- "", \
+ ADD_TRANSLATOR (TYPE ## _swallow_translator, \
+ "Swallow events of " #TYPE " type.", \
+ "", \
+ "general-music", \
+ "", \
+ "", \
"");
#endif // TYPESWALLOW_GRAV_HH
source file of the GNU LilyPond music typesetter
- (c) 2003--2005 Juergen Reuter <reuter@ipd.uka.de>
+ (c) 2003--2005 Juergen Reuter <reuter@ipd.uka.de>
*/
#ifndef VATICANA_LIGATURE_HH
struct Vaticana_ligature
{
- DECLARE_SCHEME_CALLBACK (brew_ligature_primitive, (SCM ));
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
+ DECLARE_SCHEME_CALLBACK (brew_ligature_primitive, (SCM));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
static bool has_interface (Grob *);
};
*
* The below definition extends those in gregorian-ligature.hh.
*/
-#define STACKED_HEAD 0x0100 // this head is stacked on the previous one
+#define STACKED_HEAD 0x0100 // this head is stacked on the previous one
#endif // VATICANA_LIGATURE_HH
#ifndef VOLTA_SPANNER_HH
#define VOLTA_SPANNER_HH
-
#include "spanner.hh"
class Volta_bracket_interface
{
public:
- static bool has_interface (Grob*);
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
- static void add_column (Grob*, Grob*col);
- static void add_bar (Grob*me, Item*bar);
+ static bool has_interface (Grob *);
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ static void add_column (Grob *, Grob *col);
+ static void add_bar (Grob *me, Item *bar);
};
#endif // VOLTA_SPANNER_HH
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "string.hh"
}
LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 0, (SCM sip, SCM msg),
- "Print @var{msg} as a GNU compliant error message, pointing to the"
+ "Print @var{msg} as a GNU compliant error message, pointing to the"
"location in @var{sip}.\n")
{
Input *ip = unsmob_input (sip);
}
LY_DEFINE (ly_input_file_line_column, "ly:input-file-line-column", 1, 0, 0, (SCM sip),
- "Return input location in @var{sip} as (file-name line column).")
+ "Return input location in @var{sip} as (file-name line column).")
{
Input *ip = unsmob_input (sip);
SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
}
LY_DEFINE (ly_input_both_locations, "ly:input-both-locations", 1, 0, 0, (SCM sip),
- "Return input location in @var{sip} as (file-name first-line first-column last-line last-column).")
+ "Return input location in @var{sip} as (file-name first-line first-column last-line last-column).")
{
Input *ip = unsmob_input (sip);
SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
-/*
+/*
input-smob.cc -- implement Input smob
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "input-smob.hh"
static int
print_smob (SCM s, SCM port, scm_print_state *)
{
- String str = "#<location " + unsmob_input (s)->location_string () + ">";
+ String str = "#<location " + unsmob_input (s)->location_string () + ">";
scm_puts (str.to_str0 (), port);
return 1;
}
return 0;
}
-
static void
start_input_smobs ()
{
{
Input *nip = new Input (ip);
SCM z;
-
+
SCM_NEWSMOB (z, input_tag, nip);
return z;
}
-Input *
+Input *
unsmob_input (SCM s)
{
if (SCM_IMP (s))
return 0;
if (SCM_CAR (s) == (SCM)input_tag) // ugh.
- return (Input*) SCM_CDR (s);
- else
- return 0;
+ return (Input *) SCM_CDR (s);
+ else
+ return 0;
}
-
ADD_SCM_INIT_FUNC (input, start_input_smobs);
/*
- input.cc -- implement Input
+ input.cc -- implement Input
- source file of the LilyPond music typesetter
+ source file of the LilyPond music typesetter
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
Input::step_forward ()
{
if (end_ == start_)
- end_ ++;
- start_ ++;
+ end_++;
+ start_++;
}
void
/*
Produce GNU-compliant error message. Correcting lilypond source is
such a breeze if you ('re edidor) know (s) the error column too
-
- Format:
- [file:line:column:][warning:]message
+ Format:
- */
+ [file:line:column:][warning:]message
+*/
void
Input::message (String message_string) const
{
String str;
-
+
/*
- marked "Work in prgress" in GNU iostream
- libg++ 2.7.2.8
- libstdc++ 2.8.1
+ marked "Work in prgress" in GNU iostream
+ libg++ 2.7.2.8
+ libstdc++ 2.8.1
- why not just return always -1 (unknown),
+ why not just return always -1 (unknown),
iso breaking the interface?
- int col = cerr.rdbuf ()->column ();
+ int col = cerr.rdbuf ()->column ();
- */
+ */
// well, we don't want to loose first warning...
int col = 1;
if (col > 0)
str += "\n";
-
+
if (source_file_)
str += location_string () + String (": ");
str += message_string;
if (source_file_)
- {
- str += ":\n";
- str += source_file_->error_string (start_);
- }
+ {
+ str += ":\n";
+ str += source_file_->error_string (start_);
+ }
fprintf (stderr, "%s\n", str.to_str0 ());
fflush (stderr);
}
return "";
}
-
int
Input::line_number () const
{
-/*
+/*
instrument-name-engraver.cc -- implement Instrument_name_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "engraver.hh"
#include "bar-line.hh"
class Instrument_name_engraver : public Engraver
{
-
+
public:
TRANSLATOR_DECLARATIONS (Instrument_name_engraver);
void
Instrument_name_engraver::initialize ()
{
- context ()->set_property ("instrumentSupport", SCM_EOL);
+ context ()->set_property ("instrumentSupport", SCM_EOL);
}
void
Instrument_name_engraver::create_text ()
{
if (text_)
- return ;
-
+ return;
+
SCM txt = get_property ("instrument");
-
+
if (now_mom () > Moment (0))
txt = get_property ("instr");
/*
UGH.
*/
if (txt == SCM_EOL)
- return ;
+ return;
-
text_ = make_item ("InstrumentName", SCM_EOL);
-
+
if (text_->get_property ("text") != txt)
text_->set_property ("text", txt);
-
+
}
void
/*
Ugh - typechecking for pedal and dynamic sucks.
- */
- if (dynamic_cast<Spanner*> (i.grob_)
+ */
+ if (dynamic_cast<Spanner *> (i.grob_)
&& (i.grob_->internal_has_interface (ly_symbol2scm ("dynamic-interface"))
- || i.grob_->internal_has_interface (ly_symbol2scm ("piano-pedal-interface")))
- )
+ || i.grob_->internal_has_interface (ly_symbol2scm ("piano-pedal-interface"))))
return;
/*
We could also just use stavesFound, but lets keep this working
without staffs as well.
*/
- if (dynamic_cast<Spanner*> (i.grob_)
+ if (dynamic_cast<Spanner *> (i.grob_)
&& ((Axis_group_interface::has_interface (i.grob_)
&& Axis_group_interface::has_axis (i.grob_, Y_AXIS)))
&& !Align_interface::has_interface (i.grob_))
{
SCM nl = scm_cons (i.grob_->self_scm (),
- get_property ("instrumentSupport"));
+ get_property ("instrumentSupport"));
context ()->set_property ("instrumentSupport", nl);
}
{
/*
Also create text if barlines in other groups. This allows
- a name to be attached to lyrics or chords.
- */
+ a name to be attached to lyrics or chords.
+ */
if (scm_is_string (get_property ("whichBar")))
create_text ();
}
ADD_TRANSLATOR (Instrument_name_engraver,
-/* descr */ " Prints the name of the instrument (specified by "
-" @code{Staff.instrument} and @code{Staff.instr}) "
-"at the left of the staff. ",
-/* creats*/ "InstrumentName",
-/* accepts */ "",
-/* acks */ "bar-line-interface axis-group-interface",
-/* reads */ "instrument instr",
-/* write */ "");
+ /* descr */ " Prints the name of the instrument (specified by "
+ " @code{Staff.instrument} and @code{Staff.instr}) "
+ "at the left of the staff. ",
+ /* creats*/ "InstrumentName",
+ /* accepts */ "",
+ /* acks */ "bar-line-interface axis-group-interface",
+ /* reads */ "instrument instr",
+ /* write */ "");
/****************************************************************/
-
class Vocal_name_engraver : public Instrument_name_engraver
{
public:
virtual void create_text ();
};
-
Vocal_name_engraver::Vocal_name_engraver ()
{
}
-
void
Vocal_name_engraver::create_text ()
{
if (text_)
- return ;
-
+ return;
+
SCM txt = get_property ("vocalName");
-
+
if (now_mom () > Moment (0))
txt = get_property ("vocNam");
UGH.
*/
if (txt == SCM_EOL)
- return ;
-
+ return;
+
text_ = make_item ("VocalName", SCM_EOL);
-
+
if (text_->get_property ("text") != txt)
text_->set_property ("text", txt);
-
-}
-
+}
ADD_TRANSLATOR (Vocal_name_engraver,
-/* descr */ " Prints the name of the a lyric voice (specified by "
-" @code{Staff.vocalName} and @code{Staff.vocNam}) "
-"at the left of the staff. ",
-/* creats*/ "VocalName",
-/* accepts */ "",
-/* acks */ "bar-line-interface axis-group-interface",
-/* reads */ "vocNam vocalName",
-/* write */ "");
+ /* descr */ " Prints the name of the a lyric voice (specified by "
+ " @code{Staff.vocalName} and @code{Staff.vocNam}) "
+ "at the left of the staff. ",
+ /* creats*/ "VocalName",
+ /* accepts */ "",
+ /* acks */ "bar-line-interface axis-group-interface",
+ /* reads */ "vocNam vocalName",
+ /* write */ "");
#include "system.hh"
#include "group-interface.hh"
-Grob *
+Grob *
Item::clone (int count) const
{
return new Item (*this, count);
}
-
Item::Item (SCM s, Object_key const *key)
: Grob (s, key)
{
broken_to_drul_[LEFT] = broken_to_drul_[RIGHT] = 0;
}
-
bool
-Item::is_breakable (Grob*me)
+Item::is_breakable (Grob *me)
{
if (me->original_)
return false;
- if (!dynamic_cast<Item*> (me))
+ if (!dynamic_cast<Item *> (me))
me->programming_error ("only items can be breakable.");
-
- Item * i = dynamic_cast<Item*> (me->get_parent (X_AXIS));
+
+ Item *i = dynamic_cast<Item *> (me->get_parent (X_AXIS));
return (i) ? Item::is_breakable (i) : to_boolean (me->get_property ("breakable"));
}
Paper_column *
Item::get_column () const
{
- Item *parent = dynamic_cast<Item*> (get_parent (X_AXIS));
+ Item *parent = dynamic_cast<Item *> (get_parent (X_AXIS));
return parent ? parent->get_column () : 0;
}
Item::get_system () const
{
Grob *g = get_parent (X_AXIS);
- return g ? g->get_system () : 0;
+ return g ? g->get_system () : 0;
}
-
void
Item::copy_breakable_items ()
{
Drul_array<Item *> new_copies;
Direction i = LEFT;
int count = 0;
- do
+ do
{
- Grob * dolly = clone (count ++);
- Item * item = dynamic_cast<Item*> (dolly);
+ Grob *dolly = clone (count++);
+ Item *item = dynamic_cast<Item *> (dolly);
pscore_->system_->typeset_grob (item);
new_copies[i] = item;
}
broken_to_drul_ = new_copies;
}
-
bool
Item::is_broken () const
{
return broken_to_drul_[LEFT] || broken_to_drul_[RIGHT];
}
-
/*
Generate items for begin and end-of line.
- */
+*/
void
Item::discretionary_processing ()
{
copy_breakable_items ();
}
-Grob*
-Item::find_broken_piece (System*l) const
+Grob *
+Item::find_broken_piece (System *l) const
{
- if (get_system () == l)
- return (Item*) (this);
+ if (get_system () == l)
+ return (Item *) (this);
Direction d = LEFT;
- do {
- Grob *s = broken_to_drul_[d];
- if (s && s->get_system () == l)
- return s;
- }
+ do
+ {
+ Grob *s = broken_to_drul_[d];
+ if (s && s->get_system () == l)
+ return s;
+ }
while (flip (&d) != LEFT);
return 0;
}
-
-Item*
+Item *
Item::find_prebroken_piece (Direction d) const
{
- Item * me = (Item *) (this);
+ Item *me = (Item *) (this);
if (!d)
return me;
- return dynamic_cast<Item*> (broken_to_drul_[d]);
+ return dynamic_cast<Item *> (broken_to_drul_[d]);
}
-
Direction
Item::break_status_dir () const
{
if (original_)
{
- Item * i = dynamic_cast<Item*> (original_);
+ Item *i = dynamic_cast<Item *> (original_);
return (i->broken_to_drul_[LEFT] == this) ? LEFT : RIGHT;
}
Item::handle_prebroken_dependencies ()
{
Grob::handle_prebroken_dependencies ();
-
+
/*
Can't do this earlier, because try_visibility_lambda () might set
the elt property transparent, which would then be copied.
SCM result = scm_apply_0 (vis, args);
bool trans = ly_scm2bool (scm_car (result));
bool empty = ly_scm2bool (scm_cdr (result));
-
+
if (empty && trans)
suicide ();
else if (empty)
return SCM_EOL;
}
-Item*
-unsmob_item (SCM s )
+Item *
+unsmob_item (SCM s)
{
- return dynamic_cast<Item*> (unsmob_grob (s));
+ return dynamic_cast<Item *> (unsmob_grob (s));
}
-
ADD_INTERFACE (Item,
- "item-interface",
- "\n"
- "\n"
- "Grobs can be distinguished in their role in the horizontal spacing.\n"
- "Many grobs define constraints on the spacing by their sizes. For\n"
- "example, note heads, clefs, stems, and all other symbols with a fixed\n"
- "shape. These grobs form a subtype called @code{Item}.\n"
- "\n"
- "\n"
- "Some items need special treatment for line breaking. For example, a\n"
- "clef is normally only printed at the start of a line (i.e. after a\n"
- "line break). To model this, `breakable' items (clef, key signature,\n"
- "bar lines, etc.) are copied twice. Then we have three versions of each\n"
- "breakable item: one version if there is no line break, one version\n"
- "that is printed before the line break (at the end of a system), one\n"
- "version that is printed after the line break.\n"
- "\n"
- "Whether these versions are visible and take up space, is determined by\n"
- "the outcome of the @code{break-visibility}. This grob property is a\n"
- "function taking a direction (-1, 0 or 1) as argument. It returns a\n"
- "cons of booleans, signifying whether this grob should be transparent\n"
- "and have no extent.\n"
- "\n"
- "The following variables for break-visibility are predefined:\n"
- "@example\n"
- " grob will show: before no after\n"
- " break break break\n"
- " all-invisible no no no\n"
- " begin-of-line-visible no no yes\n"
- " end-of-line-visible yes no no\n"
- " all-visible yes yes yes\n"
- " begin-of-line-invisible yes yes no\n"
- " end-of-line-invisible no yes yes\n"
- "@end example\n"
- ,
- "no-spacing-rods break-visibility breakable")
+ "item-interface",
+ "\n"
+ "\n"
+ "Grobs can be distinguished in their role in the horizontal spacing.\n"
+ "Many grobs define constraints on the spacing by their sizes. For\n"
+ "example, note heads, clefs, stems, and all other symbols with a fixed\n"
+ "shape. These grobs form a subtype called @code{Item}.\n"
+ "\n"
+ "\n"
+ "Some items need special treatment for line breaking. For example, a\n"
+ "clef is normally only printed at the start of a line (i.e. after a\n"
+ "line break). To model this, `breakable' items (clef, key signature,\n"
+ "bar lines, etc.) are copied twice. Then we have three versions of each\n"
+ "breakable item: one version if there is no line break, one version\n"
+ "that is printed before the line break (at the end of a system), one\n"
+ "version that is printed after the line break.\n"
+ "\n"
+ "Whether these versions are visible and take up space, is determined by\n"
+ "the outcome of the @code{break-visibility}. This grob property is a\n"
+ "function taking a direction (-1, 0 or 1) as argument. It returns a\n"
+ "cons of booleans, signifying whether this grob should be transparent\n"
+ "and have no extent.\n"
+ "\n"
+ "The following variables for break-visibility are predefined:\n"
+ "@example\n"
+ " grob will show: before no after\n"
+ " break break break\n"
+ " all-invisible no no no\n"
+ " begin-of-line-visible no no yes\n"
+ " end-of-line-visible yes no no\n"
+ " all-visible yes yes yes\n"
+ " begin-of-line-invisible yes yes no\n"
+ " end-of-line-invisible no yes yes\n"
+ "@end example\n",
+ "no-spacing-rods break-visibility breakable")
source file of the GNU LilyPond music typesetter
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- */
+*/
#include "item.hh"
#include "bar-line.hh"
/*
TODO: The representation of key sigs is all fucked.
- */
+*/
/**
- Make the key signature.
- */
+ Make the key signature.
+*/
class Key_engraver : public Engraver
{
void create_key (bool);
- void read_ev (Music const * r);
+ void read_ev (Music const *r);
Music *key_ev_;
Item *item_;
virtual void acknowledge_grob (Grob_info);
};
-
void
Key_engraver::finalize ()
{
}
-
Key_engraver::Key_engraver ()
{
key_ev_ = 0;
cancellation_ = 0;
}
-
void
Key_engraver::create_key (bool def)
{
- if (!item_)
+ if (!item_)
{
item_ = make_item ("KeySignature", key_ev_ ? key_ev_->self_scm () : SCM_EOL);
cancellation_ = make_item ("KeyCancellation", key_ev_ ? key_ev_->self_scm () : SCM_EOL);
cancellation_->set_property ("old-accidentals", last);
cancellation_->set_property ("c0-position",
- get_property ("middleCPosition"));
-
+ get_property ("middleCPosition"));
+
}
item_->set_property ("new-accidentals", key);
}
if (!def)
{
- SCM vis = get_property ("explicitKeySignatureVisibility");
+ SCM vis = get_property ("explicitKeySignatureVisibility");
if (ly_c_procedure_p (vis))
item_->set_property ("break-visibility", vis);
}
-}
-
+}
bool
-Key_engraver::try_music (Music * ev)
+Key_engraver::try_music (Music *ev)
{
if (ev->is_mus_type ("key-change-event"))
{
read_ev (key_ev_);
}
return true;
- }
- return false;
+ }
+ return false;
}
-
void
Key_engraver::acknowledge_grob (Grob_info info)
{
if (Clef::has_interface (info.grob_))
{
- SCM c = get_property ("createKeyOnClefChange");
+ SCM c = get_property ("createKeyOnClefChange");
if (to_boolean (c))
{
create_key (false);
}
}
-
void
Key_engraver::process_music ()
{
- if (key_ev_ ||
- get_property ("lastKeySignature") != get_property ("keySignature"))
+ if (key_ev_
+ || get_property ("lastKeySignature") != get_property ("keySignature"))
create_key (false);
}
-
void
Key_engraver::stop_translation_timestep ()
{
item_ = 0;
context ()->set_property ("lastKeySignature", get_property ("keySignature"));
- cancellation_ = 0;
+ cancellation_ = 0;
}
-
void
-Key_engraver::read_ev (Music const * r)
+Key_engraver::read_ev (Music const *r)
{
SCM p = r->get_property ("pitch-alist");
if (!scm_is_pair (p))
n = scm_delete_x (scm_car (s), n);
}
}
-
- for (SCM s = n ; scm_is_pair (s); s = scm_cdr (s))
+
+ for (SCM s = n; scm_is_pair (s); s = scm_cdr (s))
if (scm_to_int (scm_cdar (s)))
accs = scm_cons (scm_car (s), accs);
context ()->set_property ("keySignature", accs);
- context ()->set_property ("tonic" ,
+ context ()->set_property ("tonic",
r->get_property ("tonic"));
}
-
void
Key_engraver::start_translation_timestep ()
{
key_ev_ = 0;
}
-
void
Key_engraver::initialize ()
{
}
-
ADD_TRANSLATOR (Key_engraver,
-/* descr */ "",
-/* creats*/ "KeySignature",
-/* accepts */ "key-change-event",
-/* acks */ "bar-line-interface clef-interface",
-/* reads */ "keySignature printKeyCancellation lastKeySignature explicitKeySignatureVisibility createKeyOnClefChange keyAccidentalOrder keySignature",
-/* write */ "lastKeySignature tonic keySignature");
+ /* descr */ "",
+ /* creats*/ "KeySignature",
+ /* accepts */ "key-change-event",
+ /* acks */ "bar-line-interface clef-interface",
+ /* reads */ "keySignature printKeyCancellation lastKeySignature explicitKeySignatureVisibility createKeyOnClefChange keyAccidentalOrder keySignature",
+ /* write */ "lastKeySignature tonic keySignature");
~Key_performer ();
protected:
- virtual bool try_music (Music* ev);
+ virtual bool try_music (Music *ev);
virtual void create_audio_elements ();
virtual void stop_translation_timestep ();
private:
- Event* key_ev_;
- Audio_key* audio_;
+ Event *key_ev_;
+ Audio_key *audio_;
};
Key_performer::Key_performer ()
void
Key_performer::create_audio_elements ()
{
- if (key_ev_)
+ if (key_ev_)
{
SCM pitchlist = key_ev_->get_property ("pitch-alist");
SCM proc = ly_lily_module_constant ("alterations-in-key");
-
+
SCM acc = scm_call_1 (proc, pitchlist);
-
- Pitch key_do (0,
+
+ Pitch key_do (0,
scm_to_int (scm_caar (pitchlist)),
scm_to_int (scm_cdar (pitchlist)));
Pitch c_do (0, 0, 0);
-
+
SCM c_pitchlist
= ly_transpose_key_alist (pitchlist,
pitch_interval (key_do, c_do).smobbed_copy ());
}
bool
-Key_performer::try_music (Music* ev)
+Key_performer::try_music (Music *ev)
{
- if (Event *kc = dynamic_cast <Event *> (ev))
+ if (Event *kc = dynamic_cast<Event *> (ev))
{
if (key_ev_)
warning (_ ("FIXME: key change merge"));
}
ADD_TRANSLATOR (Key_performer,
- "", "",
- "key-change-event",
- "", "", "");
+ "", "",
+ "key-change-event",
+ "", "", "");
struct Key_signature_interface
{
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
};
-
/*
FIXME: too much hardcoding here.
- */
+*/
const int FLAT_TOP_PITCH =2; /* fes, ges, as and bes typeset in lower octave */
const int SHARP_TOP_PITCH =4; /* ais and bis typeset in lower octave */
/*
- TODO: look this up. I'm not sure where the naturals ought to go.
- */
-const int NATURAL_TOP_PITCH = 4;
-
-
+ TODO: look this up. I'm not sure where the naturals ought to go.
+*/
+const int NATURAL_TOP_PITCH = 4;
/*
- TODO: put this in Scheme
- TODO: can we do without c0pos? it's partly musical.
-
+ TODO: can we do without c0pos? it's partly musical.
*/
int
-alteration_pos (SCM what, int alter, int c0p)
+alteration_pos (SCM what, int alter, int c0p)
{
if (scm_is_pair (what))
return scm_to_int (scm_car (what)) * 7 + scm_to_int (scm_cdr (what)) + c0p;
from_bottom_pos = (from_bottom_pos + 7)%7; // Precaution to get positive.
int c0 = from_bottom_pos - 4;
-
- if ((alter <0 && ((p>FLAT_TOP_PITCH) || (p+c0>4)) && (p+c0>1))
- || (alter >0 && ((p > SHARP_TOP_PITCH) || (p+c0>5)) && (p+c0>2))
- || (alter == 0 && ((p > NATURAL_TOP_PITCH) || (p + c0>5)) && (p + c0>2)))
+ if ((alter <0 && ((p > FLAT_TOP_PITCH) || (p + c0 > 4)) && (p + c0 > 1))
+ || (alter >0 && ((p > SHARP_TOP_PITCH) || (p + c0 > 5)) && (p + c0 > 2))
+ || (alter == 0 && ((p > NATURAL_TOP_PITCH) || (p + c0 > 5)) && (p + c0 > 2)))
{
p -= 7; /* Typeset below c_position */
}
-
- /* Provide for the four cases in which there's a glitch
- it's a hack, but probably not worth
- the effort of finding a nicer solution.
- --dl. */
- if (c0==2 && alter >0 && p ==3)
+
+ /* Provide for the four cases in which there's a glitch
+ it's a hack, but probably not worth
+ the effort of finding a nicer solution.
+ --dl. */
+ if (c0 == 2 && alter >0 && p ==3)
p -= 7;
- if (c0==-3 && alter>0 && p ==-1)
+ if (c0==-3 && alter > 0 && p ==-1)
p += 7;
- if (c0==-4 && alter<0 && p ==-1)
+ if (c0==-4 && alter < 0 && p ==-1)
p += 7;
- if (c0==-2 && alter<0 && p ==-3)
+ if (c0==-2 && alter < 0 && p ==-3)
p += 7;
-
+
return p + c0;
}
/*
TODO
- space the `natural' signs wider
- */
+*/
MAKE_SCHEME_CALLBACK (Key_signature_interface, print, 1);
SCM
Key_signature_interface::print (SCM smob)
{
- Grob*me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
- Real inter = Staff_symbol_referencer::staff_space (me)/2.0;
+ Real inter = Staff_symbol_referencer::staff_space (me) / 2.0;
SCM scm_style = me->get_property ("style");
String style;
style = "";
}
- SCM newas = me->get_property ("new-accidentals");
+ SCM newas = me->get_property ("new-accidentals");
Stencil mol;
SCM c0s = me->get_property ("c0-position");
for (SCM s = newas; scm_is_pair (s); s = scm_cdr (s))
{
int alteration = scm_to_int (scm_cdar (s));
- String font_char =
- Accidental_interface::get_fontcharname (style, alteration);
+ String font_char
+ = Accidental_interface::get_fontcharname (style, alteration);
Stencil acc (fm->find_by_name ("accidentals." + font_char));
if (acc.is_empty ())
}
}
- Item *it = dynamic_cast<Item*> (me) ;
+ Item *it = dynamic_cast<Item *> (me);
if (it->break_status_dir () != RIGHT)
{
SCM old = me->get_property ("old-accidentals");
-
+
Stencil natural;
if (scm_is_pair (old))
natural = Font_interface::get_default_font (me)->
- find_by_name (String ("accidentals.") + style + String ("0"));
-
+ find_by_name (String ("accidentals.") + style + String ("0"));
int last_pos = -100;
for (; scm_is_pair (old); old = scm_cdr (old))
- {
+ {
SCM found = scm_assoc (scm_caar (old), newas);
if (found == SCM_BOOL_F
|| scm_cdr (found) != scm_cdar (old))
int pos = alteration_pos (what, alteration, c0p);
Stencil m = natural;
- m.translate_axis (pos* inter, Y_AXIS);
+ m.translate_axis (pos* inter, Y_AXIS);
/*
The natural sign (unlike flat & sharp)
has vertical edges on both sides. A little padding is
needed to prevent collisions.
- */
+ */
Real padding = 0.0;
if (last_pos < pos + 2
- && last_pos> pos - 6)
+ && last_pos> pos - 6)
padding = 0.3;
-
+
mol.add_at_edge (X_AXIS, LEFT, m, padding, 0);
last_pos = pos;
- }
- }
+ }
+ }
}
mol.align_to (X_AXIS, LEFT);
-
+
return mol.smobbed_copy ();
}
ADD_INTERFACE (Key_signature_interface, "key-signature-interface",
- "A group of accidentals, to be printed as signature sign.",
- "style c0-position old-accidentals new-accidentals");
+ "A group of accidentals, to be printed as signature sign.",
+ "style c0-position old-accidentals new-accidentals");
/*
keyword.cc -- keywords and identifiers
- */
+*/
#include "keyword.hh"
#include <cstdlib>
/* for qsort */
-int tabcmp (Keyword_ent const &p1, Keyword_ent const &p2)
+int tabcmp (Keyword_ent const &p1, Keyword_ent const &p2)
{
return strcmp (p1.name_, p2.name_);
}
int
Keyword_table::lookup (char const *s) const
{
- Keyword_ent e ;
- e.name_ = s;
+ Keyword_ent e;
+ e.name_ = s;
int idx = binary_search (table_, e, tabcmp);
if (idx >= 0)
return table_[idx].tokcode_;
-/*
+/*
least-squares.cc -- implement minimise_least_squares
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "least-squares.hh"
#include "warn.hh"
void
-minimise_least_squares (Real * coef, Real * offset,
+minimise_least_squares (Real *coef, Real *offset,
Array<Offset> const &input)
{
Real sx = 0.0;
Real sqx = 0.0;
Real sxy = 0.0;
- for (int i = 0; i < input.size ();i++)
+ for (int i = 0; i < input.size ();i++)
{
Real x = input[i][X_AXIS];
Real y = input[i][Y_AXIS];
*coef = 0.0;
*offset = 0.;
-
- Real den = (N*sqx - sqr (sx));
+
+ Real den = (N *sqx - sqr (sx));
if (!N || !den)
{
programming_error ("minimise_least_squares (): Nothing to minimise");
*coef = 0.0;
- *offset = N ? sy/N : 0.0;
+ *offset = N ? sy / N : 0.0;
}
else
{
- *coef = (N * sxy - sx*sy)/den;
- *offset = (sy - (*coef) * sx)/N;
+ *coef = (N *sxy - sx*sy) / den;
+ *offset = (sy - (*coef) * sx) / N;
}
}
-/*
+/*
ledger-line-engraver.cc -- implement Ledger_line_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "group-interface.hh"
class Ledger_line_engraver : public Engraver
{
- Spanner * span_;
+ Spanner *span_;
public:
TRANSLATOR_DECLARATIONS (Ledger_line_engraver);
virtual void acknowledge_grob (Grob_info);
};
-Ledger_line_engraver::Ledger_line_engraver()
+Ledger_line_engraver::Ledger_line_engraver ()
{
span_ = 0;
}
{
if (!span_)
{
- span_ = make_spanner("LedgerLineSpanner", SCM_EOL);
-
+ span_ = make_spanner ("LedgerLineSpanner", SCM_EOL);
+
span_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
}
}
span_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
}
-
void
Ledger_line_engraver::acknowledge_grob (Grob_info s)
{
s.grob_);
}
ADD_TRANSLATOR (Ledger_line_engraver,
- "Creates the spanner to draw ledger lines, and notices objects that need ledger lines",
- /* creats*/ "LedgerLineSpanner",
- /* accepts */ "",
- /* acks */ "ledgered-interface", // ledgered-interface?
- /* reads */ "",
- /* write */ "")
+ "Creates the spanner to draw ledger lines, and notices objects that need ledger lines",
+ /* creats*/ "LedgerLineSpanner",
+ /* accepts */ "",
+ /* acks */ "ledgered-interface", // ledgered-interface?
+ /* reads */ "",
+ /* write */ "")
-/*
+/*
ledger-line-spanner.cc -- implement Ledger_line_spanner
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include <map>
#include <set>
#include "item.hh"
-#include "note-head.hh"
-#include "staff-symbol-referencer.hh"
-#include "staff-symbol.hh"
-#include "lookup.hh"
-#include "spanner.hh"
-#include "group-interface.hh"
+#include "note-head.hh"
+#include "staff-symbol-referencer.hh"
+#include "staff-symbol.hh"
+#include "lookup.hh"
+#include "spanner.hh"
+#include "group-interface.hh"
#include "paper-column.hh"
struct Ledger_line_spanner
{
- DECLARE_SCHEME_CALLBACK (print, (SCM ));
- DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM ));
+ DECLARE_SCHEME_CALLBACK (print, (SCM));
+ DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM));
static Stencil brew_ledger_lines (Grob *me,
int pos,
int interspaces,
Interval x_extent,
Real left_shorten);
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
};
-
Stencil
Ledger_line_spanner::brew_ledger_lines (Grob *staff,
int pos,
if (line_count)
{
Real blotdiameter = ledgerlinethickness;
- Interval y_extent =
- Interval (-0.5*(ledgerlinethickness),
- +0.5*(ledgerlinethickness));
- Stencil proto_ledger_line =
- Lookup::round_filled_box (Box (x_extent, y_extent), blotdiameter);
+ Interval y_extent
+ = Interval (-0.5* (ledgerlinethickness),
+ +0.5* (ledgerlinethickness));
+ Stencil proto_ledger_line
+ = Lookup::round_filled_box (Box (x_extent, y_extent), blotdiameter);
x_extent[LEFT] += left_shorten;
- Stencil proto_first_line =
- Lookup::round_filled_box (Box (x_extent, y_extent), blotdiameter);
+ Stencil proto_first_line
+ = Lookup::round_filled_box (Box (x_extent, y_extent), blotdiameter);
Direction dir = (Direction)sign (pos);
Real offs = (Staff_symbol_referencer::on_staffline (staff, pos))
- ? 0.0
- : -dir * halfspace;
-
+ ? 0.0
+ : -dir * halfspace;
offs += pos * halfspace;
for (int i = 0; i < line_count; i++)
- {
- Stencil ledger_line ((i == 0)
- ? proto_first_line
- : proto_ledger_line
- );
- ledger_line.translate_axis (-dir * halfspace * i * 2 + offs, Y_AXIS);
- stencil.add_stencil (ledger_line);
- }
+ {
+ Stencil ledger_line ((i == 0)
+ ? proto_first_line
+ : proto_ledger_line);
+ ledger_line.translate_axis (-dir * halfspace * i * 2 + offs, Y_AXIS);
+ stencil.add_stencil (ledger_line);
+ }
}
return stencil;
}
-
-typedef std::map<int, Drul_array<Interval> > Head_extents_map;
-typedef std::map<int, Grob*> Column_map;
+typedef std::map < int, Drul_array<Interval> > Head_extents_map;
+typedef std::map < int, Grob *> Column_map;
MAKE_SCHEME_CALLBACK (Ledger_line_spanner, set_spacing_rods, 1);
SCM
Ledger_line_spanner::set_spacing_rods (SCM smob)
{
- Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (smob));
+ Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
// find size of note heads.
- Grob * staff = Staff_symbol_referencer::get_staff_symbol (me);
+ Grob *staff = Staff_symbol_referencer::get_staff_symbol (me);
if (!staff)
return SCM_EOL;
Link_array<Grob> heads (extract_grob_array (me, ly_symbol2scm ("note-heads")));
-
+
if (heads.is_empty ())
return SCM_EOL;
-
+
Real min_length_fraction
= robust_scm2double (me->get_property ("minimum-length-fraction"), 0.15);
-
+
Head_extents_map head_extents;
Column_map columns;
-
- int interspaces = Staff_symbol::line_count (staff)-1;
- for (int i = heads.size (); i--; )
+
+ int interspaces = Staff_symbol::line_count (staff) - 1;
+ for (int i = heads.size (); i--;)
{
- Item *h = dynamic_cast<Item*> (heads[i]);
-
+ Item *h = dynamic_cast<Item *> (heads[i]);
+
int pos = Staff_symbol_referencer::get_rounded_position (h);
if (pos
&& abs (pos) > interspaces)
Direction vdir = Direction (sign (pos));
if (!vdir)
continue;
-
- Interval prev_extent;
+
+ Interval prev_extent;
Head_extents_map::iterator j = head_extents.find (rank);
if (j != head_extents.end ())
prev_extent = (*j).second[vdir];
else
columns[rank] = column;
-
+
prev_extent.unite (head_extent);
head_extents[rank][vdir] = prev_extent;
}
}
- for (Column_map::const_iterator c (columns.begin()); c != columns.end(); c++)
+ for (Column_map::const_iterator c (columns.begin ()); c != columns.end (); c++)
{
Grob *column = (*c).second;
int rank = (*c).first;
int next_rank = rank + 2;
-
+
if (head_extents.find (next_rank) != head_extents.end ())
{
- Drul_array<Interval> extents_left = head_extents[rank];
- Drul_array<Interval> extents_right = head_extents[next_rank];
+ Drul_array<Interval> extents_left = head_extents[rank];
+ Drul_array<Interval> extents_right = head_extents[next_rank];
Direction d = DOWN;
do
{
if (!extents_right[d].is_empty () && !extents_right[d].is_empty ())
{
- Real l1 = extents_right[d].length() * min_length_fraction;
- Real l2 = extents_left[d].length() * min_length_fraction;
+ Real l1 = extents_right[d].length () * min_length_fraction;
+ Real l2 = extents_left[d].length () * min_length_fraction;
Rod rod;
- rod.distance_ = l1 + l2 + (l1+ l2)/2.0
+ rod.distance_ = l1 + l2 + (l1+ l2) / 2.0
+ extents_left[d][RIGHT]
- extents_right[d][LEFT];
-
- rod.item_drul_[LEFT] = dynamic_cast<Item*> (column);
- rod.item_drul_[RIGHT] = dynamic_cast<Item*> (columns[next_rank]);
+
+ rod.item_drul_[LEFT] = dynamic_cast<Item *> (column);
+ rod.item_drul_[RIGHT] = dynamic_cast<Item *> (columns[next_rank]);
rod.add_to_cols ();
}
}
return SCM_UNSPECIFIED;
}
-
struct Ledger_request
{
Interval ledger_extent_;
Interval head_extent_;
int position_;
bool excentric_;
- Ledger_request () {
+ Ledger_request ()
+ {
ledger_extent_.set_empty ();
head_extent_.set_empty ();
position_ = 0;
}
};
-typedef std::map<int, Drul_array<Ledger_request> > Ledger_requests;
-
+typedef std::map < int, Drul_array<Ledger_request> > Ledger_requests;
/*
TODO: ledger share a lot of info. Lots of room to optimize away common
use of objects/variables.
- */
+*/
MAKE_SCHEME_CALLBACK (Ledger_line_spanner, print, 1);
SCM
Ledger_line_spanner::print (SCM smob)
{
- Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (smob));
+ Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
Link_array<Grob> heads (extract_grob_array (me, ly_symbol2scm ("note-heads")));
if (heads.is_empty ())
return SCM_EOL;
-
+
// find size of note heads.
- Grob * staff = Staff_symbol_referencer::get_staff_symbol (me);
+ Grob *staff = Staff_symbol_referencer::get_staff_symbol (me);
if (!staff)
return SCM_EOL;
-
-
+
Real length_fraction
= robust_scm2double (me->get_property ("length-fraction"), 0.25);
Stencil ledgers;
Stencil default_ledger;
- Grob * common[NO_AXES];
-
- for (int i = X_AXIS; i < NO_AXES; i++)
+ Grob *common[NO_AXES];
+
+ for (int i = X_AXIS; i < NO_AXES; i++)
{
Axis a = Axis (i);
common[a] = common_refpoint_of_array (heads, me, a);
- for (int i = heads.size (); i--; )
- if (Grob * g = unsmob_grob (me->get_property ("accidental-grob")))
+ for (int i = heads.size (); i--;)
+ if (Grob *g = unsmob_grob (me->get_property ("accidental-grob")))
common[a] = common[a]->common_refpoint (g, a);
}
- int interspaces = Staff_symbol::line_count (staff)-1;
+ int interspaces = Staff_symbol::line_count (staff) - 1;
Ledger_requests reqs;
- for (int i = heads.size (); i--; )
+ for (int i = heads.size (); i--;)
{
- Item *h = dynamic_cast<Item*> (heads[i]);
-
+ Item *h = dynamic_cast<Item *> (heads[i]);
+
int pos = Staff_symbol_referencer::get_rounded_position (h);
if (pos
&& abs (pos) > interspaces)
Direction vdir = Direction (sign (pos));
int rank = Paper_column::get_rank (h->get_column ());
-
+
reqs[rank][vdir].ledger_extent_.unite (ledger_extent);
reqs[rank][vdir].head_extent_.unite (head_extent);
- reqs[rank][vdir].position_ =
- vdir * ((vdir* reqs[rank][vdir].position_) >? (vdir *pos));
+ reqs[rank][vdir].position_
+ = vdir * ((vdir* reqs[rank][vdir].position_) >? (vdir *pos));
}
}
{
continue;
}
-
+
Direction d = DOWN;
do
{
if (abs (last->second[d].position_) > interspaces
&& abs (i->second[d].position_) > interspaces)
{
- Real center =
- (last->second[d].head_extent_[RIGHT]
- + i->second[d].head_extent_[LEFT] )/2;
+ Real center
+ = (last->second[d].head_extent_[RIGHT]
+ + i->second[d].head_extent_[LEFT]) / 2;
Direction which = LEFT;
do
Ledger_request &lr = ((which == LEFT) ? *last : *i).second[d];
// due tilt of quarter note-heads
- bool both =
- (abs (last->second[d].position_) > interspaces + 1
- && abs (i->second[d].position_) > interspaces + 1);
+ bool both
+ = (abs (last->second[d].position_) > interspaces + 1
+ && abs (i->second[d].position_) > interspaces + 1);
- Real limit = (center + (both? which * gap/2 : 0));
+ Real limit = (center + (both? which * gap / 2 : 0));
lr.ledger_extent_.elem_ref (-which)
- = which * (which * lr.ledger_extent_[-which] >? which * limit);
+ = which * (which * lr.ledger_extent_[-which] >? which * limit);
}
- while (flip (&which) != LEFT);
+ while (flip (&which) != LEFT);
}
}
- while (flip (&d) != DOWN);
+ while (flip (&d) != DOWN);
}
// create ledgers for note heads
- Real ledgerlinethickness =
- Staff_symbol::get_ledger_line_thickness (staff);
- Real halfspace = Staff_symbol::staff_space (staff)/2;
- for (int i = heads.size (); i--; )
+ Real ledgerlinethickness
+ = Staff_symbol::get_ledger_line_thickness (staff);
+ Real halfspace = Staff_symbol::staff_space (staff) / 2;
+ for (int i = heads.size (); i--;)
{
- Item *h = dynamic_cast<Item*> (heads[i]);
-
+ Item *h = dynamic_cast<Item *> (heads[i]);
+
int pos = Staff_symbol_referencer::get_rounded_position (h);
if (abs (pos) > interspaces + 1)
{
Interval ledger_size = head_size;
ledger_size.widen (ledger_size.length ()* length_fraction);
- Interval max_size = reqs[Paper_column::get_rank (h->get_column ())][Direction (sign(pos))].ledger_extent_;
+ Interval max_size = reqs[Paper_column::get_rank (h->get_column ())][Direction (sign (pos))].ledger_extent_;
ledger_size.intersect (max_size);
Real left_shorten = 0.0;
- if (Grob * g = unsmob_grob (h->get_property ("accidental-grob")))
+ if (Grob *g = unsmob_grob (h->get_property ("accidental-grob")))
{
Interval accidental_size = g->extent (common[X_AXIS], X_AXIS);
- Real d =
- linear_combination (Drul_array<Real> (accidental_size[RIGHT],
- head_size[LEFT]),
- 0.0);
+ Real d
+ = linear_combination (Drul_array<Real> (accidental_size[RIGHT],
+ head_size[LEFT]),
+ 0.0);
- left_shorten = (-ledger_size[LEFT] + d) >? 0 ;
+ left_shorten = (-ledger_size[LEFT] + d) >? 0;
/*
TODO: shorten 2 ledger lines for the case natural +
downstem.
*/
-
+
}
ledgers.add_stencil (brew_ledger_lines (staff, pos, interspaces,
ledgers.translate_axis (-me->relative_coordinate (common[X_AXIS], X_AXIS),
X_AXIS);
-
+
return ledgers.smobbed_copy ();
}
"This spanner draws the ledger lines of a staff, for note heads that stick out. ",
"note-heads thickness minimum-length-fraction length-fraction gap");
-
-struct Ledgered_interface {
- static bool has_interface (Grob*);
+struct Ledgered_interface
+{
+ static bool has_interface (Grob *);
};
ADD_INTERFACE (Ledgered_interface,
-/*
+/*
ligature-bracket-engraver.cc -- implement Ligature_bracket_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2002--2005 Juergen Reuter <reuter@ipd.uka.de>
-
- */
+*/
#include "ligature-engraver.hh"
#include "note-column.hh"
TRANSLATOR_DECLARATIONS (Ligature_bracket_engraver);
};
-
Ligature_bracket_engraver::Ligature_bracket_engraver ()
{
}
return make_spanner ("LigatureBracket", SCM_EOL);
}
-
void
Ligature_bracket_engraver::acknowledge_grob (Grob_info info)
{
if (Note_column::has_interface (info.grob_))
{
Tuplet_bracket::add_column (current_ligature (),
- dynamic_cast<Item*> (info.grob_));
+ dynamic_cast<Item *> (info.grob_));
}
else Ligature_engraver::acknowledge_grob (info);
}
}
ADD_TRANSLATOR (Ligature_bracket_engraver,
-/* descr */ "Handles Ligature_events by engraving Ligature brackets.",
-/* creats*/ "TupletBracket",
-/* accepts */ "ligature-event",
-/* acks */ "rest-interface note-column-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Handles Ligature_events by engraving Ligature brackets.",
+ /* creats*/ "TupletBracket",
+ /* accepts */ "ligature-event",
+ /* acks */ "rest-interface note-column-interface",
+ /* reads */ "",
+ /* write */ "");
-/*
+/*
ligature-engraver.cc -- implement Ligature_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2002--2005 Juergen Reuter <reuter@ipd.uka.de>
-
- */
+*/
#include "ligature-engraver.hh"
prev_start_req_ = reqs_drul_[START];
ligature_ = create_ligature_spanner ();
- brew_ligature_primitive_proc =
- ligature_->get_property ("ligature-primitive-callback");
+ brew_ligature_primitive_proc
+ = ligature_->get_property ("ligature-primitive-callback");
if (brew_ligature_primitive_proc == SCM_EOL)
{
warning ("Ligature_engraver: ligature-primitive-callback undefined");
{
primitives_.push (info);
info.grob_->set_property ("print-function",
- brew_ligature_primitive_proc);
+ brew_ligature_primitive_proc);
}
if (Rest::has_interface (info.grob_))
{
}
ADD_TRANSLATOR (Ligature_engraver,
-/* descr */ "Abstract class; a concrete subclass handles Ligature_events by engraving Ligatures in a concrete style.",
-/* creats */ "",
-/* accepts */ "ligature-event",
-/* acks */ "note-head-interface rest-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Abstract class; a concrete subclass handles Ligature_events by engraving Ligatures in a concrete style.",
+ /* creats */ "",
+ /* accepts */ "ligature-event",
+ /* acks */ "note-head-interface rest-interface",
+ /* reads */ "",
+ /* write */ "");
source file of the GNU LilyPond music typesetter
(c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#include <cstdio>
#include <cstdlib>
#include <cstring> /* strdup, strchr */
SCM
ly_write2scm (SCM s)
{
- SCM port = scm_mkstrport (SCM_INUM0,
+ SCM port = scm_mkstrport (SCM_INUM0,
scm_make_string (SCM_INUM0, SCM_UNDEFINED),
SCM_OPN | SCM_WRTNG,
"ly_write2string");
// SCM write = scm_eval_3 (ly_symbol2scm ("write"), s, SCM_EOL);
SCM write = scm_primitive_eval (ly_symbol2scm ("write"));
-
+
// scm_apply (write, port, SCM_EOL);
scm_call_2 (write, s, port);
return scm_strport_to_string (port);
{
/*
Ugh. this is not very efficient.
- */
+ */
SCM str = scm_symbol_to_string (s);
return ly_scm2string (str);
}
int n;
char *str = gulp_file (s, &n);
- String result ((Byte*) str, n);
+ String result ((Byte *) str, n);
delete[] str;
-
+
if (be_verbose_global)
progress_indication ("]");
return result;
}
-
-
extern "C" {
// maybe gdb 5.0 becomes quicker if it doesn't do fancy C++ typing?
-void
-ly_display_scm (SCM s)
-{
- scm_display (s, scm_current_output_port ());
- scm_newline (scm_current_output_port ());
-}
+ void
+ ly_display_scm (SCM s)
+ {
+ scm_display (s, scm_current_output_port ());
+ scm_newline (scm_current_output_port ());
+ }
};
String
ly_scm2string (SCM str)
{
assert (scm_is_string (str));
- return String ((Byte*)scm_i_string_chars (str),
+ return String ((Byte *)scm_i_string_chars (str),
(int) scm_i_string_length (str));
}
void initialize_kpathsea ();
}
#endif
-
+
void
ly_init_ly_module (void *)
{
- for (int i = scm_init_funcs_->size () ; i--;)
+ for (int i = scm_init_funcs_->size (); i--;)
(scm_init_funcs_->elem (i)) ();
-
+
if (be_verbose_global)
progress_indication ("\n");
initialize_kpathsea ();
}
#endif
-
+
scm_primitive_load_path (scm_makfrom0str ("lily.scm"));
}
if (scm_is_number (s))
{
int i = scm_to_int (s);
- return i>= -1 && i <= 1;
+ return i>= -1 && i <= 1;
}
return false;
}
{
SCM s = scm_cons (SCM_EOL, SCM_EOL);
scm_set_car_x (s, s);
-
+
return s;
}
appendable_list_append (SCM l, SCM elt)
{
SCM newcons = scm_cons (elt, SCM_EOL);
-
- scm_set_cdr_x (scm_car (l), newcons);
+
+ scm_set_cdr_x (scm_car (l), newcons);
scm_set_car_x (l, newcons);
}
{
int len = scm_c_vector_length (src);
SCM nv = scm_c_make_vector (len, SCM_UNDEFINED);
- for (int i = 0 ;i < len ; i++)
+ for (int i = 0;i < len; i++)
{
SCM si = scm_int2num (i);
- scm_vector_set_x (nv, si, ly_deep_copy (scm_vector_ref (src, si)));
+ scm_vector_set_x (nv, si, ly_deep_copy (scm_vector_ref (src, si)));
}
}
return src;
Returns first match found, i.e.
alist = ((1 . 10)
- ((1 . 2) . 11)
- ((2 . 1) . 12)
- ((3 . 0) . 13)
- ((4 . 1) . 14) )
-
-I would like (ly_assoc_cdr 1) to return 12 - because it's the first
-element with the cdr of the key = 1. In other words (alloc_cdr key)
-corresponds to call
-
-(alloc (anything . key))
-
+ ((1 . 2) . 11)
+ ((2 . 1) . 12)
+ ((3 . 0) . 13)
+ ((4 . 1) . 14) )
+ I would like (ly_assoc_cdr 1) to return 12 - because it's the first
+ element with the cdr of the key = 1. In other words (alloc_cdr key)
+ corresponds to call
+ (alloc (anything . key))
*/
SCM
ly_assoc_cdr (SCM key, SCM alist)
char *orig = s;
SCM create_list = SCM_EOL;
- char * e = s + strlen (s) - 1;
+ char *e = s + strlen (s) - 1;
while (e >= s && isspace (*e))
*e-- = 0;
- for (char * p = s; *p; p++)
+ for (char *p = s; *p; p++)
if (*p == '\n')
*p = ' ';
realval = realval.left_string (100)
+ "\n :\n :\n"
+ realval.right_string (100);
- return realval;
+ return realval;
}
bool
-type_check_assignment (SCM sym, SCM val, SCM type_symbol)
+type_check_assignment (SCM sym, SCM val, SCM type_symbol)
{
bool ok = true;
TODO: should remove #f from allowed vals?
- */
+ */
if (val == SCM_EOL || val == SCM_BOOL_F)
return ok;
TODO: deprecate the use of \override and \revert for
autoBeamSettings?
- or use a symbol autoBeamSettingS?
- */
- return true;
+ or use a symbol autoBeamSettingS?
+ */
+ return true;
#endif
-
+
SCM type = scm_object_property (sym, type_symbol);
if (type != SCM_EOL && !ly_c_procedure_p (type))
- {
- warning (_f ("Can't find property type-check for `%s' (%s).",
- ly_symbol2string (sym).to_str0 (),
- ly_symbol2string (type_symbol).to_str0 ())
- + " " + _ ("Perhaps you made a typing error?"));
-
- /* Be strict when being anal :) */
- if (do_internal_type_checking_global)
- abort ();
-
- warning (_ ("Doing assignment anyway."));
- }
+ {
+ warning (_f ("Can't find property type-check for `%s' (%s).",
+ ly_symbol2string (sym).to_str0 (),
+ ly_symbol2string (type_symbol).to_str0 ())
+ + " " + _ ("Perhaps you made a typing error?"));
+
+ /* Be strict when being anal :) */
+ if (do_internal_type_checking_global)
+ abort ();
+
+ warning (_ ("Doing assignment anyway."));
+ }
else
{
if (val != SCM_EOL
SCM typefunc = ly_lily_module_constant ("type-name");
SCM type_name = scm_call_1 (typefunc, type);
-
scm_puts (_f ("Type check for `%s' failed; value `%s' must be of type `%s'",
ly_symbol2string (sym).to_str0 (),
print_scm_val (val),
ly_scm2string (type_name).to_str0 ()).to_str0 (),
errport);
- scm_puts ("\n", errport);
+ scm_puts ("\n", errport);
}
}
return ok;
}
-
/* some SCM abbrevs
- zijn deze nou handig?
- zijn ze er al in scheme, maar heten ze anders? */
-
+zijn deze nou handig?
+zijn ze er al in scheme, maar heten ze anders? */
/* Remove doubles from (sorted) list */
SCM
return scm_reverse_x (unique, SCM_EOL);
}
-
static int
scm_default_compare (void const *a, void const *b)
{
- SCM pa = *(SCM*) a;
- SCM pb = *(SCM*) b;
+ SCM pa = *(SCM *) a;
+ SCM pb = *(SCM *) b;
if (pa == pb)
return 0;
return pa < pb ? -1 : 1;
*tail = SCM_EOL;
delete[] arr;
- return lst;
+ return lst;
}
-
/* tail add */
SCM
ly_snoc (SCM s, SCM list)
break;
before = scm_cons (i, before);
}
- return scm_cons ( scm_reverse_x (before, SCM_EOL), after);
-
-}
+ return scm_cons (scm_reverse_x (before, SCM_EOL), after);
+}
void
taint (SCM *)
{
/*
nop.
- */
+ */
}
/*
display stuff without using stack
- */
+*/
SCM
display_list (SCM s)
{
for (; scm_is_pair (s); s = scm_cdr (s))
{
scm_display (scm_car (s), p);
- scm_puts (" ", p);
+ scm_puts (" ", p);
}
scm_puts (")", p);
return SCM_UNSPECIFIED;
s.set_empty ();
for (; scm_is_pair (l); l = scm_cdr (l))
if (scm_is_number (scm_car (l)))
- s.add_point (scm_to_int (scm_car (l)));
+ s.add_point (scm_to_int (scm_car (l)));
return s;
}
/* Return I-th element, or last elt L. If I < 0, then we take the first
element.
-
+
PRE: length (L) > 0 */
SCM
robust_list_ref (int i, SCM l)
int i = scm_ilength (alist);
if (i < 0)
return scm_c_make_hash_table (0);
-
+
SCM tab = scm_c_make_hash_table (i);
for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s))
{
SCM pt = scm_cdar (s);
scm_hashq_set_x (tab, scm_caar (s), pt);
}
- return tab;
+ return tab;
}
-
bool
alist_equal_p (SCM a, SCM b)
{
SCM l = scm_assoc (key, b);
if (l == SCM_BOOL_F
- || !ly_c_equal_p ( scm_cdr (l), val))
+ || !ly_c_equal_p (scm_cdr (l), val))
return false;
}
return true;
}
-
-
SCM
ly_alist_vals (SCM alist)
{
return scm_call_1 (func, tab);
}
-
-
#include "main.hh"
#include "moment.hh"
-static Keyword_ent the_key_tab[] = {
+static Keyword_ent the_key_tab[]
+= {
{"accepts", ACCEPTS},
{"addquote", ADDQUOTE},
{"addlyrics", ADDLYRICS},
{0, 0}
};
-
Lily_lexer::Lily_lexer (Sources *sources)
{
keytable_ = new Keyword_table (the_key_tab);
chordmodifier_tab_ = SCM_EOL;
- pitchname_tab_stack_ = SCM_EOL;
+ pitchname_tab_stack_ = SCM_EOL;
sources_ = sources;
scopes_ = SCM_EOL;
- error_level_ = 0;
+ error_level_ = 0;
is_main_input_ = false;
smobify_self ();
-
+
add_scope (ly_make_anonymous_module (false));
push_note_state (scm_c_make_hash_table (0));
chordmodifier_tab_ = scm_make_vector (scm_int2num (1), SCM_EOL);
chordmodifier_tab_ = src.chordmodifier_tab_;
pitchname_tab_stack_ = src.pitchname_tab_stack_;
sources_ = src.sources_;
-
- error_level_ = src.error_level_;
+
+ error_level_ = src.error_level_;
is_main_input_ = src.is_main_input_;
scopes_ = SCM_EOL;
-
+
smobify_self ();
-
+
SCM scopes = SCM_EOL;
SCM *tail = &scopes;
for (SCM s = src.scopes_; scm_is_pair (s); s = scm_cdr (s))
*tail = scm_cons (newmod, SCM_EOL);
tail = SCM_CDRLOC (*tail);
}
-
- scopes_ = scopes;
+
+ scopes_ = scopes;
push_note_state (scm_c_make_hash_table (0));
}
return sc;
}
-
int
Lily_lexer::lookup_keyword (String s)
{
{
// yy_flex_debug = 1;
new_input (main_input_name_, sources_);
-
+
/* Do not allow \include in --safe-mode */
allow_includes_b_ = allow_includes_b_ && !be_safe_global;
{
SCM sym = name;
if (scm_is_string (name))
- sym = scm_string_to_symbol (name);
-
+ sym = scm_string_to_symbol (name);
+
if (scm_is_symbol (sym))
{
if (lookup_keyword (ly_symbol2string (sym)) >= 0)
{
- String symstr = ly_symbol2string (sym);
- warning (_f ("Identifier name is a keyword: `%s'", symstr.to_str0()));
+ String symstr = ly_symbol2string (sym);
+ warning (_f ("Identifier name is a keyword: `%s'", symstr.to_str0 ()));
}
SCM mod = scm_car (scopes_);
}
/**
- Since we don't create the buffer state from the bytes directly, we
- don't know about the location of the lexer. Add this as a
- YY_USER_ACTION */
+ Since we don't create the buffer state from the bytes directly, we
+ don't know about the location of the lexer. Add this as a
+ YY_USER_ACTION */
void
Lily_lexer::add_lexed_char (int count)
{
char_count_stack_.top () += count;
}
-
#include "ly-smobs.icc"
IMPLEMENT_SMOBS (Lily_lexer);
SCM
Lily_lexer::mark_smob (SCM s)
{
- Lily_lexer *lexer = (Lily_lexer*) SCM_CELL_WORD_1 (s);
+ Lily_lexer *lexer = (Lily_lexer *) SCM_CELL_WORD_1 (s);
scm_gc_mark (lexer->chordmodifier_tab_);
scm_gc_mark (lexer->pitchname_tab_stack_);
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "file-name.hh"
#include "lily-parser.hh"
#include "warn.hh"
#include "source.hh"
-#include "lily-lexer.hh"
+#include "lily-lexer.hh"
#include "score.hh"
#include "lilypond-key.hh"
#include "ly-module.hh"
File_name out_file_name (file_name);
global_path.append (out_file_name.dir_);
-
+
out_file_name.ext_ = "";
out_file_name.root_ = "";
out_file_name.dir_ = "";
if (!output_name_global.is_empty ())
out_file_name = File_name (output_name_global);
-
+
String init;
if (!init_name_global.is_empty ())
init = init_name_global;
{
Sources sources;
sources.set_path (&global_path);
-
+
progress_indication (_f ("Processing `%s'", file_name.to_str0 ()));
progress_indication ("\n");
"Upon failure, throw @code{ly-file-failed} key.")
{
SCM_ASSERT_TYPE (scm_is_string (ly_code), ly_code, SCM_ARG1, __FUNCTION__, "string");
-
+
Sources sources;
sources.set_path (&global_path);
Lily_parser *parser = new Lily_parser (&sources);
parser->parse_string (ly_scm2string (ly_code));
scm_gc_unprotect_object (parser->self_scm ());
parser = 0;
-
+
return SCM_UNSPECIFIED;
}
LY_DEFINE (ly_clone_parser, "ly:clone-parser",
- 1, 0, 0, (SCM parser_smob),
- "Return a clone of PARSER_SMOB.")
+ 1, 0, 0, (SCM parser_smob),
+ "Return a clone of PARSER_SMOB.")
{
Lily_parser *parser = unsmob_my_lily_parser (parser_smob);
Lily_parser *clone = new Lily_parser (*parser);
{
Lily_parser *parser = unsmob_my_lily_parser (parser_smob);
SCM_ASSERT_TYPE (scm_is_symbol (symbol), symbol, SCM_ARG2, __FUNCTION__, "symbol");
- SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser");
+ SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser");
parser->lexer_->set_identifier (scm_symbol_to_string (symbol), val);
return SCM_UNSPECIFIED;
Lily_parser *parser = unsmob_my_lily_parser (parser_smob);
SCM_ASSERT_TYPE (scm_is_symbol (symbol), symbol, SCM_ARG2, __FUNCTION__, "symbol");
- SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser");
+ SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser");
SCM val = parser->lexer_->lookup_identifier (ly_scm2string (scm_symbol_to_string (symbol)));
if (val != SCM_UNDEFINED)
SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "parser");
SCM_ASSERT_TYPE (scm_is_string (ly_code), ly_code, SCM_ARG2, __FUNCTION__, "string");
-
+
parser->parse_string (ly_scm2string (ly_code));
-
+
return SCM_UNSPECIFIED;
}
Lily_parser *parser = unsmob_my_lily_parser (parser_smob);
Score *score = unsmob_score (score_smob);
- Object_key * key = new Lilypond_general_key (0, score->user_key_, 0);
-
+ Object_key *key = new Lilypond_general_key (0, score->user_key_, 0);
+
if (score->error_found_)
return SCM_UNSPECIFIED;
-
+
SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "parser");
SCM_ASSERT_TYPE (score, score_smob, SCM_ARG2, __FUNCTION__, "score");
SCM header = ly_c_module_p (score->header_) ? score->header_
: parser->lexer_->lookup_identifier ("$globalheader");
-
+
File_name outname (parser->output_basename_);
int *c = &parser->book_count_;
if (*c)
if (score->defs_.is_empty ())
{
Output_def *layout = get_layout (parser);
- default_rendering (score->get_music(), layout->self_scm (),
+ default_rendering (score->get_music (), layout->self_scm (),
get_paper (parser)->self_scm (),
header, os, key->self_scm ());
scm_gc_unprotect_object (layout->self_scm ());
return SCM_UNSPECIFIED;
}
-
-
LY_DEFINE (ly_parser_set_note_names, "ly:parser-set-note-names",
2, 0, 0, (SCM parser, SCM names),
"Replace current note names in @var{parser}. "
"This only has effect if the current mode is notes.")
{
Lily_parser *p = unsmob_my_lily_parser (parser);
- SCM_ASSERT_TYPE(p, parser, SCM_ARG1, __FUNCTION__, "Lilypond parser");
+ SCM_ASSERT_TYPE (p, parser, SCM_ARG1, __FUNCTION__, "Lilypond parser");
if (p->lexer_->is_note_state ())
{
Lily_parser *parser = unsmob_my_lily_parser (parser_smob);
Book *book = unsmob_book (book_smob);
Output_def *bp = unsmob_output_def (parser->lexer_->lookup_identifier ("$defaultpaper"));
-
+
SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "Lilypond parser");
SCM_ASSERT_TYPE (book, book_smob, SCM_ARG2, __FUNCTION__, "Book");
-
+
/* ugh. changing argument.*/
book->paper_ = bp;
-
+
File_name outname (parser->output_basename_);
int *c = &parser->book_count_;
if (*c)
(*c)++;
Output_def *layout = get_layout (parser);
- Paper_book* pb = book->process (outname.to_string (), layout);
-
+ Paper_book *pb = book->process (outname.to_string (), layout);
+
if (pb)
{
pb->output (outname.to_string ());
source file of the GNU LilyPond music typesetter
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
+ Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "lily-parser.hh"
SCM
Lily_parser::mark_smob (SCM s)
{
- Lily_parser *parser = (Lily_parser*) SCM_CELL_WORD_1 (s);
+ Lily_parser *parser = (Lily_parser *) SCM_CELL_WORD_1 (s);
return (parser->lexer_) ? parser->lexer_->self_scm () : SCM_EOL;
}
Lily_parser::print_smob (SCM s, SCM port, scm_print_state*)
{
scm_puts ("#<my_lily_parser ", port);
- Lily_parser *parser = (Lily_parser*) SCM_CELL_WORD_1 (s);
+ Lily_parser *parser = (Lily_parser *) SCM_CELL_WORD_1 (s);
(void) parser;
scm_puts (" >", port);
return 1;
}
-
/* Process one .ly file, or book. */
void
Lily_parser::parse_file (String init, String name, String out_name)
{
if (output_backend_global == "tex")
{
- try_load_text_metrics (out_name);
+ try_load_text_metrics (out_name);
}
-
+
lexer_ = new Lily_lexer (sources_);
scm_gc_unprotect_object (lexer_->self_scm ());
// TODO: use $parser
lexer_->set_identifier (ly_symbol2scm ("parser"),
self_scm ());
output_basename_ = out_name;
-
+
lexer_->main_input_name_ = name;
progress_indication (_ ("Parsing..."));
void
Lily_parser::parse_string (String ly_code)
{
- Lily_lexer * parent = lexer_;
+ Lily_lexer *parent = lexer_;
lexer_ = (parent == 0 ? new Lily_lexer (sources_)
: new Lily_lexer (*parent));
scm_gc_unprotect_object (lexer_->self_scm ());
-
SCM oldmod = scm_current_module ();
scm_set_current_module (scm_car (lexer_->scopes_));
-
+
// TODO: use $parser
lexer_->set_identifier (ly_symbol2scm ("parser"),
self_scm ());
-
+
lexer_->main_input_name_ = "<string>";
lexer_->is_main_input_ = true;
set_yydebug (0);
lexer_->new_input (lexer_->main_input_name_, ly_code, sources_);
do_yyparse ();
-
+
if (!define_spots_.is_empty ())
{
- if (define_spots_.is_empty()
- && !error_level_ )
+ if (define_spots_.is_empty ()
+ && !error_level_)
programming_error ("define_spots_ don't match, but error_level_ not set.");
}
}
void
-Lily_parser::parser_error (Input const& i, String s)
+Lily_parser::parser_error (Input const &i, String s)
{
i.error (s);
error_level_ = 1;
/****************************************************************/
-
-Output_def*
+Output_def *
get_layout (Lily_parser *parser)
{
SCM id = parser->lexer_->lookup_identifier ("$defaultlayout");
return layout;
}
-
-Output_def*
+Output_def *
get_midi (Lily_parser *parser)
{
SCM id = parser->lexer_->lookup_identifier ("$defaultmidi");
return layout;
}
-
-Output_def*
+Output_def *
get_paper (Lily_parser *parser)
{
SCM id = parser->lexer_->lookup_identifier ("$defaultpaper");
Output_def *layout = unsmob_output_def (id);
- layout = layout ? dynamic_cast<Output_def*> (layout->clone ()) : new Output_def;
+ layout = layout ? dynamic_cast<Output_def *> (layout->clone ()) : new Output_def;
layout->set_variable (ly_symbol2scm ("is-paper"), SCM_BOOL_T);
return layout;
}
String
version_string ()
{
- String str = MAJOR_VERSION "." MINOR_VERSION "." PATCH_LEVEL;
+ String str = MAJOR_VERSION "." MINOR_VERSION "." PATCH_LEVEL;
String mpl ("." MY_PATCH_LEVEL);
if (mpl != ".")
str += mpl;
return str;
}
-String
+String
gnu_lilypond_string ()
{
String str = "GNU LilyPond";
return str;
}
-String
+String
gnu_lilypond_version_string ()
{
String str = gnu_lilypond_string () + " " + version_string ();
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "lilypond-key.hh"
// todo: reverse order of comparison for efficiency reasons.
int
-Lilypond_grob_key::do_compare (Object_key const* key) const
+Lilypond_grob_key::do_compare (Object_key const *key) const
{
- Lilypond_grob_key const * other = dynamic_cast<Lilypond_grob_key const*> (key);
+ Lilypond_grob_key const *other = dynamic_cast < Lilypond_grob_key const *> (key);
int c;
c = context_->compare (other->context_);
if (c)
return c;
-
+
c = Moment::compare (creation_moment_, other->creation_moment_);
if (c)
return c;
if (c)
return c;
- c = sign (disambiguation_count_ - other->disambiguation_count_);
+ c = sign (disambiguation_count_ - other->disambiguation_count_);
if (c)
return c;
-
+
return 0;
}
-
int
Lilypond_grob_key::get_type () const
{
return GROB_KEY;
}
-
SCM
Lilypond_grob_key::as_scheme () const
{
- return scm_list_4 (context_ ? context_->self_scm() : SCM_BOOL_F,
- creation_moment_.smobbed_copy(),
- scm_makfrom0str (grob_name_.to_str0()),
- scm_from_int (disambiguation_count_));
+ return scm_list_4 (context_ ? context_->self_scm () : SCM_BOOL_F,
+ creation_moment_.smobbed_copy (),
+ scm_makfrom0str (grob_name_.to_str0 ()),
+ scm_from_int (disambiguation_count_));
}
-
Object_key *
-Lilypond_grob_key::from_scheme (SCM a)
+Lilypond_grob_key::from_scheme (SCM a)
{
return new Lilypond_grob_key (unsmob_key (scm_car (a)),
*unsmob_moment (scm_cadr (a)),
- ly_scm2string (scm_caddr (a)),
- scm_to_int (scm_list_ref (a, scm_from_int (3))));
+ ly_scm2string (scm_caddr (a)),
+ scm_to_int (scm_list_ref (a, scm_from_int (3))));
}
-
/****************************************************************/
void
id_ = id;
}
-
int
Lilypond_context_key::do_compare (Object_key const *key) const
{
- Lilypond_context_key const * other
- = dynamic_cast<Lilypond_context_key const*> (key);
+ Lilypond_context_key const *other
+ = dynamic_cast < Lilypond_context_key const *> (key);
int c;
if (parent_context_ && other->parent_context_)
return c;
}
else if (parent_context_)
- return -1 ;
+ return -1;
else if (other->parent_context_)
return 1;
-
-
+
c = Moment::compare (start_moment_, other->start_moment_);
if (c)
return c;
c = sign (disambiguation_count_ - other->disambiguation_count_);
if (c)
return c;
-
+
return 0;
}
return CONTEXT_KEY;
}
-
SCM
Lilypond_context_key::as_scheme () const
{
- return scm_list_5 (parent_context_ ? parent_context_->self_scm() : SCM_BOOL_F,
- start_moment_.smobbed_copy(),
- scm_makfrom0str (context_name_.to_str0()),
- scm_makfrom0str (id_.to_str0()),
- scm_from_int (disambiguation_count_));
+ return scm_list_5 (parent_context_ ? parent_context_->self_scm () : SCM_BOOL_F,
+ start_moment_.smobbed_copy (),
+ scm_makfrom0str (context_name_.to_str0 ()),
+ scm_makfrom0str (id_.to_str0 ()),
+ scm_from_int (disambiguation_count_));
}
Object_key *
-Lilypond_context_key::from_scheme (SCM a)
+Lilypond_context_key::from_scheme (SCM a)
{
return new Lilypond_context_key (unsmob_key (scm_car (a)),
*unsmob_moment (scm_cadr (a)),
- ly_scm2string (scm_list_ref (a, scm_from_int (2))),
- ly_scm2string (scm_list_ref (a, scm_from_int (3))),
- scm_to_int (scm_list_ref (a, scm_from_int (4))));
+ ly_scm2string (scm_list_ref (a, scm_from_int (2))),
+ ly_scm2string (scm_list_ref (a, scm_from_int (3))),
+ scm_to_int (scm_list_ref (a, scm_from_int (4))));
}
-
/****************************************************************/
int
scm_gc_mark (parent_->self_scm ());
}
-Lilypond_general_key::Lilypond_general_key (Object_key const*parent,
+Lilypond_general_key::Lilypond_general_key (Object_key const *parent,
String name,
int count)
{
parent_ = parent;
name_ = name;
- disambiguation_count_ = count;
+ disambiguation_count_ = count;
}
-
int
-Lilypond_general_key::do_compare (Object_key const* key)const
+Lilypond_general_key::do_compare (Object_key const *key)const
{
- Lilypond_general_key const* other
- = dynamic_cast<Lilypond_general_key const*> (key);
+ Lilypond_general_key const *other
+ = dynamic_cast < Lilypond_general_key const *> (key);
if (parent_ && other->parent_)
parent_->compare (other->parent_);
else if (parent_)
- return -1 ;
+ return -1;
else if (other->parent_)
return 1;
if (c)
return c;
- return 0;
+ return 0;
}
SCM
Lilypond_general_key::as_scheme () const
{
- return scm_list_3 (parent_ ? parent_->self_scm() : SCM_BOOL_F,
- scm_makfrom0str (name_.to_str0()),
- scm_from_int (disambiguation_count_));
+ return scm_list_3 (parent_ ? parent_->self_scm () : SCM_BOOL_F,
+ scm_makfrom0str (name_.to_str0 ()),
+ scm_from_int (disambiguation_count_));
}
Object_key *
-Lilypond_general_key::from_scheme (SCM a)
+Lilypond_general_key::from_scheme (SCM a)
{
return new Lilypond_general_key (unsmob_key (scm_car (a)),
- ly_scm2string (scm_list_ref (a, scm_from_int (1))),
- scm_to_int (scm_list_ref (a, scm_from_int (2))));
+ ly_scm2string (scm_list_ref (a, scm_from_int (1))),
+ scm_to_int (scm_list_ref (a, scm_from_int (2))));
}
source file of the GNU LilyPond music typesetter
(c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
-
*/
#include "lilypond-input-version.hh"
Lilypond_version::operator int () const
{
- // ugh
+ // ugh
return 100000 * major_ + 1000 * minor_ + patch_;
}
-/*
-line-interface.cc -- implement Line_interface
+/*
+ line-interface.cc -- implement Line_interface
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
- */
+ (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+*/
#include "line-interface.hh"
Stencil
Line_interface::make_dashed_line (Real thick, Offset from, Offset to,
- Real dash_period, Real dash_fraction)
+ Real dash_period, Real dash_fraction)
{
dash_fraction = (dash_fraction >? 0) <? 1.0;
- Real on = dash_fraction * dash_period + thick;
+ Real on = dash_fraction * dash_period + thick;
Real off = dash_period - on;
-
+
SCM at = scm_list_n (ly_symbol2scm ("dashed-line"),
- scm_make_real (thick),
- scm_make_real (on),
- scm_make_real (off),
- scm_make_real (to[X_AXIS] - from[X_AXIS]),
- scm_make_real (to[Y_AXIS] - from[Y_AXIS]),
- SCM_UNDEFINED);
-
+ scm_make_real (thick),
+ scm_make_real (on),
+ scm_make_real (off),
+ scm_make_real (to[X_AXIS] - from[X_AXIS]),
+ scm_make_real (to[Y_AXIS] - from[Y_AXIS]),
+ SCM_UNDEFINED);
+
Box box;
box.add_point (Offset (0, 0));
box.add_point (to - from);
- box[X_AXIS].widen (thick/2);
- box[Y_AXIS].widen (thick/2);
+ box[X_AXIS].widen (thick / 2);
+ box[Y_AXIS].widen (thick / 2);
Stencil m = Stencil (box, at);
m.translate (from);
Line_interface::make_line (Real th, Offset from, Offset to)
{
SCM at = scm_list_n (ly_symbol2scm ("draw-line"),
- scm_make_real (th),
- scm_make_real (from[X_AXIS]),
- scm_make_real (from[Y_AXIS]),
- scm_make_real (to[X_AXIS]),
- scm_make_real (to[Y_AXIS]),
- SCM_UNDEFINED);
+ scm_make_real (th),
+ scm_make_real (from[X_AXIS]),
+ scm_make_real (from[Y_AXIS]),
+ scm_make_real (to[X_AXIS]),
+ scm_make_real (to[Y_AXIS]),
+ SCM_UNDEFINED);
Box box;
box.add_point (from);
box.add_point (to);
- box[X_AXIS].widen (th/2);
- box[Y_AXIS].widen (th/2);
+ box[X_AXIS].widen (th / 2);
+ box[Y_AXIS].widen (th / 2);
return Stencil (box, at);
}
{
Real thick = Staff_symbol_referencer::line_thickness (me)
* robust_scm2double (me->get_property ("thickness"), 1);
-
+
SCM type = me->get_property ("style");
SCM dash_fraction = me->get_property ("dash-fraction");
if (scm_is_number (dash_fraction) || type == ly_symbol2scm ("dotted-line"))
{
-
+
Real fraction
= type == ly_symbol2scm ("dotted-line")
? 0.0
: robust_scm2double (dash_fraction, 0.4);
-
+
fraction = (fraction >? 0) <? 1.0;
Real period = Staff_symbol_referencer::staff_space (me)
* robust_scm2double (me->get_property ("dash-period"), 1.0);
if (period < 0)
return Stencil ();
-
+
return make_dashed_line (thick, from, to, period, fraction);
}
else
}
ADD_INTERFACE (Line_interface, "line-interface",
- "Generic line objects. Any object using lines supports this. Normally, "
- "you get a straight line. If @code{dash-period} is defined, a dashed line is "
- "produced; the length of the dashes is tuned with "
- "@code{dash-fraction}. If the latter is set to 0, a dotted line is "
- "produced. If @code{dash-fraction} is negative, the line is made "
- "transparent.",
-
- "dash-period dash-fraction thickness style")
+ "Generic line objects. Any object using lines supports this. Normally, "
+ "you get a straight line. If @code{dash-period} is defined, a dashed line is "
+ "produced; the length of the dashes is tuned with "
+ "@code{dash-fraction}. If the latter is set to 0, a dotted line is "
+ "produced. If @code{dash-fraction} is negative, the line is made "
+ "transparent.",
+
+ "dash-period dash-fraction thickness style")
#include "line-interface.hh"
Stencil
-zigzag_stencil (Grob *me,
- Offset from,
- Offset to)
+zigzag_stencil (Grob *me,
+ Offset from,
+ Offset to)
{
Offset dz = to -from;
Real dx = dz[X_AXIS];
Real thick = Staff_symbol_referencer::line_thickness (me);
thick *= robust_scm2double (me->get_property ("thickness"), 1.0); // todo: staff sym referencer?
-
+
Real staff_space = Staff_symbol_referencer::staff_space (me);
double w = robust_scm2double (me->get_property ("zigzag-width"), 1)*staff_space;
- double l = robust_scm2double ( me->get_property ("zigzag-length"), 1)* w;
- double h = l>w/2 ? sqrt (l*l-w*w/4) : 0;
-
+ double l = robust_scm2double (me->get_property ("zigzag-length"), 1)* w;
+ double h = l > w / 2 ? sqrt (l*l - w*w / 4) : 0;
+
SCM list = scm_list_n (ly_symbol2scm ("zigzag-line"),
- ly_bool2scm (true),
- scm_make_real (w),
- scm_make_real (h),
- scm_make_real (thick),
- scm_make_real (dx),
- scm_make_real (dy),
- SCM_UNDEFINED);
+ ly_bool2scm (true),
+ scm_make_real (w),
+ scm_make_real (h),
+ scm_make_real (thick),
+ scm_make_real (dx),
+ scm_make_real (dy),
+ SCM_UNDEFINED);
Box b;
b.add_point (Offset (0, 0));
b.add_point (dz);
- b[X_AXIS].widen (thick/2);
- b[Y_AXIS].widen (thick/2);
-
+ b[X_AXIS].widen (thick / 2);
+ b[Y_AXIS].widen (thick / 2);
+
return Stencil (b, list);
}
MAKE_SCHEME_CALLBACK (Line_spanner, after_line_breaking, 1);
SCM
-Line_spanner::after_line_breaking (SCM g)
+Line_spanner::after_line_breaking (SCM g)
{
- Grob *me = unsmob_grob (g);
- Spanner*sp = dynamic_cast<Spanner*> (me);
+ Grob *me = unsmob_grob (g);
+ Spanner *sp = dynamic_cast<Spanner *> (me);
/*
We remove the line at the start of the line. For piano voice
space left of a note at the start of a line is very small.
--hwn.
-
- */
+
+ */
if (sp->get_bound (LEFT)->break_status_dir ()
&& !sp->get_bound (RIGHT)->break_status_dir ())
{
/*
Can't do suicide, since this mucks up finding the trend.
- */
+ */
me->set_property ("print-function", SCM_EOL);
-
+
}
return SCM_EOL;
}
-
Stencil
-Line_spanner::line_stencil (Grob *me,
- Offset from,
- Offset to)
+Line_spanner::line_stencil (Grob *me,
+ Offset from,
+ Offset to)
{
- Offset dz = to -from ;
+ Offset dz = to -from;
SCM type = me->get_property ("style");
if (scm_is_symbol (type)
&& (type == ly_symbol2scm ("line")
|| type == ly_symbol2scm ("dashed-line")
|| type == ly_symbol2scm ("dotted-line")
- || type == ly_symbol2scm ("zigzag")
+ || type == ly_symbol2scm ("zigzag")
|| (type == ly_symbol2scm ("trill") && dz[Y_AXIS] != 0)))
{
- return (type == ly_symbol2scm ("zigzag"))
+ return (type == ly_symbol2scm ("zigzag"))
? zigzag_stencil (me, from, to)
: Line_interface::line (me, from, to);
}
{
SCM alist_chain = Font_interface::text_font_alist_chain (me);
SCM style_alist = scm_list_n (scm_cons (ly_symbol2scm ("font-encoding"),
- ly_symbol2scm ("fetaMusic")),
+ ly_symbol2scm ("fetaMusic")),
SCM_UNDEFINED);
-
+
Font_metric *fm = select_font (me->get_layout (),
scm_cons (style_alist,
- alist_chain));
+ alist_chain));
Stencil m = fm->find_by_name ("scripts.trill_element");
Stencil mol;
/*
FIXME: should center element on x/y
- */
+ */
mol.translate_axis (m.extent (X_AXIS).length () / 2, X_AXIS);
- mol.translate_axis (-(mol.extent (Y_AXIS)[DOWN]
- + mol.extent (Y_AXIS).length ())/2, Y_AXIS);
+ mol.translate_axis (- (mol.extent (Y_AXIS)[DOWN]
+ + mol.extent (Y_AXIS).length ()) / 2, Y_AXIS);
mol.translate (from);
return mol;
/*
Find a common Y parent, which --if found-- should be the
fixed-distance alignment.
- */
+*/
Grob *
line_spanner_common_parent (Grob *me)
{
- Grob * common = find_fixed_alignment_parent (me);
+ Grob *common = find_fixed_alignment_parent (me);
if (!common)
{
common = Staff_symbol_referencer::get_staff_symbol (me);
/*
Warning: this thing is a cross-staff object, so it should have empty Y-dimensions.
- (If not, you risk that this is called from the staff-alignment
+ (If not, you risk that this is called from the staff-alignment
routine, via stencil_extent. At this point, the staves aren't
separated yet, so it doesn't work cross-staff.
(huh? crossable staves have fixed distance? --hwn)
-
*/
-
-
MAKE_SCHEME_CALLBACK (Line_spanner, print, 1);
SCM
-Line_spanner::print (SCM smob)
+Line_spanner::print (SCM smob)
{
- Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (smob));
+ Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
- Drul_array<Item*> bound (me->get_bound (LEFT),
+ Drul_array<Item *> bound (me->get_bound (LEFT),
me->get_bound (RIGHT));
-
-
+
Real gap = robust_scm2double (me->get_property ("gap"), 0.0);
Offset ofxy (gap, 0); /*offset from start point to start of line*/
- Offset dxy ;
+ Offset dxy;
Offset my_off;
Offset his_off;
-
if (bound[RIGHT]->break_status_dir ())
{
heads are on different systems, there is no common parent
anymore. We have to find the piano-staff object.
*/
-
+
int k = broken_spanner_index (me);
- Spanner *parent_sp = dynamic_cast<Spanner*> (me->original_);
- Spanner *next_sp = parent_sp->broken_intos_ [k+1];
+ Spanner *parent_sp = dynamic_cast<Spanner *> (me->original_);
+ Spanner *next_sp = parent_sp->broken_intos_ [k + 1];
Item *next_bound = next_sp->get_bound (RIGHT);
if (next_bound->break_status_dir ())
me->suicide ();
return SCM_EOL;
}
-
+
Grob *commonx = bound[LEFT]->common_refpoint (bound[RIGHT], X_AXIS);
commonx = me->common_refpoint (commonx, X_AXIS);
-
+
Grob *next_common_y = line_spanner_common_parent (next_bound);
Grob *this_common_y = line_spanner_common_parent (bound[LEFT]);
Grob *all_common_y = me->common_refpoint (this_common_y, Y_AXIS);
-
- Interval next_ext = next_bound->extent (next_common_y, Y_AXIS);
- Interval this_ext = bound[LEFT]->extent (this_common_y, Y_AXIS);
+
+ Interval next_ext = next_bound->extent (next_common_y, Y_AXIS);
+ Interval this_ext = bound[LEFT]->extent (this_common_y, Y_AXIS);
Real yoff = this_common_y->relative_coordinate (all_common_y, Y_AXIS);
-
+
Offset p1 (bound[LEFT]->extent (commonx, X_AXIS)[RIGHT],
- this_ext.center () + yoff);
+ this_ext.center () + yoff);
Offset p2 (bound[RIGHT]->extent (commonx, X_AXIS)[LEFT],
next_ext.center () + yoff);
-
+
Offset dz (p2 -p1);
Real len = dz.length ();
- Offset dir = dz *(1/ len);
+ Offset dir = dz * (1/ len);
dz = (dz.length () - 2*gap) *dir;
-
-
+
Stencil l (line_stencil (me, Offset (0, 0), dz));
- l.translate (dir * gap + p1
+ l.translate (dir * gap + p1
- Offset (me->relative_coordinate (commonx, X_AXIS),
me->relative_coordinate (all_common_y, Y_AXIS)));
- return l.smobbed_copy ();
+ return l.smobbed_copy ();
}
else
{
Grob *common[] = { me, me };
- for (int a = X_AXIS; a < NO_AXES; a++)
+ for (int a = X_AXIS; a < NO_AXES; a++)
{
common[a] = me->common_refpoint (bound[RIGHT], Axis (a));
common[a] = common[a]->common_refpoint (bound[LEFT], Axis (a));
}
// distance from center to start of line
- Real off = gap + ((bound[LEFT]->extent (bound[LEFT], X_AXIS).length ()*3)/4);
+ Real off = gap + ((bound[LEFT]->extent (bound[LEFT], X_AXIS).length ()*3) / 4);
for (int a = X_AXIS; a < NO_AXES; a++)
{
Axis ax = (Axis)a;
- dxy[ax] =
- + bound[RIGHT]->extent (common[X_AXIS], ax).center ()
+ dxy[ax]
+ = + bound[RIGHT]->extent (common[X_AXIS], ax).center ()
- bound[LEFT]->extent (common[X_AXIS], ax).center ();
my_off[ax] = me->relative_coordinate (common[a], ax);
his_off[ax] = bound[LEFT]->relative_coordinate (common[a], ax);
-
+
}
- ofxy = dxy * (off/dxy.length ());
+ ofxy = dxy * (off / dxy.length ());
dxy -= 2*ofxy;
-
+
Stencil line = line_stencil (me, Offset (0, 0), dxy);
- line.translate_axis (bound[LEFT]->extent (bound[LEFT], X_AXIS).length ()/2, X_AXIS);
+ line.translate_axis (bound[LEFT]->extent (bound[LEFT], X_AXIS).length () / 2, X_AXIS);
line.translate (ofxy - my_off + his_off);
return line.smobbed_copy ();
}
}
-
ADD_INTERFACE (Line_spanner, "line-spanner-interface",
"Generic line drawn between two objects, e.g. for use with glissandi.\n"
"The property @code{style} can be @code{line}, "
"@code{dashed-line}, @code{trill}, \n"
"@code{dotted-line} or @code{zigzag}.\n"
- "\n"
- ,
+ "\n",
"gap zigzag-width zigzag-length thickness");
-
return Stencil (box, at);
}
-
-
/*
* Horizontal Slope:
*
* <----->
* width
*/
-Stencil
-Lookup::beam (Real slope, Real width, Real thick, Real blot)
+Stencil
+Lookup::beam (Real slope, Real width, Real thick, Real blot)
{
- Real height = slope * width;
- Real min_y = (0 <? height) - thick/2;
- Real max_y = (0 >? height) + thick/2;
+ Real height = slope * width;
+ Real min_y = (0 <? height) - thick / 2;
+ Real max_y = (0 >? height) + thick / 2;
Box b (Interval (0, width),
Interval (min_y, max_y));
-
+
SCM at = scm_list_n (ly_symbol2scm ("beam"),
- scm_make_real (width),
- scm_make_real (slope),
- scm_make_real (thick),
- scm_make_real (blot),
- SCM_UNDEFINED);
+ scm_make_real (width),
+ scm_make_real (slope),
+ scm_make_real (thick),
+ scm_make_real (blot),
+ SCM_UNDEFINED);
return Stencil (b, at);
}
-
Stencil
Lookup::dashed_slur (Bezier b, Real thick, Real dash_period, Real dash_fraction)
{
SCM l = SCM_EOL;
-
- Real on = dash_fraction * dash_period;
- Real off = dash_period - on;
-
- for (int i = 4; i -- ;)
+
+ Real on = dash_fraction * dash_period;
+ Real off = dash_period - on;
+
+ for (int i = 4; i--;)
{
l = scm_cons (ly_offset2scm (b.control_[i]), l);
}
SCM at = (scm_list_n (ly_symbol2scm ("dashed-slur"),
- scm_make_real (thick),
+ scm_make_real (thick),
scm_make_real (on),
scm_make_real (off),
ly_quote_scm (l),
SCM_UNDEFINED));
Box box (Interval (0, 0), Interval (0, 0));
- return Stencil (box, at);
+ return Stencil (box, at);
}
-
-
Stencil
Lookup::horizontal_line (Interval w, Real th)
{
SCM at = scm_list_n (ly_symbol2scm ("horizontal-line"),
- scm_make_real (w[LEFT]),
+ scm_make_real (w[LEFT]),
scm_make_real (w[RIGHT]),
scm_make_real (th),
SCM_UNDEFINED);
-
- Box box ;
+ Box box;
box[X_AXIS] = w;
- box[Y_AXIS] = Interval (-th/2, th/2);
+ box[Y_AXIS] = Interval (-th / 2, th / 2);
return Stencil (box, at);
}
-
Stencil
-Lookup::blank (Box b)
+Lookup::blank (Box b)
{
return Stencil (b, scm_makfrom0str (""));
}
Stencil
-Lookup::filled_box (Box b)
+Lookup::filled_box (Box b)
{
- SCM at = (scm_list_n (ly_symbol2scm ("filledbox"),
- scm_make_real (-b[X_AXIS][LEFT]),
- scm_make_real (b[X_AXIS][RIGHT]),
- scm_make_real (-b[Y_AXIS][DOWN]),
- scm_make_real (b[Y_AXIS][UP]),
- SCM_UNDEFINED));
+ SCM at = (scm_list_n (ly_symbol2scm ("filledbox"),
+ scm_make_real (-b[X_AXIS][LEFT]),
+ scm_make_real (b[X_AXIS][RIGHT]),
+ scm_make_real (-b[Y_AXIS][DOWN]),
+ scm_make_real (b[Y_AXIS][UP]),
+ SCM_UNDEFINED));
return Stencil (b, at);
}
return Stencil (b, at);
}
-
-
/*
* Create Stencil that represents a filled polygon with round edges.
*
return polygon;
}
-
/*
TODO: deprecate?
- */
+*/
Stencil
Lookup::frame (Box b, Real thick, Real blot)
{
Direction d = LEFT;
for (Axis a = X_AXIS; a < NO_AXES; a = Axis (a + 1))
{
- Axis o = Axis ((a+1)%NO_AXES);
+ Axis o = Axis ((a + 1)%NO_AXES);
do
{
Box edges;
edges[a] = b[a][d] + 0.5 * thick * Interval (-1, 1);
- edges[o][DOWN] = b[o][DOWN] - thick/2;
- edges[o][UP] = b[o][UP] + thick/2;
-
+ edges[o][DOWN] = b[o][DOWN] - thick / 2;
+ edges[o][UP] = b[o][UP] + thick / 2;
+
m.add_stencil (round_filled_box (edges, blot));
}
while (flip (&d) != LEFT);
}
/*
- Make a smooth curve along the points
- */
+ Make a smooth curve along the points
+*/
Stencil
-Lookup::slur (Bezier curve, Real curvethick, Real linethick)
+Lookup::slur (Bezier curve, Real curvethick, Real linethick)
{
Real alpha = (curve.control_[3] - curve.control_[0]).arg ();
Bezier back = curve;
- Offset perp = curvethick * complex_exp (Offset (0, alpha + M_PI/2)) * 0.5;
+ Offset perp = curvethick * complex_exp (Offset (0, alpha + M_PI / 2)) * 0.5;
back.reverse ();
back.control_[1] += perp;
back.control_[2] += perp;
curve.control_[1] -= perp;
curve.control_[2] -= perp;
-
+
SCM scontrols[8];
for (int i =4; i--;)
scontrols[ i ] = ly_offset2scm (back.control_[i]);
- for (int i =4 ; i--;)
- scontrols[i+4] = ly_offset2scm (curve.control_[i]);
+ for (int i =4; i--;)
+ scontrols[i + 4] = ly_offset2scm (curve.control_[i]);
/*
- Need the weird order b.o. the way PS want its arguments
- */
+ Need the weird order b.o. the way PS want its arguments
+ */
int indices[]= {5, 6, 7, 4, 1, 2, 3, 0};
SCM list = SCM_EOL;
for (int i = 8; i--;)
{
list = scm_cons (scontrols[indices[i]], list);
}
-
-
+
SCM at = (scm_list_n (ly_symbol2scm ("bezier-sandwich"),
- ly_quote_scm (list),
- scm_make_real (linethick),
- SCM_UNDEFINED));
+ ly_quote_scm (list),
+ scm_make_real (linethick),
+ SCM_UNDEFINED));
Box b (curve.extent (X_AXIS),
- curve.extent (Y_AXIS));
+ curve.extent (Y_AXIS));
b[X_AXIS].unite (back.extent (X_AXIS));
b[Y_AXIS].unite (back.extent (Y_AXIS));
Lookup::bezier_sandwich (Bezier top_curve, Bezier bottom_curve)
{
/*
- Need the weird order b.o. the way PS want its arguments
- */
+ Need the weird order b.o. the way PS want its arguments
+ */
SCM list = SCM_EOL;
list = scm_cons (ly_offset2scm (bottom_curve.control_[3]), list);
list = scm_cons (ly_offset2scm (bottom_curve.control_[0]), list);
/*
TODO: junk me.
- */
+*/
Stencil
-Lookup::accordion (SCM s, Real staff_space, Font_metric *fm)
+Lookup::accordion (SCM s, Real staff_space, Font_metric *fm)
{
Stencil m;
String sym = ly_scm2string (scm_car (s));
Stencil d = fm->find_by_name ("accordion.accDot");
d.translate_axis (staff_space * 2.5 PT, Y_AXIS);
m.add_stencil (d);
- reg = reg.right_string (reg.length ()-1);
+ reg = reg.right_string (reg.length () - 1);
}
int eflag = 0x00;
if (reg.left_string (3) == "EEE")
{
eflag = 0x07;
- reg = reg.right_string (reg.length ()-3);
+ reg = reg.right_string (reg.length () - 3);
}
else if (reg.left_string (2) == "EE")
{
eflag = 0x05;
- reg = reg.right_string (reg.length ()-2);
+ reg = reg.right_string (reg.length () - 2);
}
else if (reg.left_string (2) == "Eh")
{
eflag = 0x04;
- reg = reg.right_string (reg.length ()-2);
+ reg = reg.right_string (reg.length () - 2);
}
else if (reg.left_string (1) == "E")
{
eflag = 0x02;
- reg = reg.right_string (reg.length ()-1);
+ reg = reg.right_string (reg.length () - 1);
}
if (eflag & 0x02)
{
m.add_stencil (d);
d.translate_axis (-0.8 * staff_space PT, X_AXIS);
m.add_stencil (d);
- reg = reg.right_string (reg.length ()-2);
+ reg = reg.right_string (reg.length () - 2);
}
if (reg.left_string (1) == "S")
{
Stencil d = fm->find_by_name ("accordion.accDot");
d.translate_axis (0.5 * staff_space PT, Y_AXIS);
m.add_stencil (d);
- reg = reg.right_string (reg.length ()-1);
+ reg = reg.right_string (reg.length () - 1);
}
}
else if (sym == "Freebase")
Stencil d = fm->find_by_name ("accordion.accDot");
d.translate_axis (staff_space * 1.5 PT, Y_AXIS);
m.add_stencil (d);
- reg = reg.right_string (reg.length ()-1);
+ reg = reg.right_string (reg.length () - 1);
}
if (reg == "E")
{
Stencil d = fm->find_by_name ("accordion.accDot");
d.translate_axis (staff_space * 2.5 PT, Y_AXIS);
m.add_stencil (d);
- reg = reg.right_string (reg.length ()-1);
+ reg = reg.right_string (reg.length () - 1);
}
/* include 4' reed just for completeness. You don't want to use this. */
if (reg.left_string (1) == "F")
Stencil d = fm->find_by_name ("accordion.accDot");
d.translate_axis (staff_space * 1.5 PT, Y_AXIS);
m.add_stencil (d);
- reg = reg.right_string (reg.length ()-1);
+ reg = reg.right_string (reg.length () - 1);
}
if (reg.left_string (2) == "EE")
{
m.add_stencil (d);
d.translate_axis (-0.8 * staff_space PT, X_AXIS);
m.add_stencil (d);
- reg = reg.right_string (reg.length ()-2);
+ reg = reg.right_string (reg.length () - 2);
}
if (reg.left_string (1) == "E")
{
Stencil d = fm->find_by_name ("accordion.accDot");
d.translate_axis (staff_space * 0.5 PT, Y_AXIS);
m.add_stencil (d);
- reg = reg.right_string (reg.length ()-1);
+ reg = reg.right_string (reg.length () - 1);
}
}
else if (sym == "Stdbase")
Stencil d = fm->find_by_name ("accordion.accDot");
d.translate_axis (staff_space * 3.5 PT, Y_AXIS);
m.add_stencil (d);
- reg = reg.right_string (reg.length ()-1);
+ reg = reg.right_string (reg.length () - 1);
}
if (reg.left_string (1) == "F")
{
Stencil d = fm->find_by_name ("accordion.accDot");
d.translate_axis (staff_space * 2.5 PT, Y_AXIS);
m.add_stencil (d);
- reg = reg.right_string (reg.length ()-1);
+ reg = reg.right_string (reg.length () - 1);
}
if (reg.left_string (1) == "M")
{
d.translate_axis (staff_space * 2 PT, Y_AXIS);
d.translate_axis (staff_space PT, X_AXIS);
m.add_stencil (d);
- reg = reg.right_string (reg.length ()-1);
+ reg = reg.right_string (reg.length () - 1);
}
if (reg.left_string (1) == "E")
{
Stencil d = fm->find_by_name ("accordion.accDot");
d.translate_axis (staff_space * 1.5 PT, Y_AXIS);
m.add_stencil (d);
- reg = reg.right_string (reg.length ()-1);
+ reg = reg.right_string (reg.length () - 1);
}
if (reg.left_string (1) == "S")
{
Stencil d = fm->find_by_name ("accordion.accDot");
d.translate_axis (staff_space * 0.5 PT, Y_AXIS);
m.add_stencil (d);
- reg = reg.right_string (reg.length ()-1);
+ reg = reg.right_string (reg.length () - 1);
}
}
/* ugh maybe try to use regular font for S.B. and B.B and only use one font
Stencil r = fm->find_by_name ("accordion.accOldEES");
m.add_stencil (r);
}
- return m;
+ return m;
}
Stencil
SCM slashnodot = scm_list_n (ly_symbol2scm ("repeat-slash"),
wid, sl, thick, SCM_UNDEFINED);
- Box b (Interval (0, w + sqrt (sqr (t/s) + sqr (t))),
+ Box b (Interval (0, w + sqrt (sqr (t / s) + sqr (t))),
Interval (0, w * s));
return Stencil (b, slashnodot); // http://slashnodot.org
}
-
Stencil
Lookup::bracket (Axis a, Interval iv, Real thick, Real protude, Real blot)
{
Box b;
- Axis other = Axis ((a+1)%2);
+ Axis other = Axis ((a + 1)%2);
b[a] = iv;
b[other] = Interval (-1, 1) * thick * 0.5;
-
+
Stencil m = round_filled_box (b, blot);
b[a] = Interval (iv[UP] - thick, iv[UP]);
- Interval oi = Interval (-thick/2, thick/2 + fabs (protude));
+ Interval oi = Interval (-thick / 2, thick / 2 + fabs (protude));
oi *= sign (protude);
b[other] = oi;
m.add_stencil (round_filled_box (b, blot));
Stencil
Lookup::triangle (Interval iv, Real thick, Real protude)
{
- Box b ;
- b[X_AXIS] = Interval (0, iv.length());
- b[Y_AXIS] = Interval (0 <? protude , 0 >? protude);
-
+ Box b;
+ b[X_AXIS] = Interval (0, iv.length ());
+ b[Y_AXIS] = Interval (0 <? protude, 0 >? protude);
- Offset z1(iv[LEFT], 0);
- Offset z2(iv[RIGHT], 0);
- Offset z3((z1 + z2)[X_AXIS]/2, protude);
+ Offset z1 (iv[LEFT], 0);
+ Offset z2 (iv[RIGHT], 0);
+ Offset z3 ((z1 + z2)[X_AXIS] / 2, protude);
/*
TODO: move Triangle to Line_interface ?
- */
+ */
Stencil tri = Line_interface::make_line (thick, z1, z2);
tri.add_stencil (Line_interface::make_line (thick, z2, z3));
tri.add_stencil (Line_interface::make_line (thick, z3, z1));
SCM mod = SCM_EOL;
if (!safe)
{
- String s = "*anonymous-ly-" + to_string (module_count++) + "*";
+ String s = "*anonymous-ly-" + to_string (module_count++) + "*";
mod = scm_c_define_module (s.to_str0 (), ly_init_anonymous_module, 0);
ly_use_module (mod, global_lily_module);
}
mod,
scm_list_2 (ly_symbol2scm ("module-public-interface"),
used));
-
+
return scm_eval (expr, global_lily_module);
}
}
/* Ugh signature of scm_internal_hash_fold () is inaccurate. */
-typedef SCM (*Hash_cl_func)();
+typedef SCM (*Hash_cl_func) ();
/*
If a variable in changed in SRC, we DEST doesn't see the
definitions.
- */
+*/
LY_DEFINE (ly_module_copy, "ly:module-copy",
2, 0, 0, (SCM dest, SCM src),
"Copy all bindings from module SRC into DEST.")
{
SCM_VALIDATE_MODULE (1, src);
scm_internal_hash_fold ((Hash_cl_func) &module_define_closure_func,
- (void*) dest,
+ (void *) dest,
SCM_EOL, SCM_MODULE_OBARRAY (src));
return SCM_UNSPECIFIED;
}
ly_module_symbols (SCM mod)
{
SCM_VALIDATE_MODULE (1, mod);
-
+
SCM obarr = SCM_MODULE_OBARRAY (mod);
return scm_internal_hash_fold ((Hash_cl_func) &accumulate_symbol,
- NULL, SCM_EOL, obarr);
+ NULL, SCM_EOL, obarr);
}
static SCM
entry_to_alist (void *closure, SCM key, SCM val, SCM result)
{
(void) closure;
- if (scm_variable_bound_p (val) == SCM_BOOL_T)
+ if (scm_variable_bound_p (val) == SCM_BOOL_T)
{
return scm_cons (scm_cons (key, scm_variable_ref (val)), result);
}
else
{
- programming_error ("Unbound variable in module.");
+ programming_error ("Unbound variable in module.");
return result;
}
}
SCM_VALIDATE_MODULE (1, mod);
SCM obarr = SCM_MODULE_OBARRAY (mod);
- return scm_internal_hash_fold ((Hash_cl_func) &entry_to_alist, NULL, SCM_EOL, obarr);
+ return scm_internal_hash_fold ((Hash_cl_func) &entry_to_alist, NULL, SCM_EOL, obarr);
}
/* Lookup SYM, but don't give error when it is not defined. */
SCM mod = scm_car (s);
SCM v = ly_module_lookup (mod, sym);
if (SCM_VARIABLEP (v) && SCM_VARIABLE_REF (v) != SCM_UNDEFINED)
- return scm_variable_ref(v);
+ return scm_variable_ref (v);
}
if (def != SCM_UNDEFINED)
static SCM export_function;
if (!export_function)
export_function = scm_permanent_object (scm_c_lookup ("module-export!"));
-
+
scm_call_2 (SCM_VARIABLE_REF (export_function), module, namelist);
}
-/*
+/*
lyric-combine-music-iterator.cc -- implement Lyric_combine_music_iterator
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "context.hh"
#include "event.hh"
{
public:
Lyric_combine_music_iterator ();
- Lyric_combine_music_iterator (Lyric_combine_music_iterator const&src);
+ Lyric_combine_music_iterator (Lyric_combine_music_iterator const &src);
DECLARE_SCHEME_CALLBACK (constructor, ());
protected:
virtual void construct_children ();
virtual Moment pending_moment () const;
- virtual void do_quit ();
+ virtual void do_quit ();
virtual void process (Moment);
virtual Music_iterator *try_music_in_children (Music *) const;
virtual bool ok () const;
virtual void derived_mark () const;
- virtual void derived_substitute (Context *, Context *) ;
+ virtual void derived_substitute (Context *, Context *);
private:
- bool get_busy_status ()const ;
- bool melisma_busy ();
- Music* get_combine_lyrics () const;
- Music* get_combine_music () const;
-
-
- Music_iterator * music_iter_;
- Music_iterator * lyric_iter_;
-};
+ bool get_busy_status ()const;
+ bool melisma_busy ();
+ Music *get_combine_lyrics () const;
+ Music *get_combine_music () const;
+ Music_iterator *music_iter_;
+ Music_iterator *lyric_iter_;
+};
bool
-melisma_busy (Context* tr)
+melisma_busy (Context *tr)
{
SCM melisma_properties = tr->get_property ("melismaBusyProperties");
bool busy = false;
return busy;
}
-
-
/*
Ugh, why static?
- */
+*/
Music *busy_req;
Music *melisma_playing_req;
}
void
-Lyric_combine_music_iterator::derived_substitute (Context *f, Context * t)
+Lyric_combine_music_iterator::derived_substitute (Context *f, Context *t)
{
if (music_iter_)
music_iter_->substitute_outlet (f, t);
lyric_iter_->substitute_outlet (f, t);
}
-Music*
+Music *
Lyric_combine_music_iterator::get_combine_music () const
{
SCM l = get_music ()->get_property ("elements");
return unsmob_music (scm_car (l));
}
-Music*
+Music *
Lyric_combine_music_iterator::get_combine_lyrics () const
{
SCM l = get_music ()->get_property ("elements");
return unsmob_music (scm_car (l));
}
-
void
Lyric_combine_music_iterator::construct_children ()
{
instant. */
if (try_music (busy_req))
return true;
-
- Context * tr = music_iter_->get_outlet ();
+
+ Context *tr = music_iter_->get_outlet ();
SCM grobs = tr->get_property ("busyGrobs");
Moment now = tr->now_mom ();
for (; scm_is_pair (grobs); grobs = scm_cdr (grobs))
{
SCM grob = scm_cdar (grobs);
- Moment end =*unsmob_moment (scm_caar (grobs));
+ Moment end =*unsmob_moment (scm_caar (grobs));
-
/*
This is slightly ugh: we are now confunding the frontend
(iterators) and the backend (note heads) */
return false;
}
-
bool
Lyric_combine_music_iterator::melisma_busy ()
{
We can not read the property, since music_iter_->get_outlet () might
not be the context that sets the melisma properties, but rather a
parent context.
- */
+ */
return music_iter_->try_music (melisma_playing_req);
}
Moment my_next = music_iter_->pending_moment ();
if (my_next > m)
return;
-
+
music_iter_->process (m);
if (get_busy_status () && !melisma_busy () && lyric_iter_->ok ())
lyric_iter_->quit ();
}
-Music_iterator*
+Music_iterator *
Lyric_combine_music_iterator::try_music_in_children (Music *m) const
{
- Music_iterator * i = music_iter_->try_music (m);
+ Music_iterator *i = music_iter_->try_music (m);
if (i)
return i;
else
return lyric_iter_->try_music (m);
}
-
IMPLEMENT_CTOR_CALLBACK (Lyric_combine_music_iterator);
-/*
+/*
lyric-combine-music.cc -- implement Lyric_combine_music
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "music.hh"
#include "pitch.hh"
struct Lyric_combine_music
{
public:
- DECLARE_SCHEME_CALLBACK(length_callback, (SCM));
+ DECLARE_SCHEME_CALLBACK (length_callback, (SCM));
};
-
-MAKE_SCHEME_CALLBACK(Lyric_combine_music, length_callback, 1);
+MAKE_SCHEME_CALLBACK (Lyric_combine_music, length_callback, 1);
SCM
Lyric_combine_music::length_callback (SCM m)
{
- Music * me = unsmob_music (m);
+ Music *me = unsmob_music (m);
Music *melody = unsmob_music (scm_car (me->get_property ("elements")));
return melody->get_length ().smobbed_copy ();
}
/**
Generate texts for lyric syllables. We only do one lyric at a time.
Multiple copies of this engraver should be used to do multiple voices.
- */
+*/
class Lyric_engraver : public Engraver
{
protected:
}
bool
-Lyric_engraver::try_music (Music*r)
+Lyric_engraver::try_music (Music *r)
{
if (!event_)
{
}
}
-
-Context*
+Context *
get_voice_to_lyrics (Context *lyrics)
{
SCM avc = lyrics->get_property ("associatedVoiceContext");
- if (Context *c = unsmob_context (avc))
+ if (Context *c = unsmob_context (avc))
return c;
SCM voice_name = lyrics->get_property ("associatedVoice");
for (SCM s = voice->get_property ("busyGrobs");
scm_is_pair (s); s = scm_cdr (s))
{
- Item *g = dynamic_cast<Item*> (unsmob_grob (scm_cdar (s)));
-
+ Item *g = dynamic_cast<Item *> (unsmob_grob (scm_cdar (s)));
+
if (g && !g->get_column ()
&& Note_head::has_interface (g))
return g;
}
-
+
return 0;
}
event_ = 0;
}
-
ADD_TRANSLATOR (Lyric_engraver,
-/* descr */ "",
-/* creats*/ "LyricText",
-/* accepts */ "lyric-event",
-/* acks */ "",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "",
+ /* creats*/ "LyricText",
+ /* accepts */ "lyric-event",
+ /* acks */ "",
+ /* reads */ "",
+ /* write */ "");
#include "group-interface.hh"
MAKE_SCHEME_CALLBACK (Lyric_extender, print, 1)
-SCM
-Lyric_extender::print (SCM smob)
+ SCM
+Lyric_extender::print (SCM smob)
{
Spanner *me = unsmob_spanner (smob);
Item *left_edge = me->get_bound (LEFT);
Item *right_text = unsmob_item (me->get_property ("next"));
-
+
Grob *common = left_edge;
if (right_text)
common = common->common_refpoint (right_text, X_AXIS);
-
+
common = common->common_refpoint (me->get_bound (RIGHT), X_AXIS);
- Real sl = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
+ Real sl = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
Link_array<Grob> heads (extract_grob_array (me, ly_symbol2scm ("heads")));
if (!heads.size ())
return SCM_EOL;
common = common_refpoint_of_array (heads, common, X_AXIS);
-
+
Real left_point = 0.0;
if (left_edge->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
left_point = left_edge->extent (common, X_AXIS)[RIGHT];
note head, but haven't found a pattern in it yet. --hwn 1/1/04 */
SCM minlen = me->get_property ("minimum-length");
Real right_point
- = left_point + (robust_scm2double (minlen, 0));
+ = left_point + (robust_scm2double (minlen, 0));
if (heads.size ())
right_point = right_point >? heads.top ()->extent (common, X_AXIS)[RIGHT];
/* run to end of line. */
if (me->get_bound (RIGHT)->break_status_dir ())
right_point = right_point >? (robust_relative_extent (me->get_bound (RIGHT), common, X_AXIS)[LEFT] - pad);
-
+
left_point += pad;
Real w = right_point - left_point;
if (w < 1.5 * h)
return SCM_EOL;
-
- Stencil mol (Lookup::round_filled_box (Box (Interval (0, w),
- Interval (0, h)),
- 0.8 * h));
+
+ Stencil mol (Lookup::round_filled_box (Box (Interval (0, w),
+ Interval (0, h)),
+ 0.8 * h));
mol.translate_axis (left_point - me->relative_coordinate (common, X_AXIS),
X_AXIS);
return mol.smobbed_copy ();
}
-
ADD_INTERFACE (Lyric_extender, "lyric-extender-interface",
"The extender is a simple line at the baseline of the lyric "
"that helps show the length of a melissima (tied/slurred note).",
#include "moment.hh"
MAKE_SCHEME_CALLBACK (Hyphen_spanner, print, 1)
-SCM
+ SCM
Hyphen_spanner::print (SCM smob)
{
- Spanner * me = unsmob_spanner (smob);
- Drul_array<Item*> bounds (me->get_bound (LEFT),
- me->get_bound (RIGHT));
+ Spanner *me = unsmob_spanner (smob);
+ Drul_array<Item *> bounds (me->get_bound (LEFT),
+ me->get_bound (RIGHT));
if (bounds[LEFT]->break_status_dir ()
&& Paper_column::when_mom (bounds[LEFT]) == Paper_column::when_mom (bounds[RIGHT]->get_column ()))
return SCM_EOL;
-
- Grob * common = bounds[LEFT]->common_refpoint (bounds[RIGHT], X_AXIS);
+
+ Grob *common = bounds[LEFT]->common_refpoint (bounds[RIGHT], X_AXIS);
Interval span_points;
Direction d = LEFT;
: iv[-d];
}
while (flip (&d) != LEFT);
-
+
Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
- Real th = robust_scm2double (me->get_property ("thickness"), 1) * lt ;
+ Real th = robust_scm2double (me->get_property ("thickness"), 1) * lt;
Real h = robust_scm2double (me->get_property ("height"), 0.5);
// interval?
-
+
Real dp = robust_scm2double (me->get_property ("dash-period"), 1.0);
- Real dl = robust_scm2double (me->get_property ("length"), .5 );
+ Real dl = robust_scm2double (me->get_property ("length"), .5);
if (dp < dl)
dp = 1.5 * dl;
Real l = span_points.length ();
- int n = int (ceil (l/dp - 0.5));
+ int n = int (ceil (l / dp - 0.5));
if (n <= 0)
n = 1;
- Real space_left = l - dl - (n-1)* dp;
+ Real space_left = l - dl - (n - 1)* dp;
/*
If there is not enough space, the hyphen should disappear, but not
at the end of the line.
- */
+ */
if (space_left < 0.0
&& !bounds[RIGHT]->break_status_dir ())
return SCM_EOL;
space_left = space_left >? 0.0;
-
- Box b (Interval (0, dl), Interval (h, h+th));
+
+ Box b (Interval (0, dl), Interval (h, h + th));
Stencil dash_mol (Lookup::round_filled_box (b, 0.8 * lt));
Stencil total;
total.add_stencil (m);
}
- total.translate_axis ( -me->relative_coordinate (common, X_AXIS), X_AXIS);
+ total.translate_axis (-me->relative_coordinate (common, X_AXIS), X_AXIS);
return total.smobbed_copy ();
}
-
MAKE_SCHEME_CALLBACK (Hyphen_spanner, set_spacing_rods, 1);
SCM
Hyphen_spanner::set_spacing_rods (SCM smob)
{
- Grob*me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
Rod r;
- Spanner*sp = dynamic_cast<Spanner*> (me);
- r.distance_ =
- robust_scm2double (me->get_property ("minimum-length"), 0);
+ Spanner *sp = dynamic_cast<Spanner *> (me);
+ r.distance_
+ = robust_scm2double (me->get_property ("minimum-length"), 0);
Direction d = LEFT;
do
if (r.item_drul_[LEFT]
&& r.item_drul_[RIGHT])
r.add_to_cols ();
-
+
return SCM_UNSPECIFIED;
}
"A centred hyphen is a simple line between lyrics used to divide syllables",
"thickness height dash-period minimum-length length");
-
#include "audio-item.hh"
#include "performer.hh"
-class Lyric_performer : public Performer {
+class Lyric_performer : public Performer
+{
public:
TRANSLATOR_DECLARATIONS (Lyric_performer);
protected:
- virtual bool try_music (Music* req);
+ virtual bool try_music (Music *req);
virtual void stop_translation_timestep ();
virtual void create_audio_elements ();
private:
Link_array<Music> lreqs_;
- Audio_text* audio_;
+ Audio_text *audio_;
};
-
-
Lyric_performer::Lyric_performer ()
{
audio_ = 0;
}
-
void
Lyric_performer::create_audio_elements ()
{
&& ly_scm2string (lreqs_[0]->get_property ("text")).length ())
{
audio_ = new Audio_text (Audio_text::LYRIC,
- ly_scm2string (lreqs_[0]->get_property ("text")));
+ ly_scm2string (lreqs_[0]->get_property ("text")));
Audio_element_info info (audio_, lreqs_[0]);
announce_element (info);
}
}
bool
-Lyric_performer::try_music (Music* req)
+Lyric_performer::try_music (Music *req)
{
if (req->is_mus_type ("lyric-event"))
{
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
+
#include "main.hh"
#include <cassert>
bool make_preview = false;
bool make_pages = true;
-
/*
* Miscellaneous global stuff.
*/
File_path global_path;
-
/*
* File globals.
*/
-static char const *AUTHORS =
-" Han-Wen Nienhuys <hanwen@cs.uu.nl>\n"
-" Jan Nieuwenhuizen <janneke@gnu.org>\n";
+static char const *AUTHORS
+= " Han-Wen Nienhuys <hanwen@cs.uu.nl>\n"
+ " Jan Nieuwenhuizen <janneke@gnu.org>\n";
static char const *PROGRAM_NAME = "lilypond";
static char const *PROGRAM_URL = "http://lilypond.org";
-static char const *NOTICE =
-_i("This program is free software. It is covered by the GNU General Public\n"
- "License and you are welcome to change it and/or distribute copies of it\n"
- "under certain conditions. Invoke as `%s --warranty' for more\n"
- "information.\n");
-
-static char const *WARRANTY =
-_i(" This program is free software; you can redistribute it and/or\n"
- "modify it under the terms of the GNU General Public License version 2\n"
- "as published by the Free Software Foundation.\n"
- "\n"
- " This program is distributed in the hope that it will be useful,\n"
- "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
- "General Public License for more details.\n"
- "\n"
- " You should have received a copy (refer to the file COPYING) of the\n"
- "GNU General Public License along with this program; if not, write to\n"
- "the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n"
- "Boston, MA 02111-1307, USA.\n");
+static char const *NOTICE
+= _i ("This program is free software. It is covered by the GNU General Public\n"
+ "License and you are welcome to change it and/or distribute copies of it\n"
+ "under certain conditions. Invoke as `%s --warranty' for more\n"
+ "information.\n");
+
+static char const *WARRANTY
+= _i (" This program is free software; you can redistribute it and/or\n"
+ "modify it under the terms of the GNU General Public License version 2\n"
+ "as published by the Free Software Foundation.\n"
+ "\n"
+ " This program is distributed in the hope that it will be useful,\n"
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
+ "General Public License for more details.\n"
+ "\n"
+ " You should have received a copy (refer to the file COPYING) of the\n"
+ "GNU General Public License along with this program; if not, write to\n"
+ "the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n"
+ "Boston, MA 02111-1307, USA.\n");
/* Where the init files live. Typically:
LILYPOND_DATADIR = /usr/share/lilypond
static Getopt_long *option_parser = 0;
/* Internationalisation kludge in two steps:
- * use _i () to get entry in POT file
- * call gettext () explicitely for actual "translation" */
-
-static Long_option_init options_static[] =
- {
- {_i ("EXT"), "backend", 'b', _i ("select backend to use")},
- {_i ("EXPR"), "evaluate", 'e',
- _i ("set option, use -e '(ly:option-usage)' for help")},
- /* Bug in option parser: --output =foe is taken as an abbreviation
- for --output-format. */
- {_i ("EXTs"), "formats", 'f', _i ("list of formats to dump")},
- {0, "help", 'h', _i ("print this help")},
- {_i ("FIELD"), "header", 'H', _i ("write header field to BASENAME.FIELD")},
- {_i ("DIR"), "include", 'I', _i ("add DIR to search path")},
- {_i ("FILE"), "init", 'i', _i ("use FILE as init file")},
- {_i ("FILE"), "output", 'o', _i ("write output to FILE (suffix will be added)")},
- {_i ("USER,GROUP,JAIL,DIR"), "jail", 'j', _i ("chroot to JAIL, become USER:GROUP and cd into DIR")},
- {0, "preview", 'p', _i ("generate a preview")},
- {0, "no-pages", 0, _i ("don't generate full pages")},
- {0, "png", 0, _i ("generate PNG")},
- {0, "ps", 0, _i ("generate PostScript")},
- {0, "dvi", 0, _i ("generate DVI")},
- {0, "pdf", 0, _i ("generate PDF (default)")},
- {0, "tex", 0, _i ("generate TeX")},
- {0, "safe-mode", 's', _i ("run in safe mode")},
- {0, "version", 'v', _i ("print version number")},
- {0, "verbose", 'V', _i ("be verbose")},
- {0, "warranty", 'w', _i ("show warranty and copyright")},
- {0, 0, 0, 0}
- };
+ * use _i () to get entry in POT file
+ * call gettext () explicitely for actual "translation" */
+
+static Long_option_init options_static[]
+= {
+ {_i ("EXT"), "backend", 'b', _i ("select backend to use")},
+ {_i ("EXPR"), "evaluate", 'e',
+ _i ("set option, use -e '(ly:option-usage)' for help")},
+ /* Bug in option parser: --output =foe is taken as an abbreviation
+ for --output-format. */
+ {_i ("EXTs"), "formats", 'f', _i ("list of formats to dump")},
+ {0, "help", 'h', _i ("print this help")},
+ {_i ("FIELD"), "header", 'H', _i ("write header field to BASENAME.FIELD")},
+ {_i ("DIR"), "include", 'I', _i ("add DIR to search path")},
+ {_i ("FILE"), "init", 'i', _i ("use FILE as init file")},
+ {_i ("FILE"), "output", 'o', _i ("write output to FILE (suffix will be added)")},
+ {_i ("USER,GROUP,JAIL,DIR"), "jail", 'j', _i ("chroot to JAIL, become USER:GROUP and cd into DIR")},
+ {0, "preview", 'p', _i ("generate a preview")},
+ {0, "no-pages", 0, _i ("don't generate full pages")},
+ {0, "png", 0, _i ("generate PNG")},
+ {0, "ps", 0, _i ("generate PostScript")},
+ {0, "dvi", 0, _i ("generate DVI")},
+ {0, "pdf", 0, _i ("generate PDF (default)")},
+ {0, "tex", 0, _i ("generate TeX")},
+ {0, "safe-mode", 's', _i ("run in safe mode")},
+ {0, "version", 'v', _i ("print version number")},
+ {0, "verbose", 'V', _i ("be verbose")},
+ {0, "warranty", 'w', _i ("show warranty and copyright")},
+ {0, 0, 0, 0}
+};
static void
dir_info (FILE *out)
{
fputs ("\n", out);
fprintf (out, "LILYPOND_DATADIR=\"%s\"\n", LILYPOND_DATADIR);
- if (char const * env = getenv ("LILYPONDPREFIX"))
- fprintf (out, "LILYPONDPREFIX=\"%s\"\n", env);
+ if (char const *env = getenv ("LILYPONDPREFIX"))
+ fprintf (out, "LILYPONDPREFIX=\"%s\"\n", env);
fprintf (out, "LOCALEDIR=\"%s\"\n", LOCALEDIR);
- fprintf (out, "\nEffective prefix: \"%s\"\n", prefix_directory.to_str0());
+ fprintf (out, "\nEffective prefix: \"%s\"\n", prefix_directory.to_str0 ());
}
static void
fputs (gnu_lilypond_version_string ().to_str0 (), out);
fputs ("\n", out);
}
-
+
static void
notice ()
{
setup_paths ()
{
prefix_directory = LILYPOND_DATADIR;
- if (char const * env = getenv ("LILYPONDPREFIX"))
+ if (char const *env = getenv ("LILYPONDPREFIX"))
prefix_directory = env;
global_path.append ("");
{
USER_NAME, GROUP_NAME, JAIL, DIR, JAIL_MAX
};
-
+
Array<String> components = String_convert::split (jail_spec, ',');
if (components.size () != JAIL_MAX)
{
{
if (errno == 0)
error (_f ("no such user: %s", components[USER_NAME]));
- else
- error(_f ("can't get user id from user name: %s: %s",
- components[USER_NAME],
- strerror (errno)));
+ else
+ error (_f ("can't get user id from user name: %s: %s",
+ components[USER_NAME],
+ strerror (errno)));
exit (3);
}
gid = group->gr_gid;
else
{
- if (errno == 0)
+ if (errno == 0)
error (_f ("no such group: %s", components[GROUP_NAME]));
- else
+ else
error (_f ("can't get group id from group name: %s: ",
components[GROUP_NAME],
strerror (errno)));
}
}
-void test_pango();
+void test_pango ();
static void
main_with_guile (void *, int, char **)
|| output_backend_global == "texstr");
is_pango_format_global = !is_TeX_format_global;
-
ly_c_init_guile ();
call_constructors ();
init_global_tweak_registry ();
init_fontconfig ();
-
+
init_freetype ();
all_fonts_global = new All_font_metrics (global_path.to_string ());
init_scheme_code_string += ")";
- scm_c_eval_string ((char*) init_scheme_code_string.to_str0 ());
+ scm_c_eval_string ((char *) init_scheme_code_string.to_str0 ());
/* We accept multiple independent music files on the command line to
reduce compile time when processing lots of small files.
exit (2);
}
- if (! jail_spec.is_empty ())
- do_chroot_jail ();
+ if (! jail_spec.is_empty ())
+ do_chroot_jail ();
SCM result = scm_call_1 (ly_lily_module_constant ("lilypond-main"), files);
(void) result;
#if HAVE_GETTEXT
/* Enable locales */
setlocale (LC_ALL, "");
-
+
/* FIXME: check if this is still true.
- Disable localisation of float values. This breaks TeX output. */
+ Disable localisation of float values. This breaks TeX output. */
setlocale (LC_NUMERIC, "C");
-
+
String name (PACKAGE);
name.to_lower ();
bindtextdomain (name.to_str0 (), LOCALEDIR);
else if (String (opt->longname_str0_) == "no-pages")
make_pages = false;
break;
-
+
case 'v':
notice ();
exit (0);
#include "text-item.hh"
/**
- put stuff over or next to bars. Examples: bar numbers, marginal notes,
- rehearsal marks.
- */
+ put stuff over or next to bars. Examples: bar numbers, marginal notes,
+ rehearsal marks.
+*/
class Mark_engraver : public Engraver
{
public:
protected:
virtual void stop_translation_timestep ();
virtual void acknowledge_grob (Grob_info);
- void create_items (Music*);
+ void create_items (Music *);
virtual bool try_music (Music *ev);
virtual void process_music ();
-
+
private:
- Music * mark_ev_;
+ Music *mark_ev_;
};
-
-
-
Mark_engraver::Mark_engraver ()
{
text_ = 0;
void
Mark_engraver::acknowledge_grob (Grob_info inf)
{
- Grob * s = inf.grob_;
+ Grob *s = inf.grob_;
if (text_ && Bar_line::has_interface (s))
{
/*
- TODO: make this configurable. RehearsalMark cannot be
- break-aligned, since the width of the object should not be taken
- into alignment considerations.
+ TODO: make this configurable. RehearsalMark cannot be
+ break-aligned, since the width of the object should not be taken
+ into alignment considerations.
*/
text_->set_parent (s, X_AXIS);
}
}
-void
+void
Mark_engraver::stop_translation_timestep ()
{
if (text_)
{
SCM lst = get_property ("stavesFound");
- text_->set_property ("side-support-elements" , lst);
+ text_->set_property ("side-support-elements", lst);
text_ = 0;
}
mark_ev_ = 0;
}
-
void
Mark_engraver::create_items (Music *ev)
{
text_ = make_item ("RehearsalMark", ev->self_scm ());
}
-
bool
-Mark_engraver::try_music (Music* r)
+Mark_engraver::try_music (Music *r)
{
mark_ev_ = r;
return true;
}
-
/*
TODO: make the increment function in Scheme.
*/
/*
automatic marks.
- */
+ */
-
SCM m = mark_ev_->get_property ("label");
SCM proc = get_property ("markFormatter");
- if (!Text_interface::markup_p (m) &&
- ly_c_procedure_p (proc))
+ if (!Text_interface::markup_p (m)
+ && ly_c_procedure_p (proc))
{
- if (!scm_is_number (m))
- m = get_property ("rehearsalMark");
+ if (!scm_is_number (m))
+ m = get_property ("rehearsalMark");
if (scm_integer_p (m) == SCM_BOOL_T
&& scm_exact_p (m) == SCM_BOOL_T)
{
int mark_count = scm_to_int (m);
- mark_count ++;
+ mark_count++;
context ()->set_property ("rehearsalMark",
- scm_int2num (mark_count));
+ scm_int2num (mark_count));
}
if (scm_is_number (m))
}
ADD_TRANSLATOR (Mark_engraver,
-/* descr */ "This engraver will create RehearsalMark objects. "
- "It puts them on top of all staves (which is taken from "
- "the property @code{stavesFound}). If moving this engraver "
- "to a different context, "
- "@ref{Staff_collecting_engraver} must move along, otherwise all marks"
- "end up on the same Y-location"
- ,
-/* creats*/ "RehearsalMark",
-/* accepts */ "mark-event",
-/* acks */ "bar-line-interface",
-/* reads */ "rehearsalMark markFormatter stavesFound",
-/* write */ "");
+ /* descr */ "This engraver will create RehearsalMark objects. "
+ "It puts them on top of all staves (which is taken from "
+ "the property @code{stavesFound}). If moving this engraver "
+ "to a different context, "
+ "@ref{Staff_collecting_engraver} must move along, otherwise all marks"
+ "end up on the same Y-location",
+ /* creats*/ "RehearsalMark",
+ /* accepts */ "mark-event",
+ /* acks */ "bar-line-interface",
+ /* reads */ "rehearsalMark markFormatter stavesFound",
+ /* write */ "");
-/*
+/*
measure-grouping-engraver.cc -- implement Measure_grouping_engraver
source file of the GNU LilyPond music typesetter
(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- */
+*/
#include "warn.hh"
#include "side-position-interface.hh"
TRANSLATOR_DECLARATIONS (Measure_grouping_engraver);
protected:
- Spanner * grouping_;
+ Spanner *grouping_;
Rational stop_grouping_mom_;
virtual void process_music ();
}
}
-
void
Measure_grouping_engraver::acknowledge_grob (Grob_info gi)
{
{
grouping_->set_bound (RIGHT,
unsmob_grob (get_property ("currentMusicalColumn")));
-
+
grouping_ = 0;
}
-
+
if (now.grace_part_)
- return;
-
+ return;
+
SCM grouping = get_property ("beatGrouping");
if (scm_is_pair (grouping))
{
Moment *measpos = unsmob_moment (get_property ("measurePosition"));
Rational mp = measpos->main_part_;
-
- Moment * beatlen = unsmob_moment (get_property ("beatLength"));
+
+ Moment *beatlen = unsmob_moment (get_property ("beatLength"));
Rational bl = beatlen->main_part_;
-
+
Rational where (0);
for (SCM s = grouping; scm_is_pair (s);
where += Rational ((int) scm_to_int (scm_car (s))) * bl,
- s = scm_cdr (s)
- )
+ s = scm_cdr (s))
{
int grouplen = scm_to_int (scm_car (s));
if (where == mp)
programming_error ("Huh, last grouping not finished yet.");
continue;
}
-
+
grouping_ = make_spanner ("MeasureGrouping", SCM_EOL);
grouping_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn")));
-
-
- stop_grouping_mom_ = now.main_part_ + Rational (grouplen - 1) * bl ;
+ stop_grouping_mom_ = now.main_part_ + Rational (grouplen - 1) * bl;
get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_));
if (grouplen == 3)
grouping_->set_property ("style", ly_symbol2scm ("triangle"));
else
grouping_->set_property ("style", ly_symbol2scm ("bracket"));
-
- break ;
+
+ break;
}
}
}
}
ADD_TRANSLATOR (Measure_grouping_engraver,
-/* descr */ "Creates MeasureGrouping to indicate beat subdivision.",
-/* creats*/ "MeasureGrouping",
-/* accepts */ "",
-/* acks */ "note-column-interface",
-/* reads */ "beatGrouping beatLength measurePosition currentMusicalColumn",
-/* write */ "");
+ /* descr */ "Creates MeasureGrouping to indicate beat subdivision.",
+ /* creats*/ "MeasureGrouping",
+ /* accepts */ "",
+ /* acks */ "note-column-interface",
+ /* reads */ "beatGrouping beatLength measurePosition currentMusicalColumn",
+ /* write */ "");
-/*
- measure-grouping-spanner.cc -- implement Measure_grouping
+/*
+ measure-grouping-spanner.cc -- implement Measure_grouping
- source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
- (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#include "measure-grouping-spanner.hh"
#include "output-def.hh"
#include "spanner.hh"
-#include "lookup.hh"
+#include "lookup.hh"
#include "item.hh"
#include "staff-symbol-referencer.hh"
MAKE_SCHEME_CALLBACK (Measure_grouping, print, 1);
-SCM
+SCM
Measure_grouping::print (SCM grob)
{
- Spanner * me = dynamic_cast<Spanner*> (unsmob_grob (grob));
+ Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (grob));
SCM which = me->get_property ("style");
Real height = robust_scm2double (me->get_property ("height"), 1);
Real t = Staff_symbol_referencer::line_thickness (me) * robust_scm2double (me->get_property ("thickness"), 1);
Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT),
- X_AXIS);
+ X_AXIS);
Real right_point = robust_relative_extent (me->get_bound (RIGHT),
common, X_AXIS).linear_combination (CENTER);
Real left_point = me->get_bound (LEFT)->relative_coordinate (common, X_AXIS);
-
-
Interval iv (left_point, right_point);
Stencil m;
-
+
/*
TODO: use line interface
- */
+ */
if (which == ly_symbol2scm ("bracket"))
{
m = Lookup::bracket (X_AXIS, iv, t, -height, t);
"Valid choices for @code{style} are @code{bracket} and @code{triangle}.",
"thickness style height");
-
-/*
+/*
melisma-engraver.cc -- implement Melisma_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "engraver.hh"
#include "grob.hh"
/**
Signal existence of melismas.
- */
+*/
class Melisma_translator : public Translator
{
public:
virtual bool try_music (Music *);
virtual void process_music ();
virtual void start_translation_timestep ();
- Music * event_;
+ Music *event_;
};
-
bool
-Melisma_translator::try_music (Music *m)
+Melisma_translator::try_music (Music *m)
{
if (m->is_mus_type ("melisma-playing-event"))
{
else
context ()->unset_property (ly_symbol2scm ("melismaBusy"));
}
-
+
}
void
{
event_ = 0;
}
-
+
Melisma_translator::Melisma_translator ()
{
event_ = 0;
}
ADD_TRANSLATOR (Melisma_translator,
-/* descr */ "This translator collects melisma information about ties, beams, and user settings (@code{melismaBusy}, and signals it to the @code{\addlyrics} code. ",
-/* creats*/ "",
-/* accepts */ "melisma-playing-event melisma-span-event",
-/* acks */ "",
-/* reads */ "melismaBusy melismaBusyProperties slurMelismaBusy tieMelismaBusy beamMelismaBusy",
-/* write */ "");
+ /* descr */ "This translator collects melisma information about ties, beams, and user settings (@code{melismaBusy}, and signals it to the @code{\addlyrics} code. ",
+ /* creats*/ "",
+ /* accepts */ "melisma-playing-event melisma-span-event",
+ /* acks */ "",
+ /* reads */ "melismaBusy melismaBusyProperties slurMelismaBusy tieMelismaBusy beamMelismaBusy",
+ /* write */ "");
/*
mensural-ligature-engraver.cc -- implement Mensural_ligature_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2002--2005 Juergen Reuter <reuter@ipd.uka.de>,
- Pal Benko <benkop@freestart.hu>
- */
+ Pal Benko <benkop@freestart.hu>
+*/
#include "coherent-ligature-engraver.hh"
#include "mensural-ligature.hh"
void fold_up_primitives (Array<Grob_info> primitives);
};
-
Mensural_ligature_engraver::Mensural_ligature_engraver ()
{
}
bool prev_semibrevis = false;
Item *prev_primitive = NULL;
- for (int i = 0, s = primitives.size (); i < s; i++) {
- Grob_info info = primitives[i];
- Item *primitive = dynamic_cast<Item *> (info.grob_);
- int duration_log = Note_head::get_balltype (primitive);
-
- Music *nr = info.music_cause ();
-
- /*
- ugh. why not simply check for pitch?
- */
- if (!nr->is_mus_type ("note-event"))
- {
- nr->origin ()->warning
- (_f ("can not determine pitch of ligature primitive -> skipping"));
- at_beginning = true;
- continue;
- }
-
- int pitch = unsmob_pitch (nr->get_property ("pitch"))->steps ();
- int delta_pitch = 0;
-
- if (at_beginning)
- {
- if (i == s - 1)
- {
- // we can get here after invalid input
- nr->origin ()->warning
- (_f ("single note ligature - skipping"));
- break;
- }
- prev_semibrevis = prev_brevis_shape = false;
- prev_primitive = NULL;
- }
- else
- {
- delta_pitch = pitch - prev_pitch;
- if (delta_pitch == 0)
- {
- nr->origin ()->warning
- (_f ("prime interval within ligature -> skipping"));
- at_beginning = true;
- primitive->set_property ("primitive",
- scm_int2num (MLP_NONE));
- continue;
- }
- }
-
- if (duration_log < -3 // is this possible at all???
- || duration_log > 0)
- {
- nr->origin ()->warning
- (_f ("mensural ligature: duration none of Mx, L, B, S -> skipping"));
- primitive->set_property ("primitive",
- scm_int2num (MLP_NONE));
- at_beginning = true;
- continue;
- }
-
- // apply_transition replacement begins
- bool general_case = true;
-
- // first check special cases
- // 1. beginning
- if (at_beginning)
- {
- // a. semibreves
- if (duration_log == 0)
- {
- primitive->set_property ("primitive",
- scm_int2num (MLP_UP | MLP_BREVIS));
- prev_semibrevis = prev_brevis_shape = true;
- general_case = false;
- }
- // b. descendens longa or brevis
- else if (i < s - 1
- && (unsmob_pitch (primitives[i + 1].music_cause ()
- ->get_property ("pitch"))->steps () < pitch)
- && duration_log > -3)
- {
- int left_stem = duration_log == -1 ? MLP_DOWN : 0;
-
- primitive->set_property ("primitive",
- scm_int2num (left_stem | MLP_BREVIS));
- prev_brevis_shape = true;
- prev_semibrevis = general_case = false;
- }
- }
- // 2. initial semibrevis must be followed by another one
- else if (prev_semibrevis)
- {
- prev_semibrevis = false;
- if (duration_log == 0)
- {
- primitive->set_property ("primitive", scm_int2num(MLP_BREVIS));
- general_case = false;
- }
- else
- {
- nr->origin ()->warning
- (_f ("semibrevis must be followed by another one -> skipping"));
- primitive->set_property ("primitive",
- scm_int2num (MLP_NONE));
- at_beginning = true;
- continue;
- }
- }
- // 3. semibreves are otherwise not allowed
- else if (duration_log == 0)
- {
- nr->origin ()->warning
- (_f ("semibreves can only appear at the beginning of a ligature,\n"
- "and there may be only zero or two of them"));
- primitive->set_property ("primitive",
- scm_int2num (MLP_NONE));
- at_beginning = true;
- continue;
- }
- // 4. end, descendens
- else if (i == s - 1 && delta_pitch < 0)
- {
- // brevis; previous note must be turned into flexa
- if (duration_log == -1)
- {
- if (prev_brevis_shape)
- {
- prev_primitive->set_property
- ("primitive",
- scm_int2num
- (MLP_FLEXA
- | (scm_to_int (prev_primitive->get_property ("primitive"))
- & MLP_DOWN)));
- primitive->set_property ("primitive", scm_int2num (MLP_NONE));
- break; // no more notes, no join
- }
- else
- {
- nr->origin ()->warning
- (_f ("invalid ligatura ending:\n"
- "when the last note is a descending brevis,\n"
- "the penultimate note must be another one,\n"
- "or the ligatura must be LB or SSB"));
- primitive->set_property ("primitive", scm_int2num (MLP_NONE));
- break;
- }
- }
- // longa
- else if (duration_log == -2)
- {
- primitive->set_property ("primitive", scm_int2num (MLP_BREVIS));
- general_case = false;
- }
- // else maxima; fall through regular case below
- }
-
- if (general_case)
- {
- static int const shape[3] = {MLP_MAXIMA, MLP_LONGA, MLP_BREVIS};
-
- primitive->set_property ("primitive",
- scm_int2num (shape[duration_log + 3]));
- prev_brevis_shape = duration_log == -1;
- }
-
- // join_primitives replacement
- if (!at_beginning)
- {
- /*
- if the previous note is longa-shaped and this note is lower,
- then the joining line may hide the stem, so it is made longer
- to serve as stem as well
- */
- if (delta_pitch < 0
- && (scm_to_int (prev_primitive->get_property ("primitive"))
- & MLP_LONGA))
- {
- delta_pitch -= 6;
- // instead of number 6
- // the legth of the longa stem should be queried something like
- // Font_interface::get_default_font (ligature)->find_by_name
- // ("noteheads.s-2mensural").extent (Y_AXIS).length ()
- }
- prev_primitive->set_property ("join-right-amount",
- scm_int2num (delta_pitch));
- // perhaps set add-join as well
- }
- at_beginning = false;
- prev_primitive = primitive;
- prev_pitch = pitch;
- // apply_transition replacement ends
- }
+ for (int i = 0, s = primitives.size (); i < s; i++)
+ {
+ Grob_info info = primitives[i];
+ Item *primitive = dynamic_cast<Item *> (info.grob_);
+ int duration_log = Note_head::get_balltype (primitive);
+
+ Music *nr = info.music_cause ();
+
+ /*
+ ugh. why not simply check for pitch?
+ */
+ if (!nr->is_mus_type ("note-event"))
+ {
+ nr->origin ()->warning
+ (_f ("can not determine pitch of ligature primitive -> skipping"));
+ at_beginning = true;
+ continue;
+ }
+
+ int pitch = unsmob_pitch (nr->get_property ("pitch"))->steps ();
+ int delta_pitch = 0;
+
+ if (at_beginning)
+ {
+ if (i == s - 1)
+ {
+ // we can get here after invalid input
+ nr->origin ()->warning
+ (_f ("single note ligature - skipping"));
+ break;
+ }
+ prev_semibrevis = prev_brevis_shape = false;
+ prev_primitive = NULL;
+ }
+ else
+ {
+ delta_pitch = pitch - prev_pitch;
+ if (delta_pitch == 0)
+ {
+ nr->origin ()->warning
+ (_f ("prime interval within ligature -> skipping"));
+ at_beginning = true;
+ primitive->set_property ("primitive",
+ scm_int2num (MLP_NONE));
+ continue;
+ }
+ }
+
+ if (duration_log < -3 // is this possible at all???
+ || duration_log > 0)
+ {
+ nr->origin ()->warning
+ (_f ("mensural ligature: duration none of Mx, L, B, S -> skipping"));
+ primitive->set_property ("primitive",
+ scm_int2num (MLP_NONE));
+ at_beginning = true;
+ continue;
+ }
+
+ // apply_transition replacement begins
+ bool general_case = true;
+
+ // first check special cases
+ // 1. beginning
+ if (at_beginning)
+ {
+ // a. semibreves
+ if (duration_log == 0)
+ {
+ primitive->set_property ("primitive",
+ scm_int2num (MLP_UP | MLP_BREVIS));
+ prev_semibrevis = prev_brevis_shape = true;
+ general_case = false;
+ }
+ // b. descendens longa or brevis
+ else if (i < s - 1
+ && (unsmob_pitch (primitives[i + 1].music_cause ()
+ ->get_property ("pitch"))->steps () < pitch)
+ && duration_log > -3)
+ {
+ int left_stem = duration_log == -1 ? MLP_DOWN : 0;
+
+ primitive->set_property ("primitive",
+ scm_int2num (left_stem | MLP_BREVIS));
+ prev_brevis_shape = true;
+ prev_semibrevis = general_case = false;
+ }
+ }
+ // 2. initial semibrevis must be followed by another one
+ else if (prev_semibrevis)
+ {
+ prev_semibrevis = false;
+ if (duration_log == 0)
+ {
+ primitive->set_property ("primitive", scm_int2num (MLP_BREVIS));
+ general_case = false;
+ }
+ else
+ {
+ nr->origin ()->warning
+ (_f ("semibrevis must be followed by another one -> skipping"));
+ primitive->set_property ("primitive",
+ scm_int2num (MLP_NONE));
+ at_beginning = true;
+ continue;
+ }
+ }
+ // 3. semibreves are otherwise not allowed
+ else if (duration_log == 0)
+ {
+ nr->origin ()->warning
+ (_f ("semibreves can only appear at the beginning of a ligature,\n"
+ "and there may be only zero or two of them"));
+ primitive->set_property ("primitive",
+ scm_int2num (MLP_NONE));
+ at_beginning = true;
+ continue;
+ }
+ // 4. end, descendens
+ else if (i == s - 1 && delta_pitch < 0)
+ {
+ // brevis; previous note must be turned into flexa
+ if (duration_log == -1)
+ {
+ if (prev_brevis_shape)
+ {
+ prev_primitive->set_property
+ ("primitive",
+ scm_int2num
+ (MLP_FLEXA
+ | (scm_to_int (prev_primitive->get_property ("primitive"))
+ & MLP_DOWN)));
+ primitive->set_property ("primitive", scm_int2num (MLP_NONE));
+ break; // no more notes, no join
+ }
+ else
+ {
+ nr->origin ()->warning
+ (_f ("invalid ligatura ending:\n"
+ "when the last note is a descending brevis,\n"
+ "the penultimate note must be another one,\n"
+ "or the ligatura must be LB or SSB"));
+ primitive->set_property ("primitive", scm_int2num (MLP_NONE));
+ break;
+ }
+ }
+ // longa
+ else if (duration_log == -2)
+ {
+ primitive->set_property ("primitive", scm_int2num (MLP_BREVIS));
+ general_case = false;
+ }
+ // else maxima; fall through regular case below
+ }
+
+ if (general_case)
+ {
+ static int const shape[3] = {MLP_MAXIMA, MLP_LONGA, MLP_BREVIS};
+
+ primitive->set_property ("primitive",
+ scm_int2num (shape[duration_log + 3]));
+ prev_brevis_shape = duration_log == -1;
+ }
+
+ // join_primitives replacement
+ if (!at_beginning)
+ {
+ /*
+ if the previous note is longa-shaped and this note is lower,
+ then the joining line may hide the stem, so it is made longer
+ to serve as stem as well
+ */
+ if (delta_pitch < 0
+ && (scm_to_int (prev_primitive->get_property ("primitive"))
+ & MLP_LONGA))
+ {
+ delta_pitch -= 6;
+ // instead of number 6
+ // the legth of the longa stem should be queried something like
+ // Font_interface::get_default_font (ligature)->find_by_name
+ // ("noteheads.s-2mensural").extent (Y_AXIS).length ()
+ }
+ prev_primitive->set_property ("join-right-amount",
+ scm_int2num (delta_pitch));
+ // perhaps set add-join as well
+ }
+ at_beginning = false;
+ prev_primitive = primitive;
+ prev_pitch = pitch;
+ // apply_transition replacement ends
+ }
}
/*
Mensural_ligature_engraver::propagate_properties (Spanner *ligature,
Array<Grob_info> primitives)
{
- Real thickness =
- robust_scm2double (ligature->get_property ("thickness"), 1.4);
- thickness *=
- ligature->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
+ Real thickness
+ = robust_scm2double (ligature->get_property ("thickness"), 1.4);
+ thickness
+ *= ligature->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
- Real head_width =
- Font_interface::get_default_font (ligature)->
+ Real head_width
+ = Font_interface::get_default_font (ligature)->
find_by_name ("noteheads.s-1mensural").extent (X_AXIS).length ();
- Real flexa_width =
- robust_scm2double (ligature->get_property ("flexa-width"), 2);
- Real maxima_head_width =
- Font_interface::get_default_font (ligature)->
+ Real flexa_width
+ = robust_scm2double (ligature->get_property ("flexa-width"), 2);
+ Real maxima_head_width
+ = Font_interface::get_default_font (ligature)->
find_by_name ("noteheads.s-1neomensural").extent (X_AXIS).length ();
flexa_width *= Staff_symbol_referencer::staff_space (ligature);
for (int i = 0; i < primitives.size (); i++)
{
- Item *primitive = dynamic_cast<Item*> (primitives[i].grob_);
+ Item *primitive = dynamic_cast<Item *> (primitives[i].grob_);
int output = scm_to_int (primitive->get_property ("primitive"));
primitive->set_property ("thickness",
scm_make_real (thickness));
- switch (output & MLP_ANY) {
- case MLP_NONE:
- primitive->set_property ("head-width",
- scm_make_real (half_flexa_width));
- break;
- case MLP_BREVIS:
- case MLP_LONGA:
- primitive->set_property ("head-width",
- scm_make_real (head_width));
- break;
- case MLP_MAXIMA:
- primitive->set_property ("head-width",
- scm_make_real (maxima_head_width));
- break;
- case MLP_FLEXA:
- primitive->set_property ("head-width",
- scm_make_real (half_flexa_width));
- primitive->set_property ("flexa-width",
- scm_make_real (flexa_width));
- break;
- default:
- programming_error (_f ("unexpected case fall-through"));
- break;
- }
+ switch (output & MLP_ANY)
+ {
+ case MLP_NONE:
+ primitive->set_property ("head-width",
+ scm_make_real (half_flexa_width));
+ break;
+ case MLP_BREVIS:
+ case MLP_LONGA:
+ primitive->set_property ("head-width",
+ scm_make_real (head_width));
+ break;
+ case MLP_MAXIMA:
+ primitive->set_property ("head-width",
+ scm_make_real (maxima_head_width));
+ break;
+ case MLP_FLEXA:
+ primitive->set_property ("head-width",
+ scm_make_real (half_flexa_width));
+ primitive->set_property ("flexa-width",
+ scm_make_real (flexa_width));
+ break;
+ default:
+ programming_error (_f ("unexpected case fall-through"));
+ break;
+ }
}
}
Real distance = 0;
for (int i = 0; i < primitives.size (); i++)
{
- Item *current = dynamic_cast<Item*> (primitives[i].grob_);
+ Item *current = dynamic_cast<Item *> (primitives[i].grob_);
if (i == 0)
{
first = current;
current->translate_axis (distance, X_AXIS);
}
- distance +=
- scm_to_double (current->get_property ("head-width")) -
- scm_to_double (current->get_property ("thickness"));
+ distance
+ += scm_to_double (current->get_property ("head-width"))
+ - scm_to_double (current->get_property ("thickness"));
}
}
}
ADD_TRANSLATOR (Mensural_ligature_engraver,
-/* descr */ "Handles Mensural_ligature_events by glueing special ligature heads together.",
-/* creats*/ "MensuralLigature",
-/* accepts */ "ligature-event",
-/* acks */ "note-head-interface rest-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Handles Mensural_ligature_events by glueing special ligature heads together.",
+ /* creats*/ "MensuralLigature",
+ /* accepts */ "ligature-event",
+ /* acks */ "note-head-interface rest-interface",
+ /* reads */ "",
+ /* write */ "");
/*
mensural-ligature.cc -- implement Mensural_ligature
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2002--2005 Juergen Reuter <reuter@ipd.uka.de>,
- Pal Benko <benkop@freestart.hu>
+ Pal Benko <benkop@freestart.hu>
*/
-
#include <math.h>
#include "mensural-ligature.hh"
// and right endings due to slope.
Real ypos_correction = -0.1*staff_space * sign (slope);
Real slope_correction = 0.2*staff_space * sign (slope);
- Real corrected_slope = slope + slope_correction/width;
+ Real corrected_slope = slope + slope_correction / width;
if (solid) // this will come handy for colorated flexae
{
- Stencil solid_head =
- Lookup::beam (corrected_slope, width, height, 0.0);
+ Stencil solid_head
+ = Lookup::beam (corrected_slope, width, height, 0.0);
stencil.add_stencil (solid_head);
}
else // outline
{
- Stencil left_edge =
- Lookup::beam (corrected_slope, thickness, height, 0.0);
+ Stencil left_edge
+ = Lookup::beam (corrected_slope, thickness, height, 0.0);
stencil.add_stencil (left_edge);
- Stencil right_edge =
- Lookup::beam (corrected_slope, thickness, height, 0.0);
- right_edge.translate_axis (width-thickness, X_AXIS);
- right_edge.translate_axis (corrected_slope * (width-thickness), Y_AXIS);
+ Stencil right_edge
+ = Lookup::beam (corrected_slope, thickness, height, 0.0);
+ right_edge.translate_axis (width - thickness, X_AXIS);
+ right_edge.translate_axis (corrected_slope * (width - thickness), Y_AXIS);
stencil.add_stencil (right_edge);
- Stencil bottom_edge =
- Lookup::beam (corrected_slope, width, thickness, 0.0);
+ Stencil bottom_edge
+ = Lookup::beam (corrected_slope, width, thickness, 0.0);
bottom_edge.translate_axis (-0.5*height, Y_AXIS);
stencil.add_stencil (bottom_edge);
- Stencil top_edge =
- Lookup::beam (corrected_slope, width, thickness, 0.0);
+ Stencil top_edge
+ = Lookup::beam (corrected_slope, width, thickness, 0.0);
top_edge.translate_axis (+0.5*height, Y_AXIS);
stencil.add_stencil (top_edge);
}
{
delta_pitch = robust_scm2int (me->get_property ("delta-pitch"),
0);
- width =
- robust_scm2double (me->get_property ("flexa-width"), 2.0 * staff_space);
+ width
+ = robust_scm2double (me->get_property ("flexa-width"), 2.0 * staff_space);
}
if (primitive & MLP_SINGLE_HEAD)
{
return Stencil ();
}
- Real blotdiameter =
- (me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter")));
+ Real blotdiameter
+ = (me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter")));
if (primitive & MLP_STEM)
{
if (primitive & MLP_FLEXA)
{
pos += delta_pitch;
- add_ledger_lines(me, &out, pos, 0.5*delta_pitch, ledger_take_space);
+ add_ledger_lines (me, &out, pos, 0.5*delta_pitch, ledger_take_space);
}
#endif
#include "context.hh"
/**
- put stuff over or next to bars. Examples: bar numbers, marginal notes,
- rehearsal marks.
- */
+ put stuff over or next to bars. Examples: bar numbers, marginal notes,
+ rehearsal marks.
+*/
class Metronome_mark_engraver : public Engraver
{
public:
Item *text_;
Grob *bar_line_;
Music *mark_ev_;
-
- void create_items (Music*);
+
+ void create_items (Music *);
protected:
virtual void stop_translation_timestep ();
virtual bool try_music (Music *ev);
mark_ev_ = 0;
}
-void
+void
Metronome_mark_engraver::stop_translation_timestep ()
{
if (text_)
{
- Grob*mc = unsmob_grob (get_property( "currentMusicalColumn"));
+ Grob *mc = unsmob_grob (get_property ("currentMusicalColumn"));
text_->set_parent (mc, X_AXIS);
- text_->set_property ("side-support-elements" , get_property ("stavesFound"));
-
+ text_->set_property ("side-support-elements", get_property ("stavesFound"));
+
text_ = 0;
}
mark_ev_ = 0;
}
-
void
Metronome_mark_engraver::create_items (Music *rq)
{
if (text_)
return;
- text_ = make_item ("MetronomeMark", rq->self_scm () );
+ text_ = make_item ("MetronomeMark", rq->self_scm ());
}
-
bool
-Metronome_mark_engraver::try_music (Music* r)
+Metronome_mark_engraver::try_music (Music *r)
{
mark_ev_ = r;
return true;
SCM proc = get_property ("metronomeMarkFormatter");
SCM result = scm_call_2 (proc, mark_ev_->self_scm (),
- context ()->self_scm ());
-
+ context ()->self_scm ());
+
text_->set_property ("text", result);
}
}
ADD_TRANSLATOR (Metronome_mark_engraver,
-/* descr */ "Engrave metro nome marking. This delegates the formatting work "
- "to the function in the metronomeMarkFormatter property. "
- "The mark is put over all staves. "
- "The staves are taken from the @code{stavesFound} property, "
- "which is maintained by @code{@ref{Staff_collecting_engraver}}. "
-
- ,
-/* creats*/ "MetronomeMark",
-/* accepts */ "metronome-change-event",
- /* acks */ "",
-/* reads */ "stavesFound metronomeMarkFormatter",
-/* write */ "");
+ /* descr */ "Engrave metro nome marking. This delegates the formatting work "
+ "to the function in the metronomeMarkFormatter property. "
+ "The mark is put over all staves. "
+ "The staves are taken from the @code{stavesFound} property, "
+ "which is maintained by @code{@ref{Staff_collecting_engraver}}. ",
+ /* creats*/ "MetronomeMark",
+ /* accepts */ "metronome-change-event",
+ /* acks */ "",
+ /* reads */ "stavesFound metronomeMarkFormatter",
+ /* write */ "");
source file of the GNU LilyPond music typesetter
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
-
*/
#include <math.h>
#include "scm-hash.hh"
int
-get_tempo (Output_def * def,
+get_tempo (Output_def *def,
Moment one_beat_mom)
{
- SCM wis = ly_symbol2scm ("whole-in-seconds");
+ SCM wis = ly_symbol2scm ("whole-in-seconds");
Moment *w = unsmob_moment (def->lookup_variable (wis));
Moment wholes_per_min = Moment (60);
if (!w)
{
- programming_error ("wholes-in-seconds not set.");
+ programming_error ("wholes-in-seconds not set.");
wholes_per_min /= 4;
}
else
{
- wholes_per_min /= *w;
+ wholes_per_min /= *w;
}
-
- int beats_per_min = int ((wholes_per_min / one_beat_mom).main_part_);
+
+ int beats_per_min = int ((wholes_per_min / one_beat_mom).main_part_);
return int (beats_per_min);
}
void
-set_tempo (Output_def * def,
+set_tempo (Output_def *def,
Moment one_beat_mom,
int beats_per_minute_i)
{
Moment beats_per_second = Moment (beats_per_minute_i) / Moment (60);
- Moment m = Moment (1)/Moment (beats_per_second * one_beat_mom);
+ Moment m = Moment (1) / Moment (beats_per_second * one_beat_mom);
def->set_variable (ly_symbol2scm ("whole-in-seconds"), m.smobbed_copy ());
}
source file of the GNU LilyPond music typesetter
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#include "midi-item.hh"
#include "scm-option.hh"
#include "killing-cons.tcc"
-#define PITCH_WHEEL_TOP 0x3FFF
+#define PITCH_WHEEL_TOP 0x3FFF
#define PITCH_WHEEL_CENTER 0x2000
#define PITCH_WHEEL_BOTTOM 0x0000
-#define PITCH_WHEEL_RANGE (PITCH_WHEEL_TOP - PITCH_WHEEL_BOTTOM)
+#define PITCH_WHEEL_RANGE (PITCH_WHEEL_TOP - PITCH_WHEEL_BOTTOM)
-Midi_item*
-Midi_item::get_midi (Audio_item* a)
+Midi_item *
+Midi_item::get_midi (Audio_item *a)
{
- if (Audio_key* i = dynamic_cast<Audio_key*> (a))
+ if (Audio_key *i = dynamic_cast<Audio_key *> (a))
return new Midi_key (i);
- else if (Audio_instrument* i = dynamic_cast<Audio_instrument*> (a))
+ else if (Audio_instrument *i = dynamic_cast<Audio_instrument *> (a))
return i->str_.length () ? new Midi_instrument (i) : 0;
- else if (Audio_note* i = dynamic_cast<Audio_note*> (a))
+ else if (Audio_note *i = dynamic_cast<Audio_note *> (a))
return new Midi_note (i);
- else if (Audio_dynamic* i = dynamic_cast<Audio_dynamic*> (a))
+ else if (Audio_dynamic *i = dynamic_cast<Audio_dynamic *> (a))
return new Midi_dynamic (i);
- else if (Audio_piano_pedal* i = dynamic_cast<Audio_piano_pedal*> (a))
+ else if (Audio_piano_pedal *i = dynamic_cast<Audio_piano_pedal *> (a))
return new Midi_piano_pedal (i);
- else if (Audio_tempo* i = dynamic_cast<Audio_tempo*> (a))
+ else if (Audio_tempo *i = dynamic_cast<Audio_tempo *> (a))
return new Midi_tempo (i);
- else if (Audio_time_signature* i = dynamic_cast<Audio_time_signature*> (a))
+ else if (Audio_time_signature *i = dynamic_cast<Audio_time_signature *> (a))
return new Midi_time_signature (i);
- else if (Audio_text* i = dynamic_cast<Audio_text*> (a))
+ else if (Audio_text *i = dynamic_cast<Audio_text *> (a))
//return i->text_string_.length () ? new Midi_text (i) : 0;
return new Midi_text (i);
else
footer_string_ = footer_string;
header_string_ = header_string;
}
-
+
String
Midi_chunk::data_string () const
{
{
String str = header_string_;
String dat = data_string ();
- String length_string = String_convert::int2hex (dat.length ()
- + footer_string_.length (), 8, '0');
+ String length_string = String_convert::int2hex (dat.length ()
+ + footer_string_.length (), 8, '0');
length_string = String_convert::hex2bin (length_string);
str += length_string;
str += dat;
return String ("<duration: ") + ::to_string (seconds_) + ">";
}
-Midi_event::Midi_event (Moment delta_mom, Midi_item* midi)
+Midi_event::Midi_event (Moment delta_mom, Midi_item *midi)
{
delta_mom_ = delta_mom;
midi_ = midi;
/*
ugh. midi output badly broken since grace note hackage.
- */
+*/
String
Midi_event::to_string () const
{
- Rational rat_dt = (delta_mom_.main_part_ * Rational (384) +
- delta_mom_.grace_part_ * Rational (100))*Rational (4);
+ Rational rat_dt = (delta_mom_.main_part_ * Rational (384)
+ + delta_mom_.grace_part_ * Rational (100))*Rational (4);
int delta_i = int (rat_dt);
String delta_string = Midi_item::i2varint_string (delta_i);
return delta_string + midi_string;
}
-
Midi_header::Midi_header (int format_i, int tracks_i, int clocks_per_4_i)
{
String str;
-
+
String format_string = String_convert::int2hex (format_i, 4, '0');
str += String_convert::hex2bin (format_string);
set ("MThd", str, "");
}
-Midi_instrument::Midi_instrument (Audio_instrument* a)
+Midi_instrument::Midi_instrument (Audio_instrument *a)
{
audio_ = a;
audio_->str_.to_lower ();
/*
UGH. don't use eval.
- */
+ */
SCM proc = ly_lily_module_constant ("midi-program");
SCM program = scm_call_1 (proc, ly_symbol2scm (audio_->str_.to_str0 ()));
found = (program != SCM_BOOL_F);
if (found)
program_byte = scm_to_int (program);
else
- warning (_f ("no such MIDI instrument: `%s'", audio_->str_.to_str0 ()));
+ warning (_f ("no such MIDI instrument: `%s'", audio_->str_.to_str0 ()));
String str = ::to_string ((char) (0xc0 + channel_)); //YIKES! FIXME: Should be track. -rz
str += ::to_string ((char)program_byte);
Midi_item::i2varint_string (int i)
{
int buffer_i = i & 0x7f;
- while ((i >>= 7) > 0)
+ while ((i >>= 7) > 0)
{
buffer_i <<= 8;
buffer_i |= 0x80;
}
String str;
- while (1)
+ while (1)
{
str += ::to_string ((char)buffer_i);
if (buffer_i & 0x80)
return str;
}
-Midi_key::Midi_key (Audio_key*a)
+Midi_key::Midi_key (Audio_key *a)
{
audio_ = a;
}
{
warning (_ ("silly pitch"));
p = 0;
- }
+ }
return p;
}
// print warning if fine tuning was needed, HJJ
if (get_fine_tuning () != 0)
{
- warning (_f ("Experimental: temporarily fine tuning (of %d cents) a channel.",
- get_fine_tuning ()));
+ warning (_f ("Experimental: temporarily fine tuning (of %d cents) a channel.",
+ get_fine_tuning ()));
finetune = PITCH_WHEEL_CENTER;
// Move pitch wheel to a shifted position.
// The pitch wheel range (of 4 semitones) is multiplied by the cents.
- finetune += (PITCH_WHEEL_RANGE * get_fine_tuning ()) / (4 * 100);
+ finetune += (PITCH_WHEEL_RANGE *get_fine_tuning ()) / (4 * 100);
str += ::to_string ((char) (0xE0 + channel_));
str += ::to_string ((char) (finetune & 0x7F));
return str;
}
-Midi_note_off::Midi_note_off (Midi_note* n)
+Midi_note_off::Midi_note_off (Midi_note *n)
: Midi_note (n->audio_)
{
on_ = n;
// Anybody who hears any difference, or knows how this works?
// 0 should definitely be avoided, notes stick on some sound cards.
// 64 is supposed to be neutral
-
+
aftertouch_byte_ = 64;
}
// Move pitch wheel back to the central position.
str += ::to_string ((char) 0x00);
str += ::to_string ((char) (0xE0 + channel_));
- str += ::to_string ((char) (PITCH_WHEEL_CENTER & 0x7F));
+ str += ::to_string ((char) (PITCH_WHEEL_CENTER &0x7F));
str += ::to_string ((char) (PITCH_WHEEL_CENTER >> 7));
}
return str;
}
-Midi_dynamic::Midi_dynamic (Audio_dynamic* a)
+Midi_dynamic::Midi_dynamic (Audio_dynamic *a)
{
audio_ = a;
}
Main volume controller (per channel):
07 MSB
27 LSB
- */
+ */
static Real const full_scale = 127;
-
+
int volume = (int) (audio_->volume_*full_scale);
if (volume <= 0)
volume = 1;
return str;
}
-Midi_piano_pedal::Midi_piano_pedal (Audio_piano_pedal* a)
+Midi_piano_pedal::Midi_piano_pedal (Audio_piano_pedal *a)
{
audio_ = a;
}
return str;
}
-Midi_tempo::Midi_tempo (Audio_tempo* a)
+Midi_tempo::Midi_tempo (Audio_tempo *a)
{
audio_ = a;
}
// 00 00 00 3B chunk length (59)
// 00 FF 58 04 04 02 18 08 time signature
// 00 FF 51 03 07 A1 20 tempo
-
-// FF 59 02 sf mi Key Signature
-// sf = -7: 7 flats
-// sf = -1: 1 flat
-// sf = 0: key of C
-// sf = 1: 1 sharp
-// sf = 7: 7 sharps
-// mi = 0: major key
-// mi = 1: minor key
+
+ // FF 59 02 sf mi Key Signature
+ // sf = -7: 7 flats
+ // sf = -1: 1 flat
+ // sf = 0: key of C
+ // sf = 1: 1 sharp
+ // sf = 7: 7 sharps
+ // mi = 0: major key
+ // mi = 1: minor key
number_ = 0;
-
- char const* data_str0 = ""
+
+ char const *data_str0 = ""
// "00" "ff58" "0404" "0218" "08"
// "00" "ff51" "0307" "a120"
// why a key at all, in midi?
// "00" "ff59" "02" "00" "00"
// key: F (scsii-menuetto)
// "00" "ff59" "02" "ff" "00"
- ;
+ ;
String data_string;
// only for format 0 (currently using format 1)?
data_string += String_convert::hex2bin (data_str0);
- char const* footer_str0 = "00" "ff2f" "00";
+ char const *footer_str0 = "00" "ff2f" "00";
String footer_string = String_convert::hex2bin (footer_str0);
set ("MTrk", data_string, footer_string);
}
-void
-Midi_track::add (Moment delta_time_mom, Midi_item* midi)
+void
+Midi_track::add (Moment delta_time_mom, Midi_item *midi)
{
assert (delta_time_mom >= Moment (0));
- Midi_event * e = new Midi_event (delta_time_mom, midi);
+ Midi_event *e = new Midi_event (delta_time_mom, midi);
event_p_list_.append (new Killing_cons<Midi_event> (e, 0));
}
String str = Midi_chunk::data_string ();
if (midi_debug_global_b)
str += "\n";
- for (Cons<Midi_event> *i = event_p_list_.head_; i; i = i->next_)
+ for (Cons<Midi_event> *i = event_p_list_.head_; i; i = i->next_)
{
str += i->car_->to_string ();
if (midi_debug_global_b)
- str += "\n";
+ str += "\n";
}
return str;
}
Midi_stream::Midi_stream (String file_name)
{
file_name_string_ = file_name;
- out_file_ = fopen (file_name.to_str0(), "wb");
+ out_file_ = fopen (file_name.to_str0 (), "wb");
}
Midi_stream::~Midi_stream ()
fclose (out_file_);
}
-Midi_stream&
-Midi_stream::operator << (String str)
+Midi_stream &
+Midi_stream::operator<< (String str)
{
size_t sz = sizeof (Byte);
size_t n = str.length ();
return *this;
}
-Midi_stream&
-Midi_stream::operator << (Midi_item const& midi_c_r)
+Midi_stream &
+Midi_stream::operator<< (Midi_item const &midi_c_r)
{
String str = midi_c_r.to_string ();
source file of the GNU LilyPond music typesetter
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
- */
+ Jan Nieuwenhuizen <janneke@gnu.org>
+*/
#include "midi-walker.hh"
#include "midi-stream.hh"
#include "warn.hh"
-Midi_note_event::Midi_note_event ()
-{
+Midi_note_event::Midi_note_event ()
+{
ignore_b_ = false;
}
int
-compare (Midi_note_event const& left, Midi_note_event const& right)
+compare (Midi_note_event const &left, Midi_note_event const &right)
{
- Moment m = (left.key - right.key);
+ Moment m = (left.key - right.key);
- if (m<0)
+ if (m < 0)
return -1;
else if (m > 0)
return 1;
return 0;
}
-Midi_walker::Midi_walker (Audio_staff* audio_staff, Midi_track* track)
+Midi_walker::Midi_walker (Audio_staff *audio_staff, Midi_track *track)
{
track_ = track;
index_ = 0;
}
Midi_walker::~Midi_walker ()
-{
+{
// ugh
do_stop_notes (last_mom_ + Moment (Rational (10, 1)));
}
/**
- Find out if start_note event is needed, and do it if needed.
- */
-void
-Midi_walker::do_start_note (Midi_note* note)
+ Find out if start_note event is needed, and do it if needed.
+*/
+void
+Midi_walker::do_start_note (Midi_note *note)
{
- Audio_item* ptr = (*items_)[index_];
+ Audio_item *ptr = (*items_)[index_];
Moment stop_mom = note->get_length () + ptr->audio_column_->at_mom ();
bool play_start = true;
- for (int i = 0; i < stop_note_queue.size (); i++)
+ for (int i = 0; i < stop_note_queue.size (); i++)
{
/* if this pith already in queue */
- if (stop_note_queue[i].val->get_pitch () == note->get_pitch ())
+ if (stop_note_queue[i].val->get_pitch () == note->get_pitch ())
{
if (stop_note_queue[i].key < stop_mom)
{
/* let stopnote in queue be ignored,
- new stop note wins */
+ new stop note wins */
stop_note_queue[i].ignore_b_ = true;
/* don't replay start note, */
play_start = false;
delete note;
note = 0;
break;
- }
+ }
}
}
}
/**
- Output note events for all notes which end before #max_mom#
- */
+ Output note events for all notes which end before #max_mom#
+*/
void
Midi_walker::do_stop_notes (Moment max_mom)
{
- while (stop_note_queue.size () && stop_note_queue.front ().key <= max_mom)
+ while (stop_note_queue.size () && stop_note_queue.front ().key <= max_mom)
{
Midi_note_event e = stop_note_queue.get ();
if (e.ignore_b_)
delete e.val;
continue;
}
-
+
Moment stop_mom = e.key;
- Midi_note* note = e.val;
-
+ Midi_note *note = e.val;
+
output_event (stop_mom, note);
}
}
-/**
- Advance the track to #now#, output the item, and adjust current "moment".
- */
+/**
+ Advance the track to #now#, output the item, and adjust current "moment".
+*/
void
-Midi_walker::output_event (Moment now_mom, Midi_item* l)
+Midi_walker::output_event (Moment now_mom, Midi_item *l)
{
- Moment delta_t = now_mom - last_mom_ ;
+ Moment delta_t = now_mom - last_mom_;
last_mom_ = now_mom;
/*
this is not correct, but at least it doesn't crash when you
start with graces
- */
+ */
if (delta_t < Moment (0))
{
delta_t = Moment (0);
}
-
track_->add (delta_t, l);
}
void
Midi_walker::process ()
{
- Audio_item* audio = (*items_)[index_];
+ Audio_item *audio = (*items_)[index_];
do_stop_notes (audio->audio_column_->at_mom ());
- if (Midi_item* midi = Midi_item::get_midi (audio))
+ if (Midi_item *midi = Midi_item::get_midi (audio))
{
midi->channel_ = track_->channel_;
//midi->channel_ = track_->number_;
- if (Midi_note* note = dynamic_cast<Midi_note*> (midi))
+ if (Midi_note *note = dynamic_cast<Midi_note *> (midi))
{
if (note->get_length ().to_bool ())
do_start_note (note);
}
void
-Midi_walker::operator ++ (int)
+Midi_walker::operator++ (int)
{
assert (ok ());
index_++;
source file of the GNU LilyPond music typesetter
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
+ Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include <math.h>
#include "misc.hh"
#include "string.hh"
-
/*
- Return the 2-log, rounded down
- */
+ Return the 2-log, rounded down
+*/
int
intlog2 (int d)
{
assert (d);
int i = 0;
- while ((d != 1))
+ while ((d != 1))
{
d /= 2;
i++;
}
-
- assert (! (d/2));
+
+ assert (! (d / 2));
return i;
}
double
log_2 (double x)
{
- return log (x) /log (2.0);
+ return log (x) /log (2.0);
}
Array<String>
split_string (String s, char c)
{
- Array<String> rv;
+ Array<String> rv;
while (s.length ())
{
int i = s.index (c);
-
+
if (i == 0)
{
s = s.nomid_string (0, 1);
continue;
}
-
+
if (i < 0)
- i = s.length () ;
+ i = s.length ();
rv.push (s.cut_string (0, i));
s = s.nomid_string (0, i);
/*
modified-font-metric.cc -- declare Modified_font_metric
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include <cctype>
Real magnification)
{
magnification_ = magnification;
-
+
SCM desc = fm->description_;
Real total_mag = magnification * scm_to_double (scm_cdr (desc));
assert (total_mag);
-
+
description_ = scm_cons (scm_car (desc), scm_make_real (total_mag));
orig_ = fm;
}
return orig_->design_size ();
}
-
-Box
+Box
Modified_font_metric::get_indexed_char (int i) const
{
Box b = orig_->get_indexed_char (i);
b.scale (magnification_);
- return b;
+ return b;
}
-Box
+Box
Modified_font_metric::get_ascii_char (int i) const
{
Box b = orig_->get_ascii_char (i);
b.scale (magnification_);
- return b;
+ return b;
}
int
{
}
-/* TODO: put this klutchness behind ly:option switch. */
+/* TODO: put this klutchness behind ly:option switch. */
Box
Modified_font_metric::tex_kludge (String text) const
{
Interval ydims;
Real w = 0;
- for (int i = 0; i < text.length (); i++)
+ for (int i = 0; i < text.length (); i++)
{
- switch (text[i])
+ switch (text[i])
{
case '\\':
/* Accent marks use width of base letter */
- if (i +1 < text.length ())
- {
- if (text[i+1]=='\'' || text[i+1]=='`' || text[i+1]=='"'
- || text[i+1]=='^')
- {
- i++;
- break;
- }
- /* For string width \\ is a \ and \_ is a _. */
- if (text[i+1]=='\\' || text[i+1]=='_')
- break;
- }
+ if (i +1 < text.length ())
+ {
+ if (text[i + 1]=='\'' || text[i + 1]=='`' || text[i+1]=='"'
+ || text[i+1]=='^')
+ {
+ i++;
+ break;
+ }
+ /* For string width \\ is a \ and \_ is a _. */
+ if (text[i + 1]=='\\' || text[i+1]=='_')
+ break;
+ }
for (i++; (i < text.length ()) && !isspace (text[i])
&& text[i]!='{' && text[i]!='}'; i++)
Box b = get_ascii_char ((unsigned char)text[i]);
/* Use the width of 'x' for unknown characters */
- if (b[X_AXIS].length () == 0)
+ if (b[X_AXIS].length () == 0)
b = get_ascii_char ((unsigned char)'x');
w += b[X_AXIS].length ();
Real w = 0.0;
- for (int i = 0; i < text.length (); i++)
+ for (int i = 0; i < text.length (); i++)
{
Box b = get_ascii_char ((unsigned char)text[i]);
-
+
w += b[X_AXIS].length ();
- ydims.unite (b[Y_AXIS]);
+ ydims.unite (b[Y_AXIS]);
}
if (ydims.is_empty ())
ydims = Interval (0, 0);
- b = Box(Interval(0, w), ydims);
+ b = Box (Interval (0, w), ydims);
return b;
}
-Font_metric*
+Font_metric *
Modified_font_metric::original_font () const
{
return orig_;
SCM
Modified_font_metric::sub_fonts () const
{
- return orig_->sub_fonts();
+ return orig_->sub_fonts ();
}
-
+
String
Modified_font_metric::font_name () const
{
- return original_font ()->font_name();
+ return original_font ()->font_name ();
}
-/*
+/*
moment.cc -- implement Moment bindings
source file of the GNU LilyPond music typesetter
#include "moment.hh"
-
/* TODO: add optional factor argument. */
LY_DEFINE (ly_make_moment, "ly:make-moment",
2, 2, 0, (SCM n, SCM d, SCM gn, SCM gd),
Moment *ma = unsmob_moment (mom);
SCM_ASSERT_TYPE (ma, mom, SCM_ARG1, __FUNCTION__, "moment");
- return scm_from_int (ma->main_part_.numerator ());
+ return scm_from_int (ma->main_part_.numerator ());
}
LY_DEFINE (ly_moment_main_denominator, "ly:moment-main-denominator",
Moment *ma = unsmob_moment (mom);
SCM_ASSERT_TYPE (ma, mom, SCM_ARG1, __FUNCTION__, "moment");
- return scm_from_int (ma->main_part_.denominator ());
+ return scm_from_int (ma->main_part_.denominator ());
}
LY_DEFINE (ly_moment_less_p, "ly:moment<?",
Moment *mb = unsmob_moment (b);
SCM_ASSERT_TYPE (ma, a, SCM_ARG1, __FUNCTION__, "moment");
SCM_ASSERT_TYPE (mb, b, SCM_ARG2, __FUNCTION__, "moment");
- return ly_bool2scm (*ma < *mb);
+ return ly_bool2scm (*ma < *mb);
}
-/*
+/*
moment.cc -- implement Moment
source file of the GNU LilyPond music typesetter
Moment::Moment (int m)
{
main_part_ = Rational (m);
- grace_part_ = Rational ( 0);
+ grace_part_ = Rational (0);
}
Moment::Moment (Rational m, Rational g)
int
Moment::print_smob (SCM s, SCM port, scm_print_state *)
{
- Moment *r = (Moment *) SCM_CELL_WORD_1 (s);
-
+ Moment *r = (Moment *) SCM_CELL_WORD_1 (s);
+
scm_puts ("#<Mom ", port);
String str = r->to_string ();
scm_puts ((char *)str.to_str0 (), port);
scm_puts (">", port);
-
+
return 1;
}
Moment::as_scheme () const
{
return scm_list_5 (ly_symbol2scm ("ly:make-moment"),
- scm_from_int (main_part_.num()),
- scm_from_int (main_part_.den()),
- scm_from_int (grace_part_.num()),
- scm_from_int (grace_part_.den()));
+ scm_from_int (main_part_.num ()),
+ scm_from_int (main_part_.den ()),
+ scm_from_int (grace_part_.num ()),
+ scm_from_int (grace_part_.den ()));
}
-
SCM
Moment::equal_p (SCM a, SCM b)
{
Moment *m1 = unsmob_moment (a);
Moment *m2 = unsmob_moment (b);
-
+
return (*m1 == *m2) ? SCM_BOOL_T : SCM_BOOL_F;
}
}
void
-Moment::operator += (Moment const &src)
+Moment::operator+= (Moment const &src)
{
- main_part_ += src.main_part_ ;
+ main_part_ += src.main_part_;
grace_part_ += src.grace_part_;
}
void
-Moment::operator -= (Moment const &src)
+Moment::operator-= (Moment const &src)
{
- main_part_ -= src.main_part_ ;
+ main_part_ -= src.main_part_;
grace_part_ -= src.grace_part_;
}
only take the main part of SRC for multiplication.
*/
void
-Moment::operator *= (Moment const &src)
+Moment::operator*= (Moment const &src)
{
- main_part_ *= src.main_part_ ;
+ main_part_ *= src.main_part_;
grace_part_ *= src.main_part_;
}
only take the main part of SRC for multiplication.
*/
void
-Moment::operator /= (Moment const &src)
+Moment::operator/= (Moment const &src)
{
- main_part_ /= src.main_part_ ;
+ main_part_ /= src.main_part_;
grace_part_ /= src.main_part_;
}
String
Moment::to_string () const
{
- String s = main_part_.to_string ();
+ String s = main_part_.to_string ();
if (grace_part_)
{
s += "G" + grace_part_.to_string ();
}
Moment
-Moment::operator - () const
+Moment::operator- () const
{
Moment m;
- m.grace_part_ = - grace_part_;
- m. main_part_ = - main_part_ ;
+ m.grace_part_ = -grace_part_;
+ m. main_part_ = -main_part_;
return m;
}
-
#ifdef STREAM_SUPPORT
std::ostream &
-operator << (std::ostream &os, Moment const &m)
+operator<< (std::ostream &os, Moment const &m)
{
os << m.to_string ();
return os;
return *p;
}
-
bool
moment_less (SCM a, SCM b)
{
multi_measure_rest-engraver.cc -- implement Multi_measure_rest_engraver
(c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "multi-measure-rest.hh"
#include "moment.hh"
/**
- The name says it all: make multi measure rests
+ The name says it all: make multi measure rests
*/
class Multi_measure_rest_engraver : public Engraver
{
TRANSLATOR_DECLARATIONS (Multi_measure_rest_engraver);
protected:
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void process_music ();
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
virtual void finalize ();
private:
- Music * rest_ev_;
+ Music *rest_ev_;
Link_array<Music> text_events_;
int start_measure_;
Rational last_main_moment_;
Moment stop_moment_;
-
+
bool bar_seen_;
- Item *last_command_item_ ;
+ Item *last_command_item_;
Spanner *last_rest_;
Spanner *mmrest_;
}
bool
-Multi_measure_rest_engraver::try_music (Music* req)
+Multi_measure_rest_engraver::try_music (Music *req)
{
if (req->is_mus_type ("multi-measure-rest-event"))
{
rest_ev_ = req;
stop_moment_ = now_mom () + rest_ev_->get_length ();
-
+
return true;
}
else if (req->is_mus_type ("multi-measure-text-event"))
mmrest_ = make_spanner ("MultiMeasureRest", rest_ev_->self_scm ());
Spanner *sp
- = make_spanner ("MultiMeasureRestNumber", rest_ev_->self_scm () );
+ = make_spanner ("MultiMeasureRestNumber", rest_ev_->self_scm ());
numbers_.push (sp);
if (text_events_.size ())
for (int i = 0; i < text_events_.size (); i++)
{
- Music* e = text_events_[i];
+ Music *e = text_events_[i];
Spanner *sp
- = make_spanner ("MultiMeasureRestText", e->self_scm () );
+ = make_spanner ("MultiMeasureRestText", e->self_scm ());
SCM t = e->get_property ("text");
SCM dir = e->get_property ("direction");
sp->set_property ("text", t);
if (is_direction (dir))
sp->set_property ("direction", dir);
-
+
numbers_.push (sp);
}
/*
Stack different scripts.
- */
- Direction d = DOWN;
- do {
- Grob *last = 0;
- for (int i = 0; i <numbers_.size (); i++)
- {
- if (scm_int2num (d) == numbers_[i]->get_property ("direction"))
- {
- if (last)
- Side_position_interface::add_support (numbers_[i], last);
- last = numbers_[i];
- }
- }
- } while (flip (&d) != DOWN);
+ */
+ Direction d = DOWN;
+ do
+ {
+ Grob *last = 0;
+ for (int i = 0; i <numbers_.size (); i++)
+ {
+ if (scm_int2num (d) == numbers_[i]->get_property ("direction"))
+ {
+ if (last)
+ Side_position_interface::add_support (numbers_[i], last);
+ last = numbers_[i];
+ }
+ }
+ }
+ while (flip (&d) != DOWN);
+
}
- for (int i = 0 ; i < numbers_.size (); i++)
+ for (int i = 0; i < numbers_.size (); i++)
{
Side_position_interface::add_support (numbers_[i], mmrest_);
numbers_[i]->set_parent (mmrest_, Y_AXIS);
}
-
+
start_measure_
= scm_to_int (get_property ("currentBarNumber"));
}
/*
We can not do this earlier, as breakableSeparationItem is not yet there.
*/
-
+
if (bar_seen_)
{
Grob *cmc = unsmob_grob (get_property ("breakableSeparationItem"));
/*
Ugh, this is a kludge - need this for multi-measure-rest-grace.ly
- */
- last_command_item_ = dynamic_cast<Item*> (cmc);
+ */
+ last_command_item_ = dynamic_cast<Item *> (cmc);
}
- if (last_command_item_ && (mmrest_ || last_rest_))
+ if (last_command_item_ && (mmrest_ || last_rest_))
{
if (last_rest_)
{
last_command_item_ = 0;
}
}
-
- Moment mp(robust_scm2moment (get_property ("measurePosition"), Moment (0)));
+
+ Moment mp (robust_scm2moment (get_property ("measurePosition"), Moment (0)));
if (last_rest_)
{
last_rest_ = 0;
bar_seen_ = false;
- Moment mp (robust_scm2moment (get_property ("measurePosition"), Moment (0)));
+ Moment mp (robust_scm2moment (get_property ("measurePosition"), Moment (0)));
Moment now = now_mom ();
if (mmrest_
{
last_rest_ = mmrest_;
last_numbers_ = numbers_;
-
+
int cur = scm_to_int (get_property ("currentBarNumber"));
int num = cur - start_measure_;
mmrest_ = 0;
numbers_.clear ();
-
- Grob * last = last_numbers_.size () ? last_numbers_[0] : 0;
+
+ Grob *last = last_numbers_.size () ? last_numbers_[0] : 0;
if (last && last->get_property ("text") == SCM_EOL)
{
SCM thres = get_property ("restNumberThreshold");
int t = 1;
if (scm_is_number (thres))
t = scm_to_int (thres);
-
+
if (num <= t)
last->suicide ();
- else
+ else
{
SCM text
= scm_number_to_string (scm_int2num (num), scm_from_int (10));
}
ADD_TRANSLATOR (Multi_measure_rest_engraver,
-/* descr */
- "Engraves multi-measure rests that are produced with @code{R}. Reads "
-"measurePosition and currentBarNumber to determine what number to print "
-"over the MultiMeasureRest. Reads measureLength to determine if it "
-"should use a whole rest or a breve rest to represent 1 measure "
- ,
-/* creats*/ "MultiMeasureRest MultiMeasureRestNumber MultiMeasureRestText",
-/* accepts */ "multi-measure-rest-event multi-measure-text-event",
-/* acks */ "",
-/* reads */ "currentBarNumber restNumberThreshold breakableSeparationItem currentCommandColumn measurePosition measureLength",
-/* write */ "");
+ /* descr */
+ "Engraves multi-measure rests that are produced with @code{R}. Reads "
+ "measurePosition and currentBarNumber to determine what number to print "
+ "over the MultiMeasureRest. Reads measureLength to determine if it "
+ "should use a whole rest or a breve rest to represent 1 measure ",
+ /* creats*/ "MultiMeasureRest MultiMeasureRestNumber MultiMeasureRestText",
+ /* accepts */ "multi-measure-rest-event multi-measure-text-event",
+ /* acks */ "",
+ /* reads */ "currentBarNumber restNumberThreshold breakableSeparationItem currentCommandColumn measurePosition measureLength",
+ /* write */ "");
-/*
+/*
multi-measure-rest.cc -- implement Multi_measure_rest
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Jan Nieuwenhuizen <janneke@gnu.org>
-
- */
+*/
#include "multi-measure-rest.hh"
Multi_measure_rest::percent (SCM smob)
{
Grob *me = unsmob_grob (smob);
- Spanner *sp = dynamic_cast<Spanner*> (me);
-
- Stencil r = Percent_repeat_item_interface::x_percent (me, 1, 0.75, 1.6);
+ Spanner *sp = dynamic_cast<Spanner *> (me);
+
+ Stencil r = Percent_repeat_item_interface::x_percent (me, 1, 0.75, 1.6);
// ugh copy & paste.
-
+
Interval sp_iv;
Direction d = LEFT;
do
{
- Item * col = sp->get_bound (d)->get_column ();
+ Item *col = sp->get_bound (d)->get_column ();
Interval coldim = col->extent (0, X_AXIS);
- sp_iv[d] = coldim[-d] ;
+ sp_iv[d] = coldim[-d];
}
while ((flip (&d)) != LEFT);
Real x_off = 0.0;
- Real rx = sp->get_bound (LEFT)->relative_coordinate (0, X_AXIS);
+ Real rx = sp->get_bound (LEFT)->relative_coordinate (0, X_AXIS);
/*
we gotta stay clear of sp_iv, so move a bit to the right if
needed.
- */
- x_off += (sp_iv[LEFT] - rx) >? 0;
+ */
+ x_off += (sp_iv[LEFT] - rx) >? 0;
/*
center between stuff.
- */
+ */
x_off += sp_iv.length ()/ 2;
r.translate_axis (x_off, X_AXIS);
-
return r.smobbed_copy ();
}
MAKE_SCHEME_CALLBACK (Multi_measure_rest, print, 1);
SCM
-Multi_measure_rest::print (SCM smob)
+Multi_measure_rest::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
- Spanner * sp = dynamic_cast<Spanner*> (me);
+ Spanner *sp = dynamic_cast<Spanner *> (me);
Interval sp_iv;
Direction d = LEFT;
Grob *common = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
do
{
- Item * b = sp->get_bound (d);
+ Item *b = sp->get_bound (d);
- Interval coldim = (Separation_item::has_interface (b))
+ Interval coldim = (Separation_item::has_interface (b))
? Separation_item::relative_width (b, common)
: b->extent (common, X_AXIS);
- sp_iv[d] = coldim.is_empty () ? b->relative_coordinate (common, X_AXIS) : coldim[-d];
+ sp_iv[d] = coldim.is_empty () ? b->relative_coordinate (common, X_AXIS) : coldim[-d];
}
while ((flip (&d)) != LEFT);
Real space = sp_iv.length ();
- Real rx = sp->get_bound (LEFT)->relative_coordinate (0, X_AXIS);
+ Real rx = sp->get_bound (LEFT)->relative_coordinate (0, X_AXIS);
/*
we gotta stay clear of sp_iv, so move a bit to the right if
needed.
- */
- Real x_off = (sp_iv[LEFT] - rx) >? 0;
-
+ */
+ Real x_off = (sp_iv[LEFT] - rx) >? 0;
Stencil mol;
mol.add_stencil (symbol_stencil (me, space));
return mol.smobbed_copy ();
}
-
-
Stencil
Multi_measure_rest::symbol_stencil (Grob *me, Real space)
{
}
if (measures <= 0)
return Stencil ();
-
SCM limit = me->get_property ("expand-limit");
if (measures > scm_to_int (limit))
{
- Real padding = 0.15;
- Stencil s = big_rest (me, (1.0 - 2*padding) * space);
- s.translate_axis (padding * space, X_AXIS);
+ Real padding = 0.15;
+ Stencil s = big_rest (me, (1.0 - 2*padding) * space);
+ s.translate_axis (padding * space, X_AXIS);
return s;
}
{
Stencil s = musfont->find_by_name (Rest::glyph_name (me, -1, "", false));
- s.translate_axis ((space - s.extent (X_AXIS).length ())/2, X_AXIS);
-
+ s.translate_axis ((space - s.extent (X_AXIS).length ()) / 2, X_AXIS);
+
return s;
}
else
/*
ugh.
- */
+ */
if (Staff_symbol_referencer::get_position (me) == 0.0)
s.translate_axis (staff_space, Y_AXIS);
- s.translate_axis ((space - s.extent (X_AXIS).length ())/2, X_AXIS);
-
- return s ;
- }
+ s.translate_axis ((space - s.extent (X_AXIS).length ()) / 2, X_AXIS);
+
+ return s;
+ }
}
else
{
- return church_rest (me, musfont, measures, space);
+ return church_rest (me, musfont, measures, space);
}
}
-
/*
WIDTH can also be 0 to determine the minimum size of the object.
- */
+*/
Stencil
Multi_measure_rest::big_rest (Grob *me, Real width)
{
Real thick_thick = robust_scm2double (me->get_property ("thick-thickness"), 1.0);
Real hair_thick = robust_scm2double (me->get_property ("hair-thickness"), .1);
-
Real ss = Staff_symbol_referencer::staff_space (me);
Real slt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
- Real y = slt * thick_thick/2 * ss;
+ Real y = slt * thick_thick / 2 * ss;
Real ythick = hair_thick * slt * ss;
- Box b (Interval (0, 0 >? (width - 2 * ythick)), Interval (-y, y));
-
+ Box b (Interval (0, 0 >? (width - 2 * ythick)), Interval (-y, y));
+
Real blot = width ? (.8 * (y <? ythick)) : 0.0;
-
- Stencil m = Lookup::round_filled_box (b, blot);
+
+ Stencil m = Lookup::round_filled_box (b, blot);
Stencil yb = Lookup::round_filled_box (Box (Interval (-0.5, 0.5)* ythick, Interval (-ss, ss)), blot);
m.add_at_edge (X_AXIS, RIGHT, yb, 0, 0);
m.add_at_edge (X_AXIS, LEFT, yb, 0, 0);
m.align_to (X_AXIS, LEFT);
-
+
return m;
}
/*
Kirchenpause (?)
- */
+*/
Stencil
Multi_measure_rest::church_rest (Grob *me, Font_metric *musfont, int measures,
Real space)
{
- SCM mols = SCM_EOL;
+ SCM mols = SCM_EOL;
/* See Wanske pp. 125 */
int l = measures;
symbols_width += r.extent (X_AXIS).length ();
mols = scm_cons (r.smobbed_copy (), mols);
}
- else
+ else
{
int k;
if (l >= 4)
symbols_width += r.extent (X_AXIS).length ();
mols = scm_cons (r.smobbed_copy (), mols);
}
- count ++;
+ count++;
}
-
- /* Make outer padding this much bigger. */
+ /* Make outer padding this much bigger. */
Real outer_padding_factor = 1.5;
Real inner_padding = (space - symbols_width)
- / (2 * outer_padding_factor + (count-1));
+ / (2 * outer_padding_factor + (count - 1));
if (inner_padding < 0)
inner_padding = 1.0;
-
- Stencil mol;
- for (SCM s = mols; scm_is_pair (s); s = scm_cdr (s))
- mol.add_at_edge (X_AXIS, LEFT, *unsmob_stencil (scm_car (s)),
- inner_padding, 0);
+
+ Stencil mol;
+ for (SCM s = mols; scm_is_pair (s); s = scm_cdr (s))
+ mol.add_at_edge (X_AXIS, LEFT, *unsmob_stencil (scm_car (s)),
+ inner_padding, 0);
mol.align_to (X_AXIS, LEFT);
mol.translate_axis (outer_padding_factor * inner_padding, X_AXIS);
void
Multi_measure_rest::add_column (Grob *me, Item *c)
{
- add_bound_item (dynamic_cast<Spanner*> (me), c);
+ add_bound_item (dynamic_cast<Spanner *> (me), c);
}
MAKE_SCHEME_CALLBACK (Multi_measure_rest, set_spacing_rods, 1);
{
Grob *me = unsmob_grob (smob);
- Spanner*sp = dynamic_cast<Spanner*> (me);
- if (!(sp->get_bound (LEFT) && sp->get_bound (RIGHT)))
+ Spanner *sp = dynamic_cast<Spanner *> (me);
+ if (! (sp->get_bound (LEFT) && sp->get_bound (RIGHT)))
{
programming_error ("Multi_measure_rest::get_rods (): I am not spanned!");
return SCM_UNSPECIFIED;
Item *li = sp->get_bound (LEFT)->get_column ();
Item *ri = sp->get_bound (RIGHT)->get_column ();
Item *lb = li->find_prebroken_piece (RIGHT);
- Item *rb = ri->find_prebroken_piece (LEFT);
-
+ Item *rb = ri->find_prebroken_piece (LEFT);
+
Item *combinations[4][2] = {{li, ri},
{lb, ri},
{li, rb},
{lb, rb}};
Real sym_width = symbol_stencil (me, 0.0).extent (X_AXIS).length ();
-
+
for (int i = 0; i < 4; i++)
{
Item *li = combinations[i][0];
rod.distance_ = li->extent (li, X_AXIS)[BIGGER]
- ri->extent (ri, X_AXIS)[SMALLER]
/* 2.0 = magic! */
- + sym_width + 2.0;
-
+ + sym_width + 2.0;
+
Real minlen = robust_scm2double (me->get_property ("minimum-length"), 0);
rod.distance_ = max (rod.distance_, minlen);
rod.add_to_cols ();
-/*
+/*
music-constructor.cc -- implement Music_constructor
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "music-constructor.hh"
#include "warn.hh"
-static std::map<String, Music_ctor> *ctors_map_;
+static std::map < String, Music_ctor> *ctors_map_;
void
add_music_ctor (String s, Music_ctor c)
{
if (!ctors_map_)
- ctors_map_ = new std::map<String, Music_ctor>;
-
- (*ctors_map_)[s] = c;
+ ctors_map_ = new std::map < String, Music_ctor>;
+
+ (*ctors_map_)[s] = c;
}
Music_ctor
return (*ctors_map_)[s];
}
-Music *
+Music *
make_music (String s, SCM init)
{
Music_ctor c = get_music_ctor (s);
if (!c)
programming_error (String ("No constructor for music: ") + s);
assert (c);
-
+
return (*c) (init);
}
-/*
+/*
music-function.cc -- implement music_function
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "music-function.hh"
return 1;
}
-
LY_DEFINE (ly_make_music_function, "ly:make-music-function", 2, 0, 0,
(SCM signature, SCM func),
- "Make a function to process music, to be used for the "
+ "Make a function to process music, to be used for the "
"parser. @code{func} is the function, and @code{signature} describes "
"Its arguments. @code{signature} is a list containing either "
"@code{ly:music?} predicates or other type predicates.")
{
if (str != "")
str += "-";
-
+
if (scm_car (s) == Music_type_p_proc)
str += "music";
- else if (scm_car (s) == ly_lily_module_constant("markup?"))
+ else if (scm_car (s) == ly_lily_module_constant ("markup?"))
str += "markup";
else if (ly_c_procedure_p (scm_car (s)))
str += "scm";
if (str == "") str = "noarg";
scm_set_object_property_x (func, ly_symbol2scm ("music-function-signature"),
signature);
-
+
scm_set_object_property_x (func, ly_symbol2scm ("music-function-signature-keyword"),
ly_symbol2scm (str.to_str0 ()));
-
+
SCM_RETURN_NEWSMOB (music_function_tag, func);
}
return (SCM_NIMP (music_function) && SCM_CELL_TYPE (music_function) == music_function_tag);
}
-
SCM
get_music_function_transform (SCM music_function)
{
if (!is_music_function (music_function))
return SCM_UNDEFINED;
-
+
return SCM_CELL_OBJECT_1 (music_function);
}
scm_set_smob_print (music_function_tag, print_music_function);
}
-ADD_SCM_INIT_FUNC (music_function_tag, init_music_function);
+ADD_SCM_INIT_FUNC (music_function_tag, init_music_function);
/*
UGH. too many includes.
- */
+*/
#include "music-iterator.hh"
smobify_self ();
}
-Music_iterator::Music_iterator (Music_iterator const& )
+Music_iterator::Music_iterator (Music_iterator const &)
{
assert (false);
}
{
}
-Context *
+Context *
Music_iterator::get_outlet () const
{
return handle_.get_outlet ();
return false;
}
-
-
SCM
Music_iterator::get_static_get_iterator (Music *m)
{
- Music_iterator * p = 0;
+ Music_iterator *p = 0;
- SCM ctor = m->get_property ("iterator-ctor") ;
+ SCM ctor = m->get_property ("iterator-ctor");
SCM iter = SCM_EOL;
if (ly_c_procedure_p (ctor))
{
assert (m);
p->music_length_ = m->get_length ();
p->start_mom_ = m->start_mom ();
-
+
return iter;
}
-
Moment
Music_iterator::music_get_length () const
{
Music_iterator::get_iterator (Music *m) const
{
SCM ip = get_static_get_iterator (m);
- Music_iterator*p = unsmob_iterator (ip);
-
+ Music_iterator *p = unsmob_iterator (ip);
+
p->init_translator (m, get_outlet ());
-
+
p->construct_children ();
return ip;
}
/*
TODO: rename to prevent confusion between Context::try_music and
Iterator::try_music
-
- */
-Music_iterator*
+*/
+Music_iterator *
Music_iterator::try_music (Music *m) const
{
- bool b = get_outlet ()->try_music ((Music*)m); // ugh
- Music_iterator * it = b ? (Music_iterator*) this : 0; // ugh
+ bool b = get_outlet ()->try_music ((Music *)m); // ugh
+ Music_iterator *it = b ? (Music_iterator *) this : 0; // ugh
if (!it)
it = try_music_in_children (m);
return it;
}
-Music_iterator*
+Music_iterator *
Music_iterator::try_music_in_children (Music *) const
{
return 0;
SCM
Music_iterator::mark_smob (SCM smob)
{
- Music_iterator * mus = (Music_iterator *)SCM_CELL_WORD_1 (smob);
+ Music_iterator *mus = (Music_iterator *)SCM_CELL_WORD_1 (smob);
mus->derived_mark ();
/*
Careful with GC, although we intend the following as pointers
only, we _must_ mark them.
- */
+ */
if (mus->get_outlet ())
scm_gc_mark (mus->get_outlet ()->self_scm ());
if (mus->music_)
scm_gc_mark (mus->music_->self_scm ());
-
return SCM_EOL;
}
int
-Music_iterator::print_smob (SCM sm , SCM port, scm_print_state*)
+Music_iterator::print_smob (SCM sm, SCM port, scm_print_state*)
{
char s[1000];
return false;
}
-
bool
is_child_context (Context *me, Context *child)
{
{
child = child->get_parent_context ();
}
-
+
return child == me;
}
/*
move to context of child iterator if it is deeper down in the
hierarchy.
- */
+*/
void
-Music_iterator::descend_to_child (Context * child_report)
+Music_iterator::descend_to_child (Context *child_report)
{
- Context * me_report = get_outlet ();
+ Context *me_report = get_outlet ();
if (is_child_context (me_report, child_report))
set_context (child_report);
}
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "duration.hh"
LY_DEFINE (ly_music_length, "ly:music-length",
1, 0, 0, (SCM mus),
- "Get the length of music expression @var{mus}, and return as a @code{Moment} object.")
+ "Get the length of music expression @var{mus}, and return as a @code{Moment} object.")
{
Music *sc = unsmob_music (mus);
SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music");
}
LY_DEFINE (ly_music_property,
- "ly:music-property", 2, 0, 0, (SCM mus, SCM sym),
- "Get the property @var{sym} of music expression @var{mus}.\n"
- "If @var{sym} is undefined, return @code{' ()}.\n" )
+ "ly:music-property", 2, 0, 0, (SCM mus, SCM sym),
+ "Get the property @var{sym} of music expression @var{mus}.\n"
+ "If @var{sym} is undefined, return @code{' ()}.\n")
{
- Music * sc = unsmob_music (mus);
+ Music *sc = unsmob_music (mus);
SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music");
SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
}
LY_DEFINE (ly_music_set_property, "ly:music-set-property!",
- 3, 0, 0, (SCM mus, SCM sym, SCM val),
- "Set property @var{sym} in music expression @var{mus} to @var{val}.")
+ 3, 0, 0, (SCM mus, SCM sym, SCM val),
+ "Set property @var{sym} in music expression @var{mus} to @var{val}.")
{
- Music * sc = unsmob_music (mus);
+ Music *sc = unsmob_music (mus);
SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music");
SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
"Return the name of @var{music}.")
{
Music *m = unsmob_music (mus);
- SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__ , "music");
+ SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__, "music");
char const *nm = classname (m);
return scm_makfrom0str (nm);
/* todo: property args */
LY_DEFINE (ly_extended_make_music, "ly:make-bare-music",
2, 0, 0, (SCM type, SCM props),
- "Make a C++ music object of type @var{type}, initialize with\n"
- "@var{props}. \n\n"
- ""
- "This function is for internal use, and is only called by "
- "@code{make-music}, which is the preferred interface "
- "for creating music objects. "
- )
+ "Make a C++ music object of type @var{type}, initialize with\n"
+ "@var{props}. \n\n"
+ ""
+ "This function is for internal use, and is only called by "
+ "@code{make-music}, which is the preferred interface "
+ "for creating music objects. ")
{
SCM_ASSERT_TYPE (scm_is_string (type), type, SCM_ARG1, __FUNCTION__, "string");
SCM s = make_music (ly_scm2string (type), props)->self_scm ();
/* todo: property args */
LY_DEFINE (ly_music_mutable_properties, "ly:music-mutable-properties",
- 1, 0, 0, (SCM mus),
- "Return an alist containing the mutable properties of @var{mus}.\n"
- "The immutable properties are not available, since "
- "they are constant and initialized by the "
+ 1, 0, 0, (SCM mus),
+ "Return an alist containing the mutable properties of @var{mus}.\n"
+ "The immutable properties are not available, since "
+ "they are constant and initialized by the "
"@code{make-music} function.\n")
{
Music *m = unsmob_music (mus);
}
LY_DEFINE (ly_music_deep_copy, "ly:music-deep-copy",
- 1, 0, 0, (SCM m),
- "Copy @var{m} and all sub expressions of @var{m}")
+ 1, 0, 0, (SCM m),
+ "Copy @var{m} and all sub expressions of @var{m}")
{
SCM copy = m;
if (unsmob_music (m))
}
else if (scm_is_pair (m))
copy = scm_cons (ly_music_deep_copy (scm_car (m)),
- ly_music_deep_copy (scm_cdr (m)));
+ ly_music_deep_copy (scm_cdr (m)));
return copy;
}
LY_DEFINE (ly_music_transpose, "ly:music-transpose",
- 2, 0, 0, (SCM m, SCM p),
- "Transpose @var{m} such that central C is mapped to @var{p}. "
- "Return @var{m}.")
+ 2, 0, 0, (SCM m, SCM p),
+ "Transpose @var{m} such that central C is mapped to @var{p}. "
+ "Return @var{m}.")
{
- Music * sc = unsmob_music (m);
- Pitch * sp = unsmob_pitch (p);
+ Music *sc = unsmob_music (m);
+ Pitch *sp = unsmob_pitch (p);
SCM_ASSERT_TYPE (sc, m, SCM_ARG1, __FUNCTION__, "music");
SCM_ASSERT_TYPE (sp, p, SCM_ARG2, __FUNCTION__, "pitch");
/*
TODO: should take moment factor?
- */
+*/
LY_DEFINE (ly_music_compress, "ly:music-compress",
- 2, 0, 0, (SCM m, SCM factor),
- "Compress music object @var{m} by moment @var{factor}."
- )
+ 2, 0, 0, (SCM m, SCM factor),
+ "Compress music object @var{m} by moment @var{factor}.")
{
- Music * sc = unsmob_music (m);
+ Music *sc = unsmob_music (m);
SCM_ASSERT_TYPE (sc, m, SCM_ARG1, __FUNCTION__, "music");
SCM_ASSERT_TYPE (unsmob_moment (factor), factor, SCM_ARG2, __FUNCTION__, "moment");
-
+
sc->compress (*unsmob_moment (factor));
return sc->self_scm ();
}
LY_DEFINE (ly_music_duration_length, "ly:music-duration-length", 1, 0, 0,
- (SCM mus),
- "Extract the duration field from @var{mus}, and return the length.")
+ (SCM mus),
+ "Extract the duration field from @var{mus}, and return the length.")
{
- Music* m = unsmob_music (mus);
+ Music *m = unsmob_music (mus);
SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__, "Music");
-
+
Duration *d = unsmob_duration (m->get_property ("duration"));
- Moment l ;
-
+ Moment l;
+
if (d)
{
- l = d->get_length ();
+ l = d->get_length ();
}
else
programming_error ("Music has no duration");
return l.smobbed_copy ();
-
-}
+}
LY_DEFINE (ly_music_duration_compress, "ly:music-duration-compress", 2, 0, 0,
- (SCM mus, SCM fact),
- "Compress @var{mus} by factor @var{fact}, which is a @code{Moment}.")
+ (SCM mus, SCM fact),
+ "Compress @var{mus} by factor @var{fact}, which is a @code{Moment}.")
{
- Music* m = unsmob_music (mus);
- Moment * f = unsmob_moment (fact);
+ Music *m = unsmob_music (mus);
+ Moment *f = unsmob_moment (fact);
SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__, "Music");
SCM_ASSERT_TYPE (f, fact, SCM_ARG2, __FUNCTION__, "Moment");
-
+
Duration *d = unsmob_duration (m->get_property ("duration"));
if (d)
m->set_property ("duration", d->compressed (f->main_part_).smobbed_copy ());
return SCM_UNSPECIFIED;
}
-
-
/*
This is hairy, since the scale in a key-change event may contain
octaveless notes.
- TODO: this should use ly:pitch.
- */
+ TODO: this should use ly:pitch.
+*/
LY_DEFINE (ly_transpose_key_alist, "ly:transpose-key-alist",
- 2, 0, 0, (SCM l, SCM pit),
- "Make a new key alist of @var{l} transposed by pitch @var{pit}")
+ 2, 0, 0, (SCM l, SCM pit),
+ "Make a new key alist of @var{l} transposed by pitch @var{pit}")
{
SCM newlist = SCM_EOL;
Pitch *p = unsmob_pitch (pit);
-
+
for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
{
SCM key = scm_caar (s);
orig = orig.transposed (*p);
SCM key = scm_cons (scm_int2num (orig.get_octave ()),
- scm_int2num (orig.get_notename ()));
+ scm_int2num (orig.get_notename ()));
newlist = scm_cons (scm_cons (key, scm_int2num (orig.get_alteration ())),
- newlist);
+ newlist);
}
else if (scm_is_number (key))
{
-/*
+/*
music-sequence.cc -- implement Music_sequence
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
void
transpose_music_list (SCM lst, Pitch rq)
{
- for (SCM s = lst; scm_is_pair (s); s = scm_cdr (s))
- unsmob_music (scm_car (s))->transpose (rq);
+ for (SCM s = lst; scm_is_pair (s); s = scm_cdr (s))
+ unsmob_music (scm_car (s))->transpose (rq);
}
Moment
-Music_sequence::cumulative_length (SCM l)
+Music_sequence::cumulative_length (SCM l)
{
Moment cumulative;
- Moment last_len;
+ Moment last_len;
- for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
+ for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
{
Moment l = unsmob_music (scm_car (s))->get_length ();
if (last_len.grace_part_ && l.main_part_)
last_len.grace_part_ = Rational (0);
cumulative += last_len;
- return cumulative;
+ return cumulative;
}
Moment
Music_sequence::maximum_length (SCM l)
{
Moment dur = 0;
- for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
+ for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
{
- Music * m = unsmob_music (scm_car (s));
+ Music *m = unsmob_music (scm_car (s));
Moment l = m->get_length ();
dur = dur >? l;
}
return dur;
}
-MAKE_SCHEME_CALLBACK(Music_sequence, maximum_length_callback, 1);
+MAKE_SCHEME_CALLBACK (Music_sequence, maximum_length_callback, 1);
SCM
Music_sequence::maximum_length_callback (SCM m)
{
- Music* me = unsmob_music (m);
- return maximum_length (me->get_property ("elements")).smobbed_copy();
+ Music *me = unsmob_music (m);
+ return maximum_length (me->get_property ("elements")).smobbed_copy ();
}
-MAKE_SCHEME_CALLBACK(Music_sequence, cumulative_length_callback, 1);
+MAKE_SCHEME_CALLBACK (Music_sequence, cumulative_length_callback, 1);
SCM
Music_sequence::cumulative_length_callback (SCM m)
{
- Music* me = unsmob_music (m);
- return cumulative_length (me->get_property ("elements")).smobbed_copy();
+ Music *me = unsmob_music (m);
+ return cumulative_length (me->get_property ("elements")).smobbed_copy ();
}
-
-MAKE_SCHEME_CALLBACK(Music_sequence, minimum_start_callback, 1);
+MAKE_SCHEME_CALLBACK (Music_sequence, minimum_start_callback, 1);
SCM
Music_sequence::minimum_start_callback (SCM m)
{
- Music* me = unsmob_music (m);
- return minimum_start (me->get_property ("elements")).smobbed_copy();
+ Music *me = unsmob_music (m);
+ return minimum_start (me->get_property ("elements")).smobbed_copy ();
}
-MAKE_SCHEME_CALLBACK(Music_sequence, first_start_callback, 1);
+MAKE_SCHEME_CALLBACK (Music_sequence, first_start_callback, 1);
SCM
Music_sequence::first_start_callback (SCM m)
{
- Music* me = unsmob_music (m);
- return first_start (me->get_property ("elements")).smobbed_copy();
+ Music *me = unsmob_music (m);
+ return first_start (me->get_property ("elements")).smobbed_copy ();
}
Pitch
int count = 0;
Pitch last = p;
- for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
+ for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
{
if (Music *m = unsmob_music (scm_car (s)))
{
last = m->to_relative_octave (last);
- if (!count ++)
+ if (!count++)
first = last;
}
}
return (ret_first) ? first : last;
}
-
void
compress_music_list (SCM l, Moment m)
{
- for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
+ for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
unsmob_music (scm_car (s))->compress (m);
}
Music_sequence::minimum_start (SCM l)
{
Moment m;
-
- for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
+
+ for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
{
m = m <? unsmob_music (scm_car (s))->start_mom ();
}
}
Moment
-Music_sequence::first_start (SCM l)
+Music_sequence::first_start (SCM l)
{
Moment m;
-
- for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
+
+ for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
{
- Music * mus = unsmob_music (scm_car (s));
+ Music *mus = unsmob_music (scm_car (s));
Moment l = mus->get_length ();
Moment s = mus->start_mom ();
if (l.to_bool () || s.to_bool ())
return m;
}
-MAKE_SCHEME_CALLBACK(Music_sequence, simultaneous_relative_callback, 2);
+MAKE_SCHEME_CALLBACK (Music_sequence, simultaneous_relative_callback, 2);
SCM
Music_sequence::simultaneous_relative_callback (SCM music, SCM pitch)
{
copied = ly_music_deep_copy (elts);
Pitch retval = music_list_to_relative (elts, p, false);
-
+
if (lily_1_8_relative)
{
-
+
Pitch retval_1_8 = music_list_to_relative (copied, p, true);
if (retval_1_8 != retval)
lily_1_8_compatibility_used = true;
return retval.smobbed_copy ();
}
-
-MAKE_SCHEME_CALLBACK(Music_sequence, event_chord_relative_callback, 2);
+MAKE_SCHEME_CALLBACK (Music_sequence, event_chord_relative_callback, 2);
SCM
Music_sequence::event_chord_relative_callback (SCM music, SCM pitch)
{
return music_list_to_relative (me->get_property ("elements"),
p, true).smobbed_copy ();
}
-
+
-/*
+/*
music-wrapper-iterator.cc -- implement Music_wrapper_iterator
-
+
source file of the GNU LilyPond music typesetter
-
- (c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- */
+ (c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#include "music-wrapper-iterator.hh"
}
void
-Music_wrapper_iterator::derived_substitute (Context *f, Context *t)
+Music_wrapper_iterator::derived_substitute (Context *f, Context *t)
{
if (child_iter_)
child_iter_->substitute_outlet (f, t);
void
Music_wrapper_iterator::construct_children ()
{
- Music * m = dynamic_cast<Music_wrapper const*> (get_music ())-> element ();
+ Music *m = dynamic_cast < Music_wrapper const *> (get_music ())-> element ();
child_iter_ = unsmob_iterator (get_iterator (m));
}
return child_iter_ && child_iter_->ok ();
}
-
void
Music_wrapper_iterator::process (Moment m)
{
child_iter_->process (m);
}
-
Moment
Music_wrapper_iterator::pending_moment () const
{
return child_iter_->pending_moment ();
}
-Music_iterator*
+Music_iterator *
Music_wrapper_iterator::try_music_in_children (Music *m) const
{
return child_iter_->try_music (m);
-/*
+/*
music-wrapper.cc -- implement Music_wrapper
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "music-wrapper.hh"
: Music (x)
{
if (!ly_c_procedure_p (length_callback_))
- length_callback_ = length_callback_proc;
+ length_callback_ = length_callback_proc;
if (!ly_c_procedure_p (start_callback_))
- start_callback_ = length_callback_proc;
+ start_callback_ = length_callback_proc;
}
-MAKE_SCHEME_CALLBACK(Music_wrapper, start_callback, 1);
+MAKE_SCHEME_CALLBACK (Music_wrapper, start_callback, 1);
SCM
Music_wrapper::start_callback (SCM m)
{
return elt->start_mom ().smobbed_copy ();
}
-MAKE_SCHEME_CALLBACK(Music_wrapper, length_callback, 1);
+MAKE_SCHEME_CALLBACK (Music_wrapper, length_callback, 1);
SCM
Music_wrapper::length_callback (SCM m)
{
- Music * me = unsmob_music (m);
+ Music *me = unsmob_music (m);
Music *elt = unsmob_music (me->get_property ("element"));
return elt->get_length ().smobbed_copy ();
}
-Music*
+Music *
Music_wrapper::element () const
{
return unsmob_music (get_property ("element"));
}
-
ADD_MUSIC (Music_wrapper);
/*
Music is anything that has duration and supports both time compression
and transposition.
-
+
In Lily, everything that can be thought to have a length and a pitch
- (which has a duration which can be transposed) is considered "music",
+ (which has a duration which can be transposed) is considered "music",
*/
bool
Music::internal_is_music_type (SCM k) const
SCM
Music::mark_smob (SCM m)
{
- Music *mus = (Music*) SCM_CELL_WORD_1 (m);
+ Music *mus = (Music *) SCM_CELL_WORD_1 (m);
scm_gc_mark (mus->immutable_property_alist_);
scm_gc_mark (mus->mutable_property_alist_);
return SCM_EOL;
return *unsmob_moment (res);
}
- return Moment(0);
+ return Moment (0);
}
Moment
Music::print_smob (SCM s, SCM p, scm_print_state*)
{
scm_puts ("#<Music ", p);
- Music* m = unsmob_music (s);
+ Music *m = unsmob_music (s);
SCM nm = m->get_property ("name");
if (scm_is_symbol (nm) || scm_is_string (nm))
new_pit = new_pit.to_relative_octave (last);
SCM check = get_property ("absolute-octave");
- if (scm_is_number (check) &&
- new_pit.get_octave () != scm_to_int (check))
+ if (scm_is_number (check)
+ && new_pit.get_octave () != scm_to_int (check))
{
Pitch expected_pit (scm_to_int (check),
new_pit.get_notename (),
new_pit.to_string ()));
new_pit = expected_pit;
}
-
+
set_property ("pitch", new_pit.smobbed_copy ());
-
+
last = new_pit;
}
SCM callback = get_property ("to-relative-callback");
if (ly_c_procedure_p (callback))
{
- Pitch * p = unsmob_pitch (scm_call_2 (callback, self_scm(), last.smobbed_copy ()));
+ Pitch *p = unsmob_pitch (scm_call_2 (callback, self_scm (), last.smobbed_copy ()));
return *p;
}
m->compress (factor);
compress_music_list (get_property ("elements"), factor);
- Duration *d = unsmob_duration (get_property ("duration"));
+ Duration *d = unsmob_duration (get_property ("duration"));
if (d)
set_property ("duration", d ->compressed (factor.main_part_).smobbed_copy ());
}
Music::transpose (Pitch delta)
{
if (to_boolean (get_property ("untransposable")))
- return ;
-
+ return;
+
for (SCM s = this->get_property_alist (true); scm_is_pair (s); s = scm_cdr (s))
{
SCM entry = scm_car (s);
SCM val = scm_cdr (entry);
- if (Pitch * p = unsmob_pitch (val))
+ if (Pitch *p = unsmob_pitch (val))
{
- Pitch transposed = p->transposed (delta);
+ Pitch transposed = p->transposed (delta);
scm_set_cdr_x (entry, transposed.smobbed_copy ());
if (abs (transposed.get_alteration ()) > DOUBLE_SHARP)
}
}
}
-
+
SCM elt = get_property ("element");
- if (Music* m = unsmob_music (elt))
+ if (Music *m = unsmob_music (elt))
m->transpose (delta);
transpose_music_list (get_property ("elements"), delta);
/*
- UGH - how do this more generically?
+ UGH - how do this more generically?
*/
SCM pa = get_property ("pitch-alist");
if (scm_is_pair (pa))
set_property ("origin", make_input (ip));
}
-Input*
+Input *
Music::origin () const
{
Input *ip = unsmob_input (get_property ("origin"));
return 0;
}
-Music*
+Music *
make_music_by_name (SCM sym)
{
SCM make_music_proc = ly_lily_module_constant ("make-music");
-/*
+/*
fingering-engraver.cc -- implement New_fingering_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "warn.hh"
#include "engraver.hh"
note_event_ = finger_event_ = 0;
follow_into_staff_ = false;
}
- static int compare (Finger_tuple const & c1, Finger_tuple const & c2)
+ static int compare (Finger_tuple const &c1, Finger_tuple const &c2)
{
- return c1.position_- c2.position_;
+ return c1.position_- c2.position_;
}
-
+
};
class New_fingering_engraver : public Engraver
Array<Finger_tuple> articulations_;
Link_array<Grob> heads_;
Grob *stem_;
-
+
public:
TRANSLATOR_DECLARATIONS (New_fingering_engraver);
protected:
virtual void stop_translation_timestep ();
virtual void acknowledge_grob (Grob_info);
- void add_fingering (Grob*, Music*, Music*);
- void add_script (Grob*, Music*, Music*);
+ void add_fingering (Grob *, Music *, Music *);
+ void add_script (Grob *, Music *, Music *);
void position_scripts ();
};
{
if (Rhythmic_head::has_interface (inf.grob_))
{
- Music * note_ev = inf.music_cause ();
+ Music *note_ev = inf.music_cause ();
if (!note_ev)
return;
-
+
SCM arts = note_ev->get_property ("articulations");
- for (SCM s = arts; scm_is_pair (s); s = scm_cdr (s))
+ for (SCM s = arts; scm_is_pair (s); s = scm_cdr (s))
{
- Music * m = unsmob_music (scm_car (s));
+ Music *m = unsmob_music (scm_car (s));
if (!m)
continue;
-
if (m->is_mus_type ("fingering-event"))
{
- add_fingering (inf.grob_ , m, note_ev);
+ add_fingering (inf.grob_, m, note_ev);
}
else if (m->is_mus_type ("text-script-event"))
{
else if (m->is_mus_type ("harmonic-event"))
{
inf.grob_->set_property ("style", ly_symbol2scm ("harmonic"));
- Grob * d = unsmob_grob (inf.grob_->get_property ("dot"));
+ Grob *d = unsmob_grob (inf.grob_->get_property ("dot"));
if (d)
- d->suicide ();
+ d->suicide ();
}
}
}
void
-New_fingering_engraver::add_script (Grob * head,
- Music * event,
- Music * )
+New_fingering_engraver::add_script (Grob *head,
+ Music *event,
+ Music *)
{
- Finger_tuple ft ;
+ Finger_tuple ft;
- Grob * g = make_item ("Script", event->self_scm () );
+ Grob *g = make_item ("Script", event->self_scm ());
make_script_from_event (g, &ft.follow_into_staff_, context (),
event->get_property ("articulation-type"), 0);
if (g)
{
- ft.script_ = g ;
-
+ ft.script_ = g;
+
articulations_.push (ft);
-
+
ft.script_->set_parent (head, X_AXIS);
}
-}
-
+}
void
-New_fingering_engraver::add_fingering (Grob * head,
- Music * event,
+New_fingering_engraver::add_fingering (Grob *head,
+ Music *event,
Music *hevent)
{
Finger_tuple ft;
- ft.script_ = make_item ("Fingering", event->self_scm () );
-
+ ft.script_ = make_item ("Fingering", event->self_scm ());
+
Side_position_interface::add_support (ft.script_, head);
int d = scm_to_int (event->get_property ("digit"));
-
+
/*
TODO:
-
+
Should add support for thumb. It's a little involved, since
the thumb lives in a different font. Maybe it should be moved?
-
- */
+
+ */
if (d > 5)
{
/*
- music for the softenon children?
- */
- event->origin ()->warning (_("music for the martians."));
+ music for the softenon children?
+ */
+ event->origin ()->warning (_ ("music for the martians."));
}
- SCM sstr = scm_number_to_string (scm_int2num (d), scm_int2num (10)) ;
+ SCM sstr = scm_number_to_string (scm_int2num (d), scm_int2num (10));
ft.script_->set_property ("text", sstr);
-
+
ft.finger_event_ = event;
ft.note_event_ = hevent;
ft.head_ = head;
positioning the fingerings, setting both X and Y coordinates.
*/
for (int i = 0; i < fingerings_.size (); i++)
- {
- fingerings_[i].position_ = scm_to_int (fingerings_[i].head_ -> get_property ( "staff-position"));
+ {
+ fingerings_[i].position_ = scm_to_int (fingerings_[i].head_ -> get_property ("staff-position"));
}
for (int i = fingerings_.size (); i--;)
- for (int j = heads_.size () ; j--;)
+ for (int j = heads_.size (); j--;)
Side_position_interface::add_support (fingerings_[i].script_, heads_[j]);
-
+
Array<Finger_tuple> up, down, horiz;
for (int i = fingerings_.size (); i--;)
{
SCM d = fingerings_[i].finger_event_->get_property ("direction");
if (to_dir (d))
{
- ((to_dir (d) == UP) ? up : down ).push (fingerings_[i]);
+ ((to_dir (d) == UP) ? up : down).push (fingerings_[i]);
fingerings_.del (i);
}
}
-
+
fingerings_.sort (&Finger_tuple::compare);
SCM orientations = get_property ("fingeringOrientations");
down.concat (fingerings_);
fingerings_.clear ();
}
-
+
for (int i = 0; i < horiz.size (); i++)
{
Finger_tuple ft = horiz[i];
- Grob* f = ft.script_;
+ Grob *f = ft.script_;
f->set_parent (ft.head_, X_AXIS);
f->set_parent (ft.head_, Y_AXIS);
f->add_offset_callback (Self_alignment_interface::centered_on_parent_proc, Y_AXIS);
for (int i = 0; i < up.size (); i++)
{
Finger_tuple ft = up[i];
- Grob* f = ft.script_;
+ Grob *f = ft.script_;
f->set_parent (ft.head_, X_AXIS);
f->set_property ("script-priority",
- scm_int2num (finger_prio + i));
+ scm_int2num (finger_prio + i));
f->add_offset_callback (Side_position_interface::aligned_side_proc, Y_AXIS);
f->add_offset_callback (Self_alignment_interface::centered_on_parent_proc, X_AXIS);
f->add_offset_callback (Self_alignment_interface::aligned_on_self_proc, X_AXIS);
-
+
f->set_property ("direction", scm_int2num (UP));
}
-
+
for (int i = 0; i < down.size (); i++)
{
Finger_tuple ft = down[i];
- Grob* f = ft.script_;
+ Grob *f = ft.script_;
f->set_parent (ft.head_, X_AXIS);
f->set_property ("script-priority",
- scm_int2num (finger_prio + down.size () - i));
+ scm_int2num (finger_prio + down.size () - i));
f->add_offset_callback (Self_alignment_interface::centered_on_parent_proc, X_AXIS);
f->add_offset_callback (Self_alignment_interface::aligned_on_self_proc, X_AXIS);
{
if (fingerings_.size ())
{
- for (int i = 0; i < fingerings_.size(); i++)
+ for (int i = 0; i < fingerings_.size (); i++)
if (stem_ && to_boolean (fingerings_[i].script_->get_property ("add-stem-support")))
Side_position_interface::add_support (fingerings_[i].script_, stem_);
position_scripts ();
fingerings_.clear ();
}
-
- for (int i = articulations_.size (); i--;)
+
+ for (int i = articulations_.size (); i--;)
{
Grob *script = articulations_[i].script_;
-
- for (int j = heads_.size () ; j--;)
+
+ for (int j = heads_.size (); j--;)
Side_position_interface::add_support (script, heads_[j]);
if (stem_ && to_dir (script->get_property ("side-relative-direction")))
script->set_property ("direction-source", stem_->self_scm ());
-
if (stem_ && to_boolean (script->get_property ("add-stem-support")))
Side_position_interface::add_support (script, stem_);
-
+
if (articulations_[i].follow_into_staff_)
{
script->add_offset_callback (Side_position_interface::quantised_position_proc, Y_AXIS);
- script->set_property ("staff-padding" , SCM_EOL);
+ script->set_property ("staff-padding", SCM_EOL);
}
}
articulations_.clear ();
}
-
New_fingering_engraver::New_fingering_engraver ()
{
- stem_ = 0;
+ stem_ = 0;
}
ADD_TRANSLATOR (New_fingering_engraver,
-/* descr */ "Create fingering-scripts for notes in a new chord. "
- "This engraver is ill-named, since it "
- "also takes care of articulations and harmonic note heads",
-/* creats*/ "Fingering",
-/* accepts */ "",
-/* acks */ "rhythmic-head-interface stem-interface",
-/* reads */ "fingeringOrientations",
-/* write */ "");
+ /* descr */ "Create fingering-scripts for notes in a new chord. "
+ "This engraver is ill-named, since it "
+ "also takes care of articulations and harmonic note heads",
+ /* creats*/ "Fingering",
+ /* accepts */ "",
+ /* acks */ "rhythmic-head-interface stem-interface",
+ /* reads */ "fingeringOrientations",
+ /* write */ "");
/*
new-lyric-combine-iterator.cc -- implement New_lyric_combine_music_iterator
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
{
public:
New_lyric_combine_music_iterator ();
- New_lyric_combine_music_iterator (New_lyric_combine_music_iterator const&src);
+ New_lyric_combine_music_iterator (New_lyric_combine_music_iterator const &src);
DECLARE_SCHEME_CALLBACK (constructor, ());
protected:
virtual void construct_children ();
virtual Moment pending_moment () const;
- virtual void do_quit ();
+ virtual void do_quit ();
virtual void process (Moment);
virtual Music_iterator *try_music_in_children (Music *) const;
virtual bool run_always ()const;
virtual void derived_mark () const;
virtual void derived_substitute (Context *, Context *);
private:
- bool start_new_syllable () ;
+ bool start_new_syllable ();
void find_voice ();
bool music_found_;
Context *lyrics_context_;
Context *music_context_;
SCM lyricsto_voice_name_;
-
- Music_iterator * lyric_iter_;
+
+ Music_iterator *lyric_iter_;
};
/*
Ugh, why static?
- */
+*/
static Music *busy_ev;
static Music *start_ev;
static Music *melisma_playing_ev;
/*
Ugh. out of place here.
- */
+ */
if (!busy_ev)
{
busy_ev
New_lyric_combine_music_iterator::start_new_syllable ()
{
bool b = music_context_->try_music (busy_ev);
-
+
if (!b)
return false;
if (!lyrics_context_)
return false;
-
+
if (!to_boolean (lyrics_context_->get_property ("ignoreMelismata")))
{
bool m = music_context_->try_music (melisma_playing_ev);
if (m)
return false;
}
-
+
return true;
}
Moment m;
m.set_infinite (1);
-
+
return m;
}
if (lyrics_context_ && lyrics_context_ == f)
lyrics_context_ = t;
if (music_context_ && music_context_ == f)
- music_context_ = t;
+ music_context_ = t;
}
-
void
New_lyric_combine_music_iterator::construct_children ()
{
lyricsto_voice_name_ = get_music ()->get_property ("associated-context");
-
find_voice ();
-
+
if (lyric_iter_)
lyrics_context_ = find_context_below (lyric_iter_->get_outlet (),
ly_symbol2scm ("Lyrics"), "");
We do not create a Lyrics context, because the user might
create one with a different name, and then we will not find that
one.
- */
+ */
}
void
voice_name = running;
if (scm_is_string (voice_name)
- && (!music_context_ || ly_scm2string (voice_name) != music_context_->id_string ()))
+ && (!music_context_ || ly_scm2string (voice_name) != music_context_->id_string ()))
{
/*
(spaghettini).
-
+
Need to set associatedVoiceContext again
- */
+ */
if (music_context_)
made_association_ = false;
-
+
Context *t = get_outlet ();
while (t && t->get_parent_context ())
t = t->get_parent_context ();
String name = ly_scm2string (voice_name);
Context *voice = find_context_below (t, ly_symbol2scm ("Voice"), name);
-
if (voice)
music_context_ = voice;
}
{
if (!made_association_)
{
- made_association_ = true;
+ made_association_ = true;
lyrics_context_->set_property ("associatedVoiceContext",
music_context_->self_scm ());
}
}
void
-New_lyric_combine_music_iterator::process (Moment )
+New_lyric_combine_music_iterator::process (Moment)
{
find_voice ();
if (!music_context_)
- return ;
-
+ return;
+
if (!music_context_->get_parent_context ())
{
/*
The melody has died.
We die too.
- */
+ */
if (lyrics_context_)
lyrics_context_->unset_property (ly_symbol2scm ("associatedVoiceContext"));
lyric_iter_ = 0;
music_context_ = 0;
}
-
+
if (music_context_
&& start_new_syllable () && lyric_iter_->ok ())
{
Moment m = lyric_iter_->pending_moment ();
lyric_iter_->process (m);
- music_found_ = true;
+ music_found_ = true;
}
}
lyric_iter_->quit ();
}
-
-
-Music_iterator*
+Music_iterator *
New_lyric_combine_music_iterator::try_music_in_children (Music *m) const
{
return lyric_iter_->try_music (m);
}
-
IMPLEMENT_CTOR_CALLBACK (New_lyric_combine_music_iterator);
Grob *me = unsmob_grob (element_smob);
Axis a = (Axis) scm_to_int (axis);
assert (a == X_AXIS);
-
- me = me->get_parent (a);
- if (! to_boolean (me->get_property ("positioning-done")))
+ me = me->get_parent (a);
+
+ if (! to_boolean (me->get_property ("positioning-done")))
{
me->set_property ("positioning-done", SCM_BOOL_T);
do_shifts (me);
}
-
+
return scm_make_real (0.0);
}
-
void
check_meshing_chords (Grob *me,
- Drul_array< Array < Real > > *offsets,
- Drul_array< Array < Slice > > const &extents,
- Drul_array<Link_array<Grob> > const &clash_groups)
-
+ Drul_array< Array<Real> > *offsets,
+ Drul_array< Array<Slice> > const &extents,
+ Drul_array < Link_array<Grob> > const &clash_groups)
+
{
if (!extents[UP].size () || ! extents[DOWN].size ())
return;
-
+
Grob *cu = clash_groups[UP][0];
Grob *cd = clash_groups[DOWN][0];
/* Too far apart to collide. */
if (ups[0] > dps.top () + 1)
- return;
+ return;
// FIXME: what's this?
bool merge_possible = (ups[0] >= dps[0]) && (ups.top () >= dps.top ());
-
-
/* Do not merge notes typeset in different style. */
- if ( !ly_c_equal_p (nu->get_property ("style"),
- nd->get_property ("style") ) )
+ if (!ly_c_equal_p (nu->get_property ("style"),
+ nd->get_property ("style")))
merge_possible = false;
-
+
int upball_type = Note_head::get_balltype (nu);
int dnball_type = Note_head::get_balltype (nd);
-
+
/* Do not merge whole notes (or longer, like breve, longa, maxima). */
if (merge_possible && (upball_type <= 0 || dnball_type <= 0))
merge_possible = false;
&& ((Rhythmic_head::duration_log (nu) == 1
&& Rhythmic_head::duration_log (nd) == 2)
|| (Rhythmic_head::duration_log (nu) == 2
- && Rhythmic_head::duration_log (nd) == 1)))
+ && Rhythmic_head::duration_log (nd) == 1)))
merge_possible = false;
-
/*
- this case (distant half collide),
-
- |
- x |
- | x
- |
+ this case (distant half collide),
- the noteheads may be closer than this case (close half collide)
+ |
+ x |
+ | x
+ |
+
+ the noteheads may be closer than this case (close half collide)
- |
- |
- x
- x
|
|
-
- */
-
+ x
+ x
+ |
+ |
+
+ */
+
/* TODO: filter out the 'o's in this configuration, since they're no
- part in the collision.
+ part in the collision.
|
- x|o
- x|o
- x
-
- */
-
+ x|o
+ x|o
+ x
+
+ */
+
bool close_half_collide = false;
- bool distant_half_collide = false;
- bool full_collide = false;
+ bool distant_half_collide = false;
+ bool full_collide = false;
int i = 0, j = 0;
while (i < ups.size () && j < dps.size ())
- {
- if (abs (ups[i] - dps[j]) == 1)
- {
+ {
+ if (abs (ups[i] - dps[j]) == 1)
+ {
+ merge_possible = false;
+ if (ups[i] > dps[j])
+ close_half_collide = true;
+ else
+ distant_half_collide = true;
+ }
+ else if (ups[i]== dps[j])
+ full_collide = true;
+ else if (ups[i] >dps[0] && ups[i] < dps.top ())
+ merge_possible = false;
+ else if (dps[j] >ups[0] && dps[j] < ups.top ())
merge_possible = false;
- if (ups[i] > dps[j])
- close_half_collide = true;
- else
- distant_half_collide = true;
- }
- else if (ups[i]== dps[j])
- full_collide = true;
- else if (ups[i] >dps[0] && ups[i] < dps.top ())
- merge_possible = false;
- else if (dps[j] >ups[0] && dps[j] < ups.top ())
- merge_possible = false;
-
- if (ups[i] < dps[j])
- i++;
- else if (ups[i] > dps[j])
- j++;
- else
- {
+
+ if (ups[i] < dps[j])
i++;
+ else if (ups[i] > dps[j])
j++;
- }
- }
+ else
+ {
+ i++;
+ j++;
+ }
+ }
full_collide = full_collide || (close_half_collide
&& distant_half_collide);
-
+
Drul_array<Real> center_note_shifts;
center_note_shifts[LEFT] = 0.0;
center_note_shifts[RIGHT] = 0.0;
-
Real shift_amount = 1;
bool touch = (ups[0] >= dps.top ());
shift_amount = 1;
else if (Rhythmic_head::dot_count (nu) < Rhythmic_head::dot_count (nd))
stem_to_stem = true;
-
+
if (merge_possible)
{
shift_amount = 0;
-
/* If possible, don't wipe any heads. Else, wipe shortest head,
or head with smallest amount of dots. Note: when merging
different heads, dots on the smaller one disappear. */
Grob *wipe_ball = 0;
Grob *dot_wipe_head = nu;
-
+
if (upball_type == dnball_type)
{
if (Rhythmic_head::dot_count (nd) < Rhythmic_head::dot_count (nu))
if (Grob *d = unsmob_grob (dot_wipe_head->get_property ("dot")))
d->suicide ();
}
-
+
if (wipe_ball && wipe_ball->is_live ())
{
wipe_ball->set_property ("transparent", SCM_BOOL_T);
/* TODO: these numbers are magic; should devise a set of grob props
to tune this behavior. */
else if (stem_to_stem)
- shift_amount = -abs (shift_amount) * 0.65;
+ shift_amount = -abs (shift_amount) * 0.65;
else if (close_half_collide && !touch)
shift_amount *= 0.52;
else if (distant_half_collide && !touch)
shift_amount *= 0.4;
else if (distant_half_collide || close_half_collide || full_collide)
shift_amount *= 0.5;
-
+
/* we're meshing. */
else if (Rhythmic_head::dot_count (nu) || Rhythmic_head::dot_count (nd))
shift_amount *= 0.1;
Grob *d = unsmob_grob (nd->get_property ("dot"));
Grob *parent = d->get_parent (X_AXIS);
-
/*
FIXME:
-
- |
- x . o
+
+ |
+ x . o
|
-
+
the . is put right of o which is erroneous o force-shifted
far to the right.
*/
}
void
-Note_collision_interface::do_shifts (Grob* me)
+Note_collision_interface::do_shifts (Grob *me)
{
- Drul_array< Link_array <Grob> > cg = get_clash_groups (me);
+ Drul_array< Link_array<Grob> > cg = get_clash_groups (me);
SCM autos (automatic_shift (me, cg));
SCM hand (forced_shift (me));
-
+
Direction d = UP;
Real wid = 0.0;
do
{
if (cg[d].size ())
{
- Grob *h = cg[d][0];
- wid = Note_column::first_head (h)->extent (h, X_AXIS).length () ;
+ Grob *h = cg[d][0];
+ wid = Note_column::first_head (h)->extent (h, X_AXIS).length ();
}
}
while (flip (&d) != UP);
-
+
Link_array<Grob> done;
Real left_most = 1e6;
-
+
Array<Real> amounts;
for (; scm_is_pair (hand); hand = scm_cdr (hand))
{
- Grob * s = unsmob_grob (scm_caar (hand));
+ Grob *s = unsmob_grob (scm_caar (hand));
Real amount = scm_to_double (scm_cdar (hand)) * wid;
done.push (s);
amounts.push (amount);
if (amount < left_most)
left_most = amount;
-
+
}
for (; scm_is_pair (autos); autos = scm_cdr (autos))
{
- Grob * s = unsmob_grob (scm_caar (autos));
+ Grob *s = unsmob_grob (scm_caar (autos));
Real amount = scm_to_double (scm_cdar (autos)) *wid;
-
+
if (!done.find (s))
{
done.push (s);
}
}
- for (int i = 0; i < amounts.size(); i++)
+ for (int i = 0; i < amounts.size (); i++)
{
done[i]->translate_axis (amounts[i] - left_most, X_AXIS);
}
}
-Drul_array< Link_array <Grob> >
-Note_collision_interface::get_clash_groups (Grob *me)
+Drul_array< Link_array<Grob>
+> Note_collision_interface::get_clash_groups (Grob *me)
{
- Drul_array<Link_array<Grob> > clash_groups;
-
+ Drul_array < Link_array<Grob> > clash_groups;
+
SCM s = me->get_property ("elements");
for (; scm_is_pair (s); s = scm_cdr (s))
{
SCM car = scm_car (s);
- Grob * se = unsmob_grob (car);
+ Grob *se = unsmob_grob (car);
if (Note_column::has_interface (se))
clash_groups[Note_column::dir (se)].push (se);
}
-
+
Direction d = UP;
do
{
}
/** This complicated routine moves note columns around horizontally to
- ensure that notes don't clash.
+ ensure that notes don't clash.
- This should be put into Scheme.
- */
+ This should be put into Scheme.
+*/
SCM
Note_collision_interface::automatic_shift (Grob *me,
- Drul_array< Link_array <Grob> >
- clash_groups)
+ Drul_array< Link_array<Grob>
+ > clash_groups)
{
- Drul_array<Array<int> > shifts;
- SCM tups = SCM_EOL;
+ Drul_array < Array<int> > shifts;
+ SCM tups = SCM_EOL;
-
Direction d = UP;
do
{
else
shift.push (0);
}
-
+
for (int i =1; i < shift.size (); i++)
{
- if (shift[i-1] == shift[i])
+ if (shift[i - 1] == shift[i])
{
clashes[0]->warning (_ ("Too many clashing notecolumns. Ignoring them."));
return tups;
}
while ((flip (&d))!= UP);
- Drul_array< Array < Slice > > extents;
- Drul_array< Array < Real > > offsets;
+ Drul_array< Array<Slice> > extents;
+ Drul_array< Array<Real> > offsets;
d = UP;
do
{
for (int i = 0; i < clash_groups[d].size (); i++)
{
Slice s (Note_column::head_positions_interval (clash_groups[d][i]));
- s[LEFT] --;
+ s[LEFT]--;
s[RIGHT]++;
extents[d].push (s);
offsets[d].push (d * 0.5 * i);
while ((flip (&d))!= UP);
/*
- do horizontal shifts of each direction
-
- |
- x||
- x||
- x|
- */
-
+ do horizontal shifts of each direction
+
+ |
+ x||
+ x||
+ x|
+ */
+
do
{
for (int i =1; i < clash_groups[d].size (); i++)
{
- Slice prev = extents[d][i-1];
+ Slice prev = extents[d][i - 1];
prev.intersect (extents[d][i]);
- if (prev.length ()> 0 ||
- (extents[-d].size () && d * (extents[d][i][-d] - extents[-d][0][d]) < 0))
- for (int j = i; j < clash_groups[d].size (); j++)
+ if (prev.length ()> 0
+ || (extents[-d].size () && d * (extents[d][i][-d] - extents[-d][0][d]) < 0))
+ for (int j = i; j < clash_groups[d].size (); j++)
offsets[d][j] += d * 0.5;
}
- }
+ }
while ((flip (&d))!= UP);
-
/*
Check if chords are meshing
- */
+ */
check_meshing_chords (me, &offsets, extents, clash_groups);
-
+
do
{
for (int i = 0; i < clash_groups[d].size (); i++)
tups = scm_cons (scm_cons (clash_groups[d][i]->self_scm (),
- scm_make_real (offsets[d][i])),
- tups);
+ scm_make_real (offsets[d][i])),
+ tups);
}
while (flip (&d) != UP);
return tups;
}
-
SCM
Note_collision_interface::forced_shift (Grob *me)
{
SCM tups = SCM_EOL;
-
+
SCM s = me->get_property ("elements");
for (; scm_is_pair (s); s = scm_cdr (s))
{
- Grob * se = unsmob_grob (scm_car (s));
+ Grob *se = unsmob_grob (scm_car (s));
- SCM force = se->get_property ("force-hshift");
+ SCM force = se->get_property ("force-hshift");
if (scm_is_number (force))
{
tups = scm_cons (scm_cons (se->self_scm (), force),
- tups);
+ tups);
}
}
return tups;
}
void
-Note_collision_interface::add_column (Grob*me, Grob* ncol)
+Note_collision_interface::add_column (Grob *me, Grob *ncol)
{
ncol->add_offset_callback (Note_collision_interface::force_shift_callback_proc, X_AXIS);
Axis_group_interface::add_element (me, ncol);
me->add_dependency (ncol);
}
-
ADD_INTERFACE (Note_collision_interface, "note-collision-interface",
- "An object that handles collisions between notes with different stem "
+ "An object that handles collisions between notes with different stem "
"directions and horizontal shifts. Most of the interesting properties "
"are to be set in @ref{note-column-interface}: these are "
- "@code{force-hshift} and @code{horizontal-shift}."
+ "@code{force-hshift} and @code{horizontal-shift}.",
- ,
-
"merge-differently-dotted merge-differently-headed positioning-done");
/*
TODO: figure out if we can prune this class. This is just an
annoying layer between (rest)collision & (note-head + stem)
- */
+*/
bool
-Note_column::has_rests (Grob*me)
+Note_column::has_rests (Grob *me)
{
return unsmob_grob (me->get_property ("rest"));
}
int
-Note_column::shift_compare (Grob *const &p1, Grob *const&p2)
+Note_column::shift_compare (Grob *const &p1, Grob *const &p2)
{
SCM s1 = p1->get_property ("horizontal-shift");
SCM s2 = p2->get_property ("horizontal-shift");
- int h1 = (scm_is_number (s1))? scm_to_int (s1) :0;
+ int h1 = (scm_is_number (s1))? scm_to_int (s1) :0;
int h2 = (scm_is_number (s2)) ? scm_to_int (s2):0;
return h1 - h2;
}
Item *
-Note_column::get_stem (Grob*me)
+Note_column::get_stem (Grob *me)
{
SCM s = me->get_property ("stem");
- return unsmob_item (s);
+ return unsmob_item (s);
}
-
+
Slice
Note_column::head_positions_interval (Grob *me)
{
- Slice iv;
+ Slice iv;
iv.set_empty ();
for (; scm_is_pair (h); h = scm_cdr (h))
{
Grob *se = unsmob_grob (scm_car (h));
-
+
int j = Staff_symbol_referencer::get_rounded_position (se);
iv.unite (Slice (j, j));
}
}
Direction
-Note_column::dir (Grob* me)
+Note_column::dir (Grob *me)
{
Grob *stem = unsmob_grob (me->get_property ("stem"));
if (stem && Stem::has_interface (stem))
return CENTER;
}
-
void
-Note_column::set_stem (Grob*me, Grob * stem)
+Note_column::set_stem (Grob *me, Grob *stem)
{
me->set_property ("stem", stem->self_scm ());
me->add_dependency (stem);
Axis_group_interface::add_element (me, stem);
}
-
-Grob*
-Note_column::get_rest (Grob*me)
+Grob *
+Note_column::get_rest (Grob *me)
{
return unsmob_grob (me->get_property ("rest"));
}
-
+
void
-Note_column::add_head (Grob*me, Grob *h)
+Note_column::add_head (Grob *me, Grob *h)
{
bool both = false;
if (Rest::has_interface (h))
}
/**
- translate the rest symbols vertically by amount DY, but only if
- they have no staff-position set.
+ translate the rest symbols vertically by amount DY, but only if
+ they have no staff-position set.
*/
void
-Note_column::translate_rests (Grob*me, int dy)
+Note_column::translate_rests (Grob *me, int dy)
{
- Grob * r = unsmob_grob (me->get_property ("rest"));
+ Grob *r = unsmob_grob (me->get_property ("rest"));
if (r && !scm_is_number (r->get_property ("staff-position")))
{
- r->translate_axis (dy * Staff_symbol_referencer::staff_space (r)/2.0, Y_AXIS);
+ r->translate_axis (dy * Staff_symbol_referencer::staff_space (r) / 2.0, Y_AXIS);
Grob *p = r->get_parent (Y_AXIS);
p->flush_extent_cache (Y_AXIS);
}
}
-
void
-Note_column::set_dotcol (Grob*me, Grob *d)
+Note_column::set_dotcol (Grob *me, Grob *d)
{
Axis_group_interface::add_element (me, d);
}
-
-
-Grob*
-Note_column::first_head (Grob*me)
+Grob *
+Note_column::first_head (Grob *me)
{
- Grob * st = get_stem (me);
- return st? Stem::first_head (st): 0;
+ Grob *st = get_stem (me);
+ return st? Stem::first_head (st): 0;
}
-
/*
- Return the first Accidentals grob that we find in a note-head.
- */
-Grob*
+ Return the first Accidentals grob that we find in a note-head.
+*/
+Grob *
Note_column::accidentals (Grob *me)
{
SCM heads = me->get_property ("note-heads");
- Grob * acc = 0;
+ Grob *acc = 0;
for (;scm_is_pair (heads); heads = scm_cdr (heads))
{
- Grob * h = unsmob_grob (scm_car (heads));
+ Grob *h = unsmob_grob (scm_car (heads));
acc = h ? unsmob_grob (h->get_property ("accidental-grob")) : 0;
if (acc)
break;
if (!acc)
return 0;
-
+
if (Accidental_placement::has_interface (acc->get_parent (X_AXIS)))
return acc->get_parent (X_AXIS);
/* compatibility. */
- return acc;
+ return acc;
}
-
-
ADD_INTERFACE (Note_column, "note-column-interface",
- "Stem and noteheads combined",
- "arpeggio note-heads rest-collision rest horizontal-shift stem accidentals force-hshift");
+ "Stem and noteheads combined",
+ "arpeggio note-heads rest-collision rest horizontal-shift stem accidentals force-hshift");
-/*
+/*
note-head-line-engraver.cc -- implement Note_head_line_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#include "engraver.hh"
#include "group-interface.hh"
TODO: have the line commit suicide if the notes are connected with
either slur or beam.
-
*/
class Note_head_line_engraver : public Engraver
{
virtual void stop_translation_timestep ();
private:
- Spanner* line_;
- Context* last_staff_;
+ Spanner *line_;
+ Context *last_staff_;
bool follow_;
- Grob* head_;
- Grob* last_head_;
+ Grob *head_;
+ Grob *last_head_;
};
Note_head_line_engraver::Note_head_line_engraver ()
head_ = info.grob_;
if (to_boolean (get_property ("followVoice")))
{
- Context * tr = context ();
- while (tr && !tr->is_alias (ly_symbol2scm ( "Staff")))
- tr = tr->get_parent_context () ;
+ Context *tr = context ();
+ while (tr && !tr->is_alias (ly_symbol2scm ("Staff")))
+ tr = tr->get_parent_context ();
if (tr
&& tr->is_alias (ly_symbol2scm ("Staff")) && tr != last_staff_)
}
}
-
void
Note_head_line_engraver::process_acknowledged_grobs ()
{
{
/* TODO: Don't follow if there's a beam.
- We can't do beam-stuff here, since beam doesn't exist yet.
- Should probably store follow_ in line_, and suicide at some
- later point */
+ We can't do beam-stuff here, since beam doesn't exist yet.
+ Should probably store follow_ in line_, and suicide at some
+ later point */
if (follow_)
line_ = make_spanner ("VoiceFollower", head_->self_scm ());
-
+
line_->set_bound (LEFT, last_head_);
line_->set_bound (RIGHT, head_);
-
follow_ = false;
}
}
-
-
ADD_TRANSLATOR (Note_head_line_engraver,
-/* descr */ "Engrave a line between two note heads, for example a glissando. If "
-" followVoice is set, staff switches also generate a line.",
-/* creats*/ "Glissando VoiceFollower",
-/* accepts */ "glissando-event",
-/* acks */ "rhythmic-head-interface",
-/* reads */ "followVoice",
-/* write */ "");
+ /* descr */ "Engrave a line between two note heads, for example a glissando. If "
+ " followVoice is set, staff switches also generate a line.",
+ /* creats*/ "Glissando VoiceFollower",
+ /* accepts */ "glissando-event",
+ /* acks */ "rhythmic-head-interface",
+ /* reads */ "followVoice",
+ /* write */ "");
clean up the mess left by ledger line handling.
*/
static Stencil
-internal_print (Grob *me, String * font_char)
+internal_print (Grob *me, String *font_char)
{
- SCM style = me->get_property ("style");
+ SCM style = me->get_property ("style");
if (!scm_is_symbol (style))
{
return Stencil ();
SCM proc = me->get_property ("glyph-name-procedure");
SCM scm_font_char = scm_call_2 (proc, log, style);
- Font_metric * fm = Font_interface::get_default_font (me);
+ Font_metric *fm = Font_interface::get_default_font (me);
Direction stem_dir = CENTER;
if (Grob *stem = unsmob_grob (me->get_property ("stem")))
programming_error ("Must have stem dir for note head");
}
}
-
+
Stencil out;
String prefix = "noteheads.";
- String idx =
- prefix + ((stem_dir == UP) ? "u" : "d") + ly_scm2string (scm_font_char);
+ String idx
+ = prefix + ((stem_dir == UP) ? "u" : "d") + ly_scm2string (scm_font_char);
out = fm->find_by_name (idx);
if (out.is_empty ())
{
idx = prefix + "s" + ly_scm2string (scm_font_char);
out = fm->find_by_name (idx);
}
-
- if (out.is_empty())
+
+ if (out.is_empty ())
{
me->warning (_f ("note head `%s' not found", idx.to_str0 ()));
}
return out;
}
-
MAKE_SCHEME_CALLBACK (Note_head, print, 1);
SCM
-Note_head::print (SCM smob)
+Note_head::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
return internal_print (me, &idx).smobbed_copy ();
}
-
MAKE_SCHEME_CALLBACK (Note_head, brew_ez_stencil, 1);
SCM
Note_head::brew_ez_stencil (SCM smob)
SCM cause = me->get_property ("cause");
SCM spitch = unsmob_music (cause)->get_property ("pitch");
- Pitch* pit = unsmob_pitch (spitch);
+ Pitch *pit = unsmob_pitch (spitch);
SCM idx = scm_int2num (pit->get_notename ());
SCM names = me->get_property ("note-names");
SCM charstr = SCM_EOL;
if (scm_is_vector (names))
charstr = scm_vector_ref (names, idx);
- else
+ else
{
char s[2] = "a";
s[0] = (pit->get_notename () + 2)%7 + 'a';
SCM at = scm_list_n (ly_symbol2scm ("ez-ball"),
charstr,
scm_int2num (b),
- scm_int2num (1-b),
+ scm_int2num (1 - b),
SCM_UNDEFINED);
Box bx (Interval (0, 1.0), Interval (-0.5, 0.5));
Stencil m (bx, at);
return m.smobbed_copy ();
}
-
Real
Note_head::stem_attachment_coordinate (Grob *me, Axis a)
{
SCM brewer = me->get_property ("print-function");
- Font_metric * fm = Font_interface::get_default_font (me);
-
+ Font_metric *fm = Font_interface::get_default_font (me);
+
if (brewer == Note_head::print_proc)
{
String key;
internal_print (me, &key);
- int k = fm->name_to_index (key) ;
+ int k = fm->name_to_index (key);
if (k >= 0)
{
Box b = fm->get_indexed_char (k);
return 2 * (wxwy[a] - v.center ()) / v.length ();
}
}
-
+
/*
Fallback
- */
+ */
SCM v = me->get_property ("stem-attachment-function");
if (!ly_c_procedure_p (v))
return 0.0;
-
+
SCM result = scm_call_2 (v, me->self_scm (), scm_int2num (a));
if (!scm_is_pair (result))
return 0.0;
result = (a == X_AXIS) ? scm_car (result) : scm_cdr (result);
-
+
return robust_scm2double (result, 0);
}
int
-Note_head::get_balltype (Grob*me)
+Note_head::get_balltype (Grob *me)
{
SCM s = me->get_property ("duration-log");
return scm_is_number (s) ? scm_to_int (s) <? 2 : 0;
}
ADD_INTERFACE (Note_head, "note-head-interface",
- "Note head",
- "note-names glyph-name-procedure accidental-grob style stem-attachment-function");
+ "Note head",
+ "note-names glyph-name-procedure accidental-grob style stem-attachment-function");
TRANSLATOR_DECLARATIONS (Note_heads_engraver);
protected:
- virtual bool try_music (Music *ev) ;
+ virtual bool try_music (Music *ev);
virtual void process_music ();
virtual void stop_translation_timestep ();
}
bool
-Note_heads_engraver::try_music (Music *m)
+Note_heads_engraver::try_music (Music *m)
{
if (m->is_mus_type ("note-event"))
{
}
else if (m->is_mus_type ("busy-playing-event"))
return note_evs_.size ();
-
+
return false;
}
-
void
Note_heads_engraver::process_music ()
{
for (int i = 0; i < note_evs_.size (); i++)
{
- Music * ev = note_evs_[i];
+ Music *ev = note_evs_[i];
Item *note = make_item ("NoteHead", ev->self_scm ());
-
+
Duration dur = *unsmob_duration (ev->get_property ("duration"));
note->set_property ("duration-log", scm_int2num (dur.duration_log ()));
if (dur.dot_count ())
{
- Item * d = make_item ("Dots", note->self_scm ());
+ Item *d = make_item ("Dots", note->self_scm ());
Rhythmic_head::set_dots (note, d);
-
+
if (dur.dot_count ()
!= robust_scm2int (d->get_property ("dot-count"), 0))
d->set_property ("dot-count", scm_int2num (dur.dot_count ()));
d->set_parent (note, Y_AXIS);
-
+
dots_.push (d);
}
if (scm_is_number (c0))
pos += scm_to_int (c0);
- note->set_property ("staff-position", scm_int2num (pos));
+ note->set_property ("staff-position", scm_int2num (pos));
/*
Shaped note heads change on step of the scale.
- */
+ */
SCM shape_vector = get_property ("shapeNoteStyles");
if (scm_is_vector (shape_vector))
{
SCM scm_tonic = get_property ("tonic");
- Pitch tonic (0, 0, 0);
+ Pitch tonic (0, 0, 0);
if (unsmob_pitch (scm_tonic))
tonic = *unsmob_pitch (scm_tonic);
-
- unsigned int delta = (pit->get_notename() - tonic.get_notename() + 7) % 7;
-
+
+ unsigned int delta = (pit->get_notename () - tonic.get_notename () + 7) % 7;
+
SCM style = SCM_EOL;
if (scm_c_vector_length (shape_vector) > delta
&& scm_is_symbol (scm_vector_ref (shape_vector, scm_from_int (delta))))
note->set_property ("style", style);
}
}
-
+
notes_.push (note);
}
}
note_evs_.clear ();
}
-
-
ADD_TRANSLATOR (Note_heads_engraver,
-/* descr */ "Generate noteheads.",
-/* creats*/ "NoteHead Dots",
-/* accepts */ "note-event busy-playing-event",
-/* acks */ "",
-/* reads */ "middleCPosition",
-/* write */ "");
+ /* descr */ "Generate noteheads.",
+ /* creats*/ "NoteHead Dots",
+ /* accepts */ "note-event busy-playing-event",
+ /* acks */ "",
+ /* reads */ "middleCPosition",
+ /* write */ "");
-/*
+/*
note-name-engraver.cc -- implement Note_name_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "engraver.hh"
#include "item.hh"
Link_array<Music> events_;
Link_array<Item> texts_;
- virtual bool try_music (Music*m);
+ virtual bool try_music (Music *m);
virtual void process_music ();
virtual void stop_translation_timestep ();
};
void
Note_name_engraver::process_music ()
{
- String s ;
+ String s;
for (int i = 0; i < events_.size (); i++)
{
if (i)
Pitch p = *unsmob_pitch (events_[i]->get_property ("pitch"));
if (!to_boolean (get_property ("printOctaveNames")))
- p = Pitch (-1, p.get_notename (), p.get_alteration ());
-
+ p = Pitch (-1, p.get_notename (), p.get_alteration ());
+
s += p.to_string ();
}
if (s.length ())
{
- Item * t = make_item ("NoteName", events_[0]->self_scm () );
+ Item *t = make_item ("NoteName", events_[0]->self_scm ());
t->set_property ("text", scm_makfrom0str (s.to_str0 ()));
texts_.push (t);
}
void
Note_name_engraver::stop_translation_timestep ()
{
- texts_.clear () ;
+ texts_.clear ();
events_.clear ();
}
-
Note_name_engraver::Note_name_engraver ()
{
}
ADD_TRANSLATOR (Note_name_engraver,
-/* descr */ "",
-/* creats*/ "NoteName",
-/* accepts */ "note-event",
-/* acks */ "",
-/* reads */ "printOctaveNames",
-/* write */ "");
+ /* descr */ "",
+ /* creats*/ "NoteName",
+ /* accepts */ "note-event",
+ /* acks */ "",
+ /* reads */ "printOctaveNames",
+ /* write */ "");
source file of the GNU LilyPond music typesetter
(c) 1996--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#include "performer.hh"
#include "audio-item.hh"
#include "warn.hh"
/**
-Convert evs to audio notes.
+ Convert evs to audio notes.
*/
-class Note_performer : public Performer {
+class Note_performer : public Performer
+{
public:
TRANSLATOR_DECLARATIONS (Note_performer);
-
+
protected:
- virtual bool try_music (Music *ev) ;
+ virtual bool try_music (Music *ev);
virtual void stop_translation_timestep ();
virtual void create_audio_elements ();
-
+
private:
Link_array<Music> note_evs_;
Link_array<Audio_note> notes_;
};
-void
+void
Note_performer::create_audio_elements ()
{
if (note_evs_.size ())
int transposing = 0;
SCM prop = get_property ("instrumentTransposition");
- if (unsmob_pitch (prop))
+ if (unsmob_pitch (prop))
transposing = unsmob_pitch (prop)->semitone_pitch ();
while (note_evs_.size ())
{
- Music* n = note_evs_.pop ();
- SCM pit = n->get_property ("pitch");
+ Music *n = note_evs_.pop ();
+ SCM pit = n->get_property ("pitch");
- if (Pitch * pitp = unsmob_pitch (pit))
+ if (Pitch *pitp = unsmob_pitch (pit))
{
- Audio_note* p = new Audio_note (*pitp, n->get_length (), - transposing);
+ Audio_note *p = new Audio_note (*pitp, n->get_length (), - transposing);
Audio_element_info info (p, n);
announce_element (info);
notes_.push (p);
}
}
-
void
Note_performer::stop_translation_timestep ()
{
notes_.clear ();
note_evs_.clear ();
}
-
+
bool
-Note_performer::try_music (Music* ev)
+Note_performer::try_music (Music *ev)
{
if (ev->is_mus_type ("note-event"))
{
}
else if (ev->is_mus_type ("busy-playing-event"))
return note_evs_.size ();
-
+
return false;
}
ADD_TRANSLATOR (Note_performer, "", "",
- "note-event busy-playing-event", "", "", "");
+ "note-event busy-playing-event", "", "", "");
Note_performer::Note_performer ()
{
-/*
+/*
note-spacing.cc -- implement Note_spacing
source file of the GNU LilyPond music typesetter
#include "output-def.hh"
/*
-
-TODO: detect hshifts due to collisions, and account for them in
-spacing?
-
-*/
+ TODO: detect hshifts due to collisions, and account for them in
+ spacing?
+*/
void
-Note_spacing::get_spacing (Grob *me, Item* right_col,
+Note_spacing::get_spacing (Grob *me, Item *right_col,
Real base_space, Real increment, Real *space, Real *fixed)
{
Drul_array<SCM> props (me->get_property ("left-items"),
- me->get_property ("right-items"));
+ me->get_property ("right-items"));
Direction d = LEFT;
- Direction col_dir = right_col->break_status_dir ();
+ Direction col_dir = right_col->break_status_dir ();
Drul_array<Interval> extents;
- Interval left_head_wid;
+ Interval left_head_wid;
do
{
- for (SCM s = props[d]; scm_is_pair (s); s = scm_cdr (s))
+ for (SCM s = props[d]; scm_is_pair (s); s = scm_cdr (s))
{
- Item * it = dynamic_cast<Item*> (unsmob_grob (scm_car (s)));
-
+ Item *it = dynamic_cast<Item *> (unsmob_grob (scm_car (s)));
+
if (d == RIGHT && it->break_status_dir () != col_dir)
{
it = it -> find_prebroken_piece (col_dir);
/*
some kind of mismatch, eg. a note column, that is behind a
linebreak.
- */
+ */
if (!it)
- continue;
+ continue;
Item *it_col = it->get_column ();
if (d == RIGHT && right_col != it_col)
continue;
-
+
if (Separation_item::has_interface (it))
{
extents[d].unite (Separation_item::width (it));
if (d == LEFT)
{
SCM r = it->get_property ("rest");
- Grob * g = unsmob_grob (r);
+ Grob *g = unsmob_grob (r);
if (!g)
- g = Note_column::first_head (it);
+ g = Note_column::first_head (it);
/*
Ugh. If Stem is switched off, we don't know what the
first note head will be.
- */
+ */
if (g)
left_head_wid = g->extent (it_col, X_AXIS);
}
-
+
extents[d].unite (it->extent (it_col, X_AXIS));
if (d == RIGHT)
{
- Grob * accs = Note_column::accidentals (it);
+ Grob *accs = Note_column::accidentals (it);
if (!accs)
accs = Note_column::accidentals (it->get_parent (X_AXIS));
-
+
if (accs)
{
- Interval v =
- Accidental_placement::get_relevant_accidental_extent (accs, it_col, me);
-
+ Interval v
+ = Accidental_placement::get_relevant_accidental_extent (accs, it_col, me);
+
extents[d].unite (v);
}
}
}
while (flip (&d) != LEFT);
-
/*
We look at the width of the note head, since smaller heads get less space
eg. a quarter rest gets almost 0.5 ss less horizontal space than a note.
FIXED also includes the left part of the right object.
*/
- *fixed =
- (left_head_wid.is_empty () ? increment :
- /*
- Size of the head:
- */
- (left_head_wid[RIGHT]+
+ *fixed
+ = (left_head_wid.is_empty () ? increment :
+ /*
+ Size of the head:
+ */
+ (left_head_wid[RIGHT]+
- /*
- What's sticking out of the head, eg. a flag:
- */
- (extents[LEFT][RIGHT] - left_head_wid[RIGHT])/2))
+ /*
+ What's sticking out of the head, eg. a flag:
+ */
+ (extents[LEFT][RIGHT] - left_head_wid[RIGHT]) / 2))
/*
What is sticking out of the right note:
- */
- + (extents[RIGHT].is_empty () ? 0.0 : - extents[RIGHT][LEFT] / 2);
+ */
+ + (extents[RIGHT].is_empty () ? 0.0 : - extents[RIGHT][LEFT] / 2);
/*
We don't do complicated stuff: (base_space - increment) is the
normal amount of white, which also determines the amount of
stretch. Upon (extreme) stretching, notes with accidentals should
stretch as much as notes without accidentals.
- */
- *space = (base_space - increment) + *fixed ;
+ */
+ *space = (base_space - increment) + *fixed;
if (!extents[RIGHT].is_empty ()
&& (Item::is_breakable (right_col)
Since we only take half of the right-object space above, the
barline will bump into the notes preceding it, if the right
thing is big. We add the rest of the extents here:
- */
-
+ */
+
*space += -extents[RIGHT][LEFT] / 2;
*fixed += -extents[RIGHT][LEFT] / 2;
}
-
+
stem_dir_correction (me, right_col, increment, space, fixed);
}
{
if (!me->is_live ())
return 0;
-
- return dynamic_cast<Item*> (me)->get_column ();
+
+ return dynamic_cast<Item *> (me)->get_column ();
}
/*
Compute the column of the right-items. This is a big function,
-since RIGHT-ITEMS may span more columns (eg. if a clef if inserted,
-this will add a new columns to RIGHT-ITEMS. Here we look at the
-columns, and return the left-most. If there are multiple columns, we
-prune RIGHT-ITEMS.
-
- */
+ since RIGHT-ITEMS may span more columns (eg. if a clef if inserted,
+ this will add a new columns to RIGHT-ITEMS. Here we look at the
+ columns, and return the left-most. If there are multiple columns, we
+ prune RIGHT-ITEMS.
+*/
Item *
-Note_spacing::right_column (Grob*me)
+Note_spacing::right_column (Grob *me)
{
if (!me->is_live ())
return 0;
-
+
SCM right = me->get_property ("right-items");
Item *mincol = 0;
int min_rank = INT_MAX;
bool prune = false;
- for (SCM s = right ; scm_is_pair (s) ; s = scm_cdr (s))
+ for (SCM s = right; scm_is_pair (s); s = scm_cdr (s))
{
- Item * ri = unsmob_item (scm_car (s));
+ Item *ri = unsmob_item (scm_car (s));
- Item * col = ri->get_column ();
+ Item *col = ri->get_column ();
int rank = Paper_column::get_rank (col);
if (rank < min_rank)
mincol = col;
}
}
-
+
if (prune)
{
// I'm a lazy bum. We could do this in-place.
- SCM newright = SCM_EOL;
- for (SCM s = right ; scm_is_pair (s) ; s = scm_cdr (s))
+ SCM newright = SCM_EOL;
+ for (SCM s = right; scm_is_pair (s); s = scm_cdr (s))
{
if (unsmob_item (scm_car (s))->get_column () == mincol)
newright = scm_cons (scm_car (s), newright);
me->set_property ("right-items", newright);
}
-
+
if (!mincol)
{
/*
- int r = Paper_column::get_rank (dynamic_cast<Item*>(me)->get_column ());
- programming_error (_f ("Spacing wish column %d has no right item.", r));
+ int r = Paper_column::get_rank (dynamic_cast<Item*>(me)->get_column ());
+ programming_error (_f ("Spacing wish column %d has no right item.", r));
*/
return 0;
down-stem + up-stem less.
TODO: have to check wether the stems are in the same staff.
-
*/
void
-Note_spacing::stem_dir_correction (Grob*me, Item * rcolumn,
+Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn,
Real increment,
- Real * space, Real *fixed)
+ Real *space, Real *fixed)
{
Drul_array<Direction> stem_dirs (CENTER, CENTER);
Drul_array<Interval> stem_posns;
- Drul_array<Interval> head_posns;
+ Drul_array<Interval> head_posns;
Drul_array<SCM> props (me->get_property ("left-items"),
- me->get_property ("right-items"));
+ me->get_property ("right-items"));
+
+ Drul_array<Spanner *> beams_drul (0, 0);
+ Drul_array<Grob *> stems_drul (0, 0);
- Drul_array<Spanner*> beams_drul (0, 0);
- Drul_array<Grob*> stems_drul (0, 0);
-
stem_dirs[LEFT] = stem_dirs[RIGHT] = CENTER;
Interval intersect;
Interval bar_xextent;
- Interval bar_yextent;
-
+ Interval bar_yextent;
+
bool correct_stem_dirs = true;
Direction d = LEFT;
bool acc_right = false;
-
+
do
{
- for (SCM s = props[d]; scm_is_pair (s); s = scm_cdr (s))
+ for (SCM s = props[d]; scm_is_pair (s); s = scm_cdr (s))
{
- Item * it = dynamic_cast<Item*> (unsmob_grob (scm_car (s)));
+ Item *it = dynamic_cast<Item *> (unsmob_grob (scm_car (s)));
if (d == RIGHT)
acc_right = acc_right || Note_column::accidentals (it);
-
+
Grob *stem = Note_column::get_stem (it);
if (!stem || !stem->is_live ())
{
it = it->find_prebroken_piece (rcolumn->break_status_dir ());
}
-
+
Grob *last = Separation_item::extremal_break_aligned_grob (it, LEFT, &bar_xextent);
if (last)
break;
}
- return ;
+ return;
}
-
+
if (Stem::is_invisible (stem))
{
correct_stem_dirs = false;
stems_drul[d] = stem;
beams_drul[d] = Stem::get_beam (stem);
-
+
Direction sd = Stem::get_direction (stem);
if (stem_dirs[d] && stem_dirs[d] != sd)
{
/*
Correction doesn't seem appropriate when there is a large flag
hanging from the note.
- */
+ */
if (d == LEFT
- && Stem::duration_log (stem) > 2 && !Stem::get_beam (stem))
+ && Stem::duration_log (stem) > 2 && !Stem::get_beam (stem))
{
correct_stem_dirs = false;
}
-
- Interval hp = Stem::head_positions (stem);
- if (!hp.is_empty())
+
+ Interval hp = Stem::head_positions (stem);
+ if (!hp.is_empty ())
{
- Real chord_start = hp[sd];
+ Real chord_start = hp[sd];
Real stem_end = Stem::stem_end_position (stem);
-
+
stem_posns[d] = Interval (chord_start <? stem_end, chord_start>? stem_end);
head_posns[d].unite (hp);
}
}
}
while (flip (&d) != LEFT);
-
/*
don't correct if accidentals are sticking out of the right side.
*/
if (acc_right)
- return ;
+ return;
Real correction = 0.0;
if (!bar_yextent.is_empty ())
{
- stem_dirs[RIGHT] = - stem_dirs[LEFT];
+ stem_dirs[RIGHT] = -stem_dirs[LEFT];
stem_posns[RIGHT] = bar_yextent;
}
-
+
if (correct_stem_dirs && stem_dirs[LEFT] *stem_dirs[RIGHT] == -1)
{
if (beams_drul[LEFT] && beams_drul[LEFT] == beams_drul[RIGHT])
{
-
+
/*
this is a knee: maximal correction.
*/
Real note_head_width = increment;
- Grob * st = stems_drul[RIGHT];
- Grob * head = st ? Stem::support_head (st) : 0;
+ Grob *st = stems_drul[RIGHT];
+ Grob *head = st ? Stem::support_head (st) : 0;
Interval head_extent;
if (head)
}
else
{
- intersect = stem_posns[LEFT];
+ intersect = stem_posns[LEFT];
intersect.intersect (stem_posns[RIGHT]);
correct_stem_dirs = correct_stem_dirs && !intersect.is_empty ();
{
correction = abs (intersect.length ());
-
/*
Ugh. 7 is hardcoded.
*/
- correction = (correction/7) <? 1.0;
- correction *= stem_dirs[LEFT] ;
- correction *=
- robust_scm2double (me->get_property ("stem-spacing-correction"), 0);
+ correction = (correction / 7) <? 1.0;
+ correction *= stem_dirs[LEFT];
+ correction
+ *= robust_scm2double (me->get_property ("stem-spacing-correction"), 0);
}
-
+
if (!bar_yextent.is_empty ())
{
correction *= 0.5;
/*
Correct for the following situation:
- X X
- | |
+ X X
+ | |
| |
| X |
| | |
========
- ^ move the center one to the left.
-
+ ^ move the center one to the left.
+
this effect seems to be much more subtle than the
stem-direction stuff (why?), and also does not scale with the
difference in stem length.
-
- */
-
+ */
+
Interval hp = head_posns[LEFT];
- hp.intersect (head_posns[RIGHT]);
+ hp.intersect (head_posns[RIGHT]);
if (!hp.is_empty ())
- return ;
+ return;
- Direction lowest =
- (head_posns[LEFT][DOWN] > head_posns[RIGHT][UP]) ? RIGHT : LEFT;
+ Direction lowest
+ = (head_posns[LEFT][DOWN] > head_posns[RIGHT][UP]) ? RIGHT : LEFT;
- Real delta = head_posns[-lowest][DOWN] - head_posns[lowest][UP] ;
+ Real delta = head_posns[-lowest][DOWN] - head_posns[lowest][UP];
Real corr = robust_scm2double (me->get_property ("stem-spacing-correction"), 0);
- corr = (delta <= 1) ? 0.0 : 0.25;
-
- correction = -lowest * corr ;
+ corr = (delta <= 1) ? 0.0 : 0.25;
+
+ correction = -lowest * corr;
}
*space += correction;
*/
}
-
-
ADD_INTERFACE (Note_spacing, "note-spacing-interface",
- "This object calculates spacing wishes for individual voices.",
- "left-items right-items stem-spacing-correction knee-spacing-correction");
+ "This object calculates spacing wishes for individual voices.",
+ "left-items right-items stem-spacing-correction knee-spacing-correction");
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "object-key-dumper.hh"
#include "moment.hh"
-LY_DEFINE(ly_make_dumper, "ly:make-dumper",
- 0, 0, 0,
- (),
- "Create a key dumper. "
- )
+LY_DEFINE (ly_make_dumper, "ly:make-dumper",
+ 0, 0, 0,
+ (),
+ "Create a key dumper. ")
{
Object_key_dumper *u = new Object_key_dumper ();
- SCM x = u->self_scm();
+ SCM x = u->self_scm ();
scm_gc_unprotect_object (x);
return x;
}
-LY_DEFINE(ly_dumper_definitions, "ly:dumper-definitions",
- 1, 0, 0,
- (SCM dumper),
- "Return list of key definitions. "
- )
+LY_DEFINE (ly_dumper_definitions, "ly:dumper-definitions",
+ 1, 0, 0,
+ (SCM dumper),
+ "Return list of key definitions. ")
{
Object_key_dumper *u = unsmob_key_dumper (dumper);
- SCM_ASSERT_TYPE(u, dumper, SCM_ARG1, __FUNCTION__, "dumper");
- return u->get_file_contents();
+ SCM_ASSERT_TYPE (u, dumper, SCM_ARG1, __FUNCTION__, "dumper");
+ return u->get_file_contents ();
}
-LY_DEFINE(ly_dumper_key_serial, "ly:dumper-key-serial",
- 2, 0, 0,
- (SCM dumper, SCM key),
- "Return the key serial number @var{key}. "
- )
+LY_DEFINE (ly_dumper_key_serial, "ly:dumper-key-serial",
+ 2, 0, 0,
+ (SCM dumper, SCM key),
+ "Return the key serial number @var{key}. ")
{
- Object_key_dumper* u = unsmob_key_dumper (dumper);
+ Object_key_dumper *u = unsmob_key_dumper (dumper);
Object_key *k = unsmob_key (key);
- SCM_ASSERT_TYPE(u, dumper, SCM_ARG1, __FUNCTION__, "dumper");
- SCM_ASSERT_TYPE(k, key, SCM_ARG2, __FUNCTION__, "key");
+ SCM_ASSERT_TYPE (u, dumper, SCM_ARG1, __FUNCTION__, "dumper");
+ SCM_ASSERT_TYPE (k, key, SCM_ARG2, __FUNCTION__, "key");
return u->dump_key (k);
}
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "object-key-dumper.hh"
#include "ly-smobs.icc"
SCM
-Object_key_dumper::mark_smob (SCM smob )
+Object_key_dumper::mark_smob (SCM smob)
{
- Object_key_dumper * dumper = (Object_key_dumper*) SCM_CELL_WORD_1 (smob);
-
+ Object_key_dumper *dumper = (Object_key_dumper *) SCM_CELL_WORD_1 (smob);
+
for (Key_to_key_map::const_iterator i (dumper->serialized_keys_.begin ());
- i != dumper->serialized_keys_.end();
+ i != dumper->serialized_keys_.end ();
i++)
{
- scm_gc_mark ((*i).first->self_scm());
+ scm_gc_mark ((*i).first->self_scm ());
}
return SCM_EOL;
}
return 1;
}
-IMPLEMENT_DEFAULT_EQUAL_P(Object_key_dumper);
-IMPLEMENT_SMOBS(Object_key_dumper);
+IMPLEMENT_DEFAULT_EQUAL_P (Object_key_dumper);
+IMPLEMENT_SMOBS (Object_key_dumper);
Object_key_dumper::Object_key_dumper ()
{
SCM
Object_key_dumper::serialize_key (Object_key const *key)
{
- SCM skey = key->dump();
- for (SCM s = skey ; scm_is_pair (s) ; s = scm_cdr (s))
+ SCM skey = key->dump ();
+ for (SCM s = skey; scm_is_pair (s); s = scm_cdr (s))
{
- if (Object_key const * sub_key = unsmob_key (scm_car (s)))
+ if (Object_key const *sub_key = unsmob_key (scm_car (s)))
{
scm_set_car_x (s, dump_key (sub_key));
}
{
scm_set_car_x (s,
scm_list_2 (ly_symbol2scm ("unquote"),
- mom->as_scheme()));
+ mom->as_scheme ()));
}
}
- file_contents_ = scm_cons (scm_list_3 (ly_symbol2scm("define-key"),
+ file_contents_ = scm_cons (scm_list_3 (ly_symbol2scm ("define-key"),
scm_from_int (next_available_),
skey),
file_contents_);
serialized_keys_[key] = key;
key_serial_numbers_[key] = next_available_;
SCM retval = key_serial (next_available_);
- next_available_ ++;
+ next_available_++;
return retval;
}
{
return key_serial (key_serial_numbers_[ serialized_keys_ [serialized] ]);
}
-
+
return serialize_key (key);
}
return scm_reverse (file_contents_);
}
-Object_key_dumper::~Object_key_dumper()
+Object_key_dumper::~Object_key_dumper ()
{
}
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "object-key-undumper.hh"
-LY_DEFINE(ly_undumper_read_keys, "ly:undumper-read-keys",
- 2, 0, 0,
- (SCM undumper, SCM keys),
- "Read serialized @var{keys} into @var{undumper}."
- )
+LY_DEFINE (ly_undumper_read_keys, "ly:undumper-read-keys",
+ 2, 0, 0,
+ (SCM undumper, SCM keys),
+ "Read serialized @var{keys} into @var{undumper}.")
{
Object_key_undumper *u = unsmob_key_undumper (undumper);
- SCM_ASSERT_TYPE(u, undumper, SCM_ARG1, __FUNCTION__, "Undumper");
+ SCM_ASSERT_TYPE (u, undumper, SCM_ARG1, __FUNCTION__, "Undumper");
u->parse_contents (keys);
return SCM_UNSPECIFIED;
}
-LY_DEFINE(ly_make_undumper, "ly:make-undumper",
- 0, 0, 0,
- (),
- "Create a key undumper. "
- )
+LY_DEFINE (ly_make_undumper, "ly:make-undumper",
+ 0, 0, 0,
+ (),
+ "Create a key undumper. ")
{
Object_key_undumper *u = new Object_key_undumper ();
- SCM x = u->self_scm();
+ SCM x = u->self_scm ();
scm_gc_unprotect_object (x);
return x;
}
+LY_DEFINE (ly_undumper_lookup, "ly:undumper-lookup",
+ 2, 0, 0,
+ (SCM undumper, SCM serial),
+ "Return the object key for number @var{serial}. ")
-LY_DEFINE(ly_undumper_lookup, "ly:undumper-lookup",
- 2, 0, 0,
- (SCM undumper, SCM serial),
- "Return the object key for number @var{serial}. "
- )
-
{
- Object_key_undumper* u = unsmob_key_undumper (undumper);
+ Object_key_undumper *u = unsmob_key_undumper (undumper);
- SCM_ASSERT_TYPE(u, undumper, SCM_ARG1, __FUNCTION__, "undumper");
- SCM_ASSERT_TYPE(scm_is_integer(serial), serial, SCM_ARG2, __FUNCTION__, "integer");
- return u->get_key (scm_to_int (serial))->self_scm();
+ SCM_ASSERT_TYPE (u, undumper, SCM_ARG1, __FUNCTION__, "undumper");
+ SCM_ASSERT_TYPE (scm_is_integer (serial), serial, SCM_ARG2, __FUNCTION__, "integer");
+ return u->get_key (scm_to_int (serial))->self_scm ();
}
-
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "object-key-undumper.hh"
#include "ly-smobs.icc"
-IMPLEMENT_SMOBS(Object_key_undumper);
-IMPLEMENT_DEFAULT_EQUAL_P(Object_key_undumper);
+IMPLEMENT_SMOBS (Object_key_undumper);
+IMPLEMENT_DEFAULT_EQUAL_P (Object_key_undumper);
SCM
Object_key_undumper::mark_smob (SCM smob)
{
- Object_key_undumper * undumper = (Object_key_undumper*) SCM_CELL_WORD_1(smob);
- for (Int_to_key_map::const_iterator i (undumper->keys_.begin());
- i != undumper->keys_.end(); i++)
+ Object_key_undumper *undumper = (Object_key_undumper *) SCM_CELL_WORD_1 (smob);
+ for (Int_to_key_map::const_iterator i (undumper->keys_.begin ());
+ i != undumper->keys_.end (); i++)
{
scm_gc_mark ((*i).second->self_scm ());
}
int
Object_key_undumper::print_smob (SCM s, SCM port, scm_print_state*)
{
- (void) s;
+ (void) s;
scm_puts ("#<Object_key_undumper>", port);
return 1;
}
-
Object_key_undumper::Object_key_undumper ()
{
- smobify_self();
+ smobify_self ();
}
-
void
Object_key_undumper::parse_contents (SCM contents)
{
if (scm_car (entry) != ly_symbol2scm ("define-key"))
continue;
-
int number = scm_to_int (scm_cadr (entry));
SCM skey = scm_caddr (entry);
{
int index = scm_to_int (scm_cadr (item));
Object_key const *key = get_key (index);
- *tail = scm_cons (key->self_scm(), SCM_EOL);
+ *tail = scm_cons (key->self_scm (), SCM_EOL);
}
else
{
*tail = scm_cons (item, SCM_EOL);
}
- tail = SCM_CDRLOC(*tail);
+ tail = SCM_CDRLOC (*tail);
}
Object_key *k = Object_key::undump (new_key);
keys_[number] = k;
- scm_gc_unprotect_object (k->self_scm());
+ scm_gc_unprotect_object (k->self_scm ());
}
-
+
}
-Object_key const*
+Object_key const *
Object_key_undumper::get_key (int idx)
{
Int_to_key_map::const_iterator i (keys_.find (idx));
- assert (i != keys_.end());
+ assert (i != keys_.end ());
return (*i).second;
}
-Object_key_undumper::~Object_key_undumper()
+Object_key_undumper::~Object_key_undumper ()
{
}
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "lilypond-key.hh"
SCM
Object_key::mark_smob (SCM key)
{
- Object_key* k = (Object_key*) SCM_CELL_WORD_1 (key);
- k->derived_mark();
+ Object_key *k = (Object_key *) SCM_CELL_WORD_1 (key);
+ k->derived_mark ();
return SCM_EOL;
}
void
Object_key::derived_mark () const
{
-
+
}
-Object_key::~Object_key()
+Object_key::~Object_key ()
{
}
int
Object_key::print_smob (SCM smob, SCM port, scm_print_state*)
{
- Object_key* k = (Object_key*) SCM_CELL_WORD_1 (smob);
+ Object_key *k = (Object_key *) SCM_CELL_WORD_1 (smob);
scm_puts ("#<Object_key ", port);
- scm_display (scm_from_int (k->get_type()), port);
+ scm_display (scm_from_int (k->get_type ()), port);
scm_puts (">", port);
return 1;
}
{
if (this == other)
return 0;
-
- int c = sign (get_type () - other->get_type());
+
+ int c = sign (get_type () - other->get_type ());
if (c)
return c;
else
IMPLEMENT_SMOBS (Object_key);
SCM
-Object_key::equal_p (SCM a , SCM b)
+Object_key::equal_p (SCM a, SCM b)
{
Object_key *ka = unsmob_key (a);
Object_key *kb = unsmob_key (b);
-
+
return (ka->compare (kb)) ? SCM_BOOL_F : SCM_BOOL_T;
}
return 0;
}
-
SCM
Object_key::dump () const
{
- return scm_cons (scm_from_int (get_type()),
- as_scheme());
+ return scm_cons (scm_from_int (get_type ()),
+ as_scheme ());
}
-
-
SCM
Object_key::as_scheme () const
{
- return SCM_EOL;
+ return SCM_EOL;
}
-Object_key*
+Object_key *
Object_key::from_scheme (SCM)
{
- return new Object_key();
+ return new Object_key ();
}
-struct Object_dumper_table_entry {
+struct Object_dumper_table_entry
+{
Object_key_type type_;
- Object_key* (*ctor_)(SCM);
+ Object_key *(*ctor_) (SCM);
};
-static Object_dumper_table_entry undumpers[] = {
+static Object_dumper_table_entry undumpers[]
+= {
{BASE_KEY, Object_key::from_scheme},
{COPIED_KEY, Copied_key::from_scheme},
{GENERAL_KEY, Lilypond_general_key::from_scheme},
{
int t = scm_to_int (scm_car (scm_key));
assert (t == undumpers[t].type_);
- return (undumpers[t].ctor_)(scm_cdr (scm_key));
+ return (undumpers[t].ctor_) (scm_cdr (scm_key));
}
/****************************************************************/
-Copied_key::Copied_key (Object_key const* key, int count)
+Copied_key::Copied_key (Object_key const *key, int count)
{
copy_count_ = count;
original_ = key;
int
Copied_key::do_compare (Object_key const *key) const
{
- Copied_key const *other = dynamic_cast<Copied_key const*> (key);
-
+ Copied_key const *other = dynamic_cast < Copied_key const *> (key);
+
int c = original_->compare (other->original_);
if (c)
return c;
SCM
Copied_key::as_scheme () const
{
- return scm_list_2 (original_ ? original_->self_scm() : SCM_BOOL_F, scm_from_int (copy_count_));
+ return scm_list_2 (original_ ? original_->self_scm () : SCM_BOOL_F, scm_from_int (copy_count_));
}
-
Object_key *
-Copied_key::from_scheme (SCM a)
+Copied_key::from_scheme (SCM a)
{
return new Copied_key (unsmob_key (scm_car (a)),
- scm_to_int (scm_list_ref (a, scm_from_int (1))));
+ scm_to_int (scm_list_ref (a, scm_from_int (1))));
}
#include "open-type-font.hh"
LY_DEFINE (ly_font_sub_fonts, "ly:font-sub-fonts", 1, 0, 0,
- (SCM font),
+ (SCM font),
"Given the font metric @var{font} of an OpenType font, return the "
"names of the subfonts within @var{font}.")
{
}
LY_DEFINE (ly_otf_font_glyph_info, "ly:otf-font-glyph-info", 2, 0, 0,
- (SCM font, SCM glyph),
+ (SCM font, SCM glyph),
"Given the font metric @var{font} of an OpenType font, return the "
"information about named glyph @var{glyph} (a string)")
{
- Modified_font_metric * fm
- = dynamic_cast<Modified_font_metric*> (unsmob_metrics (font));
- Open_type_font * otf = dynamic_cast<Open_type_font*> (fm->original_font ());
+ Modified_font_metric *fm
+ = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font));
+ Open_type_font *otf = dynamic_cast<Open_type_font *> (fm->original_font ());
SCM_ASSERT_TYPE (otf, font, SCM_ARG1, __FUNCTION__, "OTF font-metric");
SCM_ASSERT_TYPE (scm_is_string (glyph), glyph, SCM_ARG1,
__FUNCTION__, "string");
int error_code = FT_Load_Sfnt_Table (face, tag, 0, NULL, length);
if (!error_code)
{
- FT_Byte *buffer = (FT_Byte*) malloc (*length);
+ FT_Byte *buffer = (FT_Byte *) malloc (*length);
if (buffer == NULL)
error (_f ("Cannot allocate %d bytes", *length));
- error_code = FT_Load_Sfnt_Table (face, tag, 0, buffer, length );
+ error_code = FT_Load_Sfnt_Table (face, tag, 0, buffer, length);
if (error_code)
error (_f ("Could not load %s font table", tag_str));
SCM tab = SCM_EOL;
if (buffer)
{
- String contents ((Byte const*)buffer, length);
- contents = "(quote (" + contents + "))";
+ String contents ((Byte const *)buffer, length);
+ contents = "(quote (" + contents + "))";
tab = scm_c_eval_string (contents.to_str0 ());
free (buffer);
return tab;
}
-Index_to_charcode_map
+Index_to_charcode_map
make_index_to_charcode_map (FT_Face face)
{
Index_to_charcode_map m;
return m;
}
-Open_type_font::~Open_type_font()
+Open_type_font::~Open_type_font ()
{
FT_Done_Face (face_);
}
Open_type_font::make_otf (String str)
{
FT_Face face;
- int error_code = FT_New_Face(freetype2_library, str.to_str0 (), 0, &face);
+ int error_code = FT_New_Face (freetype2_library, str.to_str0 (), 0, &face);
if (error_code == FT_Err_Unknown_File_Format)
{
lily_character_table_ = SCM_EOL;
lily_global_table_ = SCM_EOL;
lily_subfonts_ = SCM_EOL;
-
+
lily_character_table_ = alist_to_hashq (load_scheme_table ("LILC", face_));
lily_global_table_ = alist_to_hashq (load_scheme_table ("LILY", face_));
lily_subfonts_ = load_scheme_table ("LILF", face_);
SCM char_alist = entry;
SCM att_scm = scm_cdr (scm_assq (ly_symbol2scm ("attachment"), char_alist));
-
+
return point_constant * ly_scm2offset (att_scm);
}
int code = FT_Get_Glyph_Name (face_, signed_idx, name, len);
if (code)
warning (_f ("FT_Get_Glyph_Name() returned error: %d", code));
-
+
SCM sym = ly_symbol2scm (name);
SCM alist = scm_hashq_ref (lily_character_table_, sym, SCM_BOOL_F);
-
+
if (alist != SCM_BOOL_F)
{
SCM bbox = scm_cdr (scm_assq (ly_symbol2scm ("bbox"), alist));
-
+
Box b;
b[X_AXIS][LEFT] = scm_to_double (scm_car (bbox));
bbox = scm_cdr (bbox);
return b;
}
}
-
+
FT_UInt idx = signed_idx;
FT_Load_Glyph (face_,
idx,
Box b (Interval (-hb, m.width - hb),
Interval (-vb, m.height - vb));
- b.scale (design_size () / Real (face_->units_per_EM));
+ b.scale (design_size () / Real (face_->units_per_EM));
return b;
}
int
Open_type_font::name_to_index (String nm) const
{
- char *nm_str = (char*) nm.to_str0 ();
+ char *nm_str = (char *) nm.to_str0 ();
if (int idx = FT_Get_Name_Index (face_, nm_str))
return idx;
return -1;
unsigned
Open_type_font::index_to_charcode (int i) const
{
- return ((Open_type_font*) this)->index_to_charcode_map_[i];
+ return ((Open_type_font *) this)->index_to_charcode_map_[i];
}
int
Open_type_font::count () const
{
- return ((Open_type_font*) this)->index_to_charcode_map_.size ();
+ return ((Open_type_font *) this)->index_to_charcode_map_.size ();
}
Real
non-design-size fonts. I vote for 1 -
which will trip errors more
quickly. --hwn.
- */
+ */
scm_from_int (1));
return scm_to_double (entry) * Real (point_constant);
}
-
SCM
Open_type_font::sub_fonts () const
{
-/*
+/*
ottava-bracket.cc -- implement Ottava_bracket
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
- */
+*/
#include "text-item.hh"
#include "line-spanner.hh"
struct Ottava_bracket
{
DECLARE_SCHEME_CALLBACK (print, (SCM));
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
};
-
/*
TODO: the string for ottava shoudl depend on the available space, ie.
-
- Long: 15ma Short: 15ma Empty: 15
- 8va 8va 8
- 8va bassa 8ba 8
+ Long: 15ma Short: 15ma Empty: 15
+ 8va 8va 8
+ 8va bassa 8ba 8
*/
MAKE_SCHEME_CALLBACK (Ottava_bracket, print, 1);
SCM
Ottava_bracket::print (SCM smob)
{
- Spanner*me = dynamic_cast<Spanner*> (unsmob_grob (smob));
+ Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
Interval span_points;
-
+
Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS);
- Output_def * layout = me->get_layout ();
-
+ Output_def *layout = me->get_layout ();
+
Drul_array<bool> broken;
Direction d = LEFT;
do
common = common_refpoint_of_list (heads, common, X_AXIS);
for (SCM s = heads; scm_is_pair (s); s = scm_cdr (s))
{
- Grob * h = unsmob_grob (scm_car (s));
- Grob * dots = Rhythmic_head::get_dots (h);
+ Grob *h = unsmob_grob (scm_car (s));
+ Grob *dots = Rhythmic_head::get_dots (h);
if (dots)
common = dots->common_refpoint (common, X_AXIS);
}
SCM properties = Font_interface::text_font_alist_chain (me);
SCM markup = me->get_property ("text");
Stencil text;
- if (Text_interface::markup_p (markup))
+ if (Text_interface::markup_p (markup))
text = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (), properties, markup));
-
Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"),
Interval (0, 0));
-
/*
TODO: we should check if there are ledgers, and modify length of
the spanner to that.
- */
+ */
do
{
Item *b = me->get_bound (d);
{
for (SCM s = b->get_property ("note-heads"); scm_is_pair (s); s = scm_cdr (s))
{
- Grob * h = unsmob_grob (scm_car (s));
+ Grob *h = unsmob_grob (scm_car (s));
ext.unite (h->extent (common, X_AXIS));
- Grob * dots = Rhythmic_head::get_dots (h);
+ Grob *dots = Rhythmic_head::get_dots (h);
if (dots && d == RIGHT)
{
- ext.unite (dots->extent (common, X_AXIS));
+ ext.unite (dots->extent (common, X_AXIS));
}
}
}
-
+
if (ext.is_empty ())
{
ext = robust_relative_extent (b, common, X_AXIS);
span_points[d] = b->extent (common, X_AXIS)[RIGHT];
shorten[d] = 0.;
}
-
+
else
span_points[d] = ext[d];
}
while (flip (&d) != LEFT);
-
/*
- 0.3 is ~ italic correction.
- */
- Real text_size = text.extent (X_AXIS).is_empty ()
- ? 0.0 : text.extent (X_AXIS)[RIGHT] + 0.3;
-
+ 0.3 is ~ italic correction.
+ */
+ Real text_size = text.extent (X_AXIS).is_empty ()
+ ? 0.0 : text.extent (X_AXIS)[RIGHT] + 0.3;
+
span_points[LEFT] = span_points[LEFT]
<? (span_points[RIGHT] - text_size
- - robust_scm2double (me->get_property ("minimum-length"), -1.0));
-
+ - robust_scm2double (me->get_property ("minimum-length"), -1.0));
+
Interval bracket_span_points = span_points;
bracket_span_points[LEFT] += text_size;
-
+
Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
Interval (1.0, 1.0));
-
Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"),
Interval (0, 0));
-
-
edge_height[LEFT] = 0.0;
- edge_height[RIGHT] *= - get_grob_direction (me);
+ edge_height[RIGHT] *= -get_grob_direction (me);
if (broken[RIGHT])
edge_height[RIGHT] = 0.0;
-
+
Stencil b;
Interval empty;
if (!bracket_span_points.is_empty () && bracket_span_points.length () > 0.001)
b = Tuplet_bracket::make_bracket (me,
Y_AXIS, Offset (bracket_span_points.length (), 0),
- edge_height,
+ edge_height,
empty,
flare, shorten);
The vertical lines should not take space, for the following scenario:
8 -----+
- o |
- |
- |
-
+ o |
+ |
+ |
+
Just a small amount, yes. In tight situations, it is even
possible to center the `8' directly below the note, dropping the
ottava line completely...
*/
-
+
b = Stencil (Box (b.extent (X_AXIS),
- Interval (0.1, 0.1)),
- b.expr ());
-
+ Interval (0.1, 0.1)),
+ b.expr ());
+
b.translate_axis (bracket_span_points[LEFT], X_AXIS);
text.translate_axis (span_points[LEFT], X_AXIS);
text.align_to (Y_AXIS, CENTER);
b.add_stencil (text);
-
+
b.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
-
- return b.smobbed_copy ();
-}
+ return b.smobbed_copy ();
+}
ADD_INTERFACE (Ottava_bracket, "ottava-bracket-interface",
"An ottava bracket",
class Ottava_spanner_engraver : public Engraver
{
public:
- TRANSLATOR_DECLARATIONS (Ottava_spanner_engraver);
+ TRANSLATOR_DECLARATIONS (Ottava_spanner_engraver);
protected:
virtual void finalize ();
virtual void acknowledge_grob (Grob_info);
private:
Spanner *span_;
Spanner *finished_;
-
+
SCM last_ottavation_;
-
+
void typeset_all ();
};
void
Ottava_spanner_engraver::derived_mark () const
{
- scm_gc_mark (last_ottavation_ );
+ scm_gc_mark (last_ottavation_);
}
Ottava_spanner_engraver::Ottava_spanner_engraver ()
span_ = 0;
if (scm_is_string (ott))
{
- span_ = make_spanner ("OttavaBracket", SCM_EOL);
+ span_ = make_spanner ("OttavaBracket", SCM_EOL);
span_->set_property ("text", ott);
-
SCM c0 (get_property ("middleCPosition"));
SCM oc0 (get_property ("originalCentralCPosition"));
void
Ottava_spanner_engraver::acknowledge_grob (Grob_info info)
{
- Item *it = dynamic_cast<Item*> (info.grob_);
+ Item *it = dynamic_cast<Item *> (info.grob_);
if (span_ && it && Note_column::has_interface (info.grob_))
{
Side_position_interface::add_support (span_, it);
void
Ottava_spanner_engraver::typeset_all ()
-{
+{
if (finished_)
{
Direction d = LEFT;
{
if (!finished_->get_bound (RIGHT))
{
- Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
+ Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
finished_->set_bound (d, e);
}
}
while (flip (&d) != LEFT);
-
+
finished_ = 0;
}
}
{
if (span_ && !span_->get_bound (LEFT))
{
- Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
+ Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
span_->set_bound (LEFT, e);
}
}
ADD_TRANSLATOR (Ottava_spanner_engraver,
-/* descr */ "Create a text spanner when the ottavation property changes..",
-/* creats*/ "OttavaBracket",
-/* accepts */ "",
-/* acks */ "note-column-interface",
-/* reads */ "ottavation",
-/* write */ "");
+ /* descr */ "Create a text spanner when the ottavation property changes..",
+ /* creats*/ "OttavaBracket",
+ /* accepts */ "",
+ /* acks */ "note-column-interface",
+ /* reads */ "ottavation",
+ /* write */ "");
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
-
#define PANGO_ENABLE_BACKEND // ugh, why necessary?
#include <pango/pangoft2.h>
#include "warn.hh"
#if HAVE_PANGO_FT2
-#include "stencil.hh"
-
+#include "stencil.hh"
LY_DEFINE (ly_pango_font_p, "ly:pango-font?",
1, 0, 0,
(SCM f),
"Is @var{f} a pango font?")
{
- return scm_from_bool (dynamic_cast<Pango_font*> (unsmob_metrics (f)));
+ return scm_from_bool (dynamic_cast<Pango_font *> (unsmob_metrics (f)));
}
-
-
LY_DEFINE (ly_pango_font_physical_fonts, "ly:pango-font-physical-fonts",
1, 0, 0,
(SCM f),
"Return alist of (PSNAME . FILENAME) tuples.")
{
- Pango_font *pf = dynamic_cast<Pango_font*> (unsmob_metrics (f));
+ Pango_font *pf = dynamic_cast<Pango_font *> (unsmob_metrics (f));
SCM alist = SCM_EOL;
if (pf)
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
-
#define PANGO_ENABLE_BACKEND // ugh, why necessary?
#include <pango/pangoft2.h>
#if HAVE_PANGO_FT2
#include "stencil.hh"
-
Pango_font::Pango_font (PangoFT2FontMap *fontmap,
Direction dir,
PangoFontDescription *description,
pango_description_ = pango_font_description_copy (description);
// context_ = pango_ft2_font_map_create_context (fontmap);
- attribute_list_= pango_attr_list_new();
-
+ attribute_list_= pango_attr_list_new ();
/*
urgh. I don't understand this. Why isn't this 1/(scale *
resolution * output_scale)
--hwn
- */
+ */
scale_ = INCH_TO_BP / (Real (PANGO_SCALE) * Real (PANGO_RESOLUTION) * output_scale);
/*
PangoRectangle ink_rect;
pango_glyph_string_extents (pgs, pa->font, &ink_rect, &logical_rect);
- PangoFcFont *fcfont = G_TYPE_CHECK_INSTANCE_CAST(pa->font,
- PANGO_TYPE_FC_FONT,
- PangoFcFont);
+ PangoFcFont *fcfont = G_TYPE_CHECK_INSTANCE_CAST (pa->font,
+ PANGO_TYPE_FC_FONT,
+ PangoFcFont);
FT_Face ftface = pango_fc_font_lock_face (fcfont);
Box b (Interval (PANGO_LBEARING (ink_rect),
PangoFontDescription *descr = pango_font_describe (pa->font);
Real size = pango_font_description_get_size (descr)
- / (Real (PANGO_SCALE));
+ / (Real (PANGO_SCALE));
FcPattern *fcpat = fcfont->font_pattern;
char *filename = 0;
name = name.left_string (idx);
int slash_idx = name.index_last ('/'); // UGh. What's happens on windows?
- if (slash_idx >= 0)
- name = name.right_string (name.length() - slash_idx - 1);
+ if (slash_idx >= 0)
+ name = name.right_string (name.length () - slash_idx - 1);
String initial = name.cut_string (0, 1);
initial.to_upper ();
else
{
warning (_ ("FreeType face has no PostScript font name."));
- return Stencil();
+ return Stencil ();
}
}
Real x = 0.0;
while (ptr)
{
- PangoItem *item = (PangoItem*) ptr->data;
+ PangoItem *item = (PangoItem *) ptr->data;
Stencil item_stencil = pango_item_string_stencil (item, str, x);
/*
UGH. Should have flags per output format signifying supported
options.
- */
+ */
if (output_backend_global != "ps"
&& output_backend_global != "eps")
{
/*
For Pango based backends, we take a shortcut.
- */
+ */
char *descr_string = pango_font_description_to_string (pango_description_);
SCM exp
= scm_list_3 (ly_symbol2scm ("utf8-string"),
return dest;
}
-
SCM
Pango_font::font_file_name () const
{
return SCM_BOOL_F;
}
-
#endif
-
-
#if 0
void test_pango ()
{
int dpi = 1200;
- char * font_family = "Emmentaler";
- PangoContext * pango_context =
- pango_ft2_get_context (dpi, dpi);
+ char *font_family = "Emmentaler";
+ PangoContext *pango_context
+ = pango_ft2_get_context (dpi, dpi);
PangoFontDescription *font_description;
font_description = pango_font_description_new ();
pango_font_description_set_family (font_description, g_strdup (font_family));
pango_font_description_set_style (font_description, (PangoStyle) 20);
pango_context_set_font_description (pango_context, font_description);
-
- PangoAttrList *attr_list = pango_attr_list_new();
+ PangoAttrList *attr_list = pango_attr_list_new ();
char *str = "sfz";
GList *items = pango_itemize (pango_context, str, 0, strlen (str),
attr_list, NULL);
-
GList *ptr = items;
while (ptr)
{
- PangoItem *item = (PangoItem*)ptr->data;
- printf( "off %d len %d num %d\n", item->offset, item->length, item->num_chars);
+ PangoItem *item = (PangoItem *)ptr->data;
+ printf ("off %d len %d num %d\n", item->offset, item->length, item->num_chars);
PangoAnalysis paobj = item->analysis;
- PangoAnalysis * pa = &paobj;
+ PangoAnalysis *pa = &paobj;
PangoFontDescription *descr = pango_font_describe (pa->font);
// assert (font_description == descr);
printf ("font descr string '%s' fname '%s'",
pango_font_description_to_string (descr),
- pango_font_description_to_filename (descr)
- );
+ pango_font_description_to_filename (descr));
printf ("type name %s\n", g_type_name (G_TYPE_FROM_INSTANCE (pa->font)));
- PangoFcFont * fcfont = G_TYPE_CHECK_INSTANCE_CAST (pa->font,
- PANGO_TYPE_FC_FONT,
- PangoFcFont);
+ PangoFcFont *fcfont = G_TYPE_CHECK_INSTANCE_CAST (pa->font,
+ PANGO_TYPE_FC_FONT,
+ PangoFcFont);
FcPattern *fcpat = fcfont->font_pattern;
FcPatternPrint (fcpat);
char *retval ="bla";
- FcPatternGetString(fcpat, FC_FILE, 0, (FcChar8 **) &retval);
+ FcPatternGetString (fcpat, FC_FILE, 0, (FcChar8 **) &retval);
printf ("retval %s\n", retval);
FT_Face ftface = pango_fc_font_lock_face (fcfont);
PangoGlyphGeometry ggeo = pgi->geometry;
printf ("c %d w %d x %d y %d\n", pg, ggeo.width, ggeo.x_offset,
- ggeo.y_offset );
+ ggeo.y_offset);
char str[1024];
FT_Get_Glyph_Name (ftface, pg, str, 1024);
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "config.hh"
#if HAVE_PANGO_FT2
#include "pango-font.hh"
-LY_DEFINE(ly_make_pango_description_string, "ly:make-pango-description-string",
- 2, 0, 0, (SCM chain, SCM size),
- "Make a PangoFontDescription string for the property alist @var{chain} at size @var{size}.")
+LY_DEFINE (ly_make_pango_description_string, "ly:make-pango-description-string",
+ 2, 0, 0, (SCM chain, SCM size),
+ "Make a PangoFontDescription string for the property alist @var{chain} at size @var{size}.")
{
- SCM_ASSERT_TYPE(scm_is_number (size), size, SCM_ARG1, __FUNCTION__, "number");
+ SCM_ASSERT_TYPE (scm_is_number (size), size, SCM_ARG1, __FUNCTION__, "number");
PangoFontDescription *pfd = properties_to_pango_description (chain, scm_to_double (size));
char *str = pango_font_description_to_string (pfd);
pango_font_description_free (pfd);
return scm_str;
}
-
+
#endif
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include <math.h>
#include "output-def.hh"
#include "pango-font.hh"
-
PangoFontDescription *
properties_to_pango_description (SCM chain, Real text_size)
{
SCM_BOOL_F);
SCM variant = ly_chain_assoc_get (ly_symbol2scm ("font-shape"), chain,
SCM_BOOL_F);
-
+
SCM style = ly_chain_assoc_get (ly_symbol2scm ("font-shape"), chain,
SCM_BOOL_F);
SCM weight = ly_chain_assoc_get (ly_symbol2scm ("font-series"), chain,
SCM_BOOL_F);
-
+
description
= symbols_to_pango_font_description (family, style, variant, weight,
SCM_BOOL_F);
Real step = robust_scm2double (ly_symbol2scm ("font-size"), 0.0);
Real size = text_size * pow (2.0, step / 6.0);
-
+
pango_font_description_set_size (description,
gint (size * PANGO_SCALE));
return description;
PangoFontDescription *pfd = properties_to_pango_description (chain,
point_constant * layout->get_dimension (ly_symbol2scm ("text-font-size")));
- char * str = pango_font_description_to_string (pfd);
+ char *str = pango_font_description_to_string (pfd);
SCM scm_str = scm_makfrom0str (str);
g_free (str);
-
+
return find_pango_font (layout, scm_str, 1.0);
}
pstyle = PANGO_STYLE_ITALIC;
}
else if (style == ly_symbol2scm ("oblique")
- || style == ly_symbol2scm ("slanted")
- )
+ || style == ly_symbol2scm ("slanted"))
{
pstyle = PANGO_STYLE_OBLIQUE;
}
return pvariant;
}
-
PangoWeight
symbol_to_pango_weight (SCM weight)
{
PangoStretch ps = PANGO_STRETCH_NORMAL;
/*
- // TODO
-
+ // TODO
+
PANGO_STRETCH_ULTRA_CONDENSED,
PANGO_STRETCH_EXTRA_CONDENSED,
PANGO_STRETCH_CONDENSED,
PANGO_STRETCH_SEMI_CONDENSED,
-
+
PANGO_STRETCH_SEMI_EXPANDED,
PANGO_STRETCH_EXPANDED,
PANGO_STRETCH_EXTRA_EXPANDED,
PANGO_STRETCH_ULTRA_EXPANDED
- */
+ */
return ps;
}
-
-
-PangoFontDescription*
-symbols_to_pango_font_description(SCM family,
- SCM style,
- SCM variant,
- SCM weight,
- SCM stretch)
+PangoFontDescription *
+symbols_to_pango_font_description (SCM family,
+ SCM style,
+ SCM variant,
+ SCM weight,
+ SCM stretch)
{
- PangoFontDescription * description = pango_font_description_new ();
+ PangoFontDescription *description = pango_font_description_new ();
String family_str = "roman";
if (scm_is_symbol (family))
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "paper-book.hh"
#include "output-def.hh"
LY_DEFINE (ly_paper_book_pages, "ly:paper-book-pages",
- 1, 0, 0, (SCM pb),
- "Return pages in book PB.")
+ 1, 0, 0, (SCM pb),
+ "Return pages in book PB.")
{
- return unsmob_paper_book(pb)->pages ();
+ return unsmob_paper_book (pb)->pages ();
}
LY_DEFINE (ly_paper_book_scopes, "ly:paper-book-scopes",
- 1, 0, 0, (SCM book),
- "Return pages in layout book @var{book}.")
+ 1, 0, 0, (SCM book),
+ "Return pages in layout book @var{book}.")
{
- Paper_book *pb = unsmob_paper_book(book);
- SCM_ASSERT_TYPE(pb, book, SCM_ARG1, __FUNCTION__, "Paper_book");
-
+ Paper_book *pb = unsmob_paper_book (book);
+ SCM_ASSERT_TYPE (pb, book, SCM_ARG1, __FUNCTION__, "Paper_book");
+
SCM scopes = SCM_EOL;
if (ly_c_module_p (pb->header_))
scopes = scm_cons (pb->header_, scopes);
-
+
return scopes;
}
}
LY_DEFINE (ly_paper_book_paper, "ly:paper-book-paper",
- 1, 0, 0, (SCM pb),
- "Return pages in book PB.")
+ 1, 0, 0, (SCM pb),
+ "Return pages in book PB.")
{
return unsmob_paper_book (pb)->paper_->self_scm ();
}
pages_ = SCM_BOOL_F;
scores_ = SCM_EOL;
systems_ = SCM_BOOL_F;
-
+
paper_ = 0;
smobify_self ();
}
IMPLEMENT_DEFAULT_EQUAL_P (Paper_book);
IMPLEMENT_SMOBS (Paper_book)
-IMPLEMENT_TYPE_P (Paper_book, "ly:paper-book?")
+ IMPLEMENT_TYPE_P (Paper_book, "ly:paper-book?")
-SCM
+ SCM
Paper_book::mark_smob (SCM smob)
{
- Paper_book *b = (Paper_book*) SCM_CELL_WORD_1 (smob);
+ Paper_book *b = (Paper_book *) SCM_CELL_WORD_1 (smob);
if (b->paper_)
scm_gc_mark (b->paper_->self_scm ());
scm_gc_mark (b->header_);
int
Paper_book::print_smob (SCM smob, SCM port, scm_print_state*)
{
- Paper_book *b = (Paper_book*) SCM_CELL_WORD_1 (smob);
-
+ Paper_book *b = (Paper_book *) SCM_CELL_WORD_1 (smob);
+
scm_puts ("#<", port);
scm_puts (classname (b), port);
scm_puts (" ", port);
dump_fields ()
{
SCM fields = SCM_EOL;
- for (int i = dump_header_fieldnames_global.size (); i--; )
+ for (int i = dump_header_fieldnames_global.size (); i--;)
fields
= scm_cons (ly_symbol2scm (dump_header_fieldnames_global[i].to_str0 ()),
fields);
/* Generate all stencils to trigger font loads. */
pages ();
-
+
SCM scopes = SCM_EOL;
if (ly_c_module_p (header_))
scopes = scm_cons (header_, scopes);
-
+
String mod_nm = "scm framework-" + output_backend_global;
SCM mod = scm_c_resolve_module (mod_nm.to_str0 ());
dump_fields (),
SCM_UNDEFINED));
}
-
+
if (make_preview)
{
SCM func = scm_c_module_lookup (mod, "output-preview-framework");
String format = output_backend_global;
String mod_nm = "scm framework-" + format;
-
+
SCM mod = scm_c_resolve_module (mod_nm.to_str0 ());
SCM func = scm_c_module_lookup (mod, "output-classic-framework");
-
func = scm_variable_ref (func);
scm_apply_0 (func, scm_list_n (scm_makfrom0str (outname.to_str0 ()),
progress_indication ("\n");
}
-
/* TODO: resurrect more complex user-tweaks for titling? */
Stencil
Paper_book::book_title ()
if (ly_c_module_p (header_))
scopes = scm_cons (header_, scopes);
-
SCM tit = SCM_EOL;
if (ly_c_procedure_p (title_func))
tit = scm_call_2 (title_func,
- paper_->self_scm (),
- scopes);
+ paper_->self_scm (),
+ scopes);
if (unsmob_stencil (tit))
title = *unsmob_stencil (tit);
if (!title.is_empty ())
title.align_to (Y_AXIS, UP);
-
+
return title;
}
SCM tit = SCM_EOL;
if (ly_c_procedure_p (title_func))
tit = scm_call_2 (title_func,
- paper_->self_scm (),
- scopes);
+ paper_->self_scm (),
+ scopes);
if (unsmob_stencil (tit))
title = *unsmob_stencil (tit);
if (!title.is_empty ())
title.align_to (Y_AXIS, UP);
-
+
return title;
}
void
-set_system_penalty (Paper_system * ps, SCM header)
+set_system_penalty (Paper_system *ps, SCM header)
{
if (ly_c_module_p (header))
{
SCM force = ly_module_lookup (header, ly_symbol2scm ("breakbefore"));
- if (SCM_VARIABLEP(force)
- && scm_is_bool (SCM_VARIABLE_REF(force)))
+ if (SCM_VARIABLEP (force)
+ && scm_is_bool (SCM_VARIABLE_REF (force)))
{
- ps->break_before_penalty_ = to_boolean (SCM_VARIABLE_REF(force))
+ ps->break_before_penalty_ = to_boolean (SCM_VARIABLE_REF (force))
? -10000
: 10000;
}
}
}
-
+
SCM
Paper_book::systems ()
{
{
Paper_system *ps = new Paper_system (title, true);
set_system_penalty (ps, header_);
-
+
systems_ = scm_cons (ps->self_scm (), systems_);
scm_gc_unprotect_object (ps->self_scm ());
}
set_system_penalty (ps, header);
}
header = SCM_EOL;
-
+
SCM system_list = scm_vector_to_list (scm_car (s));
system_list = scm_reverse (system_list);
systems_ = scm_append (scm_list_2 (system_list, systems_));
else
assert (0);
}
-
+
systems_ = scm_reverse (systems_);
-
+
int i = 0;
Paper_system *last = 0;
for (SCM s = systems_; s != SCM_EOL; s = scm_cdr (s))
ps->break_before_penalty_ = 10000;
last = ps;
}
-
+
return systems_;
}
#include "font-interface.hh"
#include "output-def.hh"
-Grob *
+Grob *
Paper_column::clone (int count) const
{
return new Paper_column (*this, count);
}
-
ADD_INTERFACE (Paper_column, "paper-column-interface",
"@code{Paper_column} objects form the top-most X-parents for items. "
" The are two types of columns: musical columns, where are attached to, and "
" Since many columns go unused, you should only use the rank field to\n"
" get ordering information. Two adjacent columns may have\n"
" non-adjacent numbers.\n"
- "\n"
- ,
+ "\n",
"between-cols when bounded-by-me "
"page-penalty shortest-playing-duration shortest-starter-duration");
Item::do_break_processing ();
}
-
int
-Paper_column::get_rank (Grob*me)
+Paper_column::get_rank (Grob *me)
{
- return dynamic_cast<Paper_column*> (me)->rank_;
+ return dynamic_cast<Paper_column *> (me)->rank_;
}
-System*
+System *
Paper_column::get_system () const
{
return system_;
}
-Paper_column*
+Paper_column *
Paper_column::get_column () const
{
- return (Paper_column*) (this);
+ return (Paper_column *) (this);
}
-Paper_column::Paper_column (SCM l, Object_key const*key)
+Paper_column::Paper_column (SCM l, Object_key const *key)
: Item (l, key) // guh.?
{
system_ = 0;
rank_ = -1;
}
-
-Paper_column::Paper_column (Paper_column const& src, int count)
+Paper_column::Paper_column (Paper_column const &src, int count)
: Item (src, count)
{
system_ = 0;
rank_ = src.rank_;
}
-
Moment
Paper_column::when_mom (Grob *me)
{
}
return s != Moment (0);
}
-
bool
-Paper_column::is_used (Grob*me)
+Paper_column::is_used (Grob *me)
{
- return scm_is_pair (me->get_property ("elements")) || Item::is_breakable (me)
- || scm_is_pair (me->get_property ("bounded-by-me"))
- ;
+ return scm_is_pair (me->get_property ("elements")) || Item::is_breakable (me)
+ || scm_is_pair (me->get_property ("bounded-by-me"));
}
/*
- Print a vertical line and the rank number, to aid debugging.
- */
+ Print a vertical line and the rank number, to aid debugging.
+*/
MAKE_SCHEME_CALLBACK (Paper_column, print, 1);
SCM
SCM properties = Font_interface::text_font_alist_chain (me);
SCM scm_mol = Text_interface::interpret_markup (me->get_layout ()->self_scm (),
- properties,
- scm_makfrom0str (r.to_str0 ()));
+ properties,
+ scm_makfrom0str (r.to_str0 ()));
Stencil t = *unsmob_stencil (scm_mol);
t.align_to (X_AXIS, CENTER);
t.align_to (Y_AXIS, DOWN);
-
+
Stencil l = Lookup::filled_box (Box (Interval (-0.01, 0.01),
Interval (-2, -1)));
t.add_stencil (l);
- return t.smobbed_copy ();
+ return t.smobbed_copy ();
}
/*
columns are kept "alive". Unfortunately, when spanners are suicided,
this falls apart again. (sigh.)
- THIS IS BROKEN KLUDGE. WE SHOULD INVENT SOMETHING BETTER.
- */
+ THIS IS BROKEN KLUDGE. WE SHOULD INVENT SOMETHING BETTER.
+*/
MAKE_SCHEME_CALLBACK (Paper_column, before_line_breaking, 1);
SCM
Paper_column::before_line_breaking (SCM grob)
while (scm_is_pair (*ptrptr))
{
- Grob * g = unsmob_grob (scm_car (*ptrptr));
+ Grob *g = unsmob_grob (scm_car (*ptrptr));
if (!g || !g->is_live ())
{
-/*
+/*
paper-def.cc -- implement Paper_def
source file of the GNU LilyPond music typesetter
#include "pango-font.hh"
#include "all-font-metrics.hh"
-
Real
output_scale (Output_def *od)
{
{
if (mod->parent_)
return find_scaled_font (mod->parent_, f, m);
-
+
Real lookup_mag = m / output_scale (mod);
-
+
SCM font_table = get_font_table (mod);
SCM sizes = scm_hashq_ref (font_table, f->self_scm (), SCM_EOL);
SCM handle = scm_assoc (scm_make_real (lookup_mag), sizes);
if (scm_is_pair (handle))
return unsmob_metrics (scm_cdr (handle));
-
+
SCM val = Modified_font_metric::make_scaled_font_metric (f, lookup_mag);
-
+
sizes = scm_acons (scm_make_real (lookup_mag), val, sizes);
scm_gc_unprotect_object (val);
scm_hashq_set_x (font_table, f->self_scm (), sizes);
return unsmob_metrics (val);
}
-Font_metric*
-find_pango_font (Output_def *layout, SCM descr, Real factor)
+Font_metric *
+find_pango_font (Output_def *layout, SCM descr, Real factor)
{
if (layout->parent_)
return find_pango_font (layout->parent_, descr, factor);
-
+
SCM table = get_pango_font_table (layout);
- SCM sizes = scm_hash_ref (table, descr, SCM_EOL);
+ SCM sizes = scm_hash_ref (table, descr, SCM_EOL);
SCM size_key = scm_from_double (factor);
SCM handle = scm_assoc (size_key, sizes);
if (scm_is_pair (handle))
factor,
output_scale (layout));
- sizes = scm_acons (size_key, fm->self_scm(), sizes);
+ sizes = scm_acons (size_key, fm->self_scm (), sizes);
scm_hash_set_x (table, descr, sizes);
return fm;
/* TODO: this is a nasty interface. During formatting,
the Output_def should be scaled to the output_scale_
specified in the toplevel Output_def. */
-Output_def *
+Output_def *
scale_output_def (Output_def *o, Real amount)
{
SCM proc = ly_lily_module_constant ("scale-layout");
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "paper-outputter.hh"
"Create an outputter that evaluates within "
"@code{output-}@var{format}, writing to file @var{outname}.")
{
- SCM_ASSERT_TYPE(scm_is_string (outname), outname, SCM_ARG1, __FUNCTION__,
- "String");
- SCM_ASSERT_TYPE(scm_is_string (format), format, SCM_ARG2, __FUNCTION__,
- "String");
-
+ SCM_ASSERT_TYPE (scm_is_string (outname), outname, SCM_ARG1, __FUNCTION__,
+ "String");
+ SCM_ASSERT_TYPE (scm_is_string (format), format, SCM_ARG2, __FUNCTION__,
+ "String");
+
String outname_str = ly_scm2string (outname);
String f = ly_scm2string (format);
Paper_outputter *po = unsmob_outputter (outputter);
SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter");
SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "Paper_outputter");
-
+
return po->dump_string (str);
}
-
LY_DEFINE (ly_outputter_port, "ly:outputter-port",
1, 0, 0, (SCM outputter),
"Return output port for @var{outputter}.")
{
Paper_outputter *po = unsmob_outputter (outputter);
SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter");
-
+
return po->file ();
}
source file of the GNU LilyPond music typesetter
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
+ Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "paper-outputter.hh"
file_ = SCM_EOL;
output_module_ = SCM_EOL;
smobify_self ();
-
+
file_name_ = file_name;
String module_name = "scm output-" + format;
output_module_ = scm_c_resolve_module (module_name.to_str0 ());
{
}
-
IMPLEMENT_SMOBS (Paper_outputter);
IMPLEMENT_DEFAULT_EQUAL_P (Paper_outputter);
SCM
Paper_outputter::mark_smob (SCM x)
{
- Paper_outputter *p = (Paper_outputter*) SCM_CELL_WORD_1(x);
+ Paper_outputter *p = (Paper_outputter *) SCM_CELL_WORD_1 (x);
scm_gc_mark (p->output_module_);
return p->file_;
}
{
if (file_ == SCM_EOL)
if (file_name_ == "-")
- file_ = scm_current_output_port();
+ file_ = scm_current_output_port ();
else
file_ = scm_open_file (scm_makfrom0str (file_name_.to_str0 ()),
scm_makfrom0str ("w"));
void
paper_outputter_dump (void *po, SCM x)
{
- Paper_outputter *me = (Paper_outputter*) po;
+ Paper_outputter *me = (Paper_outputter *) po;
me->output_scheme (x);
}
Paper_outputter::output_stencil (Stencil stil)
{
interpret_stencil_expression (stil.expr (), paper_outputter_dump,
- (void*) this, Offset (0, 0));
+ (void *) this, Offset (0, 0));
}
void
Break_algorithm *algorithm = 0;
Array<Column_x_positions> sol;
- algorithm = new Gourlay_breaking ;
+ algorithm = new Gourlay_breaking;
algorithm->set_pscore (this);
sol = algorithm->solve ();
delete algorithm;
/* FIXME: Check out why we need this - removing gives assertion failures
down the road.
-
+
doubly, also done in Score_engraver */
Link_array<Grob> pc (system_->columns ());
pc[0]->set_property ("breakable", SCM_BOOL_T);
pc.top ()->set_property ("breakable", SCM_BOOL_T);
-
+
system_->pre_processing ();
-
+
Array<Column_x_positions> breaking = calc_breaking ();
system_->break_into_pieces (breaking);
SCM lines = system_->get_lines ();
/* gourlay:do_solve also prints newline. */
progress_indication ("\n");
#endif
-
+
/* Only keep result stencils in lines_, *title_; delete all grobs. */
systems_ = SCM_EOL;
-
+
return lines;
}
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "paper-system.hh"
SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
Axis ax = (Axis)scm_to_int (axis);
- return ly_interval2scm (ps->to_stencil().extent (ax));
+ return ly_interval2scm (ps->to_stencil ().extent (ax));
}
-
-
LY_DEFINE (ly_paper_system_title_p, "ly:paper-system-title?",
1, 0, 0, (SCM system),
"Is @var{system} a title system?")
return ps->to_stencil ().smobbed_copy ();
}
-
-
LY_DEFINE (ly_paper_system_staff_extent, "ly:paper-system-staff-extents",
1, 0, 0, (SCM system),
"Return the top and bottom staff refpoint.")
IMPLEMENT_TYPE_P (Paper_system, "ly:paper-system?");
IMPLEMENT_DEFAULT_EQUAL_P (Paper_system);
-
-
Paper_system::Paper_system (Stencil s, bool is_title)
{
is_title_ = is_title;
break_before_penalty_ = 0;
smobify_self ();
stencil_ = s;
- staff_refpoints_ = Interval(0, 0);
+ staff_refpoints_ = Interval (0, 0);
}
Paper_system::~Paper_system ()
SCM
Paper_system::mark_smob (SCM smob)
{
- Paper_system *system = (Paper_system*) SCM_CELL_WORD_1 (smob);
+ Paper_system *system = (Paper_system *) SCM_CELL_WORD_1 (smob);
return system-> stencil_.expr ();
}
int
Paper_system::print_smob (SCM smob, SCM port, scm_print_state*)
{
- Paper_system *p = (Paper_system*) SCM_CELL_WORD_1 (smob);
+ Paper_system *p = (Paper_system *) SCM_CELL_WORD_1 (smob);
scm_puts ("#<", port);
scm_puts (classname (p), port);
scm_puts ("n ", port);
/* Pass string to scm parser, evaluate one expression.
Return result value and #chars read.
-
+
Thanks to Gary Houston <ghouston@freewire.co.uk> */
SCM
-internal_ly_parse_scm (Parse_start * ps)
+internal_ly_parse_scm (Parse_start *ps)
{
Source_file *sf = ps->start_location_.source_file_;
SCM port = sf->get_port ();
int off = ps->start_location_.start_ - sf->to_str0 ();
-
+
scm_seek (port, scm_long2num (off), scm_long2num (SEEK_SET));
SCM from = scm_ftell (port);
else
answer = scm_primitive_eval (form);
}
-
+
/* Reset read_buf for scm_ftell.
Shouldn't scm_read () do this for us? */
scm_fill_input (port);
SCM
catch_protected_parse_body (void *p)
{
- Parse_start *ps = (Parse_start*) p;
-
+ Parse_start *ps = (Parse_start *) p;
+
return internal_ly_parse_scm (ps);
}
-SCM
+SCM
parse_handler (void *data, SCM tag, SCM args)
{
- Parse_start* ps = (Parse_start *) data;
+ Parse_start *ps = (Parse_start *) data;
(void) tag;
-
- ps->start_location_.error (_("GUILE signaled an error for the expression beginning here"));
+
+ ps->start_location_.error (_ ("GUILE signaled an error for the expression beginning here"));
if (scm_ilength (args) > 2)
scm_display_error_message (scm_cadr (args), scm_caddr (args), scm_current_error_port ());
/*
The following is a kludge; we should probably search for
[a-z][0-9] (a note), and start before that.
- */
+ */
ps->nchars = 1;
-
+
return SCM_UNDEFINED;
}
/*
Do some magical incantations: if not, lily will exit on the first
- GUILE error, leaving no location trace.
- */
-
+ GUILE error, leaving no location trace.
+*/
#if GUILE_MINOR_VERSION < 7
- #define READ_ERROR "misc-error"
- #else
- #define READ_ERROR "read-error"
+#define READ_ERROR "misc-error"
+#else
+#define READ_ERROR "read-error"
#endif
SCM
{
return scm_internal_catch (ly_symbol2scm (READ_ERROR),
&catch_protected_parse_body,
- (void*) ps,
- &parse_handler, (void*) ps);
+ (void *) ps,
+ &parse_handler, (void *) ps);
}
-bool parse_protect_global = true;
+bool parse_protect_global = true;
/* Try parsing. Upon failure return SCM_UNDEFINED.
FIXME: shouldn't we return SCM_UNSCPECIFIED -- jcn */
ps.str = s;
ps.start_location_ = i;
ps.safe_ = safe;
-
+
SCM ans = parse_protect_global ? protected_ly_parse_scm (&ps)
: internal_ly_parse_scm (&ps);
*n = ps.nchars;
- return ans;
+ return ans;
}
part-combine-engraver.cc -- implement PC-engraver
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "engraver.hh"
};
bool
-Part_combine_engraver::try_music (Music*m)
+Part_combine_engraver::try_music (Music *m)
{
event_ = m;
return true;
Part_combine_engraver::Part_combine_engraver ()
{
text_ = 0;
- event_ = 0;
+ event_ = 0;
}
void
if (Text_interface::markup_p (text))
{
- text_ = make_item ("CombineTextScript", event_->self_scm () );
+ text_ = make_item ("CombineTextScript", event_->self_scm ());
text_->set_property ("text", text);
}
}
{
if (Note_head::has_interface (i.grob_))
{
- Grob*t = text_;
+ Grob *t = text_;
Side_position_interface::add_support (t, i.grob_);
if (Side_position_interface::get_axis (t) == X_AXIS
&& !t->get_parent (Y_AXIS))
}
}
-void
+void
Part_combine_engraver::stop_translation_timestep ()
{
- text_ = 0;
+ text_ = 0;
event_ = 0;
}
ADD_TRANSLATOR (Part_combine_engraver,
-/* descr */ "Part combine engraver for orchestral scores: "
- "Print markings a2, Solo, Solo II, and unisono ",
-/* creats*/ "CombineTextScript",
-/* accepts */ "part-combine-event",
-/* acks */ "multi-measure-rest-interface "
-"slur-interface stem-interface note-head-interface",
-/* reads */ "printPartCombineTexts",
-/* write */ "");
+ /* descr */ "Part combine engraver for orchestral scores: "
+ "Print markings a2, Solo, Solo II, and unisono ",
+ /* creats*/ "CombineTextScript",
+ /* accepts */ "part-combine-event",
+ /* acks */ "multi-measure-rest-interface "
+ "slur-interface stem-interface note-head-interface",
+ /* reads */ "printPartCombineTexts",
+ /* write */ "");
-/*
- new-part-combine-music-iterator.cc -- implement Part_combine_iterator
+/*
+ new-part-combine-music-iterator.cc -- implement Part_combine_iterator
- source file of the GNU LilyPond music typesetter
-
- (c) 2004--2005 Han-Wen Nienhuys
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004--2005 Han-Wen Nienhuys
*/
#include "context.hh"
public:
Part_combine_iterator ();
- DECLARE_SCHEME_CALLBACK (constructor, ());
+ DECLARE_SCHEME_CALLBACK (constructor, ());
protected:
- virtual void derived_substitute (Context *f, Context *t) ;
+ virtual void derived_substitute (Context *f, Context *t);
virtual void derived_mark () const;
Part_combine_iterator (Part_combine_iterator const &);
virtual void construct_children ();
virtual Moment pending_moment () const;
- virtual void do_quit ();
+ virtual void do_quit ();
virtual void process (Moment);
virtual Music_iterator *try_music_in_children (Music *) const;
virtual bool ok () const;
private:
- Music_iterator * first_iter_;
- Music_iterator * second_iter_;
+ Music_iterator *first_iter_;
+ Music_iterator *second_iter_;
Moment start_moment_;
-
+
SCM split_list_;
- enum Status {
- APART,
- TOGETHER,
- SOLO1,
- SOLO2,
- UNISONO,
- UNISILENCE,
- };
+ enum Status
+ {
+ APART,
+ TOGETHER,
+ SOLO1,
+ SOLO2,
+ UNISONO,
+ UNISILENCE,
+ };
Status state_;
Status playing_state_;
/*
Should be SOLO1 or SOLO2
- */
+ */
Status last_playing_;
/*
- TODO: this is getting of hand...
- */
+ TODO: this is getting of hand...
+ */
Interpretation_context_handle one_;
Interpretation_context_handle two_;
Interpretation_context_handle null_;
Interpretation_context_handle shared_;
Interpretation_context_handle solo_;
-
- void substitute_both (Context * to1,
- Context * to2);
+
+ void substitute_both (Context *to1,
+ Context *to2);
void kill_mmrest (Context *);
void chords_together ();
void unisono (bool silent);
};
-
static Music *busy_playing_event;
void
split_list_ = SCM_EOL;
state_ = APART;
playing_state_ = APART;
-
+
if (!busy_playing_event)
{
busy_playing_event
void
Part_combine_iterator::derived_substitute (Context *f,
- Context *t)
+ Context *t)
{
if (first_iter_)
first_iter_->substitute_outlet (f, t);
}
}
-
void
-Part_combine_iterator::kill_mmrest (Context * tg)
+Part_combine_iterator::kill_mmrest (Context *tg)
{
- static Music * mmrest;
+ static Music *mmrest;
if (!mmrest)
{
mmrest = make_music_by_name (ly_symbol2scm ("MultiMeasureRestEvent"));
state_ = SOLO1;
substitute_both (solo_.get_outlet (),
null_.get_outlet ());
-
+
kill_mmrest (two_.get_outlet ());
kill_mmrest (shared_.get_outlet ());
if (playing_state_ != SOLO1)
{
- static Music* event;
+ static Music *event;
if (!event)
event = make_music_by_name (ly_symbol2scm ("SoloOneEvent"));
}
void
-Part_combine_iterator::substitute_both (Context * to1,
- Context * to2)
+Part_combine_iterator::substitute_both (Context *to1,
+ Context *to2)
{
- Context *tos[] = {to1, to2};
- Music_iterator *mis[] = {first_iter_, second_iter_};
- Interpretation_context_handle *hs[] = {
+ Context *tos[] = {to1, to2};
+ Music_iterator *mis[] = {first_iter_, second_iter_};
+ Interpretation_context_handle *hs[]
+ = {
&null_,
&one_, &two_,
- &shared_, &solo_,
+ &shared_, &solo_,
0
};
-
- for (int i = 0; i < 2 ; i++)
+
+ for (int i = 0; i < 2; i++)
{
- for (int j = 0; hs[j]; j++)
+ for (int j = 0; hs[j]; j++)
if (hs[j]->get_outlet () != tos[i])
- mis[i]->substitute_outlet (hs[j]->get_outlet (), tos[i]);
+ mis[i]->substitute_outlet (hs[j]->get_outlet (), tos[i]);
}
- for (int j = 0; hs[j]; j++)
+ for (int j = 0; hs[j]; j++)
{
- Context * t = hs[j]->get_outlet ();
+ Context *t = hs[j]->get_outlet ();
if (t != to1 && t != to2)
kill_mmrest (t);
}
}
-
void
Part_combine_iterator::unisono (bool silent)
{
Status newstate = (silent) ? UNISILENCE : UNISONO;
-
+
if (newstate == state_)
- return;
+ return;
else
{
/*
If we're coming from SOLO2 state, we might have kill mmrests
- in the 1st voice, so in that case, we use the second voice
+ in the 1st voice, so in that case, we use the second voice
as a basis for events.
- */
- Context *c1 = (last_playing_ == SOLO2) ? null_.get_outlet() : shared_.get_outlet();
- Context *c2 = (last_playing_ == SOLO2) ? shared_.get_outlet() : null_.get_outlet();
+ */
+ Context *c1 = (last_playing_ == SOLO2) ? null_.get_outlet () : shared_.get_outlet ();
+ Context *c2 = (last_playing_ == SOLO2) ? shared_.get_outlet () : null_.get_outlet ();
substitute_both (c1, c2);
kill_mmrest ((last_playing_ == SOLO2)
? one_.get_outlet () : two_.get_outlet ());
if (playing_state_ != UNISONO
&& newstate == UNISONO)
{
- static Music* event;
+ static Music *event;
if (!event)
event = make_music_by_name (ly_symbol2scm ("UnisonoEvent"));
(last_playing_ == SOLO2 ? second_iter_ : first_iter_)
- ->try_music_in_children (event);
+ ->try_music_in_children (event);
playing_state_ = UNISONO;
}
state_ = newstate;
else
{
state_ = SOLO2;
-
+
substitute_both (null_.get_outlet (), solo_.get_outlet ());
-
+
if (playing_state_ != SOLO2)
{
- static Music* event;
+ static Music *event;
if (!event)
event = make_music_by_name (ly_symbol2scm ("SoloTwoEvent"));
}
}
-
void
Part_combine_iterator::construct_children ()
{
start_moment_ = get_outlet ()->now_mom ();
- split_list_ = get_music ()->get_property ("split-list");
- SCM lst = get_music ()->get_property ("elements");
+ split_list_ = get_music ()->get_property ("split-list");
+ SCM lst = get_music ()->get_property ("elements");
SCM props = scm_list_n (/*
used to have tweaks here.
- */
-
+ */
+
SCM_UNDEFINED);
Context *tr
- = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"),
- "shared", props);
+ = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"),
+ "shared", props);
shared_.set_context (tr);
/*
If we don't, we get a new staff for every Voice.
- */
+ */
set_context (tr);
Context *solo_tr
- = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"),
- "solo", props);
+ = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"),
+ "solo", props);
solo_ .set_context (solo_tr);
Context *null
- = get_outlet ()->find_create_context (ly_symbol2scm ("Devnull"),
- "", SCM_EOL);
+ = get_outlet ()->find_create_context (ly_symbol2scm ("Devnull"),
+ "", SCM_EOL);
if (!null)
programming_error ("No Devnull found?");
-
+
null_.set_context (null);
Context *one = tr->find_create_context (ly_symbol2scm ("Voice"),
- "one", props);
+ "one", props);
one_.set_context (one);
set_context (one);
first_iter_ = unsmob_iterator (get_iterator (unsmob_music (scm_car (lst))));
-
Context *two = tr->find_create_context (ly_symbol2scm ("Voice"),
- "two", props);
+ "two", props);
two_.set_context (two);
set_context (two);
second_iter_ = unsmob_iterator (get_iterator (unsmob_music (scm_cadr (lst))));
-
set_context (tr);
-
- char const * syms[] = {
+ char const *syms[]
+ = {
"Stem",
"DynamicLineSpanner",
"Tie",
"Script",
0
};
-
- for (char const**p = syms; *p; p++)
+
+ for (char const **p = syms; *p; p++)
{
SCM sym = ly_symbol2scm (*p);
execute_pushpop_property (one, sym,
- ly_symbol2scm ("direction"), scm_int2num (1));
+ ly_symbol2scm ("direction"), scm_int2num (1));
execute_pushpop_property (two, sym,
ly_symbol2scm ("direction"), scm_int2num (-1));
{
Moment now = get_outlet ()->now_mom ();
Moment *splitm = 0;
-
+
for (; scm_is_pair (split_list_); split_list_ = scm_cdr (split_list_))
{
splitm = unsmob_moment (scm_caar (split_list_));
if (splitm && *splitm + start_moment_ > now)
- break ;
+ break;
SCM tag = scm_cdar (split_list_);
-
+
if (tag == ly_symbol2scm ("chords"))
chords_together ();
else if (tag == ly_symbol2scm ("apart")
solo2 ();
else if (scm_is_symbol (tag))
{
- String s = "Unknown split directive: "
- + (scm_is_symbol (tag) ? ly_symbol2string (tag) : String ("not a symbol"));
+ String s = "Unknown split directive: "
+ + (scm_is_symbol (tag) ? ly_symbol2string (tag) : String ("not a symbol"));
programming_error (s);
}
}
if (first_iter_->try_music_in_children (busy_playing_event))
last_playing_ = SOLO1;
}
-
+
if (second_iter_->ok ())
{
second_iter_->process (m);
}
}
-Music_iterator*
+Music_iterator *
Part_combine_iterator::try_music_in_children (Music *m) const
{
- Music_iterator * i = first_iter_->try_music (m);
+ Music_iterator *i = first_iter_->try_music (m);
if (i)
return i;
else
-/*
+/*
new-chord-tremolo-engraver.cc -- implement Chord_tremolo_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "repeated-music.hh"
#include "global-context.hh"
#include "score-engraver.hh"
/**
- This acknowledges repeated music with "percent" style. It typesets
- a % sign.
+ This acknowledges repeated music with "percent" style. It typesets
+ a % sign.
- TODO:
+ TODO:
- - BEAT case: Create items for single beat repeats, i.e. c4 / / /
+ - BEAT case: Create items for single beat repeats, i.e. c4 / / /
- - DOUBLE_MEASURE case: attach a % to an appropriate barline.
-
+ - DOUBLE_MEASURE case: attach a % to an appropriate barline.
*/
class Percent_repeat_engraver : public Engraver
{
Moment next_moment_;
Moment body_length_;
- enum {
- UNKNOWN,
- MEASURE,
- DOUBLE_MEASURE,
- } repeat_sign_type_ ;
+ enum
+ {
+ UNKNOWN,
+ MEASURE,
+ DOUBLE_MEASURE,
+ }
+ repeat_sign_type_;
- Item * double_percent_;
- Spanner * perc_;
- Spanner * finished_perc_;
+ Item *double_percent_;
+ Spanner *perc_;
+ Spanner *finished_perc_;
protected:
virtual void finalize ();
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
virtual void process_music ();
Percent_repeat_engraver::Percent_repeat_engraver ()
{
- perc_ = 0;
+ perc_ = 0;
finished_perc_ = 0;
repeat_ = 0;
}
bool
-Percent_repeat_engraver::try_music (Music * m)
+Percent_repeat_engraver::try_music (Music *m)
{
if (m->is_mus_type ("repeated-music")
&& m->get_property ("iterator-ctor")
- == Percent_repeat_iterator::constructor_proc
+ == Percent_repeat_iterator::constructor_proc
&& !repeat_)
{
body_length_ = Repeated_music::body_get_length (m);
int count = Repeated_music::repeat_count (m);
-
+
Moment now = now_mom ();
start_mom_ = now;
stop_mom_ = start_mom_ + Moment (count) * body_length_;
else if (Moment (2)* meas_len == body_length_)
{
repeat_sign_type_ = DOUBLE_MEASURE;
- next_moment_ += meas_len ;
+ next_moment_ += meas_len;
}
else
{
repeat_ = m;
-
Global_context *global = get_global_context ();
- for (int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
global->add_moment_to_process (next_moment_ + Moment (i) * body_length_);
/*
bars between % too.
- */
+ */
if (repeat_sign_type_ == DOUBLE_MEASURE)
global->add_moment_to_process (next_moment_ + meas_len + Moment (i) * body_length_);
-
+
}
-
+
return true;
}
else if (repeat_sign_type_ == DOUBLE_MEASURE)
{
double_percent_ = make_item ("DoublePercentRepeat", repeat_->self_scm ());
- /*
- forbid breaks on a % line. Should forbid all breaks, really.
- */
+ /*
+ forbid breaks on a % line. Should forbid all breaks, really.
+ */
get_score_engraver ()->forbid_breaks (); // guh. Use properties!
}
}
-
-
void
Percent_repeat_engraver::start_translation_timestep ()
{
}
}
-
void
Percent_repeat_engraver::stop_translation_timestep ()
{
}
-
-
ADD_TRANSLATOR (Percent_repeat_engraver,
-/* descr */ "Make whole bar and double bar repeats.",
-/* creats*/ "PercentRepeat DoublePercentRepeat",
-/* accepts */ "repeated-music",
-/* acks */ "",
-/* reads */ "measureLength currentCommandColumn",
-/* write */ "");
+ /* descr */ "Make whole bar and double bar repeats.",
+ /* creats*/ "PercentRepeat DoublePercentRepeat",
+ /* accepts */ "repeated-music",
+ /* acks */ "",
+ /* reads */ "measureLength currentCommandColumn",
+ /* write */ "");
-/*
+/*
percent-repeat-item.cc -- implement Percent_repeat_item_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "percent-repeat-item.hh"
#include "font-interface.hh"
Stencil
-Percent_repeat_item_interface::brew_slash ( Grob *me)
+Percent_repeat_item_interface::brew_slash (Grob *me)
{
Real slope = robust_scm2double (me->get_property ("slope"), 1);
Real wid = 2.0 / slope;
/*
todo: check out if in staff-rule thickness normally.
- */
+ */
Real thick = robust_scm2double (me->get_property ("thickness"), 1);
Stencil m = Lookup::repeat_slash (wid, slope, thick);
m.translate_axis (-m.extent (Y_AXIS).center (), Y_AXIS);
/*
todo: use grob props for dot_neg_kern, slash_neg_kern?
- */
+*/
Stencil
Percent_repeat_item_interface::x_percent (Grob *me, int count,
Real dot_neg_kern,
Real slash_neg_kern)
{
- Stencil m ;
+ Stencil m;
Stencil s = brew_slash (me);
- for (int i = count; i--;)
+ for (int i = count; i--;)
{
m.add_at_edge (X_AXIS, RIGHT, s, -slash_neg_kern, 0);
}
Stencil d1 = Font_interface::get_default_font (me)->find_by_name ("dots.dot");
- Stencil d2 = d1;
- d1.translate_axis (0.5, Y_AXIS );
+ Stencil d2 = d1;
+ d1.translate_axis (0.5, Y_AXIS);
d2.translate_axis (-0.5, Y_AXIS);
-
+
m.add_at_edge (X_AXIS, LEFT, d1, -dot_neg_kern, 0);
m.add_at_edge (X_AXIS, RIGHT, d2, -dot_neg_kern, 0);
}
ADD_INTERFACE (Percent_repeat_item_interface, "percent-repeat-interface",
- "Repeats that look like percent signs",
- "slope thickness");
-
-
+ "Repeats that look like percent signs",
+ "slope thickness");
-/*
+/*
percent-repeat-iterator.cc -- implement Percent_repeat_iterator
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "percent-repeat-iterator.hh"
IMPLEMENT_CTOR_CALLBACK (Percent_repeat_iterator);
-
Percent_repeat_iterator::Percent_repeat_iterator ()
{
child_iter_ = 0;
child_iter_ = unsmob_iterator (get_iterator (Repeated_music::body (mus)));
}
-
void
Percent_repeat_iterator::process (Moment m)
{
if (yeah)
set_context (yeah->get_outlet ());
else
- get_music ()->origin ()->warning ( _ ("no one to print a percent"));
+ get_music ()->origin ()->warning (_ ("no one to print a percent"));
}
-
+
if (child_iter_->ok ())
child_iter_->process (m);
- if (finish_mom_ <= m )
+ if (finish_mom_ <= m)
{
- child_iter_->quit ();
+ child_iter_->quit ();
child_iter_ = 0;
}
}
if (child_iter_->ok ())
return child_iter_->pending_moment ();
else
- return finish_mom_ ;
+ return finish_mom_;
}
-Music_iterator*
+Music_iterator *
Percent_repeat_iterator::try_music_in_children (Music *m) const
{
return child_iter_->try_music (m);
}
void
-Percent_repeat_iterator::derived_substitute (Context *f, Context *t )
+Percent_repeat_iterator::derived_substitute (Context *f, Context *t)
{
if (child_iter_)
child_iter_->substitute_outlet (f, t);
audio_elem_p_list_ = 0;
}
-
Performance::~Performance ()
{
delete audio_elem_p_list_;
}
void
-Performance::output (Midi_stream& midi_stream)
+Performance::output (Midi_stream &midi_stream)
{
int tracks_i = audio_staffs_.size () + 1;
{
Audio_staff *s = audio_staffs_[i];
if (be_verbose_global)
- progress_indication ("[" + to_string (i)) ;
+ progress_indication ("[" + to_string (i));
/*
MIDI players tend to ignore instrument settings on
channel 10, the percussion channel by default.
- */
+ */
if (channel % 16 == 9)
- channel++;
-
+ channel++;
/*
Huh? Why does each staff also have a separate channel? We
should map channels to voices, not staves. --hwn.
- */
+ */
if (s->channel_ < 0)
{
s->channel_ = channel % 16;
if (channel > 15)
warning ("MIDI channel wrapped around. Remapping modulo 16.");
}
-
+
s->output (midi_stream, channel++);
if (be_verbose_global)
progress_indication ("]");
}
}
-
void
-Performance::output_header_track (Midi_stream& midi_stream)
+Performance::output_header_track (Midi_stream &midi_stream)
{
Midi_track midi_track;
/*
This seems silly, but in fact the audio elements should
be generated elsewhere: not midi-specific.
- */
+ */
Audio_text creator_a (Audio_text::TEXT, str);
Midi_text creator (&creator_a);
midi_track.add (Moment (0), &creator);
/* Better not translate this */
str = "Generated automatically by: ";
str += id_string;
-
+
Audio_text generate_a (Audio_text::TEXT, str);
Midi_text generate (&generate_a);
midi_track.add (Moment (0), &generate);
-
+
str = _ ("at ");
time_t t (time (0));
str += ctime (&t);
str = str.left_string (str.length () - 1);
str = String_convert::pad_to (str, 60);
-
+
Audio_text at_a (Audio_text::TEXT, str);
Midi_text at (&at_a);
midi_track.add (Moment (0), &at);
-
// TODO:
// str = _f ("from musical definition: %s", origin_string_);
void
Performance::add_element (Audio_element *p)
{
- if (Audio_staff*s = dynamic_cast<Audio_staff *> (p))
+ if (Audio_staff *s = dynamic_cast<Audio_staff *> (p))
{
audio_staffs_.push (s);
}
{
if (out == "-")
out = "lelie.midi";
-
+
/* Maybe a bit crude, but we had this before */
File_name file_name (out);
file_name.ext_ = "midi";
out = file_name.to_string ();
-
+
Midi_stream midi_stream (out);
progress_indication (_f ("MIDI output to `%s'...", out));
source file of the GNU LilyPond music typesetter
(c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
- */
+ Jan Nieuwenhuizen <janneke@gnu.org>
+*/
#include "performer-group-performer.hh"
#include "warn.hh"
ADD_TRANSLATOR (Performer_group_performer,
-/* descr */ "",
-/* creats*/ "",
-/* accepts */ "",
-/* acks */ "",
-/* reads */ "",
-/* write */ "");
-
-
+ /* descr */ "",
+ /* creats*/ "",
+ /* accepts */ "",
+ /* acks */ "",
+ /* reads */ "",
+ /* write */ "");
void
Performer_group_performer::announce_element (Audio_element_info info)
Translator *t
= context ()->get_parent_context ()->implementation ();
- if (Performer_group_performer * eg = dynamic_cast<Performer_group_performer*> (t))
+ if (Performer_group_performer *eg = dynamic_cast<Performer_group_performer *> (t))
eg->announce_element (info);
}
for (SCM p = get_simple_trans_list (); scm_is_pair (p); p = scm_cdr (p))
{
- Translator * t = unsmob_translator (scm_car (p));
- Performer * eng = dynamic_cast<Performer*> (t);
+ Translator *t = unsmob_translator (scm_car (p));
+ Performer *eng = dynamic_cast<Performer *> (t);
if (eng && eng!= info.origin_trans_)
eng->acknowledge_audio_element (info);
}
create_audio_elements ();
performer_each (get_simple_trans_list (),
&Performer::create_audio_elements);
-
+
if (!announce_infos_.size ())
- break ;
-
+ break;
+
acknowledge_audio_elements ();
announce_infos_.clear ();
}
{
}
-
void
performer_each (SCM list, Performer_method method)
{
for (SCM p = list; scm_is_pair (p); p = scm_cdr (p))
{
- Performer * e = dynamic_cast<Performer*>(unsmob_translator (scm_car (p)));
+ Performer *e = dynamic_cast<Performer *> (unsmob_translator (scm_car (p)));
if (e)
(e->*method) ();
}
source file of the GNU LilyPond music typesetter
(c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
- */
+ Jan Nieuwenhuizen <janneke@gnu.org>
+*/
#include "context.hh"
#include "performer-group-performer.hh"
#include "warn.hh"
-void
-Performer::play_element (Audio_element* p)
-{
- get_daddy_performer ()->play_element (p);
+void
+Performer::play_element (Audio_element *p)
+{
+ get_daddy_performer ()->play_element (p);
}
int
return get_daddy_performer ()->get_tempo ();
}
-Performer_group_performer*
+Performer_group_performer *
Performer::get_daddy_performer () const
{
return
{
}
-
void
Performer::announce_element (Audio_element_info i)
{
Byte type = *p++;
if (type == 3)
- break ;
+ break;
- unsigned seglen =
- p[0] | (p[1] << 8)
+ unsigned seglen
+ = p[0] | (p[1] << 8)
| (p[2] << 16) | (p[3] << 24);
p += 4;
if (type == 1)
{
- out = (char*)realloc (out, olen + seglen + 1);
- char *outp = out + olen ;
+ out = (char *)realloc (out, olen + seglen + 1);
+ char *outp = out + olen;
memcpy (outp, p, seglen);
olen += seglen;
p += seglen;
{
unsigned outlength = (seglen * 2) + (seglen / 32) + 2;
- out = (char*)realloc (out, olen + outlength + 1);
+ out = (char *)realloc (out, olen + outlength + 1);
char *outp = out + olen;
for (int i = seglen; i--;)
{
sprintf (outp, "%02x", *p++);
outp += 2;
- if (!(i % 32))
+ if (! (i % 32))
{
- *outp ++ = '\n';
+ *outp++ = '\n';
}
}
LY_DEFINE (ly_pfb_to_pfa, "ly:pfb->pfa",
1, 0, 0, (SCM pfb_file_name),
- "Convert the contents of a PFB file to PFA."
- )
+ "Convert the contents of a PFB file to PFA.")
{
SCM_ASSERT_TYPE (scm_is_string (pfb_file_name), pfb_file_name,
SCM_ARG1, __FUNCTION__, "string");
String file_name = ly_scm2string (pfb_file_name);
int len;
char *str = gulp_file (file_name, &len);
- char *pfa = pfb2pfa ((Byte*)str, len);
+ char *pfa = pfb2pfa ((Byte *)str, len);
SCM pfa_scm = scm_makfrom0str (pfa);
free (pfa);
LY_DEFINE (ly_ttf_to_pfa, "ly:ttf->pfa",
1, 0, 0, (SCM ttf_file_name),
"Convert the contents of a TTF file to Type42 PFA, returning it as "
- " a string."
- )
+ " a string.")
{
SCM_ASSERT_TYPE (scm_is_string (ttf_file_name), ttf_file_name,
SCM_ARG1, __FUNCTION__, "string");
-
+
String file_name = ly_scm2string (ttf_file_name);
Memory_out_stream stream;
class Phrasing_slur_engraver : public Engraver
{
Drul_array<Music *> events_;
- Music * running_slur_start_;
+ Music *running_slur_start_;
Link_array<Grob> slurs_;
Link_array<Grob> end_slurs_;
protected:
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void acknowledge_grob (Grob_info);
virtual void stop_translation_timestep ();
virtual void finalize ();
{
if (slurs_.is_empty ())
return false;
-
+
events_[STOP] = m;
return true;
}
return false;
}
-
void
Phrasing_slur_engraver::acknowledge_grob (Grob_info info)
{
Grob *e = info.grob_;
if (Note_column::has_interface (info.grob_))
{
- for (int i = slurs_.size (); i--; )
+ for (int i = slurs_.size (); i--;)
Slur::add_column (slurs_[i], e);
- for (int i = end_slurs_.size (); i-- ; )
+ for (int i = end_slurs_.size (); i--;)
Slur::add_column (end_slurs_[i], e);
}
else
|| Slur::has_interface (e)
|| to_boolean (inside))
{
- for (int i = slurs_.size (); i--; )
+ for (int i = slurs_.size (); i--;)
Slur::add_extra_encompass (slurs_[i], e);
- for (int i = end_slurs_.size (); i--; )
+ for (int i = end_slurs_.size (); i--;)
Slur::add_extra_encompass (end_slurs_[i], e);
}
else if (inside == SCM_BOOL_F)
{
- Grob *slur = slurs_.size()?slurs_[0] : 0;
- slur = (end_slurs_.size () && !slur)
+ Grob *slur = slurs_.size ()?slurs_[0] : 0;
+ slur = (end_slurs_.size () && !slur)
? end_slurs_[0] : slur;
if (slur)
{
e->add_offset_callback (Slur::outside_slur_callback_proc, Y_AXIS);
- e->set_property ("slur", slur->self_scm());
+ e->set_property ("slur", slur->self_scm ());
}
}
}
end_slurs_ = slurs_;
slurs_.clear ();
}
-
+
if (events_[START] && slurs_.is_empty ())
{
Music *ev = events_[START];
- Grob * slur = make_spanner ("PhrasingSlur", events_[START]->self_scm ());
+ Grob *slur = make_spanner ("PhrasingSlur", events_[START]->self_scm ());
Direction updown = to_dir (ev->get_property ("direction"));
if (updown)
set_grob_direction (slur, updown);
events_[START] = events_[STOP] = 0;
}
-
ADD_TRANSLATOR (Phrasing_slur_engraver,
-/* descr */ "Print phrasing slurs. Similar to @ref{Slur_engraver}",
-/* creats*/ "PhrasingSlur",
-/* accepts */ "phrasing-slur-event",
-/* acks */ "note-column-interface tie-interface fingering-interface script-interface slur-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Print phrasing slurs. Similar to @ref{Slur_engraver}",
+ /* creats*/ "PhrasingSlur",
+ /* accepts */ "phrasing-slur-event",
+ /* acks */ "note-column-interface tie-interface fingering-interface script-interface slur-interface",
+ /* reads */ "",
+ /* write */ "");
-/*
+/*
piano-pedal-bracket.cc -- implement Piano_pedal_bracket
-source file of the GNU LilyPond music typesetter
-
-(c) 2003--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ source file of the GNU LilyPond music typesetter
+ (c) 2003--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include "stencil.hh"
struct Piano_pedal_bracket
{
DECLARE_SCHEME_CALLBACK (print, (SCM));
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
};
-
MAKE_SCHEME_CALLBACK (Piano_pedal_bracket, print, 1);
SCM
Piano_pedal_bracket::print (SCM smob)
{
- Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (smob));
- Spanner *orig = dynamic_cast<Spanner*> (me->original_);
-
+ Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
+ Spanner *orig = dynamic_cast<Spanner *> (me->original_);
+
Drul_array<bool> broken (false, false);
Drul_array<Real> height = robust_scm2drul
(me->get_property ("edge-height"), Interval (0, 0));
if (broken[d])
{
if (orig
- && ((d == RIGHT && me->get_break_index () != orig->broken_intos_.size()-1)
+ && ((d == RIGHT && me->get_break_index () != orig->broken_intos_.size () - 1)
|| (d == LEFT && me->get_break_index ())))
height[d] = 0.0;
else
- flare[d] = 0.0;
+ flare[d] = 0.0;
}
-
- Interval ext = robust_relative_extent (b, common, X_AXIS);
- span_points[d] = ext [broken[d] ? RIGHT : LEFT];
+
+ Interval ext = robust_relative_extent (b, common, X_AXIS);
+ span_points[d] = ext [broken[d] ? RIGHT : LEFT];
}
while (flip (&d) != LEFT);
-
/* For 'Mixed' style pedals, i.e. a bracket preceded by text: Ped._____|
- need to shorten by the extent of the text grob
+ need to shorten by the extent of the text grob
*/
if (textbit)
{
height[LEFT] = 0;
-
+
Real padding = robust_scm2double (me->get_property ("bound-padding"), 0);
-
+
span_points[LEFT] = padding
+ robust_relative_extent (textbit, common, X_AXIS)[RIGHT];
}
- Stencil m ;
- if (!span_points.is_empty () &&
- span_points.length () > 0.001)
+ Stencil m;
+ if (!span_points.is_empty ()
+ && span_points.length () > 0.001)
{
m = Tuplet_bracket::make_bracket (me, Y_AXIS,
Offset (span_points.length (), 0),
return m.smobbed_copy ();
}
-
-
ADD_INTERFACE (Piano_pedal_bracket, "piano-pedal-bracket-interface",
"The bracket of the piano pedal. It can be tuned through the regular "
"bracket properties.",
-/*
- piano-pedal-engraver.cc -- implement Piano_pedal_engraver
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
-
- Chris Jackson <chris@fluffhouse.org.uk> - extended to support
- bracketed pedals.
+/*
+ piano-pedal-engraver.cc -- implement Piano_pedal_engraver
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ Chris Jackson <chris@fluffhouse.org.uk> - extended to support
+ bracketed pedals.
*/
#include "engraver.hh"
struct Pedal_info
{
- char const * name_;
+ char const *name_;
/*
Event for currently running pedal.
*/
- Music* current_bracket_ev_;
+ Music *current_bracket_ev_;
/*
Event for currently starting pedal, (necessary?
-
+
distinct from current_bracket_ev_, since current_bracket_ev_ only
necessary for brackets, not for text style.
*/
- Music* start_ev_;
+ Music *start_ev_;
-
-
/*
Events that were found in this timestep.
*/
- Drul_array<Music*> event_drul_;
- Item* item_;
- Spanner* bracket_; // A single portion of a pedal bracket
- Spanner* finished_bracket_;
+ Drul_array<Music *> event_drul_;
+ Item *item_;
+ Spanner *bracket_; // A single portion of a pedal bracket
+ Spanner *finished_bracket_;
/*
This grob contains all the pedals of the same type on the same staff
*/
- Spanner* line_spanner_;
- Spanner* finished_line_spanner_;
+ Spanner *line_spanner_;
+ Spanner *finished_line_spanner_;
};
-
class Piano_pedal_engraver : public Engraver
{
public:
protected:
virtual void initialize ();
virtual void finalize ();
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void stop_translation_timestep ();
virtual void acknowledge_grob (Grob_info);
virtual void process_music ();
Record a stack of the current pedal spanners, so if more than one pedal
occurs simultaneously then extra space can be added between them.
*/
-
+
Link_array<Spanner> previous_;
- void del_linespanner (Spanner*);
-
+ void del_linespanner (Spanner *);
+
void create_text_grobs (Pedal_info *p, bool);
void create_bracket_grobs (Pedal_info *p, bool);
- void typeset_all (Pedal_info*p);
+ void typeset_all (Pedal_info *p);
};
-
Piano_pedal_engraver::Piano_pedal_engraver ()
{
info_list_ = 0;
void
Piano_pedal_engraver::initialize ()
{
- char * names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 };
+ char *names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 };
- info_list_ = new Pedal_info[sizeof (names)/ sizeof (const char*)];
+ info_list_ = new Pedal_info[sizeof (names)/ sizeof (const char *)];
Pedal_info *p = info_list_;
- char **np = names ;
+ char **np = names;
do
{
p->name_ = *np;
p++;
}
- while (* (np ++));
+ while (* (np++));
}
Piano_pedal_engraver::~Piano_pedal_engraver ()
void
Piano_pedal_engraver::acknowledge_grob (Grob_info info)
{
- for (Pedal_info*p = info_list_; p && p->name_; p ++)
+ for (Pedal_info *p = info_list_; p && p->name_; p++)
{
if (Note_column::has_interface (info.grob_))
{
{
Side_position_interface::add_support (p->line_spanner_, info.grob_);
add_bound_item (p->line_spanner_, info.grob_);
- }
+ }
if (p->bracket_)
add_bound_item (p->bracket_, info.grob_);
if (p->finished_bracket_)
- add_bound_item (p->finished_bracket_, info.grob_);
+ add_bound_item (p->finished_bracket_, info.grob_);
}
}
}
{
if (m->is_mus_type ("pedal-event"))
{
- for (Pedal_info*p = info_list_; p->name_; p ++)
+ for (Pedal_info *p = info_list_; p->name_; p++)
{
String nm = p->name_ + String ("Event");
- if (ly_c_equal_p (m->get_property ("name") ,
- scm_str2symbol(nm.to_str0())))
+ if (ly_c_equal_p (m->get_property ("name"),
+ scm_str2symbol (nm.to_str0 ())))
{
Direction d = to_dir (m->get_property ("span-direction"));
p->event_drul_[d] = m;
void
Piano_pedal_engraver::process_music ()
{
- for (Pedal_info*p = info_list_; p && p->name_; p ++)
+ for (Pedal_info *p = info_list_; p && p->name_; p++)
{
if (p->event_drul_[STOP] || p->event_drul_[START])
{
if (!p->line_spanner_)
{
- String name = String (p->name_) + "PedalLineSpanner";
- Music * rq = (p->event_drul_[START] ? p->event_drul_[START] : p->event_drul_[STOP]);
+ String name = String (p->name_) + "PedalLineSpanner";
+ Music *rq = (p->event_drul_[START] ? p->event_drul_[START] : p->event_drul_[STOP]);
p->line_spanner_ = make_spanner (name.to_str0 (), rq->self_scm ());
-
-
}
-
+
/* Choose the appropriate grobs to add to the line spanner
These can be text items or text-spanners
*/
mixed: Ped. _____/\____|
*/
-
- String prop = String ("pedal") + p->name_ + "Style";
+ String prop = String ("pedal") + p->name_ + "Style";
SCM style = get_property (prop.to_str0 ());
bool mixed = style == ly_symbol2scm ("mixed");
|| style == ly_symbol2scm ("bracket"));
bool text = (style == ly_symbol2scm ("text")
|| mixed);
-
+
if (text && !p->item_)
create_text_grobs (p, mixed);
if (bracket)
Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed)
{
SCM s = SCM_EOL;
- SCM strings = get_property ( ("pedal" + String (p->name_) + "Strings").to_str0 ());
+ SCM strings = get_property (("pedal" + String (p->name_) + "Strings").to_str0 ());
if (scm_ilength (strings) < 3)
{
- Music * m = p->event_drul_[START];
+ Music *m = p->event_drul_[START];
if (!m) m = p->event_drul_ [STOP];
String msg = _ ("Need 3 strings for piano pedals. No pedal made. ");
m->origin ()->warning (msg);
else
warning (msg);
-
- return ;
+
+ return;
}
-
- if (p->event_drul_[STOP] && p->event_drul_[START])
+
+ if (p->event_drul_[STOP] && p->event_drul_[START])
{
if (!mixed)
{
if (!p->start_ev_)
{
- p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", p->name_));
+ p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", p->name_));
}
else
{
}
}
else if (p->event_drul_[STOP])
- {
+ {
if (!mixed)
{
if (!p->start_ev_)
previous_.push (p->line_spanner_);
}
}
-
+
if (scm_is_string (s))
{
String propname = String (p->name_) + "Pedal";
p->item_->set_property ("text", s);
Axis_group_interface::add_element (p->line_spanner_, p->item_);
}
-
+
if (!mixed)
{
p->event_drul_[START] = 0;
}
}
-
void
Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed)
{
{
String msg = _f ("can't find start of piano pedal bracket: `%s'", p->name_);
p->event_drul_[STOP]->origin ()->warning (msg);
- p->event_drul_[STOP] = 0;
+ p->event_drul_[STOP] = 0;
}
if (p->event_drul_[STOP])
{
- assert (!p->finished_bracket_);
+ assert (!p->finished_bracket_);
Grob *cmc = unsmob_grob (get_property ("currentMusicalColumn"));
p->start_ev_ = p->event_drul_[START];
p->current_bracket_ev_ = p->event_drul_[START];
- p->bracket_ = make_spanner ("PianoPedalBracket", p->event_drul_[START]->self_scm ());
+ p->bracket_ = make_spanner ("PianoPedalBracket", p->event_drul_[START]->self_scm ());
/*
Set properties so that the stencil-creating function will
p->bracket_->set_property ("bracket-flare", scm_cons (scm_make_real (0), scm_cdr (flare)));
}
-
- /* Set this property for 'mixed style' pedals, Ped._______/\ ,
+ /* Set this property for 'mixed style' pedals, Ped._______/\ ,
so the stencil function will shorten the ____ line by the length of the Ped. text.
*/
p->bracket_->set_property ("pedal-text", p->item_->self_scm ());
}
-
/*
We do not use currentMusicalColumn for the left span-point.
If the column as accidentals (eg on a different stave), the
TODO:
what about the right span point?
-
+
*/
- Axis_group_interface::add_element (p->line_spanner_, p->bracket_);
+ Axis_group_interface::add_element (p->line_spanner_, p->bracket_);
if (!p->event_drul_[STOP])
{
// position new pedal spanner below the current one
*/
- if (previous_.size ())
+ if (previous_.size ())
Side_position_interface::add_support (p->line_spanner_, previous_.top ());
- previous_.push (p->line_spanner_);
+ previous_.push (p->line_spanner_);
}
}
void
Piano_pedal_engraver::finalize ()
-{
- for (Pedal_info*p = info_list_; p && p->name_; p ++)
+{
+ for (Pedal_info *p = info_list_; p && p->name_; p++)
{
/*
suicide?
if (p->line_spanner_
&& !p->line_spanner_->is_live ())
p->line_spanner_ = 0;
-
+
if (p->bracket_
&& !p->bracket_->is_live ())
p->bracket_ = 0;
-
+
if (p->bracket_)
{
SCM cc = get_property ("currentCommandColumn");
void
Piano_pedal_engraver::stop_translation_timestep ()
{
- for (Pedal_info*p = info_list_; p && p->name_; p ++)
+ for (Pedal_info *p = info_list_; p && p->name_; p++)
{
if (!p->bracket_)
{
p->line_spanner_ = 0;
del_linespanner (p->finished_line_spanner_);
}
-
+
typeset_all (p);
}
-
- for (Pedal_info*p = info_list_; p->name_; p ++)
+ for (Pedal_info *p = info_list_; p->name_; p++)
{
p->event_drul_[STOP] = 0;
p->event_drul_[START] = 0;
}
}
-
void
-Piano_pedal_engraver::typeset_all (Pedal_info * p)
+Piano_pedal_engraver::typeset_all (Pedal_info *p)
{
/*
- Handle suicide.
+ Handle suicide.
*/
if (p->finished_line_spanner_
&& !p->finished_line_spanner_->is_live ())
&& !p->finished_bracket_->is_live ())
p->finished_bracket_ = 0;
-
if (p->item_)
{
p->item_ = 0;
}
-
+
if (p->finished_bracket_)
{
- Grob * r = p->finished_bracket_->get_bound (RIGHT);
+ Grob *r = p->finished_bracket_->get_bound (RIGHT);
if (!r)
{
p->finished_bracket_->set_bound (RIGHT, unsmob_grob (get_property ("currentMusicalColumn")));
if (p->finished_line_spanner_)
{
- Grob * l = p->finished_line_spanner_->get_bound (LEFT);
- Grob * r = p->finished_line_spanner_->get_bound (RIGHT);
+ Grob *l = p->finished_line_spanner_->get_bound (LEFT);
+ Grob *r = p->finished_line_spanner_->get_bound (RIGHT);
if (!r && l)
p->finished_line_spanner_->set_bound (RIGHT, l);
else if (!l && r)
p->finished_line_spanner_->set_bound (LEFT, r);
else if (!r && !l)
{
- Grob * cc = unsmob_grob (get_property ("currentMusicalColumn"));
- Item * ci = dynamic_cast<Item*> (cc);
+ Grob *cc = unsmob_grob (get_property ("currentMusicalColumn"));
+ Item *ci = dynamic_cast<Item *> (cc);
p->finished_line_spanner_->set_bound (RIGHT, ci);
- p->finished_line_spanner_->set_bound (LEFT, ci);
+ p->finished_line_spanner_->set_bound (LEFT, ci);
}
-
+
p->finished_line_spanner_ = 0;
}
}
ADD_TRANSLATOR (Piano_pedal_engraver,
- /* descr */ "Engrave piano pedal symbols and brackets.",
- /* creats*/ "SostenutoPedal SustainPedal UnaCordaPedal SostenutoPedalLineSpanner SustainPedalLineSpanner UnaCordaPedalLineSpanner",
- /* accepts */ "pedal-event",
- /* acks */ "note-column-interface",
- /* reads */ "currentCommandColumn "
- "pedalSostenutoStrings pedalSustainStrings "
- "pedalUnaCordaStrings pedalSostenutoStyle "
- "pedalSustainStyle pedalUnaCordaStyle",
- /* write */ "");
+ /* descr */ "Engrave piano pedal symbols and brackets.",
+ /* creats*/ "SostenutoPedal SustainPedal UnaCordaPedal SostenutoPedalLineSpanner SustainPedalLineSpanner UnaCordaPedalLineSpanner",
+ /* accepts */ "pedal-event",
+ /* acks */ "note-column-interface",
+ /* reads */ "currentCommandColumn "
+ "pedalSostenutoStrings pedalSustainStrings "
+ "pedalUnaCordaStrings pedalSostenutoStyle "
+ "pedalSustainStyle pedalUnaCordaStyle",
+ /* write */ "");
/**
perform Piano pedals
- */
+*/
class Piano_pedal_performer : public Performer
{
struct Pedal_info
{
char const *name_;
- Music* start_req_;
- Drul_array<Music*> req_drul_;
+ Music *start_req_;
+ Drul_array<Music *> req_drul_;
};
public:
TRANSLATOR_DECLARATIONS (Piano_pedal_performer);
~Piano_pedal_performer ();
-
+
protected:
virtual void initialize ();
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void create_audio_elements ();
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
private:
Link_array<Audio_piano_pedal> audios_;
- Pedal_info * info_alist_;
+ Pedal_info *info_alist_;
};
Piano_pedal_performer::Piano_pedal_performer ()
info_alist_ = new Pedal_info[4];
Pedal_info *p = info_alist_;
- char * names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 };
- char **np = names ;
+ char *names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 };
+ char **np = names;
do
{
p->name_ = *np;
p++;
}
- while (* (np ++));
+ while (* (np++));
}
void
Piano_pedal_performer::create_audio_elements ()
{
- for (Pedal_info*p = info_alist_; p && p->name_; p ++)
-
+ for (Pedal_info *p = info_alist_; p && p->name_; p++)
+
{
if (p->req_drul_[STOP])
{
}
else
{
- Audio_piano_pedal* a = new Audio_piano_pedal;
+ Audio_piano_pedal *a = new Audio_piano_pedal;
a->type_string_ = String (p->name_);
a->dir_ = STOP;
audios_.push (a);
if (p->req_drul_[START])
{
p->start_req_ = p->req_drul_[START];
- Audio_piano_pedal* a = new Audio_piano_pedal;
+ Audio_piano_pedal *a = new Audio_piano_pedal;
a->type_string_ = String (p->name_);
a->dir_ = START;
audios_.push (a);
void
Piano_pedal_performer::start_translation_timestep ()
{
- for (Pedal_info*p = info_alist_; p && p->name_; p ++)
+ for (Pedal_info *p = info_alist_; p && p->name_; p++)
{
p->req_drul_[STOP] = 0;
p->req_drul_[START] = 0;
}
bool
-Piano_pedal_performer::try_music (Music* r)
+Piano_pedal_performer::try_music (Music *r)
{
- if (r->is_mus_type ("pedal-event"))
+ if (r->is_mus_type ("pedal-event"))
{
- for (Pedal_info*p = info_alist_; p->name_; p ++)
+ for (Pedal_info *p = info_alist_; p->name_; p++)
{
String nm = p->name_ + String ("Event");
- if (ly_c_equal_p (r->get_property ("name") ,
- scm_str2symbol (nm.to_str0())))
+ if (ly_c_equal_p (r->get_property ("name"),
+ scm_str2symbol (nm.to_str0 ())))
{
Direction d = to_dir (r->get_property ("span-direction"));
p->req_drul_[d] = r;
}
ADD_TRANSLATOR (Piano_pedal_performer, "", "",
- "pedal-event",
- "", "", "" );
+ "pedal-event",
+ "", "", "");
-/*
+/*
pitch-interval.cc -- implement Pitch_interval
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "pitch-interval.hh"
Pitch_interval::Pitch_interval (Pitch p1, Pitch p2)
{
- elem_ref(LEFT) = p1;
- elem_ref(RIGHT) = p2;
+ elem_ref (LEFT) = p1;
+ elem_ref (RIGHT) = p2;
}
-
Pitch_interval::Pitch_interval ()
{
- elem_ref(LEFT) = Pitch (100, 0, 0);
- elem_ref(RIGHT) = Pitch (-100, 0, 0);
+ elem_ref (LEFT) = Pitch (100, 0, 0);
+ elem_ref (RIGHT) = Pitch (-100, 0, 0);
}
-
bool
Pitch_interval::is_empty () const
{
- return elem(LEFT) > elem(RIGHT);
+ return elem (LEFT) > elem (RIGHT);
}
-
void
Pitch_interval::add_point (Pitch p)
{
- if (elem_ref(LEFT) > p)
- elem_ref(LEFT) = p;
- if (elem_ref(RIGHT) < p)
- elem_ref(RIGHT) = p;
+ if (elem_ref (LEFT) > p)
+ elem_ref (LEFT) = p;
+ if (elem_ref (RIGHT) < p)
+ elem_ref (RIGHT) = p;
}
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "pitch.hh"
"Transpose @var{p} by the amount @var{delta}, "
"where @var{delta} is relative to middle C.")
{
- Pitch* t = unsmob_pitch (p);
+ Pitch *t = unsmob_pitch (p);
Pitch *d = unsmob_pitch (delta);
SCM_ASSERT_TYPE (t, p, SCM_ARG1, __FUNCTION__, "pitch");
SCM_ASSERT_TYPE (d, delta, SCM_ARG1, __FUNCTION__, "pitch");
"The @var{alter} is zero for a natural, negative for "
"flats, or positive for sharps. ")
{
- SCM_ASSERT_TYPE (scm_integer_p (octave)== SCM_BOOL_T , octave, SCM_ARG1, __FUNCTION__, "integer");
+ SCM_ASSERT_TYPE (scm_integer_p (octave)== SCM_BOOL_T, octave, SCM_ARG1, __FUNCTION__, "integer");
SCM_ASSERT_TYPE (scm_integer_p (note)== SCM_BOOL_T, note, SCM_ARG2, __FUNCTION__, "integer");
SCM_ASSERT_TYPE (scm_integer_p (alter)== SCM_BOOL_T, alter, SCM_ARG3, __FUNCTION__, "integer");
}
LY_DEFINE (ly_pitch_diff, "ly:pitch-diff",
- 2 , 0, 0, (SCM pitch, SCM root),
+ 2, 0, 0, (SCM pitch, SCM root),
"Return pitch @var{delta} such that @code{pitch} transposed by "
- "@var{delta} equals @var{root}" )
+ "@var{delta} equals @var{root}")
{
Pitch *p = unsmob_pitch (pitch);
Pitch *r = unsmob_pitch (root);
-/*
+/*
pitch-squash-engraver.cc -- implement Pitch_squash_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "staff-symbol-referencer.hh"
#include "note-head.hh"
#include "rhythmic-head.hh"
#include "engraver.hh"
-class Pitch_squash_engraver : public Engraver {
+class Pitch_squash_engraver : public Engraver
+{
public:
TRANSLATOR_DECLARATIONS (Pitch_squash_engraver);
virtual void acknowledge_grob (Grob_info);
};
-
void
Pitch_squash_engraver::acknowledge_grob (Grob_info i)
{
}
}
-
-
Pitch_squash_engraver::Pitch_squash_engraver ()
{
}
ADD_TRANSLATOR (Pitch_squash_engraver,
-/* descr */
- "Set the vertical position of noteheads to "
- "@code{squashedPosition}, if that "
- "property is set. "
- "This can be used to make a single line staff "
- "demonstrating the rhythm of a melody.",
-
-/* creats*/ "",
-/* accepts */ "",
-/* acks */ "note-head-interface",
-/* reads */ "squashedPosition",
-/* write */ "");
+ /* descr */
+ "Set the vertical position of noteheads to "
+ "@code{squashedPosition}, if that "
+ "property is set. "
+ "This can be used to make a single line staff "
+ "demonstrating the rhythm of a melody.",
+
+ /* creats*/ "",
+ /* accepts */ "",
+ /* acks */ "note-head-interface",
+ /* reads */ "squashedPosition",
+ /* write */ "");
int
Pitch::compare (Pitch const &m1, Pitch const &m2)
{
- int o = m1.octave_ - m2.octave_;
+ int o = m1.octave_ - m2.octave_;
int n = m1.notename_ - m2.notename_;
int a = m1.alteration_ - m2.alteration_;
int
Pitch::steps () const
{
- return notename_ + octave_*7;
+ return notename_ + octave_*7;
}
/* Should be settable from input? */
-static Byte diatonic_scale_semitones[ ] = { 0, 2, 4, 5, 7, 9, 11 };
-
+static Byte diatonic_scale_semitones[ ] = { 0, 2, 4, 5, 7, 9, 11 };
/* Calculate pitch height in 12th octave steps. Don't assume
normalised pitch as this function is used to normalise the pitch. */
while (n < 0)
{
n += 7;
- o --;
+ o--;
}
if (alteration_ % 2)
while (n < 0)
{
n += 7;
- o --;
+ o--;
}
return ((o + n / 7) * 24
void
Pitch::transpose (Pitch delta)
{
- int new_semi = quartertone_pitch () +delta.quartertone_pitch ();
+ int new_semi = quartertone_pitch () +delta.quartertone_pitch ();
octave_ += delta.octave_;
notename_ += delta.notename_;
alteration_ += new_semi - quartertone_pitch ();
}
Pitch
-pitch_interval (Pitch const & from , Pitch const & to )
+pitch_interval (Pitch const &from, Pitch const &to)
{
- int sound = to.quartertone_pitch () - from.quartertone_pitch ();
+ int sound = to.quartertone_pitch () - from.quartertone_pitch ();
Pitch pt (to.get_octave () - from.get_octave (),
to.get_notename () - from.get_notename (),
return pt.transposed (Pitch (0, 0, sound - pt.quartertone_pitch ()));
}
-
/* FIXME
Merge with *pitch->text* funcs in chord-name.scm */
char const *accname[] = {"eses", "eseh", "es", "eh", "",
- "ih", "is" , "isih", "isis"};
+ "ih", "is", "isih", "isis"};
String
Pitch::to_string () const
Pitch::to_relative_octave (Pitch p) const
{
/* account for c' = octave 1 iso. 0 4 */
- int oct_mod = octave_ + 1;
+ int oct_mod = octave_ + 1;
Pitch up_pitch (p);
Pitch down_pitch (p);
{
if (notename_ > notename)
octave_++;
- notename_ = notename;
+ notename_ = notename;
}
void
}
SCM
-Pitch::equal_p (SCM a , SCM b)
+Pitch::equal_p (SCM a, SCM b)
{
Pitch *p = (Pitch *) SCM_CELL_WORD_1 (a);
Pitch *q = (Pitch *) SCM_CELL_WORD_1 (b);
return eq ? SCM_BOOL_T : SCM_BOOL_F;
}
-
MAKE_SCHEME_CALLBACK (Pitch, less_p, 2);
SCM
Pitch::less_p (SCM p1, SCM p2)
return SCM_BOOL_F;
}
-
int
Pitch::get_octave () const
{
Property_unset_iterator::process (Moment m)
{
SCM sym = get_music ()->get_property ("symbol");
- type_check_assignment (sym, SCM_EOL, ly_symbol2scm ("translation-type?"));
+ type_check_assignment (sym, SCM_EOL, ly_symbol2scm ("translation-type?"));
get_outlet ()->unset_property (sym);
Simple_music_iterator::process (m);
MAKE_SCHEME_CALLBACK (Property_iterator, once_finalization, 2);
SCM
-Property_iterator::once_finalization (SCM translator, SCM music )
+Property_iterator::once_finalization (SCM translator, SCM music)
{
- Music * m = unsmob_music (music);
- Context * tg
+ Music *m = unsmob_music (music);
+ Context *tg
= dynamic_cast<Context *> (unsmob_context (translator));
SCM sym = m->get_property ("symbol");
void
Property_iterator::do_quit ()
{
- if (to_boolean (get_music ()->get_property ("once")))
+ if (to_boolean (get_music ()->get_property ("once")))
{
SCM trans = get_outlet ()->self_scm ();
SCM music = get_music ()->self_scm ();
- Global_context * tg = get_outlet ()->get_global_context ();
+ Global_context *tg = get_outlet ()->get_global_context ();
tg->add_finalization (scm_list_n (once_finalization_proc,
trans, music, SCM_UNDEFINED));
}
}
-
SCM list_p = 0;
/*
This is a rather crude check: we merely check if the translator
property is a list.
- */
+*/
bool
check_grob (Music *mus, SCM sym)
{
{
list_p = scm_c_eval_string ("list?");
}
-
-
+
SCM type = scm_object_property (sym, ly_symbol2scm ("translation-type?"));
bool ok = type == list_p;
if (!ok)
{
- mus->origin ()->warning (_f ("Not a grob name, `%s'." , ly_symbol2string (sym)));
+ mus->origin ()->warning (_f ("Not a grob name, `%s'.", ly_symbol2string (sym)));
}
- return ok;
+ return ok;
}
void
SCM
Push_property_iterator::once_finalization (SCM trans, SCM music)
{
- Music * mus = unsmob_music (music);
- Context * tg = dynamic_cast<Context *> (unsmob_context (trans));
-
+ Music *mus = unsmob_music (music);
+ Context *tg = dynamic_cast<Context *> (unsmob_context (trans));
+
SCM sym = mus->get_property ("symbol");
if (check_grob (mus, sym))
{
SCM eprop = mus->get_property ("grob-property");
-
+
execute_pushpop_property (tg, sym, eprop, SCM_UNDEFINED);
}
return SCM_UNSPECIFIED;
void
Push_property_iterator::do_quit ()
{
- if (to_boolean (get_music ()->get_property ("once")))
+ if (to_boolean (get_music ()->get_property ("once")))
{
SCM trans = get_outlet ()->self_scm ();
SCM music = get_music ()->self_scm ();
- Global_context * tg = get_outlet ()->get_global_context ();
+ Global_context *tg = get_outlet ()->get_global_context ();
tg->add_finalization (scm_list_n (once_finalization_proc,
trans, music, SCM_UNDEFINED));
}
Pop_property_iterator::process (Moment m)
{
SCM sym = get_music ()->get_property ("symbol");
-
+
if (check_grob (get_music (), sym))
{
SCM eprop = get_music ()->get_property ("grob-property");
-execute_pushpop_property (get_outlet (), sym, eprop, SCM_UNDEFINED);
+ execute_pushpop_property (get_outlet (), sym, eprop, SCM_UNDEFINED);
}
Simple_music_iterator::process (m);
}
-
-
IMPLEMENT_CTOR_CALLBACK (Pop_property_iterator);
IMPLEMENT_CTOR_CALLBACK (Push_property_iterator);
IMPLEMENT_CTOR_CALLBACK (Property_iterator);
-/*
+/*
protected-scm.cc -- implement Protected_scm
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "protected-scm.hh"
scm_gc_unprotect_object (object_);
}
-Protected_scm &
-Protected_scm::operator = (SCM s)
+Protected_scm &
+Protected_scm::operator= (SCM s)
{
if (object_ == s)
return *this;
-
+
if (SCM_NIMP (object_))
scm_gc_unprotect_object (object_);
return *this;
}
-Protected_scm&
-Protected_scm::operator = (Protected_scm const &s)
+Protected_scm &
+Protected_scm::operator= (Protected_scm const &s)
{
- return operator = (s.object_);
+ return operator= (s.object_);
}
Protected_scm::operator SCM () const
return object_;
}
-SCM
+SCM
Protected_scm::to_SCM () const
{
return object_;
-/*
+/*
quote-iterator.cc -- implement Quote_iterator
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "context.hh"
Moment stop_moment_;
SCM event_vector_;
int event_idx_;
- int end_idx_ ;
+ int end_idx_;
SCM transposed_musics_;
-
- DECLARE_SCHEME_CALLBACK (constructor, ());
+
+ DECLARE_SCHEME_CALLBACK (constructor, ());
bool quote_ok () const;
- bool accept_music_type (Music*) const;
+ bool accept_music_type (Music *) const;
protected:
virtual void derived_mark () const;
virtual void construct_children ();
bool
Quote_iterator::accept_music_type (Music *mus) const
{
- SCM accept = get_outlet()->get_property ("quotedEventTypes");
- for (SCM s = mus->get_property ("types");
- scm_is_pair (s); s = scm_cdr (s))
+ SCM accept = get_outlet ()->get_property ("quotedEventTypes");
+ for (SCM s = mus->get_property ("types");
+ scm_is_pair (s); s = scm_cdr (s))
{
if (scm_memq (scm_car (s), accept) != SCM_BOOL_F)
return true;
return false;
}
-
void
Quote_iterator::derived_mark () const
{
- scm_gc_mark (transposed_musics_ );
+ scm_gc_mark (transposed_musics_);
}
Quote_iterator::Quote_iterator ()
end_idx_ = 0;
}
-
int
-binsearch_scm_vector (SCM vec, SCM key, bool (*is_less)(SCM a, SCM b))
+binsearch_scm_vector (SCM vec, SCM key, bool (*is_less) (SCM a, SCM b))
{
int lo = 0;
int hi = scm_c_vector_length (vec);
/* binary search */
do
- {
- int cmp = (lo + hi) / 2;
+ {
+ int cmp = (lo + hi) / 2;
SCM when = scm_caar (scm_c_vector_ref (vec, cmp));
- bool result = (*is_less) (key, when);
+ bool result = (*is_less) (key, when);
if (result)
- hi = cmp;
+ hi = cmp;
else
- lo = cmp;
+ lo = cmp;
}
while (hi - lo > 1);
return lo;
}
-
void
Quote_iterator::construct_children ()
{
if (scm_is_string (id)
&& scm_is_symbol (name))
{
- Context *cue_context = get_outlet()->find_create_context (name,
- ly_scm2string (id), SCM_EOL);
+ Context *cue_context = get_outlet ()->find_create_context (name,
+ ly_scm2string (id), SCM_EOL);
quote_outlet_.set_context (cue_context);
}
else
{
quote_outlet_.set_context (get_outlet ());
}
-
event_vector_ = get_music ()->get_property ("quoted-events");
-
+
/*
We have to delay initting event_idx_ , since we have to
- take starting grace notes into account. Those may offset
+ take starting grace notes into account. Those may offset
event_idx_.
*/
event_idx_ = -1;
}
-
bool
Quote_iterator::ok () const
{
return
- Music_wrapper_iterator::ok()
+ Music_wrapper_iterator::ok ()
|| quote_ok ();
}
/*
Don't quote the grace notes leading to an unquoted note.
- */
- && vector_moment (event_idx_).main_part_ < stop_moment_.main_part_
- );
+ */
+ && vector_moment (event_idx_).main_part_ < stop_moment_.main_part_);
}
Moment
infty.set_infinite (1);
Moment m (infty);
- if (Music_wrapper_iterator::ok())
- m = m <? Music_wrapper_iterator::pending_moment();
+ if (Music_wrapper_iterator::ok ())
+ m = m <? Music_wrapper_iterator::pending_moment ();
/*
In case event_idx_ < 0, we're not initted yet, and the wrapped
music expression determines the starting moment.
- */
+ */
if (quote_ok ())
m = m <? vector_moment (event_idx_) - start_moment_;
void
Quote_iterator::process (Moment m)
{
- if (Music_wrapper_iterator::ok())
+ if (Music_wrapper_iterator::ok ())
Music_wrapper_iterator::process (m);
if (!scm_is_vector (event_vector_))
- return ;
-
+ return;
+
if (event_idx_ < 0)
{
event_idx_ = binsearch_scm_vector (event_vector_,
get_outlet ()->now_mom ().smobbed_copy (),
&moment_less);
- start_moment_ = get_outlet ()->now_mom () - music_start_mom();
- stop_moment_ = start_moment_ + get_music()->get_length ();
-
+ start_moment_ = get_outlet ()->now_mom () - music_start_mom ();
+ stop_moment_ = start_moment_ + get_music ()->get_length ();
+
end_idx_ = binsearch_scm_vector (event_vector_,
stop_moment_.smobbed_copy (),
&moment_less);
}
-
+
m += start_moment_;
while (event_idx_ <= end_idx_)
{
Moment em = vector_moment (event_idx_);
if (em > m)
- return ;
+ return;
if (em == m)
- break ;
+ break;
event_idx_++;
}
if (quote_ok ())
{
SCM entry = scm_c_vector_ref (event_vector_, event_idx_);
- Pitch * quote_pitch = unsmob_pitch (scm_cdar (entry));
+ Pitch *quote_pitch = unsmob_pitch (scm_cdar (entry));
/*
The pitch that sounds like central C
- */
- Pitch * me_pitch = unsmob_pitch (get_outlet ()->get_property ("instrumentTransposition"));
-
+ */
+ Pitch *me_pitch = unsmob_pitch (get_outlet ()->get_property ("instrumentTransposition"));
+
for (SCM s = scm_cdr (entry); scm_is_pair (s); s = scm_cdr (s))
{
SCM ev_acc = scm_car (s);
- Music * mus = unsmob_music (scm_car (ev_acc));
+ Music *mus = unsmob_music (scm_car (ev_acc));
if (!mus)
programming_error ("need music in quote.");
else if (accept_music_type (mus))
SCM copy = ly_music_deep_copy (mus->self_scm ());
mus = unsmob_music (copy);
-
+
transposed_musics_ = scm_cons (copy, transposed_musics_);
mus->transpose (diff);
}
-
+
bool b = quote_outlet_.get_outlet ()->try_music (mus);
if (!b)
mus->origin ()->warning (_f ("In quotation: junking event %s", mus->name ()));
}
}
-
- event_idx_ ++;
+
+ event_idx_++;
}
}
-/*
+/*
recording-group-engraver.cc -- implement Recording_group_engraver
source file of the GNU LilyPond music typesetter
(c) 2003--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
- */
+*/
#include "context.hh"
#include "engraver-group-engraver.hh"
void
Recording_group_engraver::derived_mark () const
{
- Engraver_group_engraver::derived_mark();
+ Engraver_group_engraver::derived_mark ();
scm_gc_mark (now_events_);
scm_gc_mark (accumulator_);
}
now_events_ = scm_cons (scm_cons (music, success), now_events_);
}
-
void
Recording_group_engraver::stop_translation_timestep ()
{
Engraver_group_engraver::stop_translation_timestep ();
accumulator_ = scm_acons (scm_cons (now_mom ().smobbed_copy (),
- get_property ("instrumentTransposition")),
+ get_property ("instrumentTransposition")),
now_events_,
accumulator_);
now_events_ = SCM_EOL;
SCM proc = get_property ("recordEventSequence");
if (ly_c_procedure_p (proc))
- scm_call_2 (proc, context ()->self_scm (), scm_cdr (accumulator_));
+ scm_call_2 (proc, context ()->self_scm (), scm_cdr (accumulator_));
}
bool
-Recording_group_engraver::try_music (Music *m)
+Recording_group_engraver::try_music (Music *m)
{
bool retval = Translator_group::try_music (m);
return retval;
}
-
ADD_TRANSLATOR (Recording_group_engraver,
- "Engraver_group_engraver that records all music events "
- "for this context. Calls the procedure "
- "in @code{recordEventSequence} when finished.",
- "",
- "",
- "",
- "recordEventSequence",
- "");
+ "Engraver_group_engraver that records all music events "
+ "for this context. Calls the procedure "
+ "in @code{recordEventSequence} when finished.",
+ "",
+ "",
+ "",
+ "recordEventSequence",
+ "");
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "music.hh"
class Relative_octave_check
{
public:
- DECLARE_SCHEME_CALLBACK(relative_callback, (SCM, SCM));
+ DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM));
};
-
-MAKE_SCHEME_CALLBACK(Relative_octave_check, relative_callback, 2)
-SCM
+MAKE_SCHEME_CALLBACK (Relative_octave_check, relative_callback, 2)
+ SCM
Relative_octave_check::relative_callback (SCM music, SCM last_pitch)
{
Pitch p = *unsmob_pitch (last_pitch);
- Music *m = unsmob_music (music);
+ Music *m = unsmob_music (music);
Pitch *check_p = unsmob_pitch (m->get_property ("pitch"));
-
+
int delta_oct = 0;
if (check_p)
{
if (result != *check_p)
{
- String s = _("Failed octave check, got: ");
+ String s = _ ("Failed octave check, got: ");
s += result.to_string ();
-
+
m->origin ()->warning (s);
-
+
delta_oct = check_p->get_octave () - result.get_octave ();
}
}
-
+
return Pitch (p.get_octave () + delta_oct,
p.get_notename (), p.get_alteration ()).smobbed_copy ();
}
-/*
+/*
relative-music.cc -- implement Relative_octave_music
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "music.hh"
#include "pitch.hh"
#include "warn.hh"
#include "scm-option.hh"
-
class Relative_octave_music
{
public:
- DECLARE_SCHEME_CALLBACK(relative_callback, (SCM, SCM));
- DECLARE_SCHEME_CALLBACK(no_relative_callback, (SCM, SCM));
+ DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM));
+ DECLARE_SCHEME_CALLBACK (no_relative_callback, (SCM, SCM));
};
-MAKE_SCHEME_CALLBACK(Relative_octave_music, no_relative_callback, 2)
-SCM
+MAKE_SCHEME_CALLBACK (Relative_octave_music, no_relative_callback, 2)
+ SCM
Relative_octave_music::no_relative_callback (SCM music, SCM pitch)
{
(void)music;
return pitch;
}
-MAKE_SCHEME_CALLBACK(Relative_octave_music, relative_callback, 2)
-SCM
+MAKE_SCHEME_CALLBACK (Relative_octave_music, relative_callback, 2)
+ SCM
Relative_octave_music::relative_callback (SCM music, SCM pitch)
{
Music *me = unsmob_music (music);
/* last-pitch should be junked some time, when
we ditch 1.8 compat too.
- When you do, B should start where A left off.
+ When you do, B should start where A left off.
- \relative { A \relative { ...} B } */
+ \relative { A \relative { ...} B } */
SCM last_pitch = me->get_property ("last-pitch");
Pitch *ptr = unsmob_pitch (last_pitch);
- return (ptr) ? last_pitch : pitch;
+ return (ptr) ? last_pitch : pitch;
}
else
return pitch;
}
-
-/*
+/*
repeat-acknowledge-engraver.cc -- implement Repeat_acknowledge_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "engraver.hh"
#include "translator-group.hh"
Objective:
-- set and reset repeatCommands, so Unfolded_repeat_iterator knows
- where to set variables.
+ where to set variables.
-- collect information passed by Unfolded_repeat_iterator for
- Bar_engraver: writes whichBar property. (TODO: check for
- interactions with timing engraver.)
-
- */
+ Bar_engraver: writes whichBar property. (TODO: check for
+ interactions with timing engraver.)
+*/
class Repeat_acknowledge_engraver : public Engraver
{
public:
-
+
TRANSLATOR_DECLARATIONS (Repeat_acknowledge_engraver);
protected:
virtual void start_translation_timestep ();
context ()->set_property ("repeatCommands", SCM_EOL);
}
-
Repeat_acknowledge_engraver::Repeat_acknowledge_engraver ()
{
}
void
Repeat_acknowledge_engraver::start_translation_timestep ()
{
- Context * tr = context ()->where_defined (ly_symbol2scm ("repeatCommands"));
+ Context *tr = context ()->where_defined (ly_symbol2scm ("repeatCommands"));
if (!tr)
tr = context ();
{
/*
At the start of a piece, we don't print any repeat bars.
- */
+ */
if (!now_mom ().main_part_)
- return ;
-
+ return;
+
SCM cs = get_property ("repeatCommands");
-
+
String s = "";
bool start = false;
bool end = false;
end = true;
else if (scm_is_pair (command) && scm_car (command) == ly_symbol2scm ("volta"))
volta_found = true;
- cs = scm_cdr (cs);
+ cs = scm_cdr (cs);
}
if (start && end)
/*
TODO: line breaks might be allowed if we set whichBar to "".
- */
+ */
/*
We only set the barline if we wouldn't overwrite a previously set
barline.
- */
+ */
SCM wb = get_property ("whichBar");
- SCM db = get_property ("defaultBarType");
+ SCM db = get_property ("defaultBarType");
if (!scm_is_string (wb) || ly_c_equal_p (db, wb))
{
if (s != "" || (volta_found && !scm_is_string (wb)))
}
ADD_TRANSLATOR (Repeat_acknowledge_engraver,
-/* descr */ "Acknowledge repeated music, and convert the contents of "
-"repeatCommands ainto an appropriate setting for whichBar.",
-/* creats*/ "",
-/* accepts */ "",
-/* acks */ "",
-/* reads */ "repeatCommands whichBar",
-/* write */ "");
+ /* descr */ "Acknowledge repeated music, and convert the contents of "
+ "repeatCommands ainto an appropriate setting for whichBar.",
+ /* creats*/ "",
+ /* accepts */ "",
+ /* acks */ "",
+ /* reads */ "repeatCommands whichBar",
+ /* write */ "");
-/*
+/*
repeated-music.cc -- implement Repeated_music
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "repeated-music.hh"
#include "music-sequence.hh"
return me->get_property ("elements");
}
-MAKE_SCHEME_CALLBACK(Repeated_music, relative_callback, 2);
+MAKE_SCHEME_CALLBACK (Repeated_music, relative_callback, 2);
SCM
Repeated_music::relative_callback (SCM music, SCM pitch)
{
Pitch p = *unsmob_pitch (pitch);
- Music *me = unsmob_music (music);
+ Music *me = unsmob_music (music);
if (lily_1_8_relative)
{
Music *body = unsmob_music (me->get_property ("element"));
if (body)
p = body->to_relative_octave (p);
- Pitch last = p ;
+ Pitch last = p;
SCM alternatives = me->get_property ("elements");
- for (SCM s = alternatives; scm_is_pair (s); s = scm_cdr (s))
+ for (SCM s = alternatives; scm_is_pair (s); s = scm_cdr (s))
{
lily_1_8_compatibility_used = true;
unsmob_music (scm_car (s))->to_relative_octave (p);
}
}
-
Moment
-Repeated_music::alternatives_get_length (Music *me, bool fold)
+Repeated_music::alternatives_get_length (Music *me, bool fold)
{
SCM alternative_list = alternatives (me);
int len = scm_ilength (alternative_list);
if (len <= 0)
return 0;
-
+
if (fold)
return Music_sequence::maximum_length (alternative_list);
while (scm_is_pair (p) && done < count)
{
m = m + unsmob_music (scm_car (p))->get_length ();
- done ++;
+ done++;
if (count - done < len)
p = scm_cdr (p);
}
return Music_sequence::cumulative_length (alternatives (me));
}
-
/*
- Length of the body in THIS. Disregards REPEAT-COUNT.
- */
+ Length of the body in THIS. Disregards REPEAT-COUNT.
+*/
Moment
Repeated_music::body_get_length (Music *me)
{
return m;
}
-
MAKE_SCHEME_CALLBACK (Repeated_music, unfolded_music_length, 1);
SCM
{
Music *me = unsmob_music (m);
- Moment l = body_get_length (me) + alternatives_get_length (me, true);
+ Moment l = body_get_length (me) + alternatives_get_length (me, true);
return l.smobbed_copy ();
}
int
-Repeated_music::repeat_count (Music *me)
+Repeated_music::repeat_count (Music *me)
{
return scm_to_int (me->get_property ("repeat-count"));
}
SCM
Repeated_music::first_start (SCM m)
{
- Music * me = unsmob_music (m);
- Music * body = unsmob_music (me->get_property ("element"));
+ Music *me = unsmob_music (m);
+ Music *body = unsmob_music (me->get_property ("element"));
- Moment rv = (body) ? body->start_mom () :
+ Moment rv = (body) ? body->start_mom () :
Music_sequence::first_start (me->get_property ("elements"));
return rv.smobbed_copy ();
class Rest_collision_engraver : public Engraver
{
- Item* rest_collision_;
- int rest_count_;
+ Item *rest_collision_;
+ int rest_count_;
Link_array<Grob> note_columns_;
protected:
virtual void acknowledge_grob (Grob_info);
virtual void process_acknowledged_grobs ();
virtual void stop_translation_timestep ();
public:
- TRANSLATOR_DECLARATIONS (Rest_collision_engraver);
+ TRANSLATOR_DECLARATIONS (Rest_collision_engraver);
};
Rest_collision_engraver::Rest_collision_engraver ()
{
if (rest_collision_
|| note_columns_.is_empty ()
- || !rest_count_
+ || !rest_count_
|| (note_columns_.size () == rest_count_
- && rest_count_ < 2))
+ && rest_count_ < 2))
return;
rest_collision_ = make_item ("RestCollision", SCM_EOL);
-
for (int i = 0; i < note_columns_.size (); i++)
Rest_collision::add_column (rest_collision_, note_columns_[i]);
}
{
note_columns_.push (i.grob_);
if (Note_column::has_rests (i.grob_))
- rest_count_ ++;
+ rest_count_++;
}
}
}
ADD_TRANSLATOR (Rest_collision_engraver,
-/* descr */ "Handles collisions of rests.",
-/* creats*/ "RestCollision",
-/* accepts */ "",
-/* acks */ "note-column-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Handles collisions of rests.",
+ /* creats*/ "RestCollision",
+ /* accepts */ "",
+ /* acks */ "note-column-interface",
+ /* reads */ "",
+ /* write */ "");
assert (a == Y_AXIS);
if (Note_column::has_rests (them))
- {
- Grob * rc = unsmob_grob (them->get_property ("rest-collision"));
+ {
+ Grob *rc = unsmob_grob (them->get_property ("rest-collision"));
if (rc && !to_boolean (rc->get_property ("positioning-done")))
{
rc->set_property ("positioning-done", SCM_BOOL_T);
do_shift (rc);
}
- }
+ }
return scm_make_real (0.0);
}
-
MAKE_SCHEME_CALLBACK (Rest_collision, force_shift_callback_rest, 2);
SCM
Rest_collision::force_shift_callback_rest (SCM rest, SCM axis)
Grob *parent = rest_grob->get_parent (X_AXIS);
if (Note_column::has_interface (parent))
- return force_shift_callback (parent->self_scm(), axis);
+ return force_shift_callback (parent->self_scm (), axis);
else
return scm_make_real (0.0);
}
-
void
-Rest_collision::add_column (Grob*me, Grob *p)
+Rest_collision::add_column (Grob *me, Grob *p)
{
me->add_dependency (p);
Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), p);
/*
TODO: look at horizontal-shift to determine ordering between rests
for more than two voices.
-
- */
+*/
SCM
Rest_collision::do_shift (Grob *me)
{
for (SCM s = elts; scm_is_pair (s); s = scm_cdr (s))
{
- Grob * e = unsmob_grob (scm_car (s));
+ Grob *e = unsmob_grob (scm_car (s));
if (unsmob_grob (e->get_property ("rest")))
{
/*
Ignore rests under beam.
- */
- Grob* st = unsmob_grob (e->get_property ("stem"));
+ */
+ Grob *st = unsmob_grob (e->get_property ("stem"));
if (st && unsmob_grob (st->get_property ("beam")))
continue;
-
+
rests.push (e);
}
else
notes.push (e);
}
-
- /*
- handle rest-rest and rest-note collisions
+ /*
+ handle rest-rest and rest-note collisions
- [todo]
- * decide not to print rest if too crowded?
- */
+ [todo]
+ * decide not to print rest if too crowded?
+ */
/*
no partners to collide with
- */
+ */
if (rests.size () + notes.size () < 2)
return SCM_UNSPECIFIED;
-
Real staff_space = Staff_symbol_referencer::staff_space (me);
/*
only rests
*/
- if (!notes.size ())
+ if (!notes.size ())
{
/*
This is incomplete: in case of an uneven number of rests, the
center one should be centered on the staff.
- */
- Drul_array< Link_array <Grob > > ordered_rests;
+ */
+ Drul_array< Link_array<Grob> > ordered_rests;
for (int i = 0; i < rests.size (); i++)
{
- Grob * r = Note_column::get_rest (rests[i]);
-
+ Grob *r = Note_column::get_rest (rests[i]);
+
Direction d = get_grob_direction (r);
if (d)
{
ordered_rests[d].push (rests[i]);
}
else
- rests[d]->warning (_("rest direction not set. Cannot resolve collision."));
+ rests[d]->warning (_ ("rest direction not set. Cannot resolve collision."));
}
- Direction d = LEFT;
- do {
- ordered_rests[d].sort (Note_column::shift_compare);
- } while (flip (&d) != LEFT);
-
- do {
- if (ordered_rests[d].size () < 1)
- {
- if (ordered_rests[-d].size() > 1)
- ordered_rests[-d][0]->warning (_ ("too many colliding rests"));
-
- return SCM_UNSPECIFIED;
- }
- } while (flip (&d) != LEFT);
+ Direction d = LEFT;
+ do
+ {
+ ordered_rests[d].sort (Note_column::shift_compare);
+ }
+ while (flip (&d) != LEFT);
+
+ do
+ {
+ if (ordered_rests[d].size () < 1)
+ {
+ if (ordered_rests[-d].size () > 1)
+ ordered_rests[-d][0]->warning (_ ("too many colliding rests"));
+
+ return SCM_UNSPECIFIED;
+ }
+ }
+ while (flip (&d) != LEFT);
Grob *common = common_refpoint_of_array (ordered_rests[DOWN], me, Y_AXIS);
- common = common_refpoint_of_array (ordered_rests[UP], common, Y_AXIS);
+ common = common_refpoint_of_array (ordered_rests[UP], common, Y_AXIS);
- Real diff =
- (ordered_rests[DOWN].top ()->extent (common, Y_AXIS)[UP]
- - ordered_rests[UP].top ()->extent (common, Y_AXIS)[DOWN]) / staff_space;
+ Real diff
+ = (ordered_rests[DOWN].top ()->extent (common, Y_AXIS)[UP]
+ - ordered_rests[UP].top ()->extent (common, Y_AXIS)[DOWN]) / staff_space;
if (diff > 0)
{
- int amount_down = (int) ceil (diff / 2);
+ int amount_down = (int) ceil (diff / 2);
diff -= amount_down;
Note_column::translate_rests (ordered_rests[DOWN].top (),
-2 * amount_down);
2 * int (ceil (diff)));
}
- do {
- for (int i = ordered_rests[d].size () -1; i-- > 0;)
- {
- Real last_y = ordered_rests[d][i+1]->extent (common, Y_AXIS)[d];
- Real y = ordered_rests[d][i]->extent (common, Y_AXIS)[-d];
+ do
+ {
+ for (int i = ordered_rests[d].size () -1; i-- > 0;)
+ {
+ Real last_y = ordered_rests[d][i + 1]->extent (common, Y_AXIS)[d];
+ Real y = ordered_rests[d][i]->extent (common, Y_AXIS)[-d];
+
+ Real diff = d * ((last_y - y) /staff_space);
+ if (diff > 0)
+ Note_column::translate_rests (ordered_rests[d][i], d * (int) ceil (diff) * 2);
+ }
+ }
+ while (flip (&d) != LEFT);
- Real diff = d * ((last_y - y) /staff_space);
- if (diff > 0)
- Note_column::translate_rests (ordered_rests[d][i], d * (int) ceil (diff) * 2);
- }
- } while (flip (&d) != LEFT);
}
- else
+ else
{
/*
Rests and notes.
- */
+ */
if (rests.size () > 1)
{
warning (_ ("too many colliding rests"));
}
- Grob * rcol = 0;
+ Grob *rcol = 0;
Direction dir = CENTER;
for (int i = rests.size (); !rcol && i--;)
if (!rcol)
return SCM_UNSPECIFIED;
-
+
Grob *common = common_refpoint_of_array (notes, rcol, Y_AXIS);
-
+
Interval restdim = rcol->extent (common, Y_AXIS);
if (restdim.is_empty ())
return SCM_UNSPECIFIED;
-
+
Real staff_space = Staff_symbol_referencer::staff_space (rcol);
Real minimum_dist = robust_scm2double (me->get_property ("minimum-distance"), 1.0) * staff_space;
Interval notedim;
- for (int i = 0; i < notes.size (); i++)
+ for (int i = 0; i < notes.size (); i++)
{
notedim.unite (notes[i]->extent (common, Y_AXIS));
}
- Real dist =
- minimum_dist + dir * (notedim[dir] - restdim[-dir]) >? 0;
+ Real dist
+ = minimum_dist + dir * (notedim[dir] - restdim[-dir]) >? 0;
int stafflines = Staff_symbol_referencer::line_count (me);
if (!stafflines)
programming_error ("No staff line count ? ");
stafflines =5;
}
-
+
// move discretely by half spaces.
int discrete_dist = int (ceil (dist / (0.5 *staff_space)));
// move by whole spaces inside the staff.
- if (discrete_dist < stafflines+1)
+ if (discrete_dist < stafflines + 1)
discrete_dist = int (ceil (discrete_dist / 2.0)* 2.0);
Note_column::translate_rests (rcol, dir * discrete_dist);
return SCM_UNSPECIFIED;
}
-
ADD_INTERFACE (Rest_collision, "rest-collision-interface",
"Move around ordinary rests (not multi-measure-rests) to avoid "
"conflicts.",
class Rest_engraver : public Engraver
{
Music *rest_req_;
- Item * dot_;
- Grob* rest_;
+ Item *dot_;
+ Grob *rest_;
protected:
virtual bool try_music (Music *);
virtual void stop_translation_timestep ();
TRANSLATOR_DECLARATIONS (Rest_engraver);
};
-
/*
Should merge with Note_head_engraver
- */
+*/
Rest_engraver::Rest_engraver ()
{
rest_req_ = 0;
void
Rest_engraver::process_music ()
{
- if (rest_req_ && !rest_)
+ if (rest_req_ && !rest_)
{
rest_ = make_item ("Rest", rest_req_->self_scm ());
- int durlog = unsmob_duration (rest_req_->get_property ("duration"))-> duration_log ();
-
+ int durlog = unsmob_duration (rest_req_->get_property ("duration"))-> duration_log ();
+
rest_->set_property ("duration-log",
- scm_int2num (durlog));
+ scm_int2num (durlog));
int dots = unsmob_duration (rest_req_->get_property ("duration"))->dot_count ();
-
+
if (dots)
{
dot_ = make_item ("Dots", SCM_EOL);
Rhythmic_head::set_dots (rest_, dot_);
dot_->set_parent (rest_, Y_AXIS);
dot_->set_property ("dot-count", scm_int2num (dots));
-
+
}
Pitch *p = unsmob_pitch (rest_req_->get_property ("pitch"));
/*
This is ridiculous -- rests don't have pitch, but we act as if
our nose is bleeding.
- */
+ */
if (p)
{
int pos = p->steps ();
SCM c0 = get_property ("middleCPosition");
if (scm_is_number (c0))
pos += scm_to_int (c0);
-
+
rest_->set_property ("staff-position", scm_int2num (pos));
}
-
+
}
}
}
ADD_TRANSLATOR (Rest_engraver,
-/* descr */ "",
-/* creats*/ "Rest Dots",
-/* accepts */ "rest-event",
-/* acks */ "",
-/* reads */ "middleCPosition",
-/* write */ "");
+ /* descr */ "",
+ /* creats*/ "Rest Dots",
+ /* accepts */ "rest-event",
+ /* acks */ "",
+ /* reads */ "middleCPosition",
+ /* write */ "");
/*
- rest.cc -- implement Rest
+ rest.cc -- implement Rest
source file of the GNU LilyPond music typesetter
{
if (bt == 0 && lc > 1)
{
- me->translate_axis (ss , Y_AXIS);
+ me->translate_axis (ss, Y_AXIS);
}
}
else
{
- me->translate_axis (ss/2 , Y_AXIS);
+ me->translate_axis (ss / 2, Y_AXIS);
}
- Grob * d = unsmob_grob (me->get_property ("dot"));
+ Grob *d = unsmob_grob (me->get_property ("dot"));
if (d && bt > 4) // UGH.
{
d->set_property ("staff-position",
/*
make this function easily usable in C++
- */
+*/
String
Rest::glyph_name (Grob *me, int balltype, String style, bool try_ledgers)
{
Figure out when the rest is far enough outside the staff. This
could bemore generic, but hey, we understand this even after
dinner.
- */
+ */
ledgered_b |= (balltype == 0) && (pos >= +rad + 2 || pos < -rad);
ledgered_b |= (balltype == 1) && (pos <= -rad - 2 || pos > +rad);
}
+ actual_style);
}
-
MAKE_SCHEME_CALLBACK (Rest, print, 1);
SCM
Rest::brew_internal_stencil (SCM smob, bool ledgered)
{
- Grob* me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
SCM balltype_scm = me->get_property ("duration-log");
if (!scm_is_number (balltype_scm))
return Stencil ().smobbed_copy ();
int balltype = scm_to_int (balltype_scm);
-
- String style;
+
+ String style;
SCM style_scm = me->get_property ("style");
if (scm_is_symbol (style_scm))
style = ly_scm2string (scm_symbol_to_string (style_scm));
return out.smobbed_copy ();
}
-SCM
-Rest::print (SCM smob)
+SCM
+Rest::print (SCM smob)
{
return brew_internal_stencil (smob, true);
}
consequence: we get too small extents and potential collisions
with ledgered rests.
- */
+ */
SCM m = brew_internal_stencil (smob, a != X_AXIS);
return ly_interval2scm (unsmob_stencil (m)->extent (a));
}
SCM
Rest::polyphonic_offset_callback (SCM smob, SCM)
{
- Grob* me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
if (scm_is_number (me->get_property ("staff-position")))
return scm_make_real (0);
Direction d = get_grob_direction (me);
- Real off = 2 * d ;
+ Real off = 2 * d;
if (off)
off *= Staff_symbol_referencer::staff_space (me);
}
ADD_INTERFACE (Rest, "rest-interface",
- "A rest symbol.",
- "style direction minimum-distance");
+ "A rest symbol.",
+ "style direction minimum-distance");
It also generates spacing objects. Originally, we have tried to
have the spacing functionality at different levels.
-
+
- by simply using the sequence of Separation-item as
spacing-sequences (at staff level). Unfortunately, this fucks up if
there are different kinds of tuplets in different voices (8th and
spacing engraver don't know where to connect the last note of the
voice on the right with), but we don't complain about those, and let
the default spacing do its work.
-
- */
-
+*/
class Rhythmic_column_engraver :public Engraver
{
Link_array<Grob> rheads_;
- Grob * stem_;
- Grob * note_column_;
- Grob * dotcol_;
+ Grob *stem_;
+ Grob *note_column_;
+ Grob *dotcol_;
+
+ Grob *last_spacing_;
+ Grob *spacing_;
- Grob * last_spacing_;
- Grob * spacing_;
-
TRANSLATOR_DECLARATIONS (Rhythmic_column_engraver);
protected:
virtual void stop_translation_timestep ();
};
-
-
Rhythmic_column_engraver::Rhythmic_column_engraver ()
{
- spacing_ = 0 ;
+ spacing_ = 0;
last_spacing_ = 0;
-
+
stem_ = 0;
note_column_ = 0;
dotcol_ = 0;
}
-
void
Rhythmic_column_engraver::process_acknowledged_grobs ()
{
spacing_->set_property ("left-items", scm_cons (note_column_->self_scm (), SCM_EOL));
-
-
if (last_spacing_)
{
Pointer_group_interface::add_grob (last_spacing_,
- ly_symbol2scm ("right-items" ),
+ ly_symbol2scm ("right-items"),
note_column_);
}
rheads_.set_size (0);
}
-
if (note_column_)
{
if (dotcol_
void
Rhythmic_column_engraver::acknowledge_grob (Grob_info i)
{
- Item * item = dynamic_cast <Item *> (i.grob_);
+ Item *item = dynamic_cast<Item *> (i.grob_);
if (!item || item->get_parent (X_AXIS))
- return ;
+ return;
if (Stem::has_interface (item))
{
stem_ = item;
void
Rhythmic_column_engraver::stop_translation_timestep ()
{
- note_column_ = 0;
+ note_column_ = 0;
if (spacing_)
{
last_spacing_ = spacing_;
spacing_ = 0;
}
-
+
dotcol_ = 0;
stem_ = 0;
}
-
-
ADD_TRANSLATOR (Rhythmic_column_engraver,
-/* descr */ "Generates NoteColumn, an objects that groups stems, noteheads and rests.",
-/* creats*/ "NoteColumn NoteSpacing",
-/* accepts */ "",
-/* acks */ "stem-interface rhythmic-head-interface dot-column-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Generates NoteColumn, an objects that groups stems, noteheads and rests.",
+ /* creats*/ "NoteColumn NoteSpacing",
+ /* accepts */ "",
+ /* acks */ "stem-interface rhythmic-head-interface dot-column-interface",
+ /* reads */ "",
+ /* write */ "");
#include "staff-symbol-referencer.hh"
#include "item.hh"
-Item*
-Rhythmic_head::get_dots (Grob*me)
+Item *
+Rhythmic_head::get_dots (Grob *me)
{
SCM s = me->get_property ("dot");
return unsmob_item (s);
}
-Item*
-Rhythmic_head::get_stem (Grob*me)
+Item *
+Rhythmic_head::get_stem (Grob *me)
{
SCM s = me->get_property ("stem");
return unsmob_item (s);
}
int
-Rhythmic_head::dot_count (Grob*me)
+Rhythmic_head::dot_count (Grob *me)
{
return get_dots (me)
? scm_to_int (get_dots (me)->get_property ("dot-count")) : 0;
}
void
-Rhythmic_head::set_dots (Grob*me, Item *dot)
+Rhythmic_head::set_dots (Grob *me, Item *dot)
{
me->set_property ("dot", dot->self_scm ());
}
int
-Rhythmic_head::duration_log (Grob*me)
+Rhythmic_head::duration_log (Grob *me)
{
SCM s = me->get_property ("duration-log");
return scm_is_number (s) ? scm_to_int (s) : 0;
}
ADD_INTERFACE (Rhythmic_head, "rhythmic-head-interface",
- "Note head or rest",
- "dot stem duration-log");
+ "Note head or rest",
+ "dot stem duration-log");
-/*
+/*
rod.cc -- implement Rod, Column_rod
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "rod.hh"
item_drul_[LEFT] = item_drul_[RIGHT] = 0;
}
-
-
void
Rod::columnize ()
{
if (!item_drul_[LEFT]
|| !item_drul_[RIGHT])
- return ;
-
+ return;
+
Direction d = LEFT;
- do {
- Paper_column * pc = item_drul_[d]->get_column ();
- distance_ += - d * item_drul_[d]->relative_coordinate (pc, X_AXIS);
- item_drul_[d] = pc;
- } while ((flip (&d))!= LEFT);
+ do
+ {
+ Paper_column *pc = item_drul_[d]->get_column ();
+ distance_ += -d * item_drul_[d]->relative_coordinate (pc, X_AXIS);
+ item_drul_[d] = pc;
+ }
+ while ((flip (&d))!= LEFT);
}
/*
Return: number of objects.
- */
+*/
int
copy_scm_hashes (SCM dest, SCM src)
{
scm_hashq_set_x (dest, scm_caar (s), scm_cdar (s));
k++;
}
- return k ;
+ return k;
}
-
Scheme_hash_table::Scheme_hash_table ()
{
hash_tab_ = SCM_EOL;
elt_count_ = 0;
}
-
Scheme_hash_table::Scheme_hash_table (Scheme_hash_table const &src)
{
elt_count_ = 0;
smobify_self ();
- hash_tab_ = scm_make_vector (scm_int2num (src.elt_count_ >? 11 ), SCM_EOL);
+ hash_tab_ = scm_make_vector (scm_int2num (src.elt_count_ >? 11), SCM_EOL);
elt_count_ = copy_scm_hashes (hash_tab_, src.hash_tab_);
}
void
-Scheme_hash_table::operator = (Scheme_hash_table const & src)
+Scheme_hash_table::operator= (Scheme_hash_table const &src)
{
if (&src == this)
return;
SCM
Scheme_hash_table::mark_smob (SCM s)
{
- Scheme_hash_table *me = (Scheme_hash_table*) SCM_CELL_WORD_1 (s);
+ Scheme_hash_table *me = (Scheme_hash_table *) SCM_CELL_WORD_1 (s);
scm_gc_mark (me->hash_tab_);
return SCM_EOL;
}
assert (unsmob (s));
char str[1000];
sprintf (str, "#<Scheme_hash_table 0x%0lx ", SCM_UNPACK (s));
- Scheme_hash_table *me = (Scheme_hash_table*) SCM_CELL_WORD_1 (s);
+ Scheme_hash_table *me = (Scheme_hash_table *) SCM_CELL_WORD_1 (s);
scm_display (me->hash_tab_, p);
scm_puts ("> ", p);
return 1;
*/
if (elt_count_ > 2 * scm_c_vector_length (hash_tab_))
{
- SCM nh = scm_make_vector (scm_int2num (3* elt_count_+1), SCM_EOL);
+ SCM nh = scm_make_vector (scm_int2num (3* elt_count_ + 1), SCM_EOL);
elt_count_ = copy_scm_hashes (nh, hash_tab_);
hash_tab_ = nh;
}
{
/*
42 will stick out like a sore thumb, hopefully.
- */
+ */
return scm_hashq_ref (hash_tab_, k, scm_from_int (42));
}
source file of the GNU LilyPond music typesetter
(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "scm-option.hh"
preferably, also dont use TESTING_LEVEL_GLOBAL, since it defeats
another purpose of this very versatile interface, which is to
support multiple debug/testing options concurrently.
-
- */
-
+*/
/* Write midi as formatted ascii stream? */
bool midi_debug_global_b;
int preview_resolution_global = 90;
-
/* General purpose testing flag */
int testing_level_global;
/*
Backwards compatibility.
- */
+*/
bool lily_1_8_relative = false;
bool lily_1_8_compatibility_used = false;
/*
crash if internally the wrong type is used for a grob property.
- */
+*/
bool do_internal_type_checking_global;
-
/*
- What is this function for ?
- */
+ What is this function for ?
+*/
LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (SCM),
- "Print ly:set-option usage")
+ "Print ly:set-option usage")
{
- printf ( _("lilypond -e EXPR means:").to_str0 ());
+ printf (_ ("lilypond -e EXPR means:").to_str0 ());
puts ("");
printf (_ (" Evalute the Scheme EXPR before parsing any .ly files.").to_str0 ());
puts ("");
printf (_ (" Multiple -e options may be given, they will be evaluated sequentially.").to_str0 ());
puts ("");
- printf (_(" The function ly:set-option allows for access to some internal variables.").to_str0 ());
+ printf (_ (" The function ly:set-option allows for access to some internal variables.").to_str0 ());
puts ("\n");
- printf (_ ("Usage: lilypond -e \"(ly:set-option SYMBOL VAL)\"").to_str0 ());
+ printf (_ ("Usage: lilypond -e \"(ly:set - option SYMBOL VAL)\"").to_str0 ());
puts ("\n");
printf (_ ("Use help as SYMBOL to get online help.").to_str0 ());
@item -t, --test
Switch on any experimental features. Not for general public use.
-
*/
-
LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val),
- "Set a global option value. Supported options include\n"
-"\n"
-"@table @code\n"
-"@item help\n"
-"List all options.\n"
-"@item midi-debug\n"
-"If set to true, generate human readable MIDI\n"
-"@item internal-type-checking\n"
-"Set paranoia for property assignments\n"
-"@item parse-protect\n"
-"If protection is switched on, errors in inline scheme are caught in the parser. \n"
-"If off, GUILE will halt on errors, and give a stack trace. Default is protected evaluation. \n"
-"@item old-relative\n"
-"Relative for simultaneous music functions similar to chord syntax\n"
-"@item new-relative\n"
-"Relative for simultaneous music functions similar to sequential music\n"
-"@end table\n"
-"\n"
-"This function is useful to call from the command line: @code{lilypond -e\n"
-"\"(ly:set-option 'midi-debug #t)\"}.\n")
+ "Set a global option value. Supported options include\n"
+ "\n"
+ "@table @code\n"
+ "@item help\n"
+ "List all options.\n"
+ "@item midi-debug\n"
+ "If set to true, generate human readable MIDI\n"
+ "@item internal-type-checking\n"
+ "Set paranoia for property assignments\n"
+ "@item parse-protect\n"
+ "If protection is switched on, errors in inline scheme are caught in the parser. \n"
+ "If off, GUILE will halt on errors, and give a stack trace. Default is protected evaluation. \n"
+ "@item old-relative\n"
+ "Relative for simultaneous music functions similar to chord syntax\n"
+ "@item new-relative\n"
+ "Relative for simultaneous music functions similar to sequential music\n"
+ "@end table\n"
+ "\n"
+ "This function is useful to call from the command line: @code{lilypond -e\n"
+ "\"(ly:set - option 'midi-debug #t)\"}.\n")
{
if (val == SCM_UNDEFINED)
val = SCM_BOOL_T;
midi_debug_global_b = to_boolean (val);
else if (var == ly_symbol2scm ("testing-level"))
testing_level_global = scm_to_int (val);
- else if (var == ly_symbol2scm ("parse-protect" ))
+ else if (var == ly_symbol2scm ("parse-protect"))
parse_protect_global = to_boolean (val);
else if (var == ly_symbol2scm ("internal-type-checking"))
do_internal_type_checking_global = to_boolean (val);
{
if (scm_is_symbol (var))
var = scm_symbol_to_string (var);
-
+
warning (_f ("No such internal option: %s", ly_scm2string (var)));
}
return SCM_UNSPECIFIED;
}
LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var),
- "Get a global option setting. Supported options include\n"
+ "Get a global option setting. Supported options include\n"
"@table @code\n"
"@item old-relative-used\n"
"Report whether old-relative compatibility mode is necessary\n"
"\n")
{
SCM o = SCM_UNSPECIFIED;
-
+
if (var == ly_symbol2scm ("safe")) // heavily used; put in front.
o = ly_bool2scm (be_safe_global);
- else if (var == ly_symbol2scm ("old-relative-used"))
+ else if (var == ly_symbol2scm ("old-relative-used"))
o = ly_bool2scm (lily_1_8_compatibility_used);
else if (var == ly_symbol2scm ("old-relative"))
o = ly_bool2scm (lily_1_8_relative);
else if (var == ly_symbol2scm ("verbose"))
o = ly_bool2scm (be_verbose_global);
- else if ( var == ly_symbol2scm ("resolution"))
+ else if (var == ly_symbol2scm ("resolution"))
o = scm_from_int (preview_resolution_global);
else
{
var = scm_symbol_to_string (var);
String s = ly_scm2string (var);
-
- warning (_f ("No such internal option: %s", s.to_str0() ));
+
+ warning (_f ("No such internal option: %s", s.to_str0 ()));
}
return o;
}
/*
score-context.cc -- implement Score_context
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
void
Score_context::prepare (Moment w)
{
- Translator* t = implementation ();
- Score_translator * s = dynamic_cast<Score_translator *> (t);
+ Translator *t = implementation ();
+ Score_translator *s = dynamic_cast<Score_translator *> (t);
s->prepare (w);
}
void
Score_context::finish ()
{
- Translator* t = implementation ();
- Score_translator * s = dynamic_cast<Score_translator *> (t);
+ Translator *t = implementation ();
+ Score_translator *s = dynamic_cast<Score_translator *> (t);
s->finish ();
}
void
Score_context::one_time_step ()
{
- Translator* t = implementation ();
- Score_translator * s = dynamic_cast<Score_translator *> (t);
+ Translator *t = implementation ();
+ Score_translator *s = dynamic_cast<Score_translator *> (t);
s->one_time_step ();
}
-Music_output*
+Music_output *
Score_context::get_output ()
{
Translator *t = implementation ();
return s->get_output ();
}
-
Score_context::Score_context (Object_key const *key)
: Context (key)
{
/*
TODO: the column creation logic is rather hairy. Revise it.
- */
+*/
Score_engraver::Score_engraver ()
{
system_ = 0;
{
/*
ugh.
- */
+ */
if (!command_column_)
{
SCM nmp
= updated_grob_properties (context (),
ly_symbol2scm ("NonMusicalPaperColumn"));
- Object_key const *key1 = context()->get_grob_key ("NonMusicalPaperColumn");
-
+ Object_key const *key1 = context ()->get_grob_key ("NonMusicalPaperColumn");
+
SCM pc = updated_grob_properties (context (),
ly_symbol2scm ("PaperColumn"));
- Object_key const *key2 = context()->get_grob_key ("PaperColumn");
+ Object_key const *key2 = context ()->get_grob_key ("PaperColumn");
set_columns (new Paper_column (nmp, key1), new Paper_column (pc, key2));
-
Grob_info i1;
i1.grob_ = command_column_;
i1.origin_trans_ = this;
-
+
announce_grob (i1);
Grob_info i2;
{
/*
TODO: don't make columns when skipTypesetting is true.
- */
+ */
make_columns ();
SCM w = m.smobbed_copy ();
/*
use start/finish?
- */
+*/
void
Score_engraver::initialize ()
{
+ "\n"
+ _ ("Music font has not been installed properly.")
+ "\n"
- + _f ("Search path `%s'", global_path.to_string ().to_str0())
+ + _f ("Search path `%s'", global_path.to_string ().to_str0 ())
+ "\n"
- + _ ("Aborting"));
+ + _ ("Aborting"));
}
pscore_ = new Paper_score;
- pscore_->layout_ = dynamic_cast<Output_def*> (get_output_def ());
+ pscore_->layout_ = dynamic_cast<Output_def *> (get_output_def ());
SCM props = updated_grob_properties (context (), ly_symbol2scm ("System"));
- Object_key const *sys_key = context()->get_grob_key ("System");
+ Object_key const *sys_key = context ()->get_grob_key ("System");
pscore_->typeset_line (new System (props, sys_key));
-
+
system_ = pscore_->system_;
make_columns ();
system_->set_bound (LEFT, command_column_);
Engraver_group_engraver::initialize ();
}
-
void
Score_engraver::finalize ()
{
Score_translator::finalize ();
- Grob * cc
+ Grob *cc
= unsmob_grob (get_property ("currentCommandColumn"));
system_->set_bound (RIGHT, cc);
cc->set_property ("breakable", SCM_BOOL_T);
-
+
typeset_all ();
}
-
void
Score_engraver::one_time_step ()
{
if (!to_boolean (get_property ("skipTypesetting")))
{
recurse_over_translators (context (), &Engraver::process_music, UP);
- Engraver_group_engraver::do_announces();
+ Engraver_group_engraver::do_announces ();
}
-
+
recurse_over_translators (context (), &Translator::stop_translation_timestep, UP);
}
elems_.push (info.grob_);
}
-
void
Score_engraver::typeset_all ()
{
- for (int i = 0; i < elems_.size (); i++)
+ for (int i = 0; i < elems_.size (); i++)
{
- Grob * elem = elems_[i];
+ Grob *elem = elems_[i];
-
- if (dynamic_cast<Item*> (elem))
+ if (dynamic_cast<Item *> (elem))
{
- if (
- (!elem->get_parent (X_AXIS)
- || !unsmob_grob (elem->get_property ("axis-group-parent-X")))
+ if ((!elem->get_parent (X_AXIS)
+ || !unsmob_grob (elem->get_property ("axis-group-parent-X")))
&& elem != command_column_
- && elem != musical_column_
- )
+ && elem != musical_column_)
{
bool br = to_boolean (elem->get_property ("breakable"));
Axis_group_interface::add_element (br ? command_column_ : musical_column_, elem);
{
// this generates all items.
Engraver_group_engraver::stop_translation_timestep ();
-
+
typeset_all ();
if (to_boolean (command_column_->get_property ("breakable")))
{
- breaks_ ++;
+ breaks_++;
if (! (breaks_%8))
progress_indication ("[" + to_string (breaks_) + "]");
}
-
command_column_ = 0;
musical_column_ = 0;
}
void
-Score_engraver::set_columns (Paper_column *new_command,
+Score_engraver::set_columns (Paper_column *new_command,
Paper_column *new_musical)
{
assert (!command_column_ && !musical_column_);
musical_column_ = new_musical;
if (new_command)
{
- context ()->set_property ("currentCommandColumn", new_command->self_scm ());
+ context ()->set_property ("currentCommandColumn", new_command->self_scm ());
}
-
+
if (new_musical)
{
context ()->set_property ("currentMusicalColumn", new_musical->self_scm ());
system_->add_column (musical_column_);
}
-Music_output*
+Music_output *
Score_engraver::get_output ()
{
Music_output *o = pscore_;
- ///FIXME WTF? pscore_ = 0;
+ ///FIXME WTF? pscore_ = 0;
return o;
}
SCM mpage_pen = m->get_property ("page-penalty");
if (scm_is_number (mpage_pen))
total_pp += scm_to_double (mpage_pen);
-
+
command_column_->set_property ("page-penalty", scm_make_real (total_pp));
return true;
}
if (command_column_)
command_column_->set_property ("breakable", SCM_EOL);
}
-
+
void
Score_engraver::acknowledge_grob (Grob_info gi)
{
{
SCM spaceable = get_property ("verticallySpacedContexts");
Context *orig = gi.origin_contexts (this)[0];
-
- if (scm_memq (ly_symbol2scm (orig->context_name ().to_str0()),
+
+ if (scm_memq (ly_symbol2scm (orig->context_name ().to_str0 ()),
spaceable) != SCM_BOOL_F)
{
Pointer_group_interface::add_grob (system_,
gi.grob_);
}
}
-
-}
-
+}
ADD_TRANSLATOR (Score_engraver,
-/* descr */ "Top level engraver. Takes care of generating columns and the complete system (ie. System) "
-"\n\n "
-"This engraver decides whether a column is breakable. The default is "
-"that a column is always breakable. However, when every Bar_engraver "
-"that does not have a barline at a certain point will call "
-"Score_engraver::forbid_breaks to stop linebreaks. In practice, this "
-"means that you can make a breakpoint by creating a barline (assuming "
-"that there are no beams or notes that prevent a breakpoint.) "
-,
-/* creats*/ "System PaperColumn NonMusicalPaperColumn",
-/* accepts */ "break-event",
-/* acks */ "note-spacing-interface staff-spacing-interface axis-group-interface",
-/* reads */ "currentMusicalColumn currentCommandColumn verticallySpacedContexts",
-/* write */ "");
+ /* descr */ "Top level engraver. Takes care of generating columns and the complete system (ie. System) "
+ "\n\n "
+ "This engraver decides whether a column is breakable. The default is "
+ "that a column is always breakable. However, when every Bar_engraver "
+ "that does not have a barline at a certain point will call "
+ "Score_engraver::forbid_breaks to stop linebreaks. In practice, this "
+ "means that you can make a breakpoint by creating a barline (assuming "
+ "that there are no beams or notes that prevent a breakpoint.) ",
+ /* creats*/ "System PaperColumn NonMusicalPaperColumn",
+ /* accepts */ "break-event",
+ /* acks */ "note-spacing-interface staff-spacing-interface axis-group-interface",
+ /* reads */ "currentMusicalColumn currentCommandColumn verticallySpacedContexts",
+ /* write */ "");
source file of the GNU LilyPond music typesetter
(c) 1996--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#include "score-performer.hh"
#include "output-def.hh"
ADD_TRANSLATOR (Score_performer,
-/* descr */ "",
-/* creats*/ "",
-/* accepts */ "",
-/* acks */ "",
-/* reads */ "",
-/* write */ "");
-
+ /* descr */ "",
+ /* creats*/ "",
+ /* accepts */ "",
+ /* acks */ "",
+ /* reads */ "",
+ /* write */ "");
Score_performer::Score_performer ()
{
performance_ = 0;
}
-
Score_performer::~Score_performer ()
{
}
void
-Score_performer::play_element (Audio_element * p)
+Score_performer::play_element (Audio_element *p)
{
- if (Audio_item * i = dynamic_cast<Audio_item *> (p))
+ if (Audio_item *i = dynamic_cast<Audio_item *> (p))
{
audio_column_->add_audio_item (i);
}
announce_infos_.push (info);
}
-void
+void
Score_performer::prepare (Moment m)
{
audio_column_ = new Audio_column (m);
{
recurse_over_translators (context (), &Translator::finalize, UP);
}
-
-void
+
+void
Score_performer::one_time_step ()
{
recurse_over_translators (context (), &Performer::process_music, UP);
return ::get_tempo (performance_->midi_, Moment (Rational (1, 4)));
}
-
Music_output *
Score_performer::get_output ()
{
- Music_output * o = performance_;
+ Music_output *o = performance_;
performance_ = 0;
return o;
}
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
-
#include "score.hh"
#include "music.hh"
#include "output-def.hh"
"Run @var{score} through @var{layout}, an output definition, "
"scaled to correct outputscale already, "
"return a list of layout-lines. "
- "\nTake optional Object_key argument."
- )
+ "\nTake optional Object_key argument.")
{
- Score * sc = unsmob_score (score);
+ Score *sc = unsmob_score (score);
Output_def *od = unsmob_output_def (layout);
if (sc->error_found_)
return SCM_EOL;
-
+
SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "Score");
SCM_ASSERT_TYPE (od, layout, SCM_ARG2, __FUNCTION__, "Output_def");
- Output_def * score_def = 0;
+ Output_def *score_def = 0;
/* UGR, FIXME, these are default \layout blocks once again. They
suck. */
if (!score_def)
return scm_c_make_vector (0, SCM_EOL);
-
+
score_def = score_def->clone ();
SCM prot = score_def->self_scm ();
scm_gc_unprotect_object (prot);
/* TODO: SCORE_DEF should be scaled according to OD->parent_ or OD
itself. */
score_def->parent_ = od;
-
+
SCM context = ly_run_translator (sc->get_music (), score_def->self_scm (),
key);
SCM lines = ly_format_output (context, scm_makfrom0str ("<embedded>"));
-
+
scm_remember_upto_here_1 (prot);
return lines;
}
-/*
+/*
score-translator.cc -- implement Score_translator
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
- */
+*/
#include "score-translator.hh"
#include "moment.hh"
{
}
-Music_output*
+Music_output *
Score_translator::get_output ()
{
return 0;
SCM
Score::mark_smob (SCM s)
{
- Score *sc = (Score*) SCM_CELL_WORD_1 (s);
+ Score *sc = (Score *) SCM_CELL_WORD_1 (s);
scm_gc_mark (sc->header_);
scm_gc_mark (sc->texts_);
}
int
-Score::print_smob (SCM , SCM p, scm_print_state*)
+Score::print_smob (SCM, SCM p, scm_print_state*)
{
scm_puts ("#<Score>", p);
Music *m = unsmob_music (s.music_);
music_ = m ? m->clone ()->self_scm () : SCM_EOL;
scm_gc_unprotect_object (music_);
-
+
for (int i = 0, n = s.defs_.size (); i < n; i++)
defs_.push (s.defs_[i]->clone ());
texts_ = s.texts_;
}
-
void
default_rendering (SCM music, SCM outdef,
SCM book_outputdef,
{
SCM scaled_def = outdef;
SCM scaled_bookdef = book_outputdef;
-
+
Output_def *bpd = unsmob_output_def (book_outputdef);
/* ugh. */
if (bpd->c_variable ("is-paper") == SCM_BOOL_T)
{
Real scale = scm_to_double (bpd->c_variable ("outputscale"));
-
+
Output_def *def = scale_output_def (unsmob_output_def (outdef), scale);
scaled_def = def->self_scm ();
scaled_bookdef = scale_output_def (bpd, scale)->self_scm ();
unsmob_output_def (scaled_def)->parent_
= unsmob_output_def (scaled_bookdef);
-
+
scm_gc_unprotect_object (scaled_bookdef);
scm_gc_unprotect_object (scaled_def);
}
-
+
SCM context = ly_run_translator (music, scaled_def, key);
- if (Global_context *g = dynamic_cast<Global_context*>
+ if (Global_context *g = dynamic_cast<Global_context *>
(unsmob_context (context)))
{
SCM systems = ly_format_output (context, outname);
}
/*
-Format score, return systems. OUTNAME is still passed to create a midi
-file.
-
-LAYOUTBOOK should be scaled already.
+ Format score, return systems. OUTNAME is still passed to create a midi
+ file.
+ LAYOUTBOOK should be scaled already.
*/
SCM
Score::book_rendering (String outname,
{
if (error_found_)
return SCM_EOL;
-
+
SCM scaled_bookdef = SCM_EOL;
Real scale = 1.0;
if (layoutbook && layoutbook->c_variable ("is-paper") == SCM_BOOL_T)
scale = scm_to_double (layoutbook->c_variable ("outputscale"));
-
+
SCM out = scm_makfrom0str (outname.to_str0 ());
SCM systems = SCM_EOL;
int outdef_count = defs_.size ();
- Object_key * key = new Lilypond_general_key (book_key, user_key_, 0);
- SCM scm_key = key->self_scm();
+ Object_key *key = new Lilypond_general_key (book_key, user_key_, 0);
+ SCM scm_key = key->self_scm ();
scm_gc_unprotect_object (scm_key);
-
+
for (int i = 0; !i || i < outdef_count; i++)
{
Output_def *def = outdef_count ? defs_[i] : default_def;
/* TODO: fix or junk --no-layout. */
SCM context = ly_run_translator (music_, def->self_scm (), scm_key);
- if (dynamic_cast<Global_context*> (unsmob_context (context)))
+ if (dynamic_cast<Global_context *> (unsmob_context (context)))
{
SCM s = ly_format_output (context, out);
if (s != SCM_UNDEFINED)
}
-
-
-
void
Score::set_music (SCM music, SCM parser)
{
if (unsmob_music (music_))
{
- unsmob_music (music)->origin ()->error (_("Already have music in score"));
- unsmob_music (music_)->origin ()->error (_("This is the previous music"));
+ unsmob_music (music)->origin ()->error (_ ("Already have music in score"));
+ unsmob_music (music_)->origin ()->error (_ ("This is the previous music"));
}
- Music * m = unsmob_music (music);
+ Music *m = unsmob_music (music);
if (m && to_boolean (m->get_property ("error-found")))
{
- m->origin()->error (_("Error found in this music expression. Ignoring it"));
-
+ m->origin ()->error (_ ("Error found in this music expression. Ignoring it"));
+
this->error_found_ = this->error_found_ || to_boolean (m->get_property ("error-found"));
-
+
}
if (this->error_found_)
- this->music_ = SCM_EOL;
+ this->music_ = SCM_EOL;
else
this->music_ = music;
-/*
+/*
script-column-engraver.cc -- implement Script_column_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "engraver.hh"
#include "script-column.hh"
virtual void stop_translation_timestep ();
};
-
Script_column_engraver::Script_column_engraver ()
{
scol_ = 0;
}
void
-Script_column_engraver::acknowledge_grob (Grob_info inf)
+Script_column_engraver::acknowledge_grob (Grob_info inf)
{
- Item *thing = dynamic_cast<Item*> (inf.grob_);
+ Item *thing = dynamic_cast<Item *> (inf.grob_);
if (thing && Side_position_interface::has_interface (inf.grob_)) // ugh FIXME
{
if (!Item::is_breakable (thing)
if (!scol_ && scripts_.size () > 1)
{
scol_ = make_item ("ScriptColumn", SCM_EOL);
-
+
}
if (scol_)
}
ADD_TRANSLATOR (Script_column_engraver,
-/* descr */ "",
-/* creats*/ "ScriptColumn",
-/* accepts */ "",
-/* acks */ "side-position-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "",
+ /* creats*/ "ScriptColumn",
+ /* accepts */ "",
+ /* acks */ "side-position-interface",
+ /* reads */ "",
+ /* write */ "");
-/*
+/*
script-column.cc -- implement Script_column
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "script-column.hh"
if (!scm_is_number (p))
return;
- Pointer_group_interface::add_grob (me, ly_symbol2scm ("scripts"),i);
-
+ Pointer_group_interface::add_grob (me, ly_symbol2scm ("scripts"), i);
+
me->add_dependency (i);
}
LY_DEFINE (ly_grob_script_priority_less, "ly:grob-script-priority-less",
- 2, 0, 0, (SCM a, SCM b),
- "Compare two grobs by script priority. For internal use.")
+ 2, 0, 0, (SCM a, SCM b),
+ "Compare two grobs by script priority. For internal use.")
{
Grob *i1 = unsmob_grob (a);
Grob *i2 = unsmob_grob (b);
SCM
Script_column::before_line_breaking (SCM smob)
{
- Grob* me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
Drul_array<SCM> scripts (SCM_EOL, SCM_EOL);
Link_array<Grob> staff_sided;
-
+
for (SCM s = me->get_property ("scripts"); scm_is_pair (s); s = scm_cdr (s))
{
Grob *sc = unsmob_grob (scm_car (s));
/*
Don't want to consider scripts horizontally next to notes.
- */
+ */
if (!sc->has_offset_callback (Side_position_interface::aligned_side_proc,
X_AXIS))
staff_sided.push (sc);
}
-
+
for (int i = 0; i < staff_sided.size (); i++)
{
- Grob* g = staff_sided[i];
+ Grob *g = staff_sided[i];
Direction d = Side_position_interface::get_direction (g);
if (!d)
{
- programming_error ( "No direction for script?");
+ programming_error ("No direction for script?");
d = DOWN;
g->set_property ("direction", scm_int2num (d));
}
-
+
scripts[d] = scm_cons (g->self_scm (), scripts[d]);
}
{
SCM ss = scm_reverse_x (scripts[d], SCM_EOL);
ss = scm_stable_sort_x (ss, ly_grob_script_priority_less_proc);
-
- Grob * last = 0;
+
+ Grob *last = 0;
for (SCM s = ss; scm_is_pair (s); s = scm_cdr (s))
{
Grob *g = unsmob_grob (scm_car (s));
if (last)
- Side_position_interface::add_support (g,last);
-
+ Side_position_interface::add_support (g, last);
+
last = g;
}
-
- } while (flip (&d) != DOWN);
+
+ }
+ while (flip (&d) != DOWN);
return SCM_UNSPECIFIED;
}
-ADD_INTERFACE (Script_column,"script-column-interface",
+ADD_INTERFACE (Script_column, "script-column-interface",
"An interface that sorts scripts "
"according to their @code{script-priority}",
"");
Spanner *slur_;
protected:
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void stop_translation_timestep ();
virtual void process_music ();
virtual void acknowledge_grob (Grob_info);
/* Add the properties, one by one for each Script. A little memory
could be saved by tacking the props onto the Script grob (i.e. make
ScriptStaccato , ScriptMarcato, etc. ).
-
*/
-void make_script_from_event (Grob *p, bool * follow, Context *tg,
+void make_script_from_event (Grob *p, bool *follow, Context *tg,
SCM art_type, int index)
{
SCM alist = tg->get_property ("scriptDefinitions");
art);
*follow = scm_is_pair (follow_scm) && to_boolean (scm_cdr (follow_scm));
- bool priority_found = false ;
-
- for (SCM s = art ; scm_is_pair (s); s = scm_cdr (s))
+ bool priority_found = false;
+
+ for (SCM s = art; scm_is_pair (s); s = scm_cdr (s))
{
SCM sym = scm_caar (s);
SCM type = scm_object_property (sym, ly_symbol2scm ("backend-type?"));
if (!ly_c_procedure_p (type))
continue;
-
+
SCM val = scm_cdar (s);
if (sym == ly_symbol2scm ("script-priority"))
/* Make sure they're in order of user input by adding index i.
Don't use the direction in this priority. Smaller means closer
to the head. */
- int prio = scm_to_int (val) + index;
-
-
+ int prio = scm_to_int (val) + index;
+
val = scm_int2num (prio);
}
if (p->internal_get_property (sym) == SCM_EOL)
p->set_property ("script-priority",
scm_int2num (index));
}
-
+
Side_position_interface::set_axis (p, Y_AXIS);
}
for (int i = 0; i < script_count; i++)
{
Grob *e = scripts_[i].script_;
-
+
if (Side_position_interface::get_axis (e) == X_AXIS
&& !e->get_parent (Y_AXIS))
{
else if (Note_column::has_interface (info.grob_))
{
/* Make note column the parent of the script. That is not
- correct, but due to seconds in a chord, noteheads may be
- swapped around horizontally.
+ correct, but due to seconds in a chord, noteheads may be
+ swapped around horizontally.
- As the note head to put it on is not known now, postpone this
- decision to Script_interface::before_line_breaking (). */
+ As the note head to put it on is not known now, postpone this
+ decision to Script_interface::before_line_breaking (). */
for (int i = 0; i < script_count; i++)
{
Grob *e = scripts_[i].script_;
}
}
else if (Slur::has_interface (info.grob_))
- slur_ = dynamic_cast<Spanner*> (info.grob_);
+ slur_ = dynamic_cast<Spanner *> (info.grob_);
}
void
::quantised_position_proc, Y_AXIS);
sc->set_property ("staff-padding", SCM_EOL);
}
-
+
scripts_.clear ();
}
ADD_TRANSLATOR (Script_engraver,
-/* descr */ "Handles note scripted articulations.",
-/* creats*/ "Script",
-/* accepts */ "script-event articulation-event",
-/* acks */ "stem-interface rhythmic-head-interface "
- "slur-interface note-column-interface",
-/* reads */ "scriptDefinitions",
-/* write */ "");
+ /* descr */ "Handles note scripted articulations.",
+ /* creats*/ "Script",
+ /* accepts */ "script-event articulation-event",
+ /* acks */ "stem-interface rhythmic-head-interface "
+ "slur-interface note-column-interface",
+ /* reads */ "scriptDefinitions",
+ /* write */ "");
-/*
+/*
script-interface.cc -- implement Script_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "directional-element-interface.hh"
#include "warn.hh"
struct Text_script
{
- static bool has_interface (Grob*);
+ static bool has_interface (Grob *);
};
ADD_INTERFACE (Text_script, "text-script-interface",
- "An object that is put above or below a note",
- "add-stem-support slur script-priority inside-slur");
-
+ "An object that is put above or below a note",
+ "add-stem-support slur script-priority inside-slur");
/*
Hmm. Where should we put add-stem-support ?
- */
+*/
ADD_INTERFACE (Script_interface, "script-interface",
- "An object that is put above or below a note",
- "add-stem-support slur-padding slur script-priority script-stencil inside-slur");
+ "An object that is put above or below a note",
+ "add-stem-support slur-padding slur script-priority script-stencil inside-slur");
/*
self-alignment-interface.cc
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
Axis a = (Axis) scm_to_int (axis);
Grob *him = me->get_parent (a);
Interval he = him->extent (him, a);
-
- return scm_make_real (he.is_empty () ? 0.0 : he.center ());
+
+ return scm_make_real (he.is_empty () ? 0.0 : he.center ());
}
MAKE_SCHEME_CALLBACK (Self_alignment_interface, aligned_on_parent, 2);
Axis a = (Axis) scm_to_int (axis);
Grob *him = me->get_parent (a);
Interval he = him->extent (him, a);
-
+
SCM sym = (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X")
: ly_symbol2scm ("self-alignment-Y");
SCM align_prop (me->internal_get_property (sym));
Real x = 0.0;
Real align = scm_to_double (align_prop);
-
+
Interval ext (me->extent (me, a));
if (ext.is_empty ())
programming_error ("I'm empty. Can't align on self");
else
- x -= ext.linear_combination (align) ;
+ x -= ext.linear_combination (align);
if (!he.is_empty ())
x += he.linear_combination (align);
/* Position centered on parent. */
MAKE_SCHEME_CALLBACK (Self_alignment_interface, centered_on_other_axis_parent, 2);
SCM
-Self_alignment_interface::centered_on_other_axis_parent (SCM element_smob,
+Self_alignment_interface::centered_on_other_axis_parent (SCM element_smob,
SCM axis)
{
Grob *me = unsmob_grob (element_smob);
Axis a = (Axis) scm_to_int (axis);
Grob *him = me->get_parent (other_axis (a));
Interval he = him->extent (him, a);
-
- return scm_make_real (he.is_empty () ? 0.0 : he.center ());
+
+ return scm_make_real (he.is_empty () ? 0.0 : he.center ());
}
/** callback that centers the element on itself
SCM sym = (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X")
: ly_symbol2scm ("self-alignment-Y");
-
+
SCM align (me->internal_get_property (sym));
if (scm_is_number (align))
{
return scm_make_real (0.0);
}
-
ADD_INTERFACE (Self_alignment_interface, "self-alignment-interface",
"Position this object on itself and/or on its parent. To this end, the following functions "
" are provided: \n"
" extent of the parent \n"
"@item Self_alignment_interface::centered_on_other_axis_parent\n"
" For X-axis, center on the Y-parent, and vice versa.\n "
- "@end table\n",
+ "@end table\n",
"self-alignment-X self-alignment-Y");
-/*
+/*
separating-group-spanner.cc -- implement Separating_group_spanner
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "separating-group-spanner.hh"
#include "group-interface.hh"
void
-Separating_group_spanner::find_rods (Item * r, SCM next, Real padding)
+Separating_group_spanner::find_rods (Item *r, SCM next, Real padding)
{
/*
NEXT, making it linear in most of the cases.
*/
if (Separation_item::width (r).is_empty ())
- return;
-
+ return;
for (; scm_is_pair (next); next = scm_cdr (next))
{
- Item *l = dynamic_cast<Item*> (unsmob_grob (scm_car ( next)));
+ Item *l = dynamic_cast<Item *> (unsmob_grob (scm_car (next)));
Item *lb = l->find_prebroken_piece (RIGHT);
if (lb)
rod.item_drul_[RIGHT]= r;
rod.distance_ = li[RIGHT] - ri[LEFT] + padding;
-
+
rod.add_to_cols ();
break;
}
SCM
Separating_group_spanner::set_spacing_rods (SCM smob)
{
- Grob*me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
/*
Ugh: padding is added doubly, also for SeparationItem
- */
+ */
Real padding = robust_scm2double (me->get_property ("padding"), 0.1);
-
+
for (SCM s = me->get_property ("elements"); scm_is_pair (s) && scm_is_pair (scm_cdr (s)); s = scm_cdr (s))
{
/*
Order of elements is reversed!
- */
+ */
SCM elt = scm_car (s);
Item *r = unsmob_item (elt);
continue;
Item *rb
- = dynamic_cast<Item*> (r->find_prebroken_piece (LEFT));
-
+ = dynamic_cast<Item *> (r->find_prebroken_piece (LEFT));
+
find_rods (r, scm_cdr (s), padding);
if (rb)
find_rods (rb, scm_cdr (s), padding);
}
- return SCM_UNSPECIFIED ;
+ return SCM_UNSPECIFIED;
}
void
-Separating_group_spanner::add_spacing_unit (Grob* me , Item*i)
+Separating_group_spanner::add_spacing_unit (Grob *me, Item *i)
{
Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), i);
me->add_dependency (i);
}
-
-
-
ADD_INTERFACE (Separating_group_spanner, "separation-spanner-interface",
"A spanner that calculates spacing constraints (\"rods\") "
"using the @code{separation-item-interface} grobs in @code{elements}.",
-/*
-' separating-line-group-engraver.cc -- implement Separating_line_group_engraver
-
+/*
+ ' separating-line-group-engraver.cc -- implement Separating_line_group_engraver
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "separating-group-spanner.hh"
#include "separation-item.hh"
struct Spacings
{
- Item * staff_spacing_;
+ Item *staff_spacing_;
Link_array<Item> note_spacings_;
Spacings ()
bool is_empty () const
{
- return !staff_spacing_ && !note_spacings_.size ();
+ return !staff_spacing_ && !note_spacings_.size ();
}
- void clear () {
+ void clear ()
+ {
staff_spacing_ = 0;
note_spacings_.clear ();
}
};
-
class Separating_line_group_engraver : public Engraver
{
protected:
- Item * break_item_;
- Item * musical_item_;
- Item * last_musical_item_;
+ Item *break_item_;
+ Item *musical_item_;
+ Item *last_musical_item_;
Spacings current_spacings_;
Spacings last_spacings_;
-
- Spanner * sep_span_;
-
+
+ Spanner *sep_span_;
+
virtual void acknowledge_grob (Grob_info);
virtual void process_music ();
virtual void finalize ();
virtual void stop_translation_timestep ();
- virtual void start_translation_timestep ();
+ virtual void start_translation_timestep ();
public:
TRANSLATOR_DECLARATIONS (Separating_line_group_engraver);
};
{
sep_span_ = make_spanner ("SeparatingGroupSpanner", SCM_EOL);
-
sep_span_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
}
}
Separating_line_group_engraver::finalize ()
{
if (!sep_span_)
- return ;
-
+ return;
+
SCM ccol = get_property ("currentCommandColumn");
Grob *column = unsmob_grob (ccol);
-
+
sep_span_->set_bound (RIGHT, unsmob_grob (ccol));
sep_span_ = 0;
- for (int i = 0 ; i < last_spacings_.note_spacings_.size (); i++)
+ for (int i = 0; i < last_spacings_.note_spacings_.size (); i++)
{
Pointer_group_interface::add_grob (last_spacings_.note_spacings_[i],
- ly_symbol2scm ("right-items" ),
+ ly_symbol2scm ("right-items"),
column);
}
-
+
if (last_spacings_.staff_spacing_
- && last_spacings_.staff_spacing_->get_column () == column)
+ && last_spacings_.staff_spacing_->get_column () == column)
{
last_spacings_.staff_spacing_->suicide ();
}
void
Separating_line_group_engraver::acknowledge_grob (Grob_info i)
{
- Item * it = dynamic_cast <Item *> (i.grob_);
+ Item *it = dynamic_cast<Item *> (i.grob_);
if (!it)
return;
if (it->get_parent (X_AXIS)
->has_extent_callback (Axis_group_interface::group_extent_callback_proc, X_AXIS))
return;
-
if (to_boolean (it->get_property ("no-spacing-rods")))
- return ;
+ return;
- if (Note_spacing::has_interface (it))
+ if (Note_spacing::has_interface (it))
{
current_spacings_.note_spacings_.push (it);
- return ;
+ return;
}
-
+
bool ib = Item::is_breakable (it);
Item *&p_ref_ (ib ? break_item_
: musical_item_);
p_ref_->set_property ("breakable", SCM_BOOL_T);
context ()->set_property ("breakableSeparationItem", p_ref_->self_scm ());
}
-
if (to_boolean (get_property ("createSpacing"))
&& p_ref_ == break_item_)
{
- Item *it = make_item ("StaffSpacing", SCM_EOL);
+ Item *it = make_item ("StaffSpacing", SCM_EOL);
current_spacings_.staff_spacing_ = it;
it->set_property ("left-items", scm_cons (break_item_->self_scm (), SCM_EOL));
-
-
if (int i = last_spacings_.note_spacings_.size ())
{
Pointer_group_interface::add_grob (last_spacings_.note_spacings_[i],
ly_symbol2scm ("right-items"),
break_item_);
-
+
}
else if (last_spacings_.staff_spacing_)
{
last_spacings_.staff_spacing_->set_property ("right-items",
- scm_cons (break_item_->self_scm (), SCM_EOL));
+ scm_cons (break_item_->self_scm (), SCM_EOL));
}
}
}
{
Separating_group_spanner::add_spacing_unit (sep_span_, break_item_);
}
-
- if (Item * sp = current_spacings_.staff_spacing_)
+
+ if (Item *sp = current_spacings_.staff_spacing_)
{
/*
TODO: should really look at the left-items of following
note-spacing grobs.
- */
+ */
if (musical_item_)
Pointer_group_interface::add_grob (sp, ly_symbol2scm ("right-items"),
musical_item_);
}
-
if (!current_spacings_.is_empty ())
{
last_spacings_ = current_spacings_;
}
current_spacings_.clear ();
-
+
if (musical_item_)
{
Separating_group_spanner::add_spacing_unit (sep_span_, musical_item_);
}
-
+
musical_item_ = 0;
}
-
ADD_TRANSLATOR (Separating_line_group_engraver,
-/* descr */ "Generates objects for computing spacing parameters.",
-/* creats*/ "SeparationItem SeparatingGroupSpanner StaffSpacing",
-/* accepts */ "",
-/* acks */ "item-interface",
-/* reads */ "createSpacing",
-/* write */ "breakableSeparationItem");
+ /* descr */ "Generates objects for computing spacing parameters.",
+ /* creats*/ "SeparationItem SeparatingGroupSpanner StaffSpacing",
+ /* accepts */ "",
+ /* acks */ "item-interface",
+ /* reads */ "createSpacing",
+ /* write */ "breakableSeparationItem");
-/*
- separation-item.cc -- implement Separation_item
-
+/*
+ separation-item.cc -- implement Separation_item
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "separation-item.hh"
#include "accidental-placement.hh"
void
-Separation_item::add_item (Grob*s, Item* i)
+Separation_item::add_item (Grob *s, Item *i)
{
assert (i);
Pointer_group_interface::add_grob (s, ly_symbol2scm ("elements"), i);
}
void
-Separation_item::add_conditional_item (Grob* me , Grob *e)
+Separation_item::add_conditional_item (Grob *me, Grob *e)
{
Pointer_group_interface::add_grob (me, ly_symbol2scm ("conditional-elements"), e);
}
/*
Return the width of ME given that we are considering the object on
the LEFT.
- */
+*/
Interval
-Separation_item::conditional_width (Grob * me, Grob * left)
+Separation_item::conditional_width (Grob *me, Grob *left)
{
Interval w = width (me);
-
- Item *item = dynamic_cast<Item*> (me);
- Paper_column * pc = item->get_column ();
-
-
- for (SCM s = me->get_property ("conditional-elements"); scm_is_pair (s); s = scm_cdr (s))
+
+ Item *item = dynamic_cast<Item *> (me);
+ Paper_column *pc = item->get_column ();
+
+ for (SCM s = me->get_property ("conditional-elements"); scm_is_pair (s); s = scm_cdr (s))
{
SCM elt = scm_car (s);
if (!unsmob_grob (elt))
continue;
-
+
Item *il = unsmob_item (elt);
if (pc != il->get_column ())
{
/* this shouldn't happen, but let's continue anyway. */
programming_error (_ ("Separation_item: I've been drinking too much"));
- continue; /*UGH UGH*/
+ continue; /*UGH UGH*/
}
if (to_boolean (il->get_property ("no-spacing-rods")))
return ly_scm2interval (sw);
}
- Item *item = dynamic_cast<Item*> (me);
- Paper_column * pc = item->get_column ();
+ Item *item = dynamic_cast<Item *> (me);
+ Paper_column *pc = item->get_column ();
Interval w;
-
- for (SCM s = me->get_property ("elements"); scm_is_pair (s); s = scm_cdr (s))
+
+ for (SCM s = me->get_property ("elements"); scm_is_pair (s); s = scm_cdr (s))
{
SCM elt = scm_car (s);
if (!unsmob_grob (elt))
{
/* this shouldn't happen, but let's continue anyway. */
programming_error (_ ("Separation_item: I've been drinking too much"));
- continue; /*UGH UGH*/
+ continue; /*UGH UGH*/
}
if (to_boolean (il->get_property ("no-spacing-rods")))
w.widen (robust_scm2double (pad, 0.0));
me->set_property ("X-extent", ly_interval2scm (w));
-
+
return w;
}
Interval
-Separation_item::relative_width (Grob * me, Grob * common)
+Separation_item::relative_width (Grob *me, Grob *common)
{
Interval iv = width (me);
- return dynamic_cast<Item*>(me)->get_column ()->relative_coordinate (common, X_AXIS) + iv ;
+ return dynamic_cast<Item *> (me)->get_column ()->relative_coordinate (common, X_AXIS) + iv;
}
-
/*
Try to find the break-aligned symbol in SEPARATION_ITEM that is
sticking out at direction D. The x size is put in LAST_EXT
*/
-Grob*
+Grob *
Separation_item::extremal_break_aligned_grob (Grob *separation_item, Direction d,
- Interval * last_ext)
+ Interval *last_ext)
{
- Grob *col = dynamic_cast<Item*> (separation_item)->get_column ();
+ Grob *col = dynamic_cast<Item *> (separation_item)->get_column ();
last_ext->set_empty ();
Grob *last_grob = 0;
for (SCM s = separation_item->get_property ("elements");
scm_is_pair (s); s = scm_cdr (s))
{
- Grob * break_item = unsmob_grob (scm_car (s));
-
+ Grob *break_item = unsmob_grob (scm_car (s));
+
if (!scm_is_symbol (break_item->get_property ("break-align-symbol")))
continue;
if (ext.is_empty ())
continue;
if (!last_grob
- || (last_grob && d * (ext[d]- (*last_ext)[d]) > 0) )
+ || (last_grob && d * (ext[d]- (*last_ext)[d]) > 0))
{
*last_ext = ext;
- last_grob = break_item;
+ last_grob = break_item;
}
}
- return last_grob;
+ return last_grob;
}
-
-
-
ADD_INTERFACE (Separation_item, "separation-item-interface",
"Item that computes widths to generate spacing rods. "
- "This is done in concert with @ref{separation-spanner-interface}."
- ,
+ "This is done in concert with @ref{separation-spanner-interface}.",
"padding X-extent conditional-elements elements");
#include "grace-fixup.hh"
/*
-
TODO: handling of grace notes is exquisite pain. This handling
should be formally specified and then the implementation verified.
-
*/
/*
if (scm_is_pair (cursor_))
- iter_->music_ == unsmob_music (scm_car (cursor_))
+ iter_->music_ == unsmob_music (scm_car (cursor_))
else
- iter_ == 0;
+ iter_ == 0;
The length of musiclist from start to up to cursor_ (cursor_ not
including), is summed
- here_mom_ = sum (length (musiclist [start ... cursor>)) %)
-
- */
+ here_mom_ = sum (length (musiclist [start ... cursor>)) %)
+*/
Sequential_iterator::Sequential_iterator ()
{
here_mom_ = Moment (0);
- cursor_ = SCM_EOL;
+ cursor_ = SCM_EOL;
grace_fixups_ = 0;
iter_ = 0;
}
-SCM
+SCM
Sequential_iterator::get_music_list () const
{
return SCM_EOL;
}
-
-
void
Sequential_iterator::derived_mark () const
{
scm_gc_mark (cursor_);
}
-
void
Sequential_iterator::derived_substitute (Context *f, Context *t)
{
/*
TODO: this should be made lazily.
- */
+*/
Grace_fixup *
create_grace_fixup_list (SCM cursor)
{
p->grace_start_ = s.grace_part_;
p->next_ = 0;
*tail = p;
- tail = &(*tail)->next_;
+ tail = &(*tail)->next_;
}
here.grace_part_ = s.grace_part_;
}
-
+
if (l.to_bool ())
{
last = here;
here += l;
}
}
-
+
return head;
}
Music *m = unsmob_music (scm_car (cursor_));
iter_ = unsmob_iterator (get_iterator (m));
}
-
+
while (iter_ && !iter_->ok ())
{
next_element (true);
/*
iter_->ok () is tautology, but what the heck.
- */
- if (iter_ && iter_->ok ())
+ */
+ if (iter_ && iter_->ok ())
descend_to_child (iter_->get_outlet ());
}
-
/*
maintain invariants: change cursor, iter and here_mom_ in one fell
swoop.
Sequential_iterator::next_element (bool)
{
Moment len = iter_->music_get_length () - iter_->music_start_mom ();
- assert (!grace_fixups_ || grace_fixups_->start_ >= here_mom_);
-
+ assert (!grace_fixups_ || grace_fixups_->start_ >= here_mom_);
+
if (len.main_part_
&& get_grace_fixup ())
{
last_mom_ = here_mom_;;
here_mom_ += len;
}
-
+
cursor_ = scm_cdr (cursor_);
iter_->quit ();
iter_ = 0;
}
-
-
void
Sequential_iterator::process (Moment until)
{
while (iter_)
{
- Grace_fixup * gf = get_grace_fixup ();
+ Grace_fixup *gf = get_grace_fixup ();
if (gf
&& gf->start_ + gf->length_
- + Moment (Rational (0), gf->grace_start_) == until)
+ + Moment (Rational (0), gf->grace_start_) == until)
{
/*
do the stuff/note/rest preceding a grace.
- */
+ */
iter_->process (iter_->music_get_length ());
}
else
Moment w = until - here_mom_ + iter_->music_start_mom ();
iter_->process (w);
}
-
+
/*
if the iter is still OK, there must be events left that have
-
- TIME > LEFT
-
+
+ TIME > LEFT
+
*/
if (iter_->ok ())
- return ;
+ return;
descend_to_child (iter_->get_outlet ());
next_element (true);
/*
Fix-up a grace note halfway in the music.
*/
- Grace_fixup * gf = get_grace_fixup ();
+ Grace_fixup *gf = get_grace_fixup ();
if (gf
&& gf->length_ + iter_->music_start_mom () == cp)
{
return cp + here_mom_ - iter_->music_start_mom ();
}
-
bool
Sequential_iterator::ok () const
{
return iter_;
}
-Music_iterator*
+Music_iterator *
Sequential_iterator::try_music_in_children (Music *m) const
-{
+{
return iter_ ? iter_->try_music (m) : 0;
}
bool
Sequential_iterator::run_always () const
{
- return iter_ ? iter_->run_always () : false;
+ return iter_ ? iter_->run_always () : false;
}
void
Sequential_iterator::next_grace_fixup ()
{
- Grace_fixup * n = grace_fixups_->next_;
+ Grace_fixup *n = grace_fixups_->next_;
delete grace_fixups_;
grace_fixups_ = n;
}
-Grace_fixup*
+Grace_fixup *
Sequential_iterator::get_grace_fixup () const
{
if (grace_fixups_ && grace_fixups_->start_ == here_mom_)
SCM
Sequential_music_iterator::get_music_list ()const
{
- return get_music()->get_property ("elements");
+ return get_music ()->get_property ("elements");
}
-/*
+/*
side-position-interface.cc -- implement Side_position_interface
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "side-position-interface.hh"
#include "string-convert.hh"
void
-Side_position_interface::add_support (Grob*me, Grob*e)
+Side_position_interface::add_support (Grob *me, Grob *e)
{
Pointer_group_interface::add_grob (me, ly_symbol2scm ("side-support-elements"), e);
}
Direction
-Side_position_interface::get_direction (Grob*me)
+Side_position_interface::get_direction (Grob *me)
{
SCM d = me->get_property ("direction");
if (is_direction (d) && to_dir (d))
{
relative_dir = to_dir (reldir);
}
-
+
SCM other_elt = me->get_property ("direction-source");
- Grob * e = unsmob_grob (other_elt);
+ Grob *e = unsmob_grob (other_elt);
if (e)
{
return (Direction) (relative_dir * get_grob_direction (e));
}
-
+
return CENTER;
}
-
MAKE_SCHEME_CALLBACK (Side_position_interface, aligned_on_support_extents, 2);
SCM
return general_side_position (me, a, true);
}
-
/* Put the element next to the support, optionally taking in
account the extent of the support. */
SCM
Real ss = Staff_symbol_referencer::staff_space (me);
SCM support = me->get_property ("side-support-elements");
Grob *common = common_refpoint_of_list (support, me->get_parent (a), a);
- Grob * st = Staff_symbol_referencer::get_staff_symbol (me);
+ Grob *st = Staff_symbol_referencer::get_staff_symbol (me);
bool include_staff = (st
&& a == Y_AXIS
&& scm_is_number (me->get_property ("staff-padding")));
common = st->common_refpoint (common, Y_AXIS);
dim = st->extent (common, Y_AXIS);
}
-
+
for (SCM s = support; s != SCM_EOL; s = scm_cdr (s))
{
Grob *e = unsmob_grob (scm_car (s));
dim = Interval (0, 0);
Direction dir = Side_position_interface::get_direction (me);
-
+
Real off = me->get_parent (a)->relative_coordinate (common, a);
- Real minimum_space = ss * robust_scm2double (me->get_property ("minimum-space"), -1);
+ Real minimum_space = ss * robust_scm2double (me->get_property ("minimum-space"), -1);
Real total_off = dim.linear_combination (dir) - off;
total_off += dir * ss * robust_scm2double (me->get_property ("padding"), 0);
if (fabs (total_off) > 100 CM)
{
String msg
- = String_convert::form_string ("Improbable offset for grob %s: %f%s",
- me->name ().to_str0 (), total_off,
- INTERNAL_UNIT);
-
+ = String_convert::form_string ("Improbable offset for grob %s: %f%s",
+ me->name ().to_str0 (), total_off,
+ INTERNAL_UNIT);
+
programming_error (msg);
}
return scm_make_real (total_off);
/*
Cut & paste (ugh.)
- */
+*/
MAKE_SCHEME_CALLBACK (Side_position_interface, aligned_on_support_refpoints, 2);
SCM
Side_position_interface::aligned_on_support_refpoints (SCM smob, SCM axis)
Grob *me = unsmob_grob (smob);
Axis a = (Axis) scm_to_int (axis);
- return general_side_position (me, a, false);
+ return general_side_position (me, a, false);
}
-
-
Real
directed_round (Real f, Direction d)
{
Side_position_interface::quantised_position (SCM element_smob, SCM)
{
Grob *me = unsmob_grob (element_smob);
-
+
Direction d = Side_position_interface::get_direction (me);
- Grob * stsym = Staff_symbol_referencer::get_staff_symbol (me);
+ Grob *stsym = Staff_symbol_referencer::get_staff_symbol (me);
if (stsym)
{
Real p = Staff_symbol_referencer::get_position (me);
Real rp = directed_round (p, d);
- Real rad = Staff_symbol_referencer::staff_radius (me) *2 ;
+ Real rad = Staff_symbol_referencer::staff_radius (me) *2;
int ip = int (rp);
Grob *head = me->get_parent (X_AXIS);
-
+
if (Staff_symbol_referencer::on_staffline (me, ip)
&& ((abs (ip) <= rad)
|| (Note_head::has_interface (head)
&& sign (Staff_symbol_referencer::get_position (head))
- == -d)
- ))
+ == -d)))
{
ip += d;
rp += d;
}
-
+
return scm_make_real ((rp - p) * Staff_symbol_referencer::staff_space (me) / 2.0);
}
return scm_make_real (0.0);
/*
Position next to support, taking into account my own dimensions and padding.
- */
+*/
MAKE_SCHEME_CALLBACK (Side_position_interface, aligned_side, 2);
SCM
Side_position_interface::aligned_side (SCM element_smob, SCM axis)
{
Grob *me = unsmob_grob (element_smob);
Axis a = (Axis) scm_to_int (axis);
-
+
Direction d = Side_position_interface::get_direction (me);
-
+
Real o = scm_to_double (aligned_on_support_extents (element_smob, axis));
- Interval iv = me->extent (me, a);
+ Interval iv = me->extent (me, a);
if (!iv.is_empty ())
{
programming_error ("Direction unknown, but aligned-side wanted.");
d = DOWN;
}
- o += - iv[-d];
+ o += -iv[-d];
}
/*
- Maintain a minimum distance to the staff. This is similar to side
- position with padding, but it will put adjoining objects on a row if
- stuff sticks out of the staff a little.
- */
- Grob * st = Staff_symbol_referencer::get_staff_symbol (me);
+ Maintain a minimum distance to the staff. This is similar to side
+ position with padding, but it will put adjoining objects on a row if
+ stuff sticks out of the staff a little.
+ */
+ Grob *st = Staff_symbol_referencer::get_staff_symbol (me);
if (st && a == Y_AXIS
&& scm_is_number (me->get_property ("staff-padding")))
{
- Real padding =
- Staff_symbol_referencer::staff_space (me)
- * scm_to_double (me->get_property ("staff-padding"));
-
+ Real padding
+ = Staff_symbol_referencer::staff_space (me)
+ * scm_to_double (me->get_property ("staff-padding"));
+
Grob *common = me->common_refpoint (st, Y_AXIS);
-
+
Interval staff_size = st->extent (common, Y_AXIS);
- Real diff = d*staff_size[d] + padding - d*(o + iv[-d]);
- o += (d* (diff >? 0));
+ Real diff = d*staff_size[d] + padding - d* (o + iv[-d]);
+ o += (d* (diff >? 0));
}
-
+
return scm_make_real (o);
}
-
void
-Side_position_interface::set_axis (Grob*me, Axis a)
+Side_position_interface::set_axis (Grob *me, Axis a)
{
me->add_offset_callback (Side_position_interface::aligned_side_proc, a);
}
// ugh. doesn't catch all variants.
Axis
-Side_position_interface::get_axis (Grob*me)
+Side_position_interface::get_axis (Grob *me)
{
if (me->has_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS)
- || me->has_offset_callback (Side_position_interface::aligned_side_proc , X_AXIS))
+ || me->has_offset_callback (Side_position_interface::aligned_side_proc, X_AXIS))
return X_AXIS;
-
+
return Y_AXIS;
}
-
ADD_INTERFACE (Side_position_interface, "side-position-interface",
"Position a victim object (this one) next to other objects (the "
"support). The property @code{direction} signifies where to put the "
"victim object relative to the support (left or right, up or down?)\n\n "
"The routine also takes the size the staff into account if "
- "@code{staff-padding} is set. If undefined, the staff symbol is ignored."
- ,
+ "@code{staff-padding} is set. If undefined, the staff symbol is ignored.",
"staff-padding side-support-elements direction-source "
"direction side-relative-direction minimum-space padding");
-/*
+/*
simple-music-iterator.cc -- implement Simple_music_iterator
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "simple-music-iterator.hh"
Engravers can detect and event the end-moments to be processed as
well.
-
*/
Moment
Simple_music_iterator::pending_moment ()const
return music_get_length ();
}
-
void
Simple_music_iterator::process (Moment m)
{
/*
- don't do try_music (), since it would make the function useless for
- base classes
+ don't do try_music (), since it would make the function useless for
+ base classes
*/
last_processed_mom_ = m;
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
-
#include <cstdio>
#include <math.h>
#include "warn.hh"
#include "simple-spacer.hh"
-LY_DEFINE(ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem",
- 4, 1, 0, (SCM springs, SCM rods, SCM length, SCM ragged),
- "Solve a spring and rod problem for @var{count} objects, that "
- "are connected by @var{count-1} springs, and an arbitrary number of rods "
- "Springs have the format (ideal, hooke) and rods (idx1, idx2, distance) "
- "@var{length} is a number, @var{ragged} a boolean "
- "Return: a list containing the force (positive for stretching, "
- "negative for compressing and #f for non-satisfied constraints) "
- "followed by the @var{spring-count}+1 positions of the objects. "
- )
+LY_DEFINE (ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem",
+ 4, 1, 0, (SCM springs, SCM rods, SCM length, SCM ragged),
+ "Solve a spring and rod problem for @var{count} objects, that "
+ "are connected by @var{count-1} springs, and an arbitrary number of rods "
+ "Springs have the format (ideal, hooke) and rods (idx1, idx2, distance) "
+ "@var{length} is a number, @var{ragged} a boolean "
+ "Return: a list containing the force (positive for stretching, "
+ "negative for compressing and #f for non-satisfied constraints) "
+ "followed by the @var{spring-count}+1 positions of the objects. ")
{
int len = scm_ilength (springs);
if (len == 0)
return scm_list_2 (scm_from_double (0.0), scm_from_double (0.0));
-
+
SCM_ASSERT_TYPE (len >= 0, springs, SCM_ARG1, __FUNCTION__, "list of springs");
SCM_ASSERT_TYPE (scm_ilength (rods) >= 0, rods, SCM_ARG2, __FUNCTION__, "list of rods");
SCM_ASSERT_TYPE (scm_is_number (length) || length == SCM_BOOL_F,
length, SCM_ARG3, __FUNCTION__, "number or #f");
-
- bool is_ragged = ragged == SCM_BOOL_T;
- Simple_spacer spacer;
+ bool is_ragged = ragged == SCM_BOOL_T;
+ Simple_spacer spacer;
for (SCM s = springs; scm_is_pair (s); s = scm_cdr (s))
{
Real ideal = scm_to_double (scm_caar (s));
int l = scm_to_int (scm_car (entry));
int r = scm_to_int (scm_cadr (entry));
entry = scm_cddr (entry);
-
+
Real distance = scm_to_double (scm_car (entry));
spacer.add_rod (l, r, distance);
}
spacer.line_len_ = scm_to_double (length);
-
+
if (is_ragged)
spacer.my_solve_natural_len ();
else
Array<Real> posns;
posns.push (0.0);
- for (int i = 0; i < spacer.springs_.size(); i++)
+ for (int i = 0; i < spacer.springs_.size (); i++)
{
Real l = spacer.springs_[i].length ((is_ragged) ? 0.0 : spacer.force_);
- posns.push (posns.top() + l);
+ posns.push (posns.top () + l);
}
-
-
SCM force_return = SCM_BOOL_F;
if (!isinf (spacer.force_)
&& (spacer.is_active () || is_ragged))
}
SCM retval = SCM_EOL;
- for (int i = posns.size(); i--;)
+ for (int i = posns.size (); i--;)
{
- retval = scm_cons (scm_from_double (posns[i]), retval);
+ retval = scm_cons (scm_from_double (posns[i]), retval);
}
retval = scm_cons (force_return, retval);
- return retval;
+ return retval;
}
-/*
+/*
simple-spacer.cc -- implement Simple_spacer
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
TODO:
- add support for different stretch/shrink constants?
-
*/
-
#include <cstdio>
#include <math.h>
#include "dimensions.hh"
/*
- A simple spacing constraint solver. The approach:
+ A simple spacing constraint solver. The approach:
- Stretch the line uniformly until none of the constraints (rods)
- block. It then is very wide.
+ Stretch the line uniformly until none of the constraints (rods)
+ block. It then is very wide.
- Compress until the next constraint blocks,
+ Compress until the next constraint blocks,
- Mark the springs over the constrained part to be non-active.
-
- Repeat with the smaller set of non-active constraints, until all
- constraints blocked, or until the line is as short as desired.
+ Mark the springs over the constrained part to be non-active.
- This is much simpler, and much much faster than full scale
- Constrained QP. On the other hand, a situation like this will not
- be typeset as dense as possible, because
+ Repeat with the smaller set of non-active constraints, until all
+ constraints blocked, or until the line is as short as desired.
- c4 c4 c4 c4
- veryveryverylongsyllable2 veryveryverylongsyllable2
- " "4 veryveryverylongsyllable2 syllable4
+ This is much simpler, and much much faster than full scale
+ Constrained QP. On the other hand, a situation like this will not
+ be typeset as dense as possible, because
+ c4 c4 c4 c4
+ veryveryverylongsyllable2 veryveryverylongsyllable2
+ " "4 veryveryverylongsyllable2 syllable4
- can be further compressed to
+ can be further compressed to
- c4 c4 c4 c4
- veryveryverylongsyllable2 veryveryverylongsyllable2
- " "4 veryveryverylongsyllable2 syllable4
+ c4 c4 c4 c4
+ veryveryverylongsyllable2 veryveryverylongsyllable2
+ " "4 veryveryverylongsyllable2 syllable4
- Perhaps this is not a bad thing, because the 1st looks better anyway. */
+ Perhaps this is not a bad thing, because the 1st looks better anyway. */
/*
-
positive force = expanding, negative force = compressing.
-
*/
Simple_spacer::Simple_spacer ()
{
/*
If a spring is fixed, we have to do something here:
- we let the rod override the spring.
- */
+ we let the rod override the spring.
+ */
Real total_dist = 0.;
- for (int i = l ; i < r; i++)
+ for (int i = l; i < r; i++)
total_dist += springs_[i].ideal_;
if (total_dist < dist)
- for (int i = l ; i < r; i++)
- springs_[i].ideal_ *= dist/total_dist;
+ for (int i = l; i < r; i++)
+ springs_[i].ideal_ *= dist / total_dist;
return;
}
-
+
Real d = range_ideal_len (l, r);
Real block_stretch = dist - d;
-
+
Real block_force = c * block_stretch;
force_ = force_ >? block_force;
for (int i = l; i < r; i++)
springs_[i].block_force_ = block_force >?
- springs_[i].block_force_ ;
+ springs_[i].block_force_;
}
Real
-Simple_spacer::range_ideal_len (int l, int r) const
+Simple_spacer::range_ideal_len (int l, int r) const
{
Real d = 0.;
for (int i = l; i < r; i++)
Real
Simple_spacer::active_blocking_force () const
{
- Real bf = - infinity_f;
+ Real bf = -infinity_f;
for (int i = 0; i < springs_.size (); i++)
if (springs_[i].is_active_)
{
Real
Simple_spacer::active_springs_stiffness () const
{
- Real stiff = range_stiffness (0, springs_.size ());
+ Real stiff = range_stiffness (0, springs_.size ());
if (isinf (stiff))
{
/*
all springs are inactive. Take the stiffness of the
latest spring to block.
- */
+ */
Real max_block_force = -infinity_f;
int max_i = -1;
}
}
- stiff = springs_[max_i].hooke_;
+ stiff = springs_[max_i].hooke_;
}
return stiff;
}
Simple_spacer::set_active_states ()
{
/* float comparison is safe, since force is only copied. */
- for (int i = 0 ; i <springs_.size (); i++)
+ for (int i = 0; i <springs_.size (); i++)
if (springs_[i].is_active_
&& springs_[i].block_force_ >= force_)
{
springs_[i].is_active_ = false;
- active_count_ --;
+ active_count_--;
}
-}
+}
Real
Simple_spacer::configuration_length () const
bool
Simple_spacer::is_active () const
{
- return active_count_;
+ return active_count_;
}
void
}
}
-
void
Simple_spacer::my_solve_natural_len ()
{
Real line_len_force = 0.0;
-
+
while (is_active ())
{
force_ = active_blocking_force () >? 0.0;
{
line_len_force = force_
+ (line_len_ - conf)
- * active_springs_stiffness();
+ * active_springs_stiffness ();
}
-
+
if (force_ < 1e-8) // ugh.,
break;
-
+
set_active_states ();
}
force_ = line_len_force;
}
-
-
/****************************************************************/
Spring_description::Spring_description ()
block_force_ = 0.0;
}
-
bool
Spring_description::is_sane () const
{
{
if (!is_active_)
f = block_force_;
- return ideal_ + f / hooke_ ;
+ return ideal_ + f / hooke_;
}
/****************************************************************/
-
/*
-
TODO: should a add penalty for widely varying spring forces (caused
by constraints, eg.
- =====
- | |
+ =====
+ | |
o|o| x ##x
The ## forces the notes apart; we shouldn't allow the O's to touch
this closely.
-
- */
+*/
void
-Simple_spacer_wrapper::solve (Column_x_positions *positions, bool ragged)
+Simple_spacer_wrapper::solve (Column_x_positions *positions, bool ragged)
{
if (ragged)
spacer_->my_solve_natural_len ();
spacer_->my_solve_linelen ();
positions->force_ = spacer_->force_;
-
+
/*
We used to have a penalty for compression, no matter what, but that
fucked up wtk1-fugue2 (taking 3 full pages.)
positions->config_.push (spacer_->indent_);
for (int i = 0; i < spacer_->springs_.size (); i++)
{
- Real l = spacer_->springs_[i].length ((ragged) ? 0.0 : spacer_->force_);
+ Real l = spacer_->springs_[i].length ((ragged) ? 0.0 : spacer_->force_);
positions->config_.push (positions->config_.top () + l);
/*
- we have l>= 0 here, up to rounding errors
+ we have l>= 0 here, up to rounding errors
*/
}
/*
For raggedright, we must have a measure of music density: this is
to prevent lots of short lines (which all have force = 0).
- */
+ */
if (ragged)
{
- positions->satisfies_constraints_ =
- positions->config_.top () < spacer_->line_len_ ;
+ positions->satisfies_constraints_
+ = positions->config_.top () < spacer_->line_len_;
}
else
positions->satisfies_constraints_ = spacer_->is_active ();
/*
Check if breaking constraints are met.
- */
+ */
bool break_satisfy = true;
- int sz = positions->cols_.size ();
- for (int i = sz; i--; )
+ int sz = positions->cols_.size ();
+ for (int i = sz; i--;)
{
- SCM p = positions->cols_[i]->get_property ( "penalty");
+ SCM p = positions->cols_[i]->get_property ("penalty");
if (scm_is_number (p))
{
if (scm_to_double (p) < -9999)
break_satisfy = break_satisfy && (i == 0 || i == sz -1);
if (scm_to_double (p) > 9999)
- break_satisfy = break_satisfy && !(i == 0 || i == sz -1);
+ break_satisfy = break_satisfy && ! (i == 0 || i == sz -1);
}
-
+
}
- positions->satisfies_constraints_ =
- positions->satisfies_constraints_ && break_satisfy;
+ positions->satisfies_constraints_
+ = positions->satisfies_constraints_ && break_satisfy;
}
void
desc.hooke_ = 1.0;
desc.ideal_ = 1.0;
}
-
+
if (isinf (hooke))
{
desc.is_active_ = false;
else
{
/*
- desc.is_active_ ?
+ desc.is_active_ ?
*/
- desc.block_force_ = - desc.hooke_ * desc.ideal_; // block at distance 0
-
- active_count_ ++;
+ desc.block_force_ = -desc.hooke_ * desc.ideal_; // block at distance 0
+
+ active_count_++;
}
springs_.push (desc);
}
static int
-compare_paper_column_rank (Grob *const &a,
- Grob *const &b)
+compare_paper_column_rank (Grob *const &a,
+ Grob *const &b)
{
- return Paper_column::get_rank (a) - Paper_column::get_rank (b);
+ return Paper_column::get_rank (a) - Paper_column::get_rank (b);
}
void
Simple_spacer_wrapper::add_columns (Link_array<Grob> const &icols)
{
Link_array<Grob> cols (icols);
-
- for (int i = cols.size (); i--;)
+
+ for (int i = cols.size (); i--;)
if (scm_is_pair (cols[i]->get_property ("between-cols")))
{
loose_cols_.push (cols[i]);
cols.del (i);
}
-
+
spaced_cols_ = cols;
for (int i = 0; i < cols.size () - 1; i++)
{
s = scm_cdr (s))
{
Spring_smob *sp = unsmob_spring (scm_car (s));
-
-
- if (sp->other_ == cols[i+1])
+
+ if (sp->other_ == cols[i + 1])
spring = sp;
}
if (!spring)
programming_error (_f ("No spring between column %d and next one",
- Paper_column::get_rank (cols[i])
- ));
+ Paper_column::get_rank (cols[i])));
Real ideal = (spring) ? spring->distance_ : spacer_->default_space_;
Real hooke = (spring) ? spring->strength_ : 1.0;
-
+
spacer_->add_spring (ideal, hooke);
}
-
+
for (int i = 0; i < cols.size () - 1; i++)
{
for (SCM s = Spaceable_grob::get_minimum_distances (cols[i]);
scm_is_pair (s); s = scm_cdr (s))
{
- Grob * other = unsmob_grob (scm_caar (s));
+ Grob *other = unsmob_grob (scm_caar (s));
int oi = binsearch_links (cols, other, &compare_paper_column_rank);
if (oi >= 0)
{
}
if (i
- && !to_boolean (cols[i]->get_property ("allow-outside-line")))
+ && !to_boolean (cols[i]->get_property ("allow-outside-line")))
{
Interval e = cols[i]->extent (cols[i], X_AXIS);
- if (!e.is_empty())
+ if (!e.is_empty ())
{
- spacer_->add_rod (i, cols.size()-1, e[RIGHT]);
+ spacer_->add_rod (i, cols.size () - 1, e[RIGHT]);
spacer_->add_rod (0, i, e[LEFT]);
}
}
delete spacer_;
}
-
-Simple_spacer_wrapper::Simple_spacer_wrapper (Simple_spacer_wrapper const&)
+Simple_spacer_wrapper::Simple_spacer_wrapper (Simple_spacer_wrapper const &)
{
}
children_list_ = SCM_EOL;
}
-
void
Simultaneous_music_iterator::derived_mark () const
{
SCM i = get_music ()->get_property ("elements");
children_list_ = SCM_EOL;
- SCM * tail = &children_list_;
+ SCM *tail = &children_list_;
for (; scm_is_pair (i); i = scm_cdr (i), j++)
{
Music *mus = unsmob_music (scm_car (i));
SCM scm_iter = get_static_get_iterator (mus);
- Music_iterator * mi = unsmob_iterator (scm_iter);
+ Music_iterator *mi = unsmob_iterator (scm_iter);
/* if create_separate_contexts_ is set, create a new context with the
number number as name */
SCM name = ly_symbol2scm (get_outlet ()->context_name ().to_str0 ());
- Context * t = (j && create_separate_contexts_)
+ Context *t = (j && create_separate_contexts_)
? get_outlet ()->find_create_context (name, to_string (j), SCM_EOL)
: get_outlet ();
mi->init_translator (mus, t);
mi->construct_children ();
- if (mi->ok ())
+ if (mi->ok ())
{
*tail = scm_cons (scm_iter, *tail);
tail = SCM_CDRLOC (*tail);
void
Simultaneous_music_iterator::process (Moment until)
{
- SCM *proc = &children_list_;
+ SCM *proc = &children_list_;
while (scm_is_pair (*proc))
{
- Music_iterator * i = unsmob_iterator (scm_car (*proc));
+ Music_iterator *i = unsmob_iterator (scm_car (*proc));
if (i->run_always ()
- || i->pending_moment () == until)
+ || i->pending_moment () == until)
{
i->process (until);
}
{
Moment next;
next.set_infinite (1);
-
+
for (SCM s = children_list_; scm_is_pair (s); s = scm_cdr (s))
{
- Music_iterator * it = unsmob_iterator (scm_car (s));
+ Music_iterator *it = unsmob_iterator (scm_car (s));
next = next <? it->pending_moment ();
}
-
+
return next;
}
bool
Simultaneous_music_iterator::ok () const
{
- bool run_always_ok = false;
+ bool run_always_ok = false;
for (SCM s = children_list_; scm_is_pair (s); s = scm_cdr (s))
{
- Music_iterator * it = unsmob_iterator (scm_car (s));
+ Music_iterator *it = unsmob_iterator (scm_car (s));
if (!it->run_always ())
return true;
else
- run_always_ok = run_always_ok || it->ok ();
+ run_always_ok = run_always_ok || it->ok ();
}
return run_always_ok;
}
{
for (SCM s = children_list_; scm_is_pair (s); s = scm_cdr (s))
{
- Music_iterator * it = unsmob_iterator (scm_car (s));
+ Music_iterator *it = unsmob_iterator (scm_car (s));
if (it->run_always ())
return true;
}
return false;
}
-Music_iterator*
+Music_iterator *
Simultaneous_music_iterator::try_music_in_children (Music *m) const
{
- Music_iterator * b = 0;
+ Music_iterator *b = 0;
for (SCM s = children_list_; !b && scm_is_pair (s); s = scm_cdr (s))
b = unsmob_iterator (scm_car (s))->try_music (m);
return b;
-/*
+/*
skyline.cc -- implement Skyline_entry and funcs.
source file of the GNU LilyPond music typesetter
(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "skyline.hh"
+#include "skyline.hh"
/*
A skyline is a shape of the form:
- ----
- | |
- ---------| |
- | |
- | |
- | |______
+ ----
+ | |
+ ---------| |
+ | |
+ | |
+ | |______
--------| |___
-
+
This file deals with building such skyline structure, and computing
the minimum distance between two opposing skylines.
-
-
+
+
Invariants for a skyline:
skyline[...].width_ forms a partition of the real interval, where
the segments are adjacent, and ascending. Hence we have
-
+
skyline.top ().width_[RIGHT] = inf
skyline[0].width_[LEFT] = -inf
-
- */
-
+*/
-const Real EPS = 1e-12;
+const Real EPS = 1e-12;
/*
TODO: avoid unnecessary fragmentation.
Interval extent = b[line_axis];
if (extent.is_empty ())
return;
-
+
Real stick_out = b[other_axis (line_axis)][d];
/*
- Intersect each segment of LINE with EXTENT, and if non-empty, insert relevant segments.
- */
+ Intersect each segment of LINE with EXTENT, and if non-empty, insert relevant segments.
+ */
for (int i = line->size (); i--;)
{
Interval w = line->elem (i).width_;
if (extent[LEFT] >= w[RIGHT])
break;
-
+
Real my_height = line->elem (i).height_;
- if (!w.is_empty () &&
- w.length () > EPS
+ if (!w.is_empty ()
+ && w.length () > EPS
&& d* (my_height - stick_out) < 0)
{
Interval e1 (line->elem (i).width_[LEFT], extent[LEFT]);
Interval e3 (extent[RIGHT], line->elem (i).width_[RIGHT]);
if (!e3.is_empty () && e3.length () > EPS)
- line->insert (Skyline_entry (e3, my_height), i+1);
+ line->insert (Skyline_entry (e3, my_height), i + 1);
line->elem_ref (i).height_ = stick_out;
line->elem_ref (i).width_ = w;
if (!e1.is_empty () && e1.length () > EPS)
- line->insert (Skyline_entry (e1, my_height), i );
+ line->insert (Skyline_entry (e1, my_height), i);
}
-
}
}
void
merge_skyline (Array<Skyline_entry> * a1,
- Array<Skyline_entry> const & a2,
+ Array<Skyline_entry> const &a2,
Direction dir)
{
for (int i = 0; i < a2.size (); i++)
Box b;
b[X_AXIS] = a2[i].width_;
b[Y_AXIS][dir] = a2[i].height_;
- b[Y_AXIS][-dir] = dir * infinity_f ;
+ b[Y_AXIS][-dir] = dir * infinity_f;
insert_extent_into_skyline (a1, b, X_AXIS, dir);
}
}
-
Array<Skyline_entry>
empty_skyline (Direction d)
{
i.swap ();
Skyline_entry e;
e.width_ = i;
- e.height_ = -d * infinity_f;
+ e.height_ = -d * infinity_f;
skyline.push (e);
return skyline;
}
We could do a lot better (n log (n), using a balanced tree) but
that seems overkill for now.
- */
- for (int j = extents.size (); j--; )
+ */
+ for (int j = extents.size (); j--;)
insert_extent_into_skyline (&skyline, extents[j], a, d);
return skyline;
}
-
-
/*
minimum distance that can be achieved between baselines. "Clouds" is
a skyline pointing down.
This is an O (n) algorithm.
- */
+*/
Real
skyline_meshing_distance (Array<Skyline_entry> const &buildings,
Array<Skyline_entry> const &clouds)
{
int i = buildings.size () -1;
- int j = clouds.size () -1;
+ int j = clouds.size () -1;
+
+ Real distance = -infinity_f;
- Real distance = - infinity_f;
-
while (i > 0 || j > 0)
{
Interval w = buildings[i].width_;
w.intersect (clouds[j].width_);
-
+
if (!w.is_empty ())
distance = distance >? (buildings[i].height_ - clouds[j].height_);
- if (i>0 && buildings[i].width_[LEFT] >= clouds[j].width_[LEFT])
+ if (i > 0 && buildings[i].width_[LEFT] >= clouds[j].width_[LEFT])
{
i--;
}
- else if (j > 0 && buildings[i].width_[LEFT] <= clouds[j].width_[LEFT])
+ else if (j > 0 && buildings[i].width_[LEFT] <= clouds[j].width_[LEFT])
{
j--;
- }
+ }
}
return distance;
{
width_ = i;
height_ = r;
-
+
}
void
heighten_skyline (Array<Skyline_entry> *buildings, Real ground)
{
for (int i = 0; i < buildings->size (); i++)
- buildings->elem_ref (i).height_ += ground;
+ buildings->elem_ref (i).height_ += ground;
}
-/*
+/*
slash-repeat-engraver.cc -- implement Slash_repeat_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "repeated-music.hh"
#include "global-context.hh"
#include "score-engraver.hh"
/**
- This acknowledges repeated music with "percent" style. It typesets
- a % sign.
+ This acknowledges repeated music with "percent" style. It typesets
+ a % sign.
- TODO:
+ TODO:
- - BEAT case: Create items for single beat repeats, i.e. c4 / / /
+ - BEAT case: Create items for single beat repeats, i.e. c4 / / /
- - DOUBLE_MEASURE case: attach a % to an appropriate barline.
-
+ - DOUBLE_MEASURE case: attach a % to an appropriate barline.
*/
class Slash_repeat_engraver : public Engraver
{
Moment next_moment_;
Moment body_length_;
- Item * beat_slash_;
- Item * double_percent_;
+ Item *beat_slash_;
+ Item *double_percent_;
protected:
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
virtual void process_music ();
}
bool
-Slash_repeat_engraver::try_music (Music * m)
+Slash_repeat_engraver::try_music (Music *m)
{
if (m->is_mus_type ("repeated-music")
&& !repeat_
{
body_length_ = Repeated_music::body_get_length (m);
int count = Repeated_music::repeat_count (m);
-
+
Moment now = now_mom ();
start_mom_ = now;
stop_mom_ = start_mom_ + Moment (count) * body_length_;
Moment meas_length
= robust_scm2moment (get_property ("measureLength"), Moment (0));
- if (body_length_ < meas_length )
+ if (body_length_ < meas_length)
{
repeat_ = m;
}
else
return false;
-
+
Global_context *global = get_global_context ();
- for (int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
global->add_moment_to_process (next_moment_ + Moment (i) * body_length_);
-
+
return true;
}
}
}
-
void
Slash_repeat_engraver::start_translation_timestep ()
{
}
-
-
ADD_TRANSLATOR (Slash_repeat_engraver,
-/* descr */ "Make beat repeats.",
-/* creats*/ "RepeatSlash",
-/* accepts */ "repeated-music",
-/* acks */ "",
-/* reads */ "measureLength",
-/* write */ "");
+ /* descr */ "Make beat repeats.",
+ /* creats*/ "RepeatSlash",
+ /* accepts */ "repeated-music",
+ /* acks */ "",
+ /* reads */ "measureLength",
+ /* write */ "");
-/*
+/*
slur-configuration.cc -- implement Slur_configuration
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "slur-configuration.hh"
#include "libc-extension.hh"
Bezier
-avoid_staff_line (Slur_score_state const &state,
+avoid_staff_line (Slur_score_state const &state,
Bezier bez)
{
Offset horiz (1, 0);
&& (int (fabs (my_round (p))) % 2
!= Staff_symbol_referencer::line_count (staff) % 2))
{
- Direction resolution_dir =
- (distance ? state.dir_ : Direction (sign (p - my_round (p))));
+ Direction resolution_dir
+ = (distance ? state.dir_ : Direction (sign (p - my_round (p))));
// TODO: parameter
Real newp = my_round (p) + resolution_dir
* 5 * state.thickness_;
-
+
Real dy = (newp - p) * state.staff_space_ / 2.0;
-
+
bez.control_[1][Y_AXIS] += dy;
bez.control_[2][Y_AXIS] += dy;
}
Real
fit_factor (Offset dz_unit, Offset dz_perp,
- Bezier curve, Direction d, Array<Offset> const &avoid)
+ Bezier curve, Direction d, Array<Offset> const &avoid)
{
Real fit_factor = 0.0;
Offset x0 = curve.control_[0];
for (int i = 0; i < avoid.size (); i++)
{
- Offset z = (avoid[i] - x0) ;
+ Offset z = (avoid[i] - x0);
Offset p (dot_product (z, dz_unit),
d* dot_product (z, dz_perp));
if (!curve_xext.contains (p[X_AXIS]))
}
return fit_factor;
}
-
+
void
Slur_configuration::generate_curve (Slur_score_state const &state,
- Real r_0, Real h_inf )
+ Real r_0, Real h_inf)
{
Link_array<Grob> encompasses = state.columns_;
Encompass_info inf (state.get_encompass_info (encompasses[i]));
Real y = state.dir_ * ((state.dir_ * inf.head_) >? (state.dir_ *inf.stem_));
- avoid.push (Offset (inf.x_, y + state.dir_ * state.parameters_.free_head_distance_));
+ avoid.push (Offset (inf.x_, y + state.dir_ * state.parameters_.free_head_distance_));
}
Link_array<Grob> extra_encompasses
= extract_grob_array (state.slur_, ly_symbol2scm ("encompass-objects"));
- for (int i = 0; i < extra_encompasses.size (); i++)
+ for (int i = 0; i < extra_encompasses.size (); i++)
if (Slur::has_interface (extra_encompasses[i]))
{
- Grob * small_slur = extra_encompasses[i];
+ Grob *small_slur = extra_encompasses[i];
Bezier b = Slur::get_curve (small_slur);
Offset z = b.curve_point (0.5);
Real indent, height;
get_slur_indent_height (&indent, &height, dz.length (), h_inf, r_0);
-
Real len = dz.length ();
/* This condition,
- len^2 > 4h^2 + 3 (i + 1/3len)^2 - 1/3 len^2
+ len^2 > 4h^2 + 3 (i + 1/3len)^2 - 1/3 len^2
- is equivalent to:
+ is equivalent to:
- |bez' (0)| < | bez' (.5)|
+ |bez' (0)| < | bez' (.5)|
- when (control2 - control1) has the same direction as
- (control3 - control0). */
-
-
+ when (control2 - control1) has the same direction as
+ (control3 - control0). */
Real max_indent = len / 3.1;
indent = indent <? max_indent;
-
+
Real a1 = sqr (len) / 3.0;
Real a2 = 0.75 * sqr (indent + len / 3.0);
Real max_h = a1 - a2;
-
if (max_h < 0)
{
programming_error ("Slur indent too small.");
- max_h = len / 3.0 ;
+ max_h = len / 3.0;
}
else
{
}
Real excentricity = robust_scm2double (state.slur_->get_property ("excentricity"), 0);
-
+
Real x1 = (excentricity + indent);
Real x2 = (excentricity - indent);
-
+
Bezier curve;
curve.control_[0] = attachment_[LEFT];
curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_
curve.control_[3] = attachment_[RIGHT];
Real ff = fit_factor (dz_unit, dz_perp, curve, state.dir_, avoid);
-
+
height = height >? ((height * ff) <? max_h);
curve.control_[0] = attachment_[LEFT];
height_ = height;
}
-Slur_configuration::Slur_configuration()
+Slur_configuration::Slur_configuration ()
{
score_ = 0.0;
- index_ = -1;
+ index_ = -1;
};
-
-
void
Slur_configuration::score_encompass (Slur_score_state const &state)
{
Real x = state.encompass_infos_[j].x_;
bool l_edge = j == 0;
- bool r_edge = j == state.encompass_infos_.size ()-1;
- bool edge = l_edge || r_edge;
+ bool r_edge = j == state.encompass_infos_.size () - 1;
+ bool edge = l_edge || r_edge;
if (! (x < attachment_[RIGHT][X_AXIS]
&& x > attachment_[LEFT][X_AXIS]))
continue;
-
+
Real y = bez.get_other_coordinate (X_AXIS, x);
if (!edge)
{
attachment_[RIGHT][Y_AXIS],
attachment_[LEFT][Y_AXIS]);
- if ( 1 ) // state.dir_ * state.encompass_infos_[j].get_point (state.dir_) > state.dir_ *line_y )
+ if (1) // state.dir_ * state.encompass_infos_[j].get_point (state.dir_) > state.dir_ *line_y )
{
-
- Real closest =
- state.dir_ * (state.dir_ * state.encompass_infos_[j].get_point (state.dir_)
- >? state.dir_ *line_y
- );
+
+ Real closest
+ = state.dir_ * (state.dir_ * state.encompass_infos_[j].get_point (state.dir_)
+ >? state.dir_ *line_y);
Real d = fabs (closest - y);
-
+
convex_head_distances.push (d);
}
}
-
-
if (state.dir_ * (y - state.encompass_infos_[j].stem_) < 0)
{
- Real stem_dem = state.parameters_.stem_encompass_penalty_ ;
+ Real stem_dem = state.parameters_.stem_encompass_penalty_;
if ((l_edge && state.dir_ == UP)
|| (r_edge && state.dir_ == DOWN))
stem_dem /= 5;
- demerit += stem_dem;
+ demerit += stem_dem;
}
else if (!edge)
{
For slurs over 3 or 4 heads, the average distance is not a
good normalizer.
*/
- Real n = convex_head_distances.size ();
+ Real n = convex_head_distances.size ();
if (n <= 2)
{
Real fact = 1.0;
avg_distance /= n;
variance_penalty = state.parameters_.head_slur_distance_max_ratio_;
if (min_dist > 0.0)
- variance_penalty =
- (avg_distance / (min_dist + state.parameters_.absolute_closeness_measure_ ) - 1.0)
+ variance_penalty
+ = (avg_distance / (min_dist + state.parameters_.absolute_closeness_measure_) - 1.0)
<? variance_penalty;
variance_penalty = variance_penalty >? 0.0;
Direction d = LEFT;
bool found = false;
Real y = 0.0;
-
+
do
{
/*
We need to check for the bound explicitly, since the
slur-ending can be almost vertical, making the Y
coordinate a bad approximation of the object-slur
- distance.
+ distance.
*/
- Item * as_item = dynamic_cast<Item*> (state.extra_encompass_infos_[j].grob_);
+ Item *as_item = dynamic_cast<Item *> (state.extra_encompass_infos_[j].grob_);
if ((as_item
&& as_item->get_column ()
== state.extremes_[d] .bound_->get_column ())
if (!slur_wid.contains (x))
continue;
-
+
y = curve_.get_other_coordinate (X_AXIS, x);
}
Real dist = state.extra_encompass_infos_[j].extents_[Y_AXIS].distance (y);
- demerit +=
- fabs (0 >? (state.parameters_.extra_encompass_free_distance_ - dist)) /
- state.parameters_.extra_encompass_free_distance_
+ demerit
+ += fabs (0 >? (state.parameters_.extra_encompass_free_distance_ - dist))
+ / state.parameters_.extra_encompass_free_distance_
* state.extra_encompass_infos_[j].penalty_;
}
#if DEBUG_SLUR_SCORING
{
Real y = attachment_[d][Y_AXIS];
Real dy = fabs (y - state.base_attachments_[d][Y_AXIS]);
-
+
Real factor = state.parameters_.edge_attraction_factor_;
Real demerit = factor * dy;
if (state.extremes_[d].stem_
&& state.extremes_[d].stem_dir_ == state.dir_
- && !Stem::get_beaming (state.extremes_[d].stem_, -d)
- )
+ && !Stem::get_beaming (state.extremes_[d].stem_, -d))
demerit /= 5;
demerit *= exp (state.dir_ * d * slope
- * state.parameters_.edge_slope_exponent_ );
-
+ * state.parameters_.edge_slope_exponent_);
+
score_ += demerit;
#if DEBUG_SLUR_SCORING
score_card_ += to_string ("E%.2f", demerit);
demerit += state.parameters_.steeper_slope_factor_
* ((fabs (slur_dy) -max_dy) >? 0);
- demerit += ((fabs (slur_dy/slur_dz[X_AXIS])
+ demerit += ((fabs (slur_dy / slur_dz[X_AXIS])
- state.parameters_.max_slope_) >? 0)
* state.parameters_.max_slope_factor_;
score_ += demerit;
}
-
void
Slur_configuration::score (Slur_score_state const &state)
{
score_extra_encompass (state);
- score_slopes (state);
+ score_slopes (state);
score_edges (state);
score_encompass (state);
}
class Slur_engraver : public Engraver
{
Drul_array<Music *> events_;
- Music * running_slur_start_;
+ Music *running_slur_start_;
Link_array<Grob> slurs_;
Link_array<Grob> end_slurs_;
void set_melisma (bool);
protected:
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void acknowledge_grob (Grob_info);
virtual void stop_translation_timestep ();
virtual void finalize ();
Grob *e = info.grob_;
if (Note_column::has_interface (info.grob_))
{
- for (int i = slurs_.size (); i--; )
+ for (int i = slurs_.size (); i--;)
Slur::add_column (slurs_[i], e);
- for (int i = end_slurs_.size (); i-- ; )
+ for (int i = end_slurs_.size (); i--;)
Slur::add_column (end_slurs_[i], e);
}
else
if (Tie::has_interface (e)
|| to_boolean (inside))
{
- for (int i = slurs_.size (); i--; )
+ for (int i = slurs_.size (); i--;)
Slur::add_extra_encompass (slurs_[i], e);
- for (int i = end_slurs_.size (); i--; )
+ for (int i = end_slurs_.size (); i--;)
Slur::add_extra_encompass (end_slurs_[i], e);
}
else if (inside == SCM_BOOL_F)
{
- Grob *slur = slurs_.size()?slurs_[0] : 0;
- slur = (end_slurs_.size () && !slur)
+ Grob *slur = slurs_.size ()?slurs_[0] : 0;
+ slur = (end_slurs_.size () && !slur)
? end_slurs_[0] : slur;
if (slur)
{
e->add_offset_callback (Slur::outside_slur_callback_proc, Y_AXIS);
- e->set_property ("slur", slur->self_scm());
+ e->set_property ("slur", slur->self_scm ());
}
}
}
Slur_engraver::finalize ()
{
if (slurs_.size ())
- slurs_[0]->warning (_("unterminated slur"));
+ slurs_[0]->warning (_ ("unterminated slur"));
}
void
{
if (events_[STOP])
{
- if (slurs_.size() == 0)
+ if (slurs_.size () == 0)
{
- events_[STOP]->origin()->warning (_ ("No slur to end"));
+ events_[STOP]->origin ()->warning (_ ("No slur to end"));
}
-
+
end_slurs_ = slurs_;
slurs_.clear ();
}
-
+
if (events_[START] && slurs_.is_empty ())
{
Music *ev = events_[START];
bool double_slurs = to_boolean (get_property ("doubleSlurs"));
- Grob * slur = make_spanner ("Slur", events_[START]->self_scm ());
+ Grob *slur = make_spanner ("Slur", events_[START]->self_scm ());
Direction updown = to_dir (ev->get_property ("direction"));
if (updown && !double_slurs)
set_grob_direction (slur, updown);
set_grob_direction (slur, DOWN);
slur = make_spanner ("Slur", events_[START]->self_scm ());
set_grob_direction (slur, UP);
- slurs_.push (slur);
+ slurs_.push (slur);
}
}
set_melisma (slurs_.size ());
}
ADD_TRANSLATOR (Slur_engraver,
- /* descr */ "Build slurs grobs from slur events",
- /* creats*/ "Slur",
- /* accepts */ "slur-event",
- /* acks */ "note-column-interface accidental-interface fingering-interface script-interface tie-interface text-script-interface",
- /* reads */ "slurMelismaBusy doubleSlurs",
- /* write */ "");
+ /* descr */ "Build slurs grobs from slur events",
+ /* creats*/ "Slur",
+ /* accepts */ "slur-event",
+ /* acks */ "note-column-interface accidental-interface fingering-interface script-interface tie-interface text-script-interface",
+ /* reads */ "slurMelismaBusy doubleSlurs",
+ /* write */ "");
source file of the GNU LilyPond music typesetter
(c) 1996--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#include "performer.hh"
#include "audio-item.hh"
/*
this is C&P from beam_performer.
- */
+*/
-class Slur_performer : public Performer {
+class Slur_performer : public Performer
+{
public:
TRANSLATOR_DECLARATIONS (Slur_performer);
-
+
protected:
- virtual bool try_music (Music *ev) ;
+ virtual bool try_music (Music *ev);
virtual void start_translation_timestep ();
virtual void process_music ();
void set_melisma (bool);
now_stop_ev_ = 0;
}
-
-void
+void
Slur_performer::process_music ()
{
if (now_stop_ev_)
}
}
-
void
Slur_performer::set_melisma (bool ml)
{
start_ev_ = 0;
now_stop_ev_ = 0;
}
-
+
bool
Slur_performer::try_music (Music *m)
{
}
ADD_TRANSLATOR (Slur_performer, "", "",
- "slur-event", "", "", "");
+ "slur-event", "", "", "");
Jan Nieuwenhuizen <janneke@gnu.org>
*/
-
#include <math.h>
#include "slur-scoring.hh"
- calculate encompass scoring directly after determining slur shape.
- optimize.
-
*/
struct Slur_score_state;
-Slur_score_state::Slur_score_state()
+Slur_score_state::Slur_score_state ()
{
musical_dy_ = 0.0;
valid_ = false;
/* A broken slur should maintain the same vertical trend
the unbroken slur would have had. */
Real by = 0.0;
- if (Spanner *mother = dynamic_cast<Spanner*> (state.slur_->original_))
+ if (Spanner *mother = dynamic_cast<Spanner *> (state.slur_->original_))
{
int k = broken_spanner_index (state.slur_);
int j = k + hdir;
Grob *neighbor = mother->broken_intos_[j];
Spanner *common_mother
- = dynamic_cast<Spanner*> (state.common_[Y_AXIS]->original_);
+ = dynamic_cast<Spanner *> (state.common_[Y_AXIS]->original_);
int common_k
- = broken_spanner_index (dynamic_cast<Spanner*> (state.common_[Y_AXIS]));
+ = broken_spanner_index (dynamic_cast<Spanner *> (state.common_[Y_AXIS]));
int common_j = common_k + hdir;
if (common_j < 0 || common_j >= common_mother->broken_intos_.size ())
return by;
Grob *common_next_system = common_mother->broken_intos_[common_j];
-
- SCM last_point = scm_car (scm_last_pair (neighbor->get_property ("control-points")));
-
+
+ SCM last_point = scm_car (scm_last_pair (neighbor->get_property ("control-points")));
+
return scm_to_double (scm_cdr (last_point))
+ neighbor->relative_coordinate (common_next_system, Y_AXIS);
}
return by;
}
-
/*
copy slur dir forwards across line break.
*/
void
-Slur_score_state::set_next_direction ()
+Slur_score_state::set_next_direction ()
{
if (extremes_[RIGHT].note_column_)
return;
-
- if (Spanner *mother = dynamic_cast<Spanner*> (slur_->original_))
+
+ if (Spanner *mother = dynamic_cast<Spanner *> (slur_->original_))
{
int k = broken_spanner_index (slur_);
int j = k + 1;
}
-
-
Drul_array<Bound_info>
Slur_score_state::get_bound_info () const
{
void
Slur_score_state::fill (Grob *me)
{
- slur_ = dynamic_cast<Spanner*> (me);
- columns_
+ slur_ = dynamic_cast<Spanner *> (me);
+ columns_
= extract_grob_array (me, ly_symbol2scm ("note-columns"));
-
+
if (columns_.is_empty ())
{
me->suicide ();
- return ;
+ return;
}
staff_space_ = Staff_symbol_referencer::staff_space (me);
Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
- thickness_ = robust_scm2double (me->get_property ("thickness"), 1.0) * lt;
-
+ thickness_ = robust_scm2double (me->get_property ("thickness"), 1.0) * lt;
+
dir_ = get_grob_direction (me);
parameters_.fill (me);
-
+
SCM eltlist = me->get_property ("note-columns");
SCM extra_list = me->get_property ("encompass-objects");
- Spanner *sp = dynamic_cast<Spanner*> (me);
+ Spanner *sp = dynamic_cast<Spanner *> (me);
for (int i = X_AXIS; i < NO_AXES; i++)
{
common_[a] = common_refpoint_of_list (extra_list, common_[a], a);
Direction d = LEFT;
- do {
- /*
- If bound is not in note-columns, we don't want to know about
- its Y-position
- */
- if (a != Y_AXIS)
- common_[a] = common_[a]->common_refpoint (sp->get_bound (d), a);
- }
+ do
+ {
+ /*
+ If bound is not in note-columns, we don't want to know about
+ its Y-position
+ */
+ if (a != Y_AXIS)
+ common_[a] = common_[a]->common_refpoint (sp->get_bound (d), a);
+ }
while (flip (&d) != LEFT);
}
extremes_ = get_bound_info ();
is_broken_ = (!extremes_[LEFT].note_column_
- || !extremes_[RIGHT].note_column_);
+ || !extremes_[RIGHT].note_column_);
+
+ has_same_beam_
+ = (extremes_[LEFT].stem_ && extremes_[RIGHT].stem_
+ && Stem::get_beam (extremes_[LEFT].stem_) == Stem::get_beam (extremes_[RIGHT].stem_));
- has_same_beam_ =
- (extremes_[LEFT].stem_ && extremes_[RIGHT].stem_
- && Stem::get_beam (extremes_[LEFT].stem_) == Stem::get_beam (extremes_[RIGHT].stem_));
-
base_attachments_ = get_base_attachments ();
Drul_array<Real> end_ys
= get_y_attachment_range ();
- configurations_ = enumerate_attachments ( end_ys);
+ configurations_ = enumerate_attachments (end_ys);
for (int i = 0; i < columns_.size (); i++)
- encompass_infos_.push (get_encompass_info ( columns_[i]));
+ encompass_infos_.push (get_encompass_info (columns_[i]));
extra_encompass_infos_ = get_extra_encompass_infos ();
valid_ = true;
-
musical_dy_ = 0.0;
Direction d = LEFT;
do
* extremes_[d].slur_head_->relative_coordinate (common_[Y_AXIS], Y_AXIS);
}
while (flip (&d) != LEFT);
-
+
edge_has_beams_
= (extremes_[LEFT].stem_ && Stem::get_beam (extremes_[LEFT].stem_))
|| (extremes_[RIGHT].stem_ && Stem::get_beam (extremes_[RIGHT].stem_));
-
-
set_next_direction ();
if (is_broken_)
if (!state.valid_)
return;
-
+
state.generate_curves ();
SCM end_ys = me->get_property ("positions");
}
else
{
- best = state.get_best_curve();
+ best = state.get_best_curve ();
}
SCM controls = SCM_EOL;
{
Offset o = best.control_[i]
- Offset (me->relative_coordinate (state.common_[X_AXIS], X_AXIS),
- me->relative_coordinate (state.common_[Y_AXIS], Y_AXIS));
+ me->relative_coordinate (state.common_[Y_AXIS], Y_AXIS));
controls = scm_cons (ly_offset2scm (o), controls);
}
me->set_property ("control-points", controls);
}
-
Bezier
Slur_score_state::get_best_curve ()
{
{
configurations_[i]->score (*this);
}
-
+
Real opt = 1e6;
int opt_idx = -1;
for (int i = 0; i < configurations_.size (); i++)
&& scm_is_pair (inspect_quants))
opt_idx = get_closest_index (inspect_quants);
- configurations_[opt_idx]->score_card_ += to_string ("=%.2f", opt);
+ configurations_[opt_idx]->score_card_ += to_string ("=%.2f", opt);
configurations_[opt_idx]->score_card_ += to_string ("i%d", opt_idx);
// debug quanting
int opt_idx = -1;
Real mindist = 1e6;
- for (int i = 0; i < configurations_.size (); i ++)
+ for (int i = 0; i < configurations_.size (); i++)
{
Real d = fabs (configurations_[i]->attachment_[LEFT][Y_AXIS] - ins[LEFT])
+ fabs (configurations_[i]->attachment_[RIGHT][Y_AXIS] - ins[RIGHT]);
/*
TODO: should analyse encompasses to determine sensible region, and
should limit slopes available.
- */
+*/
Drul_array<Real>
Slur_score_state::get_y_attachment_range () const
if (extremes_[d].note_column_)
{
end_ys[d] = dir_
- * ((dir_ * (base_attachments_[d][Y_AXIS] + parameters_.region_size_* dir_))
+ * ((dir_ * (base_attachments_[d][Y_AXIS] + parameters_.region_size_* dir_))
>? (dir_ * (dir_ + extremes_[d].note_column_->extent (common_[Y_AXIS],
- Y_AXIS)[dir_]))
+ Y_AXIS)[dir_]))
>? (dir_ * base_attachments_[-d][Y_AXIS]));
}
else
}
bool
-spanner_less (Spanner *s1, Spanner* s2)
+spanner_less (Spanner *s1, Spanner *s2)
{
Slice b1, b2;
- Direction d = LEFT;
+ Direction d = LEFT;
do
{
b1[d] = s1->get_bound (d)->get_column ()->rank_;
b2[d] = s2->get_bound (d)->get_column ()->rank_;
- } while (flip (&d) != LEFT);
+ }
+ while (flip (&d) != LEFT);
return b2[LEFT] <= b1[LEFT] && b2[RIGHT] >= b1[RIGHT]
&& (b2[LEFT] != b1[LEFT] || b2[RIGHT] != b1[RIGHT]);
}
-
Drul_array<Offset>
Slur_score_state::get_base_attachments () const
{
Real y = 0.0;
if (extremes_[d].note_column_)
{
-
+
/*
fixme: X coord should also be set in this case.
- */
+ */
if (stem
&& extremes_[d].stem_dir_ == dir_
&& Stem::get_beaming (stem, -d)
y = head->extent (common_[Y_AXIS], Y_AXIS)[dir_];
y += dir_ * 0.5 * staff_space_;
+ y = move_away_from_staffline (y, head);
- y = move_away_from_staffline (y, head);
-
- Grob * fh = Note_column::first_head (extremes_[d].note_column_);
- x =
- (fh ? fh->extent (common_[X_AXIS], X_AXIS)
- : extremes_[d].bound_->extent (common_[X_AXIS], X_AXIS))
+ Grob *fh = Note_column::first_head (extremes_[d].note_column_);
+ x
+ = (fh ? fh->extent (common_[X_AXIS], X_AXIS)
+ : extremes_[d].bound_->extent (common_[X_AXIS], X_AXIS))
.linear_combination (CENTER);
}
base_attachment[d] = Offset (x, y);
- } while (flip (&d) != LEFT);
+ }
+ while (flip (&d) != LEFT);
do
{
{
x = slur_->get_broken_left_end_align ();
}
- Grob * col = (d == LEFT) ? columns_[0] : columns_.top();
-
+ Grob *col = (d == LEFT) ? columns_[0] : columns_.top ();
+
if (extremes_[-d].bound_ != col)
{
y = robust_relative_extent (col, common_[Y_AXIS], Y_AXIS)[dir_];
y += dir_ * 0.5 * staff_space_;
-
+
if (get_grob_direction (col) == dir_
&& Note_column::get_stem (col)
&& !Stem::is_invisible (Note_column::get_stem (col)))
else
y = base_attachment[-d][Y_AXIS];
-
y = move_away_from_staffline (y, col);
-
- base_attachment[d] = Offset (x, y);
+
+ base_attachment[d] = Offset (x, y);
}
}
while (flip (&d) != LEFT);
{
Real pos
= (y - Staff_symbol_referencer::get_staff_symbol (on_staff)->relative_coordinate (common_[Y_AXIS],
- Y_AXIS))
+ Y_AXIS))
* 2.0 / staff_space_;
-
+
if (fabs (pos - my_round (pos)) < 0.2
&& Staff_symbol_referencer::on_staffline (on_staff, (int) rint (pos))
- && Staff_symbol_referencer::line_count (on_staff) - 1 >= rint (pos)
- )
+ && Staff_symbol_referencer::line_count (on_staff) - 1 >= rint (pos))
y += 1.5 * staff_space_ * dir_ / 10;
return y;
}
-
-
-Link_array<Slur_configuration>
+Link_array<Slur_configuration>
Slur_score_state::enumerate_attachments (Drul_array<Real> end_ys) const
{
/*ugh. */
Link_array<Slur_configuration> scores;
-
Drul_array<Offset> os;
os[LEFT] = base_attachments_[LEFT];
Real minimum_length = staff_space_
}
else if (dir_ * extremes_[d].stem_extent_[Y_AXIS][dir_]
< dir_ * os[d][Y_AXIS]
- && !extremes_[d].stem_extent_[X_AXIS].is_empty ()
- )
-
+ && !extremes_[d].stem_extent_[X_AXIS].is_empty ())
+
os[d][X_AXIS] = extremes_[d].stem_extent_[X_AXIS].center ();
}
}
while (flip (&d) != LEFT);
- Offset dz;
+ Offset dz;
dz = os[RIGHT] - os[LEFT];
if (dz[X_AXIS] < minimum_length
- || fabs (dz[Y_AXIS] / dz[X_AXIS]) > parameters_.max_slope_
- )
+ || fabs (dz[Y_AXIS] / dz[X_AXIS]) > parameters_.max_slope_)
{
do
{
{
/* Horizontally move tilted slurs a little. Move
more for bigger tilts.
-
+
TODO: parameter */
os[d][X_AXIS]
-= dir_ * extremes_[d].slur_head_extent_.length ()
}
}
while (flip (&d) != LEFT);
-
+
s.attachment_ = os;
s.index_ = scores.size ();
scores.push (new Slur_configuration (s));
-
+
os[RIGHT][Y_AXIS] += dir_ * staff_space_ / 2;
}
return scores;
}
-
Array<Extra_collision_info>
Slur_score_state::get_extra_encompass_infos () const
{
Link_array<Grob> encompasses
= extract_grob_array (slur_, ly_symbol2scm ("encompass-objects"));
Array<Extra_collision_info> collision_infos;
- for (int i = encompasses.size (); i--; )
+ for (int i = encompasses.size (); i--;)
{
if (Slur::has_interface (encompasses[i]))
{
- Spanner * small_slur = dynamic_cast<Spanner*> (encompasses[i]);
+ Spanner *small_slur = dynamic_cast<Spanner *> (encompasses[i]);
Bezier b = Slur::get_curve (small_slur);
Offset relative (small_slur->relative_coordinate (common_[X_AXIS], X_AXIS),
for (int k = 0; k < 3; k++)
{
- Direction hdir = Direction (k /2 - 1);
+ Direction hdir = Direction (k /2 - 1);
/*
Only take bound into account if small slur starts
*/
if (hdir && small_slur->get_bound (hdir) != slur_->get_bound (hdir))
continue;
-
+
Offset z = b.curve_point (k / 2.0);
z += relative;
SCM cstyle = g->get_property ("cautionary-style");
parens = ly_c_equal_p (cstyle, ly_symbol2scm ("parentheses"));
}
-
+
SCM accs = g->get_property ("accidentals");
SCM scm_style = g->get_property ("style");
if (!scm_is_symbol (scm_style)
case FLAT:
case DOUBLE_FLAT:
xp = LEFT;
- break ;
+ break;
case SHARP:
xp = 0.5 * dir_;
- break ;
+ break;
case NATURAL:
xp = -dir_;
break;
ye.widen (thickness_ * 0.5);
xe.widen (thickness_ * 1.0);
- Extra_collision_info info (g, xp, xe, ye, penalty);
+ Extra_collision_info info (g, xp, xe, ye, penalty);
collision_infos.push (info);
}
}
/*
TODO: replace dashed with generic property.
*/
- SCM p = me->get_property ("dash-period");
- SCM f = me->get_property ("dash-fraction");
+ SCM p = me->get_property ("dash-period");
+ SCM f = me->get_property ("dash-fraction");
if (scm_is_number (p) && scm_is_number (f))
- a = Lookup::dashed_slur (one, thick, robust_scm2double (p, 1.0),
- robust_scm2double(f,0));
+ a = Lookup::dashed_slur (one, thick, robust_scm2double (p, 1.0),
+ robust_scm2double (f, 0));
else
a = Lookup::slur (one, get_grob_direction (me) * base_thick * ss / 10.0,
thick);
return a.smobbed_copy ();
}
-
Bezier
-Slur::get_curve (Grob*me)
+Slur::get_curve (Grob *me)
{
Bezier b;
int i = 0;
}
void
-Slur::add_column (Grob*me, Grob*n)
+Slur::add_column (Grob *me, Grob *n)
{
Pointer_group_interface::add_grob (me, ly_symbol2scm ("note-columns"), n);
- add_bound_item (dynamic_cast<Spanner*> (me), dynamic_cast<Item*> (n));
+ add_bound_item (dynamic_cast<Spanner *> (me), dynamic_cast<Item *> (n));
}
-
void
-Slur::add_extra_encompass (Grob*me, Grob*n)
+Slur::add_extra_encompass (Grob *me, Grob *n)
{
Pointer_group_interface::add_grob (me, ly_symbol2scm ("encompass-objects"), n);
}
-
-
MAKE_SCHEME_CALLBACK (Slur, outside_slur_callback, 2);
SCM
Slur::outside_slur_callback (SCM grob, SCM axis)
if (!slur)
return scm_from_int (0);
-
+
Grob *cx = script->common_refpoint (slur, X_AXIS);
Grob *cy = script->common_refpoint (slur, Y_AXIS);
Interval yext = robust_relative_extent (script, cy, Y_AXIS);
Interval xext = robust_relative_extent (script, cx, X_AXIS);
-
Real slur_padding = robust_scm2double (script->get_property ("slur-padding"),
0.0); // todo: slur property, script property?
yext.widen (slur_padding);
Real EPS = 1e-3;
-
+
Interval bezext (curve.control_[0][X_AXIS],
curve.control_[3][X_AXIS]);
if (consider[k])
{
ys[k]
- = (fabs(bezext[LEFT] - x) < EPS)
+ = (fabs (bezext[LEFT] - x) < EPS)
? curve.control_[0][Y_AXIS]
- : ((fabs(bezext[RIGHT] - x) < EPS)
+ : ((fabs (bezext[RIGHT] - x) < EPS)
? curve.control_[3][Y_AXIS]
: curve.get_other_coordinate (X_AXIS, x));
consider[k] = true;
-
+
if (yext.contains (ys[k]))
do_shift = true;
}
k++;
}
}
-
+
return scm_make_real (offset);
}
static Direction
-get_default_dir (Grob*me)
+get_default_dir (Grob *me)
{
Link_array<Grob> encompasses
= extract_grob_array (me, ly_symbol2scm ("note-columns"));
Direction d = DOWN;
- for (int i = 0; i < encompasses.size (); i ++)
+ for (int i = 0; i < encompasses.size (); i++)
{
if (Note_column::dir (encompasses[i]) < 0)
{
return d;
}
-
MAKE_SCHEME_CALLBACK (Slur, after_line_breaking, 1);
SCM
Slur::after_line_breaking (SCM smob)
{
- Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (smob));
+ Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
if (!scm_ilength (me->get_property ("note-columns")))
{
me->suicide ();
"A slur",
"positions quant-score excentricity encompass-objects control-points dash-period dash-fraction slur-details direction height-limit note-columns ratio thickness");
-
#include <sstream>
#else
#include <strstream>
-#define istringstream(x) istrstream(x, length ())
+#define istringstream(x) istrstream (x, length ())
#endif
#include "warn.hh"
contents_str0_ = chs.remove_array ();
}
-char*
+char *
gulp_file (String filename, int *filesize)
{
/* "b" must ensure to open literally, avoiding text (CR/LF)
{
name_ = filename;
istream_ = 0;
- contents_str0_ = data.get_copy_str0();
+ contents_str0_ = data.get_copy_str0 ();
length_ = data.length ();
pos_str0_ = to_str0 ();
init_port ();
load_stdin ();
else
contents_str0_ = gulp_file (filename_string, &length_);
-
+
pos_str0_ = to_str0 ();
init_port ();
}
Slice
-Source_file::line_slice (char const* pos_str0) const
+Source_file::line_slice (char const *pos_str0) const
{
if (!contains (pos_str0))
return Slice (0, 0);
- char const* data_str0 = to_str0 ();
- char const * eof_C_ = data_str0 + length ();
+ char const *data_str0 = to_str0 ();
+ char const *eof_C_ = data_str0 + length ();
if (pos_str0 == eof_C_)
- pos_str0 --;
- char const* begin_str0 = pos_str0;
+ pos_str0--;
+ char const *begin_str0 = pos_str0;
while (begin_str0 > data_str0)
if (*--begin_str0 == '\n')
{
return "";
Slice line = line_slice (pos_str0);
- char const* data_str0 = to_str0 ();
- return String ((Byte const*)data_str0 + line[LEFT], line.length ());
+ char const *data_str0 = to_str0 ();
+ return String ((Byte const *)data_str0 + line[LEFT], line.length ());
}
int
-Source_file::get_char (char const* pos_str0) const
+Source_file::get_char (char const *pos_str0) const
{
if (!contains (pos_str0))
return 0;
- char const* data_str0 = to_str0 ();
+ char const *data_str0 = to_str0 ();
return pos_str0 - (line_slice (pos_str0)[SMALLER] + data_str0);
}
int
-Source_file::get_column (char const* pos_str0) const
+Source_file::get_column (char const *pos_str0) const
{
if (!contains (pos_str0))
return 0;
error (error_string (pos_str0) + "invalid pos");
}
-char const*
+char const *
Source_file::seek_str0 (int n)
{
- char const* new_str0 = to_str0 () + n;
+ char const *new_str0 = to_str0 () + n;
if (n < 0)
new_str0 += length ();
if (contains (new_str0))
return pos_str0_;
}
-char const*
+char const *
Source_file::forward_str0 (int n)
{
- char const* old_pos = pos_str0_;
- char const* new_str0 = pos_str0_ + n;
+ char const *old_pos = pos_str0_;
+ char const *new_str0 = pos_str0_ + n;
if (contains (new_str0))
pos_str0_ = new_str0;
else
- error (error_string (new_str0) + "forward past eof");
+ error (error_string (new_str0) + "forward past eof");
return old_pos;
}
String
Source_file::get_string (int n)
{
- String str = String ((Byte const*)forward_str0 (n), n);
+ String str = String ((Byte const *)forward_str0 (n), n);
return str;
}
}
/**
- open a file
+ open a file
- @param file_string the file to be opened, name might be changed if it
- is found in a search path. UGH!
+ @param file_string the file to be opened, name might be changed if it
+ is found in a search path. UGH!
- @return 0 if no file found
- */
-Source_file*
+ @return 0 if no file found
+*/
+Source_file *
Sources::get_file (String &file_string) //UGH
{
if ((file_string != "-") && path_)
{
- String file_string_o = path_->find (file_string);
+ String file_string_o = path_->find (file_string);
if ((file_string_o == "") && (file_string != ""))
return 0;
file_string = file_string_o;
}
- Source_file * f = new Source_file (file_string) ;
+ Source_file *f = new Source_file (file_string);
add (f);
return f;
}
void
-Sources::add (Source_file* sourcefile)
+Sources::add (Source_file *sourcefile)
{
sourcefile_list_ = new Killing_cons<Source_file> (sourcefile, sourcefile_list_);
}
delete sourcefile_list_;
}
/**
- search the list for file whose map contains pointer #str0#
+ search the list for file whose map contains pointer #str0#
- @return 0 if not found.
- */
-Source_file*
-Sources::get_sourcefile (char const* str0)
+ @return 0 if not found.
+*/
+Source_file *
+Sources::get_sourcefile (char const *str0)
{
for (Cons<Source_file> *i = sourcefile_list_; i; i = i->next_)
- if (i->car_->contains (str0))
+ if (i->car_->contains (str0))
return i->car_;
return 0;
}
-/*
+/*
spaceable-grob.cc -- implement Spaceable_grob
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "spaceable-grob.hh"
-#include <cstdio>
+#include <cstdio>
#include <math.h>
#include "warn.hh"
#include "group-interface.hh"
SCM
-Spaceable_grob::get_minimum_distances (Grob*me)
+Spaceable_grob::get_minimum_distances (Grob *me)
{
return me->get_property ("minimum-distances");
}
/*todo: merge code of spring & rod?
*/
void
-Spaceable_grob::add_rod (Grob *me , Grob * p, Real d)
+Spaceable_grob::add_rod (Grob *me, Grob *p, Real d)
{
// printf ("rod %lf\n", d);
-
+
SCM mins = get_minimum_distances (me);
SCM newdist = scm_make_real (d);
for (SCM s = mins; scm_is_pair (s); s = scm_cdr (s))
if (scm_car (dist) == p->self_scm ())
{
scm_set_cdr_x (dist, scm_max (scm_cdr (dist),
- newdist));
- return ;
+ newdist));
+ return;
}
}
}
void
-Spaceable_grob::add_spring (Grob*me, Grob * p, Real d, Real strength)
+Spaceable_grob::add_spring (Grob *me, Grob *p, Real d, Real strength)
{
// printf ("dist %lf, str %lf\n", d, strength);
if (d <= 0.0 || strength <= 0.0)
d = 1.0;
strength = 1.0;
}
-
- if (isinf (d) || isnan(d)
+
+ if (isinf (d) || isnan (d)
|| isnan (strength))
{
/*
strength == INF is possible. It means fixed distance.
- */
+ */
programming_error ("Insane distance found.");
d = 1.0;
strength = 1.0;
}
-
+
#ifndef NDEBUG
SCM mins = me->get_property ("ideal-distances");
for (SCM s = mins; scm_is_pair (s); s = scm_cdr (s))
{
- Spring_smob * sp = unsmob_spring(scm_car (s));
+ Spring_smob *sp = unsmob_spring (scm_car (s));
if (sp->other_ == p)
{
programming_error ("already have that spring");
- return ;
+ return;
}
}
#endif
-
+
Spring_smob spring;
spring.strength_ = strength;
spring.distance_ = d;
spring.other_ = p;
-
+
Group_interface::add_thing (me, ly_symbol2scm ("ideal-distances"), spring.smobbed_copy ());
}
-
void
-Spaceable_grob::remove_interface (Grob*me)
+Spaceable_grob::remove_interface (Grob *me)
{
- me->set_property ("minimum-distances" , SCM_EOL);
+ me->set_property ("minimum-distances", SCM_EOL);
me->set_property ("spacing-wishes", SCM_EOL);
me->set_property ("ideal-distances", SCM_EOL);
}
-
-
ADD_INTERFACE (Spaceable_grob, "spaceable-grob-interface",
- "A layout object that takes part in the spacing problem. "
- ,
+ "A layout object that takes part in the spacing problem. ",
"measure-length spacing-wishes penalty minimum-distances ideal-distances "
"allow-outside-line left-neighbors right-neighbors");
-/*
+/*
spacing-engraver.cc -- implement Spacing_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "paper-column.hh"
#include "engraver.hh"
{
Grob_info info_;
Moment end_;
-
+
Rhythmic_tuple ()
- {
- }
+ {
+ }
Rhythmic_tuple (Grob_info i, Moment m)
- {
- info_ = i;
- end_ = m;
- }
- static int time_compare (Rhythmic_tuple const &, Rhythmic_tuple const &);
+ {
+ info_ = i;
+ end_ = m;
+ }
+ static int time_compare (Rhythmic_tuple const &, Rhythmic_tuple const &);
};
/**
Array<Rhythmic_tuple> now_durations_;
Array<Rhythmic_tuple> stopped_durations_;
Moment now_;
- Spanner * spacing_;
-
+ Spanner *spacing_;
+
TRANSLATOR_DECLARATIONS (Spacing_engraver);
protected:
virtual void acknowledge_grob (Grob_info);
if (!spacing_)
{
spacing_ = make_spanner ("SpacingSpanner", SCM_EOL);
- spacing_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
-
+ spacing_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
+
}
}
{
if (spacing_)
{
- Grob * p = unsmob_grob (get_property ("currentCommandColumn"));
-
+ Grob *p = unsmob_grob (get_property ("currentCommandColumn"));
+
spacing_->set_bound (RIGHT, p);
spacing_ = 0;
}
{
if (Note_spacing::has_interface (i.grob_) || Staff_spacing::has_interface (i.grob_))
{
- Pointer_group_interface::add_grob (spacing_, ly_symbol2scm ("wishes"), i.grob_);
+ Pointer_group_interface::add_grob (spacing_, ly_symbol2scm ("wishes"), i.grob_);
}
-
+
if (i.grob_->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface"))
|| i.grob_->internal_has_interface (ly_symbol2scm ("multi-measure-event")))
return;
/*
- only pay attention to durations that are not grace notes.
- */
+ only pay attention to durations that are not grace notes.
+ */
if (!now_.grace_part_)
{
Music *r = i.music_cause ();
shortest_playing.set_infinite (1);
for (int i = 0; i < playing_durations_.size (); i++)
{
- Music * mus = playing_durations_[i].info_.music_cause ();
+ Music *mus = playing_durations_[i].info_.music_cause ();
if (mus)
{
Moment m = mus->get_length ();
}
}
now_durations_.clear ();
-
+
shortest_playing = shortest_playing <? starter;
-
- Paper_column * sc
- = dynamic_cast<Paper_column*> (unsmob_grob (get_property ("currentMusicalColumn")));
+
+ Paper_column *sc
+ = dynamic_cast<Paper_column *> (unsmob_grob (get_property ("currentMusicalColumn")));
assert (starter.to_bool ());
SCM sh = shortest_playing.smobbed_copy ();
SCM st = starter.smobbed_copy ();
- sc->set_property ("shortest-playing-duration", sh);
+ sc->set_property ("shortest-playing-duration", sh);
sc->set_property ("shortest-starter-duration", st);
}
}
-
-
ADD_TRANSLATOR (Spacing_engraver,
-/* descr */ "make a SpacingSpanner and do bookkeeping of shortest starting and playing notes ",
-/* creats*/ "SpacingSpanner",
-/* accepts */ "",
-/* acks */ "grob-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "make a SpacingSpanner and do bookkeeping of shortest starting and playing notes ",
+ /* creats*/ "SpacingSpanner",
+ /* accepts */ "",
+ /* acks */ "grob-interface",
+ /* reads */ "",
+ /* write */ "");
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "system.hh"
#include "column-x-positions.hh"
#include "staff-spacing.hh"
-
/* Find the loose columns in POSNS, and drape them around the columns
specified in BETWEEN-COLS. */
void
-set_loose_columns (System* which, Column_x_positions const *posns)
+set_loose_columns (System *which, Column_x_positions const *posns)
{
int loose_col_count = posns->loose_cols_.size ();
for (int i = 0; i < loose_col_count; i++)
{
int divide_over = 1;
- Item *loose = dynamic_cast<Item*> (posns->loose_cols_[i]);
- Paper_column* col = dynamic_cast<Paper_column*> (loose);
-
+ Item *loose = dynamic_cast<Item *> (posns->loose_cols_[i]);
+ Paper_column *col = dynamic_cast<Paper_column *> (loose);
+
if (col->system_)
continue;
-
+
Item *left = 0;
Item *right = 0;
while (1)
if (!scm_is_pair (between))
break;
- Item *le = dynamic_cast<Item*> (unsmob_grob (scm_car (between)));
- Item *re = dynamic_cast<Item*> (unsmob_grob (scm_cdr (between)));
+ Item *le = dynamic_cast<Item *> (unsmob_grob (scm_car (between)));
+ Item *re = dynamic_cast<Item *> (unsmob_grob (scm_cdr (between)));
- if (!(le && re))
+ if (! (le && re))
break;
-
+
if (!left && le)
{
left = le->get_column ();
if (!right->get_system ())
right = right->find_prebroken_piece (LEFT);
-
+
Grob *common = right->common_refpoint (left, X_AXIS);
int count = 0;
- Real total_space = 0.0;
- Real total_fixed = 0.0;
+ Real total_space = 0.0;
+ Real total_fixed = 0.0;
for (SCM wish = col->get_property ("spacing-wishes"); scm_is_pair (wish); wish = scm_cdr (wish))
{
Grob *spacing = unsmob_grob (scm_car (wish));
total_fixed += fixed;
total_space += space;
- count ++;
+ count++;
}
}
Real left_point = left->extent (common, X_AXIS)[RIGHT];
Real space_left = ((right_point - left_point) >? 0.0)
- - (my_extent.is_empty() ? 0.0 : my_extent.length ());
+ - (my_extent.is_empty () ? 0.0 : my_extent.length ());
Real padding = (space_left / 2) <? 1.0;
/*
- Put it just left of the right column, with a bit of extra space
- */
+ Put it just left of the right column, with a bit of extra space
+ */
#endif
Real my_offset = right_point - distance_to_next;
-/*
+/*
spacing-spanner.cc -- implement Spacing_spanner
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include <math.h>
#include <cstdio>
/*
TODO: this file/class is too complex. Should figure out how to chop
this up even more.
-
- */
+*/
class Spacing_spanner
{
public:
- static void standard_breakable_column_spacing (Grob * me, Item*l, Item*r,
- Real * fixed, Real * space, Moment);
-
-
- static Real default_bar_spacing (Grob*, Grob*, Grob*, Moment);
- static Real note_spacing (Grob*, Grob*, Grob*, Moment, bool*);
- static Real get_duration_space (Grob*, Moment dur, Rational shortest, bool*);
- static Rational find_shortest (Grob *, Link_array<Grob> const &);
- static void breakable_column_spacing (Grob*, Item* l, Item *r, Moment);
+ static void standard_breakable_column_spacing (Grob *me, Item *l, Item *r,
+ Real *fixed, Real *space, Moment);
+
+ static Real default_bar_spacing (Grob *, Grob *, Grob *, Moment);
+ static Real note_spacing (Grob *, Grob *, Grob *, Moment, bool *);
+ static Real get_duration_space (Grob *, Moment dur, Rational shortest, bool *);
+ static Rational find_shortest (Grob *, Link_array<Grob> const &);
+ static void breakable_column_spacing (Grob *, Item *l, Item *r, Moment);
static void find_loose_columns () {}
- static void prune_loose_columns (Grob*, Link_array<Grob> *cols, Rational);
+ static void prune_loose_columns (Grob *, Link_array<Grob> *cols, Rational);
static void find_loose_columns (Link_array<Grob> cols);
static void set_explicit_neighbor_columns (Link_array<Grob> cols);
static void set_implicit_neighbor_columns (Link_array<Grob> cols);
- static void do_measure (Rational, Grob*me, Link_array<Grob> *cols);
- static void musical_column_spacing (Grob*, Item*, Item*, Real, Rational);
- DECLARE_SCHEME_CALLBACK (set_springs, (SCM ));
- static bool has_interface (Grob*);
+ static void do_measure (Rational, Grob *me, Link_array<Grob> *cols);
+ static void musical_column_spacing (Grob *, Item *, Item *, Real, Rational);
+ DECLARE_SCHEME_CALLBACK (set_springs, (SCM));
+ static bool has_interface (Grob *);
};
/*
Return whether COL is fixed to its neighbors by some kind of spacing
constraint.
-
+
If in doubt, then we're not loose; the spacing engine should space
for it, risking suboptimal spacing.
-
- (Otherwise, we might risk core dumps, and other weird stuff.)
+ (Otherwise, we might risk core dumps, and other weird stuff.)
*/
static bool
-loose_column (Grob *l, Grob *c, Grob *r)
+loose_column (Grob *l, Grob *c, Grob *r)
{
SCM rns = c->get_property ("right-neighbors");
SCM lns = c->get_property ("left-neighbors");
- /*
+ /*
If this column doesn't have a proper neighbor, we should really
make it loose, but spacing it correctly is more than we can
currently can handle.
(this happens in the following situation:
- |
- | clef G
- *
+ |
+ | clef G
+ *
- | | ||
- | | ||
- O O ||
+ | | ||
+ | | ||
+ O O ||
the column containing the clef is really loose, and should be
attached right to the first column, but that is a lot of work for
such a borderline case.)
-
- */
+
+ */
if (!scm_is_pair (lns) || !scm_is_pair (rns))
return false;
- Item * l_neighbor = dynamic_cast<Item*> (unsmob_grob (scm_car (lns)));
- Item * r_neighbor = dynamic_cast<Item*> (unsmob_grob (scm_car (rns)));
+ Item *l_neighbor = dynamic_cast<Item *> (unsmob_grob (scm_car (lns)));
+ Item *r_neighbor = dynamic_cast<Item *> (unsmob_grob (scm_car (rns)));
if (!l_neighbor || !r_neighbor)
return false;
l_neighbor = l_neighbor->get_column ();
- r_neighbor = dynamic_cast<Item*> (Note_spacing::right_column (r_neighbor));
+ r_neighbor = dynamic_cast<Item *> (Note_spacing::right_column (r_neighbor));
if (l == l_neighbor && r == r_neighbor)
return false;
if (!l_neighbor || !r_neighbor)
return false;
-
-
/*
Only declare loose if the bounds make a little sense. This means
some cases (two isolated, consecutive clef changes) won't be
nicely folded, but hey, then don't do that.
*/
- if (! ((Paper_column::is_musical (l_neighbor) || Item::is_breakable (l_neighbor))
- && (Paper_column::is_musical (r_neighbor) || Item::is_breakable (r_neighbor))) )
+ if (! ((Paper_column::is_musical (l_neighbor) || Item::is_breakable (l_neighbor))
+ && (Paper_column::is_musical (r_neighbor) || Item::is_breakable (r_neighbor))))
{
return false;
}
-
/*
A rather hairy check, but we really only want to move around clefs. (anything else?)
in any case, we don't want to move bar lines.
- */
+ */
for (SCM e = c->get_property ("elements"); scm_is_pair (e); e = scm_cdr (e))
{
- Grob * g = unsmob_grob (scm_car (e));
+ Grob *g = unsmob_grob (scm_car (e));
if (g && Break_align_interface::has_interface (g))
{
for (SCM s = g->get_property ("elements"); scm_is_pair (s);
Grob *h = unsmob_grob (scm_car (s));
/*
- ugh. -- fix staff-bar name?
+ ugh. -- fix staff-bar name?
*/
- if (h && h->get_property ("break-align-symbol") == ly_symbol2scm ("staff-bar"))
+ if (h && h->get_property ("break-align-symbol") == ly_symbol2scm ("staff-bar"))
return false;
}
}
}
-
+
return true;
}
between.
*/
void
-Spacing_spanner::prune_loose_columns (Grob*me, Link_array<Grob> *cols, Rational shortest)
+Spacing_spanner::prune_loose_columns (Grob *me, Link_array<Grob> *cols, Rational shortest)
{
Link_array<Grob> newcols;
Real increment = robust_scm2double (me->get_property ("spacing-increment"), 1.2);
- for (int i = 0; i < cols->size (); i++)
+ for (int i = 0; i < cols->size (); i++)
{
if (Item::is_breakable (cols->elem (i)) || Paper_column::is_musical (cols->elem (i)))
{
}
Grob *c = cols->elem (i);
- if (loose_column (cols->elem (i-1), c, cols->elem (i+1)))
+ if (loose_column (cols->elem (i - 1), c, cols->elem (i + 1)))
{
SCM lns = c->get_property ("left-neighbors");
lns = scm_is_pair (lns) ? scm_car (lns) : SCM_BOOL_F;
/*
Set distance constraints for loose columns
*/
- Drul_array<Grob*> next_door;
+ Drul_array<Grob *> next_door;
next_door[LEFT] = cols->elem (i - 1);
- next_door[RIGHT] = cols->elem (i + 1);
+ next_door[RIGHT] = cols->elem (i + 1);
Direction d = LEFT;
Drul_array<Real> dists (0, 0);
do
{
dists[d] = 0.0;
- Item *lc = dynamic_cast<Item*> ((d == LEFT) ? next_door[LEFT] : c);
- Item *rc = dynamic_cast<Item*> (d == LEFT ? c : next_door[RIGHT]);
+ Item *lc = dynamic_cast<Item *> ((d == LEFT) ? next_door[LEFT] : c);
+ Item *rc = dynamic_cast<Item *> (d == LEFT ? c : next_door[RIGHT]);
for (SCM s = lc->get_property ("spacing-wishes");
scm_is_pair (s); s = scm_cdr (s))
/*
The note spacing should be taken from the musical
columns.
-
+
*/
Real base = note_spacing (me, lc, rc, shortest, &dummy);
Note_spacing::get_spacing (sp, rc, base, increment, &space, &fixed);
- space -= increment;
-
+ space -= increment;
+
dists[d] = dists[d] >? space;
}
else
dists[d] = dists[d] >? fixed_space;
}
-
+
}
}
while (flip (&d) != LEFT);
Rod r;
r.distance_ = dists[LEFT] + dists[RIGHT];
- r.item_drul_[LEFT] = dynamic_cast<Item*> (cols->elem (i-1));
- r.item_drul_[RIGHT] = dynamic_cast<Item*> (cols->elem (i+1));
+ r.item_drul_[LEFT] = dynamic_cast<Item *> (cols->elem (i - 1));
+ r.item_drul_[RIGHT] = dynamic_cast<Item *> (cols->elem (i + 1));
r.add_to_cols ();
}
}
/*
- Set neighboring columns determined by the spacing-wishes grob property.
+ Set neighboring columns determined by the spacing-wishes grob property.
*/
void
Spacing_spanner::set_explicit_neighbor_columns (Link_array<Grob> cols)
int min_rank = 100000; // inf.
- SCM wishes = cols[i]->get_property ("spacing-wishes");
+ SCM wishes = cols[i]->get_property ("spacing-wishes");
for (SCM s = wishes; scm_is_pair (s); s = scm_cdr (s))
{
- Item * wish = dynamic_cast<Item*> (unsmob_grob (scm_car (s)));
+ Item *wish = dynamic_cast<Item *> (unsmob_grob (scm_car (s)));
- Item * lc = wish->get_column ();
- Grob * right = Note_spacing::right_column (wish);
+ Item *lc = wish->get_column ();
+ Grob *right = Note_spacing::right_column (wish);
if (!right)
continue;
- Item * rc = dynamic_cast<Item*> (right);
+ Item *rc = dynamic_cast<Item *> (right);
int right_rank = Paper_column::get_rank (rc);
- int left_rank = Paper_column::get_rank (lc);
+ int left_rank = Paper_column::get_rank (lc);
/*
update the left column.
if (right_rank <= min_rank)
{
if (right_rank < min_rank)
- right_neighbors = SCM_EOL;
-
+ right_neighbors = SCM_EOL;
+
min_rank = right_rank;
right_neighbors = scm_cons (wish->self_scm (), right_neighbors);
}
if (scm_is_pair (left_neighs)
&& unsmob_grob (scm_car (left_neighs)))
{
- Item * it = dynamic_cast<Item*> (unsmob_grob (scm_car (left_neighs)));
+ Item *it = dynamic_cast<Item *> (unsmob_grob (scm_car (left_neighs)));
maxrank = Paper_column::get_rank (it->get_column ());
}
/*
Set neighboring columns that have no left/right-neighbor set
- yet. Only do breakable non-musical columns, and musical columns.
+ yet. Only do breakable non-musical columns, and musical columns.
*/
void
Spacing_spanner::set_implicit_neighbor_columns (Link_array<Grob> cols)
{
for (int i = 0; i < cols.size (); i++)
{
- Item * it = dynamic_cast<Item*>(cols[i]);
+ Item *it = dynamic_cast<Item *> (cols[i]);
if (!Item::is_breakable (it) && !Paper_column::is_musical (it))
continue;
sloppy with typnig left/right-neighbors should take list, but paper-column found instead.
*/
SCM ln = cols[i] ->get_property ("left-neighbors");
- if (!scm_is_pair (ln) && i )
+ if (!scm_is_pair (ln) && i)
{
- cols[i]->set_property ("left-neighbors", scm_cons (cols[i-1]->self_scm (), SCM_EOL));
+ cols[i]->set_property ("left-neighbors", scm_cons (cols[i - 1]->self_scm (), SCM_EOL));
}
SCM rn = cols[i] ->get_property ("right-neighbors");
- if (!scm_is_pair (rn) && i < cols.size () - 1)
+ if (!scm_is_pair (rn) && i < cols.size () - 1)
{
cols[i]->set_property ("right-neighbors", scm_cons (cols[i + 1]->self_scm (), SCM_EOL));
}
}
}
-
MAKE_SCHEME_CALLBACK (Spacing_spanner, set_springs, 1);
SCM
Spacing_spanner::set_springs (SCM smob)
prune_loose_columns (me, &all, global_shortest);
set_implicit_neighbor_columns (all);
-
int j = 0;
for (int i = 1; i < all.size (); i++)
{
Grob *sc = all[i];
if (Item::is_breakable (sc))
- {
- Link_array<Grob> measure (all.slice (j, i+1));
- do_measure (global_shortest, me, &measure);
+ {
+ Link_array<Grob> measure (all.slice (j, i + 1));
+ do_measure (global_shortest, me, &measure);
j = i;
- }
+ }
}
return SCM_UNSPECIFIED;
}
-
/*
We want the shortest note that is also "common" in the piece, so we
find the shortest in each measure, and take the most frequently
This probably gives weird effects with modern music, where every
note has a different duration, but hey, don't write that kind of
stuff, then.
-
*/
Rational
Spacing_spanner::find_shortest (Grob *me, Link_array<Grob> const &cols)
/*
ascending in duration
*/
- Array<Rational> durations;
+ Array<Rational> durations;
Array<int> counts;
-
+
Rational shortest_in_measure;
shortest_in_measure.set_infinite (1);
-
- for (int i = 0 ; i < cols.size (); i++)
+
+ for (int i = 0; i < cols.size (); i++)
{
if (Paper_column::is_musical (cols[i]))
{
- Moment *when = unsmob_moment (cols[i]->get_property ("when"));
+ Moment *when = unsmob_moment (cols[i]->get_property ("when"));
/*
ignore grace notes for shortest notes.
*/
if (when && when->grace_part_)
continue;
-
- SCM st = cols[i]->get_property ("shortest-starter-duration");
+
+ SCM st = cols[i]->get_property ("shortest-starter-duration");
Moment this_shortest = *unsmob_moment (st);
assert (this_shortest.to_bool ());
shortest_in_measure = shortest_in_measure <? this_shortest.main_part_;
counts.push (1);
}
- shortest_in_measure.set_infinite (1);
+ shortest_in_measure.set_infinite (1);
}
}
// printf ("duration %d/%d, count %d\n", durations[i].num (), durations[i].den (), counts[i]);
}
- SCM bsd = me->get_property ("base-shortest-duration");
+ SCM bsd = me->get_property ("base-shortest-duration");
Rational d = Rational (1, 8);
if (Moment *m = unsmob_moment (bsd))
d = m->main_part_;
-
+
if (max_idx >= 0)
- d = d <? durations[max_idx] ;
+ d = d <? durations[max_idx];
return d;
}
per-measure spacing. Now we have piecewise spacing. We should fix
this to support "spacing-regions": some regions have different notes
(different time sigs) than others, and should be spaced differently.
- */
+*/
void
-Spacing_spanner::do_measure (Rational global_shortest, Grob*me,
- Link_array<Grob> *cols)
+Spacing_spanner::do_measure (Rational global_shortest, Grob *me,
+ Link_array<Grob> *cols)
{
Real headwid = robust_scm2double (me->get_property ("spacing-increment"), 1);
for (int i = 0; i < cols->size () - 1; i++)
{
- Item * l = dynamic_cast<Item*> (cols->elem (i));
- Item * r = dynamic_cast<Item*> (cols->elem (i+1));
+ Item *l = dynamic_cast<Item *> (cols->elem (i));
+ Item *r = dynamic_cast<Item *> (cols->elem (i + 1));
- Paper_column * lc = dynamic_cast<Paper_column*> (l);
- Paper_column * rc = dynamic_cast<Paper_column*> (r);
+ Paper_column *lc = dynamic_cast<Paper_column *> (l);
+ Paper_column *rc = dynamic_cast<Paper_column *> (r);
if (!Paper_column::is_musical (l))
{
breakable_column_spacing (me, l, r, global_shortest);
/*
-
The case that the right part is broken as well is rather
rare, but it is possible, eg. with a single empty measure,
or if one staff finishes a tad earlier than the rest.
-
- */
+
+ */
Item *lb = l->find_prebroken_piece (RIGHT);
Item *rb = r->find_prebroken_piece (LEFT);
-
+
if (lb)
breakable_column_spacing (me, lb, r, global_shortest);
musical_column_spacing (me, lc, rc, headwid, global_shortest);
if (Item *rb = r->find_prebroken_piece (LEFT))
musical_column_spacing (me, lc, rb, headwid, global_shortest);
- }
+ }
}
}
/*
Generate the space between two musical columns LC and RC, given
spacing parameters INCR and SHORTEST.
- */
+*/
void
-Spacing_spanner::musical_column_spacing (Grob *me, Item * lc, Item *rc, Real increment, Rational global_shortest)
+Spacing_spanner::musical_column_spacing (Grob *me, Item *lc, Item *rc, Real increment, Rational global_shortest)
{
bool expand_only = false;
Real base_note_space = note_spacing (me, lc, rc, global_shortest, &expand_only);
Real compound_note_space = 0.0;
Real compound_fixed_note_space = 0.0;
int wish_count = 0;
-
- SCM seq = lc->get_property ("right-neighbors");
+
+ SCM seq = lc->get_property ("right-neighbors");
/*
We adjust the space following a note only if the next note
*/
for (SCM s = seq; scm_is_pair (s); s = scm_cdr (s))
{
- Grob * wish = unsmob_grob (scm_car (s));
+ Grob *wish = unsmob_grob (scm_car (s));
Item *wish_rcol = Note_spacing::right_column (wish);
if (Note_spacing::left_column (wish) != lc
{
Real space = 0.0;
Real fixed = 0.0;
-
+
Note_spacing::get_spacing (wish, rc, base_note_space, increment, &space, &fixed);
-
compound_note_space = compound_note_space + space;
compound_fixed_note_space = compound_fixed_note_space + fixed;
- wish_count ++;
-
+ wish_count++;
+
}
}
- if (Paper_column::when_mom (rc).grace_part_ &&
- !Paper_column::when_mom (lc).grace_part_)
+ if (Paper_column::when_mom (rc).grace_part_
+ && !Paper_column::when_mom (lc).grace_part_)
{
/*
Ugh. 0.8 is arbitrary.
- */
- compound_note_space *= 0.8;
+ */
+ compound_note_space *= 0.8;
}
-
+
if (compound_note_space < 0 || wish_count == 0)
{
compound_note_space = base_note_space;
- compound_fixed_note_space = increment;
+ compound_fixed_note_space = increment;
}
else
{
/*
TODO: make sure that the space doesn't exceed the right margin.
- */
+ */
if (packed)
{
/*
distance = compound_note_space;
}
- Spaceable_grob::add_spring (lc, rc, distance, strength);
+ Spaceable_grob::add_spring (lc, rc, distance, strength);
}
-
/*
The one-size-fits all spacing. It doesn't take into account
different spacing wishes from one to the next column.
- */
+*/
void
-Spacing_spanner::standard_breakable_column_spacing (Grob * me, Item*l, Item*r,
- Real * fixed, Real * space,
- Moment shortest)
+Spacing_spanner::standard_breakable_column_spacing (Grob *me, Item *l, Item *r,
+ Real *fixed, Real *space,
+ Moment shortest)
{
*fixed = 0.0;
Direction d = LEFT;
- Drul_array<Item*> cols (l, r);
-
+ Drul_array<Item *> cols (l, r);
+
do
{
if (!Paper_column::is_musical (cols[d]))
/*
Tied accidentals over barlines cause problems, so lets see
what happens if we do this for non musical columns only.
- */
+ */
Interval lext = cols[d]->extent (cols [d], X_AXIS);
if (!lext.is_empty ())
*fixed += -d * lext[-d];
}
}
while (flip (&d) != LEFT);
-
if (l->is_breakable (l) && r->is_breakable (r))
{
Moment mlen (1);
if (dt)
mlen = *dt;
-
+
Real incr = robust_scm2double (me->get_property ("spacing-increment"), 1);
- *space = *fixed + incr * double (mlen.main_part_ / shortest.main_part_) * 0.8;
+ *space = *fixed + incr * double (mlen.main_part_ / shortest.main_part_) * 0.8;
}
else
{
/*
In this case, Staff_spacing should handle the job,
using dt when it is 0 is silly.
- */
- *space = *fixed + 0.5;
+ */
+ *space = *fixed + 0.5;
}
else
{
}
}
-
/*
Read hints from L and generate springs.
*/
void
-Spacing_spanner::breakable_column_spacing (Grob*me, Item* l, Item *r, Moment shortest)
+Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, Moment shortest)
{
Real compound_fixed = 0.0;
Real compound_space = 0.0;
for (SCM s = l->get_property ("spacing-wishes");
scm_is_pair (s); s = scm_cdr (s))
{
- Item * spacing_grob = dynamic_cast<Item*> (unsmob_grob (scm_car (s)));
+ Item *spacing_grob = dynamic_cast<Item *> (unsmob_grob (scm_car (s)));
if (!spacing_grob || !Staff_spacing::has_interface (spacing_grob))
continue;
compound_space += space;
compound_fixed += fixed_space;
- wish_count ++ ;
+ wish_count++;
}
}
if (compound_space <= 0.0 || !wish_count)
{
- standard_breakable_column_spacing (me, l, r, &compound_fixed, &compound_space ,
+ standard_breakable_column_spacing (me, l, r, &compound_fixed, &compound_space,
shortest);
wish_count = 1;
}
assert (!isinf (compound_space));
compound_space = compound_space >? compound_fixed;
-
/*
Hmm. we do 1/0 in the next thing. Perhaps we should check if this
works on all architectures.
- */
+ */
/*
There used to be code that changed spacing depending on
raggedright setting. Ugh.
- Do it more cleanly, or rename the property.
-
- */
+ Do it more cleanly, or rename the property.
+
+ */
Real strength = 1 / (compound_space - compound_fixed);
Real distance = compound_space;
Spaceable_grob::add_spring (l, r, distance, strength);
}
-
/**
- Get the measure wide ant for arithmetic spacing.
- */
+ Get the measure wide ant for arithmetic spacing.
+*/
Real
-Spacing_spanner::get_duration_space (Grob*me, Moment d, Rational shortest, bool * expand_only)
+Spacing_spanner::get_duration_space (Grob *me, Moment d, Rational shortest, bool *expand_only)
{
Real k = robust_scm2double (me->get_property ("shortest-duration-space"), 1);
Real incr = robust_scm2double (me->get_property ("spacing-increment"), 1);
-
+
if (d < shortest)
{
/*
mm for 8th. (white space), suggesting that we use
(1.2 / 1.5)^{-log2(duration ratio)}
-
- */
+
+ */
Rational ratio = d.main_part_ / shortest;
- return ((k-1) + double (ratio)) * incr;
+ return ((k - 1) + double (ratio)) * incr;
}
else
{
/*
- John S. Gourlay. ``Spacing a Line of Music, '' Technical
- Report OSU-CISRC-10/87-TR35, Department of Computer and
- Information Science, The Ohio State University, 1987.
- */
- Real log = log_2 (shortest);
+ John S. Gourlay. ``Spacing a Line of Music, '' Technical
+ Report OSU-CISRC-10/87-TR35, Department of Computer and
+ Information Science, The Ohio State University, 1987.
+ */
+ Real log = log_2 (shortest);
k -= log;
Rational compdur = d.main_part_ + d.grace_part_ /Rational (3);
- *expand_only = false;
-
+ *expand_only = false;
+
return (log_2 (compdur) + k) * incr;
}
}
Real
-Spacing_spanner::note_spacing (Grob*me, Grob *lc, Grob *rc,
- Moment shortest, bool * expand_only)
+Spacing_spanner::note_spacing (Grob *me, Grob *lc, Grob *rc,
+ Moment shortest, bool *expand_only)
{
Moment shortest_playing_len = 0;
SCM s = lc->get_property ("shortest-playing-duration");
if (unsmob_moment (s))
shortest_playing_len = *unsmob_moment (s);
-
+
if (! shortest_playing_len.to_bool ())
{
programming_error ("can't find a ruling note at " + Paper_column::when_mom (lc).to_string ());
}
Moment lwhen = Paper_column::when_mom (lc);
- Moment rwhen = Paper_column::when_mom (rc);
+ Moment rwhen = Paper_column::when_mom (rc);
Moment delta_t = rwhen - lwhen;
if (!Paper_column::is_musical (rc))
when toying with mmrests, it is possible to have musical
column on the left and non-musical on the right, spanning
several measures.
- */
-
+ */
+
Moment *dt = unsmob_moment (rc->get_property ("measure-length"));
if (dt)
{
/*
The following is an extra safety measure, such that
the length of a mmrest event doesn't cause havoc.
- */
+ */
shortest_playing_len = shortest_playing_len <? *dt;
}
}
SHORTEST_PLAYING_LEN away. However chord-tremolos do funky faking stuff
with durations, invalidating this assumption. Here we kludge
around to get chord tremolos to behave properly.
-
- */
+
+ */
shortest_playing_len = shortest_playing_len >? delta_t;
if (delta_t.main_part_ && !lwhen.grace_part_)
{
dist *= grace_fact;
}
-
return dist;
}
-
-
ADD_INTERFACE (Spacing_spanner, "spacing-spanner-interface",
-"The space taken by a note is dependent on its duration. Doubling a\n"
-"duration adds spacing-increment to the space. The most common shortest\n"
-"note gets @code{shortest-duration-space}. Notes that are even shorter are\n"
-"spaced proportonial to their duration.\n"
-"\n"
-"Typically, the increment is the width of a black note head. In a\n"
-"piece with lots of 8th notes, and some 16th notes, the eighth note\n"
-"gets 2 note heads width (i.e. the space following a note is 1 note\n"
-"head width) A 16th note is followed by 0.5 note head width. The\n"
-"quarter note is followed by 3 NHW, the half by 4 NHW, etc.\n",
- "grace-space-factor spacing-increment base-shortest-duration shortest-duration-space common-shortest-duration");
-
-
+ "The space taken by a note is dependent on its duration. Doubling a\n"
+ "duration adds spacing-increment to the space. The most common shortest\n"
+ "note gets @code{shortest-duration-space}. Notes that are even shorter are\n"
+ "spaced proportonial to their duration.\n"
+ "\n"
+ "Typically, the increment is the width of a black note head. In a\n"
+ "piece with lots of 8th notes, and some 16th notes, the eighth note\n"
+ "gets 2 note heads width (i.e. the space following a note is 1 note\n"
+ "head width) A 16th note is followed by 0.5 note head width. The\n"
+ "quarter note is followed by 3 NHW, the half by 4 NHW, etc.\n",
+ "grace-space-factor spacing-increment base-shortest-duration shortest-duration-space common-shortest-duration");
ADD_INTERFACE (Spacing_interface, "spacing-interface",
- "Something to do with line breaking and spacing. Kill this one after determining line breaks.",
- "");
+ "Something to do with line breaking and spacing. Kill this one after determining line breaks.",
+ "");
#include "side-position-interface.hh"
#include "staff-symbol-referencer.hh"
-/**
- Make arpeggios that span multiple staves. Catch arpeggios, and span a
- Span_arpeggio over them if we find more than two arpeggios.
- */
+/**
+ Make arpeggios that span multiple staves. Catch arpeggios, and span a
+ Span_arpeggio over them if we find more than two arpeggios.
+*/
class Span_arpeggio_engraver : public Engraver
{
public:
TRANSLATOR_DECLARATIONS (Span_arpeggio_engraver);
-
+
protected:
virtual void acknowledge_grob (Grob_info);
virtual void process_acknowledged_grobs ();
Link_array<Grob> arpeggios_;
};
-
Span_arpeggio_engraver::Span_arpeggio_engraver ()
{
span_arpeggio_ = 0;
&& to_boolean (get_property ("connectArpeggios")))
{
span_arpeggio_ = make_item ("Arpeggio", SCM_EOL);
-
+
}
}
void
Span_arpeggio_engraver::stop_translation_timestep ()
{
- if (span_arpeggio_)
+ if (span_arpeggio_)
{
/*
we do this very late, to make sure we also catch `extra'
side-pos support like accidentals.
- */
- for (int i = 0; i < arpeggios_.size (); i ++)
+ */
+ for (int i = 0; i < arpeggios_.size (); i++)
{
for (SCM s = arpeggios_[i]->get_property ("stems");
scm_is_pair (s); s = scm_cdr (s))
it transparent. */
arpeggios_[i]->set_property ("print-function", SCM_EOL);
}
-
+
span_arpeggio_ = 0;
}
arpeggios_.clear ();
}
-
-
ADD_TRANSLATOR (Span_arpeggio_engraver,
-/* descr */ "",
-/* creats*/ "Arpeggio",
-/* accepts */ "",
-/* acks */ "arpeggio-interface",
-/* reads */ "connectArpeggios",
-/* write */ "");
+ /* descr */ "",
+ /* creats*/ "Arpeggio",
+ /* accepts */ "",
+ /* acks */ "arpeggio-interface",
+ /* reads */ "connectArpeggios",
+ /* write */ "");
#include "span-bar.hh"
#include "engraver.hh"
-/**
+/**
- Make bars that span multiple "staves". Catch bars, and span a
- Span_bar over them if we find more than 2 bars. Vertical alignment
- of staves changes the appearance of spanbars. It is up to the
- aligner (Vertical_align_engraver, in this case, to add extra
- dependencies to the spanbars.
-
- */
+Make bars that span multiple "staves". Catch bars, and span a
+Span_bar over them if we find more than 2 bars. Vertical alignment
+of staves changes the appearance of spanbars. It is up to the
+aligner (Vertical_align_engraver, in this case, to add extra
+dependencies to the spanbars.
+*/
class Span_bar_engraver : public Engraver
{
Item *spanbar_;
int depth = i.origin_contexts (this).size ();
if (depth && Bar_line::has_interface (i.grob_))
{
- Item * it = dynamic_cast<Item*> (i.grob_);
+ Item *it = dynamic_cast<Item *> (i.grob_);
bars_.push (it);
- if (bars_.size () >= 2 && !spanbar_)
+ if (bars_.size () >= 2 && !spanbar_)
{
spanbar_ = make_item ("SpanBar", SCM_EOL);
spanbar_->set_parent (bars_[0], X_AXIS);
-
+
}
}
}
void
Span_bar_engraver::stop_translation_timestep ()
{
- if (spanbar_)
+ if (spanbar_)
{
- for (int i = 0; i < bars_.size () ; i++)
+ for (int i = 0; i < bars_.size (); i++)
Span_bar::add_bar (spanbar_, bars_[i]);
SCM vissym = ly_symbol2scm ("break-visibility");
- SCM vis = bars_[0]->internal_get_property (vissym);
+ SCM vis = bars_[0]->internal_get_property (vissym);
if (ly_c_equal_p (spanbar_->internal_get_property (vissym), vis))
spanbar_->internal_set_property (vissym, vis);
-
spanbar_ = 0;
}
bars_.set_size (0);
}
-
ADD_TRANSLATOR (Span_bar_engraver,
-/* descr */ "This engraver makes cross-staff barlines: It catches all normal "
-"bar lines, and draws a single span-bar across them.",
-/* creats*/ "SpanBar",
-/* accepts */ "",
-/* acks */ "bar-line-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "This engraver makes cross-staff barlines: It catches all normal "
+ "bar lines, and draws a single span-bar across them.",
+ /* creats*/ "SpanBar",
+ /* accepts */ "",
+ /* acks */ "bar-line-interface",
+ /* reads */ "",
+ /* write */ "");
#include "bar-line.hh"
void
-Span_bar::add_bar (Grob*me, Grob*b)
+Span_bar::add_bar (Grob *me, Grob *b)
{
- Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), b);
+ Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), b);
me->add_dependency (b);
}
/* Limitations/Bugs:
- (1) Elements from 'me->get_property ("elements")' must be
- ordered according to their y coordinates relative to their common
- axis group parent. Otherwise, the computation goes mad.
+(1) Elements from 'me->get_property ("elements")' must be
+ordered according to their y coordinates relative to their common
+axis group parent. Otherwise, the computation goes mad.
- (TODO:
- apply a sort algorithm that ensures this precondition.) However,
- until now, I have seen no case where lily has not fulfilled this
- precondition.
+(TODO:
+apply a sort algorithm that ensures this precondition.) However,
+until now, I have seen no case where lily has not fulfilled this
+precondition.
- (2) This method depends on bar_engraver not being removed from
- staff context. If bar_engraver is removed, the size of the staff
- lines is evaluated as 0, which results in a solid span bar line
- with faulty y coordinate. */
+(2) This method depends on bar_engraver not being removed from
+staff context. If bar_engraver is removed, the size of the staff
+lines is evaluated as 0, which results in a solid span bar line
+with faulty y coordinate. */
/* This routine was originally by Juergen Reuter, but it was a on the
bulky side. Rewritten by Han-Wen. */
SCM
-Span_bar::print (SCM smobbed_me)
+Span_bar::print (SCM smobbed_me)
{
Grob *me = unsmob_grob (smobbed_me);
SCM first_elt = me->get_property ("elements");
SCM glyph = me->get_property ("glyph");
/* glyph may not be a string, when ME is killed by Hara Kiri in
- between. */
+ between. */
if (!scm_is_string (glyph))
return SCM_EOL;
-
+
String glyph_string = ly_scm2string (glyph);
/* compose span_bar_mol */
Grob *staff_bar = unsmob_grob (smobbed_staff_bar);
Interval ext = staff_bar->extent (refp, Y_AXIS);
if (ext.is_empty ())
- continue;
-
+ continue;
+
if (!prev_extent.is_empty ())
{
Interval l (prev_extent [UP],
- ext[DOWN]);
+ ext[DOWN]);
if (l.is_empty ())
{
else
{
Stencil interbar = Bar_line::compound_barline (staff_bar,
- glyph_string,
- l.length ());
+ glyph_string,
+ l.length ());
interbar.translate_axis (l.center (), Y_AXIS);
span_bar_mol.add_stencil (interbar);
}
span_bar_mol.translate_axis (- me->relative_coordinate (refp, Y_AXIS),
Y_AXIS);
-
+
return span_bar_mol.smobbed_copy ();
}
urg.
*/
Stencil m = Bar_line::compound_barline (se, gl, 40 PT);
-
+
return ly_interval2scm (m.extent (X_AXIS));
}
SCM
Span_bar::before_line_breaking (SCM smob)
{
- Grob * g = unsmob_grob (smob);
+ Grob *g = unsmob_grob (smob);
evaluate_empty (g);
evaluate_glyph (g);
Interval i (get_spanned_interval (me));
/* Bar_line::print delivers a barline of y-extent (-h/2, h/2), so
- we have to translate ourselves to be in the center of the
+ we have to translate ourselves to be in the center of the
interval that we span. */
if (i.is_empty ())
{
me->suicide ();
return scm_make_real (0.0);
}
-
+
return scm_make_real (i.center ());
}
void
-Span_bar::evaluate_empty (Grob*me)
+Span_bar::evaluate_empty (Grob *me)
{
/* TODO: filter all hara-kiried out of ELEMENS list, and then
optionally do suicide. Call this cleanage function from
}
void
-Span_bar::evaluate_glyph (Grob*me)
+Span_bar::evaluate_glyph (Grob *me)
{
SCM gl = me->get_property ("glyph");
if (scm_is_string (gl))
- return ;
-
+ return;
+
for (SCM s = me->get_property ("elements");
!scm_is_string (gl) && scm_is_pair (s); s = scm_cdr (s))
{
me->suicide ();
return;
}
-
+
String type = ly_scm2string (gl);
- if (type == "|:")
+ if (type == "|:")
{
type = ".|";
}
}
Interval
-Span_bar::get_spanned_interval (Grob*me)
+Span_bar::get_spanned_interval (Grob *me)
{
return ly_scm2interval (Axis_group_interface::group_extent_callback
- (me->self_scm (), scm_int2num (Y_AXIS)));
+ (me->self_scm (), scm_int2num (Y_AXIS)));
}
-
MAKE_SCHEME_CALLBACK (Span_bar, get_bar_size, 1);
SCM
Span_bar::get_bar_size (SCM smob)
{
- Grob* me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
Interval iv (get_spanned_interval (me));
if (iv.is_empty ())
{
return scm_make_real (iv.length ());
}
-
-
ADD_INTERFACE (Span_bar, "span-bar-interface",
- "A bar line that spanned between other barlines. This interface is "
+ "A bar line that spanned between other barlines. This interface is "
" used for bar lines that connect different staves.",
- "elements");
-
+ "elements");
/*
TODO: fold this into 1 engraver: \< and \> should also stop when
absdyn is encountered.
- */
+*/
struct Audio_dynamic_tuple
{
- Audio_dynamic* audio_;
+ Audio_dynamic *audio_;
Moment mom_;
};
/**
perform span-dynamics
- */
+*/
class Span_dynamic_performer : public Performer
{
public:
TRANSLATOR_DECLARATIONS (Span_dynamic_performer);
protected:
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void acknowledge_audio_element (Audio_element_info);
virtual void process_music ();
virtual void stop_translation_timestep ();
private:
- Audio_dynamic* audio_;
+ Audio_dynamic *audio_;
Real last_volume_;
- Music* span_start_event_;
- Drul_array<Music*> span_events_;
+ Music *span_start_event_;
+ Drul_array<Music *> span_events_;
Array<Audio_dynamic_tuple> dynamic_tuples_;
Array<Audio_dynamic_tuple> finished_dynamic_tuples_;
Direction dir_;
void
Span_dynamic_performer::acknowledge_audio_element (Audio_element_info i)
{
- if (Audio_dynamic * d = dynamic_cast <Audio_dynamic*> (i.elem_))
+ if (Audio_dynamic *d = dynamic_cast<Audio_dynamic *> (i.elem_))
{
last_volume_ = d->volume_;
}
Audio_dynamic_tuple a = { audio_, now_mom () };
dynamic_tuples_.push (a);
}
-
+
if (span_events_[STOP])
{
if (!span_start_event_)
if (span_events_[START])
{
- dir_ = (span_events_[START]->is_mus_type ("crescendo-event"))
+ dir_ = (span_events_[START]->is_mus_type ("crescendo-event"))
? RIGHT : LEFT;
span_start_event_ = span_events_[START];
-
+
dynamic_tuples_.clear ();
Audio_dynamic_tuple a = { audio_, now_mom () };
dynamic_tuples_.push (a);
}
if (span_events_[STOP])
- {
+ {
finished_dynamic_tuples_.top ().audio_->volume_ = last_volume_;
}
-
+
if (span_events_[START])
{
dynamic_tuples_[0].audio_->volume_ = last_volume_;
urg.
Catch and fix the case of:
- | |
- x| x|
- f cresc. -- -- -- -- -- pp
+ | |
+ x| x|
+ f cresc. -- -- -- -- -- pp
- Actually, we should provide a non-displayed dynamic/volume setting,
- to set volume to 'ff' just before the pp.
- */
+ Actually, we should provide a non-displayed dynamic/volume setting,
+ to set volume to 'ff' just before the pp.
+ */
if (!dv || sign (dv) != finished_dir_)
{
// urg. 20%: about two volume steps
dv = (Real)finished_dir_ * 0.2;
if (!start_volume)
start_volume = finished_dynamic_tuples_.top
- ().audio_->volume_ - dv;
+ ().audio_->volume_ - dv;
}
Moment start_mom = finished_dynamic_tuples_[0].mom_;
Moment dt = finished_dynamic_tuples_.top ().mom_ - start_mom;
for (int i = 0; i < finished_dynamic_tuples_.size (); i++)
{
- Audio_dynamic_tuple* a = &finished_dynamic_tuples_[i];
+ Audio_dynamic_tuple *a = &finished_dynamic_tuples_[i];
Real volume = start_volume + dv * (Real) (a->mom_ - start_mom).main_part_
/ (Real)dt.main_part_;
a->audio_->volume_ = volume;
}
bool
-Span_dynamic_performer::try_music (Music* r)
+Span_dynamic_performer::try_music (Music *r)
{
if (r->is_mus_type ("crescendo-event")
|| r->is_mus_type ("decrescendo-event"))
return false;
}
ADD_TRANSLATOR (Span_dynamic_performer,
- "", "",
- "crescendo-event decrescendo-event",
- "", "", "");
+ "", "",
+ "crescendo-event decrescendo-event",
+ "", "", "");
#include <math.h>
-#include <libc-extension.hh>
+#include <libc - extension.hh>
#include "warn.hh"
#include "paper-column.hh"
#include "system.hh"
#include "group-interface.hh"
-
-
-Grob *
+Grob *
Spanner::clone (int count) const
{
return new Spanner (*this, count);
Spanner::do_break_processing ()
{
//break_into_pieces
- Item * left = spanned_drul_[LEFT];
- Item * right = spanned_drul_[RIGHT];
+ Item *left = spanned_drul_[LEFT];
+ Item *right = spanned_drul_[RIGHT];
if (!left || !right)
return;
-
+
/*
Check if our parent in X-direction spans equally wide
or wider than we do.
- */
- for (int a = X_AXIS; a < NO_AXES; a ++)
+ */
+ for (int a = X_AXIS; a < NO_AXES; a++)
{
- if (Spanner* parent = dynamic_cast<Spanner*> (get_parent ((Axis)a)))
+ if (Spanner *parent = dynamic_cast<Spanner *> (get_parent ((Axis)a)))
{
if (!parent->spanned_rank_iv ().superset (this->spanned_rank_iv ()))
{
programming_error (to_string ("Spanner `%s' is not fully contained in parent spanner `%s'.",
- name ().to_str0 (),
- parent->name ().to_str0 ()));
+ name ().to_str0 (),
+ parent->name ().to_str0 ()));
}
}
}
-
+
if (get_system () || is_broken ())
return;
Direction d = LEFT;
do
{
- Item* bound = left->find_prebroken_piece (d);
+ Item *bound = left->find_prebroken_piece (d);
if (!bound)
programming_error ("no broken bound");
else if (bound->get_system ())
{
- Spanner * span = dynamic_cast<Spanner*> (clone (broken_intos_.size ()));
+ Spanner *span = dynamic_cast<Spanner *> (clone (broken_intos_.size ()));
span->set_bound (LEFT, bound);
span->set_bound (RIGHT, bound);
- assert (span->get_system ());
+ assert (span->get_system ());
span->get_system ()->typeset_grob (span);
broken_intos_.push (span);
}
break_points.insert (left, 0);
break_points.push (right);
- for (int i =1; i < break_points.size (); i++)
+ for (int i =1; i < break_points.size (); i++)
{
- Drul_array<Item*> bounds;
- bounds[LEFT] = break_points[i-1];
+ Drul_array<Item *> bounds;
+ bounds[LEFT] = break_points[i - 1];
bounds[RIGHT] = break_points[i];
Direction d = LEFT;
do
}
while ((flip (&d))!= LEFT);
- if (!bounds[LEFT] || ! bounds[RIGHT])
+ if (!bounds[LEFT] || ! bounds[RIGHT])
{
programming_error ("bounds of this piece aren't breakable. ");
- continue;
+ continue;
}
- Spanner *span = dynamic_cast<Spanner*> (clone (broken_intos_.size ()));
+ Spanner *span = dynamic_cast<Spanner *> (clone (broken_intos_.size ()));
span->set_bound (LEFT, bounds[LEFT]);
span->set_bound (RIGHT, bounds[RIGHT]);
- if (!bounds[LEFT]->get_system ()
-
+ if (!bounds[LEFT]->get_system ()
+
|| !bounds[RIGHT]->get_system ()
|| bounds[LEFT]->get_system () != bounds[RIGHT]->get_system ())
{
Spanner::set_my_columns ()
{
Direction i = (Direction) LEFT;
- do
+ do
{
if (!spanned_drul_[i]->get_system ())
set_bound (i, spanned_drul_[i]->find_prebroken_piece ((Direction) -i));
- }
+ }
while (flip (&i) != LEFT);
-}
+}
Interval_t<int>
Spanner::spanned_rank_iv ()
return iv;
}
-
-Item*
+Item *
Spanner::get_bound (Direction d) const
{
return spanned_drul_ [d];
X-axis parent of THIS to S.
*/
void
-Spanner::set_bound (Direction d, Grob*s)
+Spanner::set_bound (Direction d, Grob *s)
{
- Item * i = dynamic_cast<Item*> (s);
+ Item *i = dynamic_cast<Item *> (s);
if (!i)
{
programming_error ("Must have Item for spanner bound.");
return;
}
-
+
spanned_drul_[d] = i;
/**
We check for System to prevent the column -> line_of_score
-> column -> line_of_score -> etc situation */
- if (d == LEFT && !dynamic_cast<System*> (this))
+ if (d == LEFT && !dynamic_cast<System *> (this))
{
set_parent (i, X_AXIS);
}
[maybe we should try keeping all columns alive?, and perhaps
inherit position from their (non-)musical brother]
-
+
*/
- if (dynamic_cast<Paper_column*> (i))
+ if (dynamic_cast<Paper_column *> (i))
{
- Pointer_group_interface::add_grob (i, ly_symbol2scm ("bounded-by-me"), this);
+ Pointer_group_interface::add_grob (i, ly_symbol2scm ("bounded-by-me"), this);
}
}
-Spanner::Spanner (SCM s, Object_key const*key)
+Spanner::Spanner (SCM s, Object_key const *key)
: Grob (s, key)
{
break_index_ = 0;
Real
Spanner::spanner_length () const
-{
+{
Real l = spanned_drul_[LEFT]->relative_coordinate (0, X_AXIS);
Real r = spanned_drul_[RIGHT]->relative_coordinate (0, X_AXIS);
if (r< l)
programming_error ("spanner with negative length");
- return r-l;
+ return r - l;
}
System *
return spanned_drul_[LEFT]->get_system ();
}
-
-Grob*
-Spanner::find_broken_piece (System*l) const
+Grob *
+Spanner::find_broken_piece (System *l) const
{
- int idx = binsearch_links (broken_intos_, (Spanner*)l, Spanner::compare);
-
+ int idx = binsearch_links (broken_intos_, (Spanner *)l, Spanner::compare);
+
if (idx < 0)
return 0;
else
return broken_intos_ [idx];
}
-
int
-Spanner::compare (Spanner * const &p1, Spanner * const &p2)
+Spanner::compare (Spanner *const &p1, Spanner *const &p2)
{
- return p1->get_system ()->rank_ - p2->get_system ()->rank_;
+ return p1->get_system ()->rank_ - p2->get_system ()->rank_;
}
bool
return broken_intos_.size ();
}
-
/*
If this is a broken spanner, return the amount the left end is to be
shifted horizontally so that the spanner starts after the initial
Real
Spanner::get_broken_left_end_align () const
{
- Paper_column *sc = dynamic_cast<Paper_column*> (spanned_drul_[LEFT]->get_column ());
+ Paper_column *sc = dynamic_cast<Paper_column *> (spanned_drul_[LEFT]->get_column ());
// Relevant only if left span point is first column in line
- if (sc != NULL &&
- sc->break_status_dir () == RIGHT)
+ if (sc != NULL
+ && sc->break_status_dir () == RIGHT)
{
/*
-
We used to do a full search for the Break_align_item.
But that doesn't make a difference, since the Paper_column
is likely to contain only a Break_align_item.
We'd be fucked if this is called before spanned_drul_[] is inited. */
if (status_ == ORPHAN)
return SCM_EOL;
-
+
Direction d = LEFT;
do
if (spanned_drul_[d])
scm_gc_mark (spanned_drul_[d]->self_scm ());
while (flip (&d) != LEFT);
- for (int i = broken_intos_.size () ; i--;)
+ for (int i = broken_intos_.size (); i--;)
scm_gc_mark (broken_intos_[i]->self_scm ());
return SCM_EOL;
}
-
/*
Set left or right bound to IT.
Warning: caller should ensure that subsequent calls put in ITems
that are left-to-right ordered.
- */
+*/
void
-add_bound_item (Spanner* sp, Grob*it)
+add_bound_item (Spanner *sp, Grob *it)
{
if (!sp->get_bound (LEFT))
sp->set_bound (LEFT, it);
sp->set_bound (RIGHT, it);
}
-
MAKE_SCHEME_CALLBACK (Spanner, set_spacing_rods, 1);
SCM
Spanner::set_spacing_rods (SCM smob)
{
- Grob*me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
Rod r;
- Spanner*sp = dynamic_cast<Spanner*> (me);
+ Spanner *sp = dynamic_cast<Spanner *> (me);
r.item_drul_[LEFT] = sp->get_bound (LEFT);
r.item_drul_[RIGHT] = sp->get_bound (RIGHT);
- r.distance_ =
- robust_scm2double (me->get_property ("minimum-length"), 0);
+ r.distance_
+ = robust_scm2double (me->get_property ("minimum-length"), 0);
r.add_to_cols ();
return SCM_UNSPECIFIED;
}
-
/*
- Return I such that SP == SP->ORIGINAL_->BROKEN_INTOS_[I].
- */
+ Return I such that SP == SP->ORIGINAL_->BROKEN_INTOS_[I].
+*/
int
-broken_spanner_index (Spanner * sp)
+broken_spanner_index (Spanner *sp)
{
- Spanner * parent = dynamic_cast<Spanner*> (sp->original_);
+ Spanner *parent = dynamic_cast<Spanner *> (sp->original_);
return parent->broken_intos_.find_index (sp);
}
-
-Spanner*
-unsmob_spanner (SCM s )
+Spanner *
+unsmob_spanner (SCM s)
{
- return dynamic_cast<Spanner*> (unsmob_grob (s));
+ return dynamic_cast<Spanner *> (unsmob_grob (s));
}
ADD_INTERFACE (Spanner,
- "spanner-interface",
-"Some objects are horizontally spanned between objects. For\n"
-"example, slur, beam, tie, etc. These grobs form a subtype called\n"
-"@code{Spanner}. All spanners have two span-points (these must be\n"
-"@code{Item} objects), one on the left and one on the right. The left bound is\n"
-"also the X-reference point of the spanner.\n"
-,
- "minimum-length");
+ "spanner-interface",
+ "Some objects are horizontally spanned between objects. For\n"
+ "example, slur, beam, tie, etc. These grobs form a subtype called\n"
+ "@code{Spanner}. All spanners have two span-points (these must be\n"
+ "@code{Item} objects), one on the left and one on the right. The left bound is\n"
+ "also the X-reference point of the spanner.\n",
+ "minimum-length");
-/*
+/*
spring.cc -- implement Spring
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "spring.hh"
#include "warn.hh"
other_ = 0;
}
-
IMPLEMENT_SIMPLE_SMOBS (Spring_smob);
SCM
}
SCM
-Spring_smob::equal_p (SCM a , SCM b)
+Spring_smob::equal_p (SCM a, SCM b)
{
return a == b? SCM_BOOL_T : SCM_BOOL_F;
}
-/*
-staff-collecting-engraver.cc -- implement Staff_collecting_engraver
+/*
+ staff-collecting-engraver.cc -- implement Staff_collecting_engraver
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+ (c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
#include "staff-symbol.hh"
#include "engraver.hh"
Staff_collecting_engraver::Staff_collecting_engraver ()
{
-
+
}
void
}
}
-
ADD_TRANSLATOR (Staff_collecting_engraver,
-/* descr */ "Maintain the stavesFound variable",
+ /* descr */ "Maintain the stavesFound variable",
-/* creats*/ "",
-/* accepts */ "",
-/* acks */ "staff-symbol-interface",
-/* reads */ "stavesFound",
-/* write */ "stavesFound");
+ /* creats*/ "",
+ /* accepts */ "",
+ /* acks */ "staff-symbol-interface",
+ /* reads */ "stavesFound",
+ /* write */ "stavesFound");
source file of the GNU LilyPond music typesetter
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+*/
#include "warn.hh"
#include "audio-column.hh"
#include "context.hh"
/** Perform a staff. Individual notes should have their instrument
- (staff-wide) set, so we override play_element ()
-
- */
-class Staff_performer : public Performer_group_performer
+ (staff-wide) set, so we override play_element ()
+*/
+class Staff_performer : public Performer_group_performer
{
public:
TRANSLATOR_DECLARATIONS (Staff_performer);
String instrument_string_;
protected:
- virtual void play_element (Audio_element* p);
+ virtual void play_element (Audio_element *p);
virtual void finalize ();
virtual void initialize ();
virtual void create_audio_elements ();
virtual void stop_translation_timestep ();
private:
- Audio_staff* audio_staff_;
- Audio_instrument* instrument_;
- Audio_text* instrument_name_;
- Audio_text* name_;
- Audio_tempo* tempo_;
+ Audio_staff *audio_staff_;
+ Audio_instrument *instrument_;
+ Audio_text *instrument_name_;
+ Audio_text *name_;
+ Audio_tempo *tempo_;
};
ADD_TRANSLATOR (Staff_performer, "", "",
- "",
- "", "", "");
+ "",
+ "", "", "");
Staff_performer::Staff_performer ()
{
/*
Have to be here before notes arrive into the staff.
- */
+ */
play_element (instrument_);
play_element (instrument_name_);
}
Staff_performer::stop_translation_timestep ()
{
SCM proc = ly_lily_module_constant ("percussion?");
-
+
SCM drums = scm_call_1 (proc, ly_symbol2scm (instrument_string_.to_str0 ()));
- audio_staff_->channel_ = (drums == SCM_BOOL_T ? 9 : -1 );
+ audio_staff_->channel_ = (drums == SCM_BOOL_T ? 9 : -1);
if (name_)
{
play_element (name_);
audio_staff_ = 0;
}
-String
-Staff_performer::new_instrument_string ()
-{
+String
+Staff_performer::new_instrument_string ()
+{
// mustn't ask Score for instrument: it will return piano!
SCM minstr = get_property ("midiInstrument");
return instrument_string_;
}
-void
-Staff_performer::play_element (Audio_element* p)
+void
+Staff_performer::play_element (Audio_element *p)
{
- if (Audio_item *ai = dynamic_cast<Audio_item *> (p))
+ if (Audio_item *ai = dynamic_cast<Audio_item *> (p))
{
audio_staff_->add_audio_item (ai);
}
-/*
- staff-spacing.cc -- implement Staff_spacing
-
- source file of the GNU LilyPond music typesetter
+/*
+ staff-spacing.cc -- implement Staff_spacing
- (c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ source file of the GNU LilyPond music typesetter
+ (c) 2001--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "staff-spacing.hh"
#include <cstdio>
-#include "paper-column.hh"
+#include "paper-column.hh"
#include "separation-item.hh"
#include "warn.hh"
#include "bar-line.hh"
/*
Insert some more space for the next note, in case it has a stem in
the wrong direction
-
- */
+*/
Real
-Staff_spacing::next_note_correction (Grob * me,
- Grob * g,
+Staff_spacing::next_note_correction (Grob *me,
+ Grob *g,
Interval bar_size)
{
if (!g || !Note_column::has_interface (g))
return 0.0;
- Item *col = dynamic_cast<Item*> (g)->get_column ();
+ Item *col = dynamic_cast<Item *> (g)->get_column ();
Real max_corr = 0. >? (- g->extent (col, X_AXIS)[LEFT]);
/*
Duh. If this gets out of hand, we should invent something more generic.
- */
- if (Grob * a = Note_column::accidentals (g))
+ */
+ if (Grob *a = Note_column::accidentals (g))
{
Interval v;
if (Accidental_placement::has_interface (a))
}
else
v = a->extent (col, X_AXIS);
-
+
max_corr = max_corr >? (- v[LEFT]);
}
- if (Grob* a = unsmob_grob (g->get_property ("arpeggio")))
+ if (Grob *a = unsmob_grob (g->get_property ("arpeggio")))
{
max_corr = max_corr >? (- a->extent (col, X_AXIS)[LEFT]);
}
-
+
/*
Let's decrease the space a little if the problem is not located
after a barline.
*/
if (bar_size.is_empty ())
max_corr *= 0.75;
-
+
if (!bar_size.is_empty ())
if (Grob *stem = Note_column::get_stem (g))
{
if (d == DOWN)
{
Real stem_start = Stem::head_positions (stem) [DOWN];
- Real stem_end = Stem::stem_end_position (stem);
+ Real stem_end = Stem::stem_end_position (stem);
Interval stem_posns (stem_start <? stem_end,
stem_end >? stem_start);
stem_posns.intersect (bar_size);
- Real corr = abs (stem_posns.length ()/7.) <? 1.0;
- corr *=
- robust_scm2double (me->get_property ("stem-spacing-correction"), 1);
+ Real corr = abs (stem_posns.length () / 7.) <? 1.0;
+ corr
+ *= robust_scm2double (me->get_property ("stem-spacing-correction"), 1);
if (d != DOWN)
corr = 0.0;
return max_corr;
}
-
/*
Y-positions that are covered by BAR_GROB, in the case that it is a
barline. */
if (Bar_line::has_interface (bar_grob))
{
SCM glyph = bar_grob->get_property ("glyph");
-
+
String glyph_string = scm_is_string (glyph) ? ly_scm2string (glyph) : "";
if (glyph_string.left_string (1) == "|" || glyph_string.left_string (1) == ".")
{
This is slightly convoluted, since the staffspacing grob gets
pointers to the separation-items, not the note-columns or
note-spacings.
-
- */
+*/
Real
-Staff_spacing::next_notes_correction (Grob *me, Grob * last_grob)
+Staff_spacing::next_notes_correction (Grob *me, Grob *last_grob)
{
Interval bar_size = bar_y_positions (last_grob);
Real max_corr = 0.0;
for (SCM s = me->get_property ("right-items");
- scm_is_pair (s); s = scm_cdr (s))
+ scm_is_pair (s); s = scm_cdr (s))
{
- Grob * g = unsmob_grob (scm_car (s));
+ Grob *g = unsmob_grob (scm_car (s));
- max_corr = max_corr >? next_note_correction (me, g, bar_size);
+ max_corr = max_corr >? next_note_correction (me, g, bar_size);
for (SCM t = g->get_property ("elements");
- scm_is_pair (t); t = scm_cdr (t))
+ scm_is_pair (t); t = scm_cdr (t))
max_corr = max_corr >? next_note_correction (me, unsmob_grob (scm_car (t)), bar_size);
-
+
}
-
+
return max_corr;
}
void
-Staff_spacing::get_spacing_params (Grob *me, Real * space, Real * fixed)
+Staff_spacing::get_spacing_params (Grob *me, Real *space, Real *fixed)
{
*space = 1.0;
*fixed = 1.0;
- Grob * separation_item = 0;
- Item * me_item = dynamic_cast<Item*> (me);
-
+ Grob *separation_item = 0;
+ Item *me_item = dynamic_cast<Item *> (me);
+
for (SCM s = me->get_property ("left-items");
scm_is_pair (s); s = scm_cdr (s))
{
- Grob * cand = unsmob_grob (scm_car (s));
+ Grob *cand = unsmob_grob (scm_car (s));
if (cand && Separation_item::has_interface (cand))
- separation_item = cand ;
+ separation_item = cand;
}
// printf ("doing col %d\n" , Paper_column::get_rank (left_col));
Interval last_ext;
Grob *last_grob = Separation_item::extremal_break_aligned_grob (separation_item, RIGHT,
- &last_ext);
+ &last_ext);
if (!last_grob)
{
/*
TODO:
-
+
Should insert a adjustable space here? For excercises, you might want to
- use a staff without a clef in the beginning.
- */
-
+ use a staff without a clef in the beginning.
+ */
+
/*
we used to have a warning here, but it generates a lot of
spurious error messages.
*/
- return ;
+ return;
}
*fixed = last_ext[RIGHT];
*space = *fixed + 1.0;
-
+
SCM alist = last_grob->get_property ("space-alist");
if (!scm_list_p (alist))
- return ;
-
+ return;
+
SCM space_def = scm_sloppy_assq (ly_symbol2scm ("first-note"), alist);
if (me_item->break_status_dir () == CENTER)
{
if (scm_is_pair (nndef))
space_def = nndef;
}
-
-
+
if (!scm_is_pair (space_def))
{
- programming_error ("Unknown prefatory spacing. ");
- return;
+ programming_error ("Unknown prefatory spacing. ");
+ return;
}
space_def = scm_cdr (space_def);
Real distance = scm_to_double (scm_cdr (space_def));
- SCM type = scm_car (space_def) ;
+ SCM type = scm_car (space_def);
*fixed = last_ext[RIGHT];
if (type == ly_symbol2scm ("fixed-space"))
{
- *fixed += distance;
- *space = *fixed;
+ *fixed += distance;
+ *space = *fixed;
}
- else if (type == ly_symbol2scm ("extra-space"))
+ else if (type == ly_symbol2scm ("extra-space"))
{
*space = *fixed + distance;
}
else if (type == ly_symbol2scm ("semi-fixed-space"))
{
- *fixed += distance / 2;
- *space = *fixed + distance/2;
+ *fixed += distance / 2;
+ *space = *fixed + distance / 2;
}
else if (type == ly_symbol2scm ("minimum-space"))
{
*space = last_ext[LEFT] + (last_ext.length () >? distance);
*fixed = *space;
}
-
+
*space += next_notes_correction (me, last_grob);
}
-
ADD_INTERFACE (Staff_spacing, "staff-spacing-interface",
"This object calculates spacing details from a "
" breakable symbol (left) to another object. For example, it takes care "
" of optical spacing from a bar lines to a note.",
- "stem-spacing-correction left-items right-items");
+ "stem-spacing-correction left-items right-items");
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#include "score.hh"
#include "paper-column.hh"
#include "output-def.hh"
#include "moment.hh"
/**
- Manage the staff symbol.
- */
-class Staff_symbol_engraver : public Engraver {
+ Manage the staff symbol.
+*/
+class Staff_symbol_engraver : public Engraver
+{
public:
TRANSLATOR_DECLARATIONS (Staff_symbol_engraver);
-
+
protected:
Spanner *span_;
-
+
virtual ~Staff_symbol_engraver ();
virtual void acknowledge_grob (Grob_info);
virtual void finalize ();
virtual void process_music ();
};
-
Staff_symbol_engraver::~Staff_symbol_engraver ()
{
assert (!span_);
if (!span_)
{
span_ = make_spanner ("StaffSymbol", SCM_EOL);
-
+
span_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
-
}
}
}
-
-
ADD_TRANSLATOR (Staff_symbol_engraver,
-/* descr */ "Create the constellation of five (default) "
-"staff lines.",
-/* creats*/ "StaffSymbol",
-/* accepts */ "",
-/* acks */ "grob-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Create the constellation of five (default) "
+ "staff lines.",
+ /* creats*/ "StaffSymbol",
+ /* accepts */ "",
+ /* acks */ "grob-interface",
+ /* reads */ "",
+ /* write */ "");
/****************************************************************/
-
class Tab_staff_symbol_engraver : public Staff_symbol_engraver
{
public:
}
ADD_TRANSLATOR (Tab_staff_symbol_engraver,
-/* descr */ "Create a staff-symbol, but look at stringTunings for the number of lines."
-"staff lines.",
-/* creats*/ "StaffSymbol",
-/* accepts */ "",
-/* acks */ "grob-interface",
-/* reads */ "stringTunings",
-/* write */ "");
+ /* descr */ "Create a staff-symbol, but look at stringTunings for the number of lines."
+ "staff lines.",
+ /* creats*/ "StaffSymbol",
+ /* accepts */ "",
+ /* acks */ "grob-interface",
+ /* reads */ "stringTunings",
+ /* write */ "");
int
Staff_symbol_referencer::line_count (Grob *me)
{
- Grob *st = get_staff_symbol (me);
- return st ? Staff_symbol::line_count (st) : 0;
+ Grob *st = get_staff_symbol (me);
+ return st ? Staff_symbol::line_count (st) : 0;
}
bool
/*
This does not take size into account.
maybe rename: on_virtual_staffline, on_staff_or_ledger_line?
- */
+*/
bool
Staff_symbol_referencer::on_staffline (Grob *me, int pos)
{
return ((pos + sz) % 2) == 0;
}
-Grob*
+Grob *
Staff_symbol_referencer::get_staff_symbol (Grob *me)
{
if (Staff_symbol::has_interface (me))
return me;
-
+
SCM st = me->get_property ("staff-symbol");
return unsmob_grob (st);
}
}
int
-Staff_symbol_referencer::get_rounded_position (Grob*me)
+Staff_symbol_referencer::get_rounded_position (Grob *me)
{
return int (rint (get_position (me)));
}
return scm_make_real (pos);
}
-
/* should use offset callback! */
MAKE_SCHEME_CALLBACK (Staff_symbol_referencer, callback, 2);
SCM
int
compare_position (Grob *const &a, Grob *const &b)
{
- return sign (Staff_symbol_referencer::get_position ((Grob*)a)
- - Staff_symbol_referencer::get_position ((Grob*) b));
+ return sign (Staff_symbol_referencer::get_position ((Grob *)a)
+ - Staff_symbol_referencer::get_position ((Grob *) b));
}
ADD_INTERFACE (Staff_symbol_referencer, "staff-symbol-referencer-interface",
"An object whose Y position is meant relative to a staff "
"symbol. "
"These usually have @code{Staff_symbol_referencer::callback} "
- "in their @code{Y-offset-callbacks}. "
- ,
+ "in their @code{Y-offset-callbacks}. ",
"staff-position");
Staff_symbol::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
- Spanner* sp = dynamic_cast<Spanner*> (me);
- Grob * common
+ Spanner *sp = dynamic_cast<Spanner *> (me);
+ Grob *common
= sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
-
+
Interval span_points (0, 0);
-
/*
For raggedright without ragged staffs, simply set width to the linewidth.
(ok -- lousy UI, since width is in staff spaces)
--hwn.
- */
+ */
Real t = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
t *= robust_scm2double (me->get_property ("thickness"), 1.0);
-
+
Direction d = LEFT;
do
{
don't multiply by Staff_symbol_referencer::staff_space (me),
since that would make aligning staff symbols of different sizes to
one right margin hell.
- */
+ */
span_points[RIGHT] = scm_to_double (width_scm);
}
else
{
- Item * x = sp->get_bound (d);
+ Item *x = sp->get_bound (d);
- span_points[d] = x->relative_coordinate (common , X_AXIS);
+ span_points[d] = x->relative_coordinate (common, X_AXIS);
if (!x->break_status_dir ()
&& !x->extent (x, X_AXIS).is_empty ())
span_points[d] += x->extent (x, X_AXIS)[d];
}
- span_points[d] -= d* t/2;
+ span_points[d] -= d* t / 2;
}
while (flip (&d) != LEFT);
-
int l = Staff_symbol::line_count (me);
-
- Real height = (l-1) * staff_space (me) /2;
- Stencil a =
- Lookup::horizontal_line (span_points
- -me->relative_coordinate (common, X_AXIS),
- t);
+
+ Real height = (l - 1) * staff_space (me) /2;
+ Stencil a
+ = Lookup::horizontal_line (span_points
+ -me->relative_coordinate (common, X_AXIS),
+ t);
Stencil m;
for (int i = 0; i < l; i++)
{
- Stencil b(a);
+ Stencil b (a);
b.translate_axis (height - i * staff_space (me), Y_AXIS);
m.add_stencil (b);
}
}
int
-Staff_symbol::get_steps (Grob*me)
+Staff_symbol::get_steps (Grob *me)
{
return line_count (me) * 2;
}
int
-Staff_symbol::line_count (Grob*me)
+Staff_symbol::line_count (Grob *me)
{
SCM c = me->get_property ("line-count");
if (scm_is_number (c))
}
Real
-Staff_symbol::staff_space (Grob*me)
+Staff_symbol::staff_space (Grob *me)
{
return robust_scm2double (me->get_property ("staff-space"), 1.0);
}
Real
-Staff_symbol::get_line_thickness (Grob* me)
+Staff_symbol::get_line_thickness (Grob *me)
{
- Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
+ Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
return robust_scm2double (me->get_property ("thickness"), 1.0) * lt;
}
Real
-Staff_symbol::get_ledger_line_thickness (Grob * me)
+Staff_symbol::get_ledger_line_thickness (Grob *me)
{
SCM lt_pair = me->get_property ("ledger-line-thickness");
Offset z = robust_scm2offset (lt_pair, Offset (1.0, 0.1));
-
+
return z[X_AXIS] * get_line_thickness (me) + z[Y_AXIS]* staff_space (me);
}
-
ADD_INTERFACE (Staff_symbol, "staff-symbol-interface",
"This spanner draws the lines of a staff. "
"A staff symbol definines a vertical unit, the staff space. "
"The center (i.e. middle line "
"or space) is position 0. The length of the symbol may be set by hand "
"through the @code{width} property. ",
-
- "ledger-line-thickness width staff-space thickness line-count");
+
+ "ledger-line-thickness width staff-space thickness line-count");
-/*
-stanza-number-align-engraver.cc -- implement
+/*
+ stanza-number-align-engraver.cc -- implement
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
- */
+ (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+*/
#include "context.hh"
#include "engraver.hh"
class Stanza_number_align_engraver : public Engraver
{
-public:
+public:
TRANSLATOR_DECLARATIONS (Stanza_number_align_engraver);
-protected:
+protected:
Link_array<Grob> lyrics_;
Link_array<Grob> stanza_numbers_;
virtual void acknowledge_grob (Grob_info);
Stanza_number_align_engraver::Stanza_number_align_engraver ()
{
-
+
}
void
Stanza_number_align_engraver::acknowledge_grob (Grob_info gi)
{
Grob *h = gi.grob_;
-
+
if (h->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
lyrics_.push (h);
else if (h->internal_has_interface (ly_symbol2scm ("stanza-number-interface")))
for (int i = lyrics_.size (); i--;)
for (int j = stanza_numbers_.size (); j--;)
Side_position_interface::add_support (stanza_numbers_[j], lyrics_[i]);
-
+
stanza_numbers_.clear ();
lyrics_.clear ();
}
-
ADD_TRANSLATOR (Stanza_number_align_engraver,
- "This engraver ensures that stanza numbers are neatly aligned. ",
- "",
- "",
- "stanza-number-interface lyric-syllable-interface ",
- "",
- "");
+ "This engraver ensures that stanza numbers are neatly aligned. ",
+ "",
+ "",
+ "stanza-number-interface lyric-syllable-interface ",
+ "",
+ "");
-/*
+/*
lyric-number-engraver.cc -- implement Stanza_number_engraver
-
+
source file of the GNU LilyPond music typesetter
-
- (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>, Glen Prideaux <glenprideaux@iname.com>
+ (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>, Glen Prideaux <glenprideaux@iname.com>
*/
#include "engraver.hh"
This is naughty, since last_stanza_ may be GCd from under us. But
since we don't look at the contents, we are/should be (knock on
wood) OK.
- */
+ */
SCM last_stanza_;
public:
TRANSLATOR_DECLARATIONS (Stanza_number_engraver);
virtual void acknowledge_grob (Grob_info);
};
-
/*
TODO: should make engraver that collects all the stanzas on a higher
level, and then groups them to the side. Stanza numbers should be
all aligned.
- */
+*/
Stanza_number_engraver::Stanza_number_engraver ()
{
Stanza_number_engraver::process_music ()
{
SCM stanza = get_property ("stanza");
-
+
if (scm_is_string (stanza) && stanza != last_stanza_)
{
last_stanza_ = stanza;
-
+
text_ = make_item ("StanzaNumber", SCM_EOL);
text_->set_property ("text", stanza);
-
+
}
}
-
void
Stanza_number_engraver::acknowledge_grob (Grob_info inf)
{
text_ = 0;
}
-
ADD_TRANSLATOR (Stanza_number_engraver,
-/* descr */ "",
-/* creats*/ "StanzaNumber",
-/* accepts */ "",
-/* acks */ "lyric-syllable-interface",
-/* reads */ "stanza",
-/* write */ "");
+ /* descr */ "",
+ /* creats*/ "StanzaNumber",
+ /* accepts */ "",
+ /* acks */ "lyric-syllable-interface",
+ /* reads */ "stanza",
+ /* write */ "");
#include "stem.hh"
/**
- Make stems upon receiving noteheads.
- */
+ Make stems upon receiving noteheads.
+*/
class Stem_engraver : public Engraver
{
Grob *stem_;
Grob *tremolo_;
Music *rhythmic_ev_;
Music *tremolo_ev_;
-
+
TRANSLATOR_DECLARATIONS (Stem_engraver);
protected:
void make_stem (Grob_info);
-
+
virtual void acknowledge_grob (Grob_info);
virtual void stop_translation_timestep ();
virtual bool try_music (Music *);
/*
docme: why do we take duration-log from request, not from note
head?
- */
+ */
int duration_log = gi.music_cause ()->duration_log ();
stem_->set_property ("duration-log", scm_int2num (duration_log));
- (duration_log > 2 ? duration_log - 2 : 0);
if (tremolo_flags <= 0)
{
- tremolo_ev_->origin ()->warning (_("tremolo duration is too long"));
+ tremolo_ev_->origin ()->warning (_ ("tremolo duration is too long"));
tremolo_flags = 0;
}
tremolo_ = make_item ("StemTremolo", tremolo_ev_->self_scm ());
/* The number of tremolo flags is the number of flags of the
- tremolo-type minus the number of flags of the note itself. */
+ tremolo-type minus the number of flags of the note itself. */
tremolo_->set_property ("flag-count", scm_int2num (tremolo_flags));
tremolo_->set_parent (stem_, X_AXIS);
stem_->set_property ("tremolo-flag", tremolo_->self_scm ());
if (Rhythmic_head::get_stem (gi.grob_))
return;
- Music * cause = gi.music_cause ();
+ Music *cause = gi.music_cause ();
if (!cause)
- return ;
-
+ return;
+
if (!stem_)
make_stem (gi);
-
+
int duration_log = cause->duration_log ();
if (Stem::duration_log (stem_) != duration_log)
{
// FIXME:
gi.music_cause ()->origin ()->warning (_f ("Adding note head to incompatible stem (type = %d)", 1 << Stem::duration_log (stem_)));
-
+
gi.music_cause ()->origin ()->warning (_f ("Don't you want polyphonic voices instead?"));
}
}
ADD_TRANSLATOR (Stem_engraver,
-/* descr */ "Create stems and single-stem tremolos. It also works together with "
-"the beam engraver for overriding beaming.",
-/* creats*/ "Stem StemTremolo",
-/* accepts */ "tremolo-event",
-/* acks */ "rhythmic-head-interface",
-/* reads */ "tremoloFlags stemLeftBeamCount stemRightBeamCount",
-/* write */ "");
+ /* descr */ "Create stems and single-stem tremolos. It also works together with "
+ "the beam engraver for overriding beaming.",
+ /* creats*/ "Stem StemTremolo",
+ /* accepts */ "tremolo-event",
+ /* acks */ "rhythmic-head-interface",
+ /* reads */ "tremoloFlags stemLeftBeamCount stemRightBeamCount",
+ /* write */ "");
-/*
+/*
stem-tremolo.cc -- implement Stem_tremolo
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "stem-tremolo.hh"
Stem_tremolo::dim_callback (SCM e, SCM)
{
Grob *se = unsmob_grob (e);
-
+
Real space = Staff_symbol_referencer::staff_space (se);
return ly_interval2scm (Interval (-space, space));
}
Stem_tremolo::raw_stencil (Grob *me)
{
Grob *stem = unsmob_grob (me->get_property ("stem"));
- Spanner*beam = Stem::get_beam (stem);
+ Spanner *beam = Stem::get_beam (stem);
Real dydx;
if (beam)
{
SCM s = beam->get_property ("positions");
if (is_number_pair (s))
dy = -scm_to_double (scm_car (s)) +scm_to_double (scm_cdr (s));
-
+
Real dx = Beam::last_visible_stem (beam)->relative_coordinate (0, X_AXIS)
- Beam::first_visible_stem (beam)->relative_coordinate (0, X_AXIS);
- dydx = dx ? dy/dx : 0;
+ dydx = dx ? dy / dx : 0;
}
else
// urg
width *= ss;
thick *= ss;
-
+
Stencil a (Lookup::beam (dydx, width, thick, blot));
a.translate (Offset (-width * 0.5, width * 0.5 * dydx));
-
+
int tremolo_flags = 0;
SCM s = me->get_property ("flag-count");
if (scm_is_number (s))
/* Who the fuck is 0.81 ? --hwn. */
Real beam_translation = beam ? Beam::get_beam_translation (beam) : 0.81;
- Stencil mol;
+ Stencil mol;
for (int i = 0; i < tremolo_flags; i++)
{
Stencil b (a);
MAKE_SCHEME_CALLBACK (Stem_tremolo, print, 1);
SCM
-Stem_tremolo::print (SCM grob)
+Stem_tremolo::print (SCM grob)
{
Grob *me = unsmob_grob (grob);
Grob *stem = unsmob_grob (me->get_property ("stem"));
programming_error ("No stem for stem-tremolo");
return SCM_EOL;
}
-
+
Spanner *beam = Stem::get_beam (stem);
Direction stemdir = Stem::get_direction (stem);
if (stemdir == 0)
int beam_count = beam ? (Stem::beam_multiplicity (stem).length () + 1) : 0;
Real beamthickness = 0.0;
- SCM sbt = (beam) ? beam->get_property ("thickness") : SCM_EOL ;
+ SCM sbt = (beam) ? beam->get_property ("thickness") : SCM_EOL;
if (scm_is_number (sbt))
beamthickness = scm_to_double (sbt) * ss;
return mol.smobbed_copy ();
}
-
-
ADD_INTERFACE (Stem_tremolo, "stem-tremolo-interface",
- "A beam slashing a stem to indicate a tremolo.",
- "stem beam-width beam-thickness flag-count");
+ "A beam slashing a stem to indicate a tremolo.",
+ "stem beam-width beam-thickness flag-count");
source file of the GNU LilyPond music typesetter
(c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
+ Jan Nieuwenhuizen <janneke@gnu.org>
TODO: This is way too hairy
return scm_ilength (lst);
}
-
Interval
Stem::head_positions (Grob *me)
{
if (head_count (me))
{
- Drul_array<Grob*> e (extremal_heads (me));
+ Drul_array<Grob *> e (extremal_heads (me));
return Interval (Staff_symbol_referencer::get_position (e[DOWN]),
Staff_symbol_referencer::get_position (e[UP]));
}
Direction d = get_direction (me);
if (d)
return extremal_heads (me)[d];
- return 0;
+ return 0;
}
/*
START is part where stem reaches `last' head.
- This function returns a drul with (bottom-head, top-head).
-
+ This function returns a drul with (bottom-head, top-head).
*/
-Drul_array<Grob*>
+Drul_array<Grob *>
Stem::extremal_heads (Grob *me)
{
const int inf = 1000000;
exthead[d] = n;
extpos[d] = p;
}
- } while (flip (&d) != DOWN);
+ }
+ while (flip (&d) != DOWN);
+
}
return exthead;
}
Array<int>
Stem::note_head_positions (Grob *me)
{
- Array<int> ps ;
+ Array<int> ps;
for (SCM s = me->get_property ("note-heads"); scm_is_pair (s);
s = scm_cdr (s))
{
{
Real stemlet_length = robust_scm2double (me->get_property ("stemlet-length"),
0.0);
-
+
return !((head_count (me)
|| stemlet_length > 0.0)
&& scm_to_int (me->get_property ("duration-log")) >= 1);
if (hp.is_empty ())
return CENTER;
- int udistance = (int) (UP * hp[UP] - staff_center);
- int ddistance = (int) (DOWN * hp[DOWN] - staff_center);
+ int udistance = (int) (UP *hp[UP] - staff_center);
+ int ddistance = (int) (DOWN *hp[DOWN] - staff_center);
if (sign (ddistance - udistance))
return Direction (sign (ddistance - udistance));
{
/* Crude hack: add extra space if tremolo flag is there.
- We can't do this for the beam, since we get into a loop
- (Stem_tremolo::raw_stencil () looks at the beam.) --hwn */
+ We can't do this for the beam, since we get into a loop
+ (Stem_tremolo::raw_stencil () looks at the beam.) --hwn */
Real minlen = 1.0
- + 2 * Stem_tremolo::raw_stencil (t_flag).extent (Y_AXIS).length ()
+ + 2 * Stem_tremolo::raw_stencil (t_flag).extent (Y_AXIS).length ()
/ ss;
if (durlog >= 3)
if (!get_beam (me) && dir == UP
&& durlog > 2)
{
- Grob * closest_to_flag = extremal_heads (me)[dir];
- Grob * dots = closest_to_flag
- ? Rhythmic_head::get_dots (closest_to_flag ) : 0;
+ Grob *closest_to_flag = extremal_heads (me)[dir];
+ Grob *dots = closest_to_flag
+ ? Rhythmic_head::get_dots (closest_to_flag) : 0;
if (dots)
{
if (!head_count (me))
return;
- Link_array<Grob> heads =
- extract_grob_array (me, ly_symbol2scm ("note-heads"));
+ Link_array<Grob> heads
+ = extract_grob_array (me, ly_symbol2scm ("note-heads"));
heads.sort (compare_position);
Direction dir = get_direction (me);
bool parity = true;
Real lastpos = Real (Staff_symbol_referencer::get_position (heads[0]));
- for (int i = 1; i < heads.size (); i ++)
+ for (int i = 1; i < heads.size (); i++)
{
Real p = Staff_symbol_referencer::get_position (heads[i]);
Real dy = fabs (lastpos- p);
/*
- dy should always be 0.5, 0.0, 1.0, but provide safety margin
- for rounding errors.
+ dy should always be 0.5, 0.0, 1.0, but provide safety margin
+ for rounding errors.
*/
- if (dy < 1.1)
+ if (dy < 1.1)
{
if (parity)
{
heads[i]->translate_axis (-thick * (2 - reverse_overlap) * d,
X_AXIS);
- /* TODO:
-
+ /* TODO:
+
For some cases we should kern some more: when the
distance between the next or prev note is too large, we'd
get large white gaps, eg.
-
- |
+
+ |
X|
- |X <- kern this.
- |
+ |X <- kern this.
+ |
X
-
+
*/
}
parity = !parity;
/*
Do the calculations for visible stems, but also for invisible stems
with note heads (i.e. half notes.)
- */
+ */
if (head_count (me))
{
stem_end_position (me); // ugh. Trigger direction calc.
position_noteheads (me);
}
-
+
return SCM_UNSPECIFIED;
}
ugh.
When in a beam with tuplet brackets, brew_mol is called early,
caching a wrong value.
- */
+*/
MAKE_SCHEME_CALLBACK (Stem, height, 2);
SCM
Stem::height (SCM smob, SCM ax)
programming_error ("No stem direction");
d = UP;
}
- iv[d] += d * Beam::get_thickness (b) * 0.5 ;
+ iv[d] += d * Beam::get_thickness (b) * 0.5;
}
return ly_interval2scm (iv);
}
-
Stencil
Stem::flag (Grob *me)
{
SCM flag_style_scm = me->get_property ("flag-style");
if (scm_is_symbol (flag_style_scm))
flag_style = ly_symbol2string (flag_style_scm);
-
+
if (flag_style == "no-flag")
return Stencil ();
{
if (adjust)
{
- int p = (int)(rint (stem_end_position (me)));
- staffline_offs =
- Staff_symbol_referencer::on_staffline (me, p) ? "0" : "1";
+ int p = (int) (rint (stem_end_position (me)));
+ staffline_offs
+ = Staff_symbol_referencer::on_staffline (me, p) ? "0" : "1";
}
else
{
Grob *me = unsmob_grob (e);
Interval r;
-
+
if (is_invisible (me))
{
r.set_empty ();
- }
+ }
else if (unsmob_grob (me->get_property ("beam")) || abs (duration_log (me)) <= 2)
{
r = Interval (-1, 1);
- r *= thickness (me)/2;
+ r *= thickness (me) / 2;
}
else
{
r = flag (me).extent (X_AXIS)
- + thickness (me)/2;
- }
+ + thickness (me) / 2;
+ }
return ly_interval2scm (r);
}
Real stemlet_length = robust_scm2double (me->get_property ("stemlet-length"),
0.0);
bool stemlet = stemlet_length > 0.0;
-
+
/* TODO: make the stem start a direction ?
This is required to avoid stems passing in tablature chords. */
- Grob *lh =
- to_boolean (me->get_property ("avoid-note-head"))
+ Grob *lh
+ = to_boolean (me->get_property ("avoid-note-head"))
? last_head (me)
: first_head (me);
Grob *beam = get_beam (me);
if (!lh && stemlet && !beam)
return SCM_EOL;
-
+
if (is_invisible (me))
return SCM_EOL;
Real y1 = y2;
Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5;
-
if (lh)
y2 = Staff_symbol_referencer::get_position (lh);
else if (stemlet)
{
/*
must not take ledgers into account.
- */
+ */
Interval head_height = hed->extent (hed, Y_AXIS);
Real y_attach = Note_head::stem_attachment_coordinate (hed, Y_AXIS);
y_attach = head_height.linear_combination (y_attach);
- stem_y[Direction (-d)] += d * y_attach/half_space;
+ stem_y[Direction (-d)] += d * y_attach / half_space;
}
-
// URG
Real stem_width = thickness (me);
- Real blot =
- me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
+ Real blot
+ = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
- Box b = Box (Interval (-stem_width/2, stem_width/2),
+ Box b = Box (Interval (-stem_width / 2, stem_width / 2),
Interval (stem_y[DOWN]*half_space, stem_y[UP]*half_space));
Stencil ss = Lookup::round_filled_box (b, blot);
if (!get_beam (me) && abs (duration_log (me)) > 2)
{
Stencil fl = flag (me);
- fl.translate_axis (stem_y[d]*half_space - d * blot/2, Y_AXIS);
- fl.translate_axis (stem_width/2, X_AXIS);
+ fl.translate_axis (stem_y[d]*half_space - d * blot / 2, Y_AXIS);
+ fl.translate_axis (stem_width / 2, X_AXIS);
mol.add_stencil (fl);
}
/*
move the stem to right of the notehead if it is up.
- */
+*/
MAKE_SCHEME_CALLBACK (Stem, offset_callback, 2);
SCM
Stem::offset_callback (SCM element_smob, SCM)
{
Grob *me = unsmob_grob (element_smob);
Real r = 0.0;
-
+
if (Grob *f = first_head (me))
{
Interval head_wid = f->extent (f, X_AXIS);
Real attach = 0.0;
-
+
if (is_invisible (me))
attach = 0.0;
else
attach = Note_head::stem_attachment_coordinate (f, X_AXIS);
-
+
Direction d = get_direction (me);
Real real_attach = head_wid.linear_combination (d * attach);
r = real_attach;
-
+
/* If not centered: correct for stem thickness. */
if (attach)
{
Real rule_thick = thickness (me);
- r += - d * rule_thick * 0.5;
+ r += -d * rule_thick * 0.5;
}
}
else
SCM rests = me->get_property ("rests");
if (scm_is_pair (rests))
{
- Grob * rest = unsmob_grob (scm_car (rests));
+ Grob *rest = unsmob_grob (scm_car (rests));
r = rest->extent (rest, X_AXIS).center ();
}
}
Stem::get_beam (Grob *me)
{
SCM b = me->get_property ("beam");
- return dynamic_cast<Spanner*> (unsmob_grob (b));
+ return dynamic_cast<Spanner *> (unsmob_grob (b));
}
Stem_info
return si;
}
-
/* TODO: add extra space for tremolos! */
void
Stem::calc_stem_info (Grob *me)
if (!my_dir)
{
programming_error ("No stem dir set?");
- my_dir = UP;
+ my_dir = UP;
}
Real staff_space = Staff_symbol_referencer::staff_space (me);
Real beam_thickness = Beam::get_thickness (beam);
int beam_count = Beam::get_direction_beam_count (beam, my_dir);
-
/* Simple standard stem length */
SCM lengths = me->get_property ("beamed-lengths");
- Real ideal_length =
- scm_to_double (robust_list_ref (beam_count - 1, lengths))
-
+ Real ideal_length
+ = scm_to_double (robust_list_ref (beam_count - 1, lengths))
+
* staff_space
/* stem only extends to center of beam
- */
- - 0.5 * beam_thickness
- ;
+ */
+ - 0.5 * beam_thickness;
/* Condition: sane minimum free stem length (chord to beams) */
lengths = me->get_property ("beamed-minimum-free-lengths");
- Real ideal_minimum_free =
- scm_to_double (robust_list_ref (beam_count - 1, lengths))
+ Real ideal_minimum_free
+ = scm_to_double (robust_list_ref (beam_count - 1, lengths))
* staff_space;
-
/* UGH
It seems that also for ideal minimum length, we must use
the maximum beam count (for this direction):
ideal_length = ideal_length >? ideal_minimum_length;
/* Convert to Y position, calculate for dir == UP */
- Real note_start =
- /* staff positions */
+ Real note_start
+ = /* staff positions */
head_positions (me)[my_dir] * 0.5
* my_dir * staff_space;
Real ideal_y = note_start + ideal_length;
-
/* Conditions for Y position */
/* Lowest beam of (UP) beam must never be lower than second staffline
- Reference?
+ Reference?
- Although this (additional) rule is probably correct,
- I expect that highest beam (UP) should also never be lower
- than middle staffline, just as normal stems.
+ Although this (additional) rule is probably correct,
+ I expect that highest beam (UP) should also never be lower
+ than middle staffline, just as normal stems.
- Reference?
+ Reference?
- Obviously not for grace beams.
+ Obviously not for grace beams.
- Also, not for knees. Seems to be a good thing. */
+ Also, not for knees. Seems to be a good thing. */
bool no_extend_b = to_boolean (me->get_property ("no-stem-extend"));
bool is_knee = to_boolean (beam->get_property ("knee"));
if (!no_extend_b && !is_knee)
{
/* Highest beam of (UP) beam must never be lower than middle
staffline */
- ideal_y = ideal_y >? 0;
+ ideal_y = ideal_y >? 0;
/* Lowest beam of (UP) beam must never be lower than second staffline */
- ideal_y = ideal_y >? (-staff_space
+ ideal_y = ideal_y >? (-staff_space
- beam_thickness + height_of_my_beams);
}
-
ideal_y -= robust_scm2double (beam->get_property ("shorten"), 0);
- Real minimum_free =
- scm_to_double (robust_list_ref
- (beam_count - 1,
- me->get_property
- ("beamed-extreme-minimum-free-lengths")))
+ Real minimum_free
+ = scm_to_double (robust_list_ref
+ (beam_count - 1,
+ me->get_property
+ ("beamed-extreme-minimum-free-lengths")))
* staff_space;
Real minimum_length = minimum_free
return le;
}
-
/* FIXME: Too many properties */
ADD_INTERFACE (Stem, "stem-interface",
"The stem represent the graphical stem. "
#include <math.h>
-#include <libc-extension.hh> // isinf
+#include <libc - extension.hh> // isinf
#include "font-metric.hh"
#include "stencil.hh"
/*
TODO: naming add/combine.
- */
+*/
/*
UGH. Junk all mutators.
- */
+*/
LY_DEFINE (ly_stencil_set_extent_x, "ly:stencil-set-extent!",
3, 0, 0, (SCM stil, SCM axis, SCM np),
"Set the extent of @var{stil} "
SCM_ASSERT_TYPE (!isinf (real_amount) && !isnan (real_amount),
amount, SCM_ARG2, __FUNCTION__, "finite number");
#endif
-
+
SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
SCM new_s = s->smobbed_copy ();
return ly_interval2scm (s->extent (Axis (scm_to_int (axis))));
}
-
LY_DEFINE (ly_stencil_empty_p, "ly:stencil-empty?",
1, 0, 0, (SCM stil),
"Return whether @var{stil} is empty ")
return scm_from_bool (s->is_empty ());
}
-
LY_DEFINE (ly_stencil_origin, "ly:stencil-origin",
2, 0, 0, (SCM stil, SCM axis),
"Return a pair of numbers signifying the origin @var{stil} in "
SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil");
SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
- return scm_from_double (s->origin()[Axis (scm_to_int (axis))]);
+ return scm_from_double (s->origin ()[Axis (scm_to_int (axis))]);
}
-
LY_DEFINE (ly_stencil_moved_to_edge, "ly:stencil-moved-to-edge",
4, 2, 0, (SCM first, SCM axis, SCM direction, SCM second,
SCM padding, SCM minimum),
{
/*
C&P from combine-at-edge.
- */
+ */
Stencil *s1 = unsmob_stencil (first);
Stencil *s2 = unsmob_stencil (second);
Stencil first_stencil;
Direction (scm_to_int (direction)),
*s2, p, m).smobbed_copy ();
else
- return Stencil().smobbed_copy ();
+ return Stencil ().smobbed_copy ();
}
-
-
LY_DEFINE (ly_stencil_combine_at_edge, "ly:stencil-combine-at-edge",
- 4, 2, 0, (SCM first, SCM axis, SCM direction,
- SCM second,
- SCM padding,
- SCM minimum),
+ 4, 2, 0, (SCM first, SCM axis, SCM direction,
+ SCM second,
+ SCM padding,
+ SCM minimum),
"Construct a stencil by putting @var{second} next to @var{first}. "
"@var{axis} can be 0 (x-axis) or 1 (y-axis), "
"@var{direction} can be -1 (left or down) or 1 (right or up). "
Stencil *s2 = unsmob_stencil (second);
Stencil result;
- SCM_ASSERT_TYPE (s1 || first == SCM_BOOL_F || first == SCM_EOL,
+ SCM_ASSERT_TYPE (s1 || first == SCM_BOOL_F || first == SCM_EOL,
first, SCM_ARG1, __FUNCTION__, "Stencil, #f or ()");
- SCM_ASSERT_TYPE (s2 || second == SCM_BOOL_F || second == SCM_EOL,
+ SCM_ASSERT_TYPE (s2 || second == SCM_BOOL_F || second == SCM_EOL,
second, SCM_ARG4, __FUNCTION__, "Stencil, #f or ()");
SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
SCM_ASSERT_TYPE (is_direction (direction), direction, SCM_ARG3, __FUNCTION__, "dir");
if (s1)
result = *s1;
-
+
if (s2)
result.add_at_edge (Axis (scm_to_int (axis)),
Direction (scm_to_int (direction)), *s2, p, m);
return result.smobbed_copy ();
}
-LY_DEFINE (ly_stencil_add , "ly:stencil-add",
+LY_DEFINE (ly_stencil_add, "ly:stencil-add",
0, 0, 1, (SCM args),
"Combine stencils. Takes any number of arguments.")
{
}
LY_DEFINE (ly_make_stencil, "ly:make-stencil",
- 3, 0, 0, (SCM expr, SCM xext, SCM yext),
+ 3, 0, 0, (SCM expr, SCM xext, SCM yext),
" \n"
"Stencils are a device independent output expressions."
"They carry two pieces of information: \n\n"
return s.smobbed_copy ();
}
-
LY_DEFINE (ly_stencil_align_to_x, "ly:stencil-align-to!",
3, 0, 0, (SCM stil, SCM axis, SCM dir),
"Align @var{stil} using its own extents. "
return stil;
}
-
LY_DEFINE (ly_stencil_fonts, "ly:stencil-fonts",
1, 0, 0, (SCM s),
- " Analyse @var{s}, and return a list of fonts used in @var{s}.")
+ " Analyse @var{s}, and return a list of fonts used in @var{s}.")
{
Stencil *stil = unsmob_stencil (s);
SCM_ASSERT_TYPE (stil, s, SCM_ARG1, __FUNCTION__, "Stencil");
return find_expression_fonts (stil->expr ());
}
-
struct Stencil_interpret_arguments
{
SCM func;
void stencil_interpret_in_scm (void *p, SCM expr)
{
- Stencil_interpret_arguments *ap = (Stencil_interpret_arguments*) p;
+ Stencil_interpret_arguments *ap = (Stencil_interpret_arguments *) p;
scm_call_2 (ap->func, ap->arg1, expr);
}
LY_DEFINE (ly_interpret_stencil_expression, "ly:interpret-stencil-expression",
- 4, 0, 0, (SCM expr, SCM func, SCM arg1, SCM offset),
- "Parse EXPR, feed bits to FUNC with first arg ARG1")
+ 4, 0, 0, (SCM expr, SCM func, SCM arg1, SCM offset),
+ "Parse EXPR, feed bits to FUNC with first arg ARG1")
{
- SCM_ASSERT_TYPE (ly_c_procedure_p(func), func, SCM_ARG1, __FUNCTION__,
+ SCM_ASSERT_TYPE (ly_c_procedure_p (func), func, SCM_ARG1, __FUNCTION__,
"procedure");
Stencil_interpret_arguments a;
a.arg1 = arg1;
Offset o = ly_scm2offset (offset);
- interpret_stencil_expression (expr, stencil_interpret_in_scm, (void*) &a, o);
+ interpret_stencil_expression (expr, stencil_interpret_in_scm, (void *) &a, o);
return SCM_UNSPECIFIED;
}
-
-
-LY_DEFINE (ly_bracket , "ly:bracket",
- 4, 0, 0,
- (SCM a, SCM iv, SCM t, SCM p),
- "Make a bracket in direction @var{a}. The extent of the bracket is "
- "given by @var{iv}. The wings protude by an amount of @var{p}, which "
- "may be negative. The thickness is given by @var{t}.")
+LY_DEFINE (ly_bracket, "ly:bracket",
+ 4, 0, 0,
+ (SCM a, SCM iv, SCM t, SCM p),
+ "Make a bracket in direction @var{a}. The extent of the bracket is "
+ "given by @var{iv}. The wings protude by an amount of @var{p}, which "
+ "may be negative. The thickness is given by @var{t}.")
{
- SCM_ASSERT_TYPE (is_axis (a), a, SCM_ARG1, __FUNCTION__, "axis") ;
- SCM_ASSERT_TYPE (is_number_pair (iv), iv, SCM_ARG2, __FUNCTION__, "number pair") ;
- SCM_ASSERT_TYPE (scm_is_number (t), a, SCM_ARG3, __FUNCTION__, "number") ;
- SCM_ASSERT_TYPE (scm_is_number (p), a, SCM_ARG4, __FUNCTION__, "number") ;
-
+ SCM_ASSERT_TYPE (is_axis (a), a, SCM_ARG1, __FUNCTION__, "axis");
+ SCM_ASSERT_TYPE (is_number_pair (iv), iv, SCM_ARG2, __FUNCTION__, "number pair");
+ SCM_ASSERT_TYPE (scm_is_number (t), a, SCM_ARG3, __FUNCTION__, "number");
+ SCM_ASSERT_TYPE (scm_is_number (p), a, SCM_ARG4, __FUNCTION__, "number");
return Lookup::bracket ((Axis)scm_to_int (a), ly_scm2interval (iv),
scm_to_double (t),
0.95 * scm_to_double (t)).smobbed_copy ();
}
-
-
-LY_DEFINE (ly_filled_box , "ly:round-filled-box",
- 3, 0, 0,
- (SCM xext, SCM yext, SCM blot),
- "Make a @code{Stencil} "
- "that prints a black box of dimensions @var{xext}, "
- "@var{yext} and roundness @var{blot}."
- )
+LY_DEFINE (ly_filled_box, "ly:round-filled-box",
+ 3, 0, 0,
+ (SCM xext, SCM yext, SCM blot),
+ "Make a @code{Stencil} "
+ "that prints a black box of dimensions @var{xext}, "
+ "@var{yext} and roundness @var{blot}.")
{
- SCM_ASSERT_TYPE (is_number_pair (xext), xext, SCM_ARG1, __FUNCTION__, "number pair") ;
- SCM_ASSERT_TYPE (is_number_pair (yext), yext, SCM_ARG2, __FUNCTION__, "number pair") ;
- SCM_ASSERT_TYPE (scm_is_number (blot), blot, SCM_ARG3, __FUNCTION__, "number") ;
+ SCM_ASSERT_TYPE (is_number_pair (xext), xext, SCM_ARG1, __FUNCTION__, "number pair");
+ SCM_ASSERT_TYPE (is_number_pair (yext), yext, SCM_ARG2, __FUNCTION__, "number pair");
+ SCM_ASSERT_TYPE (scm_is_number (blot), blot, SCM_ARG3, __FUNCTION__, "number");
return Lookup::round_filled_box (Box (ly_scm2interval (xext), ly_scm2interval (yext)),
scm_to_double (blot)).smobbed_copy ();
#include <math.h>
-#include <libc-extension.hh> // isinf
+#include <libc - extension.hh> // isinf
#include "input-smob.hh"
#include "font-metric.hh"
SCM
Stencil::mark_smob (SCM smob)
{
- Stencil *s = (Stencil*) SCM_CELL_WORD_1 (smob);
+ Stencil *s = (Stencil *) SCM_CELL_WORD_1 (smob);
return s->expr_;
}
programming_error (String_convert::form_string ("Improbable offset for stencil: %f staff space", o[a])
+ "\n"
+ "Setting to zero.");
- o[a] = 0.0;
+ o[a] = 0.0;
}
incr (a);
}
dim_.unite (s.dim_);
}
-
-
void
Stencil::set_empty (bool e)
{
toadd.translate_axis (offset, a);
if (minimum > 0 && d * (-origin ()[a] + toadd.origin ()[a]) < minimum)
- toadd.translate_axis ( -toadd.origin ()[a]
- + origin ()[a] + d * minimum, a);
+ toadd.translate_axis (-toadd.origin ()[a]
+ + origin ()[a] + d * minimum, a);
return toadd;
}
add_stencil (moved_to_edge (a, d, s, padding, minimum));
}
-
/****************************************************************/
-
void
interpret_stencil_expression (SCM expr,
- void (*func) (void*, SCM),
+ void (*func) (void *, SCM),
void *func_arg,
Offset o)
{
while (1)
{
if (!scm_is_pair (expr))
- return;
+ return;
SCM head = scm_car (expr);
if (head == ly_symbol2scm ("translate-stencil"))
- {
- o += ly_scm2offset (scm_cadr (expr));
- expr = scm_caddr (expr);
- }
+ {
+ o += ly_scm2offset (scm_cadr (expr));
+ expr = scm_caddr (expr);
+ }
else if (head == ly_symbol2scm ("combine-stencil"))
- {
- for (SCM x = scm_cdr (expr); scm_is_pair (x); x = scm_cdr (x))
+ {
+ for (SCM x = scm_cdr (expr); scm_is_pair (x); x = scm_cdr (x))
interpret_stencil_expression (scm_car (x), func, func_arg, o);
- return;
- }
+ return;
+ }
else if (head == ly_symbol2scm ("grob-cause"))
{
SCM grob = scm_cadr (expr);
-
+
(*func) (func_arg, scm_list_3 (head,
ly_quote_scm (ly_offset2scm (o)), grob));
interpret_stencil_expression (scm_caddr (expr), func, func_arg, o);
return;
}
else if (head == ly_symbol2scm ("color"))
- {
+ {
SCM color = scm_cadr (expr);
SCM r = scm_car (color);
SCM g = scm_cadr (color);
(*func) (func_arg, scm_list_4 (ly_symbol2scm ("setcolor"), r, g, b));
interpret_stencil_expression (scm_caddr (expr), func, func_arg, o);
(*func) (func_arg, scm_list_1 (ly_symbol2scm ("resetcolor")));
-
+
return;
- }
+ }
else
- {
- (*func) (func_arg,
- scm_list_4 (ly_symbol2scm ("placebox"),
- scm_make_real (o[X_AXIS]),
- scm_make_real (o[Y_AXIS]),
- expr));
- return;
- }
+ {
+ (*func) (func_arg,
+ scm_list_4 (ly_symbol2scm ("placebox"),
+ scm_make_real (o[X_AXIS]),
+ scm_make_real (o[Y_AXIS]),
+ expr));
+ return;
+ }
}
}
-
struct Font_list
{
SCM fonts_;
static void
find_font_function (void *fs, SCM x)
{
- Font_list *me = (Font_list*) fs;
+ Font_list *me = (Font_list *) fs;
if (scm_car (x) == ly_symbol2scm ("placebox"))
{
SCM what = scm_caddr (args);
if (scm_is_pair (what))
- {
- SCM head = scm_car (what);
- if (ly_symbol2scm ("text") == head)
- me->fonts_ = scm_cons (scm_cadr (what), me->fonts_);
- else if (head == ly_symbol2scm ("char"))
- me->fonts_ = scm_cons (scm_cadr (what), me->fonts_);
- }
+ {
+ SCM head = scm_car (what);
+ if (ly_symbol2scm ("text") == head)
+ me->fonts_ = scm_cons (scm_cadr (what), me->fonts_);
+ else if (head == ly_symbol2scm ("char"))
+ me->fonts_ = scm_cons (scm_cadr (what), me->fonts_);
+ }
}
}
fl.fonts_ = SCM_EOL;
interpret_stencil_expression (expr, &find_font_function,
- (void*) &fl, Offset (0, 0));
+ (void *) &fl, Offset (0, 0));
return fl.fonts_;
}
-
source file of the GNU LilyPond music typesetter
(c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "engraver.hh"
public:
TRANSLATOR_DECLARATIONS (String_number_engraver);
protected:
- virtual bool try_music (Music* m);
+ virtual bool try_music (Music *m);
};
-
bool
-String_number_engraver::try_music (Music * )
+String_number_engraver::try_music (Music *)
{
return true;
}
/*
TODO: string numbers are printed right of the note circled. This
engraver should provide this functionality.
-
- */
+*/
ADD_TRANSLATOR (String_number_engraver,
-/* descr */ "Swallow string-number-events - the purpose of this engraver is to"
-" process tab for normal notation. To provent warnings for unprocessed "
-" string-number-event to obscure real error messages, this engraver "
-" swallows them all.",
-
-/* creats*/ "",
-/* accepts */ "string-number-event",
-/* acks */ "",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Swallow string-number-events - the purpose of this engraver is to"
+ " process tab for normal notation. To provent warnings for unprocessed "
+ " string-number-event to obscure real error messages, this engraver "
+ " swallows them all.",
+
+ /* creats*/ "",
+ /* accepts */ "string-number-event",
+ /* acks */ "",
+ /* reads */ "",
+ /* write */ "");
-/*
+/*
sustain-pedal.cc -- implement Sustain_pedal
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "grob.hh"
#include "stencil.hh"
#include "font-interface.hh"
Urg.
This is almost text
Problem is:
- * we have no kerning
- * symbols are at wrong place in font
+ * we have no kerning
+ * symbols are at wrong place in font
Properties:
glyph -- text string (TODO: make one large glyph of the Ped symbol, removes need for member_print ())
-
*/
-
/*
- FIXME. Need to use markup.
- */
+ FIXME. Need to use markup.
+*/
struct Sustain_pedal
{
public:
DECLARE_SCHEME_CALLBACK (print, (SCM));
};
-
MAKE_SCHEME_CALLBACK (Sustain_pedal, print, 1);
SCM
-Sustain_pedal::print (SCM smob)
+Sustain_pedal::print (SCM smob)
{
- Grob * e = unsmob_grob (smob);
-
+ Grob *e = unsmob_grob (smob);
+
Stencil mol;
SCM glyph = e->get_property ("text");
if (!scm_is_string (glyph))
return mol.smobbed_copy ();
-
+
String text = ly_scm2string (glyph);
for (int i = 0; i < text.length (); i++)
if (!m.is_empty ())
mol.add_at_edge (X_AXIS, RIGHT, m, 0, 0);
}
-
+
return mol.smobbed_copy ();
}
public:
TRANSLATOR_DECLARATIONS (Swallow_engraver);
protected:
- bool try_music (Music*) ;
+ bool try_music (Music *);
};
bool
-Swallow_engraver::try_music (Music*)
+Swallow_engraver::try_music (Music *)
{
return true;
}
}
ADD_TRANSLATOR (Swallow_engraver,
-/* descr */ "This engraver swallows everything given to it silently. The purpose of "
- "this is to prevent spurious \"event junked\" warnings.",
-/* creats*/ "",
-/* accepts */ "general-music",
-/* acks */ "",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "This engraver swallows everything given to it silently. The purpose of "
+ "this is to prevent spurious \"event junked\" warnings.",
+ /* creats*/ "",
+ /* accepts */ "general-music",
+ /* acks */ "",
+ /* reads */ "",
+ /* write */ "");
public:
TRANSLATOR_DECLARATIONS (Swallow_performer);
protected:
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
};
bool
|| m->is_mus_type ("melisma-playing-event"))
return false;
else
- return true;
+ return true;
}
Swallow_performer::Swallow_performer ()
{}
ADD_TRANSLATOR (Swallow_performer,
-/* descr */ "",
-/* creats*/ "",
-/* accepts */ "general-music",
-/* acks */ "",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "",
+ /* creats*/ "",
+ /* accepts */ "general-music",
+ /* acks */ "",
+ /* reads */ "",
+ /* write */ "");
-/*
+/*
system-start-delimiter-engraver.cc -- implement System_start_delimiter_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "system-start-delimiter.hh"
#include "engraver.hh"
TRANSLATOR_DECLARATIONS (System_start_delimiter_engraver);
protected:
- Spanner * delim_;
+ Spanner *delim_;
virtual void acknowledge_grob (Grob_info);
virtual void process_music ();
virtual void finalize ();
};
-
-
void
System_start_delimiter_engraver::acknowledge_grob (Grob_info inf)
{
/*
don't add as Axis_group_interface::add_element (delim_, ),
because that would set the parent as well */
-
- Pointer_group_interface::add_grob (delim_, ly_symbol2scm ("elements"), inf.grob_);
+
+ Pointer_group_interface::add_grob (delim_, ly_symbol2scm ("elements"), inf.grob_);
}
else if (System_start_delimiter::has_interface (inf.grob_))
{
/*
UGH UGH
- */
- if (scm_is_string (gl) && ly_c_equal_p (gl, scm_makfrom0str ("brace"))
- && scm_is_string (my_gl) && ly_c_equal_p (my_gl, scm_makfrom0str ("bracket")))
+ */
+ if (scm_is_string (gl) && ly_c_equal_p (gl, scm_makfrom0str ("brace"))
+ && scm_is_string (my_gl) && ly_c_equal_p (my_gl, scm_makfrom0str ("bracket")))
inf.grob_->translate_axis (-0.8, X_AXIS); // ugh
- else if (scm_is_string (gl) && ly_c_equal_p (gl, scm_makfrom0str ("bracket"))
- && scm_is_string (my_gl) && ly_c_equal_p (my_gl, scm_makfrom0str ("bracket")))
- {
- inf.grob_->translate_axis ( -0.8, X_AXIS); // ugh
- inf.grob_->set_property ("arch-height",
- scm_make_real (scm_to_double (inf.grob_->get_property
- ("arch-height"))+0.5));
- }
+ else if (scm_is_string (gl) && ly_c_equal_p (gl, scm_makfrom0str ("bracket"))
+ && scm_is_string (my_gl) && ly_c_equal_p (my_gl, scm_makfrom0str ("bracket")))
+ {
+ inf.grob_->translate_axis (-0.8, X_AXIS); // ugh
+ inf.grob_->set_property ("arch-height",
+ scm_make_real (scm_to_double (inf.grob_->get_property
+ ("arch-height")) + 0.5));
+ }
}
}
{
SCM delim_name = get_property ("systemStartDelimiter");
delim_ = make_spanner_from_properties (this, delim_name, SCM_EOL,
- ly_symbol2string (delim_name).to_str0());
+ ly_symbol2string (delim_name).to_str0 ());
delim_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
-
+
}
}
void
if (delim_)
{
delim_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
-
+
}
}
ADD_TRANSLATOR (System_start_delimiter_engraver,
-/* descr */ "Creates a system start delimiter (ie. SystemStart@{Bar, Brace, Bracket@} spanner",
-/* creats*/ "SystemStartBar SystemStartBrace SystemStartBracket",
-/* accepts */ "",
-/* acks */ "system-start-delimiter-interface staff-symbol-interface",
-/* reads */ "systemStartDelimiter",
-/* write */ "");
+ /* descr */ "Creates a system start delimiter (ie. SystemStart@{Bar, Brace, Bracket@} spanner",
+ /* creats*/ "SystemStartBar SystemStartBrace SystemStartBracket",
+ /* accepts */ "",
+ /* acks */ "system-start-delimiter-interface staff-symbol-interface",
+ /* reads */ "systemStartDelimiter",
+ /* write */ "");
-/*
+/*
system-start-delimiter.cc -- implement System_start_delimiter
source file of the GNU LilyPond music typesetter
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "system-start-delimiter.hh"
#include "lookup.hh"
Stencil
-System_start_delimiter::staff_bracket (Grob*me, Real height)
+System_start_delimiter::staff_bracket (Grob *me, Real height)
{
- Real arc_height = scm_to_double (me->get_property ("arch-height")) ;
+ Real arc_height = scm_to_double (me->get_property ("arch-height"));
SCM at = scm_list_n (ly_symbol2scm ("bracket"),
- me->get_property ("arch-angle"),
- me->get_property ("arch-width"),
- scm_make_real (arc_height),
- scm_make_real (height),
- me->get_property ("arch-thick"),
- me->get_property ("thickness"),
- SCM_UNDEFINED);
+ me->get_property ("arch-angle"),
+ me->get_property ("arch-width"),
+ scm_make_real (arc_height),
+ scm_make_real (height),
+ me->get_property ("arch-thick"),
+ me->get_property ("thickness"),
+ SCM_UNDEFINED);
-/*
-TODO: sort this out.
-
-Another thing:
-In system-start-delimiter.cc I see the line
+ /*
+ TODO: sort this out.
- Real h = height + 2 * arc_height;
+ Another thing:
+ In system-start-delimiter.cc I see the line
+
+ Real h = height + 2 * arc_height;
-But I really think that you mean
+ But I really think that you mean
- Real h = height + 2 * arc_width;
+ Real h = height + 2 * arc_width;
-(arc_height changes the x-axis-size of arc ; arc_width changes the
-y-axis-size)
-Will not fix it since I'm not sure.
+ (arc_height changes the x-axis-size of arc ; arc_width changes the
+ y-axis-size)
+ Will not fix it since I'm not sure.
- */
+ */
Real h = height + 2 * arc_height;
- Box b (Interval (0, 1.5), Interval (-h/2, h/2));
+ Box b (Interval (0, 1.5), Interval (-h / 2, h / 2));
Stencil mol (b, at);
mol.align_to (X_AXIS, CENTER);
return mol;
}
-
-
Stencil
-System_start_delimiter::simple_bar (Grob*me, Real h)
+System_start_delimiter::simple_bar (Grob *me, Real h)
{
- Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")) ;
+ Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
Real w = lt * robust_scm2double (me->get_property ("thickness"), 1);
- return Lookup::round_filled_box (Box (Interval (0, w), Interval (-h/2, h/2)),
+ return Lookup::round_filled_box (Box (Interval (0, w), Interval (-h / 2, h / 2)),
lt);
}
SCM
System_start_delimiter::after_line_breaking (SCM smob)
{
- Grob * me = unsmob_grob (smob);
- SCM gl = me->get_property ("glyph");
+ Grob *me = unsmob_grob (smob);
+ SCM gl = me->get_property ("glyph");
if (ly_c_equal_p (gl, scm_makfrom0str ("bar-line")))
{
int count = 0;
/*
- Get all coordinates, to trigger Hara kiri.
+ Get all coordinates, to trigger Hara kiri.
*/
SCM elts = me->get_property ("elements");
Grob *common = common_refpoint_of_list (elts, me, Y_AXIS);
Interval v = unsmob_grob (scm_car (s))->extent (common, Y_AXIS);
if (!v.is_empty ())
- count ++;
+ count++;
}
-
- if (count <= 1)
+ if (count <= 1)
{
me->suicide ();
}
return SCM_UNSPECIFIED;
}
-
MAKE_SCHEME_CALLBACK (System_start_delimiter, print, 1);
SCM
System_start_delimiter::print (SCM smob)
SCM s = me->get_property ("glyph");
if (!scm_is_string (s))
return SCM_EOL;
- SCM gsym = scm_string_to_symbol (s) ;
+ SCM gsym = scm_string_to_symbol (s);
Real staff_space = Staff_symbol_referencer::staff_space (me);
SCM elts = me->get_property ("elements");
- Grob * common = common_refpoint_of_list (elts, me, Y_AXIS);
+ Grob *common = common_refpoint_of_list (elts, me, Y_AXIS);
Interval ext;
for (SCM s = elts; scm_is_pair (s); s = scm_cdr (s))
{
- Spanner * sp = unsmob_spanner (scm_car (s));
- if (sp &&
- sp->get_bound (LEFT) == me->get_bound (LEFT))
+ Spanner *sp = unsmob_spanner (scm_car (s));
+ if (sp
+ && sp->get_bound (LEFT) == me->get_bound (LEFT))
{
Interval dims = sp->extent (common, Y_AXIS);
if (!dims.is_empty ())
return Stencil (b, stil.expr ());
}
-
ADD_INTERFACE (System_start_delimiter, "system-start-delimiter-interface",
"The brace, bracket or bar in front of the system. "
- "It is implemented as a spanner."
- ,
+ "It is implemented as a spanner.",
"collapse-height thickness "
"arch-height arch-angle arch-thick arch-width bracket-thick glyph");
#include "paper-system.hh"
#include "tweak-registration.hh"
-
System::System (System const &src, int count)
: Spanner (src, count)
{
rank_ = 0;
}
-System::System (SCM s, Object_key const*key)
+System::System (SCM s, Object_key const *key)
: Spanner (s, key)
{
rank_ = 0;
}
-
-Grob *
+Grob *
System::clone (int count) const
{
return new System (*this, count);
}
-
int
System::element_count () const
{
{
int k = 0;
for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s))
- if (dynamic_cast<Spanner*> (unsmob_grob (scm_car (s))))
+ if (dynamic_cast<Spanner *> (unsmob_grob (scm_car (s))))
k++;
return k;
}
void
-System::typeset_grob (Grob * elem)
+System::typeset_grob (Grob *elem)
{
if (elem->pscore_)
programming_error ("Adding element twice.");
if (g->internal_has_interface (ly_symbol2scm ("only-prebreak-interface")))
{
/*
- Kill no longer needed grobs.
- */
- Item * it = dynamic_cast<Item*> (g);
+ Kill no longer needed grobs.
+ */
+ Item *it = dynamic_cast<Item *> (g);
if (it && Item::is_breakable (it))
{
it->find_prebroken_piece (LEFT)->suicide ();
fixup_refpoint (scm_car (s));
count += scm_ilength (all);
}
-
+
/*
needed for doing items.
- */
+ */
fixup_refpoints (get_property ("all-elements"));
for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s))
handle_broken_dependencies ();
#if 0 /* don't do this: strange side effects. */
-
+
/* Because the this->get_property (all-elements) contains items in 3
versions, handle_broken_dependencies () will leave duplicated
items in all-elements. Strictly speaking this is harmless, but
for (int i = 0; i < line_count; i++)
{
SCM all = broken_intos_[i]->get_property ("all-elements");
- all = ly_list_qsort_uniq_x(all);
+ all = ly_list_qsort_uniq_x (all);
}
#endif
-
+
if (be_verbose_global)
- progress_indication (_f ("Element count %d.", count + element_count ()));
+ progress_indication (_f ("Element count %d.", count + element_count ()));
int line_count = broken_intos_.size ();
SCM lines = scm_c_make_vector (line_count, SCM_EOL);
-
+
for (int i = 0; i < line_count; i++)
{
if (be_verbose_global)
progress_indication ("[");
- System *system = dynamic_cast<System*> (broken_intos_[i]);
+ System *system = dynamic_cast<System *> (broken_intos_[i]);
system->post_processing ();
scm_vector_set_x (lines, scm_int2num (i), system->get_line ());
}
void
-System::break_into_pieces (Array<Column_x_positions> const &breaking)
+System::break_into_pieces (Array<Column_x_positions> const &breaking)
{
for (int i = 0; i < breaking.size (); i++)
{
- System *system = dynamic_cast <System*> (clone (i));
+ System *system = dynamic_cast<System *> (clone (i));
system->rank_ = i;
Link_array<Grob> c (breaking[i].cols_);
pscore_->typeset_line (system);
-
+
system->set_bound (LEFT, c[0]);
system->set_bound (RIGHT, c.top ());
for (int j = 0; j < c.size (); j++)
{
c[j]->translate_axis (breaking[i].config_[j], X_AXIS);
- dynamic_cast<Paper_column*> (c[j])->system_ = system;
+ dynamic_cast<Paper_column *> (c[j])->system_ = system;
}
set_loose_columns (system, &breaking[i]);
broken_intos_.push (system);
}
void
-System::add_column (Paper_column*p)
+System::add_column (Paper_column *p)
{
Grob *me = this;
SCM cs = me->get_property ("columns");
- Grob *prev = scm_is_pair (cs) ? unsmob_grob (scm_car (cs)) : 0;
+ Grob *prev = scm_is_pair (cs) ? unsmob_grob (scm_car (cs)) : 0;
- p->rank_ = prev ? Paper_column::get_rank (prev) + 1 : 0;
+ p->rank_ = prev ? Paper_column::get_rank (prev) + 1 : 0;
me->set_property ("columns", scm_cons (p->self_scm (), cs));
{
SCM proc = scm_caar (s);
SCM rest = scm_cdar (s);
- scm_apply_1 (proc, g->self_scm(), rest);
+ scm_apply_1 (proc, g->self_scm (), rest);
}
}
}
if (be_verbose_global)
progress_indication (_f ("Grob count %d", element_count ()));
-
+
for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s))
unsmob_grob (scm_car (s))->handle_prebroken_dependencies ();
-
+
fixup_refpoints (get_property ("all-elements"));
-
for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s))
apply_tweaks (unsmob_grob (scm_car (s)), false);
Grob *sc = unsmob_grob (scm_car (s));
sc->calculate_dependencies (PRECALCED, PRECALCING, ly_symbol2scm ("before-line-breaking-callback"));
}
-
+
progress_indication ("\n");
progress_indication (_ ("Calculating line breaks..."));
progress_indication (" ");
for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s))
{
Grob *g = unsmob_grob (scm_car (s));
-
+
apply_tweaks (g, true);
g->calculate_dependencies (POSTCALCED, POSTCALCING,
- ly_symbol2scm ("after-line-breaking-callback"));
+ ly_symbol2scm ("after-line-breaking-callback"));
}
Interval iv (extent (this, Y_AXIS));
programming_error ("System with zero extent.");
else
translate_axis (-iv[MAX], Y_AXIS);
-
+
/* Generate all stencils to trigger font loads.
This might seem inefficient, but Stencils are cached per grob
anyway. */
SCM
System::get_line ()
-{
+{
static int const LAYER_COUNT = 3;
SCM exprs = SCM_EOL;
/* Output stencils in three layers: 0, 1, 2. Default layer: 1. */
SCM all = get_property ("all-elements");
-
+
for (int i = 0; i < LAYER_COUNT; i++)
for (SCM s = all; scm_is_pair (s); s = scm_cdr (s))
{
st.translate (o + extra);
*tail = scm_cons (st.expr (), SCM_EOL);
- tail = SCM_CDRLOC(*tail);
+ tail = SCM_CDRLOC (*tail);
}
if (Stencil *me = get_stencil ())
exprs));
Interval staff_refpoints;
- staff_refpoints.set_empty();
+ staff_refpoints.set_empty ();
for (SCM s = get_property ("spaceable-staves");
scm_is_pair (s); s = scm_cdr (s))
- {
- Grob *g = unsmob_grob (scm_car (s));
- staff_refpoints.add_point (g->relative_coordinate (this, Y_AXIS));
- }
-
-
+ {
+ Grob *g = unsmob_grob (scm_car (s));
+ staff_refpoints.add_point (g->relative_coordinate (this, Y_AXIS));
+ }
+
Paper_system *pl = new Paper_system (sys_stencil, false);
pl->staff_refpoints_ = staff_refpoints;
- Item * break_point = this->get_bound(LEFT);
- pl->break_before_penalty_ =
- robust_scm2double (break_point->get_property ("page-penalty"), 0.0);
-
+ Item *break_point = this->get_bound (LEFT);
+ pl->break_before_penalty_
+ = robust_scm2double (break_point->get_property ("page-penalty"), 0.0);
+
return scm_gc_unprotect_object (pl->self_scm ());
}
-Link_array<Item>
+Link_array<Item>
System::broken_col_range (Item const *left, Item const *right) const
{
Link_array<Item> ret;
while (scm_is_pair (s) && scm_car (s) != left->self_scm ())
{
- Paper_column*c = dynamic_cast<Paper_column*> (unsmob_grob (scm_car (s)));
+ Paper_column *c = dynamic_cast<Paper_column *> (unsmob_grob (scm_car (s)));
if (Item::is_breakable (c) && !c->system_)
ret.push (c);
based on note-heads-engraver.cc, by Jean-Baptiste Lamy <jiba@tuxfamily.org>,
(c) 2002--2005
-
*/
#include <cctype>
class Tab_note_heads_engraver : public Engraver
{
Link_array<Item> notes_;
-
+
Link_array<Item> dots_;
Link_array<Music> note_events_;
Link_array<Music> tabstring_events_;
TRANSLATOR_DECLARATIONS (Tab_note_heads_engraver);
protected:
- virtual bool try_music (Music *event) ;
+ virtual bool try_music (Music *event);
virtual void process_music ();
virtual void stop_translation_timestep ();
};
-
Tab_note_heads_engraver::Tab_note_heads_engraver ()
{
}
bool
-Tab_note_heads_engraver::try_music (Music *m)
+Tab_note_heads_engraver::try_music (Music *m)
{
if (m->is_mus_type ("note-event"))
{
{
return note_events_.size ();
}
-
+
return false;
}
-
void
Tab_note_heads_engraver::process_music ()
{
- int j = 0;
+ int j = 0;
for (int i = 0; i < note_events_.size (); i++)
{
SCM stringTunings = get_property ("stringTunings");
int number_of_strings = ((int) ly_length (stringTunings));
bool high_string_one = to_boolean (get_property ("highStringOne"));
-
- Music * event = note_events_[i];
- Item * note = make_item ("TabNoteHead", event->self_scm ());
+ Music *event = note_events_[i];
+ Item *note = make_item ("TabNoteHead", event->self_scm ());
-
- Music * tabstring_event = 0;
+ Music *tabstring_event = 0;
for (SCM s = event->get_property ("articulations");
!tabstring_event && scm_is_pair (s); s = scm_cdr (s))
{
- Music * art = unsmob_music (scm_car (s));
+ Music *art = unsmob_music (scm_car (s));
if (art->is_mus_type ("string-number-event"))
tabstring_event = art;
}
- if (!tabstring_event && j < tabstring_events_.size ())
+ if (!tabstring_event && j < tabstring_events_.size ())
{
tabstring_event = tabstring_events_[j];
- if (j +1 < tabstring_events_.size ())
+ if (j +1 < tabstring_events_.size ())
j++;
}
tab_string = high_string_one ? 1 : number_of_strings;
string_found = false;
}
-
+
Duration dur = *unsmob_duration (event->get_property ("duration"));
note->set_property ("duration-log",
- scm_int2num (dur.duration_log ()));
+ scm_int2num (dur.duration_log ()));
if (dur.dot_count ())
{
- Item * d = make_item ("Dots", event->self_scm ());
+ Item *d = make_item ("Dots", event->self_scm ());
Rhythmic_head::set_dots (note, d);
-
+
if (dur.dot_count ()
!= scm_to_int (d->get_property ("dot-count")))
d->set_property ("dot-count", scm_int2num (dur.dot_count ()));
d->set_parent (note, Y_AXIS);
-
+
dots_.push (d);
}
-
-
+
SCM scm_pitch = event->get_property ("pitch");
- SCM proc = get_property ("tablatureFormat");
+ SCM proc = get_property ("tablatureFormat");
SCM min_fret_scm = get_property ("minimumFret");
int min_fret = scm_is_number (min_fret_scm) ? scm_to_int (min_fret_scm) : 0;
while (!string_found)
{
int fret = unsmob_pitch (scm_pitch)->semitone_pitch ()
- - scm_to_int (scm_list_ref (stringTunings, scm_int2num (tab_string-1)));
- if (fret<min_fret)
+ - scm_to_int (scm_list_ref (stringTunings, scm_int2num (tab_string - 1)));
+ if (fret < min_fret)
tab_string += high_string_one ? 1 : -1;
else
string_found = true;
int pos = 2 * tab_string - number_of_strings - 1; // No tab-note between the string !!!
if (to_boolean (get_property ("stringOneTopmost")))
pos = -pos;
-
- note->set_property ("text", text);
-
+
+ note->set_property ("text", text);
+
note->set_property ("staff-position", scm_int2num (pos));
notes_.push (note);
}
tabstring_events_.clear ();
}
-
ADD_TRANSLATOR (Tab_note_heads_engraver,
-/* descr */ "Generate one or more tablature noteheads from Music of type NoteEvent.",
-/* creats*/ "TabNoteHead Dots",
-/* accepts */ "note-event string-number-event busy-playing-event",
-/* acks */ "",
-/* reads */ "middleCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost",
-/* write */ "");
+ /* descr */ "Generate one or more tablature noteheads from Music of type NoteEvent.",
+ /* creats*/ "TabNoteHead Dots",
+ /* accepts */ "note-event string-number-event busy-playing-event",
+ /* acks */ "",
+ /* reads */ "middleCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost",
+ /* write */ "");
return a.to_string ();
}
-
-
template INTERVAL__INSTANTIATE (Rational);
(c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
*/
-
#include "audio-item.hh"
#include "performer.hh"
protected:
- virtual bool try_music (Music* req);
+ virtual bool try_music (Music *req);
virtual void stop_translation_timestep ();
virtual void create_audio_elements ();
private:
- Music* tempo_req_;
- Audio_tempo* audio_;
+ Music *tempo_req_;
+ Audio_tempo *audio_;
};
Tempo_performer::Tempo_performer ()
{
}
-
void
Tempo_performer::create_audio_elements ()
{
SCM met = tempo_req_->get_property ("metronome-count");
Duration *d = unsmob_duration (tempo_req_->get_property ("tempo-unit"));
-
- Rational r = (d->get_length () / Moment (Rational (1, 4)) * Moment (scm_to_int (met))).main_part_;
-
+
+ Rational r = (d->get_length () / Moment (Rational (1, 4)) * Moment (scm_to_int (met))).main_part_;
+
audio_ = new Audio_tempo (int (r));
Audio_element_info info (audio_, tempo_req_);
}
bool
-Tempo_performer::try_music (Music* req)
+Tempo_performer::try_music (Music *req)
{
if (tempo_req_)
return false;
}
-
-
ADD_TRANSLATOR (Tempo_performer, "", "",
- "metronome-change-event",
- "", "", "" );
+ "metronome-change-event",
+ "", "", "");
-/*
+/*
text-engraver.cc -- implement Text_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "directional-element-interface.hh"
#include "engraver.hh"
/**
typeset directions that are plain text.
- */
+*/
class Text_engraver : public Engraver
{
Link_array<Music> evs_;
public:
TRANSLATOR_DECLARATIONS (Text_engraver);
protected:
- virtual bool try_music (Music* m);
+ virtual bool try_music (Music *m);
virtual void stop_translation_timestep ();
virtual void process_acknowledged_grobs ();
virtual void acknowledge_grob (Grob_info);
{
for (int i = 0; i < texts_.size (); i++)
{
- Grob*t = texts_[i];
+ Grob *t = texts_[i];
Side_position_interface::add_support (t, inf.grob_);
/*
ugh.
- */
+ */
if (Side_position_interface::get_axis (t) == X_AXIS
&& !t->get_parent (Y_AXIS))
t->set_parent (inf.grob_, Y_AXIS);
else if (Side_position_interface::get_axis (t) == Y_AXIS
- && !t->get_parent (X_AXIS))
+ && !t->get_parent (X_AXIS))
t->set_parent (inf.grob_, X_AXIS);
}
}
-
+
if (Stem::has_interface (inf.grob_))
{
for (int i = 0; i < texts_.size (); i++)
return;
for (int i = 0; i < evs_.size (); i++)
{
- Music * r = evs_[i];
-
+ Music *r = evs_[i];
+
// URG: Text vs TextScript
Item *text = make_item ("TextScript", r->self_scm ());
-
Axis ax = Y_AXIS;
Side_position_interface::set_axis (text, ax);
SCM s = text->get_property ("script-priority");
if (scm_is_number (s))
priority = scm_to_int (s);
-
+
/* see script-engraver.cc */
priority += i;
-
+
text->set_property ("script-priority", scm_int2num (priority));
Direction dir = to_dir (r->get_property ("direction"));
if (dir)
set_grob_direction (text, dir);
-
SCM mark = r->get_property ("text");
text->set_property ("text", mark);
evs_.clear ();
}
-
Text_engraver::Text_engraver ()
{
}
ADD_TRANSLATOR (Text_engraver,
-/* descr */ "Create text-scripts",
-/* creats*/ "TextScript",
-/* accepts */ "text-script-event",
-/* acks */ "rhythmic-head-interface stem-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Create text-scripts",
+ /* creats*/ "TextScript",
+ /* accepts */ "text-script-event",
+ /* acks */ "rhythmic-head-interface stem-interface",
+ /* reads */ "",
+ /* write */ "");
-/*
+/*
text-item.cc -- implement Text_interface
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
- Jan Nieuwenhuizen <janneke@gnu.org>
+ Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "text-item.hh"
#include <math.h>
-#include "main.hh"
+#include "main.hh"
#include "config.hh"
#include "pango-font.hh"
#include "warn.hh"
#include "output-def.hh"
#include "modified-font-metric.hh"
-
MAKE_SCHEME_CALLBACK (Text_interface, interpret_string, 3)
-SCM
+ SCM
Text_interface::interpret_string (SCM layout_smob,
SCM props,
SCM markup)
{
Output_def *layout = unsmob_output_def (layout_smob);
-
+
SCM_ASSERT_TYPE (layout, layout_smob, SCM_ARG1,
__FUNCTION__, "Layout definition");
SCM_ASSERT_TYPE (scm_is_string (markup), markup, SCM_ARG3,
return fm->text_stencil (str).smobbed_copy ();
}
-
MAKE_SCHEME_CALLBACK (Text_interface, interpret_markup, 3)
-SCM
+ SCM
Text_interface::interpret_markup (SCM layout_smob, SCM props, SCM markup)
{
if (scm_is_string (markup))
SCM args = scm_cdr (markup);
if (!markup_p (markup))
programming_error ("Markup head has no markup signature.");
-
+
return scm_apply_2 (func, layout_smob, props, args);
}
else
{
programming_error ("Is not a markup: ");
- scm_display (markup, scm_current_error_port());
+ scm_display (markup, scm_current_error_port ());
assert (false);
Box b;
- b[X_AXIS].set_empty();
- b[Y_AXIS].set_empty();
-
- Stencil s(b, SCM_EOL);
- return s.smobbed_copy();
+ b[X_AXIS].set_empty ();
+ b[Y_AXIS].set_empty ();
+
+ Stencil s (b, SCM_EOL);
+ return s.smobbed_copy ();
}
}
Text_interface::print (SCM grob)
{
Grob *me = unsmob_grob (grob);
-
+
SCM t = me->get_property ("text");
SCM chain = Font_interface::text_font_alist_chain (me);
return interpret_markup (me->get_layout ()->self_scm (), chain, t);
"text baseline-skip word-space");
-
-
Box b;
SCM limit = ly_lily_module_constant ("TEX_STRING_HASHLIMIT");
- String key_str = ly_scm2string (font->font_file_name());
+ String key_str = ly_scm2string (font->font_file_name ());
int hash_code = scm_to_int (scm_hash (text, limit));
- key_str = to_string (hash_code) + key_str;
-
+ key_str = to_string (hash_code) + key_str;
+
SCM val = SCM_BOOL_F;
if (text_dimension_hash_tab)
{
val = scm_cdr (val);
b[Y_AXIS][UP] = scm_to_double (scm_car (val)) * point_constant;
val = scm_cdr (val);
- b[Y_AXIS][DOWN] = scm_to_double (scm_car (val)) * point_constant;
+ b[Y_AXIS][DOWN] = scm_to_double (scm_car (val)) * point_constant;
}
-
- return b;
+
+ return b;
}
-LY_DEFINE(ly_load_text_dimensions, "ly:load-text-dimensions",
- 1, 0, 0,
- (SCM dimension_alist),
- "Load dimensions from TeX in a (KEY . (W H D)) format alist")
+LY_DEFINE (ly_load_text_dimensions, "ly:load-text-dimensions",
+ 1, 0, 0,
+ (SCM dimension_alist),
+ "Load dimensions from TeX in a (KEY . (W H D)) format alist")
{
if (!text_dimension_hash_tab)
{
- text_dimension_hash_tab =
- scm_gc_protect_object (scm_c_make_hash_table (113));
+ text_dimension_hash_tab
+ = scm_gc_protect_object (scm_c_make_hash_table (113));
}
for (SCM s = dimension_alist;
{
SCM key = scm_caar (s);
SCM val = scm_cdar (s);
-
+
if (scm_hash_ref (text_dimension_hash_tab, key, SCM_BOOL_F)
== SCM_BOOL_F)
{
void
try_load_text_metrics (String basename)
{
- String path = global_path.find (basename + ".textmetrics");
+ String path = global_path.find (basename + ".textmetrics");
if (path != "")
{
String contents (gulp_file_to_string (path, true));
- contents = "(quote (" + contents + "))";
+ contents = "(quote (" + contents + "))";
SCM lst = scm_c_eval_string (contents.to_str0 ());
ly_load_text_dimensions (lst);
class Text_spanner_engraver : public Engraver
{
public:
- TRANSLATOR_DECLARATIONS (Text_spanner_engraver);
+ TRANSLATOR_DECLARATIONS (Text_spanner_engraver);
protected:
virtual void finalize ();
virtual void acknowledge_grob (Grob_info);
Spanner *span_;
Spanner *finished_;
Music *current_req_;
- Drul_array<Music*> req_drul_;
+ Drul_array<Music *> req_drul_;
void typeset_all ();
};
-
Text_spanner_engraver::Text_spanner_engraver ()
{
finished_ = 0;
else
{
current_req_ = req_drul_[START];
- span_ = make_spanner ("TextSpanner", req_drul_[START]->self_scm ());
+ span_ = make_spanner ("TextSpanner", req_drul_[START]->self_scm ());
-
Side_position_interface::set_axis (span_, Y_AXIS);
req_drul_[START] = 0;
}
void
Text_spanner_engraver::acknowledge_grob (Grob_info info)
{
- Spanner * spans[2] ={span_, finished_};
- for (int i = 0; i < 2 ; i++)
+ Spanner *spans[2] ={span_, finished_};
+ for (int i = 0; i < 2; i++)
{
if (spans[i] && Note_column::has_interface (info.grob_))
{
Side_position_interface::add_support (spans[i], info.grob_);
- add_bound_item (spans[i], dynamic_cast<Item*> (info.grob_));
+ add_bound_item (spans[i], dynamic_cast<Item *> (info.grob_));
}
}
}
void
Text_spanner_engraver::typeset_all ()
-{
+{
if (finished_)
{
if (!finished_->get_bound (RIGHT))
{
- Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
+ Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
finished_->set_bound (RIGHT, e);
}
finished_ = 0;
{
if (span_ && !span_->get_bound (LEFT))
{
- Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
+ Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
span_->set_bound (LEFT, e);
}
}
ADD_TRANSLATOR (Text_spanner_engraver,
-/* descr */ "Create text spanner from a Music.",
-/* creats*/ "TextSpanner",
-/* accepts */ "text-span-event",
-/* acks */ "note-column-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Create text spanner from a Music.",
+ /* creats*/ "TextSpanner",
+ /* accepts */ "text-span-event",
+ /* acks */ "note-column-interface",
+ /* reads */ "",
+ /* write */ "");
(c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- Revised over good by Han-Wen.
+ Revised over good by Han-Wen.
*/
#include "text-spanner.hh"
TODO: this function is too long
*/
SCM
-Text_spanner::print (SCM smob)
+Text_spanner::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
- Spanner *spanner = dynamic_cast<Spanner*> (me);
-
+ Spanner *spanner = dynamic_cast<Spanner *> (me);
+
/* Ugh, must be same as Hairpin::print. */
Grob *common = spanner->get_bound (LEFT)->common_refpoint (spanner->get_bound (RIGHT), X_AXIS);
- Output_def * layout = me->get_layout ();
+ Output_def *layout = me->get_layout ();
SCM flare = me->get_property ("bracket-flare");
SCM shorten = me->get_property ("shorten-pair");
span_points[d] = b->relative_coordinate (common, X_AXIS);
}
else
- {
- Real encl = robust_scm2double (me->get_property ("enclose-bounds"), 0.0);
- Interval ext = b->extent (common, X_AXIS);
-
- span_points[d] =
- robust_relative_extent (b, common, X_AXIS).linear_combination (d * encl);
-
- if (is_number_pair (shorten))
- span_points -= d * scm_to_double (index_get_cell (shorten, d));
- }
-
+ {
+ Real encl = robust_scm2double (me->get_property ("enclose-bounds"), 0.0);
+ Interval ext = b->extent (common, X_AXIS);
+
+ span_points[d]
+ = robust_relative_extent (b, common, X_AXIS).linear_combination (d * encl);
+
+ if (is_number_pair (shorten))
+ span_points -= d * scm_to_double (index_get_cell (shorten, d));
+ }
+
if (is_number_pair (flare))
span_points -= d * scm_to_double (index_get_cell (flare, d));
}
while (flip (&d) != LEFT);
-
SCM properties = Font_interface::text_font_alist_chain (me);
SCM edge_text = me->get_property ("edge-text");
Drul_array<Stencil> edge;
{
if (broken[d])
continue;
-
+
SCM text = index_get_cell (edge_text, d);
- if (Text_interface::markup_p (text))
+ if (Text_interface::markup_p (text))
edge[d] = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (), properties, text));
-
+
if (!edge[d].is_empty ())
edge[d].align_to (Y_AXIS, CENTER);
}
while (flip (&d) != LEFT);
}
-
+
Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
Interval (0.0, 0.0));
Drul_array<Stencil> edge_line;
- {
- Direction d = LEFT;
- int dir = to_dir (me->get_property ("direction"));
- do
- {
- if (broken[d])
- continue;
-
- Real dx = 0.0;
- if (is_number_pair (flare))
- dx = scm_to_double (index_get_cell (flare, d)) * d;
-
- Real dy = - dir * edge_height[d] ;
- if (dy)
- edge_line[d] = Line_spanner::line_stencil (me, Offset (0, 0), Offset (dx, dy));
- }
- while (flip (&d) != LEFT);
- }
-
+ {
+ Direction d = LEFT;
+ int dir = to_dir (me->get_property ("direction"));
+ do
+ {
+ if (broken[d])
+ continue;
+
+ Real dx = 0.0;
+ if (is_number_pair (flare))
+ dx = scm_to_double (index_get_cell (flare, d)) * d;
+
+ Real dy = -dir * edge_height[d];
+ if (dy)
+ edge_line[d] = Line_spanner::line_stencil (me, Offset (0, 0), Offset (dx, dy));
+ }
+ while (flip (&d) != LEFT);
+ }
+
Stencil m;
do
{
{
edge[d].translate_axis (span_points[d], X_AXIS);
m.add_stencil (edge[d]);
- span_points[d] += -d * ext[-d];
+ span_points[d] += -d * ext[-d];
}
}
while (flip (&d) != LEFT);
if (!span_points.is_empty ())
{
Stencil l = Line_spanner::line_stencil (me, Offset (span_points[LEFT], 0),
- Offset (span_points[RIGHT], 0));
+ Offset (span_points[RIGHT], 0));
m.add_stencil (l);
}
m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
-/*
+/*
tfm-reader.cc -- implement Tex_font_metric_reader
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Jan Nieuwenhuizen <janneke@gnu.org>
-
+
some code shamelessly copied from GNU fontutils-0.6/tfm/tfm_input.c
- */
+*/
#include "tfm-reader.hh"
#include "warn.hh"
#define format_string String_convert::form_string
-#define FIX_UNITY \
- (1 << 20)
+#define FIX_UNITY \
+ (1 << 20)
static const Real fix_to_real (Fix f);
-
Tex_font_metric_reader::Tex_font_metric_reader (String name)
: input_ (name)
{
-
+
for (int i = 0; i < TFM_SIZE; i++)
ascii_to_metric_idx_.push (-1);
Tex_font_metric_reader::read_header ()
{
U16 file_length = input_.get_U16 ();
- (void) file_length;
+ (void) file_length;
U16 header_length = input_.get_U16 ();
info_.first_charcode = input_.get_U16 ();
U16 italic_correction_word_count = input_.get_U16 ();
U16 lig_kern_word_count = input_.get_U16 ();
U16 kern_word_count = input_.get_U16 ();
- (void)kern_word_count;
+ (void)kern_word_count;
U16 extensible_word_count = input_.get_U16 ();
- (void)extensible_word_count;
-
+ (void)extensible_word_count;
+
header_.param_word_count = input_.get_U16 ();
info_.parameter_count = header_.param_word_count;
header_.char_info_pos = (6 + header_length) * 4;
header_.width_pos = header_.char_info_pos
- + (info_.last_charcode
- - info_.first_charcode + 1) * 4;
+ + (info_.last_charcode
+ - info_.first_charcode + 1) * 4;
header_.height_pos = header_.width_pos + width_word_count * 4;
header_.depth_pos = header_.height_pos + height_word_count * 4;
header_.italic_correction_pos = header_.depth_pos
- + depth_word_count * 4;
+ + depth_word_count * 4;
header_.lig_kern_pos = header_.italic_correction_pos
+ italic_correction_word_count * 4;
header_.kern_pos = header_.lig_kern_pos + lig_kern_word_count * 4;
try to read it. */
if (code < info_.first_charcode || code > info_.last_charcode)
return tfm_char;
-
+
//brr
/* Move to the appropriate place in the `char_info' array. */
input_.seek_str0 (header_.char_info_pos + (code - info_.first_charcode) * 4);
return tfm_char;
}
-
/* We assume we are positioned at the beginning of a `char_info' word.
We read that word to get the indexes into the dimension tables; then
we go read the tables to get the values (if the character exists). */
Tex_font_char_metric tfm_char;
-#define GET_CHAR_DIMEN(d) \
- if (d##_index != 0) \
- { \
- input_.seek_str0 (header_. d##_pos + d##_index*4); \
- tfm_char.d##_fix_ = input_.get_U32 (); \
- tfm_char.d##_ = fix_to_real (tfm_char.d##_fix_) \
- * info_.design_size; \
- }
+#define GET_CHAR_DIMEN(d) \
+ if (d##_index != 0) \
+ { \
+ input_.seek_str0 (header_. d##_pos + d##_index*4); \
+ tfm_char.d##_fix_ = input_.get_U32 (); \
+ tfm_char.d##_ = fix_to_real (tfm_char.d##_fix_) \
+ * info_.design_size; \
+ }
GET_CHAR_DIMEN (width);
GET_CHAR_DIMEN (height);
#define KERN_FLAG 128
void
-Tex_font_metric_reader::read_lig_kern_program (Array <Tfm_ligature>* ligatures, Array <Tfm_kern>* kerns)
+Tex_font_metric_reader::read_lig_kern_program (Array<Tfm_ligature>* ligatures, Array<Tfm_kern>* kerns)
{
bool end_b;
bool kern_step_b = input_.get_U8 () >= KERN_FLAG;
U8 remainder = input_.get_U8 ();
-
if (kern_step_b)
{
Tfm_kern kern_element;
kern_element.character = next_char;
- char const* old_pos = input_.pos_str0 ();
+ char const *old_pos = input_.pos_str0 ();
input_.seek_str0 (header_.kern_pos + remainder * 4);
kern_element.kern = get_U32_fix_scaled ();
input_.set_pos (old_pos);
ligatures->push (ligature_element);
}
- } while (!end_b);
+ }
+ while (!end_b);
+
}
-/*
+/*
tfm.cc -- implement Tex_font_metric
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1999--2005 Jan Nieuwenhuizen <janneke@gnu.org>
some code shamelessly copied from GNU fontutils-0.6/tfm/tfm_input.c
- */
+*/
#include "file-name.hh"
#include "tfm.hh"
b.set_empty ();
return b;
}
-
+
Real d = -depth_;
Real point_constant = 1 PT;
-
- return Box (Interval (0, width_* point_constant ),
+
+ return Box (Interval (0, width_* point_constant),
Interval ((d <? height_) * point_constant,
(d >? height_) * point_constant));
}
{
if (ascii >= 0 && ascii < ascii_to_metric_idx_.size ()
&& ascii_to_metric_idx_[ascii] >= 0)
- return & char_metrics_[ascii_to_metric_idx_ [ascii]];
+ return &char_metrics_[ascii_to_metric_idx_ [ascii]];
else if (warn)
warning (_f ("can't find ascii character: %d", ascii));
- return &dummy_static_char_metric;
+ return &dummy_static_char_metric;
}
/* UGH: glyphs need not be consecutive in TFM. */
-/*
+/*
tie-column.cc -- implement Tie_column
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "tie-column.hh"
#include "paper-column.hh"
*/
/*
TODO: this doesn't follow standard pattern. Regularize.
- */
+*/
void
-Tie_column::add_tie (Grob*me, Grob *tie)
+Tie_column::add_tie (Grob *me, Grob *tie)
{
if (tie->get_parent (Y_AXIS)
&& Tie_column::has_interface (tie->get_parent (Y_AXIS)))
- return ;
+ return;
-
if (!Pointer_group_interface::count (me, ly_symbol2scm ("ties")))
{
- dynamic_cast<Spanner*> (me)->set_bound (LEFT, Tie::head (tie, LEFT));
- dynamic_cast<Spanner*> (me)->set_bound (RIGHT, Tie::head (tie, RIGHT));
+ dynamic_cast<Spanner *> (me)->set_bound (LEFT, Tie::head (tie, LEFT));
+ dynamic_cast<Spanner *> (me)->set_bound (RIGHT, Tie::head (tie, RIGHT));
}
-
-
+
tie->set_parent (me, Y_AXIS);
Pointer_group_interface::add_grob (me, ly_symbol2scm ("ties"), tie);
tie->add_dependency (me);
}
void
-Tie_column::set_directions (Grob*me)
+Tie_column::set_directions (Grob *me)
{
werner_directions (me);
}
int
-tie_compare (Grob* const & s1,
- Grob* const & s2)
+tie_compare (Grob *const &s1,
+ Grob *const &s2)
{
return sign (Tie::get_position (s1) - Tie::get_position (s2));
}
/*
-Werner:
+ Werner:
- . The algorithm to choose the direction of the ties doesn't work
- properly. I suggest the following for applying ties sequentially
- from top to bottom:
+ . The algorithm to choose the direction of the ties doesn't work
+ properly. I suggest the following for applying ties sequentially
+ from top to bottom:
- + The topmost tie is always `up'.
+ + The topmost tie is always `up'.
- + If there is a vertical gap to the last note above larger than
- or equal to a fifth (or sixth?), the tie is `up', otherwise it
- is `down'.
-
- + The bottommost tie is always `down'.
+ + If there is a vertical gap to the last note above larger than
+ or equal to a fifth (or sixth?), the tie is `up', otherwise it
+ is `down'.
+ + The bottommost tie is always `down'.
*/
void
Tie_column::werner_directions (Grob *me)
{
- Link_array<Grob> ties =
- extract_grob_array (me, ly_symbol2scm ("ties"));
+ Link_array<Grob> ties
+ = extract_grob_array (me, ly_symbol2scm ("ties"));
if (!ties.size ())
- return ;
-
+ return;
+
ties.sort (tie_compare);
Direction d = get_grob_direction (me);
{
for (int i = ties.size (); i--;)
{
- Grob * t = ties[i];
+ Grob *t = ties[i];
if (!get_grob_direction (t))
set_grob_direction (t, d);
}
- return ;
+ return;
}
-
+
if (ties.size () == 1)
{
- Grob * t = ties[0];
+ Grob *t = ties[0];
if (t->is_live ()
&& !get_grob_direction (t))
set_grob_direction (t, Tie::get_default_dir (t));
- return ;
+ return;
}
Real last_down_pos = 10000;
/*
Go downward.
- */
+ */
Grob *last_tie = 0;
for (int i = ties.size (); i--;)
{
Grob *t = ties[i];
-
+
Direction d = get_grob_direction (t);
- Real p = Tie::get_position (t);
+ Real p = Tie::get_position (t);
if (!d)
{
if (last_tie
&& Tie::get_column_rank (t, LEFT)
- < Tie::get_column_rank (last_tie, LEFT))
+ < Tie::get_column_rank (last_tie, LEFT))
{
d = DOWN;
}
last_tie = t;
}
- return ;
+ return;
}
-
MAKE_SCHEME_CALLBACK (Tie_column, after_line_breaking, 1);
SCM
Tie_column::after_line_breaking (SCM smob)
/*
Extend the spanner over its Tie constituents.
- */
+*/
MAKE_SCHEME_CALLBACK (Tie_column, before_line_breaking, 1);
SCM
Tie_column::before_line_breaking (SCM smob)
{
- Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (smob));
+ Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
for (SCM s = me->get_property ("ties"); scm_is_pair (s); s = scm_cdr (s))
{
- Spanner *tie = dynamic_cast<Spanner*> (unsmob_grob (scm_car (s)));
+ Spanner *tie = dynamic_cast<Spanner *> (unsmob_grob (scm_car (s)));
Direction dir = LEFT;
do
{
- if (dir * Paper_column::get_rank (tie->get_bound (dir)->get_column ())
+ if (dir * Paper_column::get_rank (tie->get_bound (dir)->get_column ())
> dir * Paper_column::get_rank (me->get_bound (dir)->get_column ()))
{
me->set_bound (dir, Tie::head (tie, dir));
}
ADD_INTERFACE (Tie_column, "tie-column-interface",
- "Object that sets directions of multiple ties in a tied chord",
- "direction");
+ "Object that sets directions of multiple ties in a tied chord",
+ "direction");
-/*
+/*
tie-engraver.cc -- implement Tie_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "tie.hh"
#include "context.hh"
Grob *head_;
SCM tie_definition_;
Music *event_;
- Head_event_tuple()
+ Head_event_tuple ()
{
}
- Head_event_tuple(Grob *h, Music *m, SCM def)
+ Head_event_tuple (Grob *h, Music *m, SCM def)
{
head_ = h;
event_ = m;
Link_array<Grob> now_heads_;
Array<Head_event_tuple> heads_to_tie_;
Link_array<Grob> ties_;
-
- Spanner * tie_column_;
-
+
+ Spanner *tie_column_;
+
protected:
virtual void stop_translation_timestep ();
virtual void derived_mark () const;
virtual void start_translation_timestep ();
virtual void acknowledge_grob (Grob_info);
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void process_music ();
- void typeset_tie (Grob*);
+ void typeset_tie (Grob *);
public:
TRANSLATOR_DECLARATIONS (Tie_engraver);
};
-
void
Tie_engraver::derived_mark () const
{
Engraver::derived_mark ();
- for (int i = 0; i < heads_to_tie_.size(); i++)
+ for (int i = 0; i < heads_to_tie_.size (); i++)
scm_gc_mark (heads_to_tie_[i].tie_definition_);
}
tie_column_ = 0;
}
-
bool
Tie_engraver::try_music (Music *mus)
{
{
event_ = mus;
}
-
+
return true;
}
{
if (Note_head::has_interface (i.grob_))
{
- Grob * h = i.grob_;
+ Grob *h = i.grob_;
now_heads_.push (h);
- for (int i = heads_to_tie_.size (); i--;)
+ for (int i = heads_to_tie_.size (); i--;)
{
- Grob *th = heads_to_tie_[i].head_;
- Music * right_mus = unsmob_music (h->get_property ("cause"));
- Music * left_mus = unsmob_music (th->get_property ("cause"));
+ Grob *th = heads_to_tie_[i].head_;
+ Music *right_mus = unsmob_music (h->get_property ("cause"));
+ Music *left_mus = unsmob_music (th->get_property ("cause"));
/*
maybe should check positions too.
- */
+ */
if (right_mus && left_mus
&& ly_c_equal_p (right_mus->get_property ("pitch"),
- left_mus->get_property ("pitch")))
+ left_mus->get_property ("pitch")))
{
- Grob * p = new Spanner (heads_to_tie_[i].tie_definition_,
- context()->get_grob_key ("Tie"));
+ Grob *p = new Spanner (heads_to_tie_[i].tie_definition_,
+ context ()->get_grob_key ("Tie"));
announce_grob (p, heads_to_tie_[i].event_->self_scm ());
Tie::set_interface (p); // cannot remove yet!
-
+
Tie::set_head (p, LEFT, th);
Tie::set_head (p, RIGHT, h);
-
+
ties_.push (p);
heads_to_tie_.del (i);
}
{
context ()->set_property ("tieMelismaBusy",
ly_bool2scm (heads_to_tie_.size ()));
-
+
}
void
{
heads_to_tie_.clear ();
}
-
- for (int i = 0; i< ties_.size (); i++)
+
+ for (int i = 0; i< ties_.size (); i++)
{
typeset_tie (ties_[i]);
}
ties_.clear ();
tie_column_ = 0;
}
-
+
if (event_)
{
SCM start_definition
= updated_grob_properties (context (), ly_symbol2scm ("Tie"));
if (!to_boolean (get_property ("tieWaitForNote")))
- heads_to_tie_.clear();
+ heads_to_tie_.clear ();
- for (int i = 0; i < now_heads_.size(); i++)
+ for (int i = 0; i < now_heads_.size (); i++)
{
heads_to_tie_.push (Head_event_tuple (now_heads_[i], event_,
- start_definition
- ));
- }
+ start_definition));
+ }
}
-
+
event_ = 0;
now_heads_.clear ();
}
Direction d = LEFT;
Drul_array<Grob *> new_head_drul;
new_head_drul[LEFT] = Tie::head (her, LEFT);
- new_head_drul[RIGHT] = Tie::head (her, RIGHT);
- do {
- if (!Tie::head (her, d))
- new_head_drul[d] = Tie::head (her, (Direction)-d);
- } while (flip (&d) != LEFT);
+ new_head_drul[RIGHT] = Tie::head (her, RIGHT);
+ do
+ {
+ if (!Tie::head (her, d))
+ new_head_drul[d] = Tie::head (her, (Direction) - d);
+ }
+ while (flip (&d) != LEFT);
index_set_cell (her->get_property ("head-pair"), LEFT, new_head_drul[LEFT]->self_scm ());
index_set_cell (her->get_property ("head-pair"), RIGHT, new_head_drul[RIGHT]->self_scm ());
}
-
ADD_TRANSLATOR (Tie_engraver,
-/* descr */ "Generate ties between noteheads of equal pitch.",
-/* creats*/ "Tie TieColumn",
-/* accepts */ "tie-event",
-/* acks */ "rhythmic-head-interface",
-/* reads */ "tieMelismaBusy",
-/* write */ "");
+ /* descr */ "Generate ties between noteheads of equal pitch.",
+ /* creats*/ "Tie TieColumn",
+ /* accepts */ "tie-event",
+ /* acks */ "rhythmic-head-interface",
+ /* reads */ "tieMelismaBusy",
+ /* write */ "");
-/*
+/*
tie-performer.cc -- implement Tie_performer
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "context.hh"
#include "audio-item.hh"
Array<Audio_element_info> heads_to_tie_;
bool ties_created_;
-
+
protected:
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
virtual void acknowledge_audio_element (Audio_element_info);
- virtual bool try_music (Music*);
+ virtual bool try_music (Music *);
virtual void process_music ();
public:
TRANSLATOR_DECLARATIONS (Tie_performer);
Tie_performer::Tie_performer ()
{
event_ = 0;
- last_event_ = 0;
+ last_event_ = 0;
ties_created_ = false;
}
{
event_ = mus;
}
-
+
return true;
}
void
Tie_performer::acknowledge_audio_element (Audio_element_info inf)
{
- if (Audio_note * an = dynamic_cast<Audio_note *> (inf.elem_))
+ if (Audio_note *an = dynamic_cast<Audio_note *> (inf.elem_))
{
now_heads_.push (inf);
- for (int i = heads_to_tie_.size (); i--;)
+ for (int i = heads_to_tie_.size (); i--;)
{
- Music * right_mus = inf.event_;
-
- Audio_note *th = dynamic_cast<Audio_note*> (heads_to_tie_[i].elem_);
- Music * left_mus = heads_to_tie_[i].event_;
+ Music *right_mus = inf.event_;
+
+ Audio_note *th = dynamic_cast<Audio_note *> (heads_to_tie_[i].elem_);
+ Music *left_mus = heads_to_tie_[i].event_;
if (right_mus && left_mus
&& ly_c_equal_p (right_mus->get_property ("pitch"),
left_mus->get_property ("pitch")))
{
an->tie_to (th);
- ties_created_ = true;
+ ties_created_ = true;
}
}
}
{
context ()->set_property ("tieMelismaBusy",
ly_bool2scm (heads_to_tie_.size ()));
-
+
}
void
last_event_ = 0;
ties_created_ = false;
}
-
+
if (event_)
{
heads_to_tie_ = now_heads_;
}
ADD_TRANSLATOR (Tie_performer,
-/* descr */ "Generate ties between noteheads of equal pitch.",
-/* creats*/ "",
-/* accepts */ "tie-event",
-/* acks */ "",
-/* reads */ "tieMelismaBusy",
-/* write */ "");
+ /* descr */ "Generate ties between noteheads of equal pitch.",
+ /* creats*/ "",
+ /* accepts */ "tie-event",
+ /* acks */ "",
+ /* reads */ "tieMelismaBusy",
+ /* write */ "");
c4 \staffchange c4
do we have non-horizontal ties then?
- */
-
+*/
void
-Tie::set_head (Grob*me, Direction d, Grob * h)
+Tie::set_head (Grob *me, Direction d, Grob *h)
{
assert (!head (me, d));
index_set_cell (me->get_property ("head-pair"), d, h->self_scm ());
-
- dynamic_cast<Spanner*> (me)->set_bound (d, h);
+
+ dynamic_cast<Spanner *> (me)->set_bound (d, h);
me->add_dependency (h);
}
void
-Tie::set_interface (Grob*me)
+Tie::set_interface (Grob *me)
{
me->set_property ("head-pair", scm_cons (SCM_EOL, SCM_EOL));
}
-
-Grob*
-Tie::head (Grob*me, Direction d)
+Grob *
+Tie::head (Grob *me, Direction d)
{
SCM c = me->get_property ("head-pair");
int
Tie::get_column_rank (Grob *me, Direction d)
{
- Spanner *span = dynamic_cast<Spanner*> (me);
- Grob * h = head (me, d);
+ Spanner *span = dynamic_cast<Spanner *> (me);
+ Grob *h = head (me, d);
if (!h)
h = span->get_bound (d);
- Grob *col = dynamic_cast<Item*> (h)->get_column ();
+ Grob *col = dynamic_cast<Item *> (h)->get_column ();
return Paper_column::get_rank (col);
}
Real
-Tie::get_position (Grob*me)
+Tie::get_position (Grob *me)
{
Direction d = head (me, LEFT) ? LEFT:RIGHT;
return Staff_symbol_referencer::get_position (head (me, d));
}
-
/*
Default: Put the tie oppositie of the stem [Wanske p231]
In case of chords: Tie_column takes over
-
+
The direction of the Tie is more complicated (See [Ross] p136 and
further).
- (what about linebreaks? )
-
+ (what about linebreaks? )
*/
Direction
-Tie::get_default_dir (Grob*me)
+Tie::get_default_dir (Grob *me)
{
- Item * sl = head (me, LEFT) ? Rhythmic_head::get_stem (head (me, LEFT)) :0;
- Item * sr = head (me, RIGHT) ? Rhythmic_head::get_stem (head (me, RIGHT)) :0;
+ Item *sl = head (me, LEFT) ? Rhythmic_head::get_stem (head (me, LEFT)) :0;
+ Item *sr = head (me, RIGHT) ? Rhythmic_head::get_stem (head (me, RIGHT)) :0;
if (sl && sr)
{
if (get_grob_direction (sl) == UP
else if (sl || sr)
{
Item *s = sl ? sl : sr;
- return - get_grob_direction (s);
+ return -get_grob_direction (s);
}
-
return UP;
}
-
void
-Tie::set_direction (Grob*me)
+Tie::set_direction (Grob *me)
{
if (!get_grob_direction (me))
{
/*
TODO: we should also use thickness for computing the clearance
between head and tie. Very thick ties will now touch the note head.
-
- */
+*/
SCM
Tie::get_control_points (SCM smob)
-{
- Spanner*me = unsmob_spanner (smob);
- Direction headdir = CENTER;
+{
+ Spanner *me = unsmob_spanner (smob);
+ Direction headdir = CENTER;
if (head (me, LEFT))
headdir = LEFT;
else if (head (me, RIGHT))
set_direction (me);
Direction dir = get_grob_direction (me);
-
+
Real staff_space = Staff_symbol_referencer::staff_space (me);
Real x_gap_f = robust_scm2double (me->get_property ("x-gap"), 0);
- Grob* l = me->get_bound (LEFT);
- Grob* r = me->get_bound (RIGHT);
+ Grob *l = me->get_bound (LEFT);
+ Grob *r = me->get_bound (RIGHT);
- Grob* commonx = me->common_refpoint (l, X_AXIS);
+ Grob *commonx = me->common_refpoint (l, X_AXIS);
commonx = me->common_refpoint (r, X_AXIS);
-
+
Real left_x;
/*
- the tie has to be long enough to be visible, but should not go
+ the tie has to be long enough to be visible, but should not go
through key sigs. In the 1.5 series the pref.matter - note
distance is fixed , so this won't be a problem anymore.
- */
- Real lambda = 0.9;
-
+ */
+ Real lambda = 0.9;
+
if (Note_head::has_interface (l))
{
Real where = RIGHT;
/*
This correction is due te the shape of the black note head.
- */
+ */
if (Rhythmic_head::duration_log (l) == 2)
where += dir* 0.2;
left_x = l->extent (l, X_AXIS).linear_combination (where)
}
else
left_x = l->extent (l, X_AXIS).linear_combination (lambda);
-
Real width;
if (Note_head::has_interface (l) && Note_head::has_interface (r))
{
- width =
- + r->extent (commonx, X_AXIS)[LEFT]
+ width
+ = + r->extent (commonx, X_AXIS)[LEFT]
- l->extent (commonx, X_AXIS)[RIGHT]
-2 * x_gap_f;
}
- l->extent (commonx, X_AXIS)[RIGHT]
- 2 * x_gap_f;
else
- width =
- - l->extent (commonx, X_AXIS).linear_combination (lambda)
+ width
+ = -l->extent (commonx, X_AXIS).linear_combination (lambda)
+ r->extent (commonx, X_AXIS)[LEFT]
- 2 * x_gap_f;
}
-
-
SCM details = me->get_property ("details");
SCM lim // groetjes aan de chirurgendochter.
= scm_assq (ly_symbol2scm ("height-limit"), details);
-
- Real h_inf = scm_to_double (scm_cdr (lim)) * staff_space;
+
+ Real h_inf = scm_to_double (scm_cdr (lim)) * staff_space;
Real r_0 = scm_to_double (scm_cdr (scm_assq (ly_symbol2scm ("ratio"), details)));
- Bezier b = slur_shape (width, h_inf, r_0);
-
+ Bezier b = slur_shape (width, h_inf, r_0);
+
/*
I think this better, particularly for small ties. It always allows the user to move ties if
they seem in the wrong place
*/
- Real ypos = Tie::get_position (me) * staff_space/2
+ Real ypos = Tie::get_position (me) * staff_space / 2
+ dir * scm_to_double (me->get_property ("y-offset"));;
/*
Make sure we don't start on a dots
- */
+ */
if (Note_head::has_interface (l) && Rhythmic_head::get_dots (l))
{
- Grob* dots = Rhythmic_head::get_dots (l);
+ Grob *dots = Rhythmic_head::get_dots (l);
if (fabs (staff_space * Staff_symbol_referencer::get_position (dots) /2
- - ypos) < 0.5)
+ - ypos) < 0.5)
{
- ypos += 0.5 * dir ;
+ ypos += 0.5 * dir;
}
}
-
/*
todo: prevent ending / staffline collision.
todo: tie / stem collision
- */
+ */
b = slur_shape (width, h_inf, r_0);
b.scale (1, dir);
b.translate (Offset (left_x, ypos));
-
/*
Avoid colliding of the horizontal part with stafflines.
-
+
TODO: redo this, heuristic is half-baken, and ties often look ugly
as a result.
TODO: doesn't work when on staff with even number of lines.
- */
+ */
Array<Real> horizontal (b.solve_derivative (Offset (1, 0)));
if (horizontal.size ())
{
/*
ugh. Doesnt work for non-horizontal curves.
- */
+ */
Real y = b.curve_point (horizontal[0])[Y_AXIS];
- Real ry = rint (y/staff_space) * staff_space;
+ Real ry = rint (y / staff_space) * staff_space;
Real diff = ry - y;
Real newy = y;
Real clear = staff_space * scm_to_double (me->get_property ("staffline-clearance"));
- if (fabs (y) <=
- Staff_symbol_referencer::staff_radius (me) * staff_space + clear
+ if (fabs (y)
+ <= Staff_symbol_referencer::staff_radius (me) * staff_space + clear
&& fabs (diff) < clear)
{
Real y1 = ry + clear;
Any way. This test is to make sure that staffline
collision avoidance does not result in completely flat
ties.
- */
+ */
if (fabs (y1 - ypos) < 0.5)
y1 = y2;
else if (fabs (y2 - ypos) < 0.5)
y2 = y1;
-
+
newy = (fabs (y1 - y) < fabs (y2 - y)) ? y1 : y2;
-
+
// newy = ry - 0.5 * staff_space * sign (diff) ;
/*
we don't want horizontal ties
- */
+ */
if (fabs (newy - b.control_[0][Y_AXIS]) < 1e-2)
{
- newy = newy + dir * staff_space;
+ newy = newy + dir * staff_space;
}
}
Real y0 = b.control_ [0][Y_AXIS];
- b.control_[2][Y_AXIS] =
- b.control_[1][Y_AXIS] =
- (b.control_[1][Y_AXIS] - y0) * ((newy - y0) / (y - y0)) + y0;
+ b.control_[2][Y_AXIS]
+ = b.control_[1][Y_AXIS]
+ = (b.control_[1][Y_AXIS] - y0) * ((newy - y0) / (y - y0)) + y0;
}
else
programming_error ("Tie is nowhere horizontal");
-
-
SCM controls = SCM_EOL;
for (int i = 4; i--;)
controls = scm_cons (ly_offset2scm (b.control_[i]), controls);
return controls;
}
-
MAKE_SCHEME_CALLBACK (Tie, print, 1);
SCM
-Tie::print (SCM smob)
+Tie::print (SCM smob)
{
- Grob*me = unsmob_grob (smob);
+ Grob *me = unsmob_grob (smob);
SCM cp = me->get_property ("control-points");
if (!scm_is_pair (cp)) // list is more accurate
if (!scm_is_pair (cp))
return Stencil ().smobbed_copy ();
-
+
Real thick
= Staff_symbol_referencer::line_thickness (me)
- * robust_scm2double (me->get_property ("thickness"), 1);
+ * robust_scm2double (me->get_property ("thickness"), 1);
Bezier b;
int i = 0;
b.control_[i] = ly_scm2offset (scm_car (s));
i++;
}
-
- Stencil a = Lookup::slur (b, get_grob_direction (me) * thick, thick);
-
- return a.smobbed_copy ();
-}
+ Stencil a = Lookup::slur (b, get_grob_direction (me) * thick, thick);
+ return a.smobbed_copy ();
+}
ADD_INTERFACE (Tie, "tie-interface",
- "A tie connecting two noteheads.\n"
- ,
- "y-offset staffline-clearance control-points head-pair details thickness x-gap direction minimum-length");
+ "A tie connecting two noteheads.\n",
+ "y-offset staffline-clearance control-points head-pair details thickness x-gap direction minimum-length");
-/*
+/*
time-scaled-music-iterator.cc -- implement Time_scaled_music_iterator
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "time-scaled-music-iterator.hh"
#include "context.hh"
Music_wrapper_iterator::process (m);
}
-
+
IMPLEMENT_CTOR_CALLBACK (Time_scaled_music_iterator);
#include "misc.hh"
/**
- generate time_signatures.
- */
+ generate time_signatures.
+*/
class Time_signature_engraver : public Engraver
{
Item *time_signature_;
TRANSLATOR_DECLARATIONS (Time_signature_engraver);
};
-
Time_signature_engraver::Time_signature_engraver ()
-{
+{
time_signature_ = 0;
last_time_fraction_ = SCM_BOOL_F;
}
Todo: should make typecheck?
OTOH, Tristan Keuris writes 8/20 in his Intermezzi.
- */
+ */
warning (_f ("Found strange time signature %d/%d.",
- den,
- scm_to_int (scm_car (fr))
- ));
+ den,
+ scm_to_int (scm_car (fr))));
}
-
-
- last_time_fraction_ = fr;
+
+ last_time_fraction_ = fr;
time_signature_ = make_item ("TimeSignature", SCM_EOL);
time_signature_->set_property ("fraction", fr);
}
{
time_signature_ = 0;
}
-
ADD_TRANSLATOR (Time_signature_engraver,
-/* descr */ "Create a TimeSignature whenever @code{timeSignatureFraction} changes",
-/* creats*/ "TimeSignature",
-/* accepts */ "",
-/* acks */ "",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Create a TimeSignature whenever @code{timeSignatureFraction} changes",
+ /* creats*/ "TimeSignature",
+ /* accepts */ "",
+ /* acks */ "",
+ /* reads */ "",
+ /* write */ "");
SCM prev_fraction_;
private:
- Audio_time_signature* audio_;
+ Audio_time_signature *audio_;
};
-
Time_signature_performer::Time_signature_performer ()
{
prev_fraction_ = SCM_BOOL_F;
{
}
-
void
Time_signature_performer::create_audio_elements ()
{
prev_fraction_ = fr;
int b = scm_to_int (scm_car (fr));
int o = scm_to_int (scm_cdr (fr));
-
+
audio_ = new Audio_time_signature (b, o);
Audio_element_info info (audio_, 0);
announce_element (info);
-/*
+/*
time-signature.cc -- implement Time_signature
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "time-signature.hh"
this file should go ; The formatting can completely be done with
markups.
-
- */
+*/
MAKE_SCHEME_CALLBACK (Time_signature, print, 1);
SCM
-Time_signature::print (SCM smob)
+Time_signature::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
SCM st = me->get_property ("style");
m = numbered_time_signature (me, n, d);
if (Staff_symbol_referencer::line_count (me) % 2 == 0)
- m.translate_axis (Staff_symbol_referencer::staff_space (me) / 2 , Y_AXIS);
+ m.translate_axis (Staff_symbol_referencer::staff_space (me) / 2, Y_AXIS);
return m.smobbed_copy ();
}
if (style == "C")
{
if /* neither C2/2 nor C4/4 */
- (((n != 2) || (d != 2)) &&
- ((n != 4) || (d != 4)))
+ (((n != 2) || (d != 2))
+ && ((n != 4) || (d != 4)))
{
return numbered_time_signature (me, n, d);
}
return out;
/* If there is no such symbol, we default to the numbered style.
- (Here really with a warning!) */
+ (Here really with a warning!) */
me->warning (_f ("time signature symbol `%s' not found; "
"reverting to numbered style", char_name));
return numbered_time_signature (me, n, d);
}
Stencil
-Time_signature::numbered_time_signature (Grob*me, int num, int den)
+Time_signature::numbered_time_signature (Grob *me, int num, int den)
{
SCM chain = me->get_property_alist_chain (Font_interface::text_font_alist_chain (me));
chain = scm_cons (scm_list_1 (scm_cons (ly_symbol2scm ("font-encoding"),
- ly_symbol2scm ("fetaNumber"))),
+ ly_symbol2scm ("fetaNumber"))),
chain);
-
+
SCM sn = Text_interface::interpret_markup (me->get_layout ()->self_scm (), chain,
- scm_makfrom0str (to_string (num).to_str0 ()));
+ scm_makfrom0str (to_string (num).to_str0 ()));
SCM sd = Text_interface::interpret_markup (me->get_layout ()->self_scm (), chain,
- scm_makfrom0str (to_string (den).to_str0 ()));
+ scm_makfrom0str (to_string (den).to_str0 ()));
Stencil n = *unsmob_stencil (sn);
Stencil d = *unsmob_stencil (sd);
-
+
n.align_to (X_AXIS, CENTER);
d.align_to (X_AXIS, CENTER);
Stencil m;
}
m.align_to (X_AXIS, LEFT);
-
+
return m;
}
ADD_INTERFACE (Time_signature, "time-signature-interface",
- "A time signature, in different styles.\n"
-" The following values for 'style are are recognized:\n"
-"\n"
-" @table @samp\n"
-" @item @code{C}\n"
-" 4/4 and 2/2 are typeset as C and struck C, respectively. All\n"
-" other time signatures are written with two digits.\n"
-"\n"
-" @item @code{neomensural}\n"
-" 2/2, 3/2, 2/4, 3/4, 4/4, 6/4, 9/4, 4/8, 6/8 and 9/8 are\n"
-" typeset with neo-mensural style mensuration marks. All other time\n"
-" signatures are written with two digits.\n"
-"\n"
-" @item @code{mensural}\n"
-" 2/2, 3/2, 2/4, 3/4, 4/4, 6/4, 9/4, 4/8, 6/8 and 9/8 are\n"
-" typeset with mensural style mensuration marks. All other time\n"
-" signatures are written with two digits.\n"
-"\n"
-" @item @code{single-digit}\n"
-" All time signatures are typeset with a single\n"
-" digit, e.g. 3/2 is written as 3.\n"
-" @end table\n"
-"\n"
-"See also the test-file @file{input/test/time.ly}.\n",
- "fraction style");
+ "A time signature, in different styles.\n"
+ " The following values for 'style are are recognized:\n"
+ "\n"
+ " @table @samp\n"
+ " @item @code{C}\n"
+ " 4/4 and 2/2 are typeset as C and struck C, respectively. All\n"
+ " other time signatures are written with two digits.\n"
+ "\n"
+ " @item @code{neomensural}\n"
+ " 2/2, 3/2, 2/4, 3/4, 4/4, 6/4, 9/4, 4/8, 6/8 and 9/8 are\n"
+ " typeset with neo-mensural style mensuration marks. All other time\n"
+ " signatures are written with two digits.\n"
+ "\n"
+ " @item @code{mensural}\n"
+ " 2/2, 3/2, 2/4, 3/4, 4/4, 6/4, 9/4, 4/8, 6/8 and 9/8 are\n"
+ " typeset with mensural style mensuration marks. All other time\n"
+ " signatures are written with two digits.\n"
+ "\n"
+ " @item @code{single-digit}\n"
+ " All time signatures are typeset with a single\n"
+ " digit, e.g. 3/2 is written as 3.\n"
+ " @end table\n"
+ "\n"
+ "See also the test-file @file{input/test/time.ly}.\n",
+ "fraction style");
#include "grob.hh"
/**
- Do time bookkeeping
- */
+ Do time bookkeeping
+*/
class Timing_engraver : public Timing_translator, public Engraver
{
protected:
/* Needed to know whether we're advancing in grace notes, or not. */
Moment last_moment_;
-
+
virtual void start_translation_timestep ();
virtual void initialize ();
- virtual void process_music();
+ virtual void process_music ();
virtual void stop_translation_timestep ();
public:
TRANSLATOR_DECLARATIONS (Timing_engraver);
};
-
Timing_engraver::Timing_engraver ()
{
last_moment_.main_part_ = Rational (-1);
}
-
void
Timing_engraver::initialize ()
{
Timing_translator::initialize ();
-
+
SCM which = get_property ("whichBar");
Moment now = now_mom ();
-
+
/* Set the first bar of the score? */
if (!scm_is_string (which))
which = (now.main_part_ || now.main_part_ == last_moment_.main_part_)
}
void
-Timing_engraver::process_music()
+Timing_engraver::process_music ()
{
Timing_translator::process_music ();
- bool start_of_measure = (last_moment_.main_part_ != now_mom().main_part_
+ bool start_of_measure = (last_moment_.main_part_ != now_mom ().main_part_
&& !measure_position ().main_part_);
/*
We can't do this in start_translation_timestep(), since time sig
changes won't have happened by then.
- */
+ */
if (start_of_measure)
{
Moment mlen = Moment (measure_length ());
unsmob_grob (get_property ("currentCommandColumn"))
- ->set_property ("measure-length", mlen.smobbed_copy ());
+ ->set_property ("measure-length", mlen.smobbed_copy ());
}
}
-
void
Timing_engraver::start_translation_timestep ()
{
SCM always = get_property ("barAlways");
- if ( start_of_measure || (to_boolean (always)))
+ if (start_of_measure || (to_boolean (always)))
{
/* should this work, or be junked? See input/bugs/no-bars.ly */
which = get_property ("defaultBarType");
last_moment_ = now_mom ();
}
-
ADD_TRANSLATOR (Timing_engraver,
-/* descr */ " Responsible for synchronizing timing information from staves. "
-"Normally in @code{Score}. In order to create polyrhythmic music, "
-"this engraver should be removed from @code{Score} and placed in "
-"@code{Staff}. "
-"\n\nThis engraver adds the alias @code{Timing} to its containing context."
-
- ,
-/* creats*/ "",
-/* accepts */ "",
-/* acks */ "",
-/* reads */ "automaticBars whichBar barAlways defaultBarType skipBars timing measureLength measurePosition currentBarNumber",
-/* write */ "");
+ /* descr */ " Responsible for synchronizing timing information from staves. "
+ "Normally in @code{Score}. In order to create polyrhythmic music, "
+ "this engraver should be removed from @code{Score} and placed in "
+ "@code{Staff}. "
+ "\n\nThis engraver adds the alias @code{Timing} to its containing context.",
+ /* creats*/ "",
+ /* accepts */ "",
+ /* acks */ "",
+ /* reads */ "automaticBars whichBar barAlways defaultBarType skipBars timing measureLength measurePosition currentBarNumber",
+ /* write */ "");
/*
Hmm. We insert the bar moment every time we process a
moment. A waste of cpu?
- */
+ */
&& !now.grace_part_)
global->add_moment_to_process (now + barleft);
}
{
/*
- move this to engraver-init.ly?
- */
+ move this to engraver-init.ly?
+ */
context ()->add_alias (ly_symbol2scm ("Timing"));
- context ()->set_property ("timing" , SCM_BOOL_T);
- context ()->set_property ("currentBarNumber" , scm_int2num (1));
+ context ()->set_property ("timing", SCM_BOOL_T);
+ context ()->set_property ("currentBarNumber", scm_int2num (1));
context ()->set_property ("timeSignatureFraction",
- scm_cons (scm_int2num (4), scm_int2num (4)));
+ scm_cons (scm_int2num (4), scm_int2num (4)));
/*
Do not init measurePosition; this should be done from global
context.
- */
+ */
context ()->set_property ("measureLength", Moment (Rational (1)).smobbed_copy ());
context ()->set_property ("beatLength", Moment (Rational (1, 4)).smobbed_copy ());
}
Timing_translator::measure_position () const
{
SCM sm = get_property ("measurePosition");
-
- Moment m = 0;
+
+ Moment m = 0;
if (unsmob_moment (sm))
{
m = *unsmob_moment (sm);
while (m.main_part_ < Rational (0))
m.main_part_ += measure_length ();
}
-
+
return m;
}
Global_context *global = get_global_context ();
Moment now = global->now_mom ();
- Moment dt = now - global->previous_moment ();
+ Moment dt = now - global->previous_moment ();
if (dt < Moment (0))
{
programming_error ("Moving backwards in time");
programming_error ("Moving infinitely to future");
dt = 0;
}
-
+
if (!dt.to_bool ())
return;
context ()->set_property ("measurePosition",
measposp.smobbed_copy ());
}
-
+
measposp += dt;
-
+
SCM barn = get_property ("currentBarNumber");
int b = 0;
if (scm_is_number (barn))
while (c && measposp.main_part_ >= len)
{
measposp.main_part_ -= len;
- b ++;
+ b++;
}
context ()->set_property ("currentBarNumber", scm_int2num (b));
}
ADD_TRANSLATOR (Timing_translator,
- "This engraver adds the alias "
- "@code{Timing} to its containing context."
- ,
+ "This engraver adds the alias "
+ "@code{Timing} to its containing context.",
- "", "", "", "", "");
+ "", "", "", "", "");
Scheme_hash_table *global_translator_dict = 0;
-LY_DEFINE (get_all_translators, "ly:get-all-translators", 0, 0, 0, (),
- "Return a list of all translator objects that may be instantiated. "
- )
+LY_DEFINE (get_all_translators, "ly:get-all-translators", 0, 0, 0, (),
+ "Return a list of all translator objects that may be instantiated. ")
{
- SCM l = global_translator_dict ? global_translator_dict->to_alist () : SCM_EOL;
+ SCM l = global_translator_dict ? global_translator_dict->to_alist () : SCM_EOL;
for (SCM s = l; scm_is_pair (s); s = scm_cdr (s))
{
if (!global_translator_dict)
global_translator_dict = new Scheme_hash_table;
- SCM k = ly_symbol2scm (classname (t));
+ SCM k = ly_symbol2scm (classname (t));
global_translator_dict->set (k, t->self_scm ());
scm_gc_unprotect_object (t->self_scm ());
}
-Translator*
+Translator *
get_translator (SCM sym)
{
SCM v = SCM_BOOL_F;
#include "main.hh"
#include "music.hh"
-Translator_group*
+Translator_group *
Translator_group::get_daddy_translator () const
{
return context ()->get_parent_context ()->implementation ();
}
-
void
translator_each (SCM list, Translator_method method)
{
(unsmob_translator (scm_car (p))->*method) ();
}
-
void
Translator_group::initialize ()
{
context ()->set_property ("acceptHashTable", tab);
}
-
bool
-translator_accepts_any_of (Translator*tr, SCM ifaces)
+translator_accepts_any_of (Translator *tr, SCM ifaces)
{
SCM ack_ifs = scm_assoc (ly_symbol2scm ("events-accepted"),
tr->translator_description ());
find_accept_translators (SCM gravlist, SCM ifaces)
{
SCM l = SCM_EOL;
- for (SCM s = gravlist; scm_is_pair (s); s = scm_cdr (s))
+ for (SCM s = gravlist; scm_is_pair (s); s = scm_cdr (s))
{
- Translator* tr = unsmob_translator (scm_car (s));
+ Translator *tr = unsmob_translator (scm_car (s));
if (translator_accepts_any_of (tr, ifaces))
- l = scm_cons (tr->self_scm (), l);
+ l = scm_cons (tr->self_scm (), l);
}
l = scm_reverse_x (l, SCM_EOL);
}
bool
-Translator_group::try_music (Music* m)
+Translator_group::try_music (Music *m)
{
SCM tab = get_property ("acceptHashTable");
SCM name = scm_sloppy_assq (ly_symbol2scm ("name"),
for (SCM p = accept_list; scm_is_pair (p); p = scm_cdr (p))
{
- Translator * t = unsmob_translator (scm_car (p));
+ Translator *t = unsmob_translator (scm_car (p));
if (t && t->try_music (m))
return true;
}
return false;
}
-
SCM
Translator_group::get_simple_trans_list ()
{
return simple_trans_list_;
}
-
void
-recurse_over_translators (Context * c, Translator_method ptr, Direction dir)
+recurse_over_translators (Context *c, Translator_method ptr, Direction dir)
{
- Translator_group * tg
- = dynamic_cast<Translator_group*> (c->implementation ());
+ Translator_group *tg
+ = dynamic_cast<Translator_group *> (c->implementation ());
/*
- Top down:
- */
+ Top down:
+ */
if (dir == DOWN)
{
translator_each (tg->get_simple_trans_list (),
}
}
-Translator_group::Translator_group()
+Translator_group::Translator_group ()
{
simple_trans_list_ = SCM_EOL;
}
void
Translator_group::derived_mark () const
{
- scm_gc_mark (simple_trans_list_);
+ scm_gc_mark (simple_trans_list_);
}
source file of the GNU LilyPond music typesetter
(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "context-def.hh"
#include "translator-group.hh"
LY_DEFINE (ly_translator_name, "ly:translator-name",
1, 0, 0, (SCM trans),
- "Return the type name of the translator object @var{trans}. "
+ "Return the type name of the translator object @var{trans}. "
"The name is a symbol.")
{
Translator *tr = unsmob_translator (trans);
}
LY_DEFINE (ly_translator_description, "ly:translator-description",
- 1, 0, 0, (SCM me),
- "Return an alist of properties of translator @var{me}.")
+ 1, 0, 0, (SCM me),
+ "Return an alist of properties of translator @var{me}.")
{
Translator *tr = unsmob_translator (me);
SCM_ASSERT_TYPE (tr, me, SCM_ARG1, __FUNCTION__, "Translator");
int
Translator::print_smob (SCM s, SCM port, scm_print_state *)
{
- Translator *me = (Translator*) SCM_CELL_WORD_1 (s);
+ Translator *me = (Translator *) SCM_CELL_WORD_1 (s);
scm_puts ("#<Translator ", port);
scm_puts (classname (me), port);
scm_puts (" >", port);
void
Translator::process_music ()
{
-
+
}
Translator::Translator ()
{
return false;
}
-
Moment
Translator::now_mom () const
return daddy_context_->get_output_def ();
}
-
-Translator_group*
+Translator_group *
Translator::get_daddy_translator () const
{
return daddy_context_->implementation ();
}
-
SCM
Translator::internal_get_property (SCM sym) const
{
- It is called before any user information enters the translators.
(i.e. any \property or event is not processed yet.)
-
- */
+*/
void
Translator::start_translation_timestep ()
{
{
}
-
/*
-
SMOBS
-
*/
SCM
Translator::mark_smob (SCM sm)
{
- Translator * me = (Translator*) SCM_CELL_WORD_1 (sm);
+ Translator *me = (Translator *) SCM_CELL_WORD_1 (sm);
me->derived_mark ();
return SCM_EOL;
}
return SCM_EOL;
}
-
Global_context *
Translator::get_global_context () const
{
return daddy_context_ ->get_global_context ();
}
-
Score_context *
Translator::get_score_context () const
{
return daddy_context_->get_score_context ();
-}
-
+}
SCM
Translator::static_translator_description ()const
return SCM_EOL;
}
-
IMPLEMENT_SMOBS (Translator);
IMPLEMENT_DEFAULT_EQUAL_P (Translator);
IMPLEMENT_TYPE_P (Translator, "ly:translator?");
void
Translator::derived_mark () const
{
-
+
}
C&P from text-spanner.cc
- todo: ending should be detected automatically? a new note
- automatically is the end of the trill?
-
- */
+ automatically is the end of the trill?
+*/
#include "note-column.hh"
#include "side-position-interface.hh"
class Trill_spanner_engraver : public Engraver
{
public:
- TRANSLATOR_DECLARATIONS (Trill_spanner_engraver);
+ TRANSLATOR_DECLARATIONS (Trill_spanner_engraver);
protected:
virtual void finalize ();
virtual void acknowledge_grob (Grob_info);
Spanner *span_;
Spanner *finished_;
Music *current_req_;
- Drul_array<Music*> req_drul_;
+ Drul_array<Music *> req_drul_;
void typeset_all ();
};
-
Trill_spanner_engraver::Trill_spanner_engraver ()
{
finished_ = 0;
else
{
current_req_ = req_drul_[START];
- span_ = make_spanner ("TrillSpanner", req_drul_[START]->self_scm ());
+ span_ = make_spanner ("TrillSpanner", req_drul_[START]->self_scm ());
Side_position_interface::set_axis (span_, Y_AXIS);
req_drul_[START] = 0;
}
void
Trill_spanner_engraver::acknowledge_grob (Grob_info info)
{
- Spanner * spans[2] ={span_, finished_};
- for (int i = 0; i < 2 ; i++)
+ Spanner *spans[2] ={span_, finished_};
+ for (int i = 0; i < 2; i++)
{
if (spans[i] && Note_column::has_interface (info.grob_))
{
Side_position_interface::add_support (spans[i], info.grob_);
- add_bound_item (spans[i], dynamic_cast<Item*> (info.grob_));
+ add_bound_item (spans[i], dynamic_cast<Item *> (info.grob_));
}
}
}
void
Trill_spanner_engraver::typeset_all ()
-{
+{
if (finished_)
{
if (!finished_->get_bound (RIGHT))
{
- Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
+ Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
finished_->set_bound (RIGHT, e);
}
finished_ = 0;
{
if (span_ && !span_->get_bound (LEFT))
{
- Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
+ Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
span_->set_bound (LEFT, e);
}
}
ADD_TRANSLATOR (Trill_spanner_engraver,
-/* descr */ "Create trill spanner from a Music.",
-/* creats*/ "TrillSpanner",
-/* accepts */ "trill-span-event",
-/* acks */ "note-column-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Create trill spanner from a Music.",
+ /* creats*/ "TrillSpanner",
+ /* accepts */ "trill-span-event",
+ /* acks */ "note-column-interface",
+ /* reads */ "",
+ /* write */ "");
- There is no support for kneed brackets, or nested brackets.
- number placement for parallel beams should be much more advanced:
- for sloped beams some extra horizontal offset must be introduced.
+ for sloped beams some extra horizontal offset must be introduced.
- number placement is usually done over the center note, not the
- graphical center.
-
- */
+ graphical center.
+*/
/*
-
- TODO: quantise, we don't want to collide with staff lines.
- (or should we be above staff?)
+ TODO: quantise, we don't want to collide with staff lines.
+ (or should we be above staff?)
todo: handle breaking elegantly.
*/
#include "staff-symbol-referencer.hh"
#include "lookup.hh"
-static Grob*
+static Grob *
get_x_bound_grob (Grob *g, Direction my_dir)
{
if (Note_column::get_stem (g)
return g;
}
-
-
-Grob*
+Grob *
Tuplet_bracket::parallel_beam (Grob *me, Link_array<Grob> const &cols, bool *equally_long)
{
/*
- ugh: code dup.
+ ugh: code dup.
*/
- Grob *s1 = Note_column::get_stem (cols[0]);
- Grob *s2 = Note_column::get_stem (cols.top ());
+ Grob *s1 = Note_column::get_stem (cols[0]);
+ Grob *s2 = Note_column::get_stem (cols.top ());
+
+ Grob *b1 = s1 ? Stem::get_beam (s1) : 0;
+ Grob *b2 = s2 ? Stem::get_beam (s2) : 0;
- Grob*b1 = s1 ? Stem::get_beam (s1) : 0;
- Grob*b2 = s2 ? Stem::get_beam (s2) : 0;
-
- Spanner*sp = dynamic_cast<Spanner*> (me);
+ Spanner *sp = dynamic_cast<Spanner *> (me);
*equally_long = false;
if (! (b1 && (b1 == b2) && !sp->is_broken ()))
- return 0;
+ return 0;
Link_array<Grob> beam_stems = extract_grob_array (b1, ly_symbol2scm ("stems"));
if (beam_stems.size () == 0)
*equally_long = 0;
return 0;
}
-
+
*equally_long = (beam_stems[0] == s1 && beam_stems.top () == s2);
return b1;
}
-
/*
TODO:
in the case that there is no bracket, but there is a (single) beam,
follow beam precisely for determining tuplet number location.
-
- */
+*/
MAKE_SCHEME_CALLBACK (Tuplet_bracket, print, 1);
SCM
-Tuplet_bracket::print (SCM smob)
+Tuplet_bracket::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
- Stencil mol;
- Link_array<Grob> columns =
- extract_grob_array (me, ly_symbol2scm ("note-columns"));
+ Stencil mol;
+ Link_array<Grob> columns
+ = extract_grob_array (me, ly_symbol2scm ("note-columns"));
if (!columns.size ())
return mol.smobbed_copy ();
{
SCM lp = me->get_property ("left-position");
- SCM rp = me->get_property ("right-position");
+ SCM rp = me->get_property ("right-position");
if (!scm_is_number (rp) || !scm_is_number (lp))
after_line_breaking (smob);
}
-
+
Real ly = robust_scm2double (me->get_property ("left-position"), 0);
- Real ry = robust_scm2double (me->get_property ("right-position"), 0);
-
+ Real ry = robust_scm2double (me->get_property ("right-position"), 0);
+
bool equally_long = false;
- Grob * par_beam = parallel_beam (me, columns, &equally_long);
+ Grob *par_beam = parallel_beam (me, columns, &equally_long);
- Spanner*sp = dynamic_cast<Spanner*> (me);
+ Spanner *sp = dynamic_cast<Spanner *> (me);
bool bracket_visibility = !(par_beam && equally_long);
bool number_visibility = true;
/*
Fixme: the type of this prop is sucky.
- */
+ */
SCM bracket = me->get_property ("bracket-visibility");
if (scm_is_bool (bracket))
{
else if (bracket == ly_symbol2scm ("if-no-beam"))
bracket_visibility = !par_beam;
- SCM numb = me->get_property ("number-visibility");
+ SCM numb = me->get_property ("number-visibility");
if (scm_is_bool (numb))
{
number_visibility = ly_scm2bool (numb);
}
else if (numb == ly_symbol2scm ("if-no-beam"))
number_visibility = !par_beam;
-
- Grob * commonx = columns[0]->common_refpoint (columns.top (), X_AXIS);
+
+ Grob *commonx = columns[0]->common_refpoint (columns.top (), X_AXIS);
/*
Tuplet brackets are normally not broken, but we shouldn't crash if
they are.
- */
+ */
commonx = commonx->common_refpoint (sp->get_bound (LEFT), X_AXIS);
- commonx = commonx->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
-
+ commonx = commonx->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
+
Direction dir = get_grob_direction (me);
- Grob * lgr = get_x_bound_grob (columns[0], dir);
- Grob * rgr = get_x_bound_grob (columns.top (), dir);
-
+ Grob *lgr = get_x_bound_grob (columns[0], dir);
+ Grob *rgr = get_x_bound_grob (columns.top (), dir);
+
Real x0 = robust_relative_extent (lgr, commonx, X_AXIS)[LEFT];
Real x1 = robust_relative_extent (rgr, commonx, X_AXIS)[RIGHT];
Real w = x1 -x0;
-
+
SCM number = me->get_property ("text");
Output_def *pap = me->get_layout ();
Stencil num;
- if (scm_is_string (number) && number_visibility)
+ if (scm_is_string (number) && number_visibility)
{
SCM properties = Font_interface::text_font_alist_chain (me);
SCM snum = Text_interface::interpret_markup (pap->self_scm (), properties, number);
num = *unsmob_stencil (snum);
num.align_to (X_AXIS, CENTER);
- num.translate_axis (w/2, X_AXIS);
+ num.translate_axis (w / 2, X_AXIS);
num.align_to (Y_AXIS, CENTER);
-
- num.translate_axis ((ry-ly)/2, Y_AXIS);
+
+ num.translate_axis ((ry - ly) / 2, Y_AXIS);
mol.add_stencil (num);
}
-
/*
No bracket when it would be smaller than the number.
TODO: should use GAP in calculation too.
- */
+ */
if (bracket_visibility && number_visibility
&& mol.extent (X_AXIS).length () > w)
{
bracket_visibility = false;
}
-
- if (bracket_visibility)
+
+ if (bracket_visibility)
{
- Real ss = Staff_symbol_referencer::staff_space (me);
+ Real ss = Staff_symbol_referencer::staff_space (me);
Real gap = 0.;
if (!num.extent (X_AXIS).is_empty ())
gap = num.extent (X_AXIS).length () + 1.0;
-
+
SCM fl = me->get_property ("bracket-flare");
SCM eh = me->get_property ("edge-height");
SCM sp = me->get_property ("shorten-pair");
-
+
Direction d = LEFT;
Drul_array<Real> height, flare, shorten;
- do {
- flare[d] = height[d] = shorten[d] = 0.0;
- if (is_number_pair (fl))
- flare[d] += ss * scm_to_double (index_get_cell (fl, d));
- if (is_number_pair (eh))
- height[d] += - dir * ss *scm_to_double (index_get_cell (eh, d));
- if (is_number_pair (sp))
- shorten[d] += ss *scm_to_double (index_get_cell (sp, d));
- }
+ do
+ {
+ flare[d] = height[d] = shorten[d] = 0.0;
+ if (is_number_pair (fl))
+ flare[d] += ss * scm_to_double (index_get_cell (fl, d));
+ if (is_number_pair (eh))
+ height[d] += -dir * ss *scm_to_double (index_get_cell (eh, d));
+ if (is_number_pair (sp))
+ shorten[d] += ss *scm_to_double (index_get_cell (sp, d));
+ }
while (flip (&d) != LEFT);
-
+
Stencil brack = make_bracket (me, Y_AXIS,
- Offset (w, ry - ly),
- height,
+ Offset (w, ry - ly),
+ height,
/*
0.1 = more space at right due to italics
TODO: use italic correction of font.
- */
+ */
Interval (-0.5, 0.5) * gap + 0.1,
- flare, shorten);
+ flare, shorten);
mol.add_stencil (brack);
}
-
+
mol.translate_axis (ly, Y_AXIS);
- mol.translate_axis (x0 - sp->get_bound (LEFT)->relative_coordinate (commonx, X_AXIS), X_AXIS);
+ mol.translate_axis (x0 - sp->get_bound (LEFT)->relative_coordinate (commonx, X_AXIS), X_AXIS);
return mol.smobbed_copy ();
}
TODO: this will fail for very short (shorter than the flare)
brackets.
- */
+*/
Stencil
-Tuplet_bracket::make_bracket (Grob *me, // for line properties.
+Tuplet_bracket::make_bracket (Grob *me, // for line properties.
Axis protusion_axis,
Offset dz,
Drul_array<Real> height,
Drul_array<Real> shorten)
{
Drul_array<Offset> corners (Offset (0, 0), dz);
-
+
Real length = dz.length ();
Drul_array<Offset> gap_corners;
-
Axis bracket_axis = other_axis (protusion_axis);
Drul_array<Offset> straight_corners = corners;
Direction d = LEFT;
- do {
- straight_corners[d] += - d * shorten[d] /length * dz;
- } while (flip (&d) != LEFT);
-
+ do
+ {
+ straight_corners[d] += -d * shorten[d] /length * dz;
+ }
+ while (flip (&d) != LEFT);
- if (gap.is_empty())
+ if (gap.is_empty ())
gap = Interval (0, 0);
- do {
- gap_corners[d] = (dz * 0.5) + gap[d] / length * dz;
- } while (flip (&d) != LEFT);
+ do
+ {
+ gap_corners[d] = (dz * 0.5) + gap[d] / length * dz;
+ }
+ while (flip (&d) != LEFT);
Drul_array<Offset> flare_corners = straight_corners;
- do {
- flare_corners[d][bracket_axis] = straight_corners[d][bracket_axis];
- flare_corners[d][protusion_axis] += height[d];
- straight_corners[d][bracket_axis] += - d * flare[d];
- } while (flip (&d) != LEFT);
+ do
+ {
+ flare_corners[d][bracket_axis] = straight_corners[d][bracket_axis];
+ flare_corners[d][protusion_axis] += height[d];
+ straight_corners[d][bracket_axis] += -d * flare[d];
+ }
+ while (flip (&d) != LEFT);
Stencil m;
- do {
- m.add_stencil (Line_interface::line (me, straight_corners[d],
- gap_corners[d]));
-
- m.add_stencil (Line_interface::line (me, straight_corners[d],
- flare_corners[d]));
- } while (flip (&d) != LEFT);
-
- return m;
-}
+ do
+ {
+ m.add_stencil (Line_interface::line (me, straight_corners[d],
+ gap_corners[d]));
+ m.add_stencil (Line_interface::line (me, straight_corners[d],
+ flare_corners[d]));
+ }
+ while (flip (&d) != LEFT);
+
+ return m;
+}
/*
use first -> last note for slope, and then correct for disturbing
notes in between. */
void
-Tuplet_bracket::calc_position_and_height (Grob*me, Real *offset, Real * dy)
+Tuplet_bracket::calc_position_and_height (Grob *me, Real *offset, Real *dy)
{
- Link_array<Grob> columns =
- extract_grob_array (me, ly_symbol2scm ("note-columns"));
+ Link_array<Grob> columns
+ = extract_grob_array (me, ly_symbol2scm ("note-columns"));
SCM cols = me->get_property ("note-columns");
- Grob * commony = common_refpoint_of_list (cols, me, Y_AXIS);
- Grob * commonx = common_refpoint_of_list (cols, me, X_AXIS);
+ Grob *commony = common_refpoint_of_list (cols, me, Y_AXIS);
+ Grob *commonx = common_refpoint_of_list (cols, me, X_AXIS);
Interval staff;
- if (Grob * st = Staff_symbol_referencer::get_staff_symbol (me))
+ if (Grob *st = Staff_symbol_referencer::get_staff_symbol (me))
staff = st->extent (commony, Y_AXIS);
-
+
Direction dir = get_grob_direction (me);
/*
Use outer non-rest columns to determine slope
- */
+ */
int l = 0;
while (l <columns.size () && Note_column::has_rests (columns[l]))
- l ++;
+ l++;
int r = columns.size ()- 1;
while (r >= l && Note_column::has_rests (columns[r]))
r--;
-
+
if (l < r)
{
Interval rv = columns[r]->extent (commony, Y_AXIS);
Interval lv = columns[l]->extent (commony, Y_AXIS);
rv.unite (staff);
lv.unite (staff);
- Real graphical_dy = rv[dir] - lv[dir];
+ Real graphical_dy = rv[dir] - lv[dir];
Slice ls = Note_column::head_positions_interval (columns[l]);
Slice rs = Note_column::head_positions_interval (columns[r]);
-
+
Interval musical_dy;
musical_dy[UP] = rs[UP] - ls[UP];
musical_dy[DOWN] = rs[DOWN] - ls[DOWN];
else
* dy = 0;
-
- *offset = - dir * infinity_f;
+ *offset = -dir * infinity_f;
if (!columns.size ())
return;
-
-
- Grob * lgr = get_x_bound_grob (columns[0], dir);
- Grob * rgr = get_x_bound_grob (columns.top (), dir);
+ Grob *lgr = get_x_bound_grob (columns[0], dir);
+ Grob *rgr = get_x_bound_grob (columns.top (), dir);
Real x0 = robust_relative_extent (lgr, commonx, X_AXIS)[LEFT];
Real x1 = robust_relative_extent (rgr, commonx, X_AXIS)[RIGHT];
Slope.
*/
Real factor = columns.size () > 1 ? 1/ (x1 - x0) : 1.0;
-
- for (int i = 0; i < columns.size (); i++)
+
+ for (int i = 0; i < columns.size (); i++)
{
Interval note_ext = columns[i]->extent (commony, Y_AXIS);
note_ext.unite (staff);
Real notey = note_ext[dir] - me->relative_coordinate (commony, Y_AXIS);
-
+
Real x = columns[i]->relative_coordinate (commonx, X_AXIS) - x0;
- Real tuplety = *dy * x * factor;
+ Real tuplety = *dy * x * factor;
if (notey * dir > (*offset + tuplety) * dir)
- *offset = notey - tuplety;
+ *offset = notey - tuplety;
}
// padding
- *offset += scm_to_double (me->get_property ("padding")) *dir;
+ *offset += scm_to_double (me->get_property ("padding")) *dir;
-
/*
horizontal brackets should not collide with staff lines.
-
- */
+
+ */
Real ss = Staff_symbol_referencer::staff_space (me);
- if (*dy == 0 && fabs (*offset) < ss * Staff_symbol_referencer::staff_radius (me))
+ if (*dy == 0 && fabs (*offset) < ss * Staff_symbol_referencer::staff_radius (me))
{
// quantize, then do collision check.
*offset *= 2 / ss;
-
+
*offset = rint (*offset);
if (Staff_symbol_referencer::on_staffline (me, (int) rint (*offset)))
*offset += dir;
*offset *= 0.5 * ss;
}
-
-}
-
+}
/*
We depend on the beams if there are any.
- */
+*/
MAKE_SCHEME_CALLBACK (Tuplet_bracket, before_line_breaking, 1);
SCM
Tuplet_bracket::before_line_breaking (SCM smob)
{
Grob *me = unsmob_grob (smob);
- Link_array<Grob> columns =
- extract_grob_array (me, ly_symbol2scm ("note-columns"));
-
+ Link_array<Grob> columns
+ = extract_grob_array (me, ly_symbol2scm ("note-columns"));
for (int i = columns.size (); i--;)
{
- Grob * s = Note_column::get_stem (columns[i]);
- Grob * b = s ? Stem::get_beam (s): 0;
+ Grob *s = Note_column::get_stem (columns[i]);
+ Grob *b = s ? Stem::get_beam (s): 0;
if (b)
me->add_dependency (b);
}
SCM
Tuplet_bracket::after_line_breaking (SCM smob)
{
- Grob * me = unsmob_grob (smob);
- Link_array<Grob> columns =
- extract_grob_array (me, ly_symbol2scm ("note-columns"));
+ Grob *me = unsmob_grob (smob);
+ Link_array<Grob> columns
+ = extract_grob_array (me, ly_symbol2scm ("note-columns"));
if (!columns.size ())
{
me->suicide ();
return SCM_UNSPECIFIED;
}
- if (dynamic_cast<Spanner*> (me)->is_broken ())
+ if (dynamic_cast<Spanner *> (me)->is_broken ())
{
- me->warning (_("Killing tuplet bracket across linebreak."));
+ me->warning (_ ("Killing tuplet bracket across linebreak."));
me->suicide ();
return SCM_UNSPECIFIED;
}
-
+
Direction dir = get_grob_direction (me);
if (!dir)
{
dir = Tuplet_bracket::get_default_dir (me);
set_grob_direction (me, dir);
}
-
+
bool equally_long = false;
- Grob * par_beam = parallel_beam (me, columns, &equally_long);
+ Grob *par_beam = parallel_beam (me, columns, &equally_long);
/*
We follow the beam only if there is one, and we are next to it.
- */
+ */
Real dy, offset;
if (!par_beam
|| get_grob_direction (par_beam) != dir)
}
else
{
- SCM ps = par_beam->get_property ("positions");
+ SCM ps = par_beam->get_property ("positions");
Real lp = scm_to_double (scm_car (ps));
Real rp = scm_to_double (scm_cdr (ps));
/*
duh. magic.
- */
+ */
offset = lp + dir * (0.5 + scm_to_double (me->get_property ("padding")));
dy = rp- lp;
}
-
-
- SCM lp = me->get_property ("left-position");
- SCM rp = me->get_property ("right-position");
-
+
+ SCM lp = me->get_property ("left-position");
+ SCM rp = me->get_property ("right-position");
+
if (scm_is_number (lp) && !scm_is_number (rp))
{
rp = scm_make_real (scm_to_double (lp) + dy);
return SCM_UNSPECIFIED;
}
-
/*
- similar to beam ?
- */
+ similar to beam ?
+*/
Direction
-Tuplet_bracket::get_default_dir (Grob*me)
+Tuplet_bracket::get_default_dir (Grob *me)
{
- Drul_array<int> dirs (0, 0);
+ Drul_array<int> dirs (0, 0);
for (SCM s = me->get_property ("note-columns"); scm_is_pair (s); s = scm_cdr (s))
{
- Grob * nc = unsmob_grob (scm_car (s));
+ Grob *nc = unsmob_grob (scm_car (s));
Direction d = Note_column::dir (nc);
if (d)
dirs[d]++;
}
void
-Tuplet_bracket::add_column (Grob*me, Item*n)
+Tuplet_bracket::add_column (Grob *me, Item *n)
{
Pointer_group_interface::add_grob (me, ly_symbol2scm ("note-columns"), n);
me->add_dependency (n);
- add_bound_item (dynamic_cast<Spanner*> (me), n);
+ add_bound_item (dynamic_cast<Spanner *> (me), n);
}
-
-
-
ADD_INTERFACE (Tuplet_bracket,
"tuplet-bracket-interface",
"A bracket with a number in the middle, used for tuplets.",
-
+
"note-columns bracket-flare edge-height shorten-pair "
"padding left-position right-position bracket-visibility "
"number-visibility thickness direction");
-/*
+/*
tuplet-engraver.cc -- implement Tuplet_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "tuplet-bracket.hh"
#include "note-column.hh"
Rational stop_;
Rational span_stop_;
Spanner *spanner_;
- Tuplet_description()
+ Tuplet_description ()
{
music_ = 0;
spanner_ = 0;
Array<Tuplet_description> tuplets_;
virtual void acknowledge_grob (Grob_info);
- virtual bool try_music (Music*r);
+ virtual bool try_music (Music *r);
virtual void start_translation_timestep ();
virtual void process_music ();
};
{
Tuplet_description d;
d.music_ = music;
- d.stop_ = now_mom ().main_part_ + music->get_length ().main_part_;
+ d.stop_ = now_mom ().main_part_ + music->get_length ().main_part_;
d.span_stop_ = d.stop_;
-
+
SCM s = get_property ("tupletSpannerDuration");
if (unsmob_moment (s))
d.span_stop_ = d.span_stop_ <? (now_mom () + *unsmob_moment (s)).main_part_;
-
+
tuplets_.push (d);
}
return true;
if (tuplets_[i].spanner_)
continue;
- Spanner* spanner = make_spanner ("TupletBracket",
+ Spanner *spanner = make_spanner ("TupletBracket",
tuplets_[i].music_->self_scm ());
tuplets_[i].spanner_ = spanner;
if (Note_column::has_interface (i.grob_))
{
for (int j = 0; j < tuplets_.size (); j++)
- if (tuplets_[j].spanner_)
+ if (tuplets_[j].spanner_)
Tuplet_bracket::add_column (tuplets_[j].spanner_,
- dynamic_cast<Item*> (i.grob_));
+ dynamic_cast<Item *> (i.grob_));
}
}
{
if (!sp->get_bound (RIGHT))
sp->set_bound (RIGHT, sp->get_bound (LEFT));
-
+
tuplets_[i].spanner_ = 0;
}
-
+
if (tsd.to_bool ())
tuplets_[i].span_stop_ += tsd.main_part_;
}
}
ADD_TRANSLATOR (Tuplet_engraver,
-/* descr */ "Catch Time_scaled_music and generate appropriate bracket ",
-/* creats*/ "TupletBracket",
-/* accepts */ "time-scaled-music",
-/* acks */ "note-column-interface",
-/* reads */ "tupletNumberFormatFunction tupletSpannerDuration",
-/* write */ "");
+ /* descr */ "Catch Time_scaled_music and generate appropriate bracket ",
+ /* creats*/ "TupletBracket",
+ /* accepts */ "time-scaled-music",
+ /* acks */ "note-column-interface",
+ /* reads */ "tupletNumberFormatFunction tupletSpannerDuration",
+ /* write */ "");
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
-
#include "tweak-registration.hh"
#include "grob.hh"
#include "object-key-undumper.hh"
LY_DEFINE (ly_clear_tweak_registry, "ly:tweak-clear-registry",
0, 0, 0, (),
- "Clear global tweak registry"
- )
+ "Clear global tweak registry")
{
global_registry_->clear ();
return SCM_UNSPECIFIED;
LY_DEFINE (ly_grob_insert_tweak, "ly:grob-insert-tweak",
2, 0, 0,
(SCM grob, SCM tweak),
- "add new tweak for grob."
- )
+ "add new tweak for grob.")
{
Grob *gr = unsmob_grob (grob);
SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "Grob");
SCM_ASSERT_TYPE (scm_list_p (tweak) == SCM_BOOL_T
&& ly_c_procedure_p (scm_car (tweak)),
tweak, SCM_ARG2, __FUNCTION__, "Tweak");
-
+
global_registry_->insert_grob_tweak (gr, tweak);
return SCM_UNSPECIFIED;
}
LY_DEFINE (ly_grob_replace_tweak, "ly:grob-replace-tweak",
2, 0, 0,
(SCM grob, SCM tweak),
- "Replace tweak for grob."
- )
+ "Replace tweak for grob.")
{
Grob *gr = unsmob_grob (grob);
SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "Grob");
SCM_ASSERT_TYPE (scm_list_p (tweak) == SCM_BOOL_T
&& ly_c_procedure_p (scm_car (tweak)),
tweak, SCM_ARG2, __FUNCTION__, "Tweak");
-
+
global_registry_->replace_grob_tweak (gr, tweak);
return SCM_UNSPECIFIED;
}
-
LY_DEFINE (ly_tweak_read_keys, "ly:tweak-define-keys",
1, 0, 0, (SCM keys),
- "Read keys"
- )
+ "Read keys")
{
- global_registry_->undumper ()->parse_contents (keys);
+ global_registry_->undumper ()->parse_contents (keys);
return SCM_UNSPECIFIED;
}
-
LY_DEFINE (ly_all_tweaks, "ly:all-tweaks",
0, 0, 0, (),
- "all tweaks"
- )
+ "all tweaks")
{
return global_registry_->list_tweaks ();
}
-
LY_DEFINE (ly_tweak_read_tweaks, "ly:tweak-define-tweaks",
1, 0, 0, (SCM tweaks),
- "Read tweaks"
- )
+ "Read tweaks")
{
for (SCM s = tweaks; scm_is_pair (s); s = scm_cdr (s))
global_registry_->insert_tweak_from_file (scm_car (s));
source file of the GNU LilyPond music typesetter
(c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
*/
#include "tweak-registration.hh"
{
SCM skey = scm_car (tweak);
- assert (scm_is_pair (skey) &&
- scm_car (skey) == ly_symbol2scm ("key"));
+ assert (scm_is_pair (skey)
+ && scm_car (skey) == ly_symbol2scm ("key"));
Object_key const *key = undumper_->get_key (scm_to_int (scm_cadr (skey)));
if (tweaks_.find (key) == tweaks_.end ())
}
SCM
-Tweak_registry::get_tweaks (Grob *g)
+Tweak_registry::get_tweaks (Grob *g)
{
Object_key const *key = g->get_key ();
if (tweaks_.find (key) == tweaks_.end ())
SCM
Tweak_registry::mark_smob (SCM smob)
{
- Tweak_registry *me = (Tweak_registry*) SCM_CELL_WORD_1 (smob);
+ Tweak_registry *me = (Tweak_registry *) SCM_CELL_WORD_1 (smob);
for (Tweak_map::const_iterator i (me->tweaks_.begin ());
i != me->tweaks_.end ();
if (me->undumper_)
scm_gc_mark (me->undumper_->self_scm ());
-
+
return SCM_EOL;
}
Tweak_registry::print_smob (SCM smob, SCM port, scm_print_state*)
{
(void) smob; // smother warning.
- scm_puts ("#<Tweak_registry>", port);
+ scm_puts ("#<Tweak_registry>", port);
return 1;
}
-Object_key_undumper*
+Object_key_undumper *
Tweak_registry::undumper () const
{
return undumper_;
IMPLEMENT_DEFAULT_EQUAL_P (Tweak_registry);
IMPLEMENT_SMOBS (Tweak_registry);
-
Tweak_registry *global_registry_;
void
class Skip_event_swallow_translator : public virtual Translator
{
protected:
- virtual bool try_music (Music*) { return true; }
+ virtual bool try_music (Music *) { return true; }
-public:
+public:
TRANSLATOR_DECLARATIONS (Skip_event_swallow_translator);
};
-
class Rest_swallow_translator : public virtual Translator
{
protected:
- virtual bool try_music (Music*) { return true; }
+ virtual bool try_music (Music *) { return true; }
-public:
+public:
TRANSLATOR_DECLARATIONS (Rest_swallow_translator);
};
-
Skip_event_swallow_translator::Skip_event_swallow_translator (){}
ADD_TRANSLATOR (Skip_event_swallow_translator,
- "Swallow \\skip.",
- "",
- "skip-event",
- "",
- "",
- "");
-
+ "Swallow \\skip.",
+ "",
+ "skip-event",
+ "",
+ "",
+ "");
Rest_swallow_translator::Rest_swallow_translator (){}
ADD_TRANSLATOR (Rest_swallow_translator,
- "Swallow rest",
- "",
- "rest-event",
- "",
- "",
-
+ "Swallow rest",
+ "",
+ "rest-event",
+ "",
+ "",
- "");
+ "");
class Note_swallow_translator : public virtual Translator
{
protected:
- virtual bool try_music (Music*) { return true; }
+ virtual bool try_music (Music *) { return true; }
-public:
+public:
TRANSLATOR_DECLARATIONS (Note_swallow_translator);
};
Note_swallow_translator::Note_swallow_translator (){}
ADD_TRANSLATOR (Note_swallow_translator,
- "Swallow notes",
- "",
- "note-event",
- "",
- "",
- "");
-
+ "Swallow notes",
+ "",
+ "note-event",
+ "",
+ "",
+ "");
+
-/*
-unfolded-repeat-iterator.cc -- implement Unfolded_repeat_iterator, Volta_repeat_iterator
+/*
+ unfolded-repeat-iterator.cc -- implement Unfolded_repeat_iterator, Volta_repeat_iterator
-source file of the GNU LilyPond music typesetter
+ source file of the GNU LilyPond music typesetter
-(c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "music.hh"
virtual SCM get_music_list () const;
};
-
SCM
Unfolded_repeat_iterator::get_music_list () const
{
SCM l = SCM_EOL;
SCM *tail = &l;
-
+
SCM body = get_music ()->get_property ("element");
SCM alts = get_music ()->get_property ("elements");
int alt_count = scm_ilength (alts);
for (int i = 0; i < rep_count; i++)
{
if (unsmob_music (body))
- *tail = scm_cons (body, SCM_EOL) ;
+ *tail = scm_cons (body, SCM_EOL);
tail = SCM_CDRLOC (*tail);
*tail = scm_cons (scm_car (alts), SCM_EOL);
tail = SCM_CDRLOC (*tail);
if (i >= rep_count - alt_count)
-
+
alts = scm_cdr (alts);
- }
+ }
}
- return l;
+ return l;
}
class Volta_repeat_iterator : public Sequential_iterator
int done_count_;
};
-
Volta_repeat_iterator::Volta_repeat_iterator ()
{
done_count_ = alt_count_ = rep_count_ = 0;
Volta_repeat_iterator::get_music_list ()const
{
return scm_cons (get_music ()->get_property ("element"),
- get_music ()->get_property ("elements"));
+ get_music ()->get_property ("elements"));
}
void
Volta_repeat_iterator::construct_children ()
{
Sequential_iterator::construct_children ();
-
+
SCM alts = get_music ()->get_property ("elements");
alt_count_ = scm_ilength (alts);
done_count_ = 0;
}
-
/*
TODO: add source information for debugging
- */
+*/
void
Volta_repeat_iterator::add_repeat_command (SCM what)
{
SCM reps = ly_symbol2scm ("repeatCommands");
SCM current_reps = get_outlet ()->internal_get_property (reps);
- Context * where = get_outlet ()->where_defined (reps);
+ Context *where = get_outlet ()->where_defined (reps);
if (where
&& current_reps == SCM_EOL || scm_is_pair (current_reps))
{
}
}
-
void
Volta_repeat_iterator::next_element (bool side_effect)
{
- done_count_ ++;
+ done_count_++;
Sequential_iterator::next_element (side_effect);
if (side_effect)
- {
+ {
if (alt_count_)
{
String repstr = to_string (rep_count_ - alt_count_ + done_count_) + ".";
add_repeat_command (ly_symbol2scm ("end-repeat"));
}
-
-
if (done_count_ == 1 && alt_count_ < rep_count_)
{
repstr = "1.--" + to_string (rep_count_ - alt_count_ + done_count_) + ".";
}
}
-
void
Volta_repeat_iterator::process (Moment m)
{
Sequential_iterator::process (m);
}
-
IMPLEMENT_CTOR_CALLBACK (Volta_repeat_iterator);
IMPLEMENT_CTOR_CALLBACK (Unfolded_repeat_iterator);
/*
vaticana-ligature-engraver.cc -- implement Vaticana_ligature_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2003--2005 Juergen Reuter <reuter@ipd.uka.de>
- */
+*/
#include "gregorian-ligature-engraver.hh"
#include "gregorian-ligature.hh"
Vaticana_ligature_engraver::is_stacked_head (int prefix_set,
int context_info)
{
- bool is_stacked_b;
+ bool is_stacked_b;
- // upper head of pes is stacked upon lower head of pes ...
- is_stacked_b = context_info & PES_UPPER;
+ // upper head of pes is stacked upon lower head of pes ...
+ is_stacked_b = context_info & PES_UPPER;
- // ... unless this note starts a flexa
- if (context_info & FLEXA_LEFT)
- is_stacked_b = false;
+ // ... unless this note starts a flexa
+ if (context_info & FLEXA_LEFT)
+ is_stacked_b = false;
- // ... or another pes
- if (context_info & PES_LOWER)
- is_stacked_b = false;
+ // ... or another pes
+ if (context_info & PES_LOWER)
+ is_stacked_b = false;
- // ... or the previous note is a semivocalis or inclinatum
- if (context_info & AFTER_DEMINUTUM)
- is_stacked_b = false;
+ // ... or the previous note is a semivocalis or inclinatum
+ if (context_info & AFTER_DEMINUTUM)
+ is_stacked_b = false;
- // auctum head is never stacked upon preceding note
- if (prefix_set & AUCTUM)
- is_stacked_b = false;
+ // auctum head is never stacked upon preceding note
+ if (prefix_set & AUCTUM)
+ is_stacked_b = false;
- // virga is never stacked upon preceding note
- if (prefix_set & VIRGA)
- is_stacked_b = false;
+ // virga is never stacked upon preceding note
+ if (prefix_set & VIRGA)
+ is_stacked_b = false;
- // oriscus is never stacked upon preceding note
- if (prefix_set & ORISCUS)
- is_stacked_b = false;
+ // oriscus is never stacked upon preceding note
+ if (prefix_set & ORISCUS)
+ is_stacked_b = false;
- if ((prefix_set & DEMINUTUM) &&
- !(prefix_set & INCLINATUM) &&
- (context_info & FLEXA_RIGHT))
- is_stacked_b = true; // semivocalis head of deminutus form
+ if ((prefix_set & DEMINUTUM)
+ && ! (prefix_set & INCLINATUM)
+ && (context_info & FLEXA_RIGHT))
+ is_stacked_b = true; // semivocalis head of deminutus form
- return is_stacked_b;
+ return is_stacked_b;
}
/*
*/
return true;
- if ((prefix_set & INCLINATUM) &&
- !(prev_prefix_set & INCLINATUM))
+ if ((prefix_set & INCLINATUM)
+ && ! (prev_prefix_set & INCLINATUM))
/*
* Always start a series of inclinatum heads with an extra space.
*/
return true;
- if ((context_info & FLEXA_LEFT) && !(context_info & PES_UPPER))
+ if ((context_info & FLEXA_LEFT) && ! (context_info & PES_UPPER))
/*
* Before a flexa (but not within a torculus), make a an
* additional small space such that the appendix on the left side
/*
* The paper column where we put the whole ligature into.
*/
- Paper_column *column =
- dynamic_cast<Item*> (primitives[0].grob_)->get_column ();
+ Paper_column *column
+ = dynamic_cast<Item *> (primitives[0].grob_)->get_column ();
- Real join_thickness =
- thickness * column->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
+ Real join_thickness
+ = thickness * column->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
/*
* Amount of extra space two put between some particular
int prev_prefix_set = 0;
for (int i = 0; i < primitives.size (); i++)
{
- Item *primitive = dynamic_cast<Item*> (primitives[i].grob_);
- int prefix_set =
- scm_to_int (primitive->get_property ("prefix-set"));
- int context_info =
- scm_to_int (primitive->get_property ("context-info"));
+ Item *primitive = dynamic_cast<Item *> (primitives[i].grob_);
+ int prefix_set
+ = scm_to_int (primitive->get_property ("prefix-set"));
+ int context_info
+ = scm_to_int (primitive->get_property ("context-info"));
/*
* Get glyph_name, delta_pitch and context_info for this head.
* of this and the other head are horizontally aligned.
*/
head_width = 0.0;
- x_offset = join_thickness -
- Font_interface::get_default_font (primitive)->
+ x_offset = join_thickness
+ - Font_interface::get_default_font (primitive)->
find_by_name ("noteheads." + glyph_name).extent (X_AXIS).length ();
}
- else if (!String::compare (glyph_name, "flexa") ||
- !String::compare (glyph_name, ""))
+ else if (!String::compare (glyph_name, "flexa")
+ || !String::compare (glyph_name, ""))
{
/*
* This head represents either half of a flexa shape.
* This is a regular head, placed right to the previous one.
* Retrieve its width from corresponding font.
*/
- head_width =
- Font_interface::get_default_font (primitive)->
+ head_width
+ = Font_interface::get_default_font (primitive)->
find_by_name ("noteheads." + glyph_name).extent (X_AXIS).length ();
x_offset = 0.0;
}
* Save the head's final x-offset.
*/
primitive->set_property ("x-offset",
- scm_make_real (x_offset));
+ scm_make_real (x_offset));
/*
* If the head is the 2nd head of a pes or flexa (but not a
* flexa shape), mark this head to be joined with the left-side
* neighbour head (i.e. the previous head) by a vertical beam.
*/
- if ((context_info & PES_UPPER) ||
- ((context_info & FLEXA_RIGHT) &&
- !(context_info & PES_LOWER)))
+ if ((context_info & PES_UPPER)
+ || ((context_info & FLEXA_RIGHT)
+ && ! (context_info & PES_LOWER)))
{
if (!prev_primitive)
{
else
{
prev_primitive->set_property ("add-join",
- ly_bool2scm (true));
+ ly_bool2scm (true));
/*
* Create a small overlap of adjacent heads so that the join
void
check_for_prefix_loss (Item *primitive)
{
- int prefix_set =
- scm_to_int (primitive->get_property ("prefix-set"));
+ int prefix_set
+ = scm_to_int (primitive->get_property ("prefix-set"));
if (prefix_set & ~PES_OR_FLEXA)
{
String prefs = Gregorian_ligature::prefixes_to_str (primitive);
Vaticana_ligature_engraver::transform_heads (Spanner *ligature,
Array<Grob_info> primitives)
{
- Real flexa_width = robust_scm2double ( ligature->get_property ("flexa-width"), 2);
+ Real flexa_width = robust_scm2double (ligature->get_property ("flexa-width"), 2);
- Real thickness = robust_scm2double ( ligature->get_property ("thickness"), 1);
+ Real thickness = robust_scm2double (ligature->get_property ("thickness"), 1);
Item *prev_primitive = 0;
int prev_prefix_set = 0;
int prev_context_info = 0;
int prev_delta_pitch = 0;
String prev_glyph_name = "";
- for (int i = 0; i < primitives.size (); i++) {
- Item *primitive = dynamic_cast<Item*> (primitives[i].grob_);
-
- int delta_pitch;
- SCM delta_pitch_scm = primitive->get_property ("delta-pitch");
- if (delta_pitch_scm != SCM_EOL)
- {
- delta_pitch = scm_to_int (delta_pitch_scm);
- }
- else
- {
- primitive->programming_error ("Vaticana_ligature:"
- "delta-pitch undefined -> "
- "ignoring grob");
- continue;
- }
-
- /* retrieve & complete prefix_set and context_info */
- int prefix_set =
- scm_to_int (primitive->get_property ("prefix-set"));
- int context_info =
- scm_to_int (primitive->get_property ("context-info"));
- if (is_stacked_head (prefix_set, context_info))
- {
- context_info |= STACKED_HEAD;
- primitive->set_property ("context-info",
- scm_int2num (context_info));
- }
+ for (int i = 0; i < primitives.size (); i++)
+ {
+ Item *primitive = dynamic_cast<Item *> (primitives[i].grob_);
- /*
- * Now determine which head to typeset (this is context sensitive
- * information, since it depends on neighbouring heads; therefore,
- * this decision must be made here in the engraver rather than in
- * the backend).
- */
- String glyph_name;
- if (prefix_set & VIRGA)
- {
- glyph_name = "svaticana.punctum";
- primitive->set_property ("add-stem", ly_bool2scm (true));
- }
- else if (prefix_set & QUILISMA)
- glyph_name = "svaticana.quilisma";
- else if (prefix_set & ORISCUS)
- glyph_name = "ssolesmes.oriscus";
- else if (prefix_set & STROPHA)
- if (prefix_set & AUCTUM)
- glyph_name = "ssolesmes.stropha.aucta";
- else glyph_name = "ssolesmes.stropha";
- else if (prefix_set & INCLINATUM)
- if (prefix_set & AUCTUM)
- glyph_name = "ssolesmes.incl.auctum";
- else if (prefix_set & DEMINUTUM)
- glyph_name = "ssolesmes.incl.parvum";
- else
- glyph_name = "svaticana.inclinatum";
- else if (prefix_set & DEMINUTUM)
- if (i == 0)
+ int delta_pitch;
+ SCM delta_pitch_scm = primitive->get_property ("delta-pitch");
+ if (delta_pitch_scm != SCM_EOL)
{
- // initio debilis
- glyph_name = "svaticana.reverse.plica";
+ delta_pitch = scm_to_int (delta_pitch_scm);
}
- else if (prev_delta_pitch > 0)
+ else
{
- // epiphonus
- if (!(prev_context_info & FLEXA_RIGHT))
- /* correct head of previous primitive */
- if (prev_delta_pitch > 1)
- prev_glyph_name = "svaticana.epiphonus";
- else
- prev_glyph_name = "svaticana.vepiphonus";
- glyph_name = "svaticana.plica";
+ primitive->programming_error ("Vaticana_ligature:"
+ "delta-pitch undefined -> "
+ "ignoring grob");
+ continue;
}
- else // (prev_delta_pitch <= 0)
- {
- // cephalicus
- if (!(prev_context_info & FLEXA_RIGHT))
- /* correct head of previous primitive */
- {
- if (i > 1)
- {
- /* cephalicus head with fixed size cauda */
- prev_glyph_name = "svaticana.inner.cephalicus";
- }
- else
- {
- /* cephalicus head without cauda */
- prev_glyph_name = "svaticana.cephalicus";
- }
- /*
- * Flexa has no variable size cauda if its left head is
- * stacked on the right head. This is true for
- * cephalicus. Hence, remove the cauda.
- *
- * Urgh: for the current implementation, this rule only
- * applies for cephalicus; but it is a fundamental rule.
- * Therefore, the following line of code should be
- * placed somewhere else.
- */
- prev_primitive->set_property ("add-cauda",
- ly_bool2scm (false));
- }
- glyph_name = "svaticana.reverse.plica";
+ /* retrieve & complete prefix_set and context_info */
+ int prefix_set
+ = scm_to_int (primitive->get_property ("prefix-set"));
+ int context_info
+ = scm_to_int (primitive->get_property ("context-info"));
+ if (is_stacked_head (prefix_set, context_info))
+ {
+ context_info |= STACKED_HEAD;
+ primitive->set_property ("context-info",
+ scm_int2num (context_info));
}
- else if (prefix_set & (CAVUM | LINEA))
- if ((prefix_set & CAVUM) && (prefix_set & LINEA))
- glyph_name = "svaticana.linea.punctum.cavum";
- else if (prefix_set & CAVUM)
- glyph_name = "svaticana.punctum.cavum";
- else
- glyph_name = "svaticana.linea.punctum";
- else if (prefix_set & AUCTUM)
- if (prefix_set & ASCENDENS)
- glyph_name = "ssolesmes.auct.asc";
- else
- glyph_name = "ssolesmes.auct.desc";
- else if ((context_info & STACKED_HEAD) &&
- (context_info & PES_UPPER))
- if (prev_delta_pitch > 1)
- glyph_name = "svaticana.upes";
- else
- glyph_name = "svaticana.vupes";
- else
- glyph_name = "svaticana.punctum";
- /*
- * This head needs a cauda, if it starts a flexa, is not the upper
- * head of a pes, and if it is a punctum.
- */
- if ((context_info & FLEXA_LEFT) && !(context_info & PES_UPPER))
- if (!String::compare (glyph_name, "svaticana.punctum"))
- primitive->set_property ("add-cauda", ly_bool2scm (true));
-
- /*
- * Execptional rule for porrectus:
- *
- * If the current head is preceded by a \flexa and succeded by a
- * \pes (e.g. "a \flexa g \pes a"), then join the current head and
- * the previous head into a single curved flexa shape.
- */
- if ((context_info & FLEXA_RIGHT) && (context_info & PES_LOWER))
- {
- check_for_prefix_loss (prev_primitive);
- prev_glyph_name = "flexa";
- prev_primitive->set_property ("flexa-height",
- scm_int2num (prev_delta_pitch));
- prev_primitive->set_property ("flexa-width",
- scm_make_real (flexa_width));
- bool add_cauda = !(prev_prefix_set && PES_OR_FLEXA);
- prev_primitive->set_property ("add-cauda",
- ly_bool2scm (add_cauda));
- check_for_prefix_loss (primitive);
- glyph_name = "";
- primitive->set_property ("flexa-width",
- scm_make_real (flexa_width));
- }
-
- /*
- * Exceptional rule for pes:
- *
- * If this head is stacked on the previous one due to a \pes, then
- * set the glyph of the previous head to that for this special
- * case, thereby avoiding potential vertical collision with the
- * current head.
- */
- if (prefix_set & PES_OR_FLEXA)
- {
- if ((context_info & PES_UPPER) && (context_info & STACKED_HEAD))
+ /*
+ * Now determine which head to typeset (this is context sensitive
+ * information, since it depends on neighbouring heads; therefore,
+ * this decision must be made here in the engraver rather than in
+ * the backend).
+ */
+ String glyph_name;
+ if (prefix_set & VIRGA)
+ {
+ glyph_name = "svaticana.punctum";
+ primitive->set_property ("add-stem", ly_bool2scm (true));
+ }
+ else if (prefix_set & QUILISMA)
+ glyph_name = "svaticana.quilisma";
+ else if (prefix_set & ORISCUS)
+ glyph_name = "ssolesmes.oriscus";
+ else if (prefix_set & STROPHA)
+ if (prefix_set & AUCTUM)
+ glyph_name = "ssolesmes.stropha.aucta";
+ else glyph_name = "ssolesmes.stropha";
+ else if (prefix_set & INCLINATUM)
+ if (prefix_set & AUCTUM)
+ glyph_name = "ssolesmes.incl.auctum";
+ else if (prefix_set & DEMINUTUM)
+ glyph_name = "ssolesmes.incl.parvum";
+ else
+ glyph_name = "svaticana.inclinatum";
+ else if (prefix_set & DEMINUTUM)
+ if (i == 0)
{
- if (!String::compare (prev_glyph_name, "svaticana.punctum"))
+ // initio debilis
+ glyph_name = "svaticana.reverse.plica";
+ }
+ else if (prev_delta_pitch > 0)
+ {
+ // epiphonus
+ if (! (prev_context_info & FLEXA_RIGHT))
+ /* correct head of previous primitive */
if (prev_delta_pitch > 1)
- prev_glyph_name = "svaticana.lpes";
+ prev_glyph_name = "svaticana.epiphonus";
else
- prev_glyph_name = "svaticana.vlpes";
+ prev_glyph_name = "svaticana.vepiphonus";
+ glyph_name = "svaticana.plica";
+ }
+ else // (prev_delta_pitch <= 0)
+ {
+ // cephalicus
+ if (! (prev_context_info & FLEXA_RIGHT))
+ /* correct head of previous primitive */
+ {
+ if (i > 1)
+ {
+ /* cephalicus head with fixed size cauda */
+ prev_glyph_name = "svaticana.inner.cephalicus";
+ }
+ else
+ {
+ /* cephalicus head without cauda */
+ prev_glyph_name = "svaticana.cephalicus";
+ }
+
+ /*
+ * Flexa has no variable size cauda if its left head is
+ * stacked on the right head. This is true for
+ * cephalicus. Hence, remove the cauda.
+ *
+ * Urgh: for the current implementation, this rule only
+ * applies for cephalicus; but it is a fundamental rule.
+ * Therefore, the following line of code should be
+ * placed somewhere else.
+ */
+ prev_primitive->set_property ("add-cauda",
+ ly_bool2scm (false));
+ }
+ glyph_name = "svaticana.reverse.plica";
}
- }
+ else if (prefix_set & (CAVUM | LINEA))
+ if ((prefix_set & CAVUM) && (prefix_set & LINEA))
+ glyph_name = "svaticana.linea.punctum.cavum";
+ else if (prefix_set & CAVUM)
+ glyph_name = "svaticana.punctum.cavum";
+ else
+ glyph_name = "svaticana.linea.punctum";
+ else if (prefix_set & AUCTUM)
+ if (prefix_set & ASCENDENS)
+ glyph_name = "ssolesmes.auct.asc";
+ else
+ glyph_name = "ssolesmes.auct.desc";
+ else if ((context_info & STACKED_HEAD)
+ && (context_info & PES_UPPER))
+ if (prev_delta_pitch > 1)
+ glyph_name = "svaticana.upes";
+ else
+ glyph_name = "svaticana.vupes";
+ else
+ glyph_name = "svaticana.punctum";
- if (prev_primitive)
- prev_primitive->set_property ("glyph-name",
- scm_makfrom0str (prev_glyph_name.to_str0 ()));
+ /*
+ * This head needs a cauda, if it starts a flexa, is not the upper
+ * head of a pes, and if it is a punctum.
+ */
+ if ((context_info & FLEXA_LEFT) && ! (context_info & PES_UPPER))
+ if (!String::compare (glyph_name, "svaticana.punctum"))
+ primitive->set_property ("add-cauda", ly_bool2scm (true));
- /*
- * In the backend, flexa shapes and joins need to know about line
- * thickness. Hence, for simplicity, let's distribute the
- * ligature grob's value for thickness to each ligature head (even
- * if not all of them need to know).
- */
- primitive->set_property ("thickness", scm_make_real (thickness));
+ /*
+ * Execptional rule for porrectus:
+ *
+ * If the current head is preceded by a \flexa and succeded by a
+ * \pes (e.g. "a \flexa g \pes a"), then join the current head and
+ * the previous head into a single curved flexa shape.
+ */
+ if ((context_info & FLEXA_RIGHT) && (context_info & PES_LOWER))
+ {
+ check_for_prefix_loss (prev_primitive);
+ prev_glyph_name = "flexa";
+ prev_primitive->set_property ("flexa-height",
+ scm_int2num (prev_delta_pitch));
+ prev_primitive->set_property ("flexa-width",
+ scm_make_real (flexa_width));
+ bool add_cauda = !(prev_prefix_set && PES_OR_FLEXA);
+ prev_primitive->set_property ("add-cauda",
+ ly_bool2scm (add_cauda));
+ check_for_prefix_loss (primitive);
+ glyph_name = "";
+ primitive->set_property ("flexa-width",
+ scm_make_real (flexa_width));
+ }
+
+ /*
+ * Exceptional rule for pes:
+ *
+ * If this head is stacked on the previous one due to a \pes, then
+ * set the glyph of the previous head to that for this special
+ * case, thereby avoiding potential vertical collision with the
+ * current head.
+ */
+ if (prefix_set & PES_OR_FLEXA)
+ {
+ if ((context_info & PES_UPPER) && (context_info & STACKED_HEAD))
+ {
+ if (!String::compare (prev_glyph_name, "svaticana.punctum"))
+ if (prev_delta_pitch > 1)
+ prev_glyph_name = "svaticana.lpes";
+ else
+ prev_glyph_name = "svaticana.vlpes";
+ }
+ }
- prev_primitive = primitive;
- prev_prefix_set = prefix_set;
- prev_context_info = context_info;
- prev_delta_pitch = delta_pitch;
- prev_glyph_name = glyph_name;
- }
+ if (prev_primitive)
+ prev_primitive->set_property ("glyph-name",
+ scm_makfrom0str (prev_glyph_name.to_str0 ()));
+
+ /*
+ * In the backend, flexa shapes and joins need to know about line
+ * thickness. Hence, for simplicity, let's distribute the
+ * ligature grob's value for thickness to each ligature head (even
+ * if not all of them need to know).
+ */
+ primitive->set_property ("thickness", scm_make_real (thickness));
+
+ prev_primitive = primitive;
+ prev_prefix_set = prefix_set;
+ prev_context_info = context_info;
+ prev_delta_pitch = delta_pitch;
+ prev_glyph_name = glyph_name;
+ }
prev_primitive->set_property ("glyph-name",
scm_makfrom0str (prev_glyph_name.to_str0 ()));
#if 0 // experimental code to collapse spacing after ligature
/* TODO: set to max (old/new spacing-increment), since other
voices/staves also may want to set this property. */
- Item *first_primitive = dynamic_cast<Item*> (primitives[0].grob_);
+ Item *first_primitive = dynamic_cast<Item *> (primitives[0].grob_);
Paper_column *paper_column = first_primitive->get_column ();
paper_column->warning (_f ("Vaticana_ligature_engraver: "
"setting `spacing-increment = %f': ptr =%ul",
#endif
}
-
ADD_TRANSLATOR (Vaticana_ligature_engraver,
-/* descr */ "Handles ligatures by glueing special ligature heads together.",
-/* creats*/ "VaticanaLigature",
-/* accepts */ "ligature-event",
-/* acks */ "note-head-interface rest-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Handles ligatures by glueing special ligature heads together.",
+ /* creats*/ "VaticanaLigature",
+ /* accepts */ "ligature-event",
+ /* acks */ "note-head-interface rest-interface",
+ /* reads */ "",
+ /* write */ "");
/*
vaticana-ligature.cc -- implement Vaticana_ligature
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2003--2005 Juergen Reuter <reuter@ipd.uka.de>
*/
Real blotdiameter)
{
bool on_staffline = Staff_symbol_referencer::on_staffline (me, pos);
- int interspaces = Staff_symbol_referencer::line_count (me)-1;
+ int interspaces = Staff_symbol_referencer::line_count (me) - 1;
bool above_staff = pos > interspaces;
if (delta_pitch > -1)
* Compensate curve thickness that appears to be smaller in steep
* section of bend.
*/
- Real left_height =
- right_height +
- min (0.12 * abs (interval), 0.3) * staff_space;
+ Real left_height
+ = right_height
+ + min (0.12 * abs (interval), 0.3) * staff_space;
/*
* Compensate optical illusion regarding vertical position of left
if (solid)
{
- Stencil solid_head =
- Lookup::bezier_sandwich (top_curve, bottom_curve);
+ Stencil solid_head
+ = Lookup::bezier_sandwich (top_curve, bottom_curve);
stencil.add_stencil (solid_head);
}
else // outline
{
Bezier inner_top_curve = top_curve;
inner_top_curve.translate (Offset (0.0, -line_thickness));
- Stencil top_edge =
- Lookup::bezier_sandwich (top_curve, inner_top_curve);
+ Stencil top_edge
+ = Lookup::bezier_sandwich (top_curve, inner_top_curve);
stencil.add_stencil (top_edge);
Bezier inner_bottom_curve = bottom_curve;
inner_bottom_curve.translate (Offset (0.0, +line_thickness));
- Stencil bottom_edge =
- Lookup::bezier_sandwich (bottom_curve, inner_bottom_curve);
+ Stencil bottom_edge
+ = Lookup::bezier_sandwich (bottom_curve, inner_bottom_curve);
stencil.add_stencil (bottom_edge);
/*
String glyph_name = ly_scm2string (glyph_name_scm);
Stencil out;
- Real thickness = robust_scm2double ( me->get_property ("thickness"), 1);
+ Real thickness = robust_scm2double (me->get_property ("thickness"), 1);
- Real line_thickness =
- thickness * me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
+ Real line_thickness
+ = thickness * me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
- Real blotdiameter =
- (me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter")));
+ Real blotdiameter
+ = (me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter")));
int pos = Staff_symbol_referencer::get_rounded_position (me);
else
delta_pitch = 0;
- Real x_offset = robust_scm2double ( me->get_property ("x-offset"), 0);
+ Real x_offset = robust_scm2double (me->get_property ("x-offset"), 0);
bool add_stem = to_boolean (me->get_property ("add-stem"));
bool add_cauda = to_boolean (me->get_property ("add-cauda"));
* flexa_width.)
*/
Real staff_space = Staff_symbol_referencer::staff_space (me);
- Real flexa_width = robust_scm2double ( me->get_property ("flexa-width"), 2) *staff_space;
- out =
- Lookup::blank (Box (Interval (0, 0.5*flexa_width), Interval (0, 0)));
+ Real flexa_width = robust_scm2double (me->get_property ("flexa-width"), 2) *staff_space;
+ out
+ = Lookup::blank (Box (Interval (0, 0.5*flexa_width), Interval (0, 0)));
}
else if (!String::compare (glyph_name, "flexa"))
{
}
else
{
- out =
- Font_interface::get_default_font (me)->
+ out
+ = Font_interface::get_default_font (me)->
find_by_name ("noteheads." + glyph_name);
}
out.translate_axis (x_offset, X_AXIS);
if (add_cauda)
{
- Stencil cauda =
- vaticana_brew_cauda (me, pos, delta_pitch,
- line_thickness, blotdiameter);
+ Stencil cauda
+ = vaticana_brew_cauda (me, pos, delta_pitch,
+ line_thickness, blotdiameter);
out.add_stencil (cauda);
}
if (add_stem)
{
- Stencil stem =
- vaticana_brew_cauda (me, pos, -1,
- line_thickness, blotdiameter);
+ Stencil stem
+ = vaticana_brew_cauda (me, pos, -1,
+ line_thickness, blotdiameter);
stem.translate_axis (head_width - line_thickness, X_AXIS);
out.add_stencil (stem);
}
if (add_join)
{
- Stencil join =
- vaticana_brew_join (me, delta_pitch, line_thickness, blotdiameter);
+ Stencil join
+ = vaticana_brew_join (me, delta_pitch, line_thickness, blotdiameter);
join.translate_axis (head_width - line_thickness, X_AXIS);
out.add_stencil (join);
}
class Vertical_align_engraver : public Engraver
{
- Spanner * valign_;
- bool qualifies (Grob_info) const;
+ Spanner *valign_;
+ bool qualifies (Grob_info) const;
public:
TRANSLATOR_DECLARATIONS (Vertical_align_engraver);
protected:
bool
Vertical_align_engraver::qualifies (Grob_info i) const
{
- int sz = i.origin_contexts ((Translator*)this).size () ;
+ int sz = i.origin_contexts ((Translator *)this).size ();
return sz > 0 && Axis_group_interface::has_interface (i.grob_)
&& !i.grob_->get_parent (Y_AXIS) && Axis_group_interface::has_axis (i.grob_, Y_AXIS);
}
}
-
ADD_TRANSLATOR (Vertical_align_engraver,
-/* descr */ "Catch Vertical axis groups and stack them.",
-/* creats*/ "VerticalAlignment",
-/* accepts */ "",
-/* acks */ "axis-group-interface",
-/* reads */ "",
-/* write */ "");
+ /* descr */ "Catch Vertical axis groups and stack them.",
+ /* creats*/ "VerticalAlignment",
+ /* accepts */ "",
+ /* acks */ "axis-group-interface",
+ /* reads */ "",
+ /* write */ "");
--
* Should look for system_start_delim to find left edge of staff.
-
-*/
+ */
MAKE_SCHEME_CALLBACK (Volta_bracket_interface, print, 1);
SCM
-Volta_bracket_interface::print (SCM smob)
+Volta_bracket_interface::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
- Spanner *orig_span = dynamic_cast<Spanner*> (me->original_);
+ Spanner *orig_span = dynamic_cast<Spanner *> (me->original_);
- bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0] == (Spanner*)me);
+ bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0] == (Spanner *)me);
- bool broken_last_bracket = orig_span && (orig_span->broken_intos_.top () == (Spanner*)me);
+ bool broken_last_bracket = orig_span && (orig_span->broken_intos_.top () == (Spanner *)me);
bool no_vertical_start = orig_span && !broken_first_bracket;
bool no_vertical_end = orig_span && !broken_last_bracket;
SCM s = me->get_property ("bars");
- Grob * endbar = scm_is_pair (s) ? unsmob_grob (scm_car (s)) : 0;
+ Grob *endbar = scm_is_pair (s) ? unsmob_grob (scm_car (s)) : 0;
SCM glyph = endbar ? endbar->get_property ("glyph") : SCM_EOL;
-
+
String str;
if (scm_is_string (glyph))
str = ly_scm2string (glyph);
else
str = "|";
-
- const char* cs = str.to_str0 ();
- no_vertical_end |=
- (strcmp (cs, ":|")!= 0 && strcmp (cs, "|:")!= 0 && strcmp (cs, "|.")!= 0
- && strcmp (cs, ":|:")!= 0 && strcmp (cs, ".|")!= 0);
- Output_def * layout = me->get_layout ();
+ const char *cs = str.to_str0 ();
+ no_vertical_end
+ |= (strcmp (cs, ":|")!= 0 && strcmp (cs, "|:")!= 0 && strcmp (cs, "|.")!= 0
+ && strcmp (cs, ":|:")!= 0 && strcmp (cs, ".|")!= 0);
+
+ Output_def *layout = me->get_layout ();
Real half_space = 0.5;
- Item * bound = dynamic_cast<Spanner*> (me)->get_bound (LEFT);
+ Item *bound = dynamic_cast<Spanner *> (me)->get_bound (LEFT);
/*
not a start, but really broken in two
*/
- Real left = 0.;
+ Real left = 0.;
if (bound->break_status_dir () == RIGHT)
{
Paper_column *pc = bound->get_column ();
- left = pc->extent (pc, X_AXIS)[RIGHT] - bound->relative_coordinate (pc, X_AXIS);
+ left = pc->extent (pc, X_AXIS)[RIGHT] - bound->relative_coordinate (pc, X_AXIS);
}
else
{
*/
}
- Real w = dynamic_cast<Spanner*> (me)->spanner_length () - left - half_space;
- Real h = robust_scm2double (me->get_property ("height"), 1);
+ Real w = dynamic_cast<Spanner *> (me)->spanner_length () - left - half_space;
+ Real h = robust_scm2double (me->get_property ("height"), 1);
- Stencil start, end ;
+ Stencil start, end;
if (!no_vertical_start)
- start = Line_interface::line (me, Offset (0, 0), Offset (0, h));
-
+ start = Line_interface::line (me, Offset (0, 0), Offset (0, h));
+
if (!no_vertical_end)
end = Line_interface::line (me, Offset (w, 0), Offset (w, h));
{
SCM text = me->get_property ("text");
SCM properties = me->get_property_alist_chain (SCM_EOL);
- SCM snum = Text_interface::interpret_markup (layout->self_scm (), properties, text);
+ SCM snum = Text_interface::interpret_markup (layout->self_scm (), properties, text);
Stencil num = *unsmob_stencil (snum);
mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
return mol.smobbed_copy ();
}
-
void
-Volta_bracket_interface::add_bar (Grob *me, Item* b)
+Volta_bracket_interface::add_bar (Grob *me, Item *b)
{
Pointer_group_interface::add_grob (me, ly_symbol2scm ("bars"), b);
Side_position_interface::add_support (me, b);
- add_bound_item (dynamic_cast<Spanner*> (me), b);
+ add_bound_item (dynamic_cast<Spanner *> (me), b);
}
void
-Volta_bracket_interface::add_column (Grob*me, Grob* c)
+Volta_bracket_interface::add_column (Grob *me, Grob *c)
{
Side_position_interface::add_support (me, c);
}
-/*
+/*
volta-engraver.cc -- implement Volta_engraver
-
+
source file of the GNU LilyPond music typesetter
-
+
(c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "engraver.hh"
#include "context.hh"
/*
Create Volta spanners, by reading repeatCommands property, usually
set by Unfolded_repeat_iterator.
- */
+*/
class Volta_engraver : public Engraver
{
public:
virtual void finalize ();
virtual void stop_translation_timestep ();
virtual void process_music ();
-
+
Moment started_mom_;
Spanner *volta_span_;
Spanner *end_volta_span_;
SCM start_string_;
bool staff_eligible ();
-
+
};
Volta_engraver::Volta_engraver ()
end_volta_span_ = 0;
}
-
/*
TODO: this logic should be rewritten, it is buggy.
One of the problems is that we can't determine wether or not to
print the volta bracket during the first step, since that requires
acknowledging the staff.
- */
+*/
bool
Volta_engraver::staff_eligible ()
{
return to_boolean (doit);
}
-
if (!unsmob_grob (staff_))
return false;
/*
only put a volta on the top staff.
-
+
May be this is a bit convoluted, and we should have a single
volta engraver in score context or somesuch.
-
+
*/
if (!scm_is_pair (staffs))
{
return true;
}
-
void
Volta_engraver::process_music ()
{
SCM cs = get_property ("repeatCommands");
if (!staff_eligible ())
- return ;
+ return;
-
- bool end = false;
+ bool end = false;
start_string_ = SCM_EOL;
while (scm_is_pair (cs))
{
&& scm_car (c) == ly_symbol2scm ("volta")
&& scm_is_pair (scm_cdr (c)))
{
- if (scm_cadr (c) == SCM_BOOL_F)
+ if (scm_cadr (c) == SCM_BOOL_F)
end = true;
else
start_string_ = scm_cadr (c);
}
-
+
cs = scm_cdr (cs);
}
{
SCM l (get_property ("voltaSpannerDuration"));
Moment now = now_mom ();
-
+
bool early_stop = unsmob_moment (l)
&& *unsmob_moment (l) <= now - started_mom_;
-
+
end = end || early_stop;
}
-
if (end && !volta_span_)
{
warning (_ ("No volta spanner to end")); // fixme: be more verbose.
volta_span_ = 0;
}
- if (volta_span_ &&
- (scm_is_string (start_string_) || scm_is_pair (start_string_)))
+ if (volta_span_
+ && (scm_is_string (start_string_) || scm_is_pair (start_string_)))
{
warning (_ ("Already have a volta spanner. Stopping that one prematurely."));
-
+
if (end_volta_span_)
{
warning (_ ("Also have a stopped spanner. Giving up."));
- return ;
+ return;
}
end_volta_span_ = volta_span_;
volta_span_ = 0;
}
- if (!volta_span_ &&
- (scm_is_string (start_string_) || scm_is_pair (start_string_)))
+ if (!volta_span_
+ && (scm_is_string (start_string_) || scm_is_pair (start_string_)))
{
- started_mom_ = now_mom () ;
+ started_mom_ = now_mom ();
volta_span_ = make_spanner ("VoltaBracket", SCM_EOL);
-
volta_span_->set_property ("text", start_string_);
}
}
-
void
Volta_engraver::acknowledge_grob (Grob_info i)
{
- if (Item* item = dynamic_cast<Item*> (i.grob_))
+ if (Item *item = dynamic_cast<Item *> (i.grob_))
{
if (Note_column::has_interface (item))
{
if (volta_span_)
Volta_bracket_interface::add_bar (volta_span_, item);
if (end_volta_span_)
- Volta_bracket_interface::add_bar (end_volta_span_ , item);
+ Volta_bracket_interface::add_bar (end_volta_span_, item);
}
}
else if (Staff_symbol::has_interface (i.grob_))
{
}
-
-
-void
+void
Volta_engraver::stop_translation_timestep ()
{
if (volta_span_ && !staff_eligible ())
we need to do this here, because STAFF_ is not initialized yet
in the 1st call of process_music ()
*/
-
- volta_span_->suicide ( );
+
+ volta_span_->suicide ();
volta_span_ = 0;
}
-
+
if (end_volta_span_ && !end_volta_span_->get_bound (RIGHT))
{
- Grob * cc = unsmob_grob (get_property ("currentCommandColumn"));
- Item * ci = dynamic_cast<Item*> (cc);
+ Grob *cc = unsmob_grob (get_property ("currentCommandColumn"));
+ Item *ci = dynamic_cast<Item *> (cc);
end_volta_span_->set_bound (RIGHT, ci);
}
if (volta_span_ && !volta_span_->get_bound (LEFT))
{
- Grob * cc = unsmob_grob (get_property ("currentCommandColumn"));
- Item * ci = dynamic_cast<Item*> (cc);
+ Grob *cc = unsmob_grob (get_property ("currentCommandColumn"));
+ Item *ci = dynamic_cast<Item *> (cc);
volta_span_->set_bound (LEFT, ci);
}
-
+
}
/*
TODO: should attach volta to paper-column if no bar is found.
- */
+*/
ADD_TRANSLATOR (Volta_engraver,
-/* descr */ "Make volta brackets.",
-/* creats*/ "VoltaBracket",
-/* accepts */ "",
-/* acks */ "bar-line-interface staff-symbol-interface note-column-interface",
-/* reads */ "repeatCommands voltaSpannerDuration stavesFound",
-/* write */ "");
+ /* descr */ "Make volta brackets.",
+ /* creats*/ "VoltaBracket",
+ /* accepts */ "",
+ /* acks */ "bar-line-interface staff-symbol-interface note-column-interface",
+ /* reads */ "repeatCommands voltaSpannerDuration stavesFound",
+ /* write */ "");