New twoside mode.

View: New views
18 Messages — Rating Filter:   Alert me  

New twoside mode.

by Neil Puttock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

LGTM.


http://codereview.appspot.com/144049/diff/1/2
File input/regression/paper-twoside.ly (right):

http://codereview.appspot.com/144049/diff/1/2#newcode15
Line 15: binding-offset = 5 \mm
I think this deserves a separate test, otherwise it just looks the same
as an ordinary page with slightly bigger but equal margins.

http://codereview.appspot.com/144049/diff/1/3
File lily/output-def.cc (right):

http://codereview.appspot.com/144049/diff/1/3#newcode173
Line 173: - left_margin_default
You'll have to add parentheses if you want to keep this indentation.

http://codereview.appspot.com/144049/diff/1/4
File ly/paper-defaults-init.ly (right):

http://codereview.appspot.com/144049/diff/1/4#newcode90
Line 90: twoside = ##f
I'm not too fond of this name, but can't think of anything better. :)

http://codereview.appspot.com/144049/diff/1/5
File scm/page.scm (right):

http://codereview.appspot.com/144049/diff/1/5#newcode320
Line 320: (ly:stencil-translate page-stencil (cons (prop 'right-margin)
0))))
You could simplify this a bit:

(if (ly:output-def-lookup layout 'twoside #f)
     (set! page-stencil
      (ly:stencil-translate page-stencil
       (cons (prop (if (even? number)
                       'left-margin
                       'right-margin))
             0)))

http://codereview.appspot.com/144049/diff/1/6
File scm/paper.scm (right):

http://codereview.appspot.com/144049/diff/1/6#newcode242
Line 242: (("foot-separation" . ,h) - '())
oops ;)

http://codereview.appspot.com/144049


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Parent Message unknown Re: New twoside mode.

by Joe Neeman-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


http://codereview.appspot.com/144049/diff/1/4
File ly/paper-defaults-init.ly (right):

http://codereview.appspot.com/144049/diff/1/4#newcode90
Line 90: twoside = ##f
On 2009/10/30 22:19:50, Neil Puttock wrote:
> I'm not too fond of this name, but can't think of anything better. :)

I think two-side would be at least a slight improvement.

http://codereview.appspot.com/144049


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: New twoside mode.

by David Kastrup :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

joeneeman@... writes:

> http://codereview.appspot.com/144049/diff/1/4
> File ly/paper-defaults-init.ly (right):
>
> http://codereview.appspot.com/144049/diff/1/4#newcode90
> Line 90: twoside = ##f
> On 2009/10/30 22:19:50, Neil Puttock wrote:
>> I'm not too fond of this name, but can't think of anything better. :)
>
> I think two-side would be at least a slight improvement.
>
> http://codereview.appspot.com/144049

If it is a flag, two-sided seems more appropriate.

--
David Kastrup



_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: New twoside mode.

by Michael Käppler-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> http://codereview.appspot.com/144049/diff/1/2#newcode15
> Line 15: binding-offset = 5 \mm
> I think this deserves a separate test, otherwise it just looks the same
> as an ordinary page with slightly bigger but equal margins.
Ok...
>
> http://codereview.appspot.com/144049/diff/1/3
> File lily/output-def.cc (right):
>
> http://codereview.appspot.com/144049/diff/1/3#newcode173
> Line 173: - left_margin_default
> You'll have to add parentheses if you want to keep this indentation.
I don't know why I changed the old indentation...
But why doesn't this work? It at least compiles fine... ;)
> http://codereview.appspot.com/144049/diff/1/4
> File ly/paper-defaults-init.ly (right):
>
> http://codereview.appspot.com/144049/diff/1/4#newcode90
> Line 90: twoside = ##f
> I'm not too fond of this name, but can't think of anything better. :)
LaTeX exactly uses this term, so I didn't much think about it.
Anyway, I followed your suggestions.

> http://codereview.appspot.com/144049/diff/1/5
> File scm/page.scm (right):
>
> http://codereview.appspot.com/144049/diff/1/5#newcode320
> Line 320: (ly:stencil-translate page-stencil (cons (prop 'right-margin)
> 0))))
> You could simplify this a bit:
>
> (if (ly:output-def-lookup layout 'twoside #f)
>     (set! page-stencil
>      (ly:stencil-translate page-stencil
>       (cons (prop (if (even? number)
>                       'left-margin
>                       'right-margin))
>             0)))
Done.
> http://codereview.appspot.com/144049/diff/1/6
> File scm/paper.scm (right):
>
> http://codereview.appspot.com/144049/diff/1/6#newcode242
> Line 242: (("foot-separation" . ,h) - '())
> oops ;)
Argh... fixed.

Regards,
Michael


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: New twoside mode.

by Neil Puttock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/10/31 Michael Käppler <xmichael-k@...>:

> I don't know why I changed the old indentation...
> But why doesn't this work? It at least compiles fine... ;)

If somebody auto-indents the file, your indentation will be lost
without the extra parentheses.

Regards,
Neil


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Parent Message unknown Re: New twoside mode.

by Neil Puttock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Michael,

This looks OK, apart from a few indentation issues.  In particular, the
whole of `set-paper-dimensions' is slightly off.

Cheers,
Neil




http://codereview.appspot.com/144049/diff/23/1010
File scm/page.scm (right):

http://codereview.appspot.com/144049/diff/23/1010#newcode316
Line 316: (set! page-stencil
indentation

http://codereview.appspot.com/144049/diff/23/1011
File scm/paper.scm (right):

http://codereview.appspot.com/144049/diff/23/1011#newcode236
Line 236: (("inner-margin" . ,w) . preserve)
hard tabs (inconsistent with rest of indentation)

http://codereview.appspot.com/144049


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: New twoside mode.

by Michael Käppler-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

n.puttock@... wrote:
> Hi Michael,
>
> This looks OK, apart from a few indentation issues.  In particular, the
> whole of `set-paper-dimensions' is slightly off.
>
> Cheers,
> Neil
Hi Neil,
I'm slightly unsure what to do now. Since I'm a little bit tired of this
indentation stuff I gave emacs a try (though I'm normally a VIM user ;))
and ran the script mentioned in CG 8.5.4. There are changes also in
parts of the code which I didn't modify, e.g. it is shifting comments to
the right. Does it make sense to use this emacs script, if yes, what do
I have to keep in mind when using it?

Regards,
Michael




_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: New twoside mode.

by Neil Puttock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/11/4 Michael Käppler <xmichael-k@...>:

> I'm slightly unsure what to do now. Since I'm a little bit tired of this
> indentation stuff I gave emacs a try (though I'm normally a VIM user ;))

Heh, I only use emacs because the barrier to entry is lower. :)

> and ran the script mentioned in CG 8.5.4. There are changes also in parts of
> the code which I didn't modify, e.g. it is shifting comments to the right.

Those comments should have double semicolons, according to Scheme style.

> Does it make sense to use this emacs script, if yes, what do I have to keep
> in mind when using it?

If you're using Vim, you should be fine (though I read somewhere that
it occasionally indents Lisp and Scheme incorrectly).

Regards,
Neil


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: New twoside mode.

by Michael Käppler-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> Those comments should have double semicolons, according to Scheme style.
>  
Ah...
>> Does it make sense to use this emacs script, if yes, what do I have to keep
>> in mind when using it?
>>    
>
> If you're using Vim, you should be fine (though I read somewhere that
> it occasionally indents Lisp and Scheme incorrectly).
>  
Hmm, i've never used vim indenting. What I meant was: "May I simply run
the emacs auto-indenting on any file I've put new code in?"
Please have a look if it's okay now.

Cheers,
Michael

From 5c4fd6a9017584b64884260490d52e87a0c4afec Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Michael=20K=C3=A4ppler?= <xmichael-k@...>
Date: Thu, 29 Oct 2009 11:38:45 +0100
Subject: [PATCH] New twoside mode.

  * This patch allows to specify different margins for odd and even
    pages by setting twoside to true in the \paper block
  * The corresponding settings are inner- and outer-margin, there
    exists the possibility to set a binding-offset, too
  * These values are stored internally as left- and right-margin,
    though. Translation is done in page.scm:make-page-stencil
  * Small code cleanup in paper.scm:set-paper-dimensions
---
 input/regression/paper-twosided-bcorr.ly |   20 +++++
 input/regression/paper-twosided.ly       |   19 +++++
 lily/output-def.cc                       |   29 ++++++--
 ly/paper-defaults-init.ly                |    5 ++
 scm/page.scm                             |   67 ++++++++++--------
 scm/paper.scm                            |  115 +++++++++++++++--------------
 6 files changed, 163 insertions(+), 92 deletions(-)
 create mode 100644 input/regression/paper-twosided-bcorr.ly
 create mode 100644 input/regression/paper-twosided.ly

diff --git a/input/regression/paper-twosided-bcorr.ly b/input/regression/paper-twosided-bcorr.ly
new file mode 100644
index 0000000..916070f
--- /dev/null
+++ b/input/regression/paper-twosided-bcorr.ly
@@ -0,0 +1,20 @@
+\version "2.13.7"
+
+\header {
+  texidoc = "In two-sided mode, a binding offset can be specified, which is added
+to the inner margin automatically."
+}
+
+someNotes = \relative c' { \repeat unfold 200 { c4 d e f } }
+
+\paper {
+  two-sided = ##t
+  inner-margin = 10 \mm
+  outer-margin = 20 \mm
+  binding-offset = 5 \mm
+}
+
+\book {
+  \score { \someNotes }
+}
+
diff --git a/input/regression/paper-twosided.ly b/input/regression/paper-twosided.ly
new file mode 100644
index 0000000..a89eef7
--- /dev/null
+++ b/input/regression/paper-twosided.ly
@@ -0,0 +1,19 @@
+\version "2.13.7"
+
+\header {
+  texidoc = "Two-sided mode allows you to use different margins for
+odd and even pages."
+}
+
+someNotes = \relative c' { \repeat unfold 200 { c4 d e f } }
+
+\paper {
+  two-sided = ##t
+  inner-margin = 10 \mm
+  outer-margin = 20 \mm
+}
+
+\book {
+  \score { \someNotes }
+}
+
diff --git a/lily/output-def.cc b/lily/output-def.cc
index 3461e3c..8849bc2 100644
--- a/lily/output-def.cc
+++ b/lily/output-def.cc
@@ -135,13 +135,24 @@ Output_def::normalize ()
   Real paper_width;
   SCM scm_paper_width = c_variable ("paper-width");
 
+  bool twosided = to_boolean (c_variable ("two-sided"));
+  // We don't distinguish between outer-margin / left-margin and so on
+  // until page-stencil positioning in page.scm
   Real left_margin, left_margin_default;
-  SCM scm_left_margin_default = c_variable ("left-margin-default-scaled");
-  SCM scm_left_margin = c_variable ("left-margin");
+  SCM scm_left_margin_default = (twosided
+                                 ? c_variable ("outer-margin-default-scaled")
+ : c_variable ("left-margin-default-scaled"));
+  SCM scm_left_margin = (twosided
+                         ? c_variable ("outer-margin")
+ : c_variable ("left-margin"));
 
   Real right_margin, right_margin_default;
-  SCM scm_right_margin_default = c_variable ("right-margin-default-scaled");
-  SCM scm_right_margin = c_variable ("right-margin");
+  SCM scm_right_margin_default = (twosided
+                                  ? c_variable ("inner-margin-default-scaled")
+  : c_variable ("right-margin-default-scaled"));
+  SCM scm_right_margin = (twosided
+                          ? c_variable ("inner-margin")
+  : c_variable ("right-margin"));
 
   if (scm_paper_width == SCM_UNDEFINED
       || scm_left_margin_default == SCM_UNDEFINED
@@ -162,6 +173,10 @@ Output_def::normalize ()
     = paper_width - left_margin_default - right_margin_default;
   SCM scm_line_width = c_variable ("line-width");
 
+  Real binding_offset = 0;
+  if (twosided)
+    binding_offset = robust_scm2double (c_variable ("binding-offset"), 0);
+
   if (scm_line_width == SCM_UNDEFINED)
     {
       left_margin = ((scm_left_margin == SCM_UNDEFINED)
@@ -169,7 +184,7 @@ Output_def::normalize ()
      : scm_to_double (scm_left_margin));
       right_margin = ((scm_right_margin == SCM_UNDEFINED)
       ? right_margin_default
-      : scm_to_double (scm_right_margin));
+      : scm_to_double (scm_right_margin)) + binding_offset;
       line_width = paper_width - left_margin - right_margin;
     }
   else
@@ -185,7 +200,7 @@ Output_def::normalize ()
             }
           else
             {
-              right_margin = scm_to_double (scm_right_margin);
+              right_margin = scm_to_double (scm_right_margin) + binding_offset;
               left_margin = paper_width - line_width - right_margin;
             }
         }
@@ -194,7 +209,7 @@ Output_def::normalize ()
           left_margin = scm_to_double (scm_left_margin);
           right_margin = ((scm_right_margin == SCM_UNDEFINED)
                            ? (paper_width - line_width - left_margin)
-                           : scm_to_double (scm_right_margin));
+                           : scm_to_double (scm_right_margin)) + binding_offset;
         }
     }
 
