Mercurial > hg > svgui
diff layer/FlexiNoteLayer.cpp @ 916:94e4952a6774 osx-retina
Start trying to introduce LayerGeometryProvider as proxyable interface for View methods that the Layer wants to use
author | Chris Cannam |
---|---|
date | Tue, 17 Mar 2015 15:05:25 +0000 |
parents | b66fb15de477 |
children | 4fe7a09be0fe |
line wrap: on
line diff
--- a/layer/FlexiNoteLayer.cpp Wed Mar 11 15:35:20 2015 +0000 +++ b/layer/FlexiNoteLayer.cpp Tue Mar 17 15:05:25 2015 +0000 @@ -204,7 +204,7 @@ } bool -FlexiNoteLayer::isLayerScrollable(const View *v) const +FlexiNoteLayer::isLayerScrollable(const LayerGeometryProvider *v) const { QPoint discard; return !v->shouldIlluminateLocalFeatures(this, discard); @@ -405,7 +405,7 @@ } FlexiNoteModel::PointList -FlexiNoteLayer::getLocalPoints(View *v, int x) const +FlexiNoteLayer::getLocalPoints(LayerGeometryProvider *v, int x) const { if (!m_model) return FlexiNoteModel::PointList(); @@ -448,7 +448,7 @@ } bool -FlexiNoteLayer::getPointToDrag(View *v, int x, int y, FlexiNoteModel::Point &p) const +FlexiNoteLayer::getPointToDrag(LayerGeometryProvider *v, int x, int y, FlexiNoteModel::Point &p) const { if (!m_model) return false; @@ -476,7 +476,7 @@ } bool -FlexiNoteLayer::getNoteToEdit(View *v, int x, int y, FlexiNoteModel::Point &p) const +FlexiNoteLayer::getNoteToEdit(LayerGeometryProvider *v, int x, int y, FlexiNoteModel::Point &p) const { // GF: find the note that is closest to the cursor if (!m_model) return false; @@ -505,7 +505,7 @@ } QString -FlexiNoteLayer::getFeatureDescription(View *v, QPoint &pos) const +FlexiNoteLayer::getFeatureDescription(LayerGeometryProvider *v, QPoint &pos) const { int x = pos.x(); @@ -593,7 +593,7 @@ } bool -FlexiNoteLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, +FlexiNoteLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -673,7 +673,7 @@ } void -FlexiNoteLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const +FlexiNoteLayer::getScaleExtents(LayerGeometryProvider *v, double &min, double &max, bool &log) const { min = 0.0; max = 0.0; @@ -730,11 +730,11 @@ } int -FlexiNoteLayer::getYForValue(View *v, double val) const +FlexiNoteLayer::getYForValue(LayerGeometryProvider *v, double val) const { double min = 0.0, max = 0.0; bool logarithmic = false; - int h = v->height(); + int h = v->getPaintHeight(); getScaleExtents(v, min, max, logarithmic); @@ -765,11 +765,11 @@ } double -FlexiNoteLayer::getValueForY(View *v, int y) const +FlexiNoteLayer::getValueForY(LayerGeometryProvider *v, int y) const { double min = 0.0, max = 0.0; bool logarithmic = false; - int h = v->height(); + int h = v->getPaintHeight(); getScaleExtents(v, min, max, logarithmic); @@ -794,7 +794,7 @@ } void -FlexiNoteLayer::paint(View *v, QPainter &paint, QRect rect) const +FlexiNoteLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const { if (!m_model || !m_model->isOK()) return; @@ -860,8 +860,8 @@ !FlexiNoteModel::Point::Comparator()(illuminatePoint, p) && !FlexiNoteModel::Point::Comparator()(p, illuminatePoint)) { - paint.drawLine(x, -1, x, v->height() + 1); - paint.drawLine(x+w, -1, x+w, v->height() + 1); + paint.drawLine(x, -1, x, v->getPaintHeight() + 1); + paint.drawLine(x+w, -1, x+w, v->getPaintHeight() + 1); paint.setPen(v->getForeground()); // paint.setBrush(v->getForeground()); @@ -904,7 +904,7 @@ } int -FlexiNoteLayer::getVerticalScaleWidth(View *v, bool, QPainter &paint) const +FlexiNoteLayer::getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &paint) const { if (!m_model || shouldAutoAlign()) { return 0; @@ -918,7 +918,7 @@ } void -FlexiNoteLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect) const +FlexiNoteLayer::paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect) const { if (!m_model || m_model->getPoints().empty()) return; @@ -927,7 +927,7 @@ bool logarithmic; int w = getVerticalScaleWidth(v, false, paint); - int h = v->height(); + int h = v->getPaintHeight(); getScaleExtents(v, min, max, logarithmic); @@ -956,7 +956,7 @@ } void -FlexiNoteLayer::drawStart(View *v, QMouseEvent *e) +FlexiNoteLayer::drawStart(LayerGeometryProvider *v, QMouseEvent *e) { // SVDEBUG << "FlexiNoteLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl; @@ -980,7 +980,7 @@ } void -FlexiNoteLayer::drawDrag(View *v, QMouseEvent *e) +FlexiNoteLayer::drawDrag(LayerGeometryProvider *v, QMouseEvent *e) { // SVDEBUG << "FlexiNoteLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl; @@ -1009,7 +1009,7 @@ } void -FlexiNoteLayer::drawEnd(View *, QMouseEvent *) +FlexiNoteLayer::drawEnd(LayerGeometryProvider *, QMouseEvent *) { // SVDEBUG << "FlexiNoteLayer::drawEnd(" << e->x() << "," << e->y() << ")" << endl; if (!m_model || !m_editing) return; @@ -1019,7 +1019,7 @@ } void -FlexiNoteLayer::eraseStart(View *v, QMouseEvent *e) +FlexiNoteLayer::eraseStart(LayerGeometryProvider *v, QMouseEvent *e) { if (!m_model) return; @@ -1034,12 +1034,12 @@ } void -FlexiNoteLayer::eraseDrag(View *, QMouseEvent *) +FlexiNoteLayer::eraseDrag(LayerGeometryProvider *, QMouseEvent *) { } void -FlexiNoteLayer::eraseEnd(View *v, QMouseEvent *e) +FlexiNoteLayer::eraseEnd(LayerGeometryProvider *v, QMouseEvent *e) { if (!m_model || !m_editing) return; @@ -1059,7 +1059,7 @@ } void -FlexiNoteLayer::editStart(View *v, QMouseEvent *e) +FlexiNoteLayer::editStart(LayerGeometryProvider *v, QMouseEvent *e) { // SVDEBUG << "FlexiNoteLayer::editStart(" << e->x() << "," << e->y() << ")" << endl; std::cerr << "FlexiNoteLayer::editStart(" << e->x() << "," << e->y() << ")" << std::endl; @@ -1110,7 +1110,7 @@ } void -FlexiNoteLayer::editDrag(View *v, QMouseEvent *e) +FlexiNoteLayer::editDrag(LayerGeometryProvider *v, QMouseEvent *e) { // SVDEBUG << "FlexiNoteLayer::editDrag(" << e->x() << "," << e->y() << ")" << endl; std::cerr << "FlexiNoteLayer::editDrag(" << e->x() << "," << e->y() << ")" << std::endl; @@ -1177,7 +1177,7 @@ } void -FlexiNoteLayer::editEnd(View *, QMouseEvent *e) +FlexiNoteLayer::editEnd(LayerGeometryProvider *, QMouseEvent *e) { // SVDEBUG << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << endl; std::cerr << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << std::endl; @@ -1207,7 +1207,7 @@ } void -FlexiNoteLayer::splitStart(View *v, QMouseEvent *e) +FlexiNoteLayer::splitStart(LayerGeometryProvider *v, QMouseEvent *e) { // GF: note splitting starts (!! remove printing soon) std::cerr << "splitStart" << std::endl; @@ -1231,7 +1231,7 @@ } void -FlexiNoteLayer::splitEnd(View *v, QMouseEvent *e) +FlexiNoteLayer::splitEnd(LayerGeometryProvider *v, QMouseEvent *e) { // GF: note splitting ends. (!! remove printing soon) std::cerr << "splitEnd" << std::endl; @@ -1250,13 +1250,13 @@ } void -FlexiNoteLayer::splitNotesAt(View *v, sv_frame_t frame) +FlexiNoteLayer::splitNotesAt(LayerGeometryProvider *v, sv_frame_t frame) { splitNotesAt(v, frame, 0); } void -FlexiNoteLayer::splitNotesAt(View *v, sv_frame_t frame, QMouseEvent *e) +FlexiNoteLayer::splitNotesAt(LayerGeometryProvider *v, sv_frame_t frame, QMouseEvent *e) { FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); if (onPoints.empty()) return; @@ -1296,7 +1296,7 @@ } void -FlexiNoteLayer::addNote(View *v, QMouseEvent *e) +FlexiNoteLayer::addNote(LayerGeometryProvider *v, QMouseEvent *e) { std::cerr << "addNote" << std::endl; if (!m_model) return; @@ -1335,7 +1335,7 @@ } SparseTimeValueModel * -FlexiNoteLayer::getAssociatedPitchModel(View *v) const +FlexiNoteLayer::getAssociatedPitchModel(LayerGeometryProvider *v) const { // Better than we used to do, but still not very satisfactory @@ -1359,7 +1359,7 @@ } void -FlexiNoteLayer::snapSelectedNotesToPitchTrack(View *v, Selection s) +FlexiNoteLayer::snapSelectedNotesToPitchTrack(LayerGeometryProvider *v, Selection s) { if (!m_model) return; @@ -1397,7 +1397,7 @@ } void -FlexiNoteLayer::mergeNotes(View *v, Selection s, bool inclusive) +FlexiNoteLayer::mergeNotes(LayerGeometryProvider *v, Selection s, bool inclusive) { FlexiNoteModel::PointList points = m_model->getPoints(s.getStartFrame(), s.getEndFrame()); @@ -1440,7 +1440,7 @@ } bool -FlexiNoteLayer::updateNoteValue(View *v, FlexiNoteModel::Point ¬e) const +FlexiNoteLayer::updateNoteValue(LayerGeometryProvider *v, FlexiNoteModel::Point ¬e) const { SparseTimeValueModel *model = getAssociatedPitchModel(v); if (!model) return false; @@ -1482,7 +1482,7 @@ } void -FlexiNoteLayer::mouseMoveEvent(View *v, QMouseEvent *e) +FlexiNoteLayer::mouseMoveEvent(LayerGeometryProvider *v, QMouseEvent *e) { // GF: context sensitive cursors // v->setCursor(Qt::ArrowCursor); @@ -1510,7 +1510,7 @@ } void -FlexiNoteLayer::getRelativeMousePosition(View *v, FlexiNoteModel::Point ¬e, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const +FlexiNoteLayer::getRelativeMousePosition(LayerGeometryProvider *v, FlexiNoteModel::Point ¬e, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const { // GF: TODO: consoloidate the tolerance values if (!m_model) return; @@ -1539,7 +1539,7 @@ bool -FlexiNoteLayer::editOpen(View *v, QMouseEvent *e) +FlexiNoteLayer::editOpen(LayerGeometryProvider *v, QMouseEvent *e) { std::cerr << "Opening note editor dialog" << std::endl; if (!m_model) return false; @@ -1693,7 +1693,7 @@ } void -FlexiNoteLayer::copy(View *v, Selection s, Clipboard &to) +FlexiNoteLayer::copy(LayerGeometryProvider *v, Selection s, Clipboard &to) { if (!m_model) return; @@ -1711,7 +1711,7 @@ } bool -FlexiNoteLayer::paste(View *v, const Clipboard &from, sv_frame_t /*frameOffset */, bool /* interactive */) +FlexiNoteLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t /*frameOffset */, bool /* interactive */) { if (!m_model) return false; @@ -1722,7 +1722,7 @@ if (clipboardHasDifferentAlignment(v, from)) { QMessageBox::StandardButton button = - QMessageBox::question(v, tr("Re-align pasted items?"), + QMessageBox::question(v->getWidget(), tr("Re-align pasted items?"), tr("The items you are pasting came from a layer with different source material from this one. Do you want to re-align them in time, to match the source material for this layer?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes); @@ -1859,7 +1859,7 @@ } void -FlexiNoteLayer::setVerticalRangeToNoteRange(View *v) +FlexiNoteLayer::setVerticalRangeToNoteRange(LayerGeometryProvider *v) { double minf = std::numeric_limits<double>::max(); double maxf = 0;