mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-02 11:36:30 +03:00
Some minor fixes.
--HG-- branch : dev
This commit is contained in:
@@ -308,23 +308,23 @@ bool Polygon2<T>::intersect( const Polygon2<T>& p1 ) {
|
||||
|
||||
vAxis = Line2<T>( Vector[i], Vector[n] ).getNormal();
|
||||
|
||||
min0 = vAxis.Dot( Vector[0] );
|
||||
min0 = vAxis.dot( Vector[0] );
|
||||
max0 = min0;
|
||||
for (j = 1; j < this->getSize(); j++) {
|
||||
t = vAxis.Dot( Vector[j] );
|
||||
t = vAxis.dot( Vector[j] );
|
||||
if (t < min0) min0 = t;
|
||||
if (t > max0) max0 = t;
|
||||
}
|
||||
|
||||
min1 = vAxis.Dot( p1[0] );
|
||||
min1 = vAxis.dot( p1[0] );
|
||||
max1 = min1;
|
||||
for (j = 1; j < p1.getSize(); j++) {
|
||||
t = vAxis.Dot( p1[j] );
|
||||
t = vAxis.dot( p1[j] );
|
||||
if (t < min1) min1 = t;
|
||||
if (t > max1) max1 = t;
|
||||
}
|
||||
|
||||
sOffset = vAxis.Dot( vOffset );
|
||||
sOffset = vAxis.dot( vOffset );
|
||||
min0 += sOffset;
|
||||
max0 += sOffset;
|
||||
|
||||
@@ -339,23 +339,23 @@ bool Polygon2<T>::intersect( const Polygon2<T>& p1 ) {
|
||||
|
||||
vAxis = Line2<T>( p1[i], p1[n] ).getNormal();
|
||||
|
||||
min0 = vAxis.Dot( Vector[0] );
|
||||
min0 = vAxis.dot( Vector[0] );
|
||||
max0 = min0;
|
||||
for (j = 1; j < this->getSize(); j++) {
|
||||
t = vAxis.Dot( Vector[j] );
|
||||
t = vAxis.dot( Vector[j] );
|
||||
if (t < min0) min0 = t;
|
||||
if (t > max0) max0 = t;
|
||||
}
|
||||
|
||||
min1 = vAxis.Dot( p1[0] );
|
||||
min1 = vAxis.dot( p1[0] );
|
||||
max1 = min1;
|
||||
for (j = 1; j < p1.getSize(); j++) {
|
||||
t = vAxis.Dot( p1[j] );
|
||||
t = vAxis.dot( p1[j] );
|
||||
if (t < min1) min1 = t;
|
||||
if (t > max1) max1 = t;
|
||||
}
|
||||
|
||||
sOffset = vAxis.Dot( vOffset );
|
||||
sOffset = vAxis.dot( vOffset );
|
||||
min0 += sOffset;
|
||||
max0 += sOffset;
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ bool tRECT<T>::intersectsSegment( const Vector2<T>& a, const Vector2<T>& b ) {
|
||||
Vector2<T> offset( ( a.x + b.x - Right - Left ), ( a.y + b.y - Bottom - Top ) );
|
||||
Vector2<T> extents( Right - Left, Bottom - Top );
|
||||
|
||||
return ( eeabs( axis.Dot( offset ) ) < eeabs( axis.x * extents.x ) + eeabs( axis.y * extents.y ) );
|
||||
return ( eeabs( axis.dot( offset ) ) < eeabs( axis.x * extents.x ) + eeabs( axis.y * extents.y ) );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -24,10 +24,10 @@ class Vector2 {
|
||||
Vector2<T> copy();
|
||||
|
||||
/** @return The Dot product of the 2D vectors. */
|
||||
T Dot( const Vector2<T>& V2 );
|
||||
T dot( const Vector2<T>& V2 );
|
||||
|
||||
/** @return The Cross product of the 2D vectors. */
|
||||
T Cross( const Vector2<T>& V2 );
|
||||
T cross( const Vector2<T>& V2 );
|
||||
|
||||
/** @return The perpendicular vector */
|
||||
Vector2<T> perp();
|
||||
@@ -92,6 +92,10 @@ class Vector2 {
|
||||
/** Scales the vector position against another vector */
|
||||
void scale( const T& scale, const Vector2<T>& Center );
|
||||
|
||||
Vector2<T> ceil();
|
||||
|
||||
Vector2<T> floor();
|
||||
|
||||
T x;
|
||||
T y;
|
||||
private:
|
||||
@@ -119,7 +123,7 @@ Vector2<T> Vector2<T>::lerpConst( const Vector2<T>& Vec, T Dist ) {
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::sphericalLerp( const Vector2<T>& Vec, T Time ) {
|
||||
T omega = eeacos( Dot( Vec ) );
|
||||
T omega = eeacos( dot( Vec ) );
|
||||
|
||||
if( omega ) {
|
||||
T denom = 1 / eesin( omega );
|
||||
@@ -132,7 +136,7 @@ Vector2<T> Vector2<T>::sphericalLerp( const Vector2<T>& Vec, T Time ) {
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::sphericalLerpConst( const Vector2<T>& Vec, T Angle ) {
|
||||
T angle = eeacos( Dot( Vec ) );
|
||||
T angle = eeacos( dot( Vec ) );
|
||||
return lerp( Vec, ( ( Angle < angle ) ? Angle : angle ) / angle );
|
||||
}
|
||||
|
||||
@@ -334,12 +338,12 @@ void Vector2<T>::scale( const T& scale, const Vector2<T>& Center ) {
|
||||
|
||||
|
||||
template <typename T>
|
||||
T Vector2<T>::Dot( const Vector2<T>& V2 ) {
|
||||
T Vector2<T>::dot( const Vector2<T>& V2 ) {
|
||||
return x * V2.x + y * V2.y;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Vector2<T>::Cross( const Vector2<T>& V2 ) {
|
||||
T Vector2<T>::cross( const Vector2<T>& V2 ) {
|
||||
return x * V2.x - y * V2.y;
|
||||
}
|
||||
|
||||
@@ -365,12 +369,12 @@ Vector2<T> Vector2<T>::unrotate( const Vector2<T>& V2 ) {
|
||||
|
||||
template <typename T>
|
||||
T Vector2<T>::length() {
|
||||
return eesqrt( Dot( Vector2<T>( x , y ) ) );
|
||||
return eesqrt( dot( Vector2<T>( x , y ) ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Vector2<T>::lengthSq() {
|
||||
return Dot( Vector2<T>( x , y ) );
|
||||
return dot( Vector2<T>( x , y ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -407,7 +411,7 @@ T Vector2<T>::distanceSq( const Vector2<T>& Vec ) {
|
||||
|
||||
template <typename T>
|
||||
void Vector2<T>::clamp( T len ) {
|
||||
if ( Dot( Vector2<T>( x, y ) ) > len * len ) {
|
||||
if ( dot( Vector2<T>( x, y ) ) > len * len ) {
|
||||
normalize();
|
||||
|
||||
x *= len;
|
||||
@@ -415,6 +419,16 @@ void Vector2<T>::clamp( T len ) {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::ceil() {
|
||||
return Vector2<T>( eeceil( x ), eeceil( y ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::floor() {
|
||||
return Vector2<T>( eefloor( x ), eefloor( y ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Vector2<T>::nearDist( const Vector2<T>& Vec, T Dist ) {
|
||||
return 0 != ( distanceSq( Vec ) < Dist * Dist );
|
||||
|
||||
@@ -53,11 +53,11 @@ void UIComboBox::setTheme( UITheme * Theme ) {
|
||||
mButton->setThemeSkin( Theme, "combobox_button" );
|
||||
|
||||
if ( NULL != mDropDownList->getSkin() ) {
|
||||
setInternalHeight( mDropDownList->getSkin()->getSize().getHeight() );
|
||||
setInternalHeight( mDropDownList->getSkinSize().getHeight() );
|
||||
}
|
||||
|
||||
if ( NULL != mButton->getSkin() ) {
|
||||
mButton->setSize( mButton->getSkin()->getSize() );
|
||||
mButton->setSize( mButton->getSkinSize() );
|
||||
}
|
||||
|
||||
updateControls();
|
||||
@@ -80,7 +80,7 @@ void UIComboBox::loadFromXmlNode(const pugi::xml_node& node) {
|
||||
}
|
||||
|
||||
void UIComboBox::updateControls() {
|
||||
if ( ( mFlags & UI_AUTO_SIZE ) || mSize.getHeight() < mDropDownList->getSkin()->getSize().getHeight() ) {
|
||||
if ( ( mFlags & UI_AUTO_SIZE ) || mSize.getHeight() < mDropDownList->getSkinSize().getHeight() ) {
|
||||
onAutoSize();
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ void UIComboBox::onPositionChange() {
|
||||
}
|
||||
|
||||
void UIComboBox::onAutoSize() {
|
||||
setInternalHeight( mDropDownList->getSkin()->getSize().getHeight() );
|
||||
setInternalHeight( mDropDownList->getSkinSize().getHeight() );
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -186,7 +186,7 @@ Uint32 UIMenu::addSeparator() {
|
||||
UIMenuSeparator * Control = UIMenuSeparator::New();
|
||||
Control->setParent( this );
|
||||
Control->setPosition( mStyleConfig.Padding.Left, mStyleConfig.Padding.Top + mNextPosY );
|
||||
Control->setSize( mSize.getWidth() - mStyleConfig.Padding.Left - mStyleConfig.Padding.Right, 3 );
|
||||
Control->setSize( mSize.getWidth() - mStyleConfig.Padding.Left - mStyleConfig.Padding.Right, Control->getSkinSize().getHeight() );
|
||||
|
||||
mNextPosY += Control->getSize().getHeight();
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ Uint32 UIMenuItem::onMouseEnter( const Vector2i &Pos, const Uint32 Flags ) {
|
||||
void UIMenuItem::onStateChange() {
|
||||
UIMenu * tMenu = reinterpret_cast<UIMenu*> ( getParent() );
|
||||
|
||||
if ( NULL == mSkinState )
|
||||
return;
|
||||
|
||||
if ( mSkinState->getState() == UISkinState::StateSelected ) {
|
||||
mTextBox->setFontColor( tMenu->getFontStyleConfig().getFontSelectedColor() );
|
||||
} else if ( mSkinState->getState() == UISkinState::StateMouseEnter ) {
|
||||
|
||||
@@ -29,7 +29,7 @@ void UIMenuSeparator::setTheme( UITheme * Theme ) {
|
||||
setThemeSkin( Theme, "separator" );
|
||||
|
||||
if ( NULL != getSkin() ) {
|
||||
setSize( Sizei( mSize.getWidth(), getSkin()->getSize().getHeight() ) );
|
||||
setSize( Sizei( mSize.getWidth(), getSkinSize().getHeight() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@ void UIProgressBar::draw() {
|
||||
void UIProgressBar::update() {
|
||||
UIControlAnim::update();
|
||||
|
||||
if ( NULL == mFillerSkin )
|
||||
return;
|
||||
|
||||
mOffset += mStyleConfig.MovementSpeed * (Float)( getElapsed().asSeconds() );
|
||||
|
||||
Sizei rSize( PixelDensity::dpToPxI( mFillerSkin->getSize() ) );
|
||||
|
||||
@@ -138,7 +138,7 @@ void UIPushButton::onThemeLoaded() {
|
||||
}
|
||||
|
||||
if ( ( mFlags & UI_AUTO_SIZE ) && NULL != getSkin() ) {
|
||||
setInternalHeight( getSkin()->getSize().getHeight() );
|
||||
setInternalHeight( getSkinSize().getHeight() );
|
||||
}
|
||||
|
||||
autoPadding();
|
||||
|
||||
@@ -177,16 +177,20 @@ void UIScrollView::containerUpdate() {
|
||||
mVScroll->setSize( mVScroll->getSize().getWidth(), mSize.getHeight() );
|
||||
mHScroll->setSize( mSize.getWidth() - ( mVScroll->isVisible() ? mVScroll->getSize().getWidth() : 0 ), mHScroll->getSize().getHeight() );
|
||||
|
||||
mVScroll->setPageStep( (Float)mContainer->getSize().getHeight() / (Float)mScrollView->getSize().getHeight());
|
||||
mHScroll->setPageStep( (Float)mContainer->getSize().getWidth() / (Float)mScrollView->getSize().getWidth() );
|
||||
if ( mVScroll->isVisible() && 0 != mScrollView->getSize().getHeight() )
|
||||
mVScroll->setPageStep( (Float)mContainer->getSize().getHeight() / (Float)mScrollView->getSize().getHeight() );
|
||||
|
||||
if ( mHScroll->isVisible() && 0 != mScrollView->getSize().getWidth() ) {
|
||||
mHScroll->setPageStep( (Float)mContainer->getSize().getWidth() / (Float)mScrollView->getSize().getWidth() );
|
||||
}
|
||||
|
||||
updateScroll();
|
||||
}
|
||||
|
||||
void UIScrollView::updateScroll() {
|
||||
mScrollView->setPosition(
|
||||
-( mHScroll->getSlider()->getValue() * ( mScrollView->getSize().getWidth() - mSize.getWidth() ) ),
|
||||
-( mVScroll->getSlider()->getValue() * ( mScrollView->getSize().getHeight() - mSize.getHeight() ) )
|
||||
mHScroll->isVisible() ? -( mHScroll->getSlider()->getValue() * eemax( 0, mScrollView->getSize().getWidth() - mSize.getWidth() ) ) : 0 ,
|
||||
mVScroll->isVisible() ? -( mVScroll->getSlider()->getValue() * eemax( 0, mScrollView->getSize().getHeight() - mSize.getHeight() ) ) : 0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -199,10 +203,10 @@ void UIScrollView::onScrollViewSizeChange(const UIEvent * Event) {
|
||||
}
|
||||
|
||||
void UIScrollView::onTouchDragValueChange( Vector2f diff ) {
|
||||
if ( mVScroll->isEnabled() )
|
||||
if ( mVScroll->isEnabled() && 0 != mScrollView->getSize().getHeight() )
|
||||
mVScroll->setValue( mVScroll->getValue() + ( -diff.y / (Float)( mScrollView->getSize().getHeight() ) ) );
|
||||
|
||||
if ( mHScroll->isEnabled() )
|
||||
if ( mHScroll->isEnabled() && 0 != mScrollView->getSize().getWidth() )
|
||||
mHScroll->setValue( mHScroll->getValue() + ( -diff.x / (Float)( mScrollView->getSize().getWidth() ) ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,9 @@ bool UISelectButton::selected() const {
|
||||
}
|
||||
|
||||
void UISelectButton::onStateChange() {
|
||||
if ( NULL == mSkinState )
|
||||
return;
|
||||
|
||||
if ( mSkinState->getState() != UISkinState::StateSelected && selected() ) {
|
||||
if ( mSkinState->stateExists( UISkinState::StateSelected ) ) {
|
||||
setSkinState( UISkinState::StateSelected );
|
||||
|
||||
@@ -33,7 +33,8 @@ UISkinComplex::~UISkinComplex() {
|
||||
|
||||
}
|
||||
|
||||
#define DRAWABLE_PX_SIZE PixelDensity::dpToPx( tDrawable->getSize() )
|
||||
#define DRAWABLE_PX_SIZE PixelDensity::dpToPx( tDrawable->getSize() ).ceil()
|
||||
|
||||
|
||||
void UISkinComplex::draw( const Float& X, const Float& Y, const Float& Width, const Float& Height, const Uint32& Alpha, const Uint32& State ) {
|
||||
if ( 0 == Alpha )
|
||||
|
||||
@@ -18,7 +18,7 @@ UISlider::UISlider( const UI_ORIENTATION& orientation ) :
|
||||
mMaxValue( 1.f ),
|
||||
mValue( 0.f ),
|
||||
mClickStep( 0.1f ),
|
||||
mPageStep(0),
|
||||
mPageStep( 0 ),
|
||||
mOnPosChange( false )
|
||||
{
|
||||
UITheme * theme = UIThemeManager::instance()->getDefaultTheme();
|
||||
|
||||
@@ -80,11 +80,11 @@ void UITab::onStateChange() {
|
||||
|
||||
UITabWidget * tTabW = getTabWidget();
|
||||
|
||||
if ( NULL != tTabW ) {
|
||||
Int32 skinSize = getSkin()->getSize( mSkinState->getState() ).getHeight();
|
||||
if ( NULL != tTabW && NULL != mSkinState ) {
|
||||
Int32 skinSize = getSkinSize( getSkin(), mSkinState->getState() ).getHeight();
|
||||
|
||||
if ( 0 == skinSize ) {
|
||||
skinSize = getSkin()->getSize().getHeight();
|
||||
skinSize = getSkinSize().getHeight();
|
||||
}
|
||||
|
||||
setSize( mSize.getWidth(), skinSize );
|
||||
|
||||
@@ -225,10 +225,11 @@ void UITextEdit::scrollbarsSet() {
|
||||
if ( mHScrollBar->isVisible() ) {
|
||||
Int32 totW = mRealSize.getWidth() - mContainerPadding.Left - mContainerPadding.Right - mVScrollBar->getRealSize().getWidth();
|
||||
|
||||
if ( mTextInput->getTextWidth() > totW ) {
|
||||
if ( mTextInput->getTextWidth() > totW && 0 != mTextInput->getTextWidth() ) {
|
||||
mHScrollBar->setPageStep( (Float)totW / (Float)mTextInput->getTextWidth() );
|
||||
}
|
||||
}
|
||||
|
||||
mSkipValueChange = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ void UIWinMenu::setTheme( UITheme * Theme ) {
|
||||
it->first->setThemeSkin( Theme, "winmenubutton" );
|
||||
}
|
||||
|
||||
if ( 0 == mStyleConfig.MenuHeight && NULL != getSkin() && NULL != getSkin() ) {
|
||||
mStyleConfig.MenuHeight = getSkin()->getSize().getHeight();
|
||||
if ( 0 == mStyleConfig.MenuHeight && NULL != getSkin() ) {
|
||||
mStyleConfig.MenuHeight = getSkinSize().getHeight();
|
||||
|
||||
setSize( getParent()->getSize().getWidth(), mStyleConfig.MenuHeight );
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ void EETest::createUIThemeTextureAtlas() {
|
||||
std::string Path( MyPath + "ui/" + mThemeName );
|
||||
|
||||
if ( !FileSystem::fileExists( tgpath + EE_TEXTURE_ATLAS_EXTENSION ) ) {
|
||||
TexturePacker tp( 512, 512, mThemeName.find_first_of( "2x" ) != std::string::npos ? PD_XHDPI : PD_MDPI, true, 2 );
|
||||
TexturePacker tp( 512, 512, mThemeName.find_first_of( "2x" ) != std::string::npos ? PD_XHDPI : ( mThemeName.find_first_of( "1.5x" ) != std::string::npos ? PD_HDPI : PD_MDPI ), true, 2 );
|
||||
tp.addTexturesPath( Path );
|
||||
tp.packTextures();
|
||||
tp.save( tgpath + ".png", SAVE_TYPE_PNG );
|
||||
@@ -278,6 +278,8 @@ void EETest::createUI() {
|
||||
|
||||
if ( PixelDensity::getPixelDensity() >= 2 ) {
|
||||
mThemeName += "2x";
|
||||
} else if ( PixelDensity::getPixelDensity() >= 1.1 ) {
|
||||
mThemeName += "1.5x";
|
||||
}
|
||||
|
||||
createUIThemeTextureAtlas();
|
||||
@@ -754,7 +756,7 @@ void EETest::createNewUI() {
|
||||
"<window layout_width='800dp' layout_height='600dp' winflags='default|maximize'>"
|
||||
" <LinearLayout layout_width='match_parent' layout_height='match_parent'>"
|
||||
" <ScrollView layout_width='match_parent' layout_height='match_parent' touchdrag='true'>"
|
||||
" <GridLayout columnMode='size' rowMode='size' columnWidth='200dp' rowHeight='200dp' layout_width='match_parent' layout_height='wrap_content' id='gridlayout' />"
|
||||
" <GridLayout columnMode='size' rowMode='size' columnWidth='200dp' rowHeight='200dp' layout_width='match_parent' layout_height='wrap_content' id='gridlayout' clip='false' />"
|
||||
" </ScrollView>"
|
||||
" </LinearLayout>"
|
||||
"</window>"
|
||||
@@ -768,7 +770,8 @@ void EETest::createNewUI() {
|
||||
|
||||
if ( textures.size() > 0 ) {
|
||||
for ( std::size_t i = 0; i < textures.size(); i++ ) {
|
||||
UIImage::New()->setDrawable( textures[i] )
|
||||
UIImage::New()
|
||||
->setDrawable( textures[i] )
|
||||
->setScaleType( UIScaleType::FitInside )
|
||||
->setGravity( UI_HALIGN_CENTER | UI_VALIGN_CENTER )
|
||||
->setEnabled( false )
|
||||
|
||||
Reference in New Issue
Block a user