diff --git a/ly/paper-defaults-init.ly b/ly/paper-defaults-init.ly
index 8be089f..8089b3b 100644
--- a/ly/paper-defaults-init.ly
+++ b/ly/paper-defaults-init.ly
@@ -87,6 +87,7 @@
   \include "titling-init.ly"
 
   check-consistency = ##t
+  two-sided = ##f
 
   % These margins apply to the default paper format given by (ly:get-option 'paper-size)
   % and are scaled accordingly for other formats
@@ -97,6 +98,10 @@
   left-margin-default = 10 \mm
   right-margin-default = 10 \mm
 
+  inner-margin-default = 10 \mm
+  outer-margin-default = 20 \mm
+  binding-offset-default = 0 \mm
+
   head-separation-default = 4 \mm
   foot-separation-default = 4 \mm
 
diff --git a/scm/page.scm b/scm/page.scm
index 959402c..3c81b7b 100644
--- a/scm/page.scm
+++ b/scm/page.scm
@@ -15,7 +15,7 @@
     page-printable-height
     layout->page-init
     page-lines
-    page-force
+    page-force
     page-penalty
     page-configuration
     page-lines
@@ -23,7 +23,7 @@
     page-system-numbers
     page-stencil
     page-free-height
-    page?
+    page?
     ))
 
 (use-modules (lily)
@@ -46,9 +46,9 @@
 
     (page-set-property! p 'head-stencil (page-header p))
     (page-set-property! p 'foot-stencil (page-footer p))
-    
+
     p))
-
+
 (define page-property ly:prob-property)
 (define page-set-property! ly:prob-set-property!)
 (define (page-property? page sym)
@@ -56,7 +56,7 @@
 (define (page? x)  (ly:prob-type? x 'page))
 
 
-;; define accessors.
+;; define accessors.
 (for-each
  (lambda (j)
    (module-define!
@@ -64,7 +64,7 @@
     (string->symbol (format "page-~a" j))
     (lambda (pg)
       (page-property pg j))))
-
+
  '(page-number prev lines force penalty lines))
 
 (define (page-system-numbers page)
@@ -81,7 +81,7 @@
 
        (if (not (number? (ly:prob-property sys 'Y-offset)))
    (ly:prob-set-property! sys 'Y-offset off))))
-  
+
    (zip (page-property page 'lines)
  (page-property page 'configuration))))
 
@@ -115,19 +115,19 @@
      (ly:stencil-add stencil
      (ly:stencil-translate-axis y 6 X))))))
     (add-stencil
-     (ly:stencil-translate-axis
+     (ly:stencil-translate-axis
       (annotate-y-interval layout "paper-height"
    (cons (- paper-height) 0)
    #t)
       1 X))
     (add-stencil
-     (ly:stencil-translate-axis
+     (ly:stencil-translate-axis
       (annotate-y-interval layout "top-margin"
    (cons (- top-margin) 0)
    #t)
       2 X))
     (add-stencil
-     (ly:stencil-translate-axis
+     (ly:stencil-translate-axis
       (annotate-y-interval layout "bottom-margin"
    (cons (- paper-height) (- bottom-margin paper-height))
    #t)
@@ -156,7 +156,7 @@
 
 
 (define (page-header-or-footer page dir)
-    (let*
+  (let*
       ((paper-book (page-property page 'paper-book))
        (layout (ly:paper-book-paper paper-book))
        (scopes (ly:paper-book-scopes paper-book))
@@ -168,9 +168,9 @@
  'make-footer))
        (header-proc (ly:output-def-lookup layout sym)))
 
-      (if (procedure? header-proc)
-  (header-proc layout scopes number is-last-bookpart is-bookpart-last-page)
-  #f)))
+    (if (procedure? header-proc)
+ (header-proc layout scopes number is-last-bookpart is-bookpart-last-page)
+ #f)))
 
 
 (define (page-header page)
@@ -185,21 +185,23 @@
       ((paper-height (ly:output-def-lookup layout 'paper-height))
        (paper-width (ly:output-def-lookup layout 'paper-width))
        (left-margin (ly:output-def-lookup layout 'left-margin))
+       (right-margin (ly:output-def-lookup layout 'right-margin))
        (bottom-edge (- paper-height
        (ly:output-def-lookup layout 'bottom-margin)) )
        (top-margin (ly:output-def-lookup layout 'top-margin))
        )
-    
+
     `((paper-height . ,paper-height)
       (paper-width . ,paper-width)
       (left-margin . ,left-margin)
+      (right-margin . ,right-margin)
       (top-margin . ,top-margin)
       (bottom-edge . ,bottom-edge)
       )))
 
 (define (make-page-stencil page)
   "Construct a stencil representing the page from PAGE."
-  
+
 
   (page-translate-systems page)
   (let*
@@ -211,7 +213,7 @@
        (number (page-page-number page))
 
        ;; TODO: naming paper-height/paper-width not analogous to TeX.
-      
+
        (system-xoffset (ly:output-def-lookup layout 'horizontal-shift 0.0))
        (system-separator-markup (ly:output-def-lookup layout 'system-separator-markup))
        (system-separator-stencil (if (markup? system-separator-markup)
@@ -219,7 +221,7 @@
        (layout-extract-page-properties layout)
        system-separator-markup)
      #f))
-      
+
        (page-stencil (ly:make-stencil '()))
 
        (last-system #f)
@@ -231,7 +233,7 @@
   (cons
    (+ system-xoffset x)
    (- 0 y (prop 'top-margin)))
-  
+
   )))))
        (add-system
  (lambda (system)
@@ -298,7 +300,7 @@
  (set! page-stencil
       (ly:stencil-add page-stencil
       (annotate-space-left page))))
-    
+
     (if (and (ly:stencil? foot)
      (not (ly:stencil-empty? foot)))
  (set! page-stencil
@@ -310,22 +312,29 @@
       (+ (- (prop 'bottom-edge))
  (- (car (ly:stencil-extent foot Y)))))))))
 
-    (set! page-stencil
-  (ly:stencil-translate page-stencil (cons (prop 'left-margin) 0)))
+    (if (ly:output-def-lookup layout 'two-sided #f)
+ (set! page-stencil
+      (ly:stencil-translate page-stencil
+    (cons (prop (if (even? number)
+    'left-margin
+    'right-margin))
+  0)))
+ (set! page-stencil
+      (ly:stencil-translate page-stencil (cons (prop 'left-margin) 0))))
 
     ;; annotation.
     (if (annotate? layout)
  (set! page-stencil (annotate-page layout page-stencil)))
 
     page-stencil))
-              
+
 
 (define-public (page-stencil page)
   (if (not (ly:stencil? (page-property page 'stencil)))
 
       ;; todo: make tweakable.
       ;; via property + callbacks.
-      
+
       (page-set-property! page 'stencil (make-page-stencil page)))
   (page-property page 'stencil))
 
@@ -335,9 +344,9 @@
       ((paper-book (page-property page 'paper-book))
        (layout (ly:paper-book-paper paper-book))
        (h (- (ly:output-def-lookup layout 'paper-height)
-       (ly:output-def-lookup layout 'top-margin)
-       (ly:output-def-lookup layout 'bottom-margin)))
-      
+     (ly:output-def-lookup layout 'top-margin)
+     (ly:output-def-lookup layout 'bottom-margin)))
+
        (head (page-property page 'head-stencil))
        (foot (page-property page 'foot-stencil))
        (available
@@ -347,13 +356,13 @@
    (if (ly:stencil? foot)
        (interval-length (ly:stencil-extent foot Y))
        0))))
-    
+
     ;; (display (list "\n available" available head foot))
     available))
 
 (define (page-printable-height page)
   (if (not (number? (page-property page 'printable-height)))
       (page-set-property! page 'printable-height (calc-printable-height page)))
-  
+
   (page-property page 'printable-height))
 
diff --git a/scm/paper.scm b/scm/paper.scm
index 0b5a60e..bb529c6 100644
--- a/scm/paper.scm
+++ b/scm/paper.scm
@@ -14,12 +14,16 @@
     horizontal-shift
     in
     indent
+    inner-margin
+    inner-margin-default-scaled
     ledger-line-thickness
     left-margin
                     left-margin-default-scaled
     line-thickness
     line-width
     mm
+    outer-margin
+    outer-margin-default-scaled
     paper-height
     paper-width
     pt
@@ -35,15 +39,15 @@
 
   ;; !! synchronize with feta-params.mf
   (let*
-    ((x1 (* 4.125 pt))
-     (x0 (* 5 pt))
-     (f1 (* 0.47 pt))
-     (f0 (* 0.50 pt)))
+      ((x1 (* 4.125 pt))
+       (x0 (* 5 pt))
+       (f1 (* 0.47 pt))
+       (f0 (* 0.50 pt)))
 
     (/
      (+
       (* f1 (- staff-space x0))
-   (* f0 (- x1 staff-space)))
+      (* f0 (- x1 staff-space)))
      (- x1 x0))))
 
 (define-public (layout-set-absolute-staff-size-in-module module staff-height)
@@ -89,9 +93,9 @@ size. SZ is in points"
  (in-layout? (or (module-defined? current-mod 'is-paper)
  (module-defined? current-mod 'is-layout)))
 
- ; maybe not necessary.
- ; but let's be paranoid. Maybe someone still refers to the
- ; old one.
+ ;; maybe not necessary.
+ ;; but let's be paranoid. Maybe someone still refers to the
+ ;; old one.
  (new-paper (ly:output-def-clone pap))
 
  (new-scope (ly:output-def-scope new-paper)))
@@ -207,68 +211,67 @@ size. SZ is in points"
     ("pa10" . (cons (* 26 mm) (* 35 mm)))
     ;; F4 used in southeast Asia and Australia
     ("f4" . (cons (* 210 mm) (* 330 mm)))
-   ))
+    ))
 
-; todo: take dimension arguments.
+;; todo: take dimension arguments.
 
 (define (set-paper-dimensions m w h)
   "M is a module (i.e. layout->scope_ )"
   (let*
-    ;; page layout - what to do with (printer specific!) margin settings?
-    ((paper-default (eval-carefully
-                      (assoc-get
+      ;; page layout - what to do with (printer specific!) margin settings?
+      ((paper-default (eval-carefully
+       (assoc-get
         (ly:get-option 'paper-size)
  paper-alist
  #f
  #t)
-      m
-      (cons w h)))
-     (scaleable-values `(("left-margin" . ,w)
-                         ("right-margin" . ,w)
-                         ("top-margin" . ,h)
-                         ("bottom-margin" . ,h)
-                         ("head-separation" . ,h)
-                         ("foot-separation" . ,h)
-                         ("indent" . ,w)
-                         ("short-indent" . ,w)))
-     (scaled-values
-       (map
+       m
+       (cons w h)))
+       ;; Horizontal margins, marked with 'preserve, are stored
+       ;; in renamed variables because they must not be overwritten.
+       ;; Output_def::normalize () needs to know
+       ;; whether the user set the value or not.
+       (scaleable-values `((("left-margin" . ,w) . preserve)
+   (("right-margin" . ,w) . preserve)
+   (("inner-margin" . ,w) . preserve)
+   (("outer-margin" . ,w) . preserve)
+   (("binding-offset" . ,w) . '())
+   (("top-margin" . ,h) . '())
+   (("bottom-margin" . ,h) . '())
+   (("head-separation" . ,h) . '())
+   (("foot-separation" . ,h) . '())
+   (("indent" . ,w) . '())
+   (("short-indent" . ,w) . '())))
+       (scaled-values
+ (map
          (lambda (entry)
            (let ((entry-symbol
-           (string->symbol
-                     (string-append (car entry) "-default")))
- (orientation (cdr entry)))
-      (if paper-default
-  (cons (car entry)
-        (round (* orientation
-  (/ (eval-carefully entry-symbol m 0)
-     (if (= orientation w)
-         (car paper-default)
-         (cdr paper-default))))))
-  entry)))
+  (string->symbol
+   (string-append (caar entry) "-default")))
+ (orientation (cdar entry)))
+     (if paper-default
+ (cons (if (eq? (cdr entry) 'preserve)
+   (string-append (caar entry) "-default-scaled")
+   (caar entry))
+       (round (* orientation
+ (/ (eval-carefully entry-symbol m 0)
+    (if (= orientation w)
+ (car paper-default)
+ (cdr paper-default))))))
+ entry)))
  scaleable-values)))
 
-  (module-define! m 'paper-width w)
-  (module-define! m 'paper-height h)
-  ;; Left and right margin are stored in renamed variables because
-  ;; they must not be overwritten.
-  ;; Output_def::normalize () needs to know
-  ;; whether the user set the value or not.
-  (module-define! m 'left-margin-default-scaled
-    (assoc-get "left-margin" scaled-values 0 #t))
-  (module-define! m 'right-margin-default-scaled
-    (assoc-get "right-margin" scaled-values 0 #t))
-  ;; Sometimes, lilypond-book doesn't estimate a correct line-width.
-  ;; Therefore, we need to unset line-width.
-  (module-remove! m 'line-width)
-  (set! scaled-values (assoc-remove!
-                        (assoc-remove! scaled-values "left-margin")
- "right-margin"))
-  (for-each
+    (module-define! m 'paper-width w)
+    (module-define! m 'paper-height h)
+    ;; Sometimes, lilypond-book doesn't estimate a correct line-width.
+    ;; Therefore, we need to unset line-width.
+    (module-remove! m 'line-width)
+
+    (for-each
      (lambda (value)
-        (let ((value-symbol (string->symbol (car value)))
-              (number (cdr value)))
-          (module-define! m value-symbol number)))
+       (let ((value-symbol (string->symbol (car value)))
+     (number (cdr value)))
+ (module-define! m value-symbol number)))
      scaled-values)))
 
 (define (internal-set-paper-size module name landscape?)
--
1.6.0.2


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: New twoside mode.

by Neil Puttock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/11/4 Michael Käppler <xmichael-k@...>:

> Hmm, i've never used vim indenting. What I meant was: "May I simply run the
> emacs auto-indenting on any file I've put new code in?"

If you don't mind doing this, then go for it. :)

> Please have a look if it's okay now.

Almost there; there are a few places in output-def.cc which switch
between spaces and hard tabs:

+  SCM scm_left_margin_default = (twosided
+                                 ? c_variable ("outer-margin-default-scaled")

spaces

+ : c_variable ("left-margin-default-scaled"));

hard tabs

Regards,
Neil


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: New twoside mode.

by Patrick McCarty-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 2009-11-04, Neil Puttock wrote:
> 2009/11/4 Michael Käppler <xmichael-k@...>:
>
> > Does it make sense to use this emacs script, if yes, what do I
> > have to keep in mind when using it?
>
> If you're using Vim, you should be fine (though I read somewhere that
> it occasionally indents Lisp and Scheme incorrectly).

The rumors are true.  :-)

To make my life easier, I use the attached (incomplete) configuration
file, which is located in ~/.vim/after/syntax/scheme.vim on my
machine.

-Patrick

" Additional Guile-specific 'forms'
syn keyword schemeSyntax define-public define* define-safe-public
syn keyword schemeSyntax use-modules define-module
syn keyword schemeSyntax defmacro-public define-macro
syn keyword schemeSyntax define-builtin-markup-command
syn keyword schemeSyntax define-markup-command
syn keyword schemeSyntax define-builtin-markup-list-command
syn keyword schemeSyntax let-keywords* lambda* define*-public
syn keyword schemeSyntax defmacro* defmacro*-public

" All of the above should influence indenting too
set lw+=define-public,define*,define-safe-public,use-modules,define-module
set lw+=defmacro-public,define-macro,define-builtin-markup-command
set lw+=define-markup-command,define-builtin-markup-list-command
set lw+=let-keywords*,lambda*,define*-public,defmacro*,defmacro*-public

" These forms should not influence indenting
set lw-=if
set lw-=set!

" Try to highlight all ly: procedures
syn match schemeFunc "ly:[^) ]\+"

_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: New twoside mode.

by Michael Käppler-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> Almost there; there are a few places in output-def.cc which switch
> between spaces and hard tabs:
>
> +  SCM scm_left_margin_default = (twosided
> +                                 ? c_variable ("outer-margin-default-scaled")
>
> spaces
>
> + : c_variable ("left-margin-default-scaled"));
>
> hard tabs
>  
I've removed the hard tabs now. I remember the discussion some time ago
on -devel "spaces vs. tabs" which I was confused about.
I don't think there was a clear result: so am I allowed to never use
hard tabs but spaces in the future?

Slightly off-topic: what about the doc patch I've posted a while ago in
a corrected revision?

Regards,
Michael

From 1e182cc1727239e1dac05be771356d1085a66bd6 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Michael=20K=C3=A4ppler?= <xmichael-k@...>
Date: Thu, 29 Oct 2009 11:38:45 +0100
Subject: [PATCH] New twoside mode.

  * This patch allows to specify different margins for odd and even
    pages by setting twoside to true in the \paper block
  * The corresponding settings are inner- and outer-margin, there
    exists the possibility to set a binding-offset, too
  * These values are stored internally as left- and right-margin,
    though. Translation is done in page.scm:make-page-stencil
  * Small code cleanup in paper.scm:set-paper-dimensions
---
 input/regression/paper-twosided-bcorr.ly |   20 +++++
 input/regression/paper-twosided.ly       |   19 +++++
 lily/output-def.cc                       |   39 +++++++---
 ly/paper-defaults-init.ly                |    5 ++
 scm/page.scm                             |   67 ++++++++++--------
 scm/paper.scm                            |  115 +++++++++++++++--------------
 6 files changed, 168 insertions(+), 97 deletions(-)
 create mode 100644 input/regression/paper-twosided-bcorr.ly
 create mode 100644 input/regression/paper-twosided.ly

diff --git a/input/regression/paper-twosided-bcorr.ly b/input/regression/paper-twosided-bcorr.ly
new file mode 100644
index 0000000..916070f
--- /dev/null
+++ b/input/regression/paper-twosided-bcorr.ly
@@ -0,0 +1,20 @@
+\version "2.13.7"
+
+\header {
+  texidoc = "In two-sided mode, a binding offset can be specified, which is added
+to the inner margin automatically."
+}
+
+someNotes = \relative c' { \repeat unfold 200 { c4 d e f } }
+
+\paper {
+  two-sided = ##t
+  inner-margin = 10 \mm
+  outer-margin = 20 \mm
+  binding-offset = 5 \mm
+}
+
+\book {
+  \score { \someNotes }
+}
+
diff --git a/input/regression/paper-twosided.ly b/input/regression/paper-twosided.ly
new file mode 100644
index 0000000..a89eef7
--- /dev/null
+++ b/input/regression/paper-twosided.ly
@@ -0,0 +1,19 @@
+\version "2.13.7"
+
+\header {
+  texidoc = "Two-sided mode allows you to use different margins for
+odd and even pages."
+}
+
+someNotes = \relative c' { \repeat unfold 200 { c4 d e f } }
+
+\paper {
+  two-sided = ##t
+  inner-margin = 10 \mm
+  outer-margin = 20 \mm
+}
+
+\book {
+  \score { \someNotes }
+}
+
diff --git a/lily/output-def.cc b/lily/output-def.cc
index 3461e3c..0e29b23 100644
--- a/lily/output-def.cc
+++ b/lily/output-def.cc
@@ -135,13 +135,24 @@ Output_def::normalize ()
   Real paper_width;
   SCM scm_paper_width = c_variable ("paper-width");
 
+  bool twosided = to_boolean (c_variable ("two-sided"));
+  // We don't distinguish between outer-margin / left-margin and so on
+  // until page-stencil positioning in page.scm
   Real left_margin, left_margin_default;
-  SCM scm_left_margin_default = c_variable ("left-margin-default-scaled");
-  SCM scm_left_margin = c_variable ("left-margin");
+  SCM scm_left_margin_default = (twosided
+                                 ? c_variable ("outer-margin-default-scaled")
+                                 : c_variable ("left-margin-default-scaled"));
+  SCM scm_left_margin = (twosided
+                         ? c_variable ("outer-margin")
+                         : c_variable ("left-margin"));
 
   Real right_margin, right_margin_default;
-  SCM scm_right_margin_default = c_variable ("right-margin-default-scaled");
-  SCM scm_right_margin = c_variable ("right-margin");
+  SCM scm_right_margin_default = (twosided
+                                  ? c_variable ("inner-margin-default-scaled")
+                                  : c_variable ("right-margin-default-scaled"));
+  SCM scm_right_margin = (twosided
+                          ? c_variable ("inner-margin")
+                          : c_variable ("right-margin"));
 
   if (scm_paper_width == SCM_UNDEFINED
       || scm_left_margin_default == SCM_UNDEFINED
@@ -162,14 +173,18 @@ Output_def::normalize ()
     = paper_width - left_margin_default - right_margin_default;
   SCM scm_line_width = c_variable ("line-width");
 
+  Real binding_offset = 0;
+  if (twosided)
+    binding_offset = robust_scm2double (c_variable ("binding-offset"), 0);
+
   if (scm_line_width == SCM_UNDEFINED)
     {
       left_margin = ((scm_left_margin == SCM_UNDEFINED)
-     ? left_margin_default
-     : scm_to_double (scm_left_margin));
+                     ? left_margin_default
+                     : scm_to_double (scm_left_margin));
       right_margin = ((scm_right_margin == SCM_UNDEFINED)
-      ? right_margin_default
-      : scm_to_double (scm_right_margin));
+                      ? right_margin_default
+                      : scm_to_double (scm_right_margin)) + binding_offset;
       line_width = paper_width - left_margin - right_margin;
     }
   else
@@ -177,15 +192,15 @@ Output_def::normalize ()
       line_width = scm_to_double (scm_line_width);
       if (scm_left_margin == SCM_UNDEFINED)
         {
-  // Vertically center systems if only line-width is given
-  if (scm_right_margin == SCM_UNDEFINED)
+          // Vertically center systems if only line-width is given
+          if (scm_right_margin == SCM_UNDEFINED)
             {
               left_margin = (paper_width - line_width) / 2;
               right_margin = left_margin;
             }
           else
             {
-              right_margin = scm_to_double (scm_right_margin);
+              right_margin = scm_to_double (scm_right_margin) + binding_offset;
               left_margin = paper_width - line_width - right_margin;
             }
         }
@@ -194,7 +209,7 @@ Output_def::normalize ()
           left_margin = scm_to_double (scm_left_margin);
           right_margin = ((scm_right_margin == SCM_UNDEFINED)
                            ? (paper_width - line_width - left_margin)
-                           : scm_to_double (scm_right_margin));
+                           : scm_to_double (scm_right_margin)) + binding_offset;
         }
     }
 
diff --git a/ly/paper-defaults-init.ly b/ly/paper-defaults-init.ly
index 8be089f..8089b3b 100644
--- a/ly/paper-defaults-init.ly
+++ b/ly/paper-defaults-init.ly
@@ -87,6 +87,7 @@
   \include "titling-init.ly"
 
   check-consistency = ##t
+  two-sided = ##f
 
   % These margins apply to the default paper format given by (ly:get-option 'paper-size)
   % and are scaled accordingly for other formats
@@ -97,6 +98,10 @@
   left-margin-default = 10 \mm
   right-margin-default = 10 \mm
 
+  inner-margin-default = 10 \mm
+  outer-margin-default = 20 \mm
+  binding-offset-default = 0 \mm
+
   head-separation-default = 4 \mm
   foot-separation-default = 4 \mm
 
diff --git a/scm/page.scm b/scm/page.scm
index 959402c..3c81b7b 100644
--- a/scm/page.scm
+++ b/scm/page.scm
@@ -15,7 +15,7 @@
     page-printable-height
     layout->page-init
     page-lines
-    page-force
+    page-force
     page-penalty
     page-configuration
     page-lines
@@ -23,7 +23,7 @@
     page-system-numbers
     page-stencil
     page-free-height
-    page?
+    page?
     ))
 
 (use-modules (lily)
@@ -46,9 +46,9 @@
 
     (page-set-property! p 'head-stencil (page-header p))
     (page-set-property! p 'foot-stencil (page-footer p))
-    
+
     p))
-
+
 (define page-property ly:prob-property)
 (define page-set-property! ly:prob-set-property!)
 (define (page-property? page sym)
@@ -56,7 +56,7 @@
 (define (page? x)  (ly:prob-type? x 'page))
 
 
-;; define accessors.
+;; define accessors.
 (for-each
  (lambda (j)
    (module-define!
@@ -64,7 +64,7 @@
     (string->symbol (format "page-~a" j))
     (lambda (pg)
       (page-property pg j))))
-
+
  '(page-number prev lines force penalty lines))
 
 (define (page-system-numbers page)
@@ -81,7 +81,7 @@
 
        (if (not (number? (ly:prob-property sys 'Y-offset)))
    (ly:prob-set-property! sys 'Y-offset off))))
-  
+
    (zip (page-property page 'lines)
  (page-property page 'configuration))))
 
@@ -115,19 +115,19 @@
      (ly:stencil-add stencil
      (ly:stencil-translate-axis y 6 X))))))
     (add-stencil
-     (ly:stencil-translate-axis
+     (ly:stencil-translate-axis
       (annotate-y-interval layout "paper-height"
    (cons (- paper-height) 0)
    #t)
       1 X))
     (add-stencil
-     (ly:stencil-translate-axis
+     (ly:stencil-translate-axis
       (annotate-y-interval layout "top-margin"
    (cons (- top-margin) 0)
    #t)
       2 X))
     (add-stencil
-     (ly:stencil-translate-axis
+     (ly:stencil-translate-axis
       (annotate-y-interval layout "bottom-margin"
    (cons (- paper-height) (- bottom-margin paper-height))
    #t)
@@ -156,7 +156,7 @@
 
 
 (define (page-header-or-footer page dir)
-    (let*
+  (let*
       ((paper-book (page-property page 'paper-book))
        (layout (ly:paper-book-paper paper-book))
        (scopes (ly:paper-book-scopes paper-book))
@@ -168,9 +168,9 @@
  'make-footer))
        (header-proc (ly:output-def-lookup layout sym)))
 
-      (if (procedure? header-proc)
-  (header-proc layout scopes number is-last-bookpart is-bookpart-last-page)
-  #f)))
+    (if (procedure? header-proc)
+ (header-proc layout scopes number is-last-bookpart is-bookpart-last-page)
+ #f)))
 
 
 (define (page-header page)
@@ -185,21 +185,23 @@
       ((paper-height (ly:output-def-lookup layout 'paper-height))
        (paper-width (ly:output-def-lookup layout 'paper-width))
        (left-margin (ly:output-def-lookup layout 'left-margin))
+       (right-margin (ly:output-def-lookup layout 'right-margin))
        (bottom-edge (- paper-height
        (ly:output-def-lookup layout 'bottom-margin)) )
        (top-margin (ly:output-def-lookup layout 'top-margin))
        )
-    
+
     `((paper-height . ,paper-height)
       (paper-width . ,paper-width)
       (left-margin . ,left-margin)
+      (right-margin . ,right-margin)
       (top-margin . ,top-margin)
       (bottom-edge . ,bottom-edge)
       )))
 
 (define (make-page-stencil page)
   "Construct a stencil representing the page from PAGE."
-  
+
 
   (page-translate-systems page)
   (let*
@@ -211,7 +213,7 @@
        (number (page-page-number page))
 
        ;; TODO: naming paper-height/paper-width not analogous to TeX.
-      
+
        (system-xoffset (ly:output-def-lookup layout 'horizontal-shift 0.0))
        (system-separator-markup (ly:output-def-lookup layout 'system-separator-markup))
        (system-separator-stencil (if (markup? system-separator-markup)
@@ -219,7 +221,7 @@
        (layout-extract-page-properties layout)
        system-separator-markup)
      #f))
-      
+
        (page-stencil (ly:make-stencil '()))
 
        (last-system #f)
@@ -231,7 +233,7 @@
   (cons
    (+ system-xoffset x)
    (- 0 y (prop 'top-margin)))
-  
+
   )))))
        (add-system
  (lambda (system)
@@ -298,7 +300,7 @@
  (set! page-stencil
       (ly:stencil-add page-stencil
       (annotate-space-left page))))
-    
+
     (if (and (ly:stencil? foot)
      (not (ly:stencil-empty? foot)))
  (set! page-stencil
@@ -310,22 +312,29 @@
       (+ (- (prop 'bottom-edge))
  (- (car (ly:stencil-extent foot Y)))))))))
 
-    (set! page-stencil
-  (ly:stencil-translate page-stencil (cons (prop 'left-margin) 0)))
+    (if (ly:output-def-lookup layout 'two-sided #f)
+ (set! page-stencil
+      (ly:stencil-translate page-stencil
+    (cons (prop (if (even? number)
+    'left-margin
+    'right-margin))
+  0)))
+ (set! page-stencil
+      (ly:stencil-translate page-stencil (cons (prop 'left-margin) 0))))
 
     ;; annotation.
     (if (annotate? layout)
  (set! page-stencil (annotate-page layout page-stencil)))
 
     page-stencil))
-              
+
 
 (define-public (page-stencil page)
   (if (not (ly:stencil? (page-property page 'stencil)))
 
       ;; todo: make tweakable.
       ;; via property + callbacks.
-      
+
       (page-set-property! page 'stencil (make-page-stencil page)))
   (page-property page 'stencil))
 
@@ -335,9 +344,9 @@
       ((paper-book (page-property page 'paper-book))
        (layout (ly:paper-book-paper paper-book))
        (h (- (ly:output-def-lookup layout 'paper-height)
-       (ly:output-def-lookup layout 'top-margin)
-       (ly:output-def-lookup layout 'bottom-margin)))
-      
+     (ly:output-def-lookup layout 'top-margin)
+     (ly:output-def-lookup layout 'bottom-margin)))
+
        (head (page-property page 'head-stencil))
        (foot (page-property page 'foot-stencil))
        (available
@@ -347,13 +356,13 @@
    (if (ly:stencil? foot)
        (interval-length (ly:stencil-extent foot Y))
        0))))
-    
+
     ;; (display (list "\n available" available head foot))
     available))
 
 (define (page-printable-height page)
   (if (not (number? (page-property page 'printable-height)))
       (page-set-property! page 'printable-height (calc-printable-height page)))
-  
+
   (page-property page 'printable-height))
 
diff --git a/scm/paper.scm b/scm/paper.scm
index 0b5a60e..bb529c6 100644
--- a/scm/paper.scm
+++ b/scm/paper.scm
@@ -14,12 +14,16 @@
     horizontal-shift
     in
     indent
+    inner-margin
+    inner-margin-default-scaled
     ledger-line-thickness
     left-margin
                     left-margin-default-scaled
     line-thickness
     line-width
     mm
+    outer-margin
+    outer-margin-default-scaled
     paper-height
     paper-width
     pt
@@ -35,15 +39,15 @@
 
   ;; !! synchronize with feta-params.mf
   (let*
-    ((x1 (* 4.125 pt))
-     (x0 (* 5 pt))
-     (f1 (* 0.47 pt))
-     (f0 (* 0.50 pt)))
+      ((x1 (* 4.125 pt))
+       (x0 (* 5 pt))
+       (f1 (* 0.47 pt))
+       (f0 (* 0.50 pt)))
 
     (/
      (+
       (* f1 (- staff-space x0))
-   (* f0 (- x1 staff-space)))
+      (* f0 (- x1 staff-space)))
      (- x1 x0))))
 
 (define-public (layout-set-absolute-staff-size-in-module module staff-height)
@@ -89,9 +93,9 @@ size. SZ is in points"
  (in-layout? (or (module-defined? current-mod 'is-paper)
  (module-defined? current-mod 'is-layout)))
 
- ; maybe not necessary.
- ; but let's be paranoid. Maybe someone still refers to the
- ; old one.
+ ;; maybe not necessary.
+ ;; but let's be paranoid. Maybe someone still refers to the
+ ;; old one.
  (new-paper (ly:output-def-clone pap))
 
  (new-scope (ly:output-def-scope new-paper)))
@@ -207,68 +211,67 @@ size. SZ is in points"
     ("pa10" . (cons (* 26 mm) (* 35 mm)))
     ;; F4 used in southeast Asia and Australia
     ("f4" . (cons (* 210 mm) (* 330 mm)))
-   ))
+    ))
 
-; todo: take dimension arguments.
+;; todo: take dimension arguments.
 
 (define (set-paper-dimensions m w h)
   "M is a module (i.e. layout->scope_ )"
   (let*
-    ;; page layout - what to do with (printer specific!) margin settings?
-    ((paper-default (eval-carefully
-                      (assoc-get
+      ;; page layout - what to do with (printer specific!) margin settings?
+      ((paper-default (eval-carefully
+       (assoc-get
         (ly:get-option 'paper-size)
  paper-alist
  #f
  #t)
-      m
-      (cons w h)))
-     (scaleable-values `(("left-margin" . ,w)
-                         ("right-margin" . ,w)
-                         ("top-margin" . ,h)
-                         ("bottom-margin" . ,h)
-                         ("head-separation" . ,h)
-                         ("foot-separation" . ,h)
-                         ("indent" . ,w)
-                         ("short-indent" . ,w)))
-     (scaled-values
-       (map
+       m
+       (cons w h)))
+       ;; Horizontal margins, marked with 'preserve, are stored
+       ;; in renamed variables because they must not be overwritten.
+       ;; Output_def::normalize () needs to know
+       ;; whether the user set the value or not.
+       (scaleable-values `((("left-margin" . ,w) . preserve)
+   (("right-margin" . ,w) . preserve)
+   (("inner-margin" . ,w) . preserve)
+   (("outer-margin" . ,w) . preserve)
+   (("binding-offset" . ,w) . '())
+   (("top-margin" . ,h) . '())
+   (("bottom-margin" . ,h) . '())
+   (("head-separation" . ,h) . '())
+   (("foot-separation" . ,h) . '())
+   (("indent" . ,w) . '())
+   (("short-indent" . ,w) . '())))
+       (scaled-values
+ (map
          (lambda (entry)
            (let ((entry-symbol
-           (string->symbol
-                     (string-append (car entry) "-default")))
- (orientation (cdr entry)))
-      (if paper-default
-  (cons (car entry)
-        (round (* orientation
-  (/ (eval-carefully entry-symbol m 0)
-     (if (= orientation w)
-         (car paper-default)
-         (cdr paper-default))))))
-  entry)))
+  (string->symbol
+   (string-append (caar entry) "-default")))
+ (orientation (cdar entry)))
+     (if paper-default
+ (cons (if (eq? (cdr entry) 'preserve)
+   (string-append (caar entry) "-default-scaled")
+   (caar entry))
+       (round (* orientation
+ (/ (eval-carefully entry-symbol m 0)
+    (if (= orientation w)
+ (car paper-default)
+ (cdr paper-default))))))
+ entry)))
  scaleable-values)))
 
-  (module-define! m 'paper-width w)
-  (module-define! m 'paper-height h)
-  ;; Left and right margin are stored in renamed variables because
-  ;; they must not be overwritten.
-  ;; Output_def::normalize () needs to know
-  ;; whether the user set the value or not.
-  (module-define! m 'left-margin-default-scaled
-    (assoc-get "left-margin" scaled-values 0 #t))
-  (module-define! m 'right-margin-default-scaled
-    (assoc-get "right-margin" scaled-values 0 #t))
-  ;; Sometimes, lilypond-book doesn't estimate a correct line-width.
-  ;; Therefore, we need to unset line-width.
-  (module-remove! m 'line-width)
-  (set! scaled-values (assoc-remove!
-                        (assoc-remove! scaled-values "left-margin")
- "right-margin"))
-  (for-each
+    (module-define! m 'paper-width w)
+    (module-define! m 'paper-height h)
+    ;; Sometimes, lilypond-book doesn't estimate a correct line-width.
+    ;; Therefore, we need to unset line-width.
+    (module-remove! m 'line-width)
+
+    (for-each
      (lambda (value)
-        (let ((value-symbol (string->symbol (car value)))
-              (number (cdr value)))
-          (module-define! m value-symbol number)))
+       (let ((value-symbol (string->symbol (car value)))
+     (number (cdr value)))
+ (module-define! m value-symbol number)))
      scaled-values)))
 
 (define (internal-set-paper-size module name landscape?)
--
1.6.0.2


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: New twoside mode.

by Neil Puttock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/11/5 Michael Käppler <xmichael-k@...>:

> I've removed the hard tabs now. I remember the discussion some time ago on
> -devel "spaces vs. tabs" which I was confused about.
> I don't think there was a clear result: so am I allowed to never use hard
> tabs but spaces in the future?

I think hard tabs are fine, so long as they're used consistently.

The patch looks fine, so I've pushed it to master.

> Slightly off-topic: what about the doc patch I've posted a while ago in a
> corrected revision?

I'll take another look at it shortly.

Cheers,
Neil


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: New twoside mode.

by Neil Puttock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/11/5 Patrick McCarty <pnorcks@...>:

> The rumors are true.  :-)

Ha! I knew it; the superiority of emacs is confirmed. ;)

Actually, emacs also fails to indent properly in some situations;
there's a particularly annoying example in music-functions-init.ly,
where a parenthesis in a docstring breaks indentation for the rest of
the file.

Regards,
Neil


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

[PATCH] Re: New twoside mode.

by Michael Käppler-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Neil,
thanks for applying both patches. I've added some documentation for
two-sided, too...
Maybe you can have a look at it. It's just the most important things for
now, maybe it should be extended later.

Regards,
Michael

From 2a5251ed1dc077ca7d1d7b8a584c75ec0e7b6c3a Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Michael=20K=C3=A4ppler?= <xmichael-k@...>
Date: Fri, 6 Nov 2009 14:25:52 +0100
Subject: [PATCH] Docs: Add documentation for paper variables involved in two-sided mode.

---
 Documentation/notation/spacing.itely |   42 +++++++++++++++++++++++++++++-----
 1 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/Documentation/notation/spacing.itely b/Documentation/notation/spacing.itely
index 5f1035f..dc4c513 100644
--- a/Documentation/notation/spacing.itely
+++ b/Documentation/notation/spacing.itely
@@ -398,6 +398,14 @@ on a page:
 
 @table @code
 
+@item binding-offset
+@funindex binding-offset
+
+The amount @code{inner-margin} is additionately increased
+to make sure nothing will be hidden by the binding.
+Works only with @code{two-sided} set to true.  Default:
+@code{0}.
+
 @item horizontal-shift
 @funindex horizontal-shift
 
@@ -410,30 +418,44 @@ separators) are shifted to the right.  Default: @code{0.0}.
 The level of indentation for the first system in a score.
 Default: @code{15\mm}.
 
+@item inner-margin
+@funindex inner-margin
+
+The margin all pages have at the inner side if they are part
+of a book.  Works only with @code{two-sided} set to true.
+Default: @code{10\mm}.
+
 @item left-margin
 @funindex left-margin
 
 The margin between the left edge of the page and the beginning of
 each system.  Default: @code{10\mm}.
 
-@item right-margin
-@funindex right-margin
-
-The margin between the right edge of the page and the beginning of
-each system.  Default: @code{10\mm}.
-
 @item line-width
 @funindex line-width
 
 The width of music systems.  Default: @code{paper-width} minus
 @code{left-margin} and @code{right-margin}.
 
+@item outer-margin
+@funindex outer-margin
+
+The margin all pages have at the outer side if they are part
+of a book.  Works only with @code{two-sided} set to true.
+Default: @code{20\mm}.
+
 @item paper-width
 @funindex paper-width
 
 The width of the page.  Default: the width of the current paper
 size.  For details, see @ref{Paper size}.
 
+@item right-margin
+@funindex right-margin
+
+The margin between the right edge of the page and the beginning of
+each system.  Default: @code{10\mm}.
+
 @item short-indent
 @funindex short-indent
 
@@ -708,6 +730,14 @@ The number of systems that should be placed on each page.
 This is currently supported only by the @code{ly:optimal-breaking} algorithm.
 Default: unset.
 
+@item two-sided
+@funindex two-sided
+
+If set to true, use @code{inner-margin}, @code{outer-margin} and
+@code{binding-offset} for determining margins depending on whether
+the page number is odd or even.  @code{left-margin} and @code{right-margin}
+are discarded then.  Default: @code{##f}.
+
 @end table
 
 
--
1.6.0.2


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: [PATCH] Re: New twoside mode.

by Neil Puttock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/11/6 Michael Käppler <xmichael-k@...>:

> Maybe you can have a look at it. It's just the most important things for
> now, maybe it should be extended later.

Just a few minor quibbles:

+The amount @code{inner-margin} is additionately increased

additionally (though I'd probably remove this, since `increased' is OK
by itself)

+@code{binding-offset} for determining margins depending on whether

to determine

+the page number is odd or even.  @code{left-margin} and @code{right-margin}
+are discarded then.  Default: @code{##f}.

I'd prefer something like `Overrides settings for left-margin and right-margin.'

Thanks,
Neil


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: [PATCH] Re: New twoside mode.

by Michael Käppler-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here you are.

Regards,
Michael

From 5deda137b69c7110b6fc02046497362788347e34 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Michael=20K=C3=A4ppler?= <xmichael-k@...>
Date: Fri, 6 Nov 2009 14:25:52 +0100
Subject: [PATCH] Docs: Add documentation for paper variables involved in two-sided mode.

---
 Documentation/notation/spacing.itely |   42 +++++++++++++++++++++++++++++-----
 1 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/Documentation/notation/spacing.itely b/Documentation/notation/spacing.itely
index 5f1035f..d4e3475 100644
--- a/Documentation/notation/spacing.itely
+++ b/Documentation/notation/spacing.itely
@@ -398,6 +398,14 @@ on a page:
 
 @table @code
 
+@item binding-offset
+@funindex binding-offset
+
+The amount @code{inner-margin} is increased
+to make sure nothing will be hidden by the binding.
+Works only with @code{two-sided} set to true.  Default:
+@code{0}.
+
 @item horizontal-shift
 @funindex horizontal-shift
 
@@ -410,30 +418,44 @@ separators) are shifted to the right.  Default: @code{0.0}.
 The level of indentation for the first system in a score.
 Default: @code{15\mm}.
 
+@item inner-margin
+@funindex inner-margin
+
+The margin all pages have at the inner side if they are part
+of a book.  Works only with @code{two-sided} set to true.
+Default: @code{10\mm}.
+
 @item left-margin
 @funindex left-margin
 
 The margin between the left edge of the page and the beginning of
 each system.  Default: @code{10\mm}.
 
-@item right-margin
-@funindex right-margin
-
-The margin between the right edge of the page and the beginning of
-each system.  Default: @code{10\mm}.
-
 @item line-width
 @funindex line-width
 
 The width of music systems.  Default: @code{paper-width} minus
 @code{left-margin} and @code{right-margin}.
 
+@item outer-margin
+@funindex outer-margin
+
+The margin all pages have at the outer side if they are part
+of a book.  Works only with @code{two-sided} set to true.
+Default: @code{20\mm}.
+
 @item paper-width
 @funindex paper-width
 
 The width of the page.  Default: the width of the current paper
 size.  For details, see @ref{Paper size}.
 
+@item right-margin
+@funindex right-margin
+
+The margin between the right edge of the page and the beginning of
+each system.  Default: @code{10\mm}.
+
 @item short-indent
 @funindex short-indent
 
@@ -708,6 +730,14 @@ The number of systems that should be placed on each page.
 This is currently supported only by the @code{ly:optimal-breaking} algorithm.
 Default: unset.
 
+@item two-sided
+@funindex two-sided
+
+If set to true, use @code{inner-margin}, @code{outer-margin} and
+@code{binding-offset} to determine margins depending on whether
+the page number is odd or even.  This overrides @code{left-margin}
+and @code{right-margin}.  Default: @code{##f}.
+
 @end table
 
 
--
1.6.0.2


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Re: [PATCH] Re: New twoside mode.

by Neil Puttock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/11/8 Michael Käppler <xmichael-k@...>:
> Here you are.

Cheers, it's applied.

Regards,
Neil


_______________________________________________
lilypond-devel mailing list
lilypond-devel@...
http://lists.gnu.org/mailman/listinfo/lilypond-devel