summaryrefslogtreecommitdiff
path: root/cols.hh
blob: e51e2d56c0511dca48c15b7c24877187fd8e0f0e (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef COLS_HH
#define COLS_HH

#include "glob.hh"
#include "boxes.hh"
#include "list.hh"
#include "item.hh"

/// stuff grouped vertically.
struct PCol {
    List<const Item*> its;
    List<const Spanner*> stoppers, starters;
    
    /// Can this be broken? true eg. for bars. 
    bool breakable;

    /// does this column have items, does it have spacings attached?
    bool used;

    /// prebreak is put before end of line.
    PCol *prebreak;
    /**
    if broken here, then (*this) column is discarded, and prebreak
    is put at end of line, owned by Col
    */

    /// postbreak at beginning of the new line
    PCol *postbreak;
    /**  \See{prebreak}
    */
    PCol *daddy;
    /*
    if this column is pre or postbreak, then this field points to the parent.
    */
    /// if lines are broken then this column is in #line#
    const Line_of_score *line;

    /// if lines are broken then this column x-coord #hpos#
    Real hpos;


    /****************************************************************/

    void add(const Item*i);

    Interval width() const;
    ~PCol();
    PCol(PCol * parent);
    /// initialize the prebreak and postbreak fields
    setup_breaks();
    
    /// which col comes first?
    static int compare(const PCol &c1, const PCol &c2);
    /**
    signed compare on columns.

    return < 0 if c1 < c2.
    */

    void OK() const;
    void set_breakable();

};
/**
    This is a class to address items vertically. It contains the data for:
    \begin{itemize}
    \item
    unbroken score
    \item
    broken score
    \item
    the linespacing problem
    \end{itemize}
  */

#include "compare.hh"
instantiate_compare(const PCol &, PCol::compare);
     

/// ideal spacing between two columns
struct Idealspacing {

    /// the ideal distance
    Real space;

    /// Hooke's constant: how strong are the "springs" attached to columns
    Real hooke;

    /// the two columns
    const PCol *left, *right;

    void OK() const ;
    Idealspacing(const PCol *left,const PCol *right);
};

#endif