Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
42:1bdf285c4eac | 43:78515b1e29eb |
---|---|
587 new TextModel::RelabelCommand(m_model, *points.begin(), label); | 587 new TextModel::RelabelCommand(m_model, *points.begin(), label); |
588 CommandHistory::getInstance()->addCommand(command, true); | 588 CommandHistory::getInstance()->addCommand(command, true); |
589 } | 589 } |
590 } | 590 } |
591 | 591 |
592 void | |
593 TextLayer::moveSelection(Selection s, size_t newStartFrame) | |
594 { | |
595 TextModel::EditCommand *command = | |
596 new TextModel::EditCommand(m_model, tr("Drag Selection")); | |
597 | |
598 TextModel::PointList points = | |
599 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
600 | |
601 for (TextModel::PointList::iterator i = points.begin(); | |
602 i != points.end(); ++i) { | |
603 | |
604 if (s.contains(i->frame)) { | |
605 TextModel::Point newPoint(*i); | |
606 newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); | |
607 command->deletePoint(*i); | |
608 command->addPoint(newPoint); | |
609 } | |
610 } | |
611 | |
612 command->finish(); | |
613 } | |
614 | |
615 void | |
616 TextLayer::resizeSelection(Selection s, Selection newSize) | |
617 { | |
618 TextModel::EditCommand *command = | |
619 new TextModel::EditCommand(m_model, tr("Resize Selection")); | |
620 | |
621 TextModel::PointList points = | |
622 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
623 | |
624 double ratio = | |
625 double(newSize.getEndFrame() - newSize.getStartFrame()) / | |
626 double(s.getEndFrame() - s.getStartFrame()); | |
627 | |
628 for (TextModel::PointList::iterator i = points.begin(); | |
629 i != points.end(); ++i) { | |
630 | |
631 if (s.contains(i->frame)) { | |
632 | |
633 double target = i->frame; | |
634 target = newSize.getStartFrame() + | |
635 double(target - s.getStartFrame()) * ratio; | |
636 | |
637 TextModel::Point newPoint(*i); | |
638 newPoint.frame = lrint(target); | |
639 command->deletePoint(*i); | |
640 command->addPoint(newPoint); | |
641 } | |
642 } | |
643 | |
644 command->finish(); | |
645 } | |
646 | |
592 QString | 647 QString |
593 TextLayer::toXmlString(QString indent, QString extraAttributes) const | 648 TextLayer::toXmlString(QString indent, QString extraAttributes) const |
594 { | 649 { |
595 return Layer::toXmlString(indent, extraAttributes + | 650 return Layer::toXmlString(indent, extraAttributes + |
596 QString(" colour=\"%1\"") | 651 QString(" colour=\"%1\"") |