virtual bool onEvent(const SkEvent& evt) {
        if (evt.isType(gReplaceTransitionEvt)) {
            SkView* prev = fPrev;
            prev->ref();

            fPrev->detachFromParent();
            fPrev = (SkView*)SkEventSink::FindSink(evt.getFast32());
            (void)SampleView::SetUsePipe(fPrev, SkOSMenu::kOffState);
            //attach the new fPrev and call unref to balance the ref in onDraw
            this->attachChildToBack(fPrev)->unref();
            this->inval(NULL);

            SkASSERT(1 == prev->getRefCnt());
            prev->unref();
            return true;
        }
        if (evt.isType("transition-done")) {
            fNext->setLoc(0, 0);
            fNext->setClipToBounds(false);
            SkEvent* evt = new SkEvent(gReplaceTransitionEvt,
                                       this->getParent()->getSinkID());
            evt->setFast32(fNext->getSinkID());
            //increate ref count of fNext so it survives detachAllChildren
            fNext->ref();
            this->detachAllChildren();
            evt->post();
            return true;
        }
        return this->INHERITED::onEvent(evt);
    }
示例#2
0
文件: Global.cpp 项目: Coolred/skia
// The callback that is invoked by v8 whenever the JavaScript 'setTimeout'
// function is called.
//
// JS: setTimeout(on_timeout, 500);
void Global::SetTimeout(const v8::FunctionCallbackInfo<v8::Value>& args) {
    if (args.Length() != 2) {
        args.GetIsolate()->ThrowException(
                v8::String::NewFromUtf8(
                        args.GetIsolate(), "Error: 2 arguments required."));
        return;
    }

    // Pull out the first arg, make sure it's a function.
    if (!args[0]->IsFunction()) {
        printf("Not a function passed to setTimeout.\n");
        return;
    }
    Handle<Function> timeoutFn = Handle<Function>::Cast(args[0]);

    double delay = args[1]->NumberValue();
    int32_t id = gGlobal->getNextTimerID();

    gGlobal->fTimeouts[id].Reset(gGlobal->fIsolate, timeoutFn);

    // Create an SkEvent and add it with the right delay.
    SkEvent* evt = new SkEvent();
    evt->setTargetProc(Global::TimeOutProc);
    evt->setFast32(id);
    evt->postDelay(delay);

    args.GetReturnValue().Set(Integer::New(gGlobal->fIsolate, id));
}
示例#3
0
	virtual SkEvent* getEvent(int index)
	{
		SkASSERT((unsigned)index < (unsigned)fCount);

		if (fList[index].fType == kDir_Type)
		{
			SkEvent* evt = new SkEvent();
			evt->setType(fList[index].fTarget);
			evt->setFast32(index);
			return evt;
		}
		if (fList[index].fType == kToggle_Type)
			fList[index].fTail.swap(fList[index].fAltTail);

		return NULL;
	}
示例#4
0
void SkListView::setSelection(int index)
{
	if (fCurrIndex != index)
	{
		this->invalSelection();
		fCurrIndex = index;
		this->invalSelection();
		this->ensureSelectionIsVisible();

		{
			SkEvent	evt;
			evt.setType("listview-selection");
			evt.setFast32(index);
			this->sendEventToParents(evt);
		}
	}
}
示例#5
0
SkEvent* SkOSMenu::createEvent(uint32_t os_cmd)
{
	const Item* iter = fItems.begin();
	const Item*	stop = fItems.end();

	while (iter < stop)
	{
		if (iter->fOSCmd == os_cmd)
		{
			SkEvent* evt = new SkEvent(iter->fEventType);
			evt->setFast32(iter->fEventData);
			return evt;
		}
		iter++;
	}
	return NULL;
}
示例#6
0
void SkSliderView::setValue(U16CPU value)
{
	if (fValue != value)
	{
		U16 prev = actual_value(fValue, fMax);
		U16 next = actual_value(value, fMax);

		fValue = SkToU16(value);
		if (prev != next)
		{
			this->inval(nil);

			if (this->hasListeners())
			{
				SkEvent	evt;
				
				evt.setType(SkWidgetView::GetEventType());
				evt.setFast32(this->getSinkID());
				evt.setS32("sliderValue", next);
				this->postToListeners(evt);
			}
		}
	}
}
SkEvent* GMSampleView::NewShowSizeEvt(bool doShowSize) {
    SkEvent* evt = new SkEvent("GMSampleView::showSize");
    evt->setFast32(doShowSize);
    return evt;
}