]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/stencil.hh
Issue 4550 (2/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / include / stencil.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef STENCIL_HH
20 #define STENCIL_HH
21
22 #include <cstdlib>              // size_t
23
24 #include "lily-proto.hh"
25 #include "box.hh"
26 #include "smobs.hh"
27
28 /** a group of individually translated symbols. You can add stencils
29     to the top, to the right, etc.
30
31     It is implemented as a "tree" of scheme expressions, as in
32
33     Expr = combine Expr-list
34     | translate Offset Expr
35     | origin (ORIGIN) Expr
36     | no-origin Expr
37     | (SCHEME)
38     ;
39
40     SCHEME is a Scheme expression that --when eval'd-- produces the
41     desired output.
42
43     Notes:
44
45     * Because of the way that Stencil is implemented, it is the most
46     efficient to add "fresh" stencils to what you're going to build.
47
48     * Do not create Stencil objects on the heap. That includes passing
49     around Stencil* which are produced by unsmob<Stencil>(). Either
50     copy Stencil objects, or use SCM references.
51
52     * Empty stencils have empty dimensions.  If add_at_edge is used to
53     init the stencil, we assume that
54
55     DIMENSIONS = (Interval (0, 0), Interval (0, 0)
56 */
57 class Stencil : public Simple_smob<Stencil>
58 {
59 public:
60   SCM mark_smob () const;
61   static const char type_p_name_[];
62 private:
63   Box dim_;
64   SCM expr_;
65
66 public:
67   Stencil (Box, SCM s);
68   Stencil ();
69
70   SCM expr () const;
71
72   /**
73      Set dimensions to empty, or to (Interval (0, 0), Interval (0, 0) */
74   void set_empty (bool);
75   void add_at_edge (Axis a, Direction d, const Stencil &m, Real padding);
76   void stack (Axis a, Direction d, const Stencil &m, Real padding, Real mindist);
77   void add_stencil (Stencil const &m);
78   void translate (Offset);
79   Stencil translated (Offset) const;
80   void rotate (Real, Offset);
81   void rotate_degrees (Real, Offset);
82   void rotate_degrees_absolute (Real, Offset);
83   void align_to (Axis a, Real x);
84   void translate_axis (Real, Axis);
85   void scale (Real, Real);
86
87   Interval extent (Axis) const;
88   Box extent_box () const;
89   bool is_empty () const;
90   bool is_empty (Axis) const;
91   Stencil in_color (Real r, Real g, Real b) const;
92   static SCM skylines_from_stencil (SCM, Real, Axis);
93 };
94
95
96 void interpret_stencil_expression (SCM expr,
97                                    SCM (*func) (void *, SCM),
98                                    void *func_arg,
99                                    Offset o);
100 SCM find_expression_fonts (SCM expr);
101
102 void register_stencil_head (SCM symbol);
103 bool is_stencil_head (SCM symbol);
104 SCM all_stencil_heads ();
105
106 #endif /* STENCIL_HH */