]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tuplet-bracket.cc
* lily/general-scheme.cc (LY_DEFINE): Use snprintf (WAS: sprintf).
[lilypond.git] / lily / tuplet-bracket.cc
index f067f289bad54fbf18cd59f4e9e4cc398f699592..cab2e673baaeb1b103d566f6222a7ae019582d7f 100644 (file)
   
  */
 
+/*
+
+    TODO: quantise, we don't want to collide with staff lines.
+ (or should we be above staff?)
+
+  todo: handle breaking elegantly.
+*/
+
 #include <math.h>
 
+#include "tuplet-bracket.hh"
 #include "line-interface.hh"
 #include "beam.hh"
-#include "box.hh"
 #include "warn.hh"
 #include "font-interface.hh"
-#include "stencil.hh"
 #include "output-def.hh"
 #include "text-item.hh"
-#include "tuplet-bracket.hh"
 #include "stem.hh"
 #include "note-column.hh"
 #include "group-interface.hh"
@@ -42,7 +48,6 @@
 #include "staff-symbol-referencer.hh"
 #include "lookup.hh"
 
-
 static Grob*
 get_x_bound_grob (Grob *g, Direction my_dir)
 {
@@ -70,7 +75,7 @@ Tuplet_bracket::parallel_beam (Grob *me, Link_array<Grob> const &cols, bool *equ
   
   Spanner*sp = dynamic_cast<Spanner*> (me);  
 
-  *equally_long= false;
+  *equally_long = false;
   if (! (b1 && (b1 == b2) && !sp->is_broken ()))
       return 0;
 
@@ -100,9 +105,9 @@ MAKE_SCHEME_CALLBACK (Tuplet_bracket,print,1);
 SCM
 Tuplet_bracket::print (SCM smob) 
 {
-  Grob *me= unsmob_grob (smob);
+  Grob *me = unsmob_grob (smob);
   Stencil  mol;
-  Link_array<Grob> columns=
+  Link_array<Grob> columns =
     Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns");
 
   if (!columns.size ())
@@ -168,7 +173,7 @@ Tuplet_bracket::print (SCM smob)
   
   SCM number = me->get_property ("text");
 
-  Output_def *pap = me->get_paper ();
+  Output_def *pap = me->get_layout ();
   Stencil num;
  if (scm_is_string (number) && number_visibility)
     {
@@ -199,7 +204,7 @@ Tuplet_bracket::print (SCM smob)
   if (bracket_visibility)      
     {
       Real ss =   Staff_symbol_referencer::staff_space (me);
-      Real gap=0.;
+      Real gap = 0.;
 
       if (!num.extent (X_AXIS).is_empty ())
        gap = num.extent (X_AXIS).length () + 1.0;
@@ -299,12 +304,11 @@ Tuplet_bracket::make_bracket (Grob *me,   // for line properties.
   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=
+  Link_array<Grob> columns =
     Pointer_group_interface__extract_grobs (me, (Grob*)0, "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);  
@@ -328,8 +332,8 @@ Tuplet_bracket::calc_position_and_height (Grob*me,Real *offset, Real * dy)
   
   if (l < r)
     {
-      Interval rv =columns[r]->extent (commony, Y_AXIS);
-      Interval lv =columns[l]->extent (commony, Y_AXIS);
+      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];
@@ -370,7 +374,7 @@ Tuplet_bracket::calc_position_and_height (Grob*me,Real *offset, Real * dy)
   
   for (int i = 0; i < columns.size ();  i++)
     {
-      Interval note_ext =columns[i]->extent (commony, Y_AXIS);
+      Interval note_ext = columns[i]->extent (commony, Y_AXIS);
       note_ext.unite (staff);
       Real notey = note_ext[dir] - me->relative_coordinate (commony, Y_AXIS);
       
@@ -389,7 +393,7 @@ Tuplet_bracket::calc_position_and_height (Grob*me,Real *offset, Real * dy)
     horizontal brackets should not collide with staff lines.
     
    */
-  Real ss= Staff_symbol_referencer::staff_space (me);
+  Real ss = Staff_symbol_referencer::staff_space (me);
   if (*dy == 0 && fabs (*offset) <  ss * Staff_symbol_referencer::staff_radius (me))
     {
       // quantize, then do collision check.
@@ -414,13 +418,13 @@ SCM
 Tuplet_bracket::before_line_breaking (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
-  Link_array<Grob> columns=
+  Link_array<Grob> columns =
     Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns");
 
 
   for (int i = columns.size (); i--;)
     {
-      Grob * s =Note_column::get_stem (columns[i]);
+      Grob * s = Note_column::get_stem (columns[i]);
       Grob * b = s ? Stem::get_beam (s): 0;
       if (b)
        me->add_dependency (b);
@@ -434,7 +438,7 @@ SCM
 Tuplet_bracket::after_line_breaking (SCM smob)
 {
   Grob * me = unsmob_grob (smob);
-  Link_array<Grob> columns=
+  Link_array<Grob> columns =
     Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns");
 
   if (!columns.size ())
@@ -472,8 +476,8 @@ Tuplet_bracket::after_line_breaking (SCM smob)
     {
       SCM ps =  par_beam->get_property ("positions"); 
 
-      Real lp = scm_to_double (ly_car (ps));
-      Real rp = scm_to_double (ly_cdr (ps));
+      Real lp = scm_to_double (scm_car (ps));
+      Real rp = scm_to_double (scm_cdr (ps));
 
       /*
        duh. magic.
@@ -497,7 +501,7 @@ Tuplet_bracket::after_line_breaking (SCM smob)
   else if (!scm_is_number (rp) && !scm_is_number (lp))
     {
       lp = scm_make_real (offset);
-      rp = scm_make_real (offset +dy);
+      rp = scm_make_real (offset + dy);
     }
 
   me->set_property ("left-position", lp);
@@ -514,9 +518,9 @@ Direction
 Tuplet_bracket::get_default_dir (Grob*me)
 {
   Drul_array<int> dirs (0,0);  
-  for (SCM s = me->get_property ("note-columns"); scm_is_pair (s); s = ly_cdr (s))
+  for (SCM s = me->get_property ("note-columns"); scm_is_pair (s); s = scm_cdr (s))
     {
-      Grob * nc = unsmob_grob (ly_car (s));
+      Grob * nc = unsmob_grob (scm_car (s));
       Direction d = Note_column::dir (nc);
       if (d)
        dirs[d]++;
@@ -539,7 +543,11 @@ Tuplet_bracket::add_column (Grob*me, Item*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");
+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");