From a241bb794930c4676f76fdf7fcc914621e8d0baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 19 May 2013 03:56:28 -0300 Subject: [PATCH] Fixed a bug in cUIScrollbar and fixed a bad scrollbar resize in the Map Editor. Improved premake4 for Visual Studio and OS X. Added Over control highlighting. --- include/eepp/ee.hpp | 2 +- include/eepp/ui/cuimanager.hpp | 15 ++++++++++--- include/eepp/ui/uihelper.hpp | 3 ++- premake4.lua | 26 +++++++++++++++++++---- projects/linux/ee.creator.user | 3 ++- src/eepp/gaming/mapeditor/cmapeditor.cpp | 2 +- src/eepp/ui/cuicontrol.cpp | 16 ++++++++++++++ src/eepp/ui/cuicontrolanim.cpp | 10 ++++++++- src/eepp/ui/cuimanager.cpp | 27 +++++++++++++++++++----- src/eepp/ui/cuiscrollbar.cpp | 2 ++ src/test/eetest.cpp | 2 +- 11 files changed, 90 insertions(+), 18 deletions(-) diff --git a/include/eepp/ee.hpp b/include/eepp/ee.hpp index 08feeeee6..406eb33a3 100755 --- a/include/eepp/ee.hpp +++ b/include/eepp/ee.hpp @@ -51,7 +51,7 @@ Copy-Paste will be moved for a middle to long term plan. @TODO Add PVRTC and ETC support. - STATE: Not started. + STATE: DONE. Middle-term plans: diff --git a/include/eepp/ui/cuimanager.hpp b/include/eepp/ui/cuimanager.hpp index 4e677403c..a3820b078 100644 --- a/include/eepp/ui/cuimanager.hpp +++ b/include/eepp/ui/cuimanager.hpp @@ -58,9 +58,17 @@ class EE_API cUIManager { bool HighlightFocus() const; - void HighlightColor( const eeColorA& Color ); + void HighlightFocusColor( const eeColorA& Color ); - const eeColorA& HighlightColor() const; + const eeColorA& HighlightFocusColor() const; + + void HighlightOver( bool Highlight ); + + bool HighlightOver() const; + + void HighlightOverColor( const eeColorA& Color ); + + const eeColorA& HighlightOverColor() const; void SendMouseClick( cUIControl * ToCtrl, const eeVector2i& Pos, const Uint32 Flags ); @@ -95,7 +103,8 @@ class EE_API cUIManager { Uint32 mResizeCb; Uint32 mFlags; - eeColorA mHighlightColor; + eeColorA mHighlightFocusColor; + eeColorA mHighlightOverColor; bool mInit; bool mFirstPress; diff --git a/include/eepp/ui/uihelper.hpp b/include/eepp/ui/uihelper.hpp index 252165679..92317b7a2 100644 --- a/include/eepp/ui/uihelper.hpp +++ b/include/eepp/ui/uihelper.hpp @@ -106,7 +106,8 @@ enum UI_SCROLLBAR_MODE { }; enum UI_MANAGER_FLAGS { - UI_MANAGER_HIGHLIGHT_FOCUS = ( 1 << 0 ) + UI_MANAGER_HIGHLIGHT_FOCUS = ( 1 << 0 ), + UI_MANAGER_HIGHLIGHT_OVER = ( 1 << 1 ) }; enum UI_WINDOW_FLAGS { diff --git a/premake4.lua b/premake4.lua index cd6d36d8b..71274cf2a 100644 --- a/premake4.lua +++ b/premake4.lua @@ -249,8 +249,26 @@ function build_link_configuration( package_name ) links { link_list } end - if ( is_vs() and backend_is("SDL") ) then - links { get_backend_link_name( "SDL" ), "SDLmain" } + if ( is_vs() ) then + if ( backend_is("SDL") ) then + links { get_backend_link_name( "SDL" ), "SDLmain" } + elseif ( backend_is("SDL2") ) then + links { get_backend_link_name( "SDL2" ), "SDL2main" } + elseif ( backend_is("allegro5") ) then + links { get_backend_link_name( "allegro" ), "allegro_main" } + elseif ( backend_is("SFML") ) then + links { get_backend_link_name( "SFML" ) } + end + else + if ( os.is_real("macosx") ) then + if ( backend_is("SDL") ) then + links { "SDLmain" } + elseif ( backend_is("SDL2") ) then + links { "SDL2main" } + elseif ( backend_is("allegro5") ) then + links { "allegro_main" } + end + end end end @@ -382,8 +400,8 @@ function add_allegro5() files { "src/eepp/window/backend/allegro5/*.cpp" } defines { "EE_BACKEND_ALLEGRO_ACTIVE" } - if not can_add_static_backend("allegro5") then - table.insert( link_list, get_backend_link_name( "allegro5" ) ) + if not can_add_static_backend("allegro") then + table.insert( link_list, get_backend_link_name( "allegro" ) ) else insert_static_backend( "allegro5" ) end diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 7db8f05c6..d0f016c07 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -643,6 +643,7 @@ ProjectExplorer.DefaultDeployConfiguration 1 + true diff --git a/src/eepp/gaming/mapeditor/cmapeditor.cpp b/src/eepp/gaming/mapeditor/cmapeditor.cpp index dd2053a05..2234c50e0 100644 --- a/src/eepp/gaming/mapeditor/cmapeditor.cpp +++ b/src/eepp/gaming/mapeditor/cmapeditor.cpp @@ -480,7 +480,7 @@ void cMapEditor::CreateUIMap() { mMapHScroll = mTheme->CreateScrollBar( mWinContainer, eeSize( Params.Size.Width(), ScrollH ), eeVector2i( 0, mWinContainer->Size().Height() - ScrollH ), UI_ANCHOR_LEFT | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM | UI_AUTO_SIZE ); mMapHScroll->AddEventListener( cUIEvent::EventOnValueChange, cb::Make1( this, &cMapEditor::OnScrollMapH ) ); - mMapVScroll = mTheme->CreateScrollBar( mWinContainer, eeSize( ScrollV, Params.Size.Height() ), eeVector2i( Params.Size.Width() + ScrollV, 0 ), UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM | UI_AUTO_SIZE , true ); + mMapVScroll = mTheme->CreateScrollBar( mWinContainer, eeSize( ScrollV, Params.Size.Height() ), eeVector2i( Params.Size.Width() + ScrollV, 0 ), UI_ANCHOR_TOP | UI_ANCHOR_BOTTOM | UI_AUTO_SIZE , true ); mMapVScroll->AddEventListener( cUIEvent::EventOnValueChange, cb::Make1( this, &cMapEditor::OnScrollMapV ) ); MapCreated(); diff --git a/src/eepp/ui/cuicontrol.cpp b/src/eepp/ui/cuicontrol.cpp index cd2ca0750..76795f7bf 100644 --- a/src/eepp/ui/cuicontrol.cpp +++ b/src/eepp/ui/cuicontrol.cpp @@ -248,6 +248,22 @@ void cUIControl::Draw() { if ( NULL != mSkinState ) mSkinState->Draw( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 255 ); + + if ( cUIManager::instance()->HighlightFocus() && cUIManager::instance()->FocusControl() == this ) { + cPrimitives P; + P.FillMode( EE_DRAW_LINE ); + P.BlendMode( Blend() ); + P.SetColor( cUIManager::instance()->HighlightFocusColor() ); + P.DrawRectangle( GetRectf() ); + } + + if ( cUIManager::instance()->HighlightOver() && cUIManager::instance()->OverControl() == this ) { + cPrimitives P; + P.FillMode( EE_DRAW_LINE ); + P.BlendMode( Blend() ); + P.SetColor( cUIManager::instance()->HighlightOverColor() ); + P.DrawRectangle( GetRectf() ); + } } } diff --git a/src/eepp/ui/cuicontrolanim.cpp b/src/eepp/ui/cuicontrolanim.cpp index e8d2d9e8b..f9bdbdad0 100644 --- a/src/eepp/ui/cuicontrolanim.cpp +++ b/src/eepp/ui/cuicontrolanim.cpp @@ -48,7 +48,15 @@ void cUIControlAnim::Draw() { cPrimitives P; P.FillMode( EE_DRAW_LINE ); P.BlendMode( Blend() ); - P.SetColor( cUIManager::instance()->HighlightColor() ); + P.SetColor( cUIManager::instance()->HighlightFocusColor() ); + P.DrawRectangle( GetRectf() ); + } + + if ( cUIManager::instance()->HighlightOver() && cUIManager::instance()->OverControl() == this ) { + cPrimitives P; + P.FillMode( EE_DRAW_LINE ); + P.BlendMode( Blend() ); + P.SetColor( cUIManager::instance()->HighlightOverColor() ); P.DrawRectangle( GetRectf() ); } } diff --git a/src/eepp/ui/cuimanager.cpp b/src/eepp/ui/cuimanager.cpp index 8b31d8f38..f7468f61a 100644 --- a/src/eepp/ui/cuimanager.cpp +++ b/src/eepp/ui/cuimanager.cpp @@ -18,7 +18,8 @@ cUIManager::cUIManager() : mCbId(-1), mResizeCb(0), mFlags( 0 ), - mHighlightColor( 234, 195, 123, 255 ), + mHighlightFocusColor( 234, 195, 123, 255 ), + mHighlightOverColor( 195, 123, 234, 255 ), mInit( false ), mFirstPress( false ), mShootingDown( false ) @@ -289,12 +290,28 @@ bool cUIManager::HighlightFocus() const { return 0 != ( mFlags & UI_MANAGER_HIGHLIGHT_FOCUS ); } -void cUIManager::HighlightColor( const eeColorA& Color ) { - mHighlightColor = Color; +void cUIManager::HighlightFocusColor( const eeColorA& Color ) { + mHighlightFocusColor = Color; } -const eeColorA& cUIManager::HighlightColor() const { - return mHighlightColor; +const eeColorA& cUIManager::HighlightFocusColor() const { + return mHighlightFocusColor; +} + +void cUIManager::HighlightOver( bool Highlight ) { + BitOp::SetBitFlagValue( &mFlags, UI_MANAGER_HIGHLIGHT_OVER, Highlight ? 1 : 0 ); +} + +bool cUIManager::HighlightOver() const { + return 0 != ( mFlags & UI_MANAGER_HIGHLIGHT_OVER ); +} + +void cUIManager::HighlightOverColor( const eeColorA& Color ) { + mHighlightOverColor = Color; +} + +const eeColorA& cUIManager::HighlightOverColor() const { + return mHighlightOverColor; } void cUIManager::CheckTabPress( const Uint32& KeyCode ) { diff --git a/src/eepp/ui/cuiscrollbar.cpp b/src/eepp/ui/cuiscrollbar.cpp index d2964128d..16a4200b5 100644 --- a/src/eepp/ui/cuiscrollbar.cpp +++ b/src/eepp/ui/cuiscrollbar.cpp @@ -102,9 +102,11 @@ void cUIScrollBar::SetTheme( cUITheme * Theme ) { if ( mSlider->IsVertical() ) { mSlider->Size( tSubTexture->RealSize().Width() , mSize.Height() ); Size( tSubTexture->RealSize().Width() , mSize.Height() ); + mMinControlSize.x = mSize.Width(); } else { mSlider->Size( mSize.Width(), tSubTexture->RealSize().Height() ); Size( mSize.Width(), tSubTexture->RealSize().Height() ); + mMinControlSize.y = mSize.Height(); } } } diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index fac2a98fd..a4f56d7f4 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -259,7 +259,7 @@ void cEETest::CreateUI() { Log->Writef( "Texture Atlas Loading Time: %f ms.", TE.ElapsedSinceStart() ); - cUIManager::instance()->Init(); //UI_MANAGER_HIGHLIGHT_FOCUS + cUIManager::instance()->Init(); //UI_MANAGER_HIGHLIGHT_FOCUS | UI_MANAGER_HIGHLIGHT_OVER //mTheme = cUITheme::LoadFromPath( eeNew( cUIDefaultTheme, ( "uitheme", "uitheme" ) ), MyPath + "uitheme/" );