Mercurial > hg > svgui
diff layer/TextLayer.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 | c28ebb4ba4de |
children | ad214997dddb |
line wrap: on
line diff
--- a/layer/TextLayer.cpp Mon Feb 27 17:34:41 2006 +0000 +++ b/layer/TextLayer.cpp Wed Mar 01 18:13:01 2006 +0000 @@ -589,6 +589,61 @@ } } +void +TextLayer::moveSelection(Selection s, size_t newStartFrame) +{ + TextModel::EditCommand *command = + new TextModel::EditCommand(m_model, tr("Drag Selection")); + + TextModel::PointList points = + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + + for (TextModel::PointList::iterator i = points.begin(); + i != points.end(); ++i) { + + if (s.contains(i->frame)) { + TextModel::Point newPoint(*i); + newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); + command->deletePoint(*i); + command->addPoint(newPoint); + } + } + + command->finish(); +} + +void +TextLayer::resizeSelection(Selection s, Selection newSize) +{ + TextModel::EditCommand *command = + new TextModel::EditCommand(m_model, tr("Resize Selection")); + + TextModel::PointList points = + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + + double ratio = + double(newSize.getEndFrame() - newSize.getStartFrame()) / + double(s.getEndFrame() - s.getStartFrame()); + + for (TextModel::PointList::iterator i = points.begin(); + i != points.end(); ++i) { + + if (s.contains(i->frame)) { + + double target = i->frame; + target = newSize.getStartFrame() + + double(target - s.getStartFrame()) * ratio; + + TextModel::Point newPoint(*i); + newPoint.frame = lrint(target); + command->deletePoint(*i); + command->addPoint(newPoint); + } + } + + command->finish(); +} + QString TextLayer::toXmlString(QString indent, QString extraAttributes) const {