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