From e9f40436733c7652c9118a43454823a03329921d Mon Sep 17 00:00:00 2001 From: houzh Date: Sat, 30 Dec 2023 23:49:35 +0800 Subject: [PATCH] drawablecontainer.s fading in/out tested OK --- src/gui/drawables/bitmapdrawable.cc | 1 + src/gui/drawables/drawable.cc | 12 +++++++----- src/gui/drawables/drawablecontainer.cc | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/gui/drawables/bitmapdrawable.cc b/src/gui/drawables/bitmapdrawable.cc index f53ebba8..2fc4e211 100755 --- a/src/gui/drawables/bitmapdrawable.cc +++ b/src/gui/drawables/bitmapdrawable.cc @@ -43,6 +43,7 @@ BitmapDrawable::BitmapState::BitmapState(const BitmapState&bitmapState){ mTransparency = bitmapState.mTransparency; //mRebuildShader = bitmapState.mRebuildShader; mAutoMirrored = bitmapState.mAutoMirrored; + mResource = bitmapState.mResource; } BitmapDrawable::BitmapState::~BitmapState(){ diff --git a/src/gui/drawables/drawable.cc b/src/gui/drawables/drawable.cc index 6db0c810..3d1fb534 100644 --- a/src/gui/drawables/drawable.cc +++ b/src/gui/drawables/drawable.cc @@ -489,21 +489,23 @@ static void startElement(void *userData, const XML_Char *name, const XML_Char ** if(it!=drawableParsers.end()) { auto item = pd->items.back(); - if(strcmp(name,"shape")||((strcmp(name,"item")==0)&&atts.hasAttribute("drawable"))){ + if( strcmp(name,"shape")||(((strcmp(name,"item")==0)||(strcmp(name,"transition")==0))&&atts.hasAttribute("drawable"))){ Drawable* d = it->second(pd->ctx,atts); if(d){ auto cs = d->getConstantState(); - if(cs)cs->mResource =pd->resourceFile; + if(cs){ + cs->mResource = atts.getString("drawable"); + LOGD_IF(atts.hasAttribute("drawable"),"%p.res=%s",cs->mResource.c_str()); + } } item->drawable = d; - }else if(strcmp(name,"transition")==0){ - LOGD(""); } LOGV("created drawable %s:%p props:%d",name,item->drawable,item->props.size()); } } -static Drawable*parseShapeDrawable(Context*ctx,const AttributeSet&atts,const std::vector&props,const std::vector&names) { +static Drawable*parseShapeDrawable(Context*ctx,const AttributeSet&atts, + const std::vector&props,const std::vector&names) { const AttributeSet* corners = nullptr,*gradient = nullptr,*padding = nullptr; const AttributeSet* size = nullptr, *stroke = nullptr,*solid = nullptr; diff --git a/src/gui/drawables/drawablecontainer.cc b/src/gui/drawables/drawablecontainer.cc index 063c3d64..193ac7c2 100755 --- a/src/gui/drawables/drawablecontainer.cc +++ b/src/gui/drawables/drawablecontainer.cc @@ -430,7 +430,7 @@ int DrawableContainer::getChangingConfigurations()const{ } void DrawableContainer::setAlpha(int alpha) { - if (!mHasAlpha || mAlpha != alpha) { + if (!mHasAlpha || (mAlpha != alpha)) { mHasAlpha = true; mAlpha = alpha; if (mCurrDrawable != nullptr) { @@ -645,9 +645,9 @@ void DrawableContainer::animate(bool schedule) { } else { mExitAnimationEnd = 0; } - LOGV_IF(mCurrDrawable&&mLastDrawable,"%p Cur %d:%p alpha=%d ; Last %d:%p alpha=%d",this, - mCurIndex,mCurrDrawable,mCurrDrawable->getAlpha(), - mLastIndex,mLastDrawable,mLastDrawable->getAlpha()); + LOGD_IF(mCurrDrawable&&mLastDrawable,"%p \nCur %d:%p[%s] alpha=%d\nLast %d:%p[%s] alpha=%d",this, + mCurIndex,mCurrDrawable,mCurrDrawable->getConstantState()->mResource.c_str(),mCurrDrawable->getAlpha(), + mLastIndex,mLastDrawable,mLastDrawable->getConstantState()->mResource.c_str(),mLastDrawable->getAlpha()); if (schedule && animating) { scheduleSelf(mAnimationRunnable, now + 1000 / 60); }