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