Example #1
0
bool GiCoreView::redo(GiView* view)
{
    MgRecordShapes* recorder = impl->recorder(true);
    bool ret = false;
    long changeCount = impl->changeCount;
    
    if (recorder) {
        recorder->setLoading(true);
        ret = recorder->redo(impl->getShapeFactory(), impl->doc(), &changeCount);
        if (ret) {
            submitBackDoc(view, true);
            submitDynamicShapes(view);
            giAtomicCompareAndSwap(&impl->changeCount, changeCount, impl->changeCount);
            recorder->resetDoc(MgShapeDoc::fromHandle(acquireFrontDoc()));
            impl->regenAll(true);
            impl->hideContextActions();
        }
        recorder->setLoading(false);
    }
    if (ret) {
        impl->getCmdSubject()->onDocLoaded(impl->motion());
    }
    
    return ret;
}
Example #2
0
bool GiCoreView::onPause(long curTick)
{
    bool ret = giAtomicCompareAndSwap(&impl->startPauseTick, curTick, 0);
    if (!ret) {
        LOGE("Fail to set startPauseTick via giAtomicCompareAndSwap");
    }
    return ret;
}
Example #3
0
bool GiCoreView::restoreRecord(int type, const char* path, long doc, long changeCount,
                               int index, int count, int tick, long curTick)
{
    MgRecordShapes* recorder = impl->recorder(type == 0);
    if (recorder || !path)
        return false;
    
    recorder = new MgRecordShapes(path, MgShapeDoc::fromHandle(doc), type == 0, curTick);
    recorder->restore(index, count, tick, curTick);
    impl->setRecorder(type == 0, recorder);
    
    if (type == 0 && changeCount != 0) {
        giAtomicCompareAndSwap(&impl->changeCount, changeCount, impl->changeCount);
    }
    
    return true;
}
Example #4
0
bool GiCoreView::onResume(long curTick)
{
    long startPauseTick = impl->startPauseTick;
    
    if (startPauseTick != 0
        && giAtomicCompareAndSwap(&impl->startPauseTick, 0, startPauseTick)) {
        long ticks = curTick - startPauseTick;
        if (impl->recorder(true) && !impl->recorder(true)->onResume(ticks)) {
            LOGE("recorder(true)->onResume(%ld) fail", ticks);
            return false;
        }
        if (impl->recorder(false) && !impl->recorder(false)->onResume(ticks)) {
            LOGE("recorder(false)->onResume(%ld) fail", ticks);
            return false;
        }
        return true;
    }
    
    return false;
}
Example #5
0
bool GiCoreView::onPause(long curTick)
{
    return giAtomicCompareAndSwap(&impl->startPauseTick, curTick, 0);
}