86
88
timeT getSnapTime(timeT t) const;
89
* Snap a given x-coordinate to the nearest time on
90
* the grid. Of course this also does x-to-time
91
* conversion, so it's useful even in NoSnap mode.
92
* If the snap time is greater than the bar duration
93
* at this point, the bar duration will be used instead.
91
* Snap a given x-coordinate to the nearest time on the grid. Of
92
* course this also does x-to-time conversion, so it's useful even
93
* in NoSnap mode. If the snap time is greater than the bar
94
* duration at this point, the bar duration will be used instead.
95
* If d is SnapLeft or SnapRight, a time to the left or
96
* right respectively of the given coordinate will be
97
* returned; otherwise the nearest time on either side
96
* If d is SnapLeft or SnapRight, a time to the left or right
97
* respectively of the given coordinate will be returned;
98
* otherwise the nearest time on either side will be returned.
100
100
timeT snapX(double x, SnapDirection d = SnapEither) const;
103
* Snap a given time to the nearest time on the grid.
104
* Unlike snapX, this is not useful in NoSnap mode.
105
* If the snap time is greater than the bar duration
106
* at this point, the bar duration will be used instead.
103
* Snap a given time to the nearest time on the grid. Unlike
104
* snapX, this is not useful in NoSnap mode. If the snap time is
105
* greater than the bar duration at this point, the bar duration
106
* will be used instead.
108
* If d is SnapLeft or SnapRight, a time to the left or
109
* right respectively of the given coordinate will be
110
* returned; otherwise the nearest time on either side
108
* If d is SnapLeft or SnapRight, a time to the left or right
109
* respectively of the given coordinate will be returned;
110
* otherwise the nearest time on either side will be returned.
113
112
timeT snapTime(timeT t, SnapDirection d = SnapEither) const;
116
* Snap a given y-coordinate to the nearest lower
117
* multiple of the vstep.
115
* Snap a given y-coordinate to the nearest lower bin coordinate.
119
117
int snapY(int y) const {
120
if (m_vstep == 0) return y;
121
else return y / m_vstep * m_vstep;
125
* Return the vstep bin number for the given y-coordinate.
127
int getYBin(int y) const {
128
if (m_vstep == 0) return y;
129
else return y / m_vstep;
133
* Return the y-coordinate of the grid line at the start
134
* of the given vstep bin.
136
int getYBinCoordinate(int bin) const {
137
if (m_vstep == 0) return bin;
138
else return bin * m_vstep;
118
if (m_ysnap == 0) return y;
119
return getYBinCoordinate(getYBin(y));
123
* Return the bin number for the given y-coordinate.
125
int getYBin(int y) const;
128
* Return the y-coordinate of the grid line at the start of the
131
int getYBinCoordinate(int bin) const;
134
* Set the default vertical step. This is used as the height for
135
* bins that have no specific height multiple set, and the base
136
* height for bins that have a multiple. Setting the Y snap here
137
* is equivalent to specifying it in the constructor.
139
void setYSnap(int ysnap) {
144
* Retrieve the default vertical step.
141
146
int getYSnap() const {
151
* Set the height multiple for a specific bin. The bin will be
152
* multiple * ysnap high. The default is 1 for all bins.
154
void setBinHeightMultiple(int bin, int multiple) {
155
m_ymultiple[bin] = multiple;
159
* Retrieve the height multiple for a bin.
161
int getBinHeightMultiple(int bin) {
162
if (m_ymultiple.find(bin) == m_ymultiple.end()) return 1;
163
return m_ymultiple[bin];
145
166
RulerScale *getRulerScale() {