Example #1
0
bool GiCoreViewImpl::gestureToCommand(const MgMotion& motion)
{
    MgDynShapeLock locker(true, motion.view);
    MgCommand* cmd = _cmds->getCommand();
    bool ret = false;

    if (motion.gestureState == kMgGestureCancel || !cmd) {
        return cmd && cmd->cancel(&motion);
    }
    if (motion.gestureState == kMgGesturePossible
        && motion.gestureType != kGiTwoFingersMove) {
        return true;
    }

    switch (motion.gestureType)
    {
    case kGiTwoFingersMove:
        ret = cmd->twoFingersMove(&motion);
        break;
    case kGiGesturePan:
        switch (motion.gestureState)
        {
        case kMgGestureBegan:
            ret = cmd->touchBegan(&motion);
            break;
        case kMgGestureMoved:
            ret = cmd->touchMoved(&motion);
            break;
        case kMgGestureEnded:
        default:
            ret = cmd->touchEnded(&motion);
            break;
        }
        break;
    case kGiGestureTap:
        ret = cmd->click(&motion);
        break;
    case kGiGestureDblTap:
        ret = cmd->doubleClick(&motion);
        break;
    case kGiGesturePress:
        ret = cmd->longPress(&motion);
        break;
    }

    if (!ret) {
        LOGD("The current command (%s) don't support #%d gesture (state=%d)",
            cmd->getName(), motion.gestureType, motion.gestureState);
    }
    return ret;
}
Example #2
0
bool GiCoreView::loadShapes(MgStorage* s)
{
    bool ret = true;

    impl->setCommand(&impl->motion, impl->getCommandName());
    MgCommand* cmd = impl->getCommand();
    if (cmd) cmd->cancel(&impl->motion);

    if (s) {
        MgShapesLock locker(MgShapesLock::Load, impl);
        ret = impl->doc()->load(impl->getShapeFactory(), s);
        LOGD("Load %d shapes", impl->doc()->getShapeCount());
    }
    else {
        MgShapesLock locker(MgShapesLock::Remove, impl);
        impl->doc()->clear();
    }
    impl->regenAll();
    impl->getCmdSubject()->onDocLoaded(&impl->motion);

    return ret;
}