mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-10 23:22:39 +08:00
add InsetDrawable::getIntrinsicWidth/Height
This commit is contained in:
parent
27ab200a41
commit
83ab7ee80c
@ -537,8 +537,8 @@ static Drawable*parseShapeDrawable(Context*ctx,const AttributeSet&atts,
|
||||
d->setStroke(stroke->getDimensionPixelSize("width",1),stroke->getColorStateList("color"),
|
||||
stroke->getDimensionPixelSize("dashWidth"),stroke->getDimensionPixelSize("dashGap"));
|
||||
}
|
||||
if(padding)d->setPadding(padding->getInt("left"),padding->getInt("top"),
|
||||
padding->getInt("right"),padding->getInt("bottom"));
|
||||
if(padding)d->setPadding(padding->getDimensionPixelSize("left"),padding->getDimensionPixelSize("top"),
|
||||
padding->getDimensionPixelSize("right"),padding->getDimensionPixelSize("bottom"));
|
||||
return d;
|
||||
} else {
|
||||
ShapeDrawable*sd=new ShapeDrawable();
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
int getIntrinsicHeight()const override;
|
||||
int getChangingConfigurations()const override;
|
||||
void setDrawable(Drawable* dr);
|
||||
Drawable* getDrawable();
|
||||
Drawable* getDrawable()const;
|
||||
DrawableWrapper*mutate()override;
|
||||
void clearMutated()override;
|
||||
std::shared_ptr<ConstantState>getConstantState()override;
|
||||
|
@ -114,6 +114,26 @@ void InsetDrawable::onBoundsChange(const Rect&bounds){
|
||||
DrawableWrapper::onBoundsChange(r);
|
||||
}
|
||||
|
||||
int InsetDrawable::getIntrinsicWidth()const {
|
||||
const int childWidth = getDrawable()->getIntrinsicWidth();
|
||||
const float fraction = mState->mInsetLeft->mFraction + mState->mInsetRight.mFraction;
|
||||
if (childWidth < 0 || fraction >= 1) {
|
||||
return -1;
|
||||
}
|
||||
return (int) (childWidth / (1.f - fraction)) + mState->mInsetLeft.mDimension
|
||||
+ mState->mInsetRight.mDimension;
|
||||
}
|
||||
|
||||
int InsetDrawable::getIntrinsicHeight()const {
|
||||
const int childHeight = getDrawable()->getIntrinsicHeight();
|
||||
const float fraction = mState->mInsetTop.mFraction + mState->mInsetBottom.mFraction;
|
||||
if (childHeight < 0 || fraction >= 1) {
|
||||
return -1;
|
||||
}
|
||||
return (int) (childHeight / (1.f - fraction)) + mState->mInsetTop.mDimension
|
||||
+ mState->mInsetBottom.mDimension;
|
||||
}
|
||||
|
||||
std::shared_ptr<Drawable::ConstantState>InsetDrawable::getConstantState(){
|
||||
return mState;
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ public:
|
||||
InsetDrawable(Drawable*drawable,int inset);
|
||||
InsetDrawable(Drawable* drawable,int insetLeft,int insetTop,int insetRight,int insetBottom);
|
||||
std::shared_ptr<ConstantState>getConstantState()override;
|
||||
int getIntrinsicWidth()const override;
|
||||
int getIntrinsicHeight()const override;
|
||||
bool getPadding(Rect& padding)override;
|
||||
int getOpacity()override;
|
||||
Insets getOpticalInsets()override;
|
||||
|
@ -45,7 +45,8 @@ LevelListDrawable::LevelListDrawable(std::shared_ptr<LevelListState>state){
|
||||
}
|
||||
|
||||
bool LevelListDrawable::onLevelChange(int level){
|
||||
int idx = mLevelListState->indexOfLevel(level);
|
||||
const int idx = mLevelListState->indexOfLevel(level);
|
||||
LOGV("%p level %d.index=%d",this,level,idx);
|
||||
if (selectDrawable(idx)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ namespace cdroid{
|
||||
|
||||
SnapHelper::SnapHelper(){
|
||||
mScrolled = false;
|
||||
mRecyclerView = nullptr;
|
||||
mGravityScroller = nullptr;
|
||||
mScrollListener.onScrollStateChanged=[this](RecyclerView& recyclerView, int newState) {
|
||||
//super is null;super.onScrollStateChanged(recyclerView, newState);
|
||||
if (newState == RecyclerView::SCROLL_STATE_IDLE && mScrolled) {
|
||||
|
Loading…
Reference in New Issue
Block a user