コード例 #1
0
bool SkListView::onEvent(const SkEvent& evt)
{
	if (evt.isType(SK_EventType_Key))
	{
		switch (evt.getFast32()) {
		case kUp_SkKey:
			this->moveSelectionUp();
			return true;
		case kDown_SkKey:
			this->moveSelectionDown();
			return true;
		case kRight_SkKey:
		case kOK_SkKey:
			if (fSource && fCurrIndex >= 0)
			{
				SkEvent* evt = fSource->getEvent(fCurrIndex);
				if (evt)
				{
					SkView* view = this->sendEventToParents(*evt);
					delete evt;
					return view != NULL;
				}
				else	// hack to make toggle work
				{
					this->dirtyStrCache();
					this->inval(NULL);
				}
			}
			break;
		}
	}
	return this->INHERITED::onEvent(evt);
}
コード例 #2
0
bool GMSampleView::onEvent(const SkEvent& evt) {
    if (evt.isType("GMSampleView::showSize")) {
        fShowSize = SkToBool(evt.getFast32());
        return true;
    }
    return this->INHERITED::onEvent(evt);
}
コード例 #3
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));
}
コード例 #4
0
bool SkGridView::onEvent(const SkEvent& evt)
{
	if (evt.isType(SK_EventType_Key))
	{
		switch (evt.getFast32()) {
		case kUp_SkKey:
			this->moveSelectionUp();
			return true;
		case kDown_SkKey:
			this->moveSelectionDown();
			return true;
		case kRight_SkKey:
		case kOK_SkKey:
			if (fSource && fCurrIndex >= 0)
			{
				SkEvent* evt = fSource->getEvent(fCurrIndex);
				if (evt)
				{
					// augment the event with our local rect
					(void)this->getCellRect(fCurrIndex, (SkRect*)evt->setScalars("local-rect", 4, NULL));

					SkView* view = this->sendEventToParents(*evt);
					delete evt;
					return view != NULL;
				}
			}
			break;
		}
	}
	return this->INHERITED::onEvent(evt);
}
コード例 #5
0
ファイル: SkAnimateMaker.cpp プロジェクト: ghub/NVprSDK
void SkAnimateMaker::postOnEnd(SkAnimateBase* animate, SkMSec end) {
        SkEvent evt;
        evt.setS32("time", animate->getStart() + end);
        evt.setPtr("anim", animate);
        evt.setType(SK_EventType_OnEnd);
        SkEventSinkID sinkID = fAnimator->getSinkID();
        fAnimator->onEventPost(new SkEvent(evt), sinkID);
}
コード例 #6
0
void SkGridView::onDraw(SkCanvas* canvas)
{
	this->INHERITED::onDraw(canvas);

	canvas->drawPaint(fPaint[kBG_Attr]);

	if (fSource == NULL)
		return;

#if 0
	int	visibleCount = SkMin32(fVisibleRowCount, fSource->countRows() - fScrollIndex);
	if (visibleCount == 0)
		return;

	this->ensureStrCache(visibleCount);
	int currIndex = this->logicalToVisualIndex(fCurrIndex);
#endif

	SkPaint	p;
	for (int i = 0; i < fSource->countRows(); i++)
	{
		bool	 forced = false;
		SkEvent* evt = fSource->getEvent(i);
		SkASSERT(evt);
		SkString path(evt->findString("path"));
		delete evt;

		SkBitmapRef* bmr = SkBitmapRef::Decode(path.c_str(), false);
		if (bmr == NULL)
		{
			bmr = SkBitmapRef::Decode(path.c_str(), true);
			if (bmr)
				forced = true;
		}

		if (bmr)
		{
			SkAutoTDelete<SkBitmapRef>	autoRef(bmr);
			SkRect	r;
			if (!this->getCellRect(i, &r))
				break;
			copybits(canvas, bmr->bitmap(), r, p);
		}
		// only draw one forced bitmap at a time
		if (forced)
		{
			this->inval(NULL);	// could inval only the remaining visible cells...
			break;
		}
	}

	// draw the hilite
	{
		SkRect	r;
		if (fCurrIndex >= 0 && this->getCellRect(fCurrIndex, &r))
			canvas->drawRect(r, fPaint[kHiliteCell_Attr]);
	}
}
コード例 #7
0
ファイル: app-android.cpp プロジェクト: Beifeng/WTL-DUI
bool SampleCode::KeyQ(const SkEvent& evt, SkKey* outKey) {
    if (evt.isType(gKeyEvtName, sizeof(gKeyEvtName) - 1)) {
        if (outKey) {
            *outKey = (SkKey)evt.getFast32();
        }
        return true;
    }
    return false;
}
コード例 #8
0
int SkOSMenu::appendSlider(const char label[], const char slotName[],
                           SkEventSinkID target, SkScalar min, SkScalar max,
                           SkScalar defaultValue) {
    SkEvent* evt = new SkEvent(gMenuEventType, target);
    evt->setScalar(gSlider_Min_Scalar, min);
    evt->setScalar(gSlider_Max_Scalar, max);
    evt->setScalar(slotName, defaultValue);
    return appendItem(label, SkOSMenu::kSlider_Type, slotName, evt);
}
コード例 #9
0
ファイル: app-android.cpp プロジェクト: Beifeng/WTL-DUI
bool SampleCode::CharQ(const SkEvent& evt, SkUnichar* outUni) {
    if (evt.isType(gCharEvtName, sizeof(gCharEvtName) - 1)) {
        if (outUni) {
            *outUni = evt.getFast32();
        }
        return true;
    }
    return false;
}
コード例 #10
0
bool SkOSMenu::FindText(const SkEvent& evt, const char slotName[], SkString* value) {
    if (evt.isType(gMenuEventType)) {
        const char* text = evt.findString(slotName);
        if (!text || !*text)
            return false;
        else {
            value->set(text);
            return true;
        }
    }
    return false;
}
コード例 #11
0
ファイル: SkEventSink.cpp プロジェクト: venkatarajasekhar/Qt
void SkEventSink::postToListeners(const SkEvent& evt, SkMSec delay) {
    SkListenersTagList* list = (SkListenersTagList*)this->findTagList(kListeners_SkTagList);
    if (list) {
        SkASSERT(list->countListners() > 0);
        const SkEventSinkID* iter = list->fIDs;
        const SkEventSinkID* stop = iter + list->countListners();
        while (iter < stop) {
            SkEvent* copy = SkNEW_ARGS(SkEvent, (evt));
            copy->setTargetID(*iter++)->postDelay(delay);
        }
    }
}
コード例 #12
0
ファイル: SkEventSink.cpp プロジェクト: venkatarajasekhar/Qt
SkEventSink::EventResult SkEventSink::DoEvent(const SkEvent& evt) {
    SkEvent::Proc proc = evt.getTargetProc();
    if (proc) {
        return proc(evt) ? kHandled_EventResult : kNotHandled_EventResult;
    }

    SkEventSink* sink = SkEventSink::FindSink(evt.getTargetID());
    if (sink) {
        return sink->doEvent(evt) ? kHandled_EventResult : kNotHandled_EventResult;
    }

    return kSinkNotFound_EventResult;
}
コード例 #13
0
ファイル: SkInfoPanelView.cpp プロジェクト: BBKeeper/Skia
bool SkInfoPanelView::onEvent(const SkEvent& evt) {
    if (evt.isType(SkDebugger_StateType)) {
        fMatrix = evt.findString(SkDebugger_Matrix);
        fClip = evt.findString(SkDebugger_Clip);
        
        SkPaint* ptr;
        if (evt.getMetaData().findPtr(SkDebugger_Paint, (void**)&ptr)) {
            fPaint = *ptr;
            fPaintInfo = evt.findString(SkDebugger_PaintInfo);
        }
        this->inval(NULL);
        return true;
    }
    return this->INHERITED::onEvent(evt);
}
コード例 #14
0
ファイル: SampleApp.cpp プロジェクト: avary/skia
bool SampleWindow::onEvent(const SkEvent& evt) {
    if (evt.isType(ANIMATING_EVENTTYPE)) {
        if (fAnimating) {
            this->nextSample();
            this->postAnimatingEvent();
        }
        return true;
    }
    if (evt.isType("set-curr-index")) {
        fCurrIndex = evt.getFast32() % fSamples.count();
        this->loadView(fSamples[fCurrIndex]());
        return true;
    }
    return this->INHERITED::onEvent(evt);
}
コード例 #15
0
ファイル: SamplePicture.cpp プロジェクト: Arternis/skia
 bool onEvent(const SkEvent& evt) override {
     if (evt.isType(INVAL_ALL_TYPE)) {
         this->inval(NULL);
         return true;
     }
     return this->INHERITED::onEvent(evt);
 }
