2004-01-17 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * input/regression/balloon.ly: new file.
+
+ * lily/balloon.cc (brew_molecule): new file: draw boxes around
+ objects, and make help texts.
+
* scm/new-markup.scm (parse-simple-duration): parse duration
string to log & dots. (Thanks Nicolas!)
@item Music properties
These are used internally, and most users will not see or use them.
-They use Scheme style naming: @code{pitch}, @code{tremolo-type}.
+They use Scheme-style naming, i.e. lowercase words separated with
+dashes: @code{pitch}, @code{tremolo-type}.
@item Translation properties
These influence the translation process, and most users will encounter them
--- /dev/null
+
+\header {
+ texidoc = "With balloon texts, objects in the output can be marked,
+with lines and explanatory text added."
+ }
+\version "2.1.11"
+
+\score {
+ \notes {
+
+ \relative c' {
+
+ \once\property Voice.Stem \set #'molecule-callback = #Balloon_interface::brew_molecule
+ \once\property Voice.Stem \set #'original-callback = #Stem::brew_molecule
+ \once\property Voice.Stem \set #'balloon-text = #"I'm a stem"
+ \once\property Voice.Stem \set #'balloon-text-offset = #'(3 . 4)
+ \once\property Voice.Stem \set #'balloon-text-props
+ = #'((font-family . roman))
+
+
+ c8
+ }
+ }
+ \paper{ raggedright = ##t }
+}
--- /dev/null
+/*
+ balloon.cc -- implement Balloon objects
+ */
+
+#include "text-item.hh"
+#include "grob.hh"
+#include "lookup.hh"
+#include "font-interface.hh"
+#include "molecule.hh"
+#include "lily-guile.hh"
+#include "paper-def.hh"
+#include "misc.hh"
+
+struct Balloon_interface
+{
+
+public:
+ DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM));
+ static bool has_interface (Grob*);
+};
+
+MAKE_SCHEME_CALLBACK (Balloon_interface, brew_molecule, 1);
+SCM
+Balloon_interface::brew_molecule (SCM smob)
+{
+ Grob *me= unsmob_grob (smob);
+
+ SCM cb = me->get_grob_property ("original-callback");
+ SCM scm_mol = SCM_EOL;
+
+ if (gh_procedure_p (cb))
+ {
+ scm_mol = scm_call_1 (cb, smob);
+ }
+
+ if (!unsmob_molecule (scm_mol))
+ return scm_mol;
+
+ SCM scm_off = me->get_grob_property ("balloon-text-offset");
+
+ if (!is_number_pair (scm_off))
+ return scm_mol;
+
+ Offset off = ly_scm2offset (scm_off);
+ Molecule * m = unsmob_molecule (scm_mol);
+ Box orig_extent = m->extent_box ();
+ Box box_extent = orig_extent;
+
+ SCM widen = me->get_grob_property ("balloon-padding");
+ Real w = .1;
+ if (gh_number_p (widen))
+ {
+ w = gh_scm2double (widen);
+ }
+ box_extent.widen (w, w);
+
+
+ Molecule fr = Lookup::frame (box_extent, 0.1, 0.05);
+
+
+ fr.add_molecule (*m);
+
+
+
+ SCM bt = me->get_grob_property ("balloon-text");
+ SCM chain = Font_interface::font_alist_chain (me);
+ chain = gh_cons (me->get_grob_property ("balloon-text-props"), chain);
+
+
+ SCM text = Text_item::interpret_markup (me->get_paper ()->self_scm (), chain, bt);
+
+
+ Molecule *text_mol = unsmob_molecule (text);
+
+ Offset z1;
+
+ for (int i = X_AXIS; i < NO_AXES; i++)
+ {
+ Axis a((Axis)i);
+ z1[a] = box_extent [a].linear_combination (sign (off[a]));
+ text_mol->align_to (a, -sign (off[a]));
+ }
+
+ Offset z2 = z1 + off;
+
+ fr.add_molecule (Lookup::line (0.1, z1, z2));
+
+ text_mol->translate (z2);
+ fr.add_molecule (*text_mol);
+
+ fr = Molecule (orig_extent, fr.get_expr ());
+ return fr.smobbed_copy ();
+}
+
+ADD_INTERFACE (Balloon_interface,"text-balloon-interface",
+ "comic books.",
+ "balloon-padding balloon-text-props balloon-text-offset balloon-text balloon-original-callback");
+
return Offset (interval_a_[X_AXIS].center(),
interval_a_[Y_AXIS].center());
}
+void
+Box::widen (Real x, Real y)
+{
+ interval_a_[X_AXIS].widen (x);
+ interval_a_[Y_AXIS].widen (y);
+
+}
/// smallest box enclosing #b#
void set_empty ();
void add_point (Offset);
+ void widen (Real x, Real y);
void scale (Real r);
void unite (Box b);
Box ();
/*
- text-item.hh -- declare Text_item
+ text-item.hh -- declare markup functions
source file of the GNU LilyPond music typesetter
{
public:
DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM));
- DECLARE_SCHEME_CALLBACK (interpret_markup, (SCM,SCM, SCM));
+ DECLARE_SCHEME_CALLBACK (interpret_markup, (SCM, SCM, SCM));
static bool has_interface (Grob*);
static bool markup_p (SCM) ;
| MARKUP_HEAD_SCM0_SCM1_SCM2 embedded_scm embedded_scm embedded_scm {
$$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED);
}
+ | MARKUP_HEAD_SCM0_SCM1 embedded_scm embedded_scm {
+ $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED);
+ }
| MARKUP_IDENTIFIER {
$$ = $1;
}
where a horizontal beam fits that is larger than this number, make a kneed beam.")
(grob-property-description 'axes list? "list of axis numbers.
In the case of alignment grobs, this should contain only one number.")
+
+(grob-property-description 'balloon-text markup? "Text to add to help balloon")
+(grob-property-description 'balloon-text-props list? "Font properties
+for balloon text.")
+(grob-property-description 'balloon-text-offset number-pair?
+ "Where to put text relative to balloon.")
+(grob-property-description 'balloon-padding ly:dimension? "Text to add to help balloon")
+(grob-property-description 'original-callback procedure? "The
+original molecule drawer to draw the balloon around.")
+
+
(grob-property-description 'bar-size ly:dimension? "size of a bar line.")
(grob-property-description 'bars grob-list? "list of barline pointers.")
(grob-property-description 'bar-size-procedure procedure? "Procedure that computes the size of a bar line.")