From: David Nalesnik Date: Wed, 26 Aug 2015 14:46:07 +0000 (-0500) Subject: Scheme function to draw lines based on grob layout X-Git-Tag: release/2.19.27-1~19 X-Git-Url: https://git.donarmstrong.com/?p=lilypond.git;a=commitdiff_plain;h=5eabb1db205318d9c3acc1f2eddd4aedd6547084 Scheme function to draw lines based on grob layout A number of C++ stencil callbacks use Line_interface::line to draw lines based on line-interface properties defining a particular grob. This allows control of aspects such as line style (based on the setting of Grob.style) and fine-tuning of dashed lines through dash-fraction and dash-period. This patch gives access to Line_interface::line in Scheme through the callback ly:line-interface::line. (The simpler name ly:line was ruled out in an effort to distinguish it from other functions such as ly:bracket and ly:circle which do not take a grob argument.) Users will be able to create custom stencils with more functionality (including rewriting certain C++ callbacks--such as Hairpin::print--to allow for easy modifications without loss of capability.) --- diff --git a/lily/line-interface-scheme.cc b/lily/line-interface-scheme.cc new file mode 100644 index 0000000000..dee6a15d15 --- /dev/null +++ b/lily/line-interface-scheme.cc @@ -0,0 +1,44 @@ +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 2010--2015 Han-Wen Nienhuys + + 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. + + 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. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ + +#include "line-interface.hh" + +#include "stencil.hh" +#include "grob.hh" + +LY_DEFINE (ly_line_interface__line, "ly:line-interface::line", + 5, 0, 0, (SCM grob, SCM startx, SCM starty, SCM endx, SCM endy), + "Make a line using layout information from grob @var{grob}.") +{ + LY_ASSERT_SMOB (Grob, grob, 1); + + Grob *me = unsmob (grob); + + LY_ASSERT_TYPE (scm_is_number, startx, 2); + LY_ASSERT_TYPE (scm_is_number, starty, 3); + LY_ASSERT_TYPE (scm_is_number, endx, 4); + LY_ASSERT_TYPE (scm_is_number, endy, 5); + + Offset from = Offset (scm_to_double (startx), scm_to_double (starty)); + Offset to = Offset (scm_to_double (endx), scm_to_double (endy)); + + Stencil stil = Line_interface::line (me, from, to); + + return stil.smobbed_copy (); +}