Mercurial > hg > svgui
comparison layer/FlexiNoteLayer.cpp @ 784:3a52b458fcd5 tonioni
fixed note delete bug (now deletes when any overlap with the selection occurs)
author | matthiasm |
---|---|
date | Wed, 11 Jun 2014 19:41:29 +0100 |
parents | a6b87176b259 |
children | 488add397d34 |
comparison
equal
deleted
inserted
replaced
783:c1fc074971ed | 784:3a52b458fcd5 |
---|---|
818 | 818 |
819 QPoint localPos; | 819 QPoint localPos; |
820 FlexiNoteModel::Point illuminatePoint(0); | 820 FlexiNoteModel::Point illuminatePoint(0); |
821 bool shouldIlluminate = false; | 821 bool shouldIlluminate = false; |
822 | 822 |
823 | |
823 if (v->shouldIlluminateLocalFeatures(this, localPos)) { | 824 if (v->shouldIlluminateLocalFeatures(this, localPos)) { |
824 shouldIlluminate = getPointToDrag(v, localPos.x(), localPos.y(), | 825 shouldIlluminate = getPointToDrag(v, localPos.x(), localPos.y(), |
825 illuminatePoint); | 826 illuminatePoint); |
826 } | 827 } |
827 | 828 |
845 | 846 |
846 if (w < 1) w = 1; | 847 if (w < 1) w = 1; |
847 paint.setPen(getBaseQColor()); | 848 paint.setPen(getBaseQColor()); |
848 paint.setBrush(brushColour); | 849 paint.setBrush(brushColour); |
849 | 850 |
850 // if (shouldIlluminate && | 851 if (shouldIlluminate && |
851 // // "illuminatePoint == p" | 852 // "illuminatePoint == p" |
852 // !FlexiNoteModel::Point::Comparator()(illuminatePoint, p) && | 853 !FlexiNoteModel::Point::Comparator()(illuminatePoint, p) && |
853 // !FlexiNoteModel::Point::Comparator()(p, illuminatePoint)) { | 854 !FlexiNoteModel::Point::Comparator()(p, illuminatePoint)) { |
854 // | 855 |
855 // paint.setPen(v->getForeground()); | 856 paint.drawLine(x, -1, x, v->height() + 1); |
856 // paint.setBrush(v->getForeground()); | 857 paint.drawLine(x+w, -1, x+w, v->height() + 1); |
857 // | 858 |
858 // QString vlabel = QString("%1%2").arg(p.value).arg(m_model->getScaleUnits()); | 859 paint.setPen(v->getForeground()); |
859 // v->drawVisibleText(paint, | 860 // paint.setBrush(v->getForeground()); |
860 // x - paint.fontMetrics().width(vlabel) - 2, | 861 |
861 // y + paint.fontMetrics().height()/2 | 862 QString vlabel = QString("%1%2").arg(p.value).arg(m_model->getScaleUnits()); |
862 // - paint.fontMetrics().descent(), | 863 v->drawVisibleText(paint, |
863 // vlabel, View::OutlinedText); | 864 x - paint.fontMetrics().width(vlabel) - 2, |
864 // | 865 y + paint.fontMetrics().height()/2 |
865 // QString hlabel = RealTime::frame2RealTime | 866 - paint.fontMetrics().descent(), |
866 // (p.frame, m_model->getSampleRate()).toText(true).c_str(); | 867 vlabel, View::OutlinedText); |
867 // v->drawVisibleText(paint, | 868 |
868 // x, | 869 QString hlabel = RealTime::frame2RealTime |
869 // y - h/2 - paint.fontMetrics().descent() - 2, | 870 (p.duration, m_model->getSampleRate()).toText(true).c_str(); |
870 // hlabel, View::OutlinedText); | 871 v->drawVisibleText(paint, |
871 // } | 872 x, |
873 y - h/2 - paint.fontMetrics().descent() - 2, | |
874 hlabel, View::OutlinedText); | |
875 } | |
872 | 876 |
873 paint.drawRect(x, y - h/2, w, h); | 877 paint.drawRect(x, y - h/2, w, h); |
874 } | 878 } |
875 | 879 |
876 paint.restore(); | 880 paint.restore(); |
1470 if (closeToTop) { v->setCursor(Qt::CrossCursor); m_editMode = DragNote; return; } | 1474 if (closeToTop) { v->setCursor(Qt::CrossCursor); m_editMode = DragNote; return; } |
1471 if (closeToBottom) { v->setCursor(Qt::UpArrowCursor); m_editMode = SplitNote; return; } | 1475 if (closeToBottom) { v->setCursor(Qt::UpArrowCursor); m_editMode = SplitNote; return; } |
1472 | 1476 |
1473 v->setCursor(Qt::ArrowCursor); | 1477 v->setCursor(Qt::ArrowCursor); |
1474 | 1478 |
1475 // std::cerr << "Mouse moved in edit mode over FlexiNoteLayer" << std::endl; | 1479 // QPainter paint; |
1480 // paint.begin(m_pan); | |
1481 // QRect r(rect()); | |
1482 // paint(v, paint, r); | |
1483 // paint.end(this); | |
1484 | |
1485 std::cerr << "Mouse moved in edit mode over FlexiNoteLayer" << std::endl; | |
1476 // v->setCursor(Qt::SizeHorCursor); | 1486 // v->setCursor(Qt::SizeHorCursor); |
1477 | 1487 |
1478 } | 1488 } |
1479 | 1489 |
1480 void | 1490 void |
1632 } | 1642 } |
1633 } | 1643 } |
1634 | 1644 |
1635 finish(command); | 1645 finish(command); |
1636 } | 1646 } |
1647 | |
1648 void | |
1649 FlexiNoteLayer::deleteSelectionInclusive(Selection s) | |
1650 { | |
1651 if (!m_model) return; | |
1652 | |
1653 FlexiNoteModel::EditCommand *command = | |
1654 new FlexiNoteModel::EditCommand(m_model, tr("Delete Selected Points")); | |
1655 | |
1656 FlexiNoteModel::PointList points = | |
1657 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
1658 | |
1659 for (FlexiNoteModel::PointList::iterator i = points.begin(); | |
1660 i != points.end(); ++i) { | |
1661 bool overlap = !(((s.getStartFrame() < i->frame) && (s.getEndFrame() < i->frame)) | |
1662 || ((s.getStartFrame() > i->frame+i->duration) && (s.getEndFrame() > i->frame+i->duration))); | |
1663 if (overlap) { | |
1664 command->deletePoint(*i); | |
1665 } | |
1666 } | |
1667 | |
1668 finish(command); | |
1669 } | |
1637 | 1670 |
1638 void | 1671 void |
1639 FlexiNoteLayer::copy(View *v, Selection s, Clipboard &to) | 1672 FlexiNoteLayer::copy(View *v, Selection s, Clipboard &to) |
1640 { | 1673 { |
1641 if (!m_model) return; | 1674 if (!m_model) return; |