Mercurial > hg > svgui
comparison layer/FlexiNoteLayer.h @ 904:e0f08e108064 cxx11
Move to using double rather than float for floating-point calculations (float only for storage); more build fixes
author | Chris Cannam |
---|---|
date | Mon, 09 Mar 2015 12:02:10 +0000 |
parents | 40c6c9344ff6 |
children | b66fb15de477 |
comparison
equal
deleted
inserted
replaced
903:1757933ce5a7 | 904:e0f08e108064 |
---|---|
43 virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const; | 43 virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const; |
44 virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const; | 44 virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const; |
45 | 45 |
46 virtual QString getFeatureDescription(View *v, QPoint &) const; | 46 virtual QString getFeatureDescription(View *v, QPoint &) const; |
47 | 47 |
48 virtual bool snapToFeatureFrame(View *v, int &frame, | 48 virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, |
49 int &resolution, | 49 int &resolution, |
50 SnapType snap) const; | 50 SnapType snap) const; |
51 | 51 |
52 virtual void drawStart(View *v, QMouseEvent *); | 52 virtual void drawStart(View *v, QMouseEvent *); |
53 virtual void drawDrag(View *v, QMouseEvent *); | 53 virtual void drawDrag(View *v, QMouseEvent *); |
74 virtual void resizeSelection(Selection s, Selection newSize); | 74 virtual void resizeSelection(Selection s, Selection newSize); |
75 virtual void deleteSelection(Selection s); | 75 virtual void deleteSelection(Selection s); |
76 virtual void deleteSelectionInclusive(Selection s); | 76 virtual void deleteSelectionInclusive(Selection s); |
77 | 77 |
78 virtual void copy(View *v, Selection s, Clipboard &to); | 78 virtual void copy(View *v, Selection s, Clipboard &to); |
79 virtual bool paste(View *v, const Clipboard &from, int frameOffset, | 79 virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset, |
80 bool interactive); | 80 bool interactive); |
81 | 81 |
82 void splitNotesAt(View *v, int frame); | 82 void splitNotesAt(View *v, sv_frame_t frame); |
83 void snapSelectedNotesToPitchTrack(View *v, Selection s); | 83 void snapSelectedNotesToPitchTrack(View *v, Selection s); |
84 void mergeNotes(View *v, Selection s, bool inclusive); | 84 void mergeNotes(View *v, Selection s, bool inclusive); |
85 | 85 |
86 virtual const Model *getModel() const { return m_model; } | 86 virtual const Model *getModel() const { return m_model; } |
87 void setModel(FlexiNoteModel *model); | 87 void setModel(FlexiNoteModel *model); |
120 | 120 |
121 virtual bool isLayerEditable() const { return true; } | 121 virtual bool isLayerEditable() const { return true; } |
122 | 122 |
123 virtual int getCompletion(View *) const { return m_model->getCompletion(); } | 123 virtual int getCompletion(View *) const { return m_model->getCompletion(); } |
124 | 124 |
125 virtual bool getValueExtents(float &min, float &max, | 125 virtual bool getValueExtents(double &min, double &max, |
126 bool &log, QString &unit) const; | 126 bool &log, QString &unit) const; |
127 | 127 |
128 virtual bool getDisplayExtents(float &min, float &max) const; | 128 virtual bool getDisplayExtents(double &min, double &max) const; |
129 virtual bool setDisplayExtents(float min, float max); | 129 virtual bool setDisplayExtents(double min, double max); |
130 | 130 |
131 virtual int getVerticalZoomSteps(int &defaultStep) const; | 131 virtual int getVerticalZoomSteps(int &defaultStep) const; |
132 virtual int getCurrentVerticalZoomStep() const; | 132 virtual int getCurrentVerticalZoomStep() const; |
133 virtual void setVerticalZoomStep(int); | 133 virtual void setVerticalZoomStep(int); |
134 virtual RangeMapper *getNewVerticalZoomRangeMapper() const; | 134 virtual RangeMapper *getNewVerticalZoomRangeMapper() const; |
136 /** | 136 /** |
137 * Add a note-on. Used when recording MIDI "live". The note will | 137 * Add a note-on. Used when recording MIDI "live". The note will |
138 * not be finally added to the layer until the corresponding | 138 * not be finally added to the layer until the corresponding |
139 * note-off. | 139 * note-off. |
140 */ | 140 */ |
141 void addNoteOn(int frame, int pitch, int velocity); | 141 void addNoteOn(sv_frame_t frame, int pitch, int velocity); |
142 | 142 |
143 /** | 143 /** |
144 * Add a note-off. This will cause a note to appear, if and only | 144 * Add a note-off. This will cause a note to appear, if and only |
145 * if there is a matching pending note-on. | 145 * if there is a matching pending note-on. |
146 */ | 146 */ |
147 void addNoteOff(int frame, int pitch); | 147 void addNoteOff(sv_frame_t frame, int pitch); |
148 | 148 |
149 /** | 149 /** |
150 * Abandon all pending note-on events. | 150 * Abandon all pending note-on events. |
151 */ | 151 */ |
152 void abandonNoteOns(); | 152 void abandonNoteOns(); |
157 void setProperties(const QXmlAttributes &attributes); | 157 void setProperties(const QXmlAttributes &attributes); |
158 | 158 |
159 void setVerticalRangeToNoteRange(View *v); | 159 void setVerticalRangeToNoteRange(View *v); |
160 | 160 |
161 /// VerticalScaleLayer methods | 161 /// VerticalScaleLayer methods |
162 virtual int getYForValue(View *v, float value) const; | 162 virtual int getYForValue(View *v, double value) const; |
163 virtual float getValueForY(View *v, int y) const; | 163 virtual double getValueForY(View *v, int y) const; |
164 virtual QString getScaleUnits() const; | 164 virtual QString getScaleUnits() const; |
165 | 165 |
166 protected: | 166 protected: |
167 void getScaleExtents(View *, float &min, float &max, bool &log) const; | 167 void getScaleExtents(View *, double &min, double &max, bool &log) const; |
168 bool shouldConvertMIDIToHz() const; | 168 bool shouldConvertMIDIToHz() const; |
169 | 169 |
170 virtual int getDefaultColourHint(bool dark, bool &impose); | 170 virtual int getDefaultColourHint(bool dark, bool &impose); |
171 | 171 |
172 FlexiNoteModel::PointList getLocalPoints(View *v, int) const; | 172 FlexiNoteModel::PointList getLocalPoints(View *v, int) const; |
174 bool getPointToDrag(View *v, int x, int y, FlexiNoteModel::Point &) const; | 174 bool getPointToDrag(View *v, int x, int y, FlexiNoteModel::Point &) const; |
175 bool getNoteToEdit(View *v, int x, int y, FlexiNoteModel::Point &) const; | 175 bool getNoteToEdit(View *v, int x, int y, FlexiNoteModel::Point &) const; |
176 void getRelativeMousePosition(View *v, FlexiNoteModel::Point ¬e, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const; | 176 void getRelativeMousePosition(View *v, FlexiNoteModel::Point ¬e, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const; |
177 SparseTimeValueModel *getAssociatedPitchModel(View *v) const; | 177 SparseTimeValueModel *getAssociatedPitchModel(View *v) const; |
178 bool updateNoteValue(View *v, FlexiNoteModel::Point ¬e) const; | 178 bool updateNoteValue(View *v, FlexiNoteModel::Point ¬e) const; |
179 void splitNotesAt(View *v, int frame, QMouseEvent *e); | 179 void splitNotesAt(View *v, sv_frame_t frame, QMouseEvent *e); |
180 | 180 |
181 FlexiNoteModel *m_model; | 181 FlexiNoteModel *m_model; |
182 bool m_editing; | 182 bool m_editing; |
183 bool m_intelligentActions; | 183 bool m_intelligentActions; |
184 int m_dragPointX; | 184 int m_dragPointX; |
185 int m_dragPointY; | 185 int m_dragPointY; |
186 int m_dragStartX; | 186 int m_dragStartX; |
187 int m_dragStartY; | 187 int m_dragStartY; |
188 FlexiNoteModel::Point m_originalPoint; | 188 FlexiNoteModel::Point m_originalPoint; |
189 FlexiNoteModel::Point m_editingPoint; | 189 FlexiNoteModel::Point m_editingPoint; |
190 int m_greatestLeftNeighbourFrame; | 190 sv_frame_t m_greatestLeftNeighbourFrame; |
191 int m_smallestRightNeighbourFrame; | 191 sv_frame_t m_smallestRightNeighbourFrame; |
192 FlexiNoteModel::EditCommand *m_editingCommand; | 192 FlexiNoteModel::EditCommand *m_editingCommand; |
193 VerticalScale m_verticalScale; | 193 VerticalScale m_verticalScale; |
194 EditMode m_editMode; | 194 EditMode m_editMode; |
195 | 195 |
196 typedef std::set<FlexiNoteModel::Point, FlexiNoteModel::Point::Comparator> FlexiNoteSet; | 196 typedef std::set<FlexiNoteModel::Point, FlexiNoteModel::Point::Comparator> FlexiNoteSet; |
197 FlexiNoteSet m_pendingNoteOns; | 197 FlexiNoteSet m_pendingNoteOns; |
198 | 198 |
199 mutable float m_scaleMinimum; | 199 mutable double m_scaleMinimum; |
200 mutable float m_scaleMaximum; | 200 mutable double m_scaleMaximum; |
201 | 201 |
202 bool shouldAutoAlign() const; | 202 bool shouldAutoAlign() const; |
203 | 203 |
204 void finish(FlexiNoteModel::EditCommand *command) { | 204 void finish(FlexiNoteModel::EditCommand *command) { |
205 Command *c = command->finish(); | 205 Command *c = command->finish(); |