本文整理汇总了C++中DocumentApi::moveFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentApi::moveFrame方法的具体用法?C++ DocumentApi::moveFrame怎么用?C++ DocumentApi::moveFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentApi
的用法示例。
在下文中一共展示了DocumentApi::moveFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reverse_frames
void reverse_frames(Document* doc, const DocumentRange& range)
{
const app::Context* context = static_cast<app::Context*>(doc->context());
const ContextReader reader(context);
ContextWriter writer(reader);
Transaction transaction(writer.context(), "Reverse Frames");
DocumentApi api = doc->getApi(transaction);
Sprite* sprite = doc->sprite();
frame_t frameBegin, frameEnd;
int layerBegin, layerEnd;
bool moveFrames = false;
switch (range.type()) {
case DocumentRange::kCels:
frameBegin = range.frameBegin();
frameEnd = range.frameEnd();
layerBegin = range.layerBegin();
layerEnd = range.layerEnd() + 1;
break;
case DocumentRange::kFrames:
frameBegin = range.frameBegin();
frameEnd = range.frameEnd();
moveFrames = true;
break;
case DocumentRange::kLayers:
frameBegin = frame_t(0);
frameEnd = sprite->totalFrames()-1;
layerBegin = range.layerBegin();
layerEnd = range.layerEnd() + 1;
break;
}
if (moveFrames) {
for (frame_t frameRev = frameEnd+1;
frameRev > frameBegin;
--frameRev) {
api.moveFrame(sprite, frameBegin, frameRev);
}
}
else {
std::vector<Layer*> layers;
sprite->getLayersList(layers);
for (int layerIdx = layerBegin; layerIdx != layerEnd; ++layerIdx) {
for (frame_t frame = frameBegin,
frameRev = frameEnd;
frame != (frameBegin+frameEnd)/2+1;
++frame, --frameRev) {
LayerImage* layer = static_cast<LayerImage*>(layers[layerIdx]);
api.swapCel(layer, frame, frameRev);
}
}
}
transaction.commit();
}
示例2: drop_range_op
//.........这里部分代码省略.........
dstFrameBegin = to.frameBegin();
dstFrameStep = frame_t(1);
}
else {
srcFrameBegin = from.frameEnd();
srcFrameStep = frame_t(-1);
srcFrameEnd = from.frameBegin()-1;
dstFrameBegin = to.frameBegin();
dstFrameStep = frame_t(0);
}
}
else if (place == kDocumentRangeAfter) {
if (to.frameEnd() <= from.frameBegin()) {
srcFrameBegin = from.frameBegin();
srcFrameStep = frame_t(2);
srcFrameEnd = from.frameBegin() + 2*from.frames();
dstFrameBegin = to.frameEnd()+1;
dstFrameStep = frame_t(1);
}
else {
srcFrameBegin = from.frameEnd();
srcFrameStep = frame_t(-1);
srcFrameEnd = from.frameBegin()-1;
dstFrameBegin = to.frameEnd()+1;
dstFrameStep = frame_t(0);
}
}
break;
}
for (frame_t srcFrame = srcFrameBegin,
dstFrame = dstFrameBegin; srcFrame != srcFrameEnd; ) {
switch (op) {
case Move: api.moveFrame(sprite, srcFrame, dstFrame); break;
case Copy: api.copyFrame(sprite, srcFrame, dstFrame); break;
}
srcFrame += srcFrameStep;
dstFrame += dstFrameStep;
}
if (place == kDocumentRangeBefore) {
resultRange.startRange(LayerIndex::NoLayer, frame_t(to.frameBegin()), from.type());
resultRange.endRange(LayerIndex::NoLayer, frame_t(to.frameBegin()+from.frames()-1));
}
else if (place == kDocumentRangeAfter) {
resultRange.startRange(LayerIndex::NoLayer, frame_t(to.frameEnd()+1), from.type());
resultRange.endRange(LayerIndex::NoLayer, frame_t(to.frameEnd()+1+from.frames()-1));
}
if (op == Move && from.frameBegin() < to.frameBegin())
resultRange.displace(0, -from.frames());
}
break;
case DocumentRange::kLayers:
{
std::vector<Layer*> layers;
sprite->getLayersList(layers);
if (layers.empty())
break;
switch (op) {
case Move:
if (place == kDocumentRangeBefore) {