]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/paper-line.cc
* lily/include/paper-line.hh (class Paper_line): New member
[lilypond.git] / lily / paper-line.cc
index e4da3cb548337bba2cf5120c3466e0f1c67b4d18..210dda7d69dfb160b899c29d9b533e9ddf736578 100644 (file)
@@ -8,12 +8,44 @@
 
 #include "paper-line.hh"
 #include "ly-smobs.icc"
+#include "string.hh" // to_string
 
-Paper_line::Paper_line (Offset o, SCM stencils, bool is_title)
+#define TITLE_PENALTY -1
+
+Paper_line::Paper_line (Offset o, SCM stencils, int penalty, bool is_title)
 {
   dim_ = o;
   stencils_ = stencils;
   is_title_ = is_title;
+  penalty_ = penalty;
+  smobify_self ();
+}
+
+Paper_line::~Paper_line ()
+{
+}
+
+IMPLEMENT_SMOBS (Paper_line);
+IMPLEMENT_TYPE_P (Paper_line, "ly:paper-line?");
+IMPLEMENT_DEFAULT_EQUAL_P (Paper_line);
+
+SCM
+Paper_line::mark_smob (SCM s)
+{
+  Paper_line *line = (Paper_line*) ly_cdr (s);
+  return line->stencils_;
+}
+
+int
+Paper_line::print_smob (SCM s, SCM port, scm_print_state*)
+{
+  scm_puts ("#<Paper_line ", port);
+  Paper_line *line = (Paper_line*) ly_cdr (s);
+  scm_puts (to_string (line->number_).to_str0 (), port);
+  if (line->is_title ())
+    scm_puts (" t", port);
+  scm_puts (" >", port);
+  return 1;
 }
 
 Offset
@@ -28,34 +60,41 @@ Paper_line::is_title () const
   return is_title_;
 }
 
+int
+Paper_line::penalty () const
+{
+  return penalty_;
+}
+
 SCM
 Paper_line::stencils () const
 {
   return stencils_;
 }
 
-SCM
-Paper_line::mark_smob (SCM s)
+LY_DEFINE (ly_paper_line_height, "ly:paper-line-height",
+          1, 0, 0, (SCM line),
+          "Return the height of @var{line}.")
 {
-  Paper_line *line = (Paper_line*) ly_cdr (s);
-  return line->stencils_;
+  Paper_line *pl = unsmob_paper_line (line);
+  SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
+  return scm_make_real (pl->dim ()[Y_AXIS]);
 }
 
-int
-Paper_line::print_smob (SCM, SCM port, scm_print_state*)
+LY_DEFINE (ly_paper_line_number, "ly:paper-line-number",
+          1, 0, 0, (SCM line),
+          "Return the number of @var{line}.")
 {
-  scm_puts ("#<Paper_line ", port);
-  scm_puts (" >", port);
-  return 1;
+  Paper_line *pl = unsmob_paper_line (line);
+  SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
+  return scm_int2num (pl->number_);
 }
 
-SCM
-Paper_line::smobbed_copy () const
+LY_DEFINE (ly_paper_line_break_score, "ly:paper-line-break-score",
+          1, 0, 0, (SCM line),
+          "Return the score for page break after @var{line}.")
 {
-  Paper_line *line = new Paper_line (*this);
-  return line->smobbed_self ();
+  Paper_line *pl = unsmob_paper_line (line);
+  SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line");
+  return scm_int2num (int (pl->penalty ()));
 }
-
-IMPLEMENT_SIMPLE_SMOBS (Paper_line);
-IMPLEMENT_TYPE_P (Paper_line, "ly:paper-line?");
-IMPLEMENT_DEFAULT_EQUAL_P (Paper_line);