]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar.cc
913c2c72ed1c0622c0107c4ef11829ec30fef4af
[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 }
22
23 void
24 Bar::do_print () const
25 {
26 #ifndef NPRINT
27   String s = type_str_;
28   DOUT << "type = " << s;
29 #endif
30 }
31
32 Real
33 Bar::get_bar_size () const
34 {
35   // Never called!
36   return 0;
37 }
38
39
40 Molecule*
41 Bar::do_brew_molecule_p () const
42 {    
43   Molecule *output = new Molecule (lookup_l ()->bar (type_str_, get_bar_size (), paper_l ()));
44   
45   return output;
46 }
47
48 /**
49   Prescriptions for splitting bars.
50   TODO: put this in SCM.
51  */
52 static char const *bar_breaks[][3] ={
53   {":|", ":|:", "|:"},
54   {"|", "|", ""},
55   {"", "|s", "|"},
56   {"|", "|:", "|:"},
57   {"|.", "|.", ""},
58   {":|", ":|", ""},
59   {"||", "||", ""},
60   {".|.", ".|.", ""},
61   {"", "scorebar", "scorepostbreak"},
62   {"", "brace", "brace"},
63   {"", "bracket", "bracket"},  
64   {0,0,0}
65 };
66
67 void
68 Bar::do_pre_processing ()
69 {
70   for (int i=0; bar_breaks[i][0]; i++) 
71     {
72       if (bar_breaks[i][1] == type_str_)
73         {
74           type_str_ = bar_breaks[i][break_status_dir ()+1];
75           break;
76         }
77     }
78   if (remove_elt_property (at_line_start_scm_sym)!= SCM_BOOL_F
79       && (break_status_dir () == RIGHT) && (type_str_ == ""))
80     {
81       type_str_ = "|";
82     }
83
84   if (type_str_ =="")
85     dim_cache_[X_AXIS]->set_empty (true);
86 }
87