]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar.cc
release: 1.1.35
[lilypond.git] / lily / bar.cc
1 /*
2   bar.cc -- implement Bar
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "bar.hh"
10 #include "string.hh"
11 #include "molecule.hh"
12 #include "paper-def.hh"
13 #include "lookup.hh"
14 #include "debug.hh"
15
16
17 Bar::Bar ()
18 {
19   set_elt_property (breakable_scm_sym, SCM_BOOL_T);
20   type_str_ = "|";
21   at_line_start_b_ = false;
22 }
23
24 void
25 Bar::do_print () const
26 {
27 #ifndef NPRINT
28     //  DOUT << type_str_; "{[" confuse  indenter.
29 #endif
30 }
31
32 Real
33 Bar::get_bar_size () const
34 {
35   return paper_l ()->get_var ("barsize");
36 }
37
38
39 Molecule*
40 Bar::do_brew_molecule_p () const
41 {    
42   Molecule *output = new Molecule (lookup_l ()->bar (type_str_, get_bar_size ()));
43   
44   return output;
45 }
46
47 /**
48   Prescriptions for splitting bars.
49   TODO: put this in SCM.
50  */
51 static char const *bar_breaks[][3] ={
52   {":|", ":|:", "|:"},
53   {"|", "|", ""},
54   {"", "|s", "|"},
55   {"", "|:", "|:"},
56   {"|.", "|.", ""},
57   {":|", ":|", ""},
58   {"||", "||", ""},
59   {".|.", ".|.", ""},
60   {"", "scorebar", "|"},
61   {"", "{", "{"},
62   {"", "[", "["},  
63   {0,0,0}
64 };
65
66 void
67 Bar::do_pre_processing ()
68 {
69   for (int i=0; bar_breaks[i][0]; i++) 
70     {
71       if (bar_breaks[i][1] == type_str_)
72         {
73           type_str_ = bar_breaks[i][break_status_dir ()+1];
74           if (at_line_start_b_ && (break_status_dir () == RIGHT) && (type_str_ == ""))
75             {
76               type_str_ = "|";
77             }
78         }
79     }
80 }
81