Mercurial > hg > svgui
diff layer/FlexiNoteLayer.cpp @ 808:40c6c9344ff6 warnfix_no_size_t
Merge from branch tony_integration
author | Chris Cannam |
---|---|
date | Wed, 18 Jun 2014 08:40:46 +0100 |
parents | 4c8ca536b54f d6b79166ae0d |
children | a9731b49745a |
line wrap: on
line diff
--- a/layer/FlexiNoteLayer.cpp Tue Jun 17 15:55:27 2014 +0100 +++ b/layer/FlexiNoteLayer.cpp Wed Jun 18 08:40:46 2014 +0100 @@ -818,12 +818,12 @@ QPoint localPos; FlexiNoteModel::Point illuminatePoint(0); -// bool shouldIlluminate = false; + bool shouldIlluminate = false; -// if (v->shouldIlluminateLocalFeatures(this, localPos)) { -// shouldIlluminate = getPointToDrag(v, localPos.x(), localPos.y(), -// illuminatePoint); -// } + if (v->shouldIlluminateLocalFeatures(this, localPos)) { + shouldIlluminate = getPointToDrag(v, localPos.x(), localPos.y(), + illuminatePoint); + } paint.save(); paint.setRenderHint(QPainter::Antialiasing, false); @@ -847,28 +847,42 @@ paint.setPen(getBaseQColor()); paint.setBrush(brushColour); - // if (shouldIlluminate && - // // "illuminatePoint == p" - // !FlexiNoteModel::Point::Comparator()(illuminatePoint, p) && - // !FlexiNoteModel::Point::Comparator()(p, illuminatePoint)) { - // - // paint.setPen(v->getForeground()); - // paint.setBrush(v->getForeground()); - // - // QString vlabel = QString("%1%2").arg(p.value).arg(m_model->getScaleUnits()); - // v->drawVisibleText(paint, - // x - paint.fontMetrics().width(vlabel) - 2, - // y + paint.fontMetrics().height()/2 - // - paint.fontMetrics().descent(), - // vlabel, View::OutlinedText); - // - // QString hlabel = RealTime::frame2RealTime - // (p.frame, m_model->getSampleRate()).toText(true).c_str(); - // v->drawVisibleText(paint, - // x, - // y - h/2 - paint.fontMetrics().descent() - 2, - // hlabel, View::OutlinedText); - // } + if (shouldIlluminate && + // "illuminatePoint == p" + !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.setPen(v->getForeground()); + // paint.setBrush(v->getForeground()); + + QString vlabel = QString("freq: %1%2").arg(p.value).arg(m_model->getScaleUnits()); + // v->drawVisibleText(paint, + // x - paint.fontMetrics().width(vlabel) - 2, + // y + paint.fontMetrics().height()/2 + // - paint.fontMetrics().descent(), + // vlabel, View::OutlinedText); + v->drawVisibleText(paint, + x, + y - h/2 - 2 - paint.fontMetrics().height() + - paint.fontMetrics().descent(), + vlabel, View::OutlinedText); + + QString hlabel = "dur: " + QString(RealTime::frame2RealTime + (p.duration, m_model->getSampleRate()).toText(true).c_str()); + v->drawVisibleText(paint, + x, + y - h/2 - paint.fontMetrics().descent() - 2, + hlabel, View::OutlinedText); + + QString llabel = QString("%1").arg(p.label); + v->drawVisibleText(paint, + x, + y + h + 2 + paint.fontMetrics().descent(), + llabel, View::OutlinedText); + } paint.drawRect(x, y - h/2, w, h); } @@ -1279,19 +1293,22 @@ int frame = v->getFrameForX(e->x()); float value = getValueForY(v, e->y()); + FlexiNoteModel::PointList noteList = m_model->getPoints(); + if (m_intelligentActions) { int smallestRightNeighbourFrame = 0; - for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin(); - i != m_model->getPoints().end(); ++i) { + for (FlexiNoteModel::PointList::const_iterator i = noteList.begin(); + i != noteList.end(); ++i) { FlexiNote currentNote = *i; if (currentNote.frame > frame) { smallestRightNeighbourFrame = currentNote.frame; break; } } - - duration = std::min(smallestRightNeighbourFrame - frame + 1, duration); - duration = (duration > 0) ? duration : 0; + if (smallestRightNeighbourFrame > 0) { + duration = std::min(smallestRightNeighbourFrame - frame + 1, duration); + duration = (duration > 0) ? duration : 0; + } } if (!m_intelligentActions || @@ -1313,7 +1330,7 @@ for (int i = 0; i < v->getLayerCount(); ++i) { Layer *layer = v->getLayer(i); - if (layer && !layer->isLayerDormant(v) && + if (layer && layer->getLayerPresentationName() != "candidate") { cerr << "FlexiNoteLayer::getAssociatedPitchModel: looks like our layer is " << layer << endl; SparseTimeValueModel *model = qobject_cast<SparseTimeValueModel *> @@ -1474,7 +1491,7 @@ v->setCursor(Qt::ArrowCursor); - // std::cerr << "Mouse moved in edit mode over FlexiNoteLayer" << std::endl; + std::cerr << "Mouse moved in edit mode over FlexiNoteLayer" << std::endl; // v->setCursor(Qt::SizeHorCursor); } @@ -1638,6 +1655,31 @@ } void +FlexiNoteLayer::deleteSelectionInclusive(Selection s) +{ + if (!m_model) return; + + FlexiNoteModel::EditCommand *command = + new FlexiNoteModel::EditCommand(m_model, tr("Delete Selected Points")); + + FlexiNoteModel::PointList points = + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + + for (FlexiNoteModel::PointList::iterator i = points.begin(); + i != points.end(); ++i) { + bool overlap = !( + ((s.getStartFrame() <= i->frame) && (s.getEndFrame() <= i->frame)) || // selection is left of note + ((s.getStartFrame() >= (i->frame+i->duration)) && (s.getEndFrame() >= (i->frame+i->duration))) // selection is right of note + ); + if (overlap) { + command->deletePoint(*i); + } + } + + finish(command); +} + +void FlexiNoteLayer::copy(View *v, Selection s, Clipboard &to) { if (!m_model) return;