]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/paper-book.cc
Add '-dcrop' option to ps and svg backends
[lilypond.git] / lily / paper-book.cc
index dfa52f4f79f121bbd9f5df5243c904d860adf774..f1787e99550f2bb09eb001188b69384c69e5f004 100644 (file)
@@ -30,6 +30,8 @@
 #include "warn.hh"
 #include "program-option.hh"
 #include "page-marker.hh"
+#include "ly-module.hh"
+#include "lily-imports.hh"
 
 
 Paper_book::Paper_book ()
@@ -51,7 +53,7 @@ Paper_book::~Paper_book ()
 {
 }
 
-const char Paper_book::type_p_name_[] = "ly:paper-book?";
+const char * const Paper_book::type_p_name_ = "ly:paper-book?";
 
 SCM
 Paper_book::mark_smob () const
@@ -116,12 +118,9 @@ Paper_book::output_aux (SCM output_channel,
   long page_nb = 0;
   if (scm_is_pair (performances_))
     {
-      SCM proc = ly_lily_module_constant ("write-performances-midis");
-
-      scm_call_3 (proc,
-                  performances (),
-                  output_channel,
-                  scm_from_long (*first_performance_number));
+      Lily::write_performances_midis (performances (),
+                                      output_channel,
+                                      scm_from_long (*first_performance_number));
       *first_performance_number += scm_ilength (performances_);
     }
 
@@ -220,6 +219,25 @@ Paper_book::output (SCM output_channel)
         warning (_f ("program option -dpreview not supported by backend `%s'",
                      get_output_backend_name ()));
     }
+
+  if (get_program_option ("crop"))
+    {
+      SCM framework
+        = ly_module_lookup (mod, ly_symbol2scm ("output-crop-framework"));
+
+      if (scm_is_true (framework))
+        {
+          SCM func = scm_variable_ref (framework);
+          scm_call_4 (func,
+                      output_channel,
+                      self_scm (),
+                      scopes,
+                      dump_fields ());
+        }
+      else
+        warning (_f ("program option -dcrop not supported by backend `%s'",
+                     get_output_backend_name ()));
+    }
 }
 
 void
@@ -228,11 +246,9 @@ Paper_book::classic_output_aux (SCM output,
 {
   if (scm_is_pair (performances_))
     {
-      SCM proc = ly_lily_module_constant ("write-performances-midis");
-      scm_call_3 (proc,
-                  performances (),
-                  output,
-                  scm_from_long (*first_performance_number));
+      Lily::write_performances_midis (performances (),
+                                      output,
+                                      scm_from_long (*first_performance_number));
       *first_performance_number += scm_ilength (performances_);
     }
 
@@ -433,10 +449,8 @@ Paper_book::get_system_specs ()
     }
 
   SCM page_properties
-    = scm_call_1 (ly_lily_module_constant ("layout-extract-page-properties"),
-                  paper_->self_scm ());
+    = Lily::layout_extract_page_properties (paper_->self_scm ());
 
-  SCM interpret_markup_list = ly_lily_module_constant ("interpret-markup-list");
   SCM header = SCM_EOL;
   SCM labels = SCM_EOL;
   for (SCM s = scm_reverse (scores_); scm_is_pair (s); s = scm_cdr (s))
@@ -497,10 +511,9 @@ Paper_book::get_system_specs ()
         }
       else if (Text_interface::is_markup_list (scm_car (s)))
         {
-          SCM texts = scm_call_3 (interpret_markup_list,
-                                  paper_->self_scm (),
-                                  page_properties,
-                                  scm_car (s));
+          SCM texts = Lily::interpret_markup_list (paper_->self_scm (),
+                                                   page_properties,
+                                                   scm_car (s));
           Prob *first = 0;
           Prob *last = 0;
           for (SCM list = texts; scm_is_pair (list); list = scm_cdr (list))
@@ -520,7 +533,7 @@ Paper_book::get_system_specs ()
               SCM footnotes = get_footnotes (unsmob<Stencil> (t)->expr ());
               ps->set_property ("footnotes", footnotes);
               ps->set_property ("is-title", SCM_BOOL_T);
-              if (list == texts)
+              if (scm_is_eq (list, texts))
                 first = ps;
               else
                 {