コード例 #16
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;
	}
コード例 #17
0
bool SkOSMenu::FindListItems(const SkEvent& evt, SkString items[]) {
    if (evt.isType(gMenuEventType) && items) {
        const char* text = evt.findString(gList_Items_Str);
        if (text != NULL) {
            SkString temp(text);
            char* token = strtok((char*)temp.c_str(), gDelimiter);
            int index = 0;
            while (token != NULL) {
                items[index].set(token, strlen(token));
                token = strtok (NULL, gDelimiter);
                ++index;
            }
        }
        return true;
    }
    return false;
}
コード例 #18
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;
}
コード例 #19
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);
		}
	}
}
コード例 #20
0
ファイル: SkProgressBarView.cpp プロジェクト: 3rdexp/soui
/*virtual*/ bool SkProgressBarView::onEvent(const SkEvent& evt)
{
    if (evt.isType(SK_EventType_Inval))
    {
        this->inval(NULL);
        return true;
    }
    if (evt.isType("recommendDim"))
    {
        SkScalar    height;

        if (evt.findScalar("y", &height))
            this->setHeight(height);
        return true;
    }
    return this->INHERITED::onEvent(evt);
}
コード例 #21
0
ファイル: SkWindow.cpp プロジェクト: nikolayvoronchikhin/skia
bool SkWindow::onEvent(const SkEvent& evt) {
    if (evt.isType(SK_EventDelayInval)) {
        for (SkRegion::Iterator iter(fDirtyRgn); !iter.done(); iter.next())
            this->onHandleInval(iter.rect());
        fWaitingOnInval = false;
        return true;
    }
    return this->INHERITED::onEvent(evt);
}
コード例 #22
0
ファイル: SkOSWindow_Unix.cpp プロジェクト: jamorton/blix
bool SkOSWindow::onEvent(const SkEvent& evt) {
    if (evt.isType("inval-imageview")) {
        update(NULL);
        if (NULL == fUnixWindow.fGLContext)
            this->doPaint();
        return true;
    }
    return INHERITED::onEvent(evt);
}
コード例 #23
0
bool SkOSWindow::onEvent(const SkEvent& evt)
{
    if (evt.isType("inval-imageview")) {
        update(NULL);
        doPaint();
        return true;
    }
    return INHERITED::onEvent(evt);
}
コード例 #24
0
ファイル: SkScrollBarView.cpp プロジェクト: ghub/NVprSDK
/*virtual*/ bool SkScrollBarView::onEvent(const SkEvent& evt)
{
	if (evt.isType(SK_EventType_Inval))
	{
		this->inval(NULL);
		return true;
	}
	if (evt.isType("recommendDim"))
	{
		SkScalar	width;
		
		if (evt.findScalar("x", &width))
			this->setWidth(width);
		return true;
	}

	return this->INHERITED::onEvent(evt);
}
コード例 #25
0
ファイル: SkAnimator.cpp プロジェクト: 03050903/skia
bool SkAnimator::onEvent(const SkEvent& evt) {
#ifdef SK_DEBUG
    SkAnimator* root = fMaker->getRoot();
    if (root == nullptr)
        root = this;
    if (root->isTrackingEvents())
        root->eventDone(evt);
#endif
    if (evt.isType(SK_EventType_OnEnd)) {
        SkEventState eventState;
        SkDEBUGCODE(bool success =) evt.findPtr("anim", (void**) &eventState.fDisplayable);
        SkASSERT(success);
        SkDEBUGCODE(success =) evt.findS32("time", (int32_t*) &fMaker->fEnableTime);
        SkASSERT(success);
        fMaker->fAdjustedStart = fMaker->getAppTime() - fMaker->fEnableTime;
        fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kOnEnd, &eventState);
        fMaker->fAdjustedStart = 0;
        goto inval;
    }
