SkBorderView::SkBorderView() : fLeft(SkIntToScalar(0)), fRight(SkIntToScalar(0)), fTop(SkIntToScalar(0)), fBottom(SkIntToScalar(0)) { fAnim.setHostEventSink(this); init_skin_anim(kBorder_SkinEnum, &fAnim); }
SkProgressBarView::SkProgressBarView() { init_skin_anim(kProgress_SkinEnum, &fAnim); fAnim.setHostEventSink(this); fProgress = 0; fMax = 100; }
void init_skin_paint(SkinEnum se, SkPaint* paint) { SkASSERT(paint); SkAnimator anim; SkCanvas canvas; init_skin_anim(se, &anim); anim.draw(&canvas, paint, 0); }
SkScrollBarView::SkScrollBarView() { fAnim.setHostEventSink(this); init_skin_anim(kScroll_SkinEnum, &fAnim); fTotalLength = 0; fStartPoint = 0; fShownLength = 0; this->adjust(); }
bool SkListView::ensureCache() { if (fSkinName.size() == 0) return false; if (fAnims == NULL) { int n = SkMax32(1, fVisibleRowCount); SkASSERT(fAnimContentDirty); fAnims = new SkAnimator[n]; for (int i = 0; i < n; i++) { fAnims[i].setHostEventSink(this); init_skin_anim(fSkinName.c_str(), &fAnims[i]); } fHeights[kNormal_Height] = fAnims[0].getScalar("idleHeight", "value"); fHeights[kSelected_Height] = fAnims[0].getScalar("focusedHeight", "value"); fAnimFocusDirty = true; } if (fAnimContentDirty && fSource) { fAnimContentDirty = false; SkString str; SkEvent evt("user"); evt.setString("id", "setFields"); evt.setS32("rowCount", fVisibleRowCount); SkEvent dimEvt("user"); dimEvt.setString("id", "setDim"); dimEvt.setScalar("dimX", this->getContentWidth()); dimEvt.setScalar("dimY", this->height()); for (int i = fScrollIndex; i < fScrollIndex + fVisibleRowCount; i++) { evt.setS32("relativeIndex", i - fScrollIndex); for (int j = 0; j < fBindingCount; j++) { fSource->getRecord(i, fBindings[j].fFieldIndex, &str); //SkDEBUGF(("getRecord(%d,%d,%s) slot(%s)\n", i, fBindings[j].fFieldIndex, str.c_str(), fBindings[j].fSlotName.c_str())); evt.setString(fBindings[j].fSlotName.c_str(), str.c_str()); } (void)fAnims[i % fVisibleRowCount].doUserEvent(evt); (void)fAnims[i % fVisibleRowCount].doUserEvent(dimEvt); } fAnimFocusDirty = true; } if (fAnimFocusDirty) { //SkDEBUGF(("service fAnimFocusDirty\n")); fAnimFocusDirty = false; SkEvent focusEvt("user"); focusEvt.setString("id", "setFocus"); for (int i = fScrollIndex; i < fScrollIndex + fVisibleRowCount; i++) { focusEvt.setS32("FOCUS", i == fCurrIndex); (void)fAnims[i % fVisibleRowCount].doUserEvent(focusEvt); } } return true; }
void SkBorderView::setSkin(const char skin[]) { init_skin_anim(skin, &fAnim); }
void init_skin_anim(SkinEnum se, SkAnimator* anim) { init_skin_anim(get_skin_enum_path(se), anim); }