mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-03 12:48:56 +08:00
fix gradientdrawables,transparent->black
This commit is contained in:
parent
16f5d94bbb
commit
d56efce0c1
@ -255,7 +255,7 @@ void GradientDrawable::updateLocalState() {
|
|||||||
Color c(stateColor);
|
Color c(stateColor);
|
||||||
mFillPaint = SolidPattern::create_rgba(c.red(),c.green(),c.blue(),c.alpha());
|
mFillPaint = SolidPattern::create_rgba(c.red(),c.green(),c.blue(),c.alpha());
|
||||||
} else if(state->mGradientColors.size()==0) {
|
} else if(state->mGradientColors.size()==0) {
|
||||||
mFillPaint = SolidPattern::create_rgba(0,0,0,0);
|
//mFillPaint = SolidPattern::create_rgba(0,0,0,0);
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
mPadding = state->mPadding;
|
mPadding = state->mPadding;
|
||||||
@ -537,7 +537,7 @@ void GradientDrawable::setColor(ColorStateList* colorStateList) {
|
|||||||
color = Color::TRANSPARENT;
|
color = Color::TRANSPARENT;
|
||||||
} else {
|
} else {
|
||||||
std::vector< int>stateSet = getState();
|
std::vector< int>stateSet = getState();
|
||||||
color = colorStateList->getColorForState(stateSet, 0);
|
color = colorStateList->getColorForState(stateSet, colorStateList->getDefaultColor());
|
||||||
}
|
}
|
||||||
Color c(color);
|
Color c(color);
|
||||||
mFillPaint=SolidPattern::create_rgba(c.red(),c.green(),c.blue(),c.alpha());
|
mFillPaint=SolidPattern::create_rgba(c.red(),c.green(),c.blue(),c.alpha());
|
||||||
@ -741,16 +741,8 @@ bool GradientDrawable::ensureValidRect() {
|
|||||||
// maxed out so that alpha modulation works correctly.
|
// maxed out so that alpha modulation works correctly.
|
||||||
//if (st.mSolidColors == nullptr)
|
//if (st.mSolidColors == nullptr)
|
||||||
// mFillPaint=SolidPattern::create_rgb(0,0,0);//setColor(Color.BLACK);
|
// mFillPaint=SolidPattern::create_rgb(0,0,0);//setColor(Color.BLACK);
|
||||||
} else { //gradientColors.size()
|
} else{ //gradientColors.size()==0
|
||||||
int color = Color::BLACK;
|
//transparent ,mFillPaint=nullptr
|
||||||
if(st.mSolidColors) {
|
|
||||||
if(st.mSolidColors->isStateful())
|
|
||||||
color = st.mSolidColors->getColorForState(getState(),color);
|
|
||||||
else
|
|
||||||
color = st.mSolidColors->getDefaultColor();
|
|
||||||
}
|
|
||||||
Color c(color);
|
|
||||||
mFillPaint = SolidPattern::create_rgba(c.red(),c.green(),c.blue(),c.alpha());
|
|
||||||
}
|
}
|
||||||
LOGE_IF((mFillPaint==nullptr)&&(mStrokePaint==nullptr),"stroke and solid must be setted one or both of them");
|
LOGE_IF((mFillPaint==nullptr)&&(mStrokePaint==nullptr),"stroke and solid must be setted one or both of them");
|
||||||
}
|
}
|
||||||
@ -820,14 +812,13 @@ void GradientDrawable::draw(Canvas&canvas) {
|
|||||||
rad = std::min(st->mRadius,std::min(mRect.width, mRect.height) * 0.5f);
|
rad = std::min(st->mRadius,std::min(mRect.width, mRect.height) * 0.5f);
|
||||||
if(st->mRadiusArray.size())radii=st->mRadiusArray;
|
if(st->mRadiusArray.size())radii=st->mRadiusArray;
|
||||||
if(st->mRadius > 0.0f)radii= {rad,rad,rad,rad};
|
if(st->mRadius > 0.0f)radii= {rad,rad,rad,rad};
|
||||||
if(mFillPaint)
|
|
||||||
canvas.set_source(mFillPaint);
|
|
||||||
drawRound(canvas,mRect,radii);
|
drawRound(canvas,mRect,radii);
|
||||||
if (haveStroke) {
|
if (haveStroke) {
|
||||||
canvas.fill_preserve();
|
if(mFillPaint)canvas.fill_preserve();
|
||||||
prepareStrokeProps(canvas);
|
prepareStrokeProps(canvas);
|
||||||
canvas.stroke();
|
canvas.stroke();
|
||||||
} else if(mFillPaint) {
|
} else if(mFillPaint) {
|
||||||
|
canvas.set_source(mFillPaint);
|
||||||
canvas.fill();
|
canvas.fill();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -73,6 +73,7 @@ View* LayoutInflater::inflate(const std::string&resource,ViewGroup*root,bool att
|
|||||||
if(mContext) {
|
if(mContext) {
|
||||||
std::string package;
|
std::string package;
|
||||||
std::unique_ptr<std::istream>stream = mContext->getInputStream(resource,&package);
|
std::unique_ptr<std::istream>stream = mContext->getInputStream(resource,&package);
|
||||||
|
LOGD("inflate from %s",resource.c_str());
|
||||||
if(stream && stream->good()) {
|
if(stream && stream->good()) {
|
||||||
v = inflate(package,*stream,root,attachToRoot && (root!=nullptr),atts);
|
v = inflate(package,*stream,root,attachToRoot && (root!=nullptr),atts);
|
||||||
} else {
|
} else {
|
||||||
|
@ -146,7 +146,7 @@ void ViewGroup::initGroup(){
|
|||||||
if (!DEBUG_DRAW/*isShowingLayoutBounds()*/) {
|
if (!DEBUG_DRAW/*isShowingLayoutBounds()*/) {
|
||||||
setFlags(WILL_NOT_DRAW, DRAW_MASK);
|
setFlags(WILL_NOT_DRAW, DRAW_MASK);
|
||||||
}
|
}
|
||||||
mGroupFlags = FLAG_CLIP_CHILDREN;
|
mGroupFlags = FLAG_CLIP_CHILDREN;
|
||||||
mGroupFlags|= FLAG_CLIP_TO_PADDING;
|
mGroupFlags|= FLAG_CLIP_TO_PADDING;
|
||||||
mGroupFlags|= FLAG_ANIMATION_DONE;
|
mGroupFlags|= FLAG_ANIMATION_DONE;
|
||||||
mGroupFlags|= FLAG_ANIMATION_CACHE;
|
mGroupFlags|= FLAG_ANIMATION_CACHE;
|
||||||
|
Loading…
Reference in New Issue
Block a user