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