mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
Optimized memory usage of cUIListBox.
Optimized polygon2 template.
This commit is contained in:
@@ -10,13 +10,12 @@
|
||||
#include <cctype>
|
||||
#include <cassert>
|
||||
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
@@ -95,7 +95,7 @@ Uint32 cTextureFactory::FindFreeSlot() {
|
||||
if ( mVectorFreeSlots.size() ) {
|
||||
Uint32 Pos = mVectorFreeSlots.front();
|
||||
|
||||
mVectorFreeSlots.pop();
|
||||
mVectorFreeSlots.pop_front();
|
||||
|
||||
return Pos;
|
||||
}
|
||||
@@ -153,7 +153,7 @@ bool cTextureFactory::Remove( Uint32 TexId ) {
|
||||
mCurrentTexture[ i ] = 0;
|
||||
}
|
||||
|
||||
mVectorFreeSlots.push( TexId );
|
||||
mVectorFreeSlots.push_back( TexId );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -316,7 +316,7 @@ void cTextureFactory::Allocate( const eeUint& size ) {
|
||||
mTextures.resize( size + 1, NULL );
|
||||
|
||||
for ( eeUint i = 1; i < mTextures.size(); i++ )
|
||||
mVectorFreeSlots.push( i );
|
||||
mVectorFreeSlots.push_back( i );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ class EE_API cTextureFactory: public tSingleton<cTextureFactory>, protected cMut
|
||||
|
||||
std::string mAppPath;
|
||||
|
||||
std::queue<Uint32> mVectorFreeSlots;
|
||||
std::list<Uint32> mVectorFreeSlots;
|
||||
|
||||
void UnloadTextures();
|
||||
|
||||
|
||||
@@ -556,7 +556,7 @@ void cEETest::CreateUI() {
|
||||
mListBox->Visible( true );
|
||||
mListBox->Enabled( true );
|
||||
|
||||
Int32 wsize = 100;
|
||||
Int32 wsize = 10000;
|
||||
|
||||
if ( wsize ) {
|
||||
std::vector<std::wstring> wstr(wsize);
|
||||
|
||||
@@ -96,8 +96,10 @@ cUIScrollBar * cUIListBox::HScrollBar() const {
|
||||
void cUIListBox::AddListBoxItems( std::vector<std::wstring> Texts ) {
|
||||
mDisableScrollUpdate = true;
|
||||
|
||||
for ( Uint32 i = 0; i < Texts.size(); i++ )
|
||||
AddListBoxItem( Texts[i] );
|
||||
for ( Uint32 i = 0; i < Texts.size(); i++ ) {
|
||||
mTexts.push_back( Texts[i] );
|
||||
mItems.push_back( NULL );
|
||||
}
|
||||
|
||||
mDisableScrollUpdate = false;
|
||||
|
||||
@@ -106,6 +108,7 @@ void cUIListBox::AddListBoxItems( std::vector<std::wstring> Texts ) {
|
||||
|
||||
Uint32 cUIListBox::AddListBoxItem( cUIListBoxItem * Item ) {
|
||||
mItems.push_back( Item );
|
||||
mTexts.push_back( Item->Text() );
|
||||
|
||||
if ( Item->Parent() != mContainer )
|
||||
Item->Parent( mContainer );
|
||||
@@ -132,15 +135,19 @@ Uint32 cUIListBox::AddListBoxItem( const std::string& Text ) {
|
||||
}
|
||||
|
||||
Uint32 cUIListBox::AddListBoxItem( const std::wstring& Text ) {
|
||||
return AddListBoxItem( CreateListBoxItem( Text ) );
|
||||
}
|
||||
|
||||
cUIListBoxItem * cUIListBox::CreateListBoxItem( const std::wstring& Name ) {
|
||||
cUITextBox::CreateParams TextParams;
|
||||
TextParams.Parent( mContainer );
|
||||
TextParams.Flags = UI_VALIGN_CENTER | UI_HALIGN_LEFT;
|
||||
TextParams.Font = mFont;
|
||||
TextParams.FontColor = mFontColor;
|
||||
cUIListBoxItem * tItem = eeNew( cUIListBoxItem, ( TextParams ) );
|
||||
tItem->Text( Text );
|
||||
tItem->Text( Name );
|
||||
|
||||
return AddListBoxItem( tItem );
|
||||
return tItem;
|
||||
}
|
||||
|
||||
Uint32 cUIListBox::RemoveListBoxItem( const std::wstring& Text ) {
|
||||
@@ -154,7 +161,8 @@ Uint32 cUIListBox::RemoveListBoxItem( cUIListBoxItem * Item ) {
|
||||
void cUIListBox::RemoveListBoxItems( std::vector<Uint32> ItemsIndex ) {
|
||||
if ( ItemsIndex.size() && 0xFFFFFFFF != ItemsIndex[0] ) {
|
||||
std::vector<cUIListBoxItem*> ItemsCpy;
|
||||
bool erase = false;
|
||||
bool erase;
|
||||
mTexts.clear();
|
||||
|
||||
for ( Uint32 i = 0; i < mItems.size(); i++ ) {
|
||||
erase = false;
|
||||
@@ -179,8 +187,9 @@ void cUIListBox::RemoveListBoxItems( std::vector<Uint32> ItemsIndex ) {
|
||||
|
||||
if ( !erase ) {
|
||||
ItemsCpy.push_back( mItems[i] );
|
||||
mTexts.push_back( mItems[i]->Text() );
|
||||
} else {
|
||||
eeDelete( mItems[i] ); // doesn't call to mItems[i]->Close(); because is not checking for close.
|
||||
eeSAFE_DELETE( mItems[i] ); // doesn't call to mItems[i]->Close(); because is not checking for close.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,6 +331,22 @@ void cUIListBox::ContainerResize() {
|
||||
mContainer->Size( mSize.Width() - mPaddingContainer.Right - mPaddingContainer.Left, mSize.Height() - mPaddingContainer.Top - mPaddingContainer.Bottom );
|
||||
}
|
||||
|
||||
void cUIListBox::CreateItemIndex( const Uint32& i ) {
|
||||
if ( NULL == mItems[i] ) {
|
||||
mItems[i] = CreateListBoxItem( mTexts[i] );
|
||||
|
||||
ItemUpdateSize( mItems[i] );
|
||||
|
||||
for ( std::list<Uint32>::iterator it = mSelected.begin(); it != mSelected.end(); it++ ) {
|
||||
if ( *it == i ) {
|
||||
mItems[i]->Select();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cUIListBox::UpdateScroll( bool FromScrollChange ) {
|
||||
if ( !mItems.size() )
|
||||
return;
|
||||
@@ -380,12 +405,12 @@ void cUIListBox::UpdateScroll( bool FromScrollChange ) {
|
||||
}
|
||||
}
|
||||
|
||||
VisibleItems = mContainer->Size().Height() / mRowHeight;
|
||||
mItemsNotVisible = (Uint32)mItems.size() - VisibleItems;
|
||||
Uint32 Scrolleable = (Uint32)mItems.size() * mRowHeight - mContainer->Size().Height();
|
||||
bool isScrollVisible = mScrollBar->Visible();
|
||||
bool isHScrollVisible = mHScrollBar->Visible();
|
||||
bool FirstVisible = false;
|
||||
VisibleItems = mContainer->Size().Height() / mRowHeight;
|
||||
mItemsNotVisible = (Uint32)mItems.size() - VisibleItems;
|
||||
Uint32 Scrolleable = (Uint32)mItems.size() * mRowHeight - mContainer->Size().Height();
|
||||
bool isScrollVisible = mScrollBar->Visible();
|
||||
bool isHScrollVisible = mHScrollBar->Visible();
|
||||
bool FirstVisible = false;
|
||||
|
||||
if ( Clipped && mSmoothScroll ) {
|
||||
RelPos = (Uint32)( mScrollBar->Value() * Scrolleable );
|
||||
@@ -402,6 +427,11 @@ void cUIListBox::UpdateScroll( bool FromScrollChange ) {
|
||||
ItemPosMax = ItemPos + mRowHeight;
|
||||
|
||||
if ( ( ItemPos >= (Int32)RelPos || ItemPosMax >= (Int32)RelPos ) && ( ItemPos <= (Int32)RelPosMax ) ) {
|
||||
if ( NULL == Item ) {
|
||||
CreateItemIndex( i );
|
||||
Item = mItems[i];
|
||||
}
|
||||
|
||||
Item->Pos( mHScrollInit, ItemPos - RelPos );
|
||||
Item->Enabled( true );
|
||||
Item->Visible( true );
|
||||
@@ -413,12 +443,17 @@ void cUIListBox::UpdateScroll( bool FromScrollChange ) {
|
||||
|
||||
mVisibleLast = i;
|
||||
} else {
|
||||
Item->Enabled( false );
|
||||
Item->Visible( false );
|
||||
//Item->Enabled( false );
|
||||
//Item->Visible( false );
|
||||
|
||||
eeSAFE_DELETE( mItems[i] );
|
||||
Item = NULL;
|
||||
}
|
||||
|
||||
if ( ( !wasScrollVisible && isScrollVisible ) || ( wasScrollVisible && !isScrollVisible ) ||( !wasHScrollVisible && isHScrollVisible ) || ( wasHScrollVisible && !isHScrollVisible ) )
|
||||
ItemUpdateSize( Item );
|
||||
if ( NULL != Item ) {
|
||||
if ( ( !wasScrollVisible && isScrollVisible ) || ( wasScrollVisible && !isScrollVisible ) ||( !wasHScrollVisible && isHScrollVisible ) || ( wasHScrollVisible && !isHScrollVisible ) )
|
||||
ItemUpdateSize( Item );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RelPosMax = (Uint32)mItems.size();
|
||||
@@ -438,6 +473,11 @@ void cUIListBox::UpdateScroll( bool FromScrollChange ) {
|
||||
ItemPos = mRowHeight * ( i - RelPos );
|
||||
|
||||
if ( i >= RelPos && i < RelPosMax ) {
|
||||
if ( NULL == Item ) {
|
||||
CreateItemIndex( i );
|
||||
Item = mItems[i];
|
||||
}
|
||||
|
||||
if ( Clipped )
|
||||
Item->Pos( mHScrollInit, ItemPos );
|
||||
else
|
||||
@@ -453,12 +493,17 @@ void cUIListBox::UpdateScroll( bool FromScrollChange ) {
|
||||
|
||||
mVisibleLast = i;
|
||||
} else {
|
||||
Item->Enabled( false );
|
||||
Item->Visible( false );
|
||||
//Item->Enabled( false );
|
||||
//Item->Visible( false );
|
||||
|
||||
eeSAFE_DELETE( mItems[i] );
|
||||
Item = NULL;
|
||||
}
|
||||
|
||||
if ( ( !wasScrollVisible && isScrollVisible ) || ( wasScrollVisible && !isScrollVisible ) ||( !wasHScrollVisible && isHScrollVisible ) || ( wasHScrollVisible && !isHScrollVisible ) )
|
||||
ItemUpdateSize( Item );
|
||||
if ( NULL != Item ) {
|
||||
if ( ( !wasScrollVisible && isScrollVisible ) || ( wasScrollVisible && !isScrollVisible ) ||( !wasHScrollVisible && isHScrollVisible ) || ( wasHScrollVisible && !isHScrollVisible ) )
|
||||
ItemUpdateSize( Item );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -476,7 +521,8 @@ Uint32 cUIListBox::OnSelected() {
|
||||
|
||||
void cUIListBox::ResetItemsStates() {
|
||||
for ( Uint32 i = 0; i < mItems.size(); i++ ) {
|
||||
mItems[i]->Unselect();
|
||||
if ( NULL != mItems[i] )
|
||||
mItems[i]->Unselect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,8 +537,12 @@ cUIListBoxItem * cUIListBox::GetItem( const Uint32& Index ) const {
|
||||
}
|
||||
|
||||
cUIListBoxItem * cUIListBox::GetItemSelected() {
|
||||
if ( mSelected.size() )
|
||||
if ( mSelected.size() ) {
|
||||
if ( NULL == mItems[ mSelected.front() ] )
|
||||
CreateItemIndex( mSelected.front() );
|
||||
|
||||
return mItems[ mSelected.front() ];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -512,8 +562,12 @@ std::list<cUIListBoxItem *> cUIListBox::GetItemsSelected() {
|
||||
std::list<cUIListBoxItem *> tItems;
|
||||
std::list<Uint32>::iterator it;
|
||||
|
||||
for ( it = mSelected.begin(); it != mSelected.end(); it++ )
|
||||
for ( it = mSelected.begin(); it != mSelected.end(); it++ ) {
|
||||
if ( NULL == mItems[ *it ] )
|
||||
CreateItemIndex( *it );
|
||||
|
||||
tItems.push_back( mItems[ *it ] );
|
||||
}
|
||||
|
||||
return tItems;
|
||||
}
|
||||
|
||||
@@ -142,8 +142,9 @@ class EE_API cUIListBox : public cUIControlAnim {
|
||||
Uint32 mVisibleFirst;
|
||||
Uint32 mVisibleLast;
|
||||
|
||||
std::list<Uint32> mSelected;
|
||||
std::list<Uint32> mSelected;
|
||||
std::vector<cUIListBoxItem *> mItems;
|
||||
std::vector<std::wstring> mTexts;
|
||||
|
||||
void UpdateScroll( bool FromScrollChange = false );
|
||||
|
||||
@@ -176,6 +177,10 @@ class EE_API cUIListBox : public cUIControlAnim {
|
||||
void FindMaxWidth();
|
||||
|
||||
void ManageKeyboard();
|
||||
|
||||
cUIListBoxItem * CreateListBoxItem( const std::wstring& Name );
|
||||
|
||||
void CreateItemIndex( const Uint32& i );
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -19,7 +19,8 @@ void cUIListBoxContainer::Update() {
|
||||
|
||||
if ( LBParent->mItems.size() ) {
|
||||
for ( Uint32 i = LBParent->mVisibleFirst; i <= LBParent->mVisibleLast; i++ )
|
||||
LBParent->mItems[i]->Update();
|
||||
if ( NULL != LBParent->mItems[i] )
|
||||
LBParent->mItems[i]->Update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +29,8 @@ void cUIListBoxContainer::DrawChilds() {
|
||||
|
||||
if ( LBParent->mItems.size() ) {
|
||||
for ( Uint32 i = LBParent->mVisibleFirst; i <= LBParent->mVisibleLast; i++ )
|
||||
LBParent->mItems[i]->InternalDraw();
|
||||
if ( NULL != LBParent->mItems[i] )
|
||||
LBParent->mItems[i]->InternalDraw();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +44,14 @@ cUIControl * cUIListBoxContainer::OverFind( const eeVector2f& Point ) {
|
||||
|
||||
if ( PointInsidePolygon2( mPoly, Point ) ) {
|
||||
for ( Uint32 i = LBParent->mVisibleFirst; i <= LBParent->mVisibleLast; i++ ) {
|
||||
cUIControl * ChildOver = LBParent->mItems[i]->OverFind( Point );
|
||||
if ( NULL != LBParent->mItems[i] ) {
|
||||
cUIControl * ChildOver = LBParent->mItems[i]->OverFind( Point );
|
||||
|
||||
if ( NULL != ChildOver ) {
|
||||
pOver = ChildOver;
|
||||
if ( NULL != ChildOver ) {
|
||||
pOver = ChildOver;
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,12 @@ cUIListBoxItem::cUIListBoxItem( cUITextBox::CreateParams& Params ) :
|
||||
}
|
||||
|
||||
cUIListBoxItem::~cUIListBoxItem() {
|
||||
}
|
||||
if ( cUIManager::instance()->FocusControl() == this )
|
||||
cUIManager::instance()->FocusControl( mParentCtrl );
|
||||
|
||||
if ( cUIManager::instance()->OverControl() == this )
|
||||
cUIManager::instance()->OverControl( mParentCtrl );
|
||||
}
|
||||
|
||||
void cUIListBoxItem::SetTheme( cUITheme * Theme ) {
|
||||
cUIControl::SetTheme( Theme, "listboxitem" );
|
||||
|
||||
@@ -12,12 +12,13 @@ cUITextBox::cUITextBox( const cUITextBox::CreateParams& Params ) :
|
||||
{
|
||||
mType |= UI_TYPE_GET(UI_TYPE_TEXTBOX);
|
||||
|
||||
mTextCache.Font( Params.Font );
|
||||
mTextCache.Color( mFontColor );
|
||||
mTextCache.ShadowColor( mFontShadowColor );
|
||||
mTextCache = eeNew( cTextCache, () );
|
||||
mTextCache->Font( Params.Font );
|
||||
mTextCache->Color( mFontColor );
|
||||
mTextCache->ShadowColor( mFontShadowColor );
|
||||
|
||||
if ( NULL == Params.Font && NULL != cUIThemeManager::instance()->DefaultFont() ) {
|
||||
mTextCache.Font( cUIThemeManager::instance()->DefaultFont() );
|
||||
mTextCache->Font( cUIThemeManager::instance()->DefaultFont() );
|
||||
} else {
|
||||
eePRINT( "cUITextBox::cUITextBox : Created a UI TextBox without a defined font." );
|
||||
}
|
||||
@@ -26,17 +27,18 @@ cUITextBox::cUITextBox( const cUITextBox::CreateParams& Params ) :
|
||||
}
|
||||
|
||||
cUITextBox::~cUITextBox() {
|
||||
eeSAFE_DELETE( mTextCache );
|
||||
}
|
||||
|
||||
void cUITextBox::Draw() {
|
||||
if ( mVisible ) {
|
||||
cUIControl::Draw();
|
||||
|
||||
if ( mTextCache.GetTextWidth() ) {
|
||||
if ( mTextCache->GetTextWidth() ) {
|
||||
if ( mFlags & UI_CLIP_ENABLE )
|
||||
cUIManager::instance()->ClipEnable( mScreenPos.x + mPadding.Left, mScreenPos.y + mPadding.Top, mSize.Width() - mPadding.Left - mPadding.Right, mSize.Height() - mPadding.Bottom );
|
||||
|
||||
mTextCache.Draw( (eeFloat)mScreenPos.x + mAlignOffset.x + (eeFloat)mPadding.Left + 1.f, (eeFloat)mScreenPos.y + mAlignOffset.y + (eeFloat)mPadding.Top, Flags(), 1.f, 0.f, mBlend );
|
||||
mTextCache->Draw( (eeFloat)mScreenPos.x + mAlignOffset.x + (eeFloat)mPadding.Left + 1.f, (eeFloat)mScreenPos.y + mAlignOffset.y + (eeFloat)mPadding.Top, Flags(), 1.f, 0.f, mBlend );
|
||||
|
||||
if ( mFlags & UI_CLIP_ENABLE )
|
||||
cUIManager::instance()->ClipDisable();
|
||||
@@ -45,11 +47,11 @@ void cUITextBox::Draw() {
|
||||
}
|
||||
|
||||
cFont * cUITextBox::Font() const {
|
||||
return mTextCache.Font();
|
||||
return mTextCache->Font();
|
||||
}
|
||||
|
||||
void cUITextBox::Font( cFont * font ) {
|
||||
mTextCache.Font( font );
|
||||
mTextCache->Font( font );
|
||||
AutoShrink();
|
||||
AutoSize();
|
||||
AutoAlign();
|
||||
@@ -57,7 +59,7 @@ void cUITextBox::Font( cFont * font ) {
|
||||
}
|
||||
|
||||
const std::wstring& cUITextBox::Text() {
|
||||
return mTextCache.Text();
|
||||
return mTextCache->Text();
|
||||
}
|
||||
|
||||
void cUITextBox::Text( const std::string& text ) {
|
||||
@@ -65,7 +67,7 @@ void cUITextBox::Text( const std::string& text ) {
|
||||
}
|
||||
|
||||
void cUITextBox::Text( const std::wstring& text ) {
|
||||
mTextCache.Text( text );
|
||||
mTextCache->Text( text );
|
||||
AutoShrink();
|
||||
AutoSize();
|
||||
AutoAlign();
|
||||
@@ -79,7 +81,7 @@ const eeColorA& cUITextBox::Color() const {
|
||||
void cUITextBox::Color( const eeColorA& color ) {
|
||||
mFontColor = color;
|
||||
Alpha( color.A() );
|
||||
mTextCache.Color( mFontColor );
|
||||
mTextCache->Color( mFontColor );
|
||||
}
|
||||
|
||||
const eeColorA& cUITextBox::ShadowColor() const {
|
||||
@@ -99,24 +101,24 @@ void cUITextBox::Alpha( const eeFloat& alpha ) {
|
||||
|
||||
void cUITextBox::AutoShrink() {
|
||||
if ( Flags() & UI_AUTO_SHRINK_TEXT ) {
|
||||
mTextCache.Font()->ShrinkText( mTextCache.Text(), mSize.Width() );
|
||||
mTextCache->Font()->ShrinkText( mTextCache->Text(), mSize.Width() );
|
||||
}
|
||||
}
|
||||
|
||||
void cUITextBox::AutoSize() {
|
||||
if ( Flags() & UI_AUTO_SIZE ) {
|
||||
mSize.Width( (eeInt)mTextCache.GetTextWidth() );
|
||||
mSize.Height( (eeInt)mTextCache.GetTextHeight() );
|
||||
mSize.Width( (eeInt)mTextCache->GetTextWidth() );
|
||||
mSize.Height( (eeInt)mTextCache->GetTextHeight() );
|
||||
}
|
||||
}
|
||||
|
||||
void cUITextBox::AutoAlign() {
|
||||
switch ( FontHAlignGet( Flags() ) ) {
|
||||
case UI_HALIGN_CENTER:
|
||||
mAlignOffset.x = (eeFloat)( (Int32)( mSize.x - mTextCache.GetTextWidth() ) / 2 );
|
||||
mAlignOffset.x = (eeFloat)( (Int32)( mSize.x - mTextCache->GetTextWidth() ) / 2 );
|
||||
break;
|
||||
case UI_HALIGN_RIGHT:
|
||||
mAlignOffset.x = ( (eeFloat)mSize.x - (eeFloat)mTextCache.GetTextWidth() );
|
||||
mAlignOffset.x = ( (eeFloat)mSize.x - (eeFloat)mTextCache->GetTextWidth() );
|
||||
break;
|
||||
case UI_HALIGN_LEFT:
|
||||
mAlignOffset.x = 0.f;
|
||||
@@ -125,10 +127,10 @@ void cUITextBox::AutoAlign() {
|
||||
|
||||
switch ( FontVAlignGet( Flags() ) ) {
|
||||
case UI_VALIGN_CENTER:
|
||||
mAlignOffset.y = (eeFloat)( ( (Int32)( mSize.y - mTextCache.GetTextHeight() ) ) / 2 );
|
||||
mAlignOffset.y = (eeFloat)( ( (Int32)( mSize.y - mTextCache->GetTextHeight() ) ) / 2 );
|
||||
break;
|
||||
case UI_VALIGN_BOTTOM:
|
||||
mAlignOffset.y = ( (eeFloat)mSize.y - (eeFloat)mTextCache.GetTextHeight() );
|
||||
mAlignOffset.y = ( (eeFloat)mSize.y - (eeFloat)mTextCache->GetTextHeight() );
|
||||
break;
|
||||
case UI_VALIGN_TOP:
|
||||
mAlignOffset.y = 0.f;
|
||||
@@ -143,7 +145,7 @@ void cUITextBox::OnSizeChange() {
|
||||
|
||||
cUIControlAnim::OnSizeChange();
|
||||
|
||||
mTextCache.Cache();
|
||||
mTextCache->Cache();
|
||||
}
|
||||
|
||||
void cUITextBox::OnTextChanged() {
|
||||
@@ -165,25 +167,25 @@ const eeRecti& cUITextBox::Padding() const {
|
||||
void cUITextBox::SetTheme( cUITheme * Theme ) {
|
||||
cUIControlAnim::SetTheme( Theme );
|
||||
|
||||
if ( NULL == mTextCache.Font() && NULL != Theme->DefaultFont() ) {
|
||||
mTextCache.Font( Theme->DefaultFont() );
|
||||
if ( NULL == mTextCache->Font() && NULL != Theme->DefaultFont() ) {
|
||||
mTextCache->Font( Theme->DefaultFont() );
|
||||
}
|
||||
}
|
||||
|
||||
cTextCache& cUITextBox::GetTextCache() {
|
||||
cTextCache * cUITextBox::GetTextCache() {
|
||||
return mTextCache;
|
||||
}
|
||||
|
||||
eeFloat cUITextBox::GetTextWidth() {
|
||||
return mTextCache.GetTextWidth();
|
||||
return mTextCache->GetTextWidth();
|
||||
}
|
||||
|
||||
eeFloat cUITextBox::GetTextHeight() {
|
||||
return mTextCache.GetTextHeight();
|
||||
return mTextCache->GetTextHeight();
|
||||
}
|
||||
|
||||
const eeInt& cUITextBox::GetNumLines() const {
|
||||
return mTextCache.GetNumLines();
|
||||
return mTextCache->GetNumLines();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -60,7 +60,7 @@ class EE_API cUITextBox : public cUIControlAnim {
|
||||
|
||||
virtual void SetTheme( cUITheme * Theme );
|
||||
|
||||
cTextCache& GetTextCache();
|
||||
cTextCache * GetTextCache();
|
||||
|
||||
eeFloat GetTextWidth();
|
||||
|
||||
@@ -68,7 +68,7 @@ class EE_API cUITextBox : public cUIControlAnim {
|
||||
|
||||
const eeInt& GetNumLines() const;
|
||||
protected:
|
||||
cTextCache mTextCache;
|
||||
cTextCache * mTextCache;
|
||||
eeColorA mFontColor;
|
||||
eeColorA mFontShadowColor;
|
||||
eeVector2f mAlignOffset;
|
||||
|
||||
@@ -68,7 +68,7 @@ void cUITextInput::Draw() {
|
||||
if ( CurPosX > (eeFloat)mScreenPos.x + (eeFloat)mSize.x )
|
||||
CurPosX = (eeFloat)mScreenPos.x + (eeFloat)mSize.x;
|
||||
|
||||
P.DrawLine( CurPosX, CurPosY, CurPosX, CurPosY + mTextCache.Font()->GetFontHeight(), 1.f );
|
||||
P.DrawLine( CurPosX, CurPosY, CurPosX, CurPosY + mTextCache->Font()->GetFontHeight(), 1.f );
|
||||
|
||||
if ( disableSmooth )
|
||||
cEngine::instance()->SetLineSmooth( true );
|
||||
@@ -121,13 +121,13 @@ void cUITextInput::AlignFix() {
|
||||
Uint32 NLPos = 0;
|
||||
Uint32 LineNum = mTextBuffer.GetCurPosLinePos( NLPos );
|
||||
|
||||
mTextCache.Font()->SetText( mTextBuffer.Buffer().substr( NLPos, mTextBuffer.CurPos() - NLPos ) );
|
||||
mTextCache->Font()->SetText( mTextBuffer.Buffer().substr( NLPos, mTextBuffer.CurPos() - NLPos ) );
|
||||
|
||||
eeFloat tW = mTextCache.Font()->GetTextWidth();
|
||||
eeFloat tW = mTextCache->Font()->GetTextWidth();
|
||||
eeFloat tX = mAlignOffset.x + tW;
|
||||
|
||||
mCurPos.x = tW;
|
||||
mCurPos.y = (eeFloat)LineNum * (eeFloat)mTextCache.GetTextHeight();
|
||||
mCurPos.y = (eeFloat)LineNum * (eeFloat)mTextCache->GetTextHeight();
|
||||
|
||||
if ( tX < 0.f )
|
||||
mAlignOffset.x = -( mAlignOffset.x + ( tW - mAlignOffset.x ) );
|
||||
|
||||
@@ -38,7 +38,7 @@ class Polygon2 {
|
||||
|
||||
void Scale( const T& scale, const Vector2<T>& Center );
|
||||
private:
|
||||
std::deque< Vector2<T> > Vector;
|
||||
std::vector< Vector2<T> > Vector;
|
||||
T cOffsetX, cOffsetY;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user