mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-30 10:06:35 +03:00
Some minor fixes on the ListBox.
This commit is contained in:
@@ -555,7 +555,7 @@ void cEETest::CreateUI() {
|
||||
mListBox->Visible( true );
|
||||
mListBox->Enabled( true );
|
||||
|
||||
for ( Int32 i = 1; i <= 25; i++ )
|
||||
for ( Int32 i = 1; i <= 12; i++ )
|
||||
mListBox->AddListBoxItem( L"Test ListBox " + toWStr(i) + L" testing it right now!" );
|
||||
|
||||
mBuda = L"El mono ve el pez en el agua y sufre. Piensa que su mundo es el único que existe, el mejor, el real. Sufre porque es bueno y tiene compasión, lo ve y piensa: \"Pobre se está ahogando no puede respirar\". Y lo saca, lo saca y se queda tranquilo, por fin lo salvé. Pero el pez se retuerce de dolor y muere. Por eso te mostré el sueño, es imposible meter el mar en tu cabeza, que es un balde.";
|
||||
@@ -587,6 +587,8 @@ void cEETest::ButtonClick( const cUIEvent * Event ) {
|
||||
Gfx->StartRotation( 0, 2500, 2500 );
|
||||
Gfx->StartMovement( eeVector2i( eeRandi( 0, EE->GetWidth() ), -64 ), eeVector2i( eeRandi( 0, EE->GetWidth() ), EE->GetHeight() + 64 ), 2500 );
|
||||
Gfx->CloseFadeOut( 3500 );
|
||||
|
||||
mListBox->AddListBoxItem( L"Test ListBox " + toWStr( mListBox->Size()+1 ) + L" testing it right now!" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -110,10 +110,16 @@ Uint32 cUIListBox::AddListBoxItem( cUIListBoxItem * Item ) {
|
||||
if ( !mDisableScrollUpdate )
|
||||
UpdateScroll();
|
||||
|
||||
Uint32 tMaxTextWidth = mMaxTextWidth;
|
||||
|
||||
ItemUpdateSize( Item );
|
||||
|
||||
Item->Visible( false );
|
||||
Item->Enabled( false );
|
||||
if ( tMaxTextWidth != mMaxTextWidth ) {
|
||||
UpdateListBoxItemsSize();
|
||||
|
||||
if ( !mDisableScrollUpdate )
|
||||
UpdateScroll();
|
||||
}
|
||||
|
||||
return mItems.size() - 1;
|
||||
}
|
||||
@@ -178,6 +184,7 @@ void cUIListBox::RemoveListBoxItems( std::vector<Uint32> ItemsIndex ) {
|
||||
mItems = ItemsCpy;
|
||||
|
||||
UpdateScroll();
|
||||
FindMaxWidth();
|
||||
UpdateListBoxItemsSize();
|
||||
}
|
||||
}
|
||||
@@ -262,11 +269,23 @@ void cUIListBox::SetRowHeight() {
|
||||
}
|
||||
}
|
||||
|
||||
void cUIListBox::UpdateListBoxItemsSize() {
|
||||
void cUIListBox::FindMaxWidth() {
|
||||
Uint32 size = mItems.size();
|
||||
Int32 width;
|
||||
|
||||
mMaxTextWidth = 0;
|
||||
|
||||
for ( Uint32 i = 0; i < size; i++ ) {
|
||||
width = mItems[i]->GetTextCache().GetTextWidth();
|
||||
|
||||
if ( width > (Int32)mMaxTextWidth )
|
||||
mMaxTextWidth = (Uint32)width;
|
||||
}
|
||||
}
|
||||
|
||||
void cUIListBox::UpdateListBoxItemsSize() {
|
||||
Uint32 size = mItems.size();
|
||||
|
||||
for ( Uint32 i = 0; i < size; i++ ) {
|
||||
ItemUpdateSize( mItems[i] );
|
||||
}
|
||||
@@ -276,7 +295,7 @@ void cUIListBox::ItemUpdateSize( cUIListBoxItem * Item ) {
|
||||
Int32 width = Item->GetTextCache().GetTextWidth();
|
||||
|
||||
if ( width > (Int32)mMaxTextWidth )
|
||||
mMaxTextWidth = width;
|
||||
mMaxTextWidth = (Uint32)width;
|
||||
|
||||
if ( !mHScrollBar->Visible() ) {
|
||||
if ( width < mContainer->Size().Width() )
|
||||
@@ -284,6 +303,8 @@ void cUIListBox::ItemUpdateSize( cUIListBoxItem * Item ) {
|
||||
|
||||
if ( ( mItemsNotVisible > 0 || mScrollAlwaysVisible ) )
|
||||
width -= mScrollBar->Size().Width();
|
||||
} else {
|
||||
width = mMaxTextWidth;
|
||||
}
|
||||
|
||||
Item->Size( width, mRowHeight );
|
||||
@@ -520,6 +541,7 @@ void cUIListBox::Font( cFont * Font ) {
|
||||
for ( Uint32 i = 0; i < mItems.size(); i++ )
|
||||
mItems[i]->Font( mFont );
|
||||
|
||||
FindMaxWidth();
|
||||
UpdateListBoxItemsSize();
|
||||
UpdateScroll();
|
||||
}
|
||||
@@ -591,4 +613,8 @@ const bool& cUIListBox::AllowHorizontalScroll() const {
|
||||
return mAllowHorizontalScroll;
|
||||
}
|
||||
|
||||
Uint32 cUIListBox::Size() {
|
||||
return mItems.size();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -113,6 +113,8 @@ class EE_API cUIListBox : public cUIControlAnim {
|
||||
void AllowHorizontalScroll( const bool& allow );
|
||||
|
||||
const bool& AllowHorizontalScroll() const;
|
||||
|
||||
Uint32 Size();
|
||||
protected:
|
||||
friend class cUIListBoxItem;
|
||||
|
||||
@@ -163,6 +165,8 @@ class EE_API cUIListBox : public cUIControlAnim {
|
||||
void ItemUpdateSize( cUIListBoxItem * Item );
|
||||
|
||||
void AutoPadding();
|
||||
|
||||
void FindMaxWidth();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user