Esempio n. 1
0
	virtual SkEvent* getEvent(int index)
	{
		SkASSERT((unsigned)index < (unsigned)fCount);

		SkEvent*	evt = new SkEvent();
		SkString	label;

		this->getRow(index, &label, NULL);
		evt->setString("name", label.c_str());

		int c = fPath.c_str()[fPath.size() - 1];
		if (c != '/' && c != '\\')
			label.prepend("/");
		label.prepend(fPath);
		label.append(fSuffix);
		evt->setString("path", label.c_str());
		evt->setS32("index", index);
		evt->setS32("duration", 22);
		evt->setType(fTarget);
		return evt;
	}
Esempio n. 2
0
int SkOSMenu::appendList(const char label[], const char slotName[],
                         SkEventSinkID target, int index, const char option[], ...) {
    SkEvent* evt = new SkEvent(gMenuEventType, target);
    va_list args;
    if (option) {
        SkString str(option);
        va_start(args, option);
        int count = 1;
        for (const char* arg = va_arg(args, const char*); arg != NULL; arg = va_arg(args, const char*)) {
            str += gDelimiter;
            str += arg;
            ++count;
        }
        va_end(args);
        evt->setString(gList_Items_Str, str);
        evt->setS32(gList_ItemCount_S32, count);
        evt->setS32(slotName, index);
    }
    return appendItem(label, SkOSMenu::kList_Type, slotName, evt);
}
void SkAnimatorScript::UnitTest() {
#if defined(SK_SUPPORT_UNITTEST)
    SkAnimator animator;
    SkASSERT(animator.decodeMemory(scriptTestSetup, sizeof(scriptTestSetup)-1));
    SkEvent evt;
    evt.setString("id", "evt");
    evt.setS32("x", 3);
    animator.doUserEvent(evt);
    // set up animator with memory script above, then run value tests
    for (unsigned index = 0; index < SkScriptNAnswer_testCount; index++) {
        SkAnimatorScript engine(*animator.fMaker, NULL, scriptTests[index].fType);
        SkScriptValue value;
        const char* script = scriptTests[index].fScript;
        bool success = engine.evaluateScript(&script, &value);
        if (success == false) {
            SkDebugf("script failed: %s\n", scriptTests[index].fScript);
            SkASSERT(scriptTests[index].fType == SkType_Unknown);
            continue;
        }
        SkASSERT(value.fType == scriptTests[index].fType);
        SkScalar error;
        switch (value.fType) {
            case SkType_Int:
                SkASSERT(value.fOperand.fS32 == scriptTests[index].fIntAnswer);
                break;
            case SkType_Float:
                error = SkScalarAbs(value.fOperand.fScalar - scriptTests[index].fScalarAnswer);
                SkASSERT(error < SK_Scalar1 / 10000);
                break;
            case SkType_String:
                SkASSERT(strcmp(value.fOperand.fString->c_str(), scriptTests[index].fStringAnswer) == 0);
                break;
            default:
                SkASSERT(0);
        }
    }
#endif
}
Esempio n. 4
0
int SkOSMenu::appendTextField(const char label[], const char slotName[],
                              SkEventSinkID target, const char placeholder[]) {
    SkEvent* evt = new SkEvent(gMenuEventType, target);
    evt->setString(slotName, placeholder);
    return appendItem(label, SkOSMenu::kTextField_Type, slotName, evt);
}
Esempio n. 5
0
int SkOSMenu::appendAction(const char label[], SkEventSinkID target) {
    SkEvent* evt = new SkEvent(gMenuEventType, target);
    //Store label in event so it can be used to identify the action later
    evt->setString(label, label);
    return appendItem(label, SkOSMenu::kAction_Type, "", evt);
}