]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/horizontal-bracket.cc
Release: bump Welcome versions.
[lilypond.git] / lily / horizontal-bracket.cc
index 654a1e0015857a41cf59f4213867518ac2f19252..b453985b091b6ef31c7ff16f3b6f5110597d6232 100644 (file)
@@ -1,73 +1,66 @@
 /*
-  horizontal-bracket.cc -- implement  Horizontal_bracket
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the GNU LilyPond music typesetter
+  Copyright (C) 2002--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
-  (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
 
-#include "side-position-interface.hh"
-#include "lookup.hh"
-#include "group-interface.hh"
-#include "directional-element-interface.hh"
-#include "output-def.hh"
-#include "staff-symbol-referencer.hh"
-#include "tuplet-bracket.hh"   // ugh.
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
 
-struct Horizontal_bracket
-{
-  DECLARE_SCHEME_CALLBACK (print, (SCM));
-  static bool has_interface (Grob *);
-};
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
+*/
 
-/*
-  TODO:
+#include "horizontal-bracket.hh"
 
-  This doesn't look very elegant: should support winged edges.
+#include "bracket.hh"
+#include "stencil.hh"
+#include "pointer-group-interface.hh"
+#include "directional-element-interface.hh"
+#include "spanner.hh"
+#include "item.hh"
 
-  Support texts on the brackets?
-*/
 MAKE_SCHEME_CALLBACK (Horizontal_bracket, print, 1);
-
 SCM
 Horizontal_bracket::print (SCM smob)
 {
-  Grob *me = unsmob_grob (smob);
-  Spanner *sp = dynamic_cast<Spanner *> (me);
-  Link_array<Grob> gs = extract_grob_array (me, ly_symbol2scm ("columns"));
+  Spanner *me = unsmob<Spanner> (smob);
+  extract_grob_set (me, "columns", gs);
 
+  vector<Grob *> enclosed = gs;
   if (!gs.size ())
     {
       me->suicide ();
       return SCM_EOL;
     }
-  Grob *cx = common_refpoint_of_array (gs, me, X_AXIS);
-  cx = cx->common_refpoint (sp->get_bound (LEFT), X_AXIS);
-  cx = cx->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
 
-  Interval ext = gs.top ()->extent (cx, X_AXIS);
-  ext.unite (gs[0]->extent (cx, X_AXIS));
-
-  Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
-                                                     Interval (1.0, 1.0));
-
-  Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"),
-                                               Interval (0, 0));
-
-  Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"),
-                                                 Interval (0, 0));
-
-  Interval empty;
-  Stencil b
-    = Tuplet_bracket::make_bracket (me, Y_AXIS, Offset (ext.length (), 0),
-                                   edge_height, empty, flare, shorten);
-
-  b.translate_axis (ext[LEFT] - sp->get_bound (LEFT)->relative_coordinate (cx, X_AXIS), X_AXIS);
+  for (LEFT_and_RIGHT (d))
+    {
+      Item *b = me->get_bound (d);
+      if (b->break_status_dir ())
+        enclosed.push_back (b);
+    }
 
+  Stencil b = Bracket::make_enclosing_bracket (me, me, enclosed, X_AXIS,
+                                               get_grob_direction (me));
   return b.smobbed_copy ();
 }
 
-ADD_INTERFACE (Horizontal_bracket, "horizontal-bracket-interface",
-              "A horizontal bracket encompassing notes.",
-              "columns bracket-flare shorten-pair edge-height");
+ADD_INTERFACE (Horizontal_bracket,
+               "A horizontal bracket encompassing notes.",
+
+               /* properties */
+               "bracket-flare "
+               "bracket-text "
+               "columns "
+               "edge-height "
+               "shorten-pair "
+               "connect-to-neighbor "
+              );