diff --git a/ee.kdevelop b/ee.kdevelop index fd3f92565..676f94ffa 100644 --- a/ee.kdevelop +++ b/ee.kdevelop @@ -193,10 +193,7 @@ Vertical - std - automatic_%2Fhome%2Fprogramacion%2FEE - automatic_%2Fhome%2Fdownloads%2Ffiles%2FEE - automatic_%2Fhome%2Fprogramming%2FProjects%2FEE + automatic_%2Fhome%2Fprogramming%2Fprojects%2FEE diff --git a/ee.linux.cbp b/ee.linux.cbp index 142939c31..42759346d 100644 --- a/ee.linux.cbp +++ b/ee.linux.cbp @@ -33,6 +33,7 @@ + @@ -509,12 +510,16 @@ + + + + diff --git a/src/ee.h b/src/ee.h index 3d9121a6b..e278390fe 100755 --- a/src/ee.h +++ b/src/ee.h @@ -161,5 +161,7 @@ #include "ui/cuiprogressbar.hpp" #include "ui/cuilistbox.hpp" #include "ui/cuilistboxitem.hpp" + #include "ui/cuidropdownlist.hpp" + #include "ui/cuicombobox.hpp" using namespace EE::UI; #endif diff --git a/src/graphics/cfont.cpp b/src/graphics/cfont.cpp index 0124287d4..bb75f2a20 100644 --- a/src/graphics/cfont.cpp +++ b/src/graphics/cfont.cpp @@ -160,13 +160,13 @@ void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, con glRotatef( Angle, 0.0f, 0.0f, 1.0f ); glScalef( Scale, Scale, 1.0f ); glTranslatef( -Center.x, -Center.y, 0.f ); - + glTranslatef( X, Y, 0.f ); } std::vector& RenderCoords = TextCache.VertextCoords(); std::vector& Colors = TextCache.Colors(); - + #ifndef EE_GLES if ( !TextCache.CachedCoords() ) { #else @@ -193,7 +193,7 @@ void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, con if ( Char >= 0 && Char < tGlyphSize ) { eeTexCoords* C = &mTexCoords[ Char ]; - + switch(Char) { case L'\v': { @@ -245,7 +245,7 @@ void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, con RenderCoords[ numvert ].Vertex[1] = cY + C->Vertex[ z + 1 ] + nY; numvert++; } - + #ifdef EE_GLES glColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast( &Colors[0] ) ); glTexCoordPointer( 2, GL_FLOAT, sizeof(eeVertexCoords), reinterpret_cast( &RenderCoords[ numvert - 4 ] ) ); @@ -424,9 +424,9 @@ void cFont::CacheWidth( const std::wstring& Text, std::vector& LinesWid eeFloat Width = 0, MaxWidth = 0; Int32 CharID; Int32 Lines = 1; - + Int32 tGlyphSize = (Int32)mGlyphs.size(); - + for (std::size_t i = 0; i < Text.size(); ++i) { CharID = static_cast( Text.at(i) ); @@ -471,7 +471,7 @@ void cFont::ShrinkText( std::string& Str, const Uint32& MaxWidth ) { char * tStringLoop = &Str[0]; char * tLastSpace = NULL; Uint32 tGlyphSize = (Uint32)mGlyphs.size(); - + while ( *tStringLoop ) { if ( (Uint32)( *tStringLoop ) < tGlyphSize ) { eeGlyph * pChar = &mGlyphs[ ( *tStringLoop ) ]; diff --git a/src/test/ee.cpp b/src/test/ee.cpp index 529c89de2..07ed0a1eb 100644 --- a/src/test/ee.cpp +++ b/src/test/ee.cpp @@ -385,11 +385,12 @@ void cEETest::CreateUI() { CreateAquaTextureAtlas(); + /* cTextureGroupLoader tgl( MyPath + "data/aqua.etg" ); TF->GetByName( "data/aqua.png" )->TextureFilter( TEX_FILTER_NEAREST ); cUIThemeManager::instance()->Add( cUITheme::LoadFromShapeGroup( cShapeGroupManager::instance()->GetByName( "aqua" ), "aqua", "aqua" ) ); + */ - //cUIManager::instance()->SetTheme( "aqua" ); cUIManager::instance()->DefaultTheme( "aqua" ); Params.Border.Width( 2 ); @@ -422,7 +423,7 @@ void cEETest::CreateUI() { Child2->Visible( true ); Child2->Enabled( true ); Child2->StartRotation( 0.f, 360.f * 10.f, 5000.f * 10.f ); - +/* cUIGfx::CreateParams GfxParams; GfxParams.Parent( C ); GfxParams.PosSet( 160, 100 ); @@ -436,7 +437,7 @@ void cEETest::CreateUI() { Gfx->StartAlphaAnim( 100.f, 255.f, 1000.f ); Gfx->AlphaInterpolation()->Loop( true ); Gfx->AlphaInterpolation()->SetTotalTime( 1000.f ); - +*/ cUITextBox::CreateParams TextParams; TextParams.Parent( C ); TextParams.PosSet( 0, 0 ); @@ -471,7 +472,7 @@ void cEETest::CreateUI() { Button->Text( L"Click Me" ); Button->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cEETest::ButtonClick ) ); - TextParams.PosSet( 120, 20 ); + TextParams.PosSet( 130, 20 ); TextParams.Size = eeSize( 80, 22 ); TextParams.Flags = UI_VALIGN_CENTER | UI_HALIGN_LEFT; cUICheckBox * Checkbox = eeNew( cUICheckBox, ( TextParams ) ); @@ -479,13 +480,13 @@ void cEETest::CreateUI() { Checkbox->Text( L"Check Me" ); Checkbox->Enabled( true ); - TextParams.PosSet( 120, 40 ); + TextParams.PosSet( 130, 40 ); cUIRadioButton * RadioButton = eeNew( cUIRadioButton, ( TextParams ) ); RadioButton->Visible( true ); RadioButton->Text( L"Check Me" ); RadioButton->Enabled( true ); - TextParams.PosSet( 120, 60 ); + TextParams.PosSet( 130, 60 ); RadioButton = eeNew( cUIRadioButton, ( TextParams ) ); RadioButton->Visible( true ); RadioButton->Text( L"Check Me 2" ); @@ -567,6 +568,36 @@ void cEETest::CreateUI() { mListBox->AddListBoxItems( wstr ); } + cUIDropDownList::CreateParams DDLParams; + DDLParams.Parent( C ); + DDLParams.PosSet( 20, 55 ); + DDLParams.Size = eeSize( 100, 19 ); + DDLParams.Flags = UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_VALIGN_CENTER | UI_HALIGN_LEFT; + cUIDropDownList * mDropDownList = eeNew( cUIDropDownList, ( DDLParams ) ); + mDropDownList->Visible( true ); + mDropDownList->Enabled( true ); + + std::vector combostrs; + combostrs.push_back( L"Plane" ); + combostrs.push_back( L"Car" ); + combostrs.push_back( L"Bus" ); + combostrs.push_back( L"Train" ); + + mDropDownList->ListBox()->AddListBoxItems( combostrs ); + mDropDownList->ListBox()->SetSelected( 0 ); + + cUIComboBox::CreateParams ComboParams; + ComboParams.Parent( C ); + ComboParams.PosSet( 20, 80 ); + ComboParams.Size = eeSize( 100, 19 ); + DDLParams.Flags = UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_VALIGN_CENTER | UI_HALIGN_LEFT; + cUIComboBox * mComboBox = eeNew( cUIComboBox, ( ComboParams ) ); + mComboBox->Visible( true ); + mComboBox->Enabled( true ); + + mComboBox->ListBox()->AddListBoxItems( combostrs ); + mComboBox->ListBox()->SetSelected( 0 ); + 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."; TTFB->ShrinkText( mBuda, 400 ); @@ -597,7 +628,7 @@ void cEETest::ButtonClick( const cUIEvent * Event ) { 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!" ); + mListBox->AddListBoxItem( L"Test ListBox " + toWStr( mListBox->Count() + 1 ) + L" testing it right now!" ); } } diff --git a/src/ui/cuicombobox.cpp b/src/ui/cuicombobox.cpp new file mode 100644 index 000000000..3f2f10908 --- /dev/null +++ b/src/ui/cuicombobox.cpp @@ -0,0 +1,76 @@ +#include "cuicombobox.hpp" + +namespace EE { namespace UI { + +cUIComboBox::cUIComboBox( cUIComboBox::CreateParams& Params ) : + cUIDropDownList( Params ) +{ + mType |= UI_TYPE_GET( UI_TYPE_COMBOBOX ); + + AllowEditing( true ); + + ApplyDefaultTheme(); +} + +cUIComboBox::~cUIComboBox() { +} + +void cUIComboBox::SetTheme( cUITheme * Theme ) { + cUIControl::SetTheme( Theme, "combobox" ); + + AutoPadding(); + + OnSizeChange(); +} + +Uint32 cUIComboBox::OnMouseClick( const eeVector2i& Pos, const Uint32 Flags ) { + if ( Flags & EE_BUTTON_LMASK ) { + eeVector2i CtrlPos = Pos; + ScreenToControl( CtrlPos ); + + Int32 btnWidth = 0; + + if ( NULL != mSkinState && NULL != mSkinState->GetSkin() ) { + if ( mSkinState->GetSkin()->GetType() == cUISkin::UISkinComplex ) { + + cUISkinComplex * tComplex = reinterpret_cast ( mSkinState->GetSkin() ); + + cShape * tShape = tComplex->GetShapeSide( cUISkinState::StateNormal, cUISkinComplex::Right ); + + if ( NULL != tShape ) + btnWidth = tShape->RealSize().Width(); + } + } + // Fix for scaled/rotated combobox + if ( CtrlPos.x >= mSize.Width() - btnWidth ) { + ShowListBox(); + } else { + cUITextInput::OnMouseClick( Pos, Flags ); + } + } + + return 1; +} + +void cUIComboBox::OnItemSelected( const cUIEvent * Event ) { + if ( mListBox->Visible() ) { + mListBox->Enabled( false ); + mListBox->Visible( false ); + } + + mTextBuffer.Buffer( mListBox->GetItemSelectedText() ); + + eeVector2f offSet = mAlignOffset; + + Text( mTextBuffer.Buffer() ); + + mAlignOffset = offSet; + + ResetWaitCursor(); + + AlignFix(); + + mCursorPos = mTextBuffer.CurPos(); +} + +}} diff --git a/src/ui/cuicombobox.hpp b/src/ui/cuicombobox.hpp new file mode 100644 index 000000000..74f510707 --- /dev/null +++ b/src/ui/cuicombobox.hpp @@ -0,0 +1,24 @@ +#ifndef EE_UICUICOMBOBOX_HPP +#define EE_UICUICOMBOBOX_HPP + +#include "cuidropdownlist.hpp" + +namespace EE { namespace UI { + +class cUIComboBox : public cUIDropDownList { + public: + cUIComboBox( cUIComboBox::CreateParams& Params ); + + ~cUIComboBox(); + + virtual void SetTheme( cUITheme * Theme ); + + Uint32 OnMouseClick( const eeVector2i& Pos, const Uint32 Flags ); + protected: + virtual void OnItemSelected( const cUIEvent * Event ); +}; + +}} + +#endif + diff --git a/src/ui/cuicontrol.cpp b/src/ui/cuicontrol.cpp index 714db92bf..71d40d079 100644 --- a/src/ui/cuicontrol.cpp +++ b/src/ui/cuicontrol.cpp @@ -135,7 +135,7 @@ void cUIControl::Size( const eeSize& Size ) { OnSizeChange(); } -void cUIControl::Size( const Int32 Width, const Int32 Height ) { +void cUIControl::Size( const Int32& Width, const Int32& Height ) { Size( eeSize( Width, Height ) ); } @@ -178,8 +178,8 @@ cUIControl * cUIControl::Parent() const { } void cUIControl::Parent( cUIControl * parent ) { - if ( NULL != Parent() ) - Parent()->ChildRemove( this ); + if ( NULL != mParentCtrl ) + mParentCtrl->ChildRemove( this ); mParentCtrl = parent; @@ -187,6 +187,19 @@ void cUIControl::Parent( cUIControl * parent ) { mParentCtrl->ChildAdd( this ); } +bool cUIControl::IsParentOf( cUIControl * Ctrl ) { + cUIControl * tParent = Ctrl->Parent(); + + while ( NULL != tParent ) { + if ( this == tParent ) + return true; + + tParent = tParent->Parent(); + } + + return false; +} + void cUIControl::CenterHorizontal() { cUIControl * Ctrl = Parent(); @@ -219,7 +232,7 @@ void cUIControl::Draw() { BorderDraw(); if ( NULL != mSkinState ) - mSkinState->Draw( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height() ); + mSkinState->Draw( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 255 ); } } @@ -401,19 +414,18 @@ EE_PRE_BLEND_FUNC& cUIControl::Blend() { } void cUIControl::ToFront() { - Parent()->ChildRemove( this ); - mNext = NULL; - Parent()->ChildAdd( this ); + mParentCtrl->ChildRemove( this ); + mParentCtrl->ChildAdd( this ); } void cUIControl::ToBack() { - Parent()->ChildRemove( this ); - Parent()->ChildAddAt( this, 0 ); + mParentCtrl->ChildRemove( this ); + mParentCtrl->ChildAddAt( this, 0 ); } void cUIControl::ToPos( const Uint32& Pos ) { - Parent()->ChildRemove( this ); - Parent()->ChildAddAt( this, Pos ); + mParentCtrl->ChildRemove( this ); + mParentCtrl->ChildAddAt( this, Pos ); } void cUIControl::OnVisibleChange() { @@ -561,17 +573,9 @@ void cUIControl::ChildAdd( cUIControl * ChildCtrl ) { mChild = ChildCtrl; mChildLast = ChildCtrl; } else { - /* - cUIControl * ChildLoop = mChild; - - while ( NULL != ChildLoop->mNext ) - ChildLoop = ChildLoop->mNext; - - ChildLoop->mNext = ChildCtrl; - */ - mChildLast->mNext = ChildCtrl; ChildCtrl->mPrev = mChildLast; + ChildCtrl->mNext = NULL; mChildLast = ChildCtrl; } } @@ -615,26 +619,17 @@ void cUIControl::ChildRemove( cUIControl * ChildCtrl ) { if ( NULL != mChild ) mChild->mPrev = NULL; } else { - /* - cUIControl * ChildLoop = mChild; - - while ( NULL != ChildLoop->mNext ) { - if ( ChildCtrl == ChildLoop->mNext ) { - ChildLoop->mNext = ChildLoop->mNext->mNext; - return; - } - - ChildLoop = ChildLoop->mNext; - } - */ - if ( mChildLast == ChildCtrl ) mChildLast = mChildLast->mPrev; ChildCtrl->mPrev->mNext = ChildCtrl->mNext; - if ( NULL != ChildCtrl->mNext ) + if ( NULL != ChildCtrl->mNext ) { ChildCtrl->mNext->mPrev = ChildCtrl->mPrev; + ChildCtrl->mNext = NULL; + } + + ChildCtrl->mPrev = NULL; } } @@ -675,31 +670,6 @@ cUIControl * cUIControl::ChildAt( Uint32 Index ) const { } cUIControl * cUIControl::ChildPrev( cUIControl * Ctrl, bool Loop ) const { - /* - cUIControl * ChildLoop = NULL; - - if ( NULL != mChild ) { - if ( mChild != Ctrl ) { - ChildLoop = mChild; - - while ( NULL != ChildLoop ) { - if ( ChildLoop->mNext == Ctrl ) - break; - - ChildLoop = ChildLoop->mNext; - } - } else if ( Loop ) { - ChildLoop = mChild; - - while ( NULL != ChildLoop->mNext ) - ChildLoop = ChildLoop->mNext; - - } - } - - return ChildLoop; - */ - if ( Loop && Ctrl == mChild && NULL != mChild->mNext ) return mChildLast; @@ -728,19 +698,6 @@ cUIControl * cUIControl::OverFind( const eeVector2f& Point ) { UpdateQuad(); if ( PointInsidePolygon2( mPoly, Point ) ) { - /* - cUIControl * ChildLoop = mChild; - - while ( NULL != ChildLoop ) { - cUIControl * ChildOver = ChildLoop->OverFind( Point ); - - if ( NULL != ChildOver ) - pOver = ChildOver; - - ChildLoop = ChildLoop->mNext; - } - */ - cUIControl * ChildLoop = mChildLast; while ( NULL != ChildLoop ) { @@ -755,6 +712,7 @@ cUIControl * cUIControl::OverFind( const eeVector2f& Point ) { ChildLoop = ChildLoop->mPrev; } + if ( NULL == pOver ) pOver = const_cast( reinterpret_cast( this ) ); } diff --git a/src/ui/cuicontrol.hpp b/src/ui/cuicontrol.hpp index e314ff281..32a5a0f17 100644 --- a/src/ui/cuicontrol.hpp +++ b/src/ui/cuicontrol.hpp @@ -96,7 +96,7 @@ class EE_API cUIControl { void Size( const eeSize& Size ); - void Size( const Int32 Width, const Int32 Height ); + void Size( const Int32& Width, const Int32& Height ); eeRecti Rect() const; @@ -299,6 +299,8 @@ class EE_API cUIControl { cUIControl * ChildPrev( cUIControl * Ctrl, bool Loop = false ) const; cUIControl * ChildNext( cUIControl * Ctrl, bool Loop = false ) const; + + bool IsParentOf( cUIControl * Ctrl ); virtual cUIControl * OverFind( const eeVector2f& Point ); diff --git a/src/ui/cuicontrolanim.cpp b/src/ui/cuicontrolanim.cpp index 9759ebd84..72c2b90c0 100644 --- a/src/ui/cuicontrolanim.cpp +++ b/src/ui/cuicontrolanim.cpp @@ -24,6 +24,20 @@ cUIControlAnim::~cUIControlAnim() { eeSAFE_DELETE( mMoveAnim ); } + +void cUIControlAnim::Draw() { + if ( mVisible ) { + if ( mFlags & UI_FILL_BACKGROUND ) + BackgroundDraw(); + + if ( mFlags & UI_BORDER ) + BorderDraw(); + + if ( NULL != mSkinState ) + mSkinState->Draw( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), (Uint32)mAlpha ); + } +} + const eeFloat& cUIControlAnim::Angle() const { return mAngle; } diff --git a/src/ui/cuicontrolanim.hpp b/src/ui/cuicontrolanim.hpp index 7e485be00..a0d52b578 100644 --- a/src/ui/cuicontrolanim.hpp +++ b/src/ui/cuicontrolanim.hpp @@ -50,6 +50,8 @@ class EE_API cUIControlAnim : public cUIDragable { cInterpolation * AlphaInterpolation(); cWaypoints * MovementInterpolation(); + + virtual void Draw(); protected: friend class cUIManager; diff --git a/src/ui/cuidropdownlist.cpp b/src/ui/cuidropdownlist.cpp new file mode 100644 index 000000000..5f27fbd18 --- /dev/null +++ b/src/ui/cuidropdownlist.cpp @@ -0,0 +1,117 @@ +#include "cuidropdownlist.hpp" +#include "cuimanager.hpp" + +namespace EE { namespace UI { + +cUIDropDownList::cUIDropDownList( cUIDropDownList::CreateParams& Params ) : + cUITextInput( Params ), + mListBox( Params.ListBox ), + mMinNumVisibleItems( Params.MinNumVisibleItems ) +{ + mType |= UI_TYPE_GET( UI_TYPE_DROPDOWNLIST ); + + if ( NULL == mListBox ) { + cUIListBox::CreateParams LBParams; + LBParams.Size = eeSize( mSize.Width(), mMinNumVisibleItems * mSize.Height() ); + LBParams.Flags = UI_CLIP_ENABLE | UI_AUTO_PADDING; + LBParams.FontSelectedColor = eeColorA( 255, 255, 255, 255 ); + mListBox = eeNew( cUIListBox, ( LBParams ) ); + } + + mListBox->Enabled( false ); + mListBox->Visible( false ); + + AllowEditing( false ); + + ApplyDefaultTheme(); + + mListBox->AddEventListener( cUIEvent::EventOnComplexControlFocusLoss, cb::Make1( this, &cUIDropDownList::OnListBoxFocusLoss ) ); + mListBox->AddEventListener( cUIEvent::EventOnSelected, cb::Make1( this, &cUIDropDownList::OnItemSelected ) ); +} + +cUIDropDownList::~cUIDropDownList() { +} + +void cUIDropDownList::SetTheme( cUITheme * Theme ) { + cUIControl::SetTheme( Theme, "dropdownlist" ); + + AutoPadding(); + + OnSizeChange(); +} + +cUIListBox * cUIDropDownList::ListBox() const { + return mListBox; +} + +Uint32 cUIDropDownList::OnMouseClick( const eeVector2i& Pos, const Uint32 Flags ) { + if ( Flags & EE_BUTTON_LMASK ) + ShowListBox(); + + return 1; +} + +void cUIDropDownList::ShowListBox() { + if ( !mListBox->Visible() ) { + mListBox->Parent( cUIManager::instance()->MainControl() ); + + eeVector2i Pos = mScreenPos; + Pos.y += mSize.Height(); + + mListBox->Pos( Pos ); + + eeRecti tPadding = mListBox->PaddingContainer(); + + if ( mMinNumVisibleItems < mListBox->Count() ) + mListBox->Size( mSize.Width(), (Int32)( mMinNumVisibleItems * mSize.Height() ) + tPadding.Top ); + else + mListBox->Size( mSize.Width(), (Int32)( mListBox->Count() * mSize.Height() ) + tPadding.Top ); + + mListBox->Enabled( true ); + mListBox->Visible( true ); + + cUIManager::instance()->FocusControl( mListBox ); + } else { + mListBox->Enabled( false ); + mListBox->Visible( false ); + } +} + +void cUIDropDownList::OnListBoxFocusLoss( const cUIEvent * Event ) { + if ( cUIManager::instance()->FocusControl() != this ) { + mListBox->Enabled( false ); + mListBox->Visible( false ); + } +} + +void cUIDropDownList::OnItemSelected( const cUIEvent * Event ) { + if ( mListBox->Visible() ) { + mListBox->Enabled( false ); + mListBox->Visible( false ); + } + + Text( mListBox->GetItemSelectedText() ); +} + +void cUIDropDownList::Update() { + cUITextInput::Update(); + + if ( mEnabled && mVisible ) { + if ( ( mControlFlags & UI_CTRL_FLAG_HAS_FOCUS ) ) + mListBox->ManageKeyboard(); + + if ( IsMouseOver() ) { + Uint32 Flags = cUIManager::instance()->GetInput()->ClickTrigger(); + + if ( Flags & EE_BUTTONS_WUWD ) { + if ( Flags & EE_BUTTON_WUMASK ) { + mListBox->SelectPrev(); + } else if ( Flags & EE_BUTTON_WDMASK ) { + mListBox->SelectNext(); + } + } + } + } +} + +}} diff --git a/src/ui/cuidropdownlist.hpp b/src/ui/cuidropdownlist.hpp new file mode 100644 index 000000000..e85e3c6f0 --- /dev/null +++ b/src/ui/cuidropdownlist.hpp @@ -0,0 +1,50 @@ +#ifndef EE_UICUIDROPDOWNLIST_HPP +#define EE_UICUIDROPDOWNLIST_HPP + +#include "cuitextinput.hpp" +#include "cuilistbox.hpp" + +namespace EE { namespace UI { + +class EE_API cUIDropDownList : public cUITextInput { + public: + class CreateParams : public cUITextInput::CreateParams { + public: + inline CreateParams() : + cUITextInput::CreateParams(), + ListBox( NULL ), + MinNumVisibleItems( 6 ) + { + } + + inline ~CreateParams() {} + + cUIListBox * ListBox; + Uint32 MinNumVisibleItems; + }; + + cUIDropDownList( cUIDropDownList::CreateParams& Params ); + + ~cUIDropDownList(); + + virtual void SetTheme( cUITheme * Theme ); + + cUIListBox * ListBox() const; + + Uint32 OnMouseClick( const eeVector2i& Pos, const Uint32 Flags ); + + virtual void Update(); + protected: + cUIListBox * mListBox; + Uint32 mMinNumVisibleItems; + + void ShowListBox(); + + void OnListBoxFocusLoss( const cUIEvent * Event ); + + virtual void OnItemSelected( const cUIEvent * Event ); +}; + +}} + +#endif diff --git a/src/ui/cuievent.hpp b/src/ui/cuievent.hpp index 23dfc7d3b..2b28ad24c 100644 --- a/src/ui/cuievent.hpp +++ b/src/ui/cuievent.hpp @@ -33,6 +33,7 @@ class EE_API cUIEvent { EventOnPressEnter, EventOnValueChange, EventOnSelected, + EventOnComplexControlFocusLoss, EventUser, EventForceDWord = 0xFFFFFFFF }; diff --git a/src/ui/cuilistbox.cpp b/src/ui/cuilistbox.cpp index 9960b9321..e05a30f3d 100644 --- a/src/ui/cuilistbox.cpp +++ b/src/ui/cuilistbox.cpp @@ -25,7 +25,7 @@ cUIListBox::cUIListBox( cUIListBox::CreateParams& Params ) : mVisibleFirst(0), mVisibleLast(0) { - mType |= UI_TYPE_LISTBOX; + mType |= UI_TYPE_GET( UI_TYPE_LISTBOX ); if ( NULL == Params.Font && NULL != cUIThemeManager::instance()->DefaultFont() ) mFont = cUIThemeManager::instance()->DefaultFont(); @@ -459,9 +459,6 @@ void cUIListBox::UpdateScroll( bool FromScrollChange ) { mVisibleLast = i; } else { - //Item->Enabled( false ); - //Item->Visible( false ); - eeSAFE_DELETE( mItems[i] ); Item = NULL; } @@ -509,9 +506,6 @@ void cUIListBox::UpdateScroll( bool FromScrollChange ) { mVisibleLast = i; } else { - //Item->Enabled( false ); - //Item->Visible( false ); - eeSAFE_DELETE( mItems[i] ); Item = NULL; } @@ -570,6 +564,15 @@ Uint32 cUIListBox::GetItemSelectedIndex() const { return 0xFFFFFFFF; } +std::wstring cUIListBox::GetItemSelectedText() const { + std::wstring tstr; + + if ( mSelected.size() ) + return mTexts[ mSelected.front() ]; + + return tstr; +} + std::list cUIListBox::GetItemsSelectedIndex() const { return mSelected; } @@ -702,54 +705,99 @@ const bool& cUIListBox::AllowHorizontalScroll() const { return mAllowHorizontalScroll; } -Uint32 cUIListBox::Size() { +Uint32 cUIListBox::Count() { return (Uint32)mItems.size(); } +void cUIListBox::SetSelected( Uint32 Index ) { + if ( Index < mItems.size() ) { + if ( IsMultiSelect() ) { + for ( std::list::iterator it = mSelected.begin(); it != mSelected.end(); it++ ) { + if ( *it == Index ) + return; + } + } else { + if ( mSelected.size() ) + mSelected.clear(); + } + + mSelected.push_back( Index ); + + if ( NULL != mItems[ Index ] ) { + mItems[ Index ]->Select(); + } else { + UpdateScroll(); + } + } +} + +void cUIListBox::SelectPrev() { + if ( !IsMultiSelect() && mSelected.size() ) { + Int32 SelIndex = mSelected.front() - 1; + + if ( SelIndex >= 0 ) { + if ( NULL == mItems[ mSelected.front() ] ) + CreateItemIndex( mSelected.front() ); + + if ( NULL == mItems[ SelIndex ] ) + CreateItemIndex( SelIndex ); + + mItems[ mSelected.front() ]->Unselect(); + + if ( ScrollBar()->Visible() ) { + if ( mItems[ SelIndex ]->Pos().y < 0 ) { + ScrollBar()->Value( (eeFloat)( SelIndex * mRowHeight ) / (eeFloat)( ( mItems.size() - 1 ) * mRowHeight ) ); + + cUIManager::instance()->FocusControl( mItems[ SelIndex ] ); + } + } + + mItems[ SelIndex ]->Select(); + } + } +} + +void cUIListBox::SelectNext() { + if ( !IsMultiSelect() && mSelected.size() ) { + Int32 SelIndex = mSelected.front() + 1; + + if ( SelIndex < (Int32)mItems.size() ) { + if ( NULL == mItems[ mSelected.front() ] ) + CreateItemIndex( mSelected.front() ); + + if ( NULL == mItems[ SelIndex ] ) + CreateItemIndex( SelIndex ); + + mItems[ mSelected.front() ]->Unselect(); + + if ( ScrollBar()->Visible() ) { + if ( mItems[ SelIndex ]->Pos().y + (Int32)RowHeight() > mContainer->Size().Height() ) { + ScrollBar()->Value( (eeFloat)( SelIndex * mRowHeight ) / (eeFloat)( ( mItems.size() - 1 ) * mRowHeight ) ); + + cUIManager::instance()->FocusControl( mItems[ SelIndex ] ); + } + } + + mItems[ SelIndex ]->Select(); + } + } +} + void cUIListBox::ManageKeyboard() { if ( !mSelected.size() || mFlags & UI_MULTI_SELECT ) return; cInput * KM = cUIManager::instance()->GetInput(); - Int32 SelIndex = 0; if ( eeGetTicks() - mLastTickMove > 100 ) { if ( KM->IsKeyDown( KEY_DOWN ) ) { mLastTickMove = eeGetTicks(); - SelIndex = mSelected.front() + 1; - - if ( SelIndex < (Int32)mItems.size() ) { - mItems[ mSelected.front() ]->Unselect(); - - if ( ScrollBar()->Visible() ) { - if ( mItems[ SelIndex ]->Pos().y + (Int32)RowHeight() > mContainer->Size().Height() ) { - ScrollBar()->Value( (eeFloat)( SelIndex * mRowHeight ) / (eeFloat)( ( mItems.size() - 1 ) * mRowHeight ) ); - - cUIManager::instance()->FocusControl( mItems[ SelIndex ] ); - } - } - - mItems[ SelIndex ]->Select(); - } + SelectNext(); } else if ( KM->IsKeyDown( KEY_UP ) ) { mLastTickMove = eeGetTicks(); - SelIndex = mSelected.front() - 1; - - if ( SelIndex >= 0 ) { - mItems[ mSelected.front() ]->Unselect(); - - if ( ScrollBar()->Visible() ) { - if ( mItems[ SelIndex ]->Pos().y < 0 ) { - ScrollBar()->Value( (eeFloat)( SelIndex * mRowHeight ) / (eeFloat)( ( mItems.size() - 1 ) * mRowHeight ) ); - - cUIManager::instance()->FocusControl( mItems[ SelIndex ] ); - } - } - - mItems[ mSelected.front() - 1 ]->Select(); - } + SelectPrev(); } else if ( KM->IsKeyDown( KEY_PAGEUP ) ) { mLastTickMove = eeGetTicks(); @@ -765,17 +813,33 @@ void cUIListBox::ManageKeyboard() { } else if ( KM->IsKeyDown( KEY_PAGEDOWN ) ) { mLastTickMove = eeGetTicks(); - if ( mSelected.front() != Size() - 1 ) { + if ( mSelected.front() != Count() - 1 ) { mItems[ mSelected.front() ]->Unselect(); ScrollBar()->Value( 1 ); - cUIManager::instance()->FocusControl( mItems[ Size() - 1 ] ); + cUIManager::instance()->FocusControl( mItems[ Count() - 1 ] ); - mItems[ Size() - 1 ]->Select(); + mItems[ Count() - 1 ]->Select(); } } } } +Uint32 cUIListBox::OnMessage( const cUIMessage * Msg ) { + switch ( Msg->Msg() ) { + case cUIMessage::MsgFocusLoss: + { + cUIControl * FocusCtrl = cUIManager::instance()->FocusControl(); + + if ( this != FocusCtrl && !IsParentOf( FocusCtrl ) ) + SendCommonEvent( cUIEvent::EventOnComplexControlFocusLoss ); + + return 1; + } + } + + return 0; +} + }} diff --git a/src/ui/cuilistbox.hpp b/src/ui/cuilistbox.hpp index 4ef93c3de..d7d22a76c 100644 --- a/src/ui/cuilistbox.hpp +++ b/src/ui/cuilistbox.hpp @@ -73,6 +73,8 @@ class EE_API cUIListBox : public cUIControlAnim { cUIListBoxItem * GetItemSelected(); + std::wstring GetItemSelectedText() const; + Uint32 GetItemSelectedIndex() const; std::list GetItemsSelectedIndex() const; @@ -115,10 +117,19 @@ class EE_API cUIListBox : public cUIControlAnim { const bool& AllowHorizontalScroll() const; - Uint32 Size(); + Uint32 Count(); + + virtual Uint32 OnMessage( const cUIMessage * Msg ); + + void SetSelected( Uint32 Index ); + + void SelectPrev(); + + void SelectNext(); protected: friend class cUIListBoxItem; friend class cUIListBoxContainer; + friend class cUIDropDownList; Uint32 mRowHeight; bool mScrollAlwaysVisible; diff --git a/src/ui/cuilistboxcontainer.cpp b/src/ui/cuilistboxcontainer.cpp index 11ba5c8cd..59df9b4ef 100644 --- a/src/ui/cuilistboxcontainer.cpp +++ b/src/ui/cuilistboxcontainer.cpp @@ -18,9 +18,10 @@ void cUIListBoxContainer::Update() { cUIListBox * LBParent = reinterpret_cast ( Parent() ); if ( LBParent->mItems.size() ) { - for ( Uint32 i = LBParent->mVisibleFirst; i <= LBParent->mVisibleLast; i++ ) + for ( Uint32 i = LBParent->mVisibleFirst; i <= LBParent->mVisibleLast; i++ ) { if ( NULL != LBParent->mItems[i] ) LBParent->mItems[i]->Update(); + } } } diff --git a/src/ui/cuilistboxitem.cpp b/src/ui/cuilistboxitem.cpp index 07616d5a5..d7ff86f4f 100644 --- a/src/ui/cuilistboxitem.cpp +++ b/src/ui/cuilistboxitem.cpp @@ -7,7 +7,7 @@ namespace EE { namespace UI { cUIListBoxItem::cUIListBoxItem( cUITextBox::CreateParams& Params ) : cUITextBox( Params ) { - mType |= UI_TYPE_LISTBOXITEM; + mType |= UI_TYPE_GET( UI_TYPE_LISTBOXITEM ); ApplyDefaultTheme(); } @@ -72,6 +72,9 @@ void cUIListBoxItem::Update() { cUIListBox * LBParent = reinterpret_cast ( Parent()->Parent() ); Uint32 Flags = cUIManager::instance()->GetInput()->ClickTrigger(); + if ( NULL != LBParent && LBParent->Alpha() != mAlpha ) + Alpha( LBParent->Alpha() ); + if ( IsMouseOver() ) { if ( Flags & EE_BUTTONS_WUWD ) LBParent->ScrollBar()->Slider()->ManageClick( Flags ); diff --git a/src/ui/cuimanager.cpp b/src/ui/cuimanager.cpp index 92097c8f1..de27aa924 100644 --- a/src/ui/cuimanager.cpp +++ b/src/ui/cuimanager.cpp @@ -100,9 +100,15 @@ cUIControl * cUIManager::FocusControl() const { void cUIManager::FocusControl( cUIControl * Ctrl ) { if ( NULL != Ctrl && Ctrl != mFocusControl ) { - mFocusControl->OnFocusLoss(); + cUIControl * CtrlFocusLoss = mFocusControl; + mFocusControl = Ctrl; + + CtrlFocusLoss->OnFocusLoss(); + SendMsg( CtrlFocusLoss, cUIMessage::MsgFocusLoss ); + mFocusControl->OnFocus(); + SendMsg( mFocusControl, cUIMessage::MsgFocus ); } } @@ -127,12 +133,8 @@ void cUIManager::Update() { if ( mKM->PressTrigger() ) { if ( NULL != mOverControl ) { - if ( mOverControl != mFocusControl ) { - mOverControl->OnFocus(); - mFocusControl->OnFocusLoss(); - - mFocusControl = mOverControl; - } + if ( mOverControl != mFocusControl ) + FocusControl( mOverControl ); mOverControl->OnMouseDown( mKM->GetMousePos(), mKM->PressTrigger() ); } diff --git a/src/ui/cuimessage.hpp b/src/ui/cuimessage.hpp index d7195cb14..e30ef6c16 100644 --- a/src/ui/cuimessage.hpp +++ b/src/ui/cuimessage.hpp @@ -16,6 +16,8 @@ class EE_API cUIMessage { MsgMouseEnter, MsgMouseExit, MsgWindowResize, + MsgFocus, + MsgFocusLoss, MsgUser, MsgForceDWord = 0xFFFFFFFF }; diff --git a/src/ui/cuiskin.hpp b/src/ui/cuiskin.hpp index 5930ad948..e15c1f9f5 100644 --- a/src/ui/cuiskin.hpp +++ b/src/ui/cuiskin.hpp @@ -22,7 +22,7 @@ class EE_API cUISkin { virtual ~cUISkin(); - virtual void Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height, const Uint32& State ) = 0; + virtual void Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height, const Uint32& Alpha, const Uint32& State ) = 0; virtual void SetSkin( const Uint32& State ) = 0; diff --git a/src/ui/cuiskincomplex.cpp b/src/ui/cuiskincomplex.cpp index ce29715bb..ebee9d517 100644 --- a/src/ui/cuiskincomplex.cpp +++ b/src/ui/cuiskincomplex.cpp @@ -27,15 +27,20 @@ cUISkinComplex::~cUISkinComplex() { } -void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height, const Uint32& State ) { +void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height, const Uint32& Alpha, const Uint32& State ) { cShape * tShape = mShape[ State ][ UpLeft ]; + mTempColor = mColor[ State ]; + + if ( mTempColor.Alpha != Alpha ) { + mTempColor.Alpha = (Uint8)( (eeFloat)mTempColor.Alpha * ( (eeFloat)Alpha / 255.f ) ); + } eeSize uls; if ( NULL != tShape ) { uls = tShape->RealSize(); - tShape->Draw( X, Y, mColor[ State ] ); + tShape->Draw( X, Y, mTempColor ); } tShape = mShape[ State ][ DownLeft ]; @@ -45,7 +50,7 @@ void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wi if ( NULL != tShape ) { dls = tShape->RealSize(); - tShape->Draw( X, Y + Height - dls.Height(), mColor[ State ] ); + tShape->Draw( X, Y + Height - dls.Height(), mTempColor ); } tShape = mShape[ State ][ UpRight ]; @@ -55,7 +60,7 @@ void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wi if ( NULL != tShape ) { urs = tShape->RealSize(); - tShape->Draw( X + Width - urs.Width(), Y, mColor[ State ] ); + tShape->Draw( X + Width - urs.Width(), Y, mTempColor ); } tShape = mShape[ State ][ DownRight ]; @@ -65,7 +70,7 @@ void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wi if ( NULL != tShape ) { drs = tShape->RealSize(); - tShape->Draw( X + Width - drs.Width(), Y + Height - drs.Height(), mColor[ State ] ); + tShape->Draw( X + Width - drs.Width(), Y + Height - drs.Height(), mTempColor ); } tShape = mShape[ State ][ Left ]; @@ -73,7 +78,7 @@ void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wi if ( NULL != tShape ) { tShape->DestHeight( Height - uls.Height() - dls.Height() ); - tShape->Draw( X, Y + uls.Height(), mColor[ State ] ); + tShape->Draw( X, Y + uls.Height(), mTempColor ); tShape->ResetDestWidthAndHeight(); @@ -86,7 +91,7 @@ void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wi if ( NULL != tShape ) { tShape->DestWidth( Width - uls.Width() - urs.Width() ); - tShape->Draw( X + uls.Width(), Y, mColor[ State ] ); + tShape->Draw( X + uls.Width(), Y, mTempColor ); tShape->ResetDestWidthAndHeight(); @@ -105,7 +110,7 @@ void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wi tShape->DestHeight( Height - urs.Height() - drs.Height() ); - tShape->Draw( X + Width - urs.Width(), Y + urs.Height(), mColor[ State ] ); + tShape->Draw( X + Width - urs.Width(), Y + urs.Height(), mTempColor ); tShape->ResetDestWidthAndHeight(); } @@ -115,7 +120,7 @@ void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wi if ( NULL != tShape ) { tShape->DestWidth( Width - dls.Width() - drs.Width() ); - tShape->Draw( X + dls.Width(), Y + Height - tShape->RealSize().Height(), mColor[ State ] ); + tShape->Draw( X + dls.Width(), Y + Height - tShape->RealSize().Height(), mTempColor ); tShape->ResetDestWidthAndHeight(); } @@ -126,7 +131,7 @@ void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wi tShape->DestWidth( Width - uls.Width() - urs.Width() ); tShape->DestHeight( Height - uls.Height() - urs.Height() ); - tShape->Draw( X + uls.Width(), Y + uls.Height(), mColor[ State ] ); + tShape->Draw( X + uls.Width(), Y + uls.Height(), mTempColor ); tShape->ResetDestWidthAndHeight(); } diff --git a/src/ui/cuiskincomplex.hpp b/src/ui/cuiskincomplex.hpp index e5d70a7f2..2dfdeb6b3 100644 --- a/src/ui/cuiskincomplex.hpp +++ b/src/ui/cuiskincomplex.hpp @@ -27,7 +27,7 @@ class EE_API cUISkinComplex : public cUISkin { virtual ~cUISkinComplex(); - virtual void Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height, const Uint32& State ); + virtual void Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height, const Uint32& Alpha, const Uint32& State ); void SetSkin( const Uint32& State ); @@ -40,6 +40,7 @@ class EE_API cUISkinComplex : public cUISkin { virtual cUISkin * Copy(); protected: cShape * mShape[ cUISkinState::StateCount ][ SideCount ]; + eeColorA mTempColor; void StateNormalToState( const Uint32& State ); }; diff --git a/src/ui/cuiskinsimple.cpp b/src/ui/cuiskinsimple.cpp index 3825863e5..0aed0f354 100644 --- a/src/ui/cuiskinsimple.cpp +++ b/src/ui/cuiskinsimple.cpp @@ -15,14 +15,19 @@ cUISkinSimple::cUISkinSimple( const std::string& Name ) : cUISkinSimple::~cUISkinSimple() { } -void cUISkinSimple::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height, const Uint32& State ) { +void cUISkinSimple::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height, const Uint32& Alpha, const Uint32& State ) { cShape * tShape = mShape[ State ]; + mTempColor = mColor[ State ]; if ( NULL != tShape ) { tShape->DestWidth( Width ); tShape->DestHeight( Height ); - tShape->Draw( X, Y, mColor[ State ] ); + if ( mTempColor.Alpha != Alpha ) { + mTempColor.Alpha = (Uint8)( (eeFloat)mTempColor.Alpha * ( (eeFloat)Alpha / 255.f ) ); + } + + tShape->Draw( X, Y, mTempColor ); tShape->ResetDestWidthAndHeight(); } diff --git a/src/ui/cuiskinsimple.hpp b/src/ui/cuiskinsimple.hpp index 9fb3471ab..7e30b3aac 100644 --- a/src/ui/cuiskinsimple.hpp +++ b/src/ui/cuiskinsimple.hpp @@ -12,7 +12,7 @@ class EE_API cUISkinSimple : public cUISkin { virtual ~cUISkinSimple(); - virtual void Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height, const Uint32& State ); + virtual void Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height, const Uint32& Alpha, const Uint32& State ); void SetSkin( const Uint32& State ); @@ -23,6 +23,7 @@ class EE_API cUISkinSimple : public cUISkin { virtual cUISkin * Copy(); protected: cShape * mShape[ cUISkinState::StateCount ]; + eeColorA mTempColor; void StateNormalToState( const Uint32& State ); }; diff --git a/src/ui/cuiskinstate.cpp b/src/ui/cuiskinstate.cpp index 2b3796de6..0fc68b4eb 100644 --- a/src/ui/cuiskinstate.cpp +++ b/src/ui/cuiskinstate.cpp @@ -14,9 +14,9 @@ cUISkinState::cUISkinState( cUISkin * Skin ) : cUISkinState::~cUISkinState() { } -void cUISkinState::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height ) { +void cUISkinState::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height, const Uint32& Alpha ) { if ( NULL != mSkin ) - mSkin->Draw( X, Y, Width, Height, mCurState ); + mSkin->Draw( X, Y, Width, Height, Alpha, mCurState ); } void cUISkinState::StateBack( const Uint32& State ) { diff --git a/src/ui/cuiskinstate.hpp b/src/ui/cuiskinstate.hpp index 5bbeffc3b..ad4d25c3a 100644 --- a/src/ui/cuiskinstate.hpp +++ b/src/ui/cuiskinstate.hpp @@ -29,7 +29,7 @@ class cUISkinState { cUISkin * GetSkin() const; - void Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height ); + void Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height, const Uint32& Alpha ); protected: friend class cUIControl; diff --git a/src/ui/cuitextbox.cpp b/src/ui/cuitextbox.cpp index 0ce33b6bd..5c991efe4 100644 --- a/src/ui/cuitextbox.cpp +++ b/src/ui/cuitextbox.cpp @@ -33,7 +33,7 @@ cUITextBox::~cUITextBox() { void cUITextBox::Draw() { if ( mVisible ) { - cUIControl::Draw(); + cUIControlAnim::Draw(); if ( mTextCache->GetTextWidth() ) { if ( mFlags & UI_CLIP_ENABLE ) @@ -82,7 +82,6 @@ const eeColorA& cUITextBox::Color() const { void cUITextBox::Color( const eeColorA& color ) { mFontColor = color; Alpha( color.A() ); - mTextCache->Color( mFontColor ); } const eeColorA& cUITextBox::ShadowColor() const { @@ -92,12 +91,15 @@ const eeColorA& cUITextBox::ShadowColor() const { void cUITextBox::ShadowColor( const eeColorA& color ) { mFontShadowColor = color; Alpha( color.A() ); + mTextCache->ShadowColor( mFontColor ); } void cUITextBox::Alpha( const eeFloat& alpha ) { cUIControlAnim::Alpha( alpha ); mFontColor.Alpha = (Uint8)alpha; mFontShadowColor.Alpha = (Uint8)alpha; + + mTextCache->Color( mFontColor ); } void cUITextBox::AutoShrink() { diff --git a/src/ui/cuitextinput.cpp b/src/ui/cuitextinput.cpp index 4178db592..e8b5eb0a5 100644 --- a/src/ui/cuitextinput.cpp +++ b/src/ui/cuitextinput.cpp @@ -82,8 +82,13 @@ void cUITextInput::Draw() { } Uint32 cUITextInput::OnMouseClick( const eeVector2i& Pos, const Uint32 Flags ) { - mTextBuffer.Active( true ); - ResetWaitCursor(); + cUIControlAnim::OnMouseClick( Pos, Flags ); + + if ( mAllowEditing ) { + mTextBuffer.Active( true ); + + ResetWaitCursor(); + } return 1; } diff --git a/src/ui/cuitheme.cpp b/src/ui/cuitheme.cpp index 1394a4e4a..ac2883d64 100644 --- a/src/ui/cuitheme.cpp +++ b/src/ui/cuitheme.cpp @@ -42,7 +42,9 @@ static const char * UI_THEME_ELEMENTS[] = { "progressbar", "progressbar_filler", "listbox", - "listboxitem" + "listboxitem", + "dropdownlist", + "combobox" }; cUITheme * cUITheme::LoadFromPath( const std::string& Path, const std::string& Name, const std::string& NameAbbr, const std::string ImgExt ) { diff --git a/src/ui/uihelper.hpp b/src/ui/uihelper.hpp index 8cbda2124..c6549e676 100644 --- a/src/ui/uihelper.hpp +++ b/src/ui/uihelper.hpp @@ -66,6 +66,8 @@ Uint32 EE_API VAlignGet( Uint32 Flags ); #define UI_TYPE_PROGRESSBAR (11) #define UI_TYPE_LISTBOX (12) #define UI_TYPE_LISTBOXITEM (13) +#define UI_TYPE_DROPDOWNLIST (14) +#define UI_TYPE_COMBOBOX (15) #define UI_TYPE_GET(X) ( 1 << (X) )