mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-02 19:46:29 +03:00
Implemented padding for UIScrollBar, UISlider and UIWindow.
--HG-- branch : dev-widget-padding
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
<vbox id="rvbox" layout_width="match_parent" layout_weight="0.5" layout_height="match_parent" backgroundColor="#323232" layout_marginTop="20dp" padding="12dp">
|
||||
<RelativeLayout id="rrl" layout_width="match_parent" layout_height="match_parent" backgroundColor="#999" padding="24dp">
|
||||
<TextView layout_width="match_parent" layout_height="match_parent" text="testing match_parent" textSize="24dp" padding="12dp" backgroundColor="#333" gravity="center" />
|
||||
<TextView layout_width="wrap_content" layout_height="wrap_content" text="testing padding" textSize="24dp" padding="12dp" backgroundColor="#242424" />
|
||||
<TextView id="el1" layout_width="wrap_content" layout_height="wrap_content" text="testing padding" textSize="24dp" padding="12dp" backgroundColor="#242424" />
|
||||
<TextView layout_width="wrap_content" layout_height="wrap_content" text="testing margin" textSize="24dp" padding="12dp" backgroundColor="#242424" layout_gravity="top|right" layout_margin="12dp" />
|
||||
<TextView id="tm" layout_width="wrap_content" layout_height="wrap_content" text="testing margin" textSize="24dp" backgroundColor="#242424" layout_gravity="bottom|left" layout_margin="12dp" />
|
||||
<TextView id="tmp" layout_width="wrap_content" layout_height="wrap_content" text="testing margin padding" textSize="24dp" backgroundColor="#242424" layout_gravity="bottom|right" layout_margin="12dp" padding="12dp" />
|
||||
@@ -32,6 +32,10 @@
|
||||
-->
|
||||
<PushButton layout_width="wrap_content" layout_height="wrap_content" text="testing padding" layout_gravity="bottom|right" gravity="center" padding="8dp" layout_to_top_of="tmp" />
|
||||
<PushButton text="OK!" textSize="16dp" icon="ok" layout_gravity="left|bottom" gravity="center" layout_width="wrap_content" layout_height="wrap_content" layout_marginBottom="8dp" padding="8dp" layout_to_top_of="tm" />
|
||||
|
||||
<Slider id="slider" halfslider="true" layout_width="200dp" layout_height="wrap_content" padding="32dp" background="#555" layout_to_bottom_of="el1" />
|
||||
|
||||
<ScrollBar orientation="horizontal" layout_width="200dp" layout_height="wrap_content" padding="8dp" background="#12345666" layout_to_bottom_of="slider" />
|
||||
</RelativeLayout>
|
||||
</vbox>
|
||||
</hbox>
|
||||
|
||||
@@ -183,22 +183,35 @@ tRECT<T>& operator /(tRECT<T>& R, Y X) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
tRECT<T>::tRECT(T left, T top, T right, T bottom) {
|
||||
Left = left; Right = right; Top = top; Bottom = bottom;
|
||||
Vector2<T> operator -(Vector2<T> X, const tRECT<T>& R) {
|
||||
return Vector2<T>(X.x - R.Left - R.Right, X.y - R.Top - R.Bottom);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> operator +(Vector2<T> X, const tRECT<T>& R) {
|
||||
return Vector2<T>(X.x + R.Left + R.Right, X.y + R.Top + R.Bottom);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
tRECT<T>::tRECT(T left, T top, T right, T bottom) :
|
||||
Left(left),
|
||||
Right(right),
|
||||
Top(top),
|
||||
Bottom(bottom)
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
tRECT<T> tRECT<T>::copy() {
|
||||
return tRECT<T>( Left, Top, Right, Bottom );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
tRECT<T>::tRECT( const Vector2<T>& Pos, const tSize<T>& Size ) {
|
||||
Left = Pos.x;
|
||||
Top = Pos.y;
|
||||
Right = Left + Size.getWidth();
|
||||
Bottom = Top + Size.getHeight();
|
||||
}
|
||||
tRECT<T>::tRECT( const Vector2<T>& Pos, const tSize<T>& Size ) :
|
||||
Left( Pos.x ),
|
||||
Right( Pos.x + Size.getWidth() ),
|
||||
Top( Pos.y ),
|
||||
Bottom( Pos.y + Size.getHeight() )
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
tRECT<T>::tRECT() : Left(0), Right(0), Top(0), Bottom(0) {}
|
||||
|
||||
@@ -86,6 +86,8 @@ class EE_API UIScrollBar : public UIWidget {
|
||||
|
||||
virtual Uint32 onMessage( const NodeMessage * Msg );
|
||||
|
||||
virtual void onPaddingChange();
|
||||
|
||||
void manageClick( const Uint32& flags );
|
||||
};
|
||||
|
||||
|
||||
@@ -65,6 +65,8 @@ class EE_API UISlider : public UIWidget {
|
||||
void setPageStep( const Float & pageStep );
|
||||
|
||||
virtual bool setAttribute( const NodeAttribute& attribute );
|
||||
|
||||
Sizef getMinimumSize();
|
||||
protected:
|
||||
friend class Private::UISliderButton;
|
||||
|
||||
@@ -82,8 +84,12 @@ class EE_API UISlider : public UIWidget {
|
||||
|
||||
Uint32 mLastTickMove;
|
||||
|
||||
virtual void onAutoSize();
|
||||
|
||||
virtual void onSizeChange();
|
||||
|
||||
virtual void onPaddingChange();
|
||||
|
||||
void fixSliderPos();
|
||||
|
||||
virtual Uint32 onKeyDown( const KeyEvent &Event );
|
||||
|
||||
@@ -189,8 +189,6 @@ class EE_API UIWindow : public UIWidget {
|
||||
|
||||
virtual void matrixUnset();
|
||||
|
||||
void onContainerPositionChange( const Event * Event );
|
||||
|
||||
void fixChildsSize();
|
||||
|
||||
void doResize( const NodeMessage * Msg );
|
||||
@@ -237,6 +235,8 @@ class EE_API UIWindow : public UIWidget {
|
||||
|
||||
virtual void drawShadow();
|
||||
|
||||
virtual void onPaddingChange();
|
||||
|
||||
virtual void preDraw();
|
||||
|
||||
virtual void postDraw();
|
||||
|
||||
@@ -85,10 +85,11 @@ void UIScrollBar::setTheme( UITheme * Theme ) {
|
||||
}
|
||||
|
||||
void UIScrollBar::onAutoSize() {
|
||||
Sizef size;
|
||||
UISkin * tSkin = mSlider->getBackSlider()->getSkin();
|
||||
|
||||
if ( NULL != tSkin ) {
|
||||
Sizef size = tSkin->getSize();
|
||||
size = tSkin->getSize();
|
||||
|
||||
mMinControlSize = PixelDensity::pxToDp( size );
|
||||
|
||||
@@ -105,7 +106,7 @@ void UIScrollBar::onAutoSize() {
|
||||
UISkin * tSkin = mSlider->getSliderButton()->getSkin();
|
||||
|
||||
if ( NULL != tSkin ) {
|
||||
Sizef size = tSkin->getSize();
|
||||
size = tSkin->getSize();
|
||||
|
||||
if ( mFlags & UI_AUTO_SIZE ) {
|
||||
if ( mSlider->isVertical() ) {
|
||||
@@ -116,6 +117,26 @@ void UIScrollBar::onAutoSize() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( mLayoutWidthRules == WRAP_CONTENT || mLayoutHeightRules == WRAP_CONTENT ) {
|
||||
Sizef size = PixelDensity::dpToPx( mSlider->getMinimumSize() ) + mRealPadding;
|
||||
|
||||
if ( mScrollBarType == TwoButtons ) {
|
||||
if ( mSlider->isVertical() ) {
|
||||
size.y += mBtnDown->getRealSize().getHeight() + mBtnUp->getRealSize().getHeight();
|
||||
} else {
|
||||
size.x += mBtnDown->getRealSize().getWidth() + mBtnUp->getRealSize().getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
if ( mLayoutWidthRules == WRAP_CONTENT ) {
|
||||
setInternalPixelsWidth( size.getWidth() );
|
||||
}
|
||||
|
||||
if ( mLayoutHeightRules == WRAP_CONTENT ) {
|
||||
setInternalPixelsHeight( size.getHeight() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UIScrollBar::onSizeChange() {
|
||||
@@ -138,9 +159,9 @@ void UIScrollBar::adjustChilds() {
|
||||
mBtnUp->setVisible( false )->setEnabled( false );
|
||||
|
||||
if ( !isVertical() ) {
|
||||
mSlider->setSize( mDpSize )->setPosition( 0, 0 )->centerVertical();
|
||||
mSlider->setSize( mDpSize - mPadding )->setPosition( mPadding.Left, mPadding.Top )->centerVertical();
|
||||
} else {
|
||||
mSlider->setSize( mDpSize )->setPosition( 0, 0 )->centerHorizontal();
|
||||
mSlider->setSize( mDpSize - mPadding )->setPosition( mPadding.Left, mPadding.Top )->centerHorizontal();
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -152,17 +173,19 @@ void UIScrollBar::adjustChilds() {
|
||||
mBtnUp->setVisible( true )->setEnabled( true );
|
||||
|
||||
if ( !isVertical() ) {
|
||||
mBtnDown->setPosition( mDpSize.getWidth() - mBtnDown->getSize().getWidth(), 0 );
|
||||
mSlider->setSize( mDpSize.getWidth() - mBtnDown->getSize().getWidth() - mBtnUp->getSize().getWidth(), mDpSize.getHeight() );
|
||||
mSlider->setPosition( mBtnUp->getSize().getWidth(), 0 );
|
||||
mBtnUp->setPosition( mPadding.Left, mPadding.Top );
|
||||
mBtnDown->setPosition( mDpSize.getWidth() - mBtnDown->getSize().getWidth() - mPadding.Right, mPadding.Top );
|
||||
mSlider->setSize( mDpSize.getWidth() - mBtnDown->getSize().getWidth() - mBtnUp->getSize().getWidth() - mPadding.Left - mPadding.Bottom, mDpSize.getHeight() );
|
||||
mSlider->setPosition( mPadding.Left + mBtnUp->getSize().getWidth(), mPadding.Top );
|
||||
|
||||
mBtnDown->centerVertical();
|
||||
mBtnUp->centerVertical();
|
||||
mSlider->centerVertical();
|
||||
} else {
|
||||
mBtnDown->setPosition( 0, mDpSize.getHeight() - mBtnDown->getSize().getHeight() );
|
||||
mSlider->setSize( mDpSize.getWidth(), mDpSize.getHeight() - mBtnDown->getSize().getHeight() - mBtnUp->getSize().getHeight() );
|
||||
mSlider->setPosition( 0, mBtnUp->getSize().getHeight() );
|
||||
mBtnUp->setPosition( mPadding.Left, mPadding.Top );
|
||||
mBtnDown->setPosition( mPadding.Left, mDpSize.getHeight() - mBtnDown->getSize().getHeight() - mPadding.Bottom );
|
||||
mSlider->setSize( mDpSize.getWidth(), mDpSize.getHeight() - mBtnDown->getSize().getHeight() - mBtnUp->getSize().getHeight() - mPadding.Top - mPadding.Bottom );
|
||||
mSlider->setPosition( mPadding.Left, mBtnUp->getSize().getHeight() + mPadding.Top );
|
||||
|
||||
mBtnDown->centerHorizontal();
|
||||
mBtnUp->centerHorizontal();
|
||||
@@ -281,11 +304,36 @@ void UIScrollBar::setExpandBackground( bool expandBackground ) {
|
||||
}
|
||||
|
||||
bool UIScrollBar::setAttribute(const NodeAttribute & attribute) {
|
||||
bool attributeSet = UIScrollBar::setAttribute( attribute );
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
mSlider->setAttribute( attribute );
|
||||
if ( "orientation" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
return attributeSet;
|
||||
if ( "horizontal" == val )
|
||||
setOrientation( UI_HORIZONTAL );
|
||||
else if ( "vertical" == val )
|
||||
setOrientation( UI_VERTICAL );
|
||||
} else if ( "minvalue" == name ) {
|
||||
setMinValue( attribute.asFloat() );
|
||||
} else if ( "maxvalue" == name ) {
|
||||
setMaxValue( attribute.asFloat() );
|
||||
} else if ( "value" == name ) {
|
||||
setValue( attribute.asFloat() );
|
||||
} else if ( "clickstep" == name ) {
|
||||
setClickStep( attribute.asFloat() );
|
||||
} else if ( "pagestep" == name ) {
|
||||
setPageStep( attribute.asFloat() );
|
||||
} else if ( "scrollbartype" == name || "scrollbar_type" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
setScrollBarType( val == "nobuttons" || val == "mobile" || val == "simple" ? NoButtons : TwoButtons );
|
||||
} else {
|
||||
return UIWidget::setAttribute( attribute );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
UIScrollBar::ScrollBarType UIScrollBar::getScrollBarType() const {
|
||||
@@ -320,4 +368,9 @@ void UIScrollBar::onAlphaChange() {
|
||||
mBtnDown->setAlpha( mAlpha );
|
||||
}
|
||||
|
||||
void UIScrollBar::onPaddingChange() {
|
||||
adjustChilds();
|
||||
UIWidget::onPaddingChange();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -93,6 +93,11 @@ void UISlider::onSizeChange() {
|
||||
adjustChilds();
|
||||
}
|
||||
|
||||
void UISlider::onPaddingChange() {
|
||||
adjustChilds();
|
||||
UIWidget::onPaddingChange();
|
||||
}
|
||||
|
||||
void UISlider::adjustChilds() {
|
||||
UISkin * tSkin = NULL;
|
||||
|
||||
@@ -129,24 +134,24 @@ void UISlider::adjustChilds() {
|
||||
Float Height;
|
||||
|
||||
if ( mStyleConfig.ExpandBackground )
|
||||
Height = mDpSize.getHeight();
|
||||
Height = mDpSize.getHeight() - mPadding.Top - mPadding.Bottom;
|
||||
else
|
||||
Height = tSkin->getSize().getHeight();
|
||||
|
||||
if ( mStyleConfig.AllowHalfSliderOut )
|
||||
mBackSlider->setSize( Sizef( mDpSize.getWidth() - mSlider->getSize().getWidth(), Height ) );
|
||||
mBackSlider->setSize( Sizef( mDpSize.getWidth() - mSlider->getSize().getWidth() - mPadding.Left - mPadding.Right, Height ) );
|
||||
else
|
||||
mBackSlider->setSize( Sizef( mDpSize.getWidth(), Height ) );
|
||||
mBackSlider->setSize( Sizef( mDpSize.getWidth() - mPadding.Left - mPadding.Right, Height ) );
|
||||
} else {
|
||||
Float Width;
|
||||
|
||||
if ( mStyleConfig.ExpandBackground )
|
||||
Width = mDpSize.getWidth();
|
||||
Width = mDpSize.getWidth() - mPadding.Left - mPadding.Right;
|
||||
else
|
||||
Width = tSkin->getSize().getWidth();
|
||||
|
||||
if ( mStyleConfig.AllowHalfSliderOut )
|
||||
mBackSlider->setSize( Sizef( Width, mDpSize.getHeight() - mSlider->getSize().getHeight() ) );
|
||||
mBackSlider->setSize( Sizef( Width, mDpSize.getHeight() - mSlider->getSize().getHeight() - mPadding.Top - mPadding.Bottom ) );
|
||||
else
|
||||
mBackSlider->setSize( Sizef( Width, mDpSize.getHeight() ) );
|
||||
}
|
||||
@@ -164,44 +169,44 @@ void UISlider::fixSliderPos() {
|
||||
if ( UI_HORIZONTAL == mOrientation ) {
|
||||
mSlider->setPosition( mSlider->getPosition().x, 0 );
|
||||
|
||||
if ( mSlider->getPosition().x < 0 )
|
||||
mSlider->setPosition( 0, 0 );
|
||||
if ( mSlider->getPosition().x < mPadding.Left )
|
||||
mSlider->setPosition( mPadding.Left, 0 );
|
||||
|
||||
if ( mStyleConfig.AllowHalfSliderOut ) {
|
||||
if ( mSlider->getPosition().x > mBackSlider->getSize().getWidth() )
|
||||
mSlider->setPosition( mBackSlider->getSize().getWidth(), 0 );
|
||||
if ( mSlider->getPosition().x > mBackSlider->getSize().getWidth() + mPadding.Left )
|
||||
mSlider->setPosition( mBackSlider->getSize().getWidth() + mPadding.Left, 0 );
|
||||
} else {
|
||||
if ( mSlider->getPosition().x > mBackSlider->getSize().getWidth() - mSlider->getSize().getWidth() )
|
||||
mSlider->setPosition( mBackSlider->getSize().getWidth() - mSlider->getSize().getWidth(), 0 );
|
||||
if ( mSlider->getPosition().x > mBackSlider->getSize().getWidth() - mSlider->getSize().getWidth() + mPadding.Left )
|
||||
mSlider->setPosition( mBackSlider->getSize().getWidth() - mSlider->getSize().getWidth() + mPadding.Left, 0 );
|
||||
}
|
||||
|
||||
mSlider->centerVertical();
|
||||
|
||||
if ( mStyleConfig.AllowHalfSliderOut )
|
||||
setValue( mMinValue + (Float)mSlider->getPosition().x * ( mMaxValue - mMinValue ) / (Float)mBackSlider->getSize().getWidth() );
|
||||
setValue( mMinValue + ( mSlider->getPosition().x - mPadding.Left ) * ( mMaxValue - mMinValue ) / (Float)mBackSlider->getSize().getWidth() );
|
||||
else
|
||||
setValue( mMinValue + (Float)mSlider->getPosition().x * ( mMaxValue - mMinValue ) / ( (Float)mDpSize.getWidth() - mSlider->getSize().getWidth() ) );
|
||||
setValue( mMinValue + ( mSlider->getPosition().x - mPadding.Left ) * ( mMaxValue - mMinValue ) / ( (Float)mDpSize.getWidth() - mSlider->getSize().getWidth() ) );
|
||||
} else {
|
||||
mSlider->setPosition( 0, mSlider->getPosition().y );
|
||||
|
||||
if ( mSlider->getPosition().y < 0 )
|
||||
mSlider->setPosition( 0, 0 );
|
||||
if ( mSlider->getPosition().y < mPadding.Top )
|
||||
mSlider->setPosition( 0, mPadding.Top );
|
||||
|
||||
if ( mStyleConfig.AllowHalfSliderOut ) {
|
||||
if ( mSlider->getPosition().y > mBackSlider->getSize().getHeight() )
|
||||
mSlider->setPosition( 0, mBackSlider->getSize().getHeight() );
|
||||
if ( mSlider->getPosition().y > mBackSlider->getSize().getHeight() + mPadding.Top )
|
||||
mSlider->setPosition( 0, mBackSlider->getSize().getHeight() + mPadding.Top );
|
||||
} else {
|
||||
if ( mSlider->getPosition().y > mBackSlider->getSize().getHeight() - mSlider->getSize().getHeight() ) {
|
||||
mSlider->setPosition( 0, mBackSlider->getSize().getHeight() - mSlider->getSize().getHeight() );
|
||||
if ( mSlider->getPosition().y > mBackSlider->getSize().getHeight() - mSlider->getSize().getHeight() + mPadding.Top ) {
|
||||
mSlider->setPosition( 0, mBackSlider->getSize().getHeight() - mSlider->getSize().getHeight() + mPadding.Top );
|
||||
}
|
||||
}
|
||||
|
||||
mSlider->centerHorizontal();
|
||||
|
||||
if ( mStyleConfig.AllowHalfSliderOut )
|
||||
setValue( mMinValue + (Float)mSlider->getPosition().y * ( mMaxValue - mMinValue ) / (Float)mBackSlider->getSize().getHeight() );
|
||||
setValue( mMinValue + ( mSlider->getPosition().y - mPadding.Top ) * ( mMaxValue - mMinValue ) / (Float)mBackSlider->getSize().getHeight() );
|
||||
else
|
||||
setValue( mMinValue + (Float)mSlider->getPosition().y * ( mMaxValue - mMinValue ) / ( (Float)mDpSize.getHeight() - mSlider->getSize().getHeight() ) );
|
||||
setValue( mMinValue + ( mSlider->getPosition().y - mPadding.Top ) * ( mMaxValue - mMinValue ) / ( (Float)mDpSize.getHeight() - mSlider->getSize().getHeight() ) );
|
||||
}
|
||||
|
||||
mOnPosChange = false;
|
||||
@@ -222,14 +227,14 @@ void UISlider::setValue( Float Val ) {
|
||||
|
||||
if ( UI_HORIZONTAL == mOrientation ) {
|
||||
if ( mStyleConfig.AllowHalfSliderOut )
|
||||
mSlider->setPosition( (Int32)( (Float)mBackSlider->getSize().getWidth() * Percent ), mSlider->getPosition().y );
|
||||
mSlider->setPosition( mPadding.Left + (Int32)( (Float)mBackSlider->getSize().getWidth() * Percent ), mSlider->getPosition().y );
|
||||
else
|
||||
mSlider->setPosition( (Int32)( ( (Float)mDpSize.getWidth() - mSlider->getSize().getWidth() ) * Percent ), mSlider->getPosition().y );
|
||||
mSlider->setPosition( mPadding.Left + (Int32)( ( (Float)mDpSize.getWidth() - mPadding.Left - mPadding.Top - mSlider->getSize().getWidth() ) * Percent ), mSlider->getPosition().y );
|
||||
} else {
|
||||
if ( mStyleConfig.AllowHalfSliderOut )
|
||||
mSlider->setPosition( mSlider->getPosition().x, (Int32)( (Float)mBackSlider->getSize().getHeight() * Percent ) );
|
||||
mSlider->setPosition( mSlider->getPosition().x, mPadding.Top + (Int32)( (Float)mBackSlider->getSize().getHeight() * Percent ) );
|
||||
else
|
||||
mSlider->setPosition( mSlider->getPosition().x, (Int32)( ( (Float)mDpSize.getHeight() - mSlider->getSize().getHeight() ) * Percent ) );
|
||||
mSlider->setPosition( mSlider->getPosition().x, mPadding.Top + (Int32)( ( (Float)mDpSize.getHeight() - mPadding.Top - mPadding.Bottom - mSlider->getSize().getHeight() ) * Percent ) );
|
||||
}
|
||||
|
||||
mOnPosChange = false;
|
||||
@@ -423,6 +428,8 @@ bool UISlider::setAttribute( const NodeAttribute& attribute ) {
|
||||
setClickStep( attribute.asFloat() );
|
||||
} else if ( "pagestep" == name ) {
|
||||
setPageStep( attribute.asFloat() );
|
||||
} else if ( "halfslider" == name ) {
|
||||
setAllowHalfSliderOut( attribute.asBool() );
|
||||
} else {
|
||||
return UIWidget::setAttribute( attribute );
|
||||
}
|
||||
@@ -430,4 +437,28 @@ bool UISlider::setAttribute( const NodeAttribute& attribute ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Sizef UISlider::getMinimumSize() {
|
||||
Float w = eemax( mBackSlider->getSkinSize().getWidth(), mSlider->getSkinSize().getWidth() );
|
||||
Float h = eemax( mBackSlider->getSkinSize().getHeight(), mSlider->getSkinSize().getHeight() );
|
||||
return Sizef( w + ( mStyleConfig.AllowHalfSliderOut ? w : 0 ) + mPadding.Left + mPadding.Right, h + mPadding.Top + mPadding.Bottom );
|
||||
}
|
||||
|
||||
void UISlider::onAutoSize() {
|
||||
if ( mLayoutWidthRules == WRAP_CONTENT || mLayoutHeightRules == WRAP_CONTENT ) {
|
||||
Sizef total( getMinimumSize() );
|
||||
|
||||
total = PixelDensity::dpToPx( total );
|
||||
|
||||
if ( mLayoutWidthRules == WRAP_CONTENT ) {
|
||||
setInternalPixelsWidth( total.getWidth() );
|
||||
}
|
||||
|
||||
if ( mLayoutHeightRules == WRAP_CONTENT ) {
|
||||
setInternalPixelsHeight( total.getHeight() );
|
||||
}
|
||||
|
||||
adjustChilds();
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -69,7 +69,6 @@ UIWindow::UIWindow( UIWindow::WindowBaseContainerType type, const UIWindowStyleC
|
||||
mContainer->clipEnable();
|
||||
mContainer->enableReportSizeChangeToChilds();
|
||||
mContainer->setSize( mDpSize );
|
||||
mContainer->addEventListener( Event::OnPositionChange, cb::Make1( this, &UIWindow::onContainerPositionChange ) );
|
||||
|
||||
updateWinFlags();
|
||||
|
||||
@@ -328,6 +327,12 @@ void UIWindow::drawShadow() {
|
||||
}
|
||||
}
|
||||
|
||||
void UIWindow::onPaddingChange() {
|
||||
fixChildsSize();
|
||||
|
||||
UIWidget::onPaddingChange();
|
||||
}
|
||||
|
||||
Sizei UIWindow::getFrameBufferSize() {
|
||||
return isResizeable() && (Node*)this != mSceneNode ? Sizei( Math::nextPowOfTwo( (int)mSize.getWidth() ), Math::nextPowOfTwo( (int)mSize.getHeight() ) ) : mSize.ceil().asInt();
|
||||
}
|
||||
@@ -405,19 +410,6 @@ bool UIWindow::isType( const Uint32& type ) const {
|
||||
return UIWindow::getType() == type ? true : UIWidget::isType( type );
|
||||
}
|
||||
|
||||
void UIWindow::onContainerPositionChange( const Event * Event ) {
|
||||
if ( NULL == mContainer )
|
||||
return;
|
||||
|
||||
Vector2f PosDiff = mContainer->getPosition() - Vector2f( NULL != mBorderLeft ? mBorderLeft->getSize().getWidth() : 0, NULL != mWindowDecoration ? mWindowDecoration->getSize().getHeight() : 0 );
|
||||
|
||||
if ( PosDiff.x != 0 || PosDiff.y != 0 ) {
|
||||
mContainer->setPosition( NULL != mBorderLeft ? mBorderLeft->getSize().getWidth() : 0, NULL != mWindowDecoration ? mWindowDecoration->getSize().getHeight() : 0 );
|
||||
|
||||
setPosition( mDpPos + PosDiff );
|
||||
}
|
||||
}
|
||||
|
||||
void UIWindow::closeWindow() {
|
||||
if ( NULL != mButtonClose )
|
||||
mButtonClose->setEnabled( false );
|
||||
@@ -578,7 +570,8 @@ void UIWindow::fixChildsSize() {
|
||||
}
|
||||
|
||||
if ( NULL == mWindowDecoration && NULL != mContainer ) {
|
||||
mContainer->setPixelsSize( mSize );
|
||||
mContainer->setPixelsSize( mSize - mRealPadding );
|
||||
mContainer->setPosition( mRealPadding.Left, mRealPadding.Top );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -610,9 +603,9 @@ void UIWindow::fixChildsSize() {
|
||||
mBorderRight->setPixelsPosition( mSize.getWidth() - mBorderRight->getRealSize().getWidth(), mWindowDecoration->getRealSize().getHeight() );
|
||||
mBorderBottom->setPixelsPosition( 0, mWindowDecoration->getRealSize().getHeight() + mBorderLeft->getRealSize().getHeight() );
|
||||
|
||||
mContainer->setPixelsPosition( mBorderLeft->getRealSize().getWidth(), mWindowDecoration->getRealSize().getHeight() );
|
||||
mContainer->setPixelsSize( mSize.getWidth() - mBorderLeft->getRealSize().getWidth() - mBorderRight->getRealSize().getWidth(),
|
||||
mSize.getHeight() - mWindowDecoration->getRealSize().getHeight() - mBorderBottom->getRealSize().getHeight() );
|
||||
mContainer->setPixelsPosition( mBorderLeft->getRealSize().getWidth() + mRealPadding.Left, mWindowDecoration->getRealSize().getHeight() + mRealPadding.Top );
|
||||
mContainer->setPixelsSize( mSize.getWidth() - mBorderLeft->getRealSize().getWidth() - mBorderRight->getRealSize().getWidth() - mRealPadding.Left - mRealPadding.Right,
|
||||
mSize.getHeight() - mWindowDecoration->getRealSize().getHeight() - mBorderBottom->getRealSize().getHeight() - mRealPadding.Top - mRealPadding.Bottom );
|
||||
|
||||
Uint32 yPos;
|
||||
Vector2f posFix( PixelDensity::dpToPx( Vector2f( mStyleConfig.ButtonsPositionFixer.x, mStyleConfig.ButtonsPositionFixer.y ) ) );
|
||||
|
||||
Reference in New Issue
Block a user