Reviewers: Neil Puttock,
Message:
Thanks Neil!
New patch set uploaded.
Cheers,
Mike
http://codereview.appspot.com/4254055/diff/1/lily/balloon.cc
File lily/balloon.cc (right):
http://codereview.appspot.com/4254055/diff/1/lily/balloon.cc#newcode38
lily/balloon.cc:38: static SCM internal_balloon_print (Grob *me, Grob
*p, Offset &off);
On 2011/03/06 23:35:28, Neil Puttock wrote:
Offset *off (makes code fussy due to dereferencing)
or
Offset off (better: all existing code appears to pass Offset by value)
Done.
http://codereview.appspot.com/4254055/diff/1/lily/balloon.cc#newcode75
lily/balloon.cc:75: spanner_placement = 1.0;
On 2011/03/06 23:35:28, Neil Puttock wrote:
Real spanner_placement =
min (1.0, max (robust_scm2double (me->get_property
("spanner-placement"),
-1.0), -1.0));
Done.
http://codereview.appspot.com/4254055/diff/1/lily/balloon.cc#newcode93
lily/balloon.cc:93: Drul_array<Item *> bounds;
On 2011/03/06 23:35:28, Neil Puttock wrote:
remove
Done.
http://codereview.appspot.com/4254055/diff/1/scm/define-grob-properties.scm
File scm/define-grob-properties.scm (right):
http://codereview.appspot.com/4254055/diff/1/scm/define-grob-properties.scm#newcode51
scm/define-grob-properties.scm:51: (annotation-balloon ,boolean? "Print
the ballon around an annotation.")
On 2011/03/06 23:35:28, Neil Puttock wrote:
Print the balloon
Done.
http://codereview.appspot.com/4254055/diff/1/scm/define-grobs.scm
File scm/define-grobs.scm (left):
http://codereview.appspot.com/4254055/diff/1/scm/define-grobs.scm#oldcode872
scm/define-grobs.scm:872: (Y-extent . 0.0)
On 2011/03/06 23:35:28, Neil Puttock wrote:
Y-extent . #f
Done.
http://codereview.appspot.com/4254055/diff/1/scm/define-grobs.scm#oldcode887
scm/define-grobs.scm:887: (Y-extent . 0.0)
On 2011/03/06 23:35:28, Neil Puttock wrote:
Y-extent . #f
Done.
http://codereview.appspot.com/4254055/diff/1/scm/define-grobs.scm
File scm/define-grobs.scm (right):
http://codereview.appspot.com/4254055/diff/1/scm/define-grobs.scm#newcode180
scm/define-grobs.scm:180: (annotation-balloon . #f)
On 2011/03/06 23:37:55, Neil Puttock wrote:
On 2011/03/06 23:35:28, Neil Puttock wrote:
> remove
Oops, I mean change to #t (same for annotation-line)
Done.
Description:
Implements the 2nd of 5 legs of getting footnotes up and running.
Gets the annotations to print next to the footnoted grobs.
The 3rd leg will be merging Balloon and FootnoteItem into one grob
that is responsible for annotations.
The 4th will be implementing endnotes.
The 5th will be automatic numbering.
Please review this at http://codereview.appspot.com/4254055/
Affected files:
M lily/balloon.cc
M lily/system.cc
M scm/define-grob-properties.scm
M scm/define-grobs.scm
Index: lily/balloon.cc
diff --git a/lily/balloon.cc b/lily/balloon.cc
index
f4efd4c4894a7b827e62b4a203a312daa8da0c28..793bcf13c3ed751e6bcc63be9dc5fde02790a201
100644
--- a/lily/balloon.cc
+++ b/lily/balloon.cc
@@ -19,18 +19,23 @@
#include "text-interface.hh"
#include "grob.hh"
+#include "item.hh"
#include "line-interface.hh"
#include "lookup.hh"
#include "font-interface.hh"
#include "lily-guile.hh"
#include "output-def.hh"
#include "misc.hh"
+#include "spanner.hh"
class Balloon_interface
{
public:
DECLARE_SCHEME_CALLBACK (print, (SCM));
+ DECLARE_SCHEME_CALLBACK (print_spanner, (SCM));
DECLARE_GROB_INTERFACE ();
+
+ static SCM internal_balloon_print (Grob *me, Grob *p, Offset off);
};
MAKE_SCHEME_CALLBACK (Balloon_interface, print, 1);
@@ -39,19 +44,67 @@ Balloon_interface::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
+ if (Item *item = dynamic_cast<Item *>(me))
+ if (!Item::break_visible (item))
+ return SCM_EOL;
+
Grob *p = me->get_parent (X_AXIS);
-
+
Offset off (me->relative_coordinate (p, X_AXIS),
me->relative_coordinate (p, Y_AXIS));
+ return internal_balloon_print (me, p, off);
+}
+
+// ugh...code dup...hopefully can be consolidated w/ above one day
+MAKE_SCHEME_CALLBACK (Balloon_interface, print_spanner, 1);
+SCM
+Balloon_interface::print_spanner (SCM smob)
+{
+ Spanner *me = unsmob_spanner (smob);
+ Grob *orig = me->original ();
+
+ if (orig)
+ {
+ // TODO : consolidate code dup from
System::get_footnote_grobs_in_range
+ int pos = orig->spanned_rank_interval ()[LEFT];
+ Real spanner_placement = min (1.0,
+ max (robust_scm2double
(me->get_property ("spanner-placement"), -1.0),
+ -1.0));
+
+ spanner_placement = (spanner_placement + 1.0) / 2.0;
+ int rpos = orig->spanned_rank_interval ()[RIGHT];
+ pos = (int)((rpos - pos) * spanner_placement + pos + 0.5);
+
+ if (pos < me->spanned_rank_interval () [LEFT])
+ return SCM_EOL;
+ if (pos >= me->spanned_rank_interval () [RIGHT] &&
(me->spanned_rank_interval () [RIGHT] != orig->spanned_rank_interval ()
[RIGHT]))
+ return SCM_EOL;
+ }
+
+
+ Spanner *p = dynamic_cast<Spanner *>(me->get_parent (Y_AXIS));
+
+ if (!p)
+ return SCM_EOL;
+
+ Offset off (me->relative_coordinate (me->get_bound (LEFT), X_AXIS),
+ me->relative_coordinate (p, Y_AXIS));
+ return internal_balloon_print (me, p, off);
+}
+
+SCM
+Balloon_interface::internal_balloon_print (Grob *me, Grob *p, Offset off)
+{
Box b (p->extent (p, X_AXIS),
p->extent (p, Y_AXIS));
-
Real padding = robust_scm2double (me->get_property ("padding"), .1);
b.widen (padding, padding);
// FIXME
- Stencil fr = Lookup::frame (b, 0.1, 0.05);
+ Stencil fr;
+ if (to_boolean (me->get_property ("annotation-balloon")))
+ fr = Lookup::frame (b, 0.1, 0.05);
SCM bt = me->get_property ("text");
SCM chain = Font_interface::text_font_alist_chain (me);
@@ -71,7 +124,8 @@ Balloon_interface::print (SCM smob)
Offset z2 = z1 + off;
- fr.add_stencil (Line_interface::line (me, z1, z2));
+ if (to_boolean (me->get_property ("annotation-line")))
+ fr.add_stencil (Line_interface::line (me, z1, z2));
text_stil->translate (z2);
fr.add_stencil (*text_stil);
@@ -85,7 +139,10 @@ ADD_INTERFACE (Balloon_interface,
" object.",
/* properties */
+ "annotation-balloon "
+ "annotation-line "
"padding "
+ "spanner-placement "
"text "
);
Index: lily/system.cc
diff --git a/lily/system.cc b/lily/system.cc
index
6bf428206d2481882108720405ef89e51d345beb..574dce56c9de8e54869b164e772dc702707663d0
100644
--- a/lily/system.cc
+++ b/lily/system.cc
@@ -254,11 +254,9 @@ System::get_footnote_grobs_in_range (vector<Grob *>
&out, vsize start, vsize end
bool end_of_line_visible = true;
if (Spanner *s = dynamic_cast<Spanner *>(footnote_grobs_[i]))
{
- Real spanner_placement = robust_scm2double (s->get_property
("spanner-placement"), -1.0);
- if (spanner_placement < -1.0)
- spanner_placement = -1.0;
- if (spanner_placement > 1.0)
- spanner_placement = 1.0;
+ Real spanner_placement = min (1.0,
+ max (robust_scm2double
(s->get_property ("spanner-placement"), -1.0),
+ -1.0));
spanner_placement = (spanner_placement + 1.0) / 2.0;
int rpos = s->spanned_rank_interval ()[RIGHT];
Index: scm/define-grob-properties.scm
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index
9a6ba22d8b44130b7e12648d1007dd06bdd2998d..aa6ce82cb7ff1c2bad24b65a9f06369ae50959a4
100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -48,6 +48,9 @@ be created below this bar line.")
(alteration-alist ,list? "List of @code{(@var{pitch}
. @var{accidental})} pairs for key signature.")
(annotation ,string? "Annotate a grob for debug purposes.")
+ (annotation-balloon ,boolean? "Print the balloon around an
annotation.")
+ (annotation-line ,boolean? "Print the line from an annotation to the
+grob that it annotates.")
(arpeggio-direction ,ly:dir? "If set, put an arrow on the
arpeggio squiggly line.")
(arrow-length ,number? "Arrow length.")
Index: scm/define-grobs.scm
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index
ac75852215a03d5cde2ab83815e16b2ec172c2d7..e5658a8384d4c2745f709ea49917d440196048c8
100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -177,6 +177,8 @@
(BalloonTextItem
. (
+ (annotation-balloon . #t)
+ (annotation-line . #t)
(stencil . ,ly:balloon-interface::print)
(text . ,(grob::calc-property-by-copy 'text))
(X-offset . ,(grob::calc-property-by-copy 'X-offset))
@@ -865,11 +867,13 @@
(FootnoteItem
. (
+ (annotation-balloon . #f)
+ (annotation-line . #t)
(break-visibility . ,inherit-y-parent-visibility)
(footnote-text . ,(grob::calc-property-by-copy 'footnote-text))
- (stencil . #f)
+ (stencil . ,ly:balloon-interface::print)
(text . ,(grob::calc-property-by-copy 'text))
- (Y-extent . 0.0)
+ (Y-extent . #f)
(X-offset . ,(grob::calc-property-by-copy 'X-offset))
(Y-offset . ,(grob::calc-property-by-copy 'Y-offset))
(meta . ((class . Item)
@@ -880,11 +884,13 @@
(FootnoteSpanner
. (
+ (annotation-balloon . #f)
+ (annotation-line . #t)
(footnote-text . ,(grob::calc-property-by-copy 'footnote-text))
(spanner-placement . -1.0)
- (stencil . #f)
+ (stencil . ,ly:balloon-interface::print-spanner)
(text . ,(grob::calc-property-by-copy 'text))
- (Y-extent . 0.0)
+ (Y-extent . #f)
(X-offset . ,(grob::calc-property-by-copy 'X-offset))
(Y-offset . ,(grob::calc-property-by-copy 'Y-offset))
(meta . ((class . Spanner)
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel