Mercurial > hg > svgui
comparison layer/NoteLayer.cpp @ 43:78515b1e29eb
* Rejig project file a bit to do pkg-config detection &c
and change some HAVE_* symbol names accordingly
* Add selection move/resize/delete
* First stubs for add layer / pane commands
author | Chris Cannam |
---|---|
date | Wed, 01 Mar 2006 18:13:01 +0000 |
parents | 1bdf285c4eac |
children | ad214997dddb |
comparison
equal
deleted
inserted
replaced
42:1bdf285c4eac | 43:78515b1e29eb |
---|---|
615 | 615 |
616 m_editingCommand = 0; | 616 m_editingCommand = 0; |
617 m_editing = false; | 617 m_editing = false; |
618 } | 618 } |
619 | 619 |
620 void | |
621 NoteLayer::moveSelection(Selection s, size_t newStartFrame) | |
622 { | |
623 NoteModel::EditCommand *command = | |
624 new NoteModel::EditCommand(m_model, tr("Drag Selection")); | |
625 | |
626 NoteModel::PointList points = | |
627 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
628 | |
629 for (NoteModel::PointList::iterator i = points.begin(); | |
630 i != points.end(); ++i) { | |
631 | |
632 if (s.contains(i->frame)) { | |
633 NoteModel::Point newPoint(*i); | |
634 newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); | |
635 command->deletePoint(*i); | |
636 command->addPoint(newPoint); | |
637 } | |
638 } | |
639 | |
640 command->finish(); | |
641 } | |
642 | |
643 void | |
644 NoteLayer::resizeSelection(Selection s, Selection newSize) | |
645 { | |
646 NoteModel::EditCommand *command = | |
647 new NoteModel::EditCommand(m_model, tr("Resize Selection")); | |
648 | |
649 NoteModel::PointList points = | |
650 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
651 | |
652 double ratio = | |
653 double(newSize.getEndFrame() - newSize.getStartFrame()) / | |
654 double(s.getEndFrame() - s.getStartFrame()); | |
655 | |
656 for (NoteModel::PointList::iterator i = points.begin(); | |
657 i != points.end(); ++i) { | |
658 | |
659 if (s.contains(i->frame)) { | |
660 | |
661 double targetStart = i->frame; | |
662 targetStart = newSize.getStartFrame() + | |
663 double(targetStart - s.getStartFrame()) * ratio; | |
664 | |
665 double targetEnd = i->frame + i->duration; | |
666 targetEnd = newSize.getStartFrame() + | |
667 double(targetEnd - s.getStartFrame()) * ratio; | |
668 | |
669 NoteModel::Point newPoint(*i); | |
670 newPoint.frame = lrint(targetStart); | |
671 newPoint.duration = lrint(targetEnd - targetStart); | |
672 command->deletePoint(*i); | |
673 command->addPoint(newPoint); | |
674 } | |
675 } | |
676 | |
677 command->finish(); | |
678 } | |
679 | |
620 QString | 680 QString |
621 NoteLayer::toXmlString(QString indent, QString extraAttributes) const | 681 NoteLayer::toXmlString(QString indent, QString extraAttributes) const |
622 { | 682 { |
623 return Layer::toXmlString(indent, extraAttributes + | 683 return Layer::toXmlString(indent, extraAttributes + |
624 QString(" colour=\"%1\" verticalScale=\"%2\"") | 684 QString(" colour=\"%1\" verticalScale=\"%2\"") |