Scrollbar improvements.

Minor fixes.

--HG--
branch : dev
This commit is contained in:
Martí­n Lucas Golini
2017-02-24 21:07:25 -03:00
parent 3ef58e62ea
commit 8e514cdac0
44 changed files with 68 additions and 21 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

View File

@@ -157,6 +157,8 @@ class EE_API UIGenericGrid : public UIComplexControl {
void updateVScroll();
void updateHScroll();
void setHScrollStep();
};
}}

View File

@@ -236,6 +236,8 @@ class EE_API UIListBox : public UIComplexControl {
virtual Uint32 onKeyDown( const UIEventKey &Event );
void itemKeyEvent( const UIEventKey &Event );
void setHScrollStep();
};
}}

View File

@@ -811,6 +811,8 @@ void MapEditor::OnMapSizeChange( const UIEvent *Event ) {
mMapVScroll->setMinValue( 0 );
mMapVScroll->setMaxValue( v.y );
mMapVScroll->setClickStep( mUIMap->Map()->getTileSize().getHeight() * mUIMap->Map()->getScale() );
mMapHScroll->setPageStep( (Float)mUIMap->Map()->getViewSize().getWidth() );
mMapVScroll->setPageStep( (Float)mUIMap->Map()->getViewSize().getHeight() );
}
void MapEditor::OnScrollMapH( const UIEvent * Event ) {

View File

@@ -207,6 +207,27 @@ void UIGenericGrid::updateHScroll() {
}
}
void UIGenericGrid::setHScrollStep() {
Float width = (Float)mContainer->getRealSize().getWidth();
if ( ( mItemsNotVisible > 0 && UI_SCROLLBAR_AUTO == mVScrollMode ) || UI_SCROLLBAR_ALWAYS_ON == mVScrollMode )
width -= mVScrollBar->getRealSize().getWidth();
Float maxWidth = 0;
if ( mCollumnsCount > 0 ) {
for ( Uint32 i = 0; i < mCollumnsCount; i++ ) {
maxWidth += mCollumnsWidth[i];
}
}
Float stepVal = width / (Float)maxWidth;
mHScrollBar->setPageStep( stepVal );
mHScrollBar->setClickStep( stepVal );
}
void UIGenericGrid::updateScroll( bool FromScrollChange ) {
if ( !mItems.size() )
return;
@@ -309,6 +330,8 @@ void UIGenericGrid::updateScroll( bool FromScrollChange ) {
mHScrollBar->setPosition( 0, mSize.getHeight() - mHScrollBar->getSize().getHeight() );
mHScrollBar->setSize( mSize.getWidth() - mVScrollBar->getSize().getWidth(), mHScrollBar->getSize().getHeight() );
}
setHScrollStep();
}
void UIGenericGrid::updateSize() {
@@ -330,6 +353,8 @@ void UIGenericGrid::add( UIGridCell * Cell ) {
updateSize();
updateScroll();
mVScrollBar->setPageStep( ( (Float)mContainer->getSize().getHeight() /(Float) mRowHeight ) / (Float)mItems.size() );
}
void UIGenericGrid::remove( UIGridCell * Cell ) {

View File

@@ -174,7 +174,7 @@ void UIListBox::setTheme( UITheme * Theme ) {
void UIListBox::autoPadding() {
if ( mFlags & UI_AUTO_PADDING ) {
mPaddingContainer = makePadding();
mPaddingContainer = pxToDpI( makePadding() );
}
}
@@ -227,8 +227,8 @@ Uint32 UIListBox::addListBoxItem( const String& Text ) {
if ( NULL != mFont ) {
Uint32 twidth = mFont->getTextWidth( Text );
if ( twidth > (Uint32)dpToPxI( mMaxTextWidth ) ) {
mMaxTextWidth = (Uint32)pxToDpI( twidth );
if ( twidth > mMaxTextWidth ) {
mMaxTextWidth = twidth;
updateListBoxItemsSize();
}
@@ -310,8 +310,8 @@ void UIListBox::clear() {
mSelected.clear();
mVScrollBar->setValue(0);
updateScroll();
findMaxWidth();
updateScroll();
updateListBoxItemsSize();
sendCommonEvent( UIEvent::EventOnControlClear );
@@ -361,7 +361,7 @@ void UIListBox::onSizeChange() {
mHScrollBar->setSize( mSize.getWidth() - mVScrollBar->getSize().getWidth() + mHScrollPadding.Right, mHScrollBar->getSize().getHeight() + mHScrollPadding.Bottom );
if ( mContainer->isClipped() && UI_SCROLLBAR_AUTO == mHScrollMode ) {
if ( (Int32)mMaxTextWidth <= mContainer->getSize().getWidth() ) {
if ( (Int32)mMaxTextWidth <= mContainer->getRealSize().getWidth() ) {
mHScrollBar->setVisible( false );
mHScrollBar->setEnabled( false );
mHScrollInit = 0;
@@ -397,6 +397,19 @@ void UIListBox::setRowHeight() {
}
}
void UIListBox::setHScrollStep() {
Float width = (Float)mContainer->getRealSize().getWidth();
if ( ( mItemsNotVisible > 0 && UI_SCROLLBAR_AUTO == mVScrollMode ) || UI_SCROLLBAR_ALWAYS_ON == mVScrollMode )
width -= mVScrollBar->getRealSize().getWidth();
Float stepVal = width / (Float)mMaxTextWidth;
mHScrollBar->setPageStep( stepVal );
mHScrollBar->setClickStep( stepVal );
}
void UIListBox::findMaxWidth() {
Uint32 size = (Uint32)mItems.size();
Int32 width;
@@ -409,8 +422,8 @@ void UIListBox::findMaxWidth() {
else
width = mFont->getTextWidth( mTexts[i] );
if ( width > dpToPxI( mMaxTextWidth ) )
mMaxTextWidth = (Uint32)pxToDpI( width );
if ( width > (Int32)mMaxTextWidth )
mMaxTextWidth = width;
}
}
@@ -425,8 +438,9 @@ void UIListBox::itemUpdateSize( UIListBoxItem * Item ) {
if ( NULL != Item ) {
Int32 width = (Int32)Item->getTextWidth();
if ( width > dpToPxI( mMaxTextWidth ) )
mMaxTextWidth = (Uint32)pxToDpI( width );
if ( width > (Int32)mMaxTextWidth ) {
mMaxTextWidth = width;
}
if ( !mHScrollBar->isVisible() ) {
if ( width < mContainer->getSize().getWidth() )
@@ -503,8 +517,8 @@ void UIListBox::updateScroll( bool FromScrollChange ) {
}
if ( Clipped && ( UI_SCROLLBAR_AUTO == mHScrollMode || UI_SCROLLBAR_ALWAYS_ON == mHScrollMode ) ) {
if ( ( mVScrollBar->isVisible() && mContainer->getSize().getWidth() - mVScrollBar->getSize().getWidth() < (Int32)mMaxTextWidth ) ||
( !mVScrollBar->isVisible() && mContainer->getSize().getWidth() < (Int32)mMaxTextWidth ) ) {
if ( ( mVScrollBar->isVisible() && mContainer->getRealSize().getWidth() - mVScrollBar->getRealSize().getWidth() < (Int32)mMaxTextWidth ) ||
( !mVScrollBar->isVisible() && mContainer->getRealSize().getWidth() < (Int32)mMaxTextWidth ) ) {
mHScrollBar->setVisible( true );
mHScrollBar->setEnabled( true );
@@ -513,9 +527,9 @@ void UIListBox::updateScroll( bool FromScrollChange ) {
Int32 ScrollH;
if ( mVScrollBar->isVisible() )
ScrollH = mMaxTextWidth - mContainer->getSize().getWidth() + mVScrollBar->getSize().getWidth();
ScrollH = pxToDpI( mMaxTextWidth ) - mContainer->getSize().getWidth() + mVScrollBar->getSize().getWidth();
else
ScrollH = mMaxTextWidth - mContainer->getSize().getWidth();
ScrollH = pxToDpI( mMaxTextWidth ) - mContainer->getSize().getWidth();
Int32 HScrolleable = (Uint32)( mHScrollBar->getValue() * ScrollH );
@@ -640,6 +654,8 @@ void UIListBox::updateScroll( bool FromScrollChange ) {
mHScrollBar->setPosition( mHScrollPadding.Left, mSize.getHeight() - mHScrollBar->getSize().getHeight() + mHScrollPadding.Top );
mHScrollBar->setSize( mSize.getWidth() - mVScrollBar->getSize().getWidth() + mHScrollPadding.Right, mHScrollBar->getSize().getHeight() + mHScrollPadding.Bottom );
}
setHScrollStep();
}
void UIListBox::itemKeyEvent( const UIEventKey &Event ) {

View File

@@ -147,7 +147,6 @@ void UISkinComplex::setSkin( const Uint32& State ) {
eeASSERT ( State < UISkinState::StateCount );
for ( Uint32 Side = 0; Side < SideCount; Side++ ) {
SubTexture * SubTexture = TextureAtlasManager::instance()->getSubTextureByName( std::string( mName + "_" + UISkin::getSkinStateName( State ) + "_" + SideSuffix[ Side ] ) );
if ( NULL != SubTexture )
@@ -168,7 +167,7 @@ SubTexture * UISkinComplex::getSubTextureSide( const Uint32& State, const Uint32
}
void UISkinComplex::stateNormalToState( const Uint32& State ) {
if ( NULL == mSubTexture[ State ][ 0 ] ) {
if ( NULL == mSubTexture[ State ][ Center ] ) {
for ( Uint32 Side = 0; Side < SideCount; Side++ ) {
mSubTexture[ State ][ Side ] = mSubTexture[ UISkinState::StateNormal ][ Side ];
}

View File

@@ -21,7 +21,7 @@ UISlider::UISlider( const UISlider::CreateParams& Params ) :
UIControl::CreateParams BgParams;
BgParams.setParent( this );
if ( !mOrientation )
if ( UI_HORIZONTAL == mOrientation )
BgParams.Size = Sizei( mSize.getWidth() - 16, 8 );
else
BgParams.Size = Sizei( 8, mSize.getHeight() - 16 );
@@ -41,7 +41,7 @@ UISlider::UISlider( const UISlider::CreateParams& Params ) :
mSlider->setVisible( true );
mSlider->setDragEnabled( true );
if ( !mOrientation )
if ( UI_HORIZONTAL == mOrientation )
mSlider->centerVertical();
else
mSlider->centerHorizontal();

View File

@@ -159,7 +159,7 @@ void EETest::createUIThemeTextureAtlas() {
std::string Path( MyPath + "ui/" + mThemeName );
if ( !FileSystem::fileExists( tgpath + EE_TEXTURE_ATLAS_EXTENSION ) ) {
TexturePacker tp( 256, 256, true, 2 );
TexturePacker tp( 512, 512, true, 2 );
tp.addTexturesPath( Path );
tp.packTextures();
tp.save( tgpath + ".png", SAVE_TYPE_PNG );
@@ -286,7 +286,7 @@ void EETest::createUI() {
str[i-1] = "Test ListBox " + String::toStr(i) + " testing it right now!";
}
/*
UIControl::CreateParams Params( UIManager::instance()->getMainControl(), Vector2i(0,0), Sizei( 530, 380 ), UI_FILL_BACKGROUND | UI_CLIP_ENABLE | UI_BORDER );
Params.Border.setWidth( 2 );
@@ -547,7 +547,7 @@ void EETest::createUI() {
TxtGfxParams.Flags = UI_VALIGN_CENTER | UI_HALIGN_CENTER;
TxtGfxParams.SubTexture = mTheme->getIconByName( "ok" );
for ( Uint32 i = 0; i < 100; i++ ) {
for ( Uint32 i = 0; i < 15; i++ ) {
UIGridCell * Cell = eeNew( UIGridCell, ( CellParams ) );
UITextBox * TxtBox = eeNew( UITextBox, ( TxtBoxParams ) );
UITextInput * TxtInput = eeNew( UITextInput, ( TxtInputParams ) );
@@ -587,6 +587,7 @@ void EETest::createUI() {
eePRINTL( "CreateUI time: %4.3f ms.", TE.getElapsed().asMilliseconds() );
/**/
/**/
UIRadioButton * ctrl = eeNew( UIRadioButton, () );
ctrl->setPosition( 100, 100 );
ctrl->setSize( 320, 32 );
@@ -658,7 +659,7 @@ void EETest::createUI() {
UIListBox * listBox = eeNew( UIListBox, () );
listBox->setPosition( 50, 320 );
listBox->setSize( 100, 160 );
listBox->setSize( 200, 160 );
listBox->setVisible( true );
listBox->setEnabled( true );
listBox->addListBoxItems( str );