コード例 #26
0
bool SkListView::onEvent(const SkEvent& evt)
{
	if (evt.isType(SK_EventType_Key))
	{
		switch (evt.getFast32()) {
		case kUp_SkKey:
			return this->moveSelectionUp();
		case kDown_SkKey:
			return this->moveSelectionDown();
		case kRight_SkKey:
		case kOK_SkKey:
			this->postWidgetEvent();
			return true;
		default:
			break;
		}
	}
	return this->INHERITED::onEvent(evt);
}
コード例 #27
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);
}
コード例 #28
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;
	}
コード例 #29
0
    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);
    }
コード例 #30
0
/*virtual*/ bool SkBorderView::onEvent(const SkEvent& evt)
{
	if (evt.isType(SK_EventType_Inval))
	{
		this->inval(NULL);
		return true;
	}
	if (evt.isType("recommendDim"))
	{
		evt.findScalar("leftMargin", &fLeft);
		evt.findScalar("rightMargin", &fRight);
		evt.findScalar("topMargin", &fTop);
		evt.findScalar("bottomMargin", &fBottom);
	
		//setup_views.cpp uses SkView::Layout instead of SkStackViewLayout
		//but that gives me an error
		SkStackViewLayout* layout;
		fMargin.set(fLeft, fTop, fRight, fBottom);
		if (this->getLayout())
		{
			layout = (SkStackViewLayout*)this->getLayout();
			layout->setMargin(fMargin);
		}
		else
		{
			layout = new SkStackViewLayout;
			layout->setMargin(fMargin);
			this->setLayout(layout)->unref();
		}
		this->invokeLayout();
	}
	return this->INHERITED::onEvent(evt);
}