Some minor changes.

This commit is contained in:
spartanj
2010-12-29 04:31:27 -03:00
parent cd662ed08b
commit cc33bc3b4d
18 changed files with 114 additions and 137 deletions

View File

@@ -370,7 +370,18 @@ void cEETest::OnFontLoaded( cResourceLoader * ObjLoaded ) {
Con.Create( FF, true );
Con.IgnoreCharOnPrompt( 186 ); // L'º'
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.";
cTimeElapsed TE;
cUIManager::instance()->Init();
CreateUI();
cLog::instance()->Writef( "CreateUI time: %f", TE.ElapsedSinceStart() );
TTFB->ShrinkText( mBuda, 400 );
mBudaTC.Create( TTFB, mBuda, eeColorA(255,255,255,255) );
mEEText.Create( TTFB, L"Entropia Engine++\nCTRL + 1 = Screen 1 - CTRL + 2 = Screen 2\nCTRL + 3 = Screen 3" );
mFBOText.Create( TTFB, L"This is a VBO\nInside of a FBO" );
mInfoText.Create( FF, L"", eeColorA(255,255,255,150) );
EE->Display();
@@ -389,17 +400,15 @@ void cEETest::CreateShaders() {
}
void cEETest::CreateUI() {
cUIManager::instance()->Init();
cUIControl::CreateParams Params( cUIManager::instance()->MainControl(), eeVector2i(0,0), eeSize( 530, 380 ), UI_FILL_BACKGROUND | UI_CLIP_ENABLE | UI_BORDER );
cUIThemeManager::instance()->Add( cUITheme::LoadFromPath( MyPath + "data/aqua/", "aqua", "aqua" ) );
//cUIThemeManager::instance()->Add( cUITheme::LoadFromPath( MyPath + "data/aqua/", "aqua", "aqua" ) );
CreateAquaTextureAtlas();
/*
cTextureGroupLoader tgl( MyPath + "data/aquatg/aqua.etg" );
TF->GetByName( "data/aquatg/aqua.png" )->TextureFilter( TEX_FILTER_NEAREST );
cUIThemeManager::instance()->Add( cUITheme::LoadFromShapeGroup( cShapeGroupManager::instance()->GetByName( "aqua" ), "aqua", "aqua" ) );
*/
cUIThemeManager::instance()->DefaultEffectsEnabled( true );
cUIThemeManager::instance()->DefaultFont( TTF );
cUIThemeManager::instance()->DefaultTheme( "aqua" );
@@ -564,7 +573,7 @@ void cEETest::CreateUI() {
mListBox->Visible( true );
mListBox->Enabled( true );
Int32 wsize = 10000;
Int32 wsize = 100;
if ( wsize ) {
std::vector<std::wstring> wstr(wsize);
@@ -661,6 +670,7 @@ void cEETest::CreateUI() {
cUITextEdit * TextEdit = eeNew( cUITextEdit, ( TEParams ) );
TextEdit->Visible( true );
TextEdit->Enabled( true );
TextEdit->Text( mBuda );
cUIGenericGrid::CreateParams GridParams;
GridParams.Parent( C );
@@ -684,7 +694,7 @@ void cEETest::CreateUI() {
TxtGfxParams.Flags = UI_VALIGN_CENTER | UI_HALIGN_CENTER;
TxtGfxParams.Shape = cGlobalShapeGroup::instance()->GetByName( "aqua_button_ok" );
for ( Uint32 i = 0; i < 10; i++ ) {
for ( Uint32 i = 0; i < 100; i++ ) {
cUIGridCell * Cell = eeNew( cUIGridCell, ( CellParams ) );
cUITextBox * TxtBox = eeNew( cUITextBox, ( TxtBoxParams ) );
cUITextInput * TxtInput = eeNew( cUITextInput, ( TxtInputParams ) );
@@ -702,16 +712,6 @@ void cEETest::CreateUI() {
mGenGrid->CollumnWidth( 0, 50 );
mGenGrid->CollumnWidth( 1, 24 );
mGenGrid->CollumnWidth( 2, 100 );
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.";
TextEdit->Text( mBuda );
TTFB->ShrinkText( mBuda, 400 );
mBudaTC.Create( TTFB, mBuda, eeColorA(255,255,255,255) );
mEEText.Create( TTFB, L"Entropia Engine++\nCTRL + 1 = Screen 1 - CTRL + 2 = Screen 2\nCTRL + 3 = Screen 3" );
mFBOText.Create( TTFB, L"This is a VBO\nInside of a FBO" );
mInfoText.Create( FF, L"", eeColorA(255,255,255,150) );
}
void cEETest::ItemClick( const cUIEvent * Event ) {

View File

@@ -66,21 +66,11 @@ Uint32 cUIComboBox::OnMouseClick( const eeVector2i& Pos, const Uint32 Flags ) {
cUITextInput::OnMouseClick( Pos, Flags );
if ( mListBox->Visible() ) {
mListBox->Enabled( false );
mListBox->Visible( false );
Hide();
}
}
return 1;
}
void cUIComboBox::OnItemSelected( const cUIEvent * Event ) {
if ( mListBox->Visible() ) {
mListBox->Enabled( false );
mListBox->Visible( false );
}
mTextBuffer.Buffer( mListBox->GetItemSelectedText() );
}
}}

View File

@@ -15,8 +15,6 @@ class EE_API cUIComboBox : public cUIDropDownList {
protected:
cUIControl * mButton;
virtual void OnItemSelected( const cUIEvent * Event );
void OnButtonClick( const cUIEvent * Event );
Uint32 OnMouseClick( const eeVector2i& Pos, const Uint32 Flags );

View File

@@ -937,6 +937,15 @@ void cUIControl::WriteCtrlFlag( const Uint32& Pos, const Uint32& Val ) {
Write32BitKey( &mControlFlags, Pos, Val );
}
void cUIControl::WriteFlag( const Uint32& Flag, const Uint32& Val ) {
if ( Val )
mFlags |= Flag;
else {
if ( mFlags & Flag )
mFlags &= ~Flag;
}
}
void cUIControl::ApplyDefaultTheme() {
cUIThemeManager::instance()->ApplyDefaultTheme( this );
}

View File

@@ -343,6 +343,8 @@ class EE_API cUIControl {
void WriteCtrlFlag( const Uint32& Pos, const Uint32& Val );
void WriteFlag( const Uint32& Flag, const Uint32& Val );
void ApplyDefaultTheme();
eeFloat Elapsed();

View File

@@ -1,11 +1,10 @@
#include "cuidragable.hpp"
#include "cuimanager.hpp"
namespace EE { namespace UI {
cUIDragable::cUIDragable( const cUIControl::CreateParams& Params ) :
cUIControl( Params ),
mDragEnable( false ),
mDragging( false ),
mDragButton( EE_BUTTON_LMASK )
{
mType |= UI_TYPE_CONTROL_DRAGABLE;
@@ -15,9 +14,9 @@ cUIDragable::~cUIDragable() {
}
Uint32 cUIDragable::OnMouseDown( const eeVector2i& Pos, const Uint32 Flags ) {
if ( !( cInput::instance()->LastPressTrigger() & mDragButton ) && ( Flags & mDragButton ) && mDragEnable && !mDragging ) {
mDragging = true;
mDragPoint = mDraggingPoint = Pos;
if ( !( cInput::instance()->LastPressTrigger() & mDragButton ) && ( Flags & mDragButton ) && DragEnable() && !Dragging() ) {
Dragging( true );
mDragPoint = Pos;
}
cUIControl::OnMouseDown( Pos, Flags );
@@ -25,21 +24,14 @@ Uint32 cUIDragable::OnMouseDown( const eeVector2i& Pos, const Uint32 Flags ) {
}
Uint32 cUIDragable::OnMouseUp( const eeVector2i& Pos, const Uint32 Flags ) {
if ( mDragEnable && mDragging && ( Flags & mDragButton ) )
mDragging = false;
if ( DragEnable() && Dragging() && ( Flags & mDragButton ) ) {
Dragging( false );
}
cUIControl::OnMouseUp( Pos, Flags );
return 1;
}
bool cUIDragable::Dragging() const {
return mDragging;
}
void cUIDragable::Dragging( const bool& dragging ) {
mDragging = dragging;
}
const eeVector2i& cUIDragable::DragPoint() const {
return mDragPoint;
}
@@ -48,46 +40,44 @@ void cUIDragable::DragPoint( const eeVector2i& Point ) {
mDragPoint = Point;
}
const eeVector2i& cUIDragable::DraggingPoint() const {
return mDraggingPoint;
}
void cUIDragable::DraggingPoint( const eeVector2i& Point ) {
mDraggingPoint = Point;
}
void cUIDragable::Update() {
cUIControl::Update();
if ( !mDragEnable )
if ( !DragEnable() )
return;
if ( mDragging ) {
if ( Dragging() ) {
if ( !( cInput::instance()->PressTrigger() & mDragButton ) ) {
mDragging = false;
Dragging( false );
return;
}
eeVector2i Pos( cInput::instance()->GetMousePos() );
eeVector2i Pos( cUIManager::instance()->GetMousePos() );
if ( mDraggingPoint.x != Pos.x || mDraggingPoint.y != Pos.y ) {
mDragPoint = mDraggingPoint;
mDraggingPoint = Pos;
if ( mDragPoint != Pos ) {
mPos += -( mDragPoint - Pos );
mPos += ( mDragPoint - mDraggingPoint ) * (eeInt)-1;
mDragPoint = Pos;
OnPosChange();
} else
mDragPoint = mDraggingPoint;
}
}
}
const bool& cUIDragable::DragEnable() const {
return mDragEnable;
bool cUIDragable::DragEnable() const {
return 0 != ( mFlags & UI_DRAG_ENABLE );
}
void cUIDragable::DragEnable( const bool& enable ) {
mDragEnable = enable;
WriteFlag( UI_DRAG_ENABLE, true == enable );
}
bool cUIDragable::Dragging() const {
return 0 != ( mControlFlags & UI_CTRL_FLAG_DRAGGING );
}
void cUIDragable::Dragging( const bool& dragging ) {
WriteCtrlFlag( UI_CTRL_FLAG_DRAGGING_POS, true == dragging );
}
void cUIDragable::DragButton( const Uint32& Button ) {

View File

@@ -15,26 +15,21 @@ class EE_API cUIDragable : public cUIControl {
const eeVector2i& DragPoint() const;
void DragPoint( const eeVector2i& Point );
const eeVector2i& DraggingPoint() const;
void DraggingPoint( const eeVector2i& Point );
virtual void Update();
const bool& DragEnable() const;
bool DragEnable() const;
void DragEnable( const bool& enable );
void DragButton( const Uint32& Button );
const Uint32& DragButton() const;
protected:
virtual ~cUIDragable();
virtual ~cUIDragable();
bool mDragEnable;
bool mDragging;
eeVector2i mDragPoint;
eeVector2i mDraggingPoint;
Uint32 mDragButton;
eeVector2i mDragPoint;
Uint32 mDragButton;
virtual Uint32 OnMouseDown( const eeVector2i& Pos, const Uint32 Flags );
virtual Uint32 OnMouseUp( const eeVector2i& Pos, const Uint32 Flags );
};

View File

@@ -27,10 +27,10 @@ cUIDropDownList::cUIDropDownList( cUIDropDownList::CreateParams& Params ) :
ApplyDefaultTheme();
mListBox->AddEventListener( cUIEvent::EventOnComplexControlFocusLoss, cb::Make1( this, &cUIDropDownList::OnListBoxFocusLoss ) );
mListBox->AddEventListener( cUIEvent::EventOnSelected, cb::Make1( this, &cUIDropDownList::OnItemSelected ) );
mListBox->AddEventListener( cUIEvent::EventOnSelected , cb::Make1( this, &cUIDropDownList::OnItemSelected ) );
mListBox->AddEventListener( cUIEvent::EventOnItemClicked, cb::Make1( this, &cUIDropDownList::OnItemClicked ) );
mListBox->AddEventListener( cUIEvent::EventOnItemKeyDown, cb::Make1( this, &cUIDropDownList::OnItemKeyDown ) );
mListBox->AddEventListener( cUIEvent::EventKeyDown, cb::Make1( this, &cUIDropDownList::OnItemKeyDown ) );
mListBox->AddEventListener( cUIEvent::EventKeyDown , cb::Make1( this, &cUIDropDownList::OnItemKeyDown ) );
}
cUIDropDownList::~cUIDropDownList() {
@@ -93,7 +93,7 @@ void cUIDropDownList::OnItemKeyDown( const cUIEvent * Event ) {
}
void cUIDropDownList::OnListBoxFocusLoss( const cUIEvent * Event ) {
if ( cUIManager::instance()->FocusControl() != this ) {
if ( cUIManager::instance()->FocusControl() != this && !IsChild( cUIManager::instance()->FocusControl() ) ) {
Hide();
}
}
@@ -104,7 +104,7 @@ void cUIDropDownList::OnItemClicked( const cUIEvent * Event ) {
}
void cUIDropDownList::OnItemSelected( const cUIEvent * Event ) {
mTextBuffer.Buffer( mListBox->GetItemSelectedText() );
Text( mListBox->GetItemSelectedText() );
}
void cUIDropDownList::Show() {
@@ -129,12 +129,7 @@ void cUIDropDownList::Hide() {
}
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();
@@ -147,6 +142,14 @@ void cUIDropDownList::Update() {
}
}
}
cUITextInput::Update();
}
Uint32 cUIDropDownList::OnKeyDown( const cUIEventKey &Event ) {
mListBox->OnKeyDown( Event );
return 1;
}
}}

View File

@@ -54,6 +54,8 @@ class EE_API cUIDropDownList : public cUITextInput {
virtual void OnItemClicked( const cUIEvent * Event );
virtual void OnItemKeyDown( const cUIEvent * Event );
Uint32 OnKeyDown( const cUIEventKey &Event );
};
}}

View File

@@ -173,22 +173,8 @@ void cUIGenericGrid::UpdateVScroll() {
ContainerResize();
}
void cUIGenericGrid::UpdateScroll( bool FromScrollChange ) {
if ( !mItems.size() )
return;
cUIGridCell * Item;
Uint32 i, RelPos = 0, RelPosMax;
Int32 ItemPos, ItemPosMax;
Int32 tHLastScroll = mHScrollInit;
Uint32 VisibleItems = mContainer->Size().Height() / mRowHeight;
mItemsNotVisible = (Int32)mItems.size() - VisibleItems;
bool Clipped = 0 != mContainer->IsClipped();
UpdateVScroll();
if ( Clipped && ( UI_SCROLLBAR_AUTO == mHScrollMode || UI_SCROLLBAR_ALWAYS_ON == mHScrollMode ) ) {
void cUIGenericGrid::UpdateHScroll() {
if ( mContainer->IsClipped() && ( UI_SCROLLBAR_AUTO == mHScrollMode || UI_SCROLLBAR_ALWAYS_ON == mHScrollMode ) ) {
if ( mContainer->Size().Width() < (Int32)mTotalWidth ) {
mHScrollBar->Visible( true );
mHScrollBar->Enabled( true );
@@ -211,6 +197,24 @@ void cUIGenericGrid::UpdateScroll( bool FromScrollChange ) {
}
}
}
}
void cUIGenericGrid::UpdateScroll( bool FromScrollChange ) {
if ( !mItems.size() )
return;
cUIGridCell * Item;
Uint32 i, RelPos = 0, RelPosMax;
Int32 ItemPos, ItemPosMax;
Int32 tHLastScroll = mHScrollInit;
Uint32 VisibleItems = mContainer->Size().Height() / mRowHeight;
mItemsNotVisible = (Int32)mItems.size() - VisibleItems;
bool Clipped = 0 != mContainer->IsClipped();
UpdateVScroll();
UpdateHScroll();
VisibleItems = mContainer->Size().Height() / mRowHeight;
mItemsNotVisible = (Uint32)mItems.size() - VisibleItems;
@@ -394,7 +398,6 @@ void cUIGenericGrid::UpdateCollumnsPos() {
mTotalWidth = Pos;
}
void cUIGenericGrid::OnAlphaChange() {
cUIControlAnim::OnAlphaChange();

View File

@@ -130,6 +130,8 @@ class EE_API cUIGenericGrid : public cUIControlAnim {
virtual Uint32 OnSelected();
void UpdateVScroll();
void UpdateHScroll();
};
}}

View File

@@ -81,15 +81,11 @@ void cUIGridCell::Update() {
if ( Flags & EE_BUTTONS_WUWD && MyParent->VerticalScrollBar()->Visible() )
MyParent->VerticalScrollBar()->Slider()->ManageClick( Flags );
}
/*if ( ( mControlFlags & UI_CTRL_FLAG_HAS_FOCUS ) )
LBParent->ManageKeyboard();*/
}
cUIComplexControl::Update();
}
void cUIGridCell::Select() {
cUIGenericGrid * MyParent = reinterpret_cast<cUIGenericGrid*> ( Parent()->Parent() );

View File

@@ -104,6 +104,9 @@ cUIScrollBar * cUIListBox::HorizontalScrollBar() const {
}
void cUIListBox::AddListBoxItems( std::vector<std::wstring> Texts ) {
mItems.reserve( mItems.size() + Texts.size() );
mTexts.reserve( mTexts.size() + Texts.size() );
for ( Uint32 i = 0; i < Texts.size(); i++ ) {
AddListBoxItem( Texts[i] );
}
@@ -791,27 +794,19 @@ void cUIListBox::SelectNext() {
Uint32 cUIListBox::OnKeyDown( const cUIEventKey &Event ) {
cUIControlAnim::OnKeyDown( Event );
ManageKeyboard();
return 1;
}
void cUIListBox::ManageKeyboard() {
if ( !mSelected.size() || mFlags & UI_MULTI_SELECT )
return;
cInput * KM = cUIManager::instance()->GetInput();
return 0;
if ( eeGetTicks() - mLastTickMove > 100 ) {
if ( KM->IsKeyDown( KEY_DOWN ) ) {
if ( KEY_DOWN == Event.KeyCode() ) {
mLastTickMove = eeGetTicks();
SelectNext();
} else if ( KM->IsKeyDown( KEY_UP ) ) {
} else if ( KEY_UP == Event.KeyCode() ) {
mLastTickMove = eeGetTicks();
SelectPrev();
} else if ( KM->IsKeyDown( KEY_PAGEUP ) ) {
} else if ( KEY_PAGEUP == Event.KeyCode() ) {
mLastTickMove = eeGetTicks();
if ( mSelected.front() != 0 ) {
@@ -823,7 +818,7 @@ void cUIListBox::ManageKeyboard() {
mItems[ 0 ]->Select();
}
} else if ( KM->IsKeyDown( KEY_PAGEDOWN ) ) {
} else if ( KEY_PAGEDOWN == Event.KeyCode() ) {
mLastTickMove = eeGetTicks();
if ( mSelected.front() != Count() - 1 ) {
@@ -837,6 +832,10 @@ void cUIListBox::ManageKeyboard() {
}
}
}
ItemKeyEvent( Event );
return 1;
}
Uint32 cUIListBox::OnMessage( const cUIMessage * Msg ) {

View File

@@ -199,8 +199,6 @@ class EE_API cUIListBox : public cUIComplexControl {
void FindMaxWidth();
void ManageKeyboard();
cUIListBoxItem * CreateListBoxItem( const std::wstring& Name );
void CreateItemIndex( const Uint32& i );

View File

@@ -32,12 +32,6 @@ Uint32 cUIListBoxItem::OnMouseClick( const eeVector2i& Pos, const Uint32 Flags )
return 1;
}
Uint32 cUIListBoxItem::OnKeyDown( const cUIEventKey &Event ) {
reinterpret_cast<cUIListBox*> ( Parent()->Parent() )->ItemKeyEvent( Event );
return 1;
}
void cUIListBoxItem::Select() {
cUIListBox * LBParent = reinterpret_cast<cUIListBox*> ( Parent()->Parent() );
@@ -72,8 +66,6 @@ void cUIListBoxItem::Select() {
}
void cUIListBoxItem::Update() {
cUITextBox::Update();
if ( mEnabled && mVisible ) {
cUIListBox * LBParent = reinterpret_cast<cUIListBox*> ( Parent()->Parent() );
Uint32 Flags = cUIManager::instance()->GetInput()->ClickTrigger();
@@ -85,10 +77,9 @@ void cUIListBoxItem::Update() {
if ( Flags & EE_BUTTONS_WUWD && LBParent->VerticalScrollBar()->Visible() )
LBParent->VerticalScrollBar()->Slider()->ManageClick( Flags );
}
if ( ( mControlFlags & UI_CTRL_FLAG_HAS_FOCUS ) )
LBParent->ManageKeyboard();
}
cUITextBox::Update();
}
Uint32 cUIListBoxItem::OnMouseExit( const eeVector2i& Pos, const Uint32 Flags ) {

View File

@@ -31,8 +31,6 @@ class EE_API cUIListBoxItem : public cUITextBox {
virtual Uint32 OnMouseClick( const eeVector2i& Pos, const Uint32 Flags );
virtual Uint32 OnMouseExit( const eeVector2i& Pos, const Uint32 Flags );
virtual Uint32 OnKeyDown( const cUIEventKey &Event );
};
}}

View File

@@ -51,9 +51,7 @@ class EE_API cUIManager : public tSingleton<cUIManager> {
cUIControl * mOverControl;
cUIControl * mDownControl;
bool mFirstPress;
eeFloat mElapsed;
Int32 mCbId;
void InputCallback( EE_Event * Event );

View File

@@ -19,6 +19,7 @@ enum UI_CONTROL_FLAGS_POS {
UI_CTRL_FLAG_DISABLE_CHECK_CLOSE_CHILDS_POS = 6,
UI_CTRL_FLAG_DISABLE_FADE_OUT_POS = 7,
UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD_POS = 8,
UI_CTRL_FLAG_DRAGGING_POS = 9,
UI_CTRL_FLAG_FREE_USE_POS = 31
};
@@ -32,6 +33,7 @@ enum UI_CONTROL_FLAGS_VALUES {
UI_CTRL_FLAG_DISABLE_CHECK_CLOSE_CHILDS = (1<<UI_CTRL_FLAG_DISABLE_CHECK_CLOSE_CHILDS_POS),
UI_CTRL_FLAG_DISABLE_FADE_OUT = (1<<UI_CTRL_FLAG_DISABLE_FADE_OUT_POS),
UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD = (1<<UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD_POS),
UI_CTRL_FLAG_DRAGGING = (1<<UI_CTRL_FLAG_DRAGGING_POS),
UI_CTRL_FLAG_FREE_USE = (1<<UI_CTRL_FLAG_FREE_USE_POS)
};
@@ -55,7 +57,8 @@ enum UI_FLAGS {
UI_CLIP_ENABLE = (1 << 12),
UI_AUTO_SHRINK_TEXT = (1 << 13),
UI_MULTI_SELECT = (1 << 14),
UI_AUTO_PADDING = (1 << 15)
UI_AUTO_PADDING = (1 << 15),
UI_DRAG_ENABLE = (1 << 16)
};
enum UI_CONTROL_TYPES {