Mercurial > hg > svgui
comparison layer/TimeValueLayer.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 |
---|---|
693 | 693 |
694 m_editingCommand = 0; | 694 m_editingCommand = 0; |
695 m_editing = false; | 695 m_editing = false; |
696 } | 696 } |
697 | 697 |
698 void | |
699 TimeValueLayer::moveSelection(Selection s, size_t newStartFrame) | |
700 { | |
701 SparseTimeValueModel::EditCommand *command = | |
702 new SparseTimeValueModel::EditCommand(m_model, | |
703 tr("Drag Selection")); | |
704 | |
705 SparseTimeValueModel::PointList points = | |
706 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
707 | |
708 for (SparseTimeValueModel::PointList::iterator i = points.begin(); | |
709 i != points.end(); ++i) { | |
710 | |
711 if (s.contains(i->frame)) { | |
712 SparseTimeValueModel::Point newPoint(*i); | |
713 newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); | |
714 command->deletePoint(*i); | |
715 command->addPoint(newPoint); | |
716 } | |
717 } | |
718 | |
719 command->finish(); | |
720 } | |
721 | |
722 void | |
723 TimeValueLayer::resizeSelection(Selection s, Selection newSize) | |
724 { | |
725 SparseTimeValueModel::EditCommand *command = | |
726 new SparseTimeValueModel::EditCommand(m_model, | |
727 tr("Resize Selection")); | |
728 | |
729 SparseTimeValueModel::PointList points = | |
730 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
731 | |
732 double ratio = | |
733 double(newSize.getEndFrame() - newSize.getStartFrame()) / | |
734 double(s.getEndFrame() - s.getStartFrame()); | |
735 | |
736 for (SparseTimeValueModel::PointList::iterator i = points.begin(); | |
737 i != points.end(); ++i) { | |
738 | |
739 if (s.contains(i->frame)) { | |
740 | |
741 double target = i->frame; | |
742 target = newSize.getStartFrame() + | |
743 double(target - s.getStartFrame()) * ratio; | |
744 | |
745 SparseTimeValueModel::Point newPoint(*i); | |
746 newPoint.frame = lrint(target); | |
747 command->deletePoint(*i); | |
748 command->addPoint(newPoint); | |
749 } | |
750 } | |
751 | |
752 command->finish(); | |
753 } | |
754 | |
698 QString | 755 QString |
699 TimeValueLayer::toXmlString(QString indent, QString extraAttributes) const | 756 TimeValueLayer::toXmlString(QString indent, QString extraAttributes) const |
700 { | 757 { |
701 return Layer::toXmlString(indent, extraAttributes + | 758 return Layer::toXmlString(indent, extraAttributes + |
702 QString(" colour=\"%1\" plotStyle=\"%2\"") | 759 QString(" colour=\"%1\" plotStyle=\"%2\"") |