mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-05 05:37:53 +08:00
fix pivotx/y
This commit is contained in:
parent
98a7354ee5
commit
58a24f6a37
@ -12,7 +12,7 @@ RenderNode::RenderNode(){
|
||||
mTranslationX = .0f;
|
||||
mTranslationY = .0f;
|
||||
mTranslationZ = .0f;
|
||||
mPivotX = mPivotY = FLT_MIN;//std::numeric_limits<float>::min();
|
||||
mPivotX = mPivotY = 0.5f;
|
||||
mRotation = .0f;
|
||||
mRotationX = .0f;
|
||||
mRotationY = .0f;
|
||||
@ -32,13 +32,12 @@ static inline float sdot(float a,float b,float c,float d){
|
||||
|
||||
void RenderNode::getMatrix(Matrix&outMatrix)const{
|
||||
outMatrix = identity_matrix();
|
||||
const float px = (mPivotX==FLT_MIN) ? (mRight - mLeft)/2.f : mPivotX;
|
||||
const float py = (mPivotY==FLT_MIN) ? (mBottom- mTop)/2.f : mPivotY;
|
||||
const float px = (mRight - mLeft)*mPivotX;
|
||||
const float py = (mBottom- mTop)*mPivotY;
|
||||
outMatrix.translate(px,py);
|
||||
outMatrix.scale(mScaleX,mScaleY);
|
||||
outMatrix.rotate(mRotation*M_PI/180.f);
|
||||
outMatrix.translate(mTranslationX - px,mTranslationY - py);
|
||||
//outMatrix.translate((mTranslationX-px)/mScaleX,(mTranslationY-py)/mScaleY);
|
||||
}
|
||||
|
||||
void RenderNode::getInverseMatrix(Matrix&outMatrix)const{
|
||||
|
@ -118,8 +118,8 @@ View::View(Context*ctx,const AttributeSet&attrs){
|
||||
setRotationY( attrs.getFloat("rotationY",0) );
|
||||
setScaleX( attrs.getFloat("scaleX",1.f) );
|
||||
setScaleY( attrs.getFloat("scaleY",1.f) );
|
||||
setPivotX( attrs.getDimensionPixelSize("transformPivotX",0));
|
||||
setPivotY( attrs.getDimensionPixelSize("transformPivotY",0));
|
||||
setPivotX( attrs.getFloat("transformPivotX",0.5));
|
||||
setPivotY( attrs.getFloat("transformPivotY",0.5));
|
||||
|
||||
setKeyboardNavigationCluster( attrs.getBoolean("keyboardNavigationCluster",false) );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user