本文整理汇总了C++中SkEvent类的典型用法代码示例。如果您正苦于以下问题:C++ SkEvent类的具体用法?C++ SkEvent怎么用?C++ SkEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
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: onEvent
bool GMSampleView::onEvent(const SkEvent& evt) {
if (evt.isType("GMSampleView::showSize")) {
fShowSize = SkToBool(evt.getFast32());
return true;
}
return this->INHERITED::onEvent(evt);
}
示例3: printf
// 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: SkEvent
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);
}
示例5: SkMin32
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]);
}
}
示例6: KeyQ
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;
}
示例7: SkEvent
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);
}
示例8: CharQ
bool SampleCode::CharQ(const SkEvent& evt, SkUnichar* outUni) {
if (evt.isType(gCharEvtName, sizeof(gCharEvtName) - 1)) {
if (outUni) {
*outUni = evt.getFast32();
}
return true;
}
return false;
}
示例9: FindText
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;
}
示例10: SkASSERT
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);
}
}
}
示例11: proc
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;
}
示例12: onEvent
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);
}
示例13: onEvent
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);
}
示例14: onEvent
bool onEvent(const SkEvent& evt) override {
if (evt.isType(INVAL_ALL_TYPE)) {
this->inval(NULL);
return true;
}
return this->INHERITED::onEvent(evt);
}
示例15: getEvent
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;
}