mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-04 20:46:29 +03:00
Added cUIWindow, still in development, basic window is working ( no resizing from borders ).
Some UI bug fixes. Some minor changes on cEngine where made.
This commit is contained in:
34
src/base.hpp
34
src/base.hpp
@@ -33,9 +33,9 @@
|
||||
#define Int32 Sint32
|
||||
#define Int64 Sint64
|
||||
|
||||
#define EE_PLATFORM_WIN 1
|
||||
#define EE_PLATFORM_LINUX 2
|
||||
#define EE_PLATFORM_MACOSX 3
|
||||
#define EE_PLATFORM_WIN 1
|
||||
#define EE_PLATFORM_LINUX 2
|
||||
#define EE_PLATFORM_MACOSX 3
|
||||
|
||||
#if defined( __WIN32__ ) || defined( _WIN32 ) || defined( _WIN64 )
|
||||
# define EE_PLATFORM EE_PLATFORM_WIN
|
||||
@@ -74,6 +74,24 @@
|
||||
#define EE_32BIT
|
||||
#endif
|
||||
|
||||
|
||||
#define EE_LITTLE_ENDIAN 1
|
||||
#define EE_BIG_ENDIAN 2
|
||||
|
||||
#if defined(__386__) || defined(i386) || defined(__i386__) \
|
||||
|| defined(__X86) || defined(_M_IX86) \
|
||||
|| defined(_M_X64) || defined(__x86_64__) \
|
||||
|| defined(alpha) || defined(__alpha) || defined(__alpha__) \
|
||||
|| defined(_M_ALPHA) \
|
||||
|| defined(ARM) || defined(_ARM) || defined(__arm__) \
|
||||
|| defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
|
||||
|| defined(_WIN32_WCE) || defined(__NT__) \
|
||||
|| defined(__MIPSEL__)
|
||||
#define EE_ENDIAN EE_LITTLE_ENDIAN
|
||||
#else
|
||||
#define EE_ENDIAN EE_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_MACOSX || EE_PLATFORM == EE_PLATFORM_LINUX
|
||||
#define EE_GLEW_AVAILABLE
|
||||
#else
|
||||
@@ -128,12 +146,12 @@
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
namespace EE {
|
||||
#define eeARRAY_SIZE(__array) ( sizeof(__array) / sizeof(__array[0]) )
|
||||
#define eeSAFE_DELETE(p) { if(p) { eeDelete (p); (p)=NULL; } }
|
||||
#define eeSAFE_FREE(p) { if(p) { eeFree ( (void*)p ); (p)=NULL; } }
|
||||
#define eeSAFE_DELETE_ARRAY(p) { if(p) { eeDeleteArray(p); (p)=NULL; } }
|
||||
#define eeARRAY_SIZE(__array) ( sizeof(__array) / sizeof(__array[0]) )
|
||||
#define eeSAFE_DELETE(p) { if(p) { eeDelete (p); (p)=NULL; } }
|
||||
#define eeSAFE_FREE(p) { if(p) { eeFree ( (void*)p ); (p)=NULL; } }
|
||||
#define eeSAFE_DELETE_ARRAY(p) { if(p) { eeDeleteArray(p); (p)=NULL; } }
|
||||
|
||||
namespace EE {
|
||||
typedef float eeFloat; //! The internal floating point used on EE++. \n This can help to improve compatibility with some platforms. \n And helps for an easy change from single precision to double precision.
|
||||
typedef double eeDouble; //! The internal double floating point. It's only used when the engine needs some very high precision floating point ( for example the timer )
|
||||
typedef unsigned int eeUint;
|
||||
|
||||
@@ -60,21 +60,11 @@ void * MemoryManager::AddPointer( const cAllocatedPointer& aAllocatedPointer ) {
|
||||
bool MemoryManager::RemovePointer( void * Data ) {
|
||||
bool Found = false;
|
||||
|
||||
tAllocatedPointerMapIt it = mMapPointers.upper_bound( Data );
|
||||
tAllocatedPointerMapIt it = mMapPointers.find( Data );
|
||||
|
||||
it--;
|
||||
|
||||
if( it != mMapPointers.end() ) {
|
||||
char * Test = (char*)it->second.mData;
|
||||
|
||||
size_t testSize = it->second.mMemory;
|
||||
|
||||
if( Data >= Test && Data < Test + testSize )
|
||||
Found = true;
|
||||
}
|
||||
|
||||
|
||||
if ( !Found ) {
|
||||
if ( it != mMapPointers.end() ) {
|
||||
Found = true;
|
||||
} else {
|
||||
eePRINT( "Trying to delete pointer %p created that does not exist!\n", Data );
|
||||
|
||||
return false;
|
||||
@@ -145,7 +135,8 @@ void MemoryManager::LogResults() {
|
||||
eePRINT( "|\n" );
|
||||
eePRINT( "| Memory left: %s\n", SizeToString( mTotalMemoryUsage ).c_str() );
|
||||
eePRINT( "| Peak Memory Usage: %s\n", SizeToString( mPeakMemoryUsage ).c_str() );
|
||||
eePRINT( "|------------------------------------------------------|\n\n" );
|
||||
eePRINT( "|------------------------------------------------------------\n\n" );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class cAllocatedPointer {
|
||||
|
||||
std::string mFile;
|
||||
int mLine;
|
||||
size_t mMemory;
|
||||
size_t mMemory;
|
||||
void * mData;
|
||||
};
|
||||
|
||||
@@ -23,79 +23,80 @@ typedef tAllocatedPointerMap::iterator tAllocatedPointerMapIt;
|
||||
|
||||
class MemoryManager {
|
||||
public:
|
||||
|
||||
static void * AddPointer( const cAllocatedPointer& aAllocatedPointer );
|
||||
|
||||
static bool RemovePointer( void * Data );
|
||||
|
||||
static void LogResults();
|
||||
|
||||
static void SetLogCreation( bool abX );
|
||||
|
||||
template<class T>
|
||||
static T* DeleteAndReturn( T * Data ) {
|
||||
static T* Delete( T * Data ) {
|
||||
delete Data;
|
||||
return Data;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static T* DeleteArrayAndReturn( T * Data ) {
|
||||
static T* DeleteArray( T * Data ) {
|
||||
delete [] Data;
|
||||
return Data;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static T* FreeAndReturn( T * Data ) {
|
||||
static T * Free( T * Data ) {
|
||||
free( Data );
|
||||
return Data;
|
||||
}
|
||||
|
||||
static size_t GetPeakMemoryUsage() { return mPeakMemoryUsage; }
|
||||
static size_t GetTotalMemoryUsage() { return mTotalMemoryUsage; }
|
||||
inline static void * Allocate( size_t size ) {
|
||||
return malloc( size );
|
||||
}
|
||||
|
||||
static size_t GetPeakMemoryUsage() { return mPeakMemoryUsage; }
|
||||
static size_t GetTotalMemoryUsage() { return mTotalMemoryUsage; }
|
||||
|
||||
static tAllocatedPointerMap mMapPointers;
|
||||
static size_t mTotalMemoryUsage;
|
||||
static size_t mTotalMemoryUsage;
|
||||
static size_t mPeakMemoryUsage;
|
||||
};
|
||||
|
||||
#ifdef EE_MEMORY_MANAGER
|
||||
#define eeNew(classType, constructor) \
|
||||
( classType *)EE::MemoryManager::AddPointer( EE::cAllocatedPointer(new classType constructor ,__FILE__,__LINE__,sizeof(classType) ) )
|
||||
#define eeNew( classType, constructor ) \
|
||||
( classType *)EE::MemoryManager::AddPointer( EE::cAllocatedPointer( new classType constructor ,__FILE__,__LINE__, sizeof(classType) ) )
|
||||
|
||||
#define eeNewArray(classType, amount) \
|
||||
#define eeNewArray( classType, amount ) \
|
||||
( classType *) EE::MemoryManager::AddPointer( EE::cAllocatedPointer( new classType [ amount ], __FILE__, __LINE__, amount * sizeof( classType ) ) )
|
||||
|
||||
#define eeMalloc(amount) \
|
||||
EE::MemoryManager::AddPointer( EE::cAllocatedPointer( malloc( amount ) , __FILE__, __LINE__, amount ) )
|
||||
EE::MemoryManager::AddPointer( EE::cAllocatedPointer( EE::MemoryManager::Allocate( amount ), __FILE__, __LINE__, amount ) )
|
||||
|
||||
#define eeDelete(data){ \
|
||||
if( EE::MemoryManager::RemovePointer( EE::MemoryManager::DeleteAndReturn( data ) ) == false ) printf( "Deleting at '%s' %d\n", __FILE__, __LINE__ ); \
|
||||
#define eeDelete( data ){ \
|
||||
if( EE::MemoryManager::RemovePointer( EE::MemoryManager::Delete( data ) ) == false ) printf( "Deleting at '%s' %d\n", __FILE__, __LINE__ ); \
|
||||
}
|
||||
|
||||
#define eeDeleteArray(data){ \
|
||||
if(EE::MemoryManager::RemovePointer( EE::MemoryManager::DeleteArrayAndReturn( data ) ) == false ) printf( "Deleting at '%s' %d\n", __FILE__, __LINE__ ); \
|
||||
#define eeDeleteArray( data ){ \
|
||||
if ( EE::MemoryManager::RemovePointer( EE::MemoryManager::DeleteArray( data ) ) == false ) printf( "Deleting at '%s' %d\n", __FILE__, __LINE__ ); \
|
||||
}
|
||||
|
||||
#define eeFree( data ){ \
|
||||
if( EE::MemoryManager::RemovePointer( EE::MemoryManager::FreeAndReturn( data ) ) == false ) printf( "Deleting at '%s' %d\n", __FILE__, __LINE__ ); \
|
||||
if( EE::MemoryManager::RemovePointer( EE::MemoryManager::Free( data ) ) == false ) printf( "Deleting at '%s' %d\n", __FILE__, __LINE__ ); \
|
||||
}
|
||||
#else
|
||||
#define eeNew(classType, constructor) \
|
||||
#define eeNew( classType, constructor ) \
|
||||
new classType constructor
|
||||
|
||||
#define eeNewArray(classType, amount) \
|
||||
#define eeNewArray( classType, amount ) \
|
||||
new classType [ amount ]
|
||||
|
||||
#define eeMalloc(amount) \
|
||||
#define eeMalloc( amount ) \
|
||||
malloc( amount )
|
||||
|
||||
#define eeDelete(data) \
|
||||
#define eeDelete( data ) \
|
||||
delete data;
|
||||
|
||||
#define eeDeleteArray(data) \
|
||||
#define eeDeleteArray( data ) \
|
||||
delete [] data;
|
||||
|
||||
#define eeFree(data) \
|
||||
#define eeFree( data ) \
|
||||
free(data);
|
||||
#endif
|
||||
|
||||
|
||||
1
src/ee.h
1
src/ee.h
@@ -171,5 +171,6 @@
|
||||
#include "ui/cuitextedit.hpp"
|
||||
#include "ui/cuigridcell.hpp"
|
||||
#include "ui/cuigenericgrid.hpp"
|
||||
#include "ui/cuiwindow.hpp"
|
||||
using namespace EE::UI;
|
||||
#endif
|
||||
|
||||
@@ -48,6 +48,12 @@ class cUITest : public cUIControlAnim {
|
||||
return 1;
|
||||
}
|
||||
|
||||
virtual Uint32 OnFocus() {
|
||||
ToFront();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
const std::vector<eeColorA>& OldColor() { return mOldColor; }
|
||||
protected:
|
||||
std::vector<eeColorA> mOldColor;
|
||||
@@ -403,6 +409,7 @@ void cEETest::CreateUI() {
|
||||
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" ) );
|
||||
|
||||
CreateAquaTextureAtlas();
|
||||
|
||||
cTextureGroupLoader tgl( MyPath + "data/aquatg/aqua.etg" );
|
||||
@@ -658,10 +665,6 @@ void cEETest::CreateUI() {
|
||||
Menu->GetItem( L"Quit" )->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cEETest::QuitClick ) );
|
||||
cUIManager::instance()->MainControl()->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cEETest::MainClick ) );
|
||||
|
||||
C->StartScaleAnim( 0.f, 1.f, 500.f, SINEOUT );
|
||||
C->StartAlphaAnim( 0.f, 255.f, 500.f );
|
||||
C->StartRotation( 0, 360, 500.f, SINEOUT );
|
||||
|
||||
cUITextEdit::CreateParams TEParams;
|
||||
TEParams.Parent( C );
|
||||
TEParams.PosSet( 5, 245 );
|
||||
@@ -712,6 +715,19 @@ void cEETest::CreateUI() {
|
||||
mGenGrid->CollumnWidth( 0, 50 );
|
||||
mGenGrid->CollumnWidth( 1, 24 );
|
||||
mGenGrid->CollumnWidth( 2, 100 );
|
||||
|
||||
C->StartScaleAnim( 0.f, 1.f, 500.f, SINEOUT );
|
||||
C->StartAlphaAnim( 0.f, 255.f, 500.f );
|
||||
C->StartRotation( 0, 360, 500.f, SINEOUT );
|
||||
|
||||
cUIWindow::CreateParams WinParams;
|
||||
WinParams.PosSet( 200, 50 );
|
||||
WinParams.Size = eeSize( 530, 380 );
|
||||
WinParams.ButtonsPositionFixer.x = -4;
|
||||
WinParams.ButtonsPositionFixer.y = -2;
|
||||
cUIWindow * mWindow = eeNew( cUIWindow, ( WinParams ) );
|
||||
mWindow->ToBack();
|
||||
mWindow->Show();
|
||||
}
|
||||
|
||||
void cEETest::ItemClick( const cUIEvent * Event ) {
|
||||
@@ -1296,9 +1312,13 @@ void cEETest::Input() {
|
||||
if ( mLastFPSLimit != EE->GetFrameRateLimit() && !mWasMinimized )
|
||||
mLastFPSLimit = EE->GetFrameRateLimit();
|
||||
|
||||
if ( mWasMinimized )
|
||||
if ( mWasMinimized ) {
|
||||
mWasMinimized = false;
|
||||
|
||||
if ( !EE->Windowed() )
|
||||
KM->GrabInput( true );
|
||||
}
|
||||
|
||||
EE->SetFrameRateLimit( mLastFPSLimit );
|
||||
|
||||
if ( Mus->State() == SOUND_PAUSED )
|
||||
@@ -1328,11 +1348,11 @@ void cEETest::Input() {
|
||||
}
|
||||
|
||||
if ( KM->GrabInput() ) {
|
||||
if ( KM->AltPressed() && KM->IsKeyDown(KEY_TAB) ) {
|
||||
if ( KM->AltPressed() && KM->IsKeyDown( KEY_TAB ) ) {
|
||||
EE->MinimizeWindow();
|
||||
|
||||
if ( KM->GrabInput() )
|
||||
KM->GrabInput(false);
|
||||
KM->GrabInput( false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1347,11 +1367,6 @@ void cEETest::Input() {
|
||||
InBuf.Active( true );
|
||||
}
|
||||
|
||||
if ( InBuf.Active() && ( ( KM->ControlPressed() && KM->IsKeyUp(KEY_V) ) || ( KM->ShiftPressed() && KM->IsKeyUp(KEY_INSERT) ) ) ) {
|
||||
std::wstring tmp = InBuf.Buffer();
|
||||
InBuf.Buffer( tmp + EE->GetClipboardTextWStr() );
|
||||
}
|
||||
|
||||
if ( KM->IsKeyUp(KEY_1) && KM->ControlPressed() )
|
||||
Screen = 0;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ cUIComplexControl::cUIComplexControl( const cUIComplexControl::CreateParams& Par
|
||||
cUIControlAnim( Params ),
|
||||
mTooltip( NULL )
|
||||
{
|
||||
mType |= UI_TYPE_CONTROL_COMPLEX;
|
||||
mType |= UI_TYPE_GET( UI_TYPE_CONTROL_COMPLEX );
|
||||
|
||||
TooltipText( Params.TooltipText );
|
||||
}
|
||||
@@ -73,7 +73,7 @@ void cUIComplexControl::CreateTooltip() {
|
||||
cUITooltip::CreateParams Params;
|
||||
Params.Parent( cUIManager::instance()->MainControl() );
|
||||
Params.Flags = UI_VALIGN_CENTER | UI_HALIGN_CENTER | UI_AUTO_PADDING | UI_AUTO_SIZE;
|
||||
mTooltip = eeNew( cUITooltip, ( Params ) );
|
||||
mTooltip = eeNew( cUITooltip, ( Params, this ) );
|
||||
}
|
||||
|
||||
void cUIComplexControl::TooltipText( const std::wstring& Text ) {
|
||||
@@ -99,4 +99,8 @@ std::wstring cUIComplexControl::TooltipText() {
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
void cUIComplexControl::TooltipRemove() {
|
||||
mTooltip = NULL;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -28,6 +28,8 @@ class EE_API cUIComplexControl : public cUIControlAnim {
|
||||
|
||||
cUITooltip * Tooltip();
|
||||
|
||||
void TooltipRemove();
|
||||
|
||||
void TooltipText( const std::wstring& Text );
|
||||
|
||||
void TooltipText( const std::string& Text );
|
||||
|
||||
@@ -51,11 +51,13 @@ cUIControl::~cUIControl() {
|
||||
if ( NULL != mParentCtrl )
|
||||
mParentCtrl->ChildRemove( this );
|
||||
|
||||
if ( cUIManager::instance()->FocusControl() == this )
|
||||
cUIManager::instance()->FocusControl( NULL );
|
||||
if ( cUIManager::instance()->FocusControl() == this && cUIManager::instance()->MainControl() != this ) {
|
||||
cUIManager::instance()->FocusControl( cUIManager::instance()->MainControl() );
|
||||
}
|
||||
|
||||
if ( cUIManager::instance()->OverControl() == this )
|
||||
cUIManager::instance()->OverControl( NULL );
|
||||
if ( cUIManager::instance()->OverControl() == this && cUIManager::instance()->MainControl() != this ) {
|
||||
cUIManager::instance()->OverControl( cUIManager::instance()->MainControl() );
|
||||
}
|
||||
}
|
||||
|
||||
void cUIControl::ScreenToControl( eeVector2i& Pos ) const {
|
||||
@@ -178,6 +180,9 @@ cUIControl * cUIControl::Parent() const {
|
||||
}
|
||||
|
||||
void cUIControl::Parent( cUIControl * parent ) {
|
||||
if ( parent == mParentCtrl )
|
||||
return;
|
||||
|
||||
if ( NULL != mParentCtrl )
|
||||
mParentCtrl->ChildRemove( this );
|
||||
|
||||
@@ -433,12 +438,10 @@ void cUIControl::ToFront() {
|
||||
}
|
||||
|
||||
void cUIControl::ToBack() {
|
||||
mParentCtrl->ChildRemove( this );
|
||||
mParentCtrl->ChildAddAt( this, 0 );
|
||||
}
|
||||
|
||||
void cUIControl::ToPos( const Uint32& Pos ) {
|
||||
mParentCtrl->ChildRemove( this );
|
||||
mParentCtrl->ChildAddAt( this, Pos );
|
||||
}
|
||||
|
||||
@@ -466,6 +469,7 @@ void cUIControl::OnPosChange() {
|
||||
|
||||
void cUIControl::OnSizeChange() {
|
||||
SendCommonEvent( cUIEvent::EventOnSizeChange );
|
||||
SendParentSizeChange();
|
||||
}
|
||||
|
||||
void cUIControl::BackgroundDraw() {
|
||||
@@ -602,6 +606,7 @@ void cUIControl::ChildAddAt( cUIControl * ChildCtrl, Uint32 Pos ) {
|
||||
cUIControl * ChildLoop = mChild;
|
||||
|
||||
ChildCtrl->Parent( this );
|
||||
|
||||
ChildRemove( ChildCtrl );
|
||||
ChildCtrl->mParentCtrl = this;
|
||||
|
||||
@@ -1003,4 +1008,62 @@ void cUIControl::SetFocus() {
|
||||
cUIManager::instance()->FocusControl( this );
|
||||
}
|
||||
|
||||
void cUIControl::SendParentSizeChange() {
|
||||
if ( mFlags & UI_REPORT_SIZE_CHANGE_TO_CHILDS ) {
|
||||
cUIControl * ChildLoop = mChild;
|
||||
|
||||
while( NULL != ChildLoop ) {
|
||||
ChildLoop->OnParentSizeChange();
|
||||
ChildLoop = ChildLoop->mNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cUIControl::OnParentSizeChange() {
|
||||
SendCommonEvent( cUIEvent::EventOnParentSizeChange );
|
||||
}
|
||||
|
||||
eeSize cUIControl::GetSkinShapeSize() {
|
||||
cUISkin * tSkin = GetSkin();
|
||||
eeSize tSize;
|
||||
|
||||
if ( NULL != tSkin ) {
|
||||
cShape * tShape = tSkin->GetShape( cUISkinState::StateNormal );
|
||||
|
||||
if ( NULL != tShape ) {
|
||||
tSize = tShape->RealSize();
|
||||
}
|
||||
|
||||
if ( tSkin->GetType() == cUISkin::UISkinComplex ) {
|
||||
cUISkinComplex * tSkinC = reinterpret_cast<cUISkinComplex*> ( tSkin );
|
||||
|
||||
tShape = tSkinC->GetShapeSide( cUISkinState::StateNormal, cUISkinComplex::Up );
|
||||
|
||||
if ( NULL != tShape ) {
|
||||
tSize.y += tShape->RealSize().Height();
|
||||
}
|
||||
|
||||
tShape = tSkinC->GetShapeSide( cUISkinState::StateNormal, cUISkinComplex::Down );
|
||||
|
||||
if ( NULL != tShape ) {
|
||||
tSize.y += tShape->RealSize().Height();
|
||||
}
|
||||
|
||||
tShape = tSkinC->GetShapeSide( cUISkinState::StateNormal, cUISkinComplex::Left );
|
||||
|
||||
if ( NULL != tShape ) {
|
||||
tSize.x += tShape->RealSize().Width();
|
||||
}
|
||||
|
||||
tShape = tSkinC->GetShapeSide( cUISkinState::StateNormal, cUISkinComplex::Right );
|
||||
|
||||
if ( NULL != tShape ) {
|
||||
tSize.y += tShape->RealSize().Width();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tSize;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -92,7 +92,7 @@ class EE_API cUIControl {
|
||||
|
||||
const eeVector2i& Pos() const;
|
||||
|
||||
void Size( const eeSize& Size );
|
||||
virtual void Size( const eeSize& Size );
|
||||
|
||||
void Size( const Int32& Width, const Int32& Height );
|
||||
|
||||
@@ -222,6 +222,8 @@ class EE_API cUIControl {
|
||||
void SendMouseEvent( const Uint32& Event, const eeVector2i& Pos, const Uint32& Flags );
|
||||
|
||||
void SendCommonEvent( const Uint32& Event );
|
||||
|
||||
eeSize GetSkinShapeSize();
|
||||
protected:
|
||||
friend class cUIManager;
|
||||
|
||||
@@ -289,6 +291,8 @@ class EE_API cUIControl {
|
||||
|
||||
virtual void OnSizeChange();
|
||||
|
||||
virtual void OnParentSizeChange();
|
||||
|
||||
virtual void OnStateChange();
|
||||
|
||||
virtual void OnComplexControlFocusLoss();
|
||||
@@ -347,6 +351,8 @@ class EE_API cUIControl {
|
||||
|
||||
void ApplyDefaultTheme();
|
||||
|
||||
void SendParentSizeChange();
|
||||
|
||||
eeFloat Elapsed();
|
||||
|
||||
eeRecti MakePadding( bool PadLeft = true, bool PadRight = true, bool PadTop = true, bool PadBottom = true, bool SkipFlags = false );
|
||||
|
||||
@@ -24,7 +24,6 @@ cUIControlAnim::~cUIControlAnim() {
|
||||
eeSAFE_DELETE( mMoveAnim );
|
||||
}
|
||||
|
||||
|
||||
void cUIControlAnim::Draw() {
|
||||
if ( mVisible && 0.f != mAlpha ) {
|
||||
if ( mFlags & UI_FILL_BACKGROUND )
|
||||
@@ -105,7 +104,6 @@ void cUIControlAnim::Update() {
|
||||
if ( ( mControlFlags & UI_CTRL_FLAG_CLOSE_FO ) )
|
||||
Close();
|
||||
|
||||
|
||||
if ( ( mControlFlags & UI_CTRL_FLAG_DISABLE_FADE_OUT ) ) {
|
||||
mControlFlags &= ~UI_CTRL_FLAG_DISABLE_FADE_OUT;
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ class EE_API cUIEvent {
|
||||
EventOnItemKeyDown,
|
||||
EventOnItemKeyUp,
|
||||
EventOnCursorPosChange,
|
||||
EventOnParentSizeChange,
|
||||
EventUser,
|
||||
EventForceDWord = 0xFFFFFFFF
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@ bool cUIPopUpMenu::Show() {
|
||||
if ( !Visible() ) {
|
||||
Enabled( true );
|
||||
Visible( true );
|
||||
ToFront();
|
||||
|
||||
if ( 255.f == Alpha() )
|
||||
StartAlphaAnim( 0.f, 255.f, cUIThemeManager::instance()->ControlsFadeInTime() );
|
||||
|
||||
@@ -132,7 +132,7 @@ void cUISkinComplex::Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Wi
|
||||
|
||||
if ( NULL != tShape ) {
|
||||
tShape->DestWidth( Width - uls.Width() - urs.Width() );
|
||||
tShape->DestHeight( Height - uls.Height() - urs.Height() );
|
||||
tShape->DestHeight( Height - uls.Height() - dls.Height() );
|
||||
|
||||
tShape->Draw( X + uls.Width(), Y + uls.Height(), mTempColor );
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ static std::vector<std::string> UI_THEME_ELEMENTS;
|
||||
|
||||
static void LoadThemeElements() {
|
||||
if ( !UI_THEME_ELEMENTS.size() ) {
|
||||
UI_THEME_ELEMENTS.reserve( 50 );
|
||||
UI_THEME_ELEMENTS.reserve( 60 );
|
||||
UI_THEME_ELEMENTS.push_back( "control" );
|
||||
UI_THEME_ELEMENTS.push_back( "button" );
|
||||
UI_THEME_ELEMENTS.push_back( "textinput" );
|
||||
@@ -60,6 +60,15 @@ static void LoadThemeElements() {
|
||||
UI_THEME_ELEMENTS.push_back( "tooltip" );
|
||||
UI_THEME_ELEMENTS.push_back( "genericgrid" );
|
||||
UI_THEME_ELEMENTS.push_back( "gridcell" );
|
||||
UI_THEME_ELEMENTS.push_back( "windeco" );
|
||||
UI_THEME_ELEMENTS.push_back( "winback" );
|
||||
UI_THEME_ELEMENTS.push_back( "winborderleft" );
|
||||
UI_THEME_ELEMENTS.push_back( "winborderright" );
|
||||
UI_THEME_ELEMENTS.push_back( "winborderbottom" );
|
||||
UI_THEME_ELEMENTS.push_back( "winclose" );
|
||||
UI_THEME_ELEMENTS.push_back( "winmax" );
|
||||
UI_THEME_ELEMENTS.push_back( "winmin" );
|
||||
UI_THEME_ELEMENTS.push_back( "winshade" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +77,8 @@ void cUITheme::AddThemeElement( const std::string& Element ) {
|
||||
}
|
||||
|
||||
cUITheme * cUITheme::LoadFromPath( const std::string& Path, const std::string& Name, const std::string& NameAbbr, const std::string ImgExt ) {
|
||||
cTimeElapsed TE;
|
||||
|
||||
LoadThemeElements();
|
||||
|
||||
Uint32 i;
|
||||
@@ -114,10 +125,14 @@ cUITheme * cUITheme::LoadFromPath( const std::string& Path, const std::string& N
|
||||
tTheme->Add( eeNew( cUISkinSimple, ( ElemFound[i] ) ) );
|
||||
}
|
||||
|
||||
cLog::instance()->Write( "UI Theme Loaded in: " + toStr( TE.ElapsedSinceStart() ) + " ( from path )" );
|
||||
|
||||
return tTheme;
|
||||
}
|
||||
|
||||
cUITheme * cUITheme::LoadFromShapeGroup( cShapeGroup * ShapeGroup, const std::string& Name, const std::string NameAbbr ) {
|
||||
cTimeElapsed TE;
|
||||
|
||||
LoadThemeElements();
|
||||
|
||||
Uint32 i;
|
||||
@@ -150,6 +165,8 @@ cUITheme * cUITheme::LoadFromShapeGroup( cShapeGroup * ShapeGroup, const std::st
|
||||
tTheme->Add( eeNew( cUISkinSimple, ( ElemFound[i] ) ) );
|
||||
}
|
||||
|
||||
cLog::instance()->Write( "UI Theme Loaded in: " + toStr( TE.ElapsedSinceStart() ) + " ( from ShapeGroup )" );
|
||||
|
||||
return tTheme;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
#include "cuitooltip.hpp"
|
||||
#include "cuimanager.hpp"
|
||||
#include "cuicomplexcontrol.hpp"
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
cUITooltip::cUITooltip( cUITooltip::CreateParams& Params ) :
|
||||
cUITooltip::cUITooltip( cUITooltip::CreateParams& Params, cUIControl * TooltipOf ) :
|
||||
cUIControlAnim( Params ),
|
||||
mFontColor( Params.FontColor ),
|
||||
mFontShadowColor( Params.FontShadowColor ),
|
||||
mAlignOffset( 0.f, 0.f ),
|
||||
mTooltipTime( 0.f )
|
||||
mTooltipTime( 0.f ),
|
||||
mTooltipOf( TooltipOf )
|
||||
{
|
||||
mType |= UI_TYPE_TOOLTIP;
|
||||
|
||||
@@ -34,6 +36,10 @@ cUITooltip::cUITooltip( cUITooltip::CreateParams& Params ) :
|
||||
|
||||
cUITooltip::~cUITooltip() {
|
||||
eeSAFE_DELETE( mTextCache );
|
||||
|
||||
if ( NULL != mTooltipOf && mTooltipOf->IsType( UI_TYPE_CONTROL_COMPLEX ) ) {
|
||||
reinterpret_cast<cUIComplexControl*>( mTooltipOf )->TooltipRemove();
|
||||
}
|
||||
}
|
||||
|
||||
void cUITooltip::SetTheme( cUITheme * Theme ) {
|
||||
|
||||
@@ -34,7 +34,7 @@ class EE_API cUITooltip : public cUIControlAnim {
|
||||
eeColorA FontShadowColor;
|
||||
};
|
||||
|
||||
cUITooltip( cUITooltip::CreateParams& Params );
|
||||
cUITooltip( cUITooltip::CreateParams& Params, cUIControl * TooltipOf );
|
||||
|
||||
~cUITooltip();
|
||||
|
||||
@@ -96,6 +96,7 @@ class EE_API cUITooltip : public cUIControlAnim {
|
||||
eeVector2f mAlignOffset;
|
||||
eeRecti mPadding;
|
||||
eeFloat mTooltipTime;
|
||||
cUIControl * mTooltipOf;
|
||||
|
||||
virtual void OnSizeChange();
|
||||
|
||||
|
||||
294
src/ui/cuiwindow.cpp
Normal file
294
src/ui/cuiwindow.cpp
Normal file
@@ -0,0 +1,294 @@
|
||||
#include "cuiwindow.hpp"
|
||||
#include "cuimanager.hpp"
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
cUIWindow::cUIWindow( const cUIWindow::CreateParams& Params ) :
|
||||
cUIComplexControl( Params ),
|
||||
mWinFlags( Params.WinFlags ),
|
||||
mButtonClose( NULL ),
|
||||
mButtonMinimize( NULL ),
|
||||
mButtonMaximize( NULL ),
|
||||
mDecoSize( Params.DecorationSize ),
|
||||
mBorderSize( Params.BorderSize ),
|
||||
mMinWindowSize( Params.MinWindowSize ),
|
||||
mButtonsPositionFixer( Params.ButtonsPositionFixer ),
|
||||
mButtonsSeparation( Params.ButtonsSeparation ),
|
||||
mDecoAutoSize( Params.DecorationAutoSize ),
|
||||
mBorderAutoSize( Params.BorderAutoSize )
|
||||
{
|
||||
mType |= UI_TYPE_GET( UI_TYPE_WINDOW );
|
||||
|
||||
cUIControlAnim::CreateParams tParams;
|
||||
tParams.Parent( this );
|
||||
|
||||
mWindowDecoration = eeNew( cUIControlAnim, ( tParams ) );
|
||||
mWindowDecoration->Visible( true );
|
||||
mWindowDecoration->Enabled( false );
|
||||
|
||||
mBorderLeft = eeNew( cUIControlAnim, ( tParams ) );
|
||||
mBorderLeft->Enabled( true );
|
||||
mBorderLeft->Visible( true );
|
||||
|
||||
mBorderRight = eeNew( cUIControlAnim, ( tParams ) );
|
||||
mBorderRight->Enabled( true );
|
||||
mBorderRight->Visible( true );
|
||||
|
||||
mBorderBottom = eeNew( cUIControlAnim, ( tParams ) );
|
||||
mBorderBottom->Enabled( true );
|
||||
mBorderBottom->Visible( true );
|
||||
|
||||
mContainer = eeNew( cUIControlAnim, ( tParams ) );
|
||||
mContainer->Enabled( true );
|
||||
mContainer->Visible( true );
|
||||
mContainer->AddEventListener( cUIEvent::EventOnPosChange, cb::Make1( this, &cUIWindow::ContainerPosChange ) );
|
||||
|
||||
if ( mWinFlags & UI_WIN_DRAGABLE_CONTAINER )
|
||||
mContainer->DragEnable( true );
|
||||
|
||||
cUIComplexControl::CreateParams ButtonParams;
|
||||
ButtonParams.Parent( this );
|
||||
|
||||
if ( mWinFlags & UI_WIN_CLOSE_BUTTON ) {
|
||||
mButtonClose = eeNew( cUIComplexControl, ( ButtonParams ) );
|
||||
mButtonClose->Visible( true );
|
||||
mButtonClose->Enabled( true );
|
||||
|
||||
if ( mWinFlags & UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS ) {
|
||||
mButtonClose->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cUIWindow::ButtonCloseClick ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( mWinFlags & UI_WIN_RESIZEABLE ) && ( mWinFlags & UI_WIN_MAXIMIZE_BUTTON ) ) {
|
||||
mButtonMaximize = eeNew( cUIComplexControl, ( ButtonParams ) );
|
||||
mButtonMaximize->Visible( true );
|
||||
mButtonMaximize->Enabled( true );
|
||||
|
||||
if ( mWinFlags & UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS ) {
|
||||
mButtonMaximize->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cUIWindow::ButtonMaximizeClick ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( mWinFlags & UI_WIN_MINIMIZE_BUTTON ) {
|
||||
mButtonMinimize = eeNew( cUIComplexControl, ( ButtonParams ) );
|
||||
mButtonMinimize->Visible( true );
|
||||
mButtonMinimize->Enabled( true );
|
||||
|
||||
if ( mWinFlags & UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS ) {
|
||||
mButtonMinimize->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cUIWindow::ButtonMinimizeClick ) );
|
||||
}
|
||||
}
|
||||
|
||||
DragEnable( true );
|
||||
|
||||
ApplyDefaultTheme();
|
||||
}
|
||||
|
||||
cUIWindow::~cUIWindow() {
|
||||
}
|
||||
|
||||
void cUIWindow::ContainerPosChange( const cUIEvent * Event ) {
|
||||
eeVector2i PosDiff = mContainer->Pos() - eeVector2i( mBorderLeft->Size().Width(), mWindowDecoration->Size().Height() );
|
||||
|
||||
if ( PosDiff.x != 0 || PosDiff.y != 0 ) {
|
||||
mContainer->Pos( mBorderLeft->Size().Width(), mWindowDecoration->Size().Height() );
|
||||
|
||||
Pos( mPos + PosDiff );
|
||||
}
|
||||
}
|
||||
|
||||
void cUIWindow::ButtonCloseClick( const cUIEvent * Event ) {
|
||||
CloseFadeOut( cUIThemeManager::instance()->ControlsFadeOutTime() );
|
||||
}
|
||||
|
||||
void cUIWindow::ButtonMaximizeClick( const cUIEvent * Event ) {
|
||||
cUIControl * Ctrl = cUIManager::instance()->MainControl();
|
||||
|
||||
if ( Ctrl->Size() == cUIControl::Size() ) {
|
||||
Pos( mNonMaxPos );
|
||||
Size( mNonMaxSize );
|
||||
} else {
|
||||
mNonMaxPos = mPos;
|
||||
mNonMaxSize = mSize;
|
||||
|
||||
Pos( 0, 0 );
|
||||
Size( cUIManager::instance()->MainControl()->Size() );
|
||||
}
|
||||
}
|
||||
|
||||
void cUIWindow::ButtonMinimizeClick( const cUIEvent * Event ) {
|
||||
Hide();
|
||||
}
|
||||
|
||||
void cUIWindow::SetTheme( cUITheme *Theme ) {
|
||||
cUIComplexControl::SetTheme( Theme );
|
||||
|
||||
mContainer->ForceThemeSkin ( Theme, "winback" );
|
||||
mWindowDecoration->ForceThemeSkin ( Theme, "windeco" );
|
||||
mBorderLeft->ForceThemeSkin ( Theme, "winborderleft" );
|
||||
mBorderRight->ForceThemeSkin ( Theme, "winborderright" );
|
||||
mBorderBottom->ForceThemeSkin ( Theme, "winborderbottom" );
|
||||
|
||||
if ( NULL != mButtonClose ) {
|
||||
mButtonClose->ForceThemeSkin( Theme, "winclose" );
|
||||
mButtonClose->Size( mButtonClose->GetSkinShapeSize() );
|
||||
}
|
||||
|
||||
if ( NULL != mButtonMaximize ) {
|
||||
mButtonMaximize->ForceThemeSkin( Theme, "winmax" );
|
||||
mButtonMaximize->Size( mButtonMaximize->GetSkinShapeSize() );
|
||||
}
|
||||
|
||||
if ( NULL != mButtonMinimize ) {
|
||||
mButtonMinimize->ForceThemeSkin( Theme, "winmin" );
|
||||
mButtonMinimize->Size( mButtonMinimize->GetSkinShapeSize() );
|
||||
}
|
||||
|
||||
FixChildsSize();
|
||||
}
|
||||
|
||||
void cUIWindow::OnSizeChange() {
|
||||
if ( ( 0 != mMinWindowSize.x && 0 != mMinWindowSize.y ) && ( mSize.x < mMinWindowSize.x || mSize.y < mMinWindowSize.y ) ) {
|
||||
Size( mMinWindowSize );
|
||||
} else {
|
||||
FixChildsSize();
|
||||
|
||||
cUIComplexControl::OnSizeChange();
|
||||
}
|
||||
}
|
||||
|
||||
void cUIWindow::Size( const eeSize& Size ) {
|
||||
eeSize size = Size;
|
||||
|
||||
size.x += mBorderLeft->Size().Width() + mBorderRight->Size().Width();
|
||||
size.y += mWindowDecoration->Size().Height() + mBorderBottom->Size().Height();
|
||||
|
||||
cUIControl::Size( size );
|
||||
}
|
||||
|
||||
void cUIWindow::FixChildsSize() {
|
||||
if ( mDecoAutoSize ) {
|
||||
mDecoSize = eeSize( mSize.Width(), mWindowDecoration->GetSkinShapeSize().Height() );
|
||||
}
|
||||
|
||||
mWindowDecoration->Size( mDecoSize );
|
||||
|
||||
if ( mBorderAutoSize ) {
|
||||
mBorderBottom->Size( mSize.Width(), mBorderBottom->GetSkinShapeSize().Height() );
|
||||
} else {
|
||||
mBorderBottom->Size( mSize.Width(), mBorderSize.Height() );
|
||||
}
|
||||
|
||||
Uint32 BorderHeight = mSize.Height() - mDecoSize.Height() - mBorderBottom->Size().Height();
|
||||
|
||||
if ( mBorderAutoSize ) {
|
||||
mBorderLeft->Size( mBorderLeft->GetSkinShapeSize().Width() , BorderHeight );
|
||||
mBorderRight->Size( mBorderRight->GetSkinShapeSize().Width(), BorderHeight );
|
||||
} else {
|
||||
mBorderLeft->Size( mBorderSize.Width(), BorderHeight );
|
||||
mBorderRight->Size( mBorderSize.Width(), BorderHeight );
|
||||
}
|
||||
|
||||
mBorderLeft->Pos( 0, mWindowDecoration->Size().Height() );
|
||||
mBorderRight->Pos( mSize.Width() - mBorderRight->Size().Width(), mWindowDecoration->Size().Height() );
|
||||
mBorderBottom->Pos( 0, mSize.Height() - mBorderBottom->Size().Height() );
|
||||
|
||||
mContainer->Pos( mBorderLeft->Size().Width(), mWindowDecoration->Size().Height() );
|
||||
mContainer->Size( mSize.Width() - mBorderLeft->Size().Width() - mBorderRight->Size().Width(), mSize.Height() - mWindowDecoration->Size().Height() - mBorderBottom->Size().Height() );
|
||||
|
||||
Uint32 yPos;
|
||||
|
||||
if ( NULL != mButtonClose ) {
|
||||
yPos = mWindowDecoration->Size().Height() / 2 - mButtonClose->Size().Height() / 2 + mButtonsPositionFixer.y;
|
||||
|
||||
mButtonClose->Pos( mWindowDecoration->Size().Width() - mBorderRight->Size().Width() - mButtonClose->Size().Width() + mButtonsPositionFixer.x, yPos );
|
||||
}
|
||||
|
||||
if ( NULL != mButtonMaximize ) {
|
||||
yPos = mWindowDecoration->Size().Height() / 2 - mButtonMaximize->Size().Height() / 2 + mButtonsPositionFixer.y;
|
||||
|
||||
if ( NULL != mButtonClose ) {
|
||||
mButtonMaximize->Pos( mButtonClose->Pos().x - mButtonsSeparation - mButtonMaximize->Size().Width(), yPos );
|
||||
} else {
|
||||
mButtonMaximize->Pos( mWindowDecoration->Size().Width() - mBorderRight->Size().Width() - mButtonMaximize->Size().Width() + mButtonsPositionFixer.x, yPos );
|
||||
}
|
||||
}
|
||||
|
||||
if ( NULL != mButtonMinimize ) {
|
||||
yPos = mWindowDecoration->Size().Height() / 2 - mButtonMinimize->Size().Height() / 2 + mButtonsPositionFixer.y;
|
||||
|
||||
if ( NULL != mButtonMaximize ) {
|
||||
mButtonMinimize->Pos( mButtonMaximize->Pos().x - mButtonsSeparation - mButtonMinimize->Size().Width(), yPos );
|
||||
} else {
|
||||
if ( NULL != mButtonClose ) {
|
||||
mButtonMinimize->Pos( mButtonClose->Pos().x - mButtonsSeparation - mButtonMinimize->Size().Width(), yPos );
|
||||
} else {
|
||||
mButtonMinimize->Pos( mWindowDecoration->Size().Width() - mBorderRight->Size().Width() - mButtonMinimize->Size().Width() + mButtonsPositionFixer.x, yPos );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 cUIWindow::OnMessage( const cUIMessage * Msg ) {
|
||||
switch ( Msg->Msg() ) {
|
||||
case cUIMessage::MsgFocus:
|
||||
{
|
||||
ToFront();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return cUIComplexControl::OnMessage( Msg );
|
||||
}
|
||||
|
||||
cUIControlAnim * cUIWindow::Container() const {
|
||||
return mContainer;
|
||||
}
|
||||
|
||||
cUIComplexControl * cUIWindow::ButtonClose() const {
|
||||
return mButtonClose;
|
||||
}
|
||||
|
||||
cUIComplexControl * cUIWindow::ButtonMaximize() const {
|
||||
return mButtonMaximize;
|
||||
}
|
||||
|
||||
cUIComplexControl * cUIWindow::ButtonMinimize() const {
|
||||
return mButtonMinimize;
|
||||
}
|
||||
|
||||
bool cUIWindow::Show() {
|
||||
if ( !Visible() ) {
|
||||
Enabled( true );
|
||||
Visible( true );
|
||||
|
||||
if ( 255.f == Alpha() ) {
|
||||
StartAlphaAnim( 0.f, 255.f, cUIThemeManager::instance()->ControlsFadeInTime() );
|
||||
} else {
|
||||
CreateFadeIn( cUIThemeManager::instance()->ControlsFadeInTime() );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cUIWindow::Hide() {
|
||||
if ( Visible() ) {
|
||||
if ( cUIThemeManager::instance()->DefaultEffectsEnabled() ) {
|
||||
DisableFadeOut( cUIThemeManager::instance()->ControlsFadeOutTime() );
|
||||
} else {
|
||||
Enabled( false );
|
||||
Visible( false );
|
||||
}
|
||||
|
||||
cUIManager::instance()->MainControl()->SetFocus();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}}
|
||||
103
src/ui/cuiwindow.hpp
Normal file
103
src/ui/cuiwindow.hpp
Normal file
@@ -0,0 +1,103 @@
|
||||
#ifndef EE_UICUIWINDOW_HPP
|
||||
#define EE_UICUIWINDOW_HPP
|
||||
|
||||
#include "cuicomplexcontrol.hpp"
|
||||
#include "cuipushbutton.hpp"
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
class cUIWindow : public cUIComplexControl {
|
||||
public:
|
||||
enum UIWindowFlags {
|
||||
UI_WIN_NO_BORDER = ( 1 << 0 ),
|
||||
UI_WIN_CLOSE_BUTTON = ( 1 << 1 ),
|
||||
UI_WIN_MINIMIZE_BUTTON = ( 1 << 2 ),
|
||||
UI_WIN_MAXIMIZE_BUTTON = ( 1 << 3 ),
|
||||
UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS = ( 1 << 4 ),
|
||||
UI_WIN_RESIZEABLE = ( 1 << 5 ),
|
||||
UI_WIN_DRAGABLE_CONTAINER = ( 1 << 6 )
|
||||
};
|
||||
|
||||
class CreateParams : public cUIComplexControl::CreateParams {
|
||||
public:
|
||||
inline CreateParams() :
|
||||
cUIComplexControl::CreateParams(),
|
||||
WinFlags( UI_WIN_CLOSE_BUTTON | UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS | UI_WIN_RESIZEABLE ),
|
||||
ButtonsSeparation( 4 ),
|
||||
DecorationAutoSize( true ),
|
||||
BorderAutoSize( true )
|
||||
{
|
||||
}
|
||||
|
||||
inline ~CreateParams() {};
|
||||
|
||||
Uint32 WinFlags;
|
||||
eeSize DecorationSize;
|
||||
eeSize BorderSize;
|
||||
eeSize MinWindowSize;
|
||||
eeVector2i ButtonsPositionFixer;
|
||||
Uint32 ButtonsSeparation;
|
||||
bool DecorationAutoSize;
|
||||
bool BorderAutoSize;
|
||||
};
|
||||
|
||||
cUIWindow( const cUIWindow::CreateParams& Params );
|
||||
|
||||
~cUIWindow();
|
||||
|
||||
virtual void Size( const eeSize& Size );
|
||||
|
||||
virtual void SetTheme( cUITheme * Theme );
|
||||
|
||||
virtual Uint32 OnMessage( const cUIMessage *Msg );
|
||||
|
||||
cUIControlAnim * Container() const;
|
||||
|
||||
cUIComplexControl * ButtonClose() const;
|
||||
|
||||
cUIComplexControl * ButtonMaximize() const;
|
||||
|
||||
cUIComplexControl * ButtonMinimize() const;
|
||||
|
||||
virtual bool Show();
|
||||
|
||||
virtual bool Hide();
|
||||
protected:
|
||||
Uint32 mWinFlags;
|
||||
|
||||
cUIControlAnim * mWindowDecoration;
|
||||
cUIControlAnim * mBorderLeft;
|
||||
cUIControlAnim * mBorderRight;
|
||||
cUIControlAnim * mBorderBottom;
|
||||
cUIControlAnim * mContainer;
|
||||
|
||||
cUIComplexControl * mButtonClose;
|
||||
cUIComplexControl * mButtonMinimize;
|
||||
cUIComplexControl * mButtonMaximize;
|
||||
|
||||
eeSize mDecoSize;
|
||||
eeSize mBorderSize;
|
||||
eeSize mMinWindowSize;
|
||||
eeVector2i mNonMaxPos;
|
||||
eeSize mNonMaxSize;
|
||||
eeVector2i mButtonsPositionFixer;
|
||||
Uint32 mButtonsSeparation;
|
||||
bool mDecoAutoSize;
|
||||
bool mBorderAutoSize;
|
||||
|
||||
virtual void OnSizeChange();
|
||||
|
||||
void ButtonCloseClick( const cUIEvent * Event );
|
||||
|
||||
void ButtonMaximizeClick( const cUIEvent * Event );
|
||||
|
||||
void ButtonMinimizeClick( const cUIEvent * Event );
|
||||
|
||||
void ContainerPosChange( const cUIEvent * Event );
|
||||
|
||||
void FixChildsSize();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -43,22 +43,27 @@ enum UI_CONTROL_FLAGS_VALUES {
|
||||
#define UI_VALIGN_MASK FONT_DRAW_VALIGN_MASK
|
||||
|
||||
enum UI_FLAGS {
|
||||
UI_HALIGN_RIGHT = FONT_DRAW_RIGHT,
|
||||
UI_HALIGN_CENTER = FONT_DRAW_CENTER,
|
||||
UI_VALIGN_BOTTOM = FONT_DRAW_BOTTOM,
|
||||
UI_VALIGN_CENTER = FONT_DRAW_MIDDLE,
|
||||
UI_TEXT_DRAW_SHADOW = FONT_DRAW_SHADOW,
|
||||
UI_AUTO_SIZE = (1 << 6),
|
||||
UI_INGORE_FOCUS = (1 << 7),
|
||||
UI_FILL_BACKGROUND = (1 << 8),
|
||||
UI_BORDER = (1 << 9),
|
||||
UI_TAB_STOP = (1 << 10),
|
||||
UI_FIT_TO_CONTROL = (1 << 11),
|
||||
UI_CLIP_ENABLE = (1 << 12),
|
||||
UI_AUTO_SHRINK_TEXT = (1 << 13),
|
||||
UI_MULTI_SELECT = (1 << 14),
|
||||
UI_AUTO_PADDING = (1 << 15),
|
||||
UI_DRAG_ENABLE = (1 << 16)
|
||||
UI_HALIGN_RIGHT = FONT_DRAW_RIGHT,
|
||||
UI_HALIGN_CENTER = FONT_DRAW_CENTER,
|
||||
UI_VALIGN_BOTTOM = FONT_DRAW_BOTTOM,
|
||||
UI_VALIGN_CENTER = FONT_DRAW_MIDDLE,
|
||||
UI_DRAW_SHADOW = FONT_DRAW_SHADOW,
|
||||
UI_AUTO_SIZE = (1 << 6),
|
||||
UI_INGORE_FOCUS = (1 << 7),
|
||||
UI_FILL_BACKGROUND = (1 << 8),
|
||||
UI_BORDER = (1 << 9),
|
||||
UI_TAB_STOP = (1 << 10),
|
||||
UI_FIT_TO_CONTROL = (1 << 11),
|
||||
UI_CLIP_ENABLE = (1 << 12),
|
||||
UI_AUTO_SHRINK_TEXT = (1 << 13),
|
||||
UI_MULTI_SELECT = (1 << 14),
|
||||
UI_AUTO_PADDING = (1 << 15),
|
||||
UI_DRAG_ENABLE = (1 << 16),
|
||||
UI_REPORT_SIZE_CHANGE_TO_CHILDS = (1 << 17),
|
||||
UI_ANCHOR_TOP = (1 << 18),
|
||||
UI_ANCHOR_BOTTOM = (1 << 19),
|
||||
UI_ANCHOR_LEFT = (1 << 20),
|
||||
UI_ANCHOR_RIGHT = (1 << 21)
|
||||
};
|
||||
|
||||
enum UI_CONTROL_TYPES {
|
||||
@@ -86,7 +91,8 @@ enum UI_CONTROL_TYPES {
|
||||
UI_TYPE_SPRITE = 21,
|
||||
UI_TYPE_TEXTEDIT = 22,
|
||||
UI_TYPE_TOOLTIP = 23,
|
||||
UI_TYPE_GENERICGRID = 24
|
||||
UI_TYPE_GENERICGRID = 24,
|
||||
UI_TYPE_WINDOW = 25
|
||||
};
|
||||
|
||||
#define UI_TYPE_GET(X) ( 1 << (X) )
|
||||
|
||||
@@ -2,20 +2,36 @@
|
||||
#define EE_WINDOW_BASE
|
||||
|
||||
#include "../base.hpp"
|
||||
|
||||
#include <SDL/SDL_syswm.h>
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN
|
||||
inline BOOL WIN_ShowWindow( HWND hWnd, int nCmdShow ) {
|
||||
return ShowWindow( hWnd, nCmdShow );
|
||||
}
|
||||
|
||||
#include "../helper/glew/wglew.h"
|
||||
|
||||
typedef HGLRC eeWindowContex;
|
||||
typedef HWND eeWindowHandler;
|
||||
typedef UINT eeScrapType;
|
||||
|
||||
#elif EE_PLATFORM == EE_PLATFORM_LINUX
|
||||
|
||||
#include "../helper/glew/glxew.h"
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
typedef Window X11Window;
|
||||
|
||||
typedef GLXContext eeWindowContex;
|
||||
typedef Display * eeWindowHandler;
|
||||
typedef Atom eeScrapType;
|
||||
|
||||
#elif EE_PLATFORM == EE_PLATFORM_MACOSX
|
||||
//#include <AGL/agl.h>
|
||||
#endif
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_LINUX
|
||||
#include <X11/Xlib.h>
|
||||
typedef Window X11Window;
|
||||
//typedef AGLContext eeWindowContex;
|
||||
//typedef NSWindow * eeWindowHandler;
|
||||
typedef Uint32 eeScrapType;
|
||||
#endif
|
||||
|
||||
#include "../utils/colors.hpp"
|
||||
|
||||
@@ -29,7 +29,7 @@ static int clipboard_filter(const SDL_Event *event) {
|
||||
return(1);
|
||||
}
|
||||
|
||||
Display* SDL_Display = cEngine::instance()->GetVideoInfo()->info.info.x11.display;
|
||||
Display* curDisplay = cEngine::instance()->GetWindowHandler();
|
||||
|
||||
/* Handle window-manager specific clipboard events */
|
||||
switch ( event->syswm.msg->event.xevent.type ) {
|
||||
@@ -51,19 +51,19 @@ static int clipboard_filter(const SDL_Event *event) {
|
||||
sevent.xselection.requestor = req->requestor;
|
||||
sevent.xselection.time = req->time;
|
||||
|
||||
if ( XGetWindowProperty(SDL_Display, DefaultRootWindow(SDL_Display), XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target, &sevent.xselection.target, &seln_format, &nbytes, &overflow, &seln_data) == Success ) {
|
||||
if ( XGetWindowProperty(curDisplay, DefaultRootWindow(curDisplay), XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target, &sevent.xselection.target, &seln_format, &nbytes, &overflow, &seln_data) == Success ) {
|
||||
if ( sevent.xselection.target == req->target ) {
|
||||
if ( sevent.xselection.target == XA_STRING ) {
|
||||
if ( seln_data[nbytes-1] == '\0' )
|
||||
--nbytes;
|
||||
}
|
||||
XChangeProperty(SDL_Display, req->requestor, req->property, sevent.xselection.target, seln_format, PropModeReplace, seln_data, nbytes);
|
||||
XChangeProperty(curDisplay, req->requestor, req->property, sevent.xselection.target, seln_format, PropModeReplace, seln_data, nbytes);
|
||||
sevent.xselection.property = req->property;
|
||||
}
|
||||
XFree(seln_data);
|
||||
}
|
||||
XSendEvent(SDL_Display,req->requestor, False, 0, &sevent);
|
||||
XSync(SDL_Display, False);
|
||||
XSendEvent(curDisplay,req->requestor, False, 0, &sevent);
|
||||
XSync(curDisplay, False);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -126,20 +126,19 @@ cEngine::~cEngine() {
|
||||
|
||||
bool cEngine::Init(const Uint32& Width, const Uint32& Height, const Uint8& BitColor, const bool& Windowed, const bool& Resizeable, const bool& VSync, const bool& DoubleBuffering, const bool& UseDesktopResolution, const bool& NoFrame ) {
|
||||
try {
|
||||
mInit = false;
|
||||
mInit = false;
|
||||
|
||||
mVideoInfo.Width = Width;
|
||||
mVideoInfo.Height = Height;
|
||||
mVideoInfo.ColorDepth = BitColor;
|
||||
mVideoInfo.Windowed = Windowed;
|
||||
mVideoInfo.Resizeable = Resizeable;
|
||||
mVideoInfo.DoubleBuffering = DoubleBuffering;
|
||||
mVideoInfo.VSync = VSync;
|
||||
mVideoInfo.NoFrame = NoFrame;
|
||||
mVideoInfo.LineSmooth = true;
|
||||
mOldWinPos = eeVector2i( 0, 0 );
|
||||
|
||||
if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) {
|
||||
mVideoInfo.Width = Width;
|
||||
mVideoInfo.Height = Height;
|
||||
mVideoInfo.ColorDepth = BitColor;
|
||||
mVideoInfo.Windowed = Windowed;
|
||||
mVideoInfo.Resizeable = Resizeable;
|
||||
mVideoInfo.DoubleBuffering = DoubleBuffering;
|
||||
mVideoInfo.VSync = VSync;
|
||||
mVideoInfo.NoFrame = NoFrame;
|
||||
mVideoInfo.LineSmooth = true;
|
||||
|
||||
if ( SDL_Init( SDL_INIT_VIDEO ) != 0 ) {
|
||||
cLog::instance()->Write( "Unable to initialize SDL: " + std::string( SDL_GetError() ) );
|
||||
return false;
|
||||
}
|
||||
@@ -151,51 +150,42 @@ bool cEngine::Init(const Uint32& Width, const Uint32& Height, const Uint8& BitCo
|
||||
}
|
||||
|
||||
mVideoInfo.Flags = SDL_OPENGL | SDL_HWPALETTE;
|
||||
|
||||
const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo();
|
||||
|
||||
mVideoInfo.DeskWidth = videoInfo->current_w;
|
||||
mVideoInfo.DeskHeight = videoInfo->current_h;
|
||||
mVideoInfo.DeskWidth = videoInfo->current_w;
|
||||
mVideoInfo.DeskHeight = videoInfo->current_h;
|
||||
|
||||
if ( UseDesktopResolution ) {
|
||||
mVideoInfo.Width = mVideoInfo.DeskWidth;
|
||||
mVideoInfo.Height = mVideoInfo.DeskHeight;
|
||||
mVideoInfo.Width = mVideoInfo.DeskWidth;
|
||||
mVideoInfo.Height = mVideoInfo.DeskHeight;
|
||||
}
|
||||
|
||||
if (videoInfo->hw_available)
|
||||
mVideoInfo.Flags |= SDL_HWSURFACE;
|
||||
else
|
||||
mVideoInfo.Flags |= SDL_SWSURFACE;
|
||||
|
||||
if ( videoInfo->blit_hw ) // This checks if hardware blits can be done
|
||||
mVideoInfo.Flags |= SDL_HWACCEL;
|
||||
|
||||
if ( mVideoInfo.Resizeable )
|
||||
mVideoInfo.Flags |= SDL_RESIZABLE;
|
||||
|
||||
if ( mVideoInfo.NoFrame )
|
||||
mVideoInfo.Flags |= SDL_NOFRAME;
|
||||
|
||||
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); // Depth
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, (mVideoInfo.DoubleBuffering ? 1 : 0) ); // Double Buffering
|
||||
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); // Depth
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, ( mVideoInfo.DoubleBuffering ? 1 : 0 ) ); // Double Buffering
|
||||
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 1 );
|
||||
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, (mVideoInfo.VSync ? 1 : 0) ); // VSync
|
||||
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, ( mVideoInfo.VSync ? 1 : 0 ) ); // VSync
|
||||
|
||||
Uint32 mTmpFlags = mVideoInfo.Flags;
|
||||
if (!mVideoInfo.Windowed)
|
||||
|
||||
if ( !mVideoInfo.Windowed )
|
||||
mTmpFlags |= SDL_FULLSCREEN;
|
||||
|
||||
if ( SDL_VideoModeOK(mVideoInfo.Width, mVideoInfo.Height, mVideoInfo.ColorDepth, mTmpFlags) )
|
||||
mVideoInfo.Screen = SDL_SetVideoMode(mVideoInfo.Width, mVideoInfo.Height, mVideoInfo.ColorDepth, mTmpFlags);
|
||||
else {
|
||||
if ( SDL_VideoModeOK(mVideoInfo.Width, mVideoInfo.Height, mVideoInfo.ColorDepth, mTmpFlags ) ) {
|
||||
mVideoInfo.Screen = SDL_SetVideoMode(mVideoInfo.Width, mVideoInfo.Height, mVideoInfo.ColorDepth, mTmpFlags );
|
||||
} else {
|
||||
cLog::instance()->Write( "Video Mode Unsopported for this videocard: " );
|
||||
return false;
|
||||
}
|
||||
|
||||
mInitialWidth = mVideoInfo.Width;
|
||||
mInitialHeight = mVideoInfo.Height;
|
||||
|
||||
mVideoInfo.WWidth = mVideoInfo.Width;
|
||||
mVideoInfo.WHeight = mVideoInfo.Height;
|
||||
mVideoInfo.WWidth = mVideoInfo.Width;
|
||||
mVideoInfo.WHeight = mVideoInfo.Height;
|
||||
|
||||
mVideoInfo.Maximized = false;
|
||||
|
||||
@@ -214,24 +204,19 @@ bool cEngine::Init(const Uint32& Width, const Uint32& Height, const Uint8& BitCo
|
||||
#endif
|
||||
|
||||
if ( mVideoInfo.ColorDepth == 16 ) {
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE , 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE , 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE , 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE , 4);
|
||||
} else {
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE , 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE , 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE , 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE , 8);
|
||||
}
|
||||
|
||||
if ( mVideoInfo.Windowed )
|
||||
mOldWinPos = GetWindowPosition();
|
||||
|
||||
cGL::instance()->Init();
|
||||
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
|
||||
|
||||
GetMainContext();
|
||||
|
||||
mDefaultView.SetView( 0, 0, mVideoInfo.Width, mVideoInfo.Height );
|
||||
@@ -279,9 +264,6 @@ const cView& cEngine::GetView() const {
|
||||
}
|
||||
|
||||
void cEngine::Setup2D( const bool& KeepView ) {
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
|
||||
SetBackColor( mBackColor );
|
||||
|
||||
glShadeModel( GL_SMOOTH );
|
||||
@@ -342,10 +324,13 @@ void cEngine::Display() {
|
||||
SetView( *mCurrentView );
|
||||
|
||||
SDL_GL_SwapBuffers();
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
|
||||
|
||||
GetElapsedTime();
|
||||
|
||||
CalculateFps();
|
||||
|
||||
LimitFps();
|
||||
}
|
||||
|
||||
@@ -375,9 +360,9 @@ void cEngine::ChangeRes( const Uint16& width, const Uint16& height, const bool&
|
||||
|
||||
mDefaultView.SetView( 0, 0, mVideoInfo.Width, mVideoInfo.Height );
|
||||
|
||||
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); // Depth
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, (mVideoInfo.DoubleBuffering ? 1 : 0) );
|
||||
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, (mVideoInfo.VSync ? 1 : 0) ); // VSync
|
||||
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); // Depth
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, ( mVideoInfo.DoubleBuffering ? 1 : 0 ) ); // Double Buffering
|
||||
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, ( mVideoInfo.VSync ? 1 : 0 ) ); // VSync
|
||||
|
||||
if (Windowed)
|
||||
mVideoInfo.Screen = SDL_SetVideoMode( mVideoInfo.Width, mVideoInfo.Height, mVideoInfo.ColorDepth, mVideoInfo.Flags );
|
||||
@@ -966,12 +951,14 @@ void cEngine::clipboard_get_scrap(int type, int *dstlen, char **dst) {
|
||||
|
||||
std::string cEngine::GetClipboardText() {
|
||||
std::string tStr;
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_LINUX || EE_PLATFORM == EE_PLATFORM_WIN
|
||||
char *scrap = NULL;
|
||||
int scraplen;
|
||||
|
||||
clipboard_get_scrap(T('T','E','X','T'), &scraplen, &scrap);
|
||||
if ( scraplen != 0 && strcmp(scrap,"SDL-\r-scrap") ) {
|
||||
clipboard_get_scrap( T('T','E','X','T'), &scraplen, &scrap );
|
||||
|
||||
if ( scraplen != 0 && strcmp( scrap, "SDL-\r-scrap") ) {
|
||||
char *cp;
|
||||
int i;
|
||||
|
||||
@@ -993,12 +980,14 @@ std::string cEngine::GetClipboardText() {
|
||||
|
||||
std::wstring cEngine::GetClipboardTextWStr() {
|
||||
std::wstring tStr;
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_LINUX || EE_PLATFORM == EE_PLATFORM_WIN
|
||||
char * scrap = NULL;
|
||||
int scraplen;
|
||||
|
||||
clipboard_get_scrap(T('T','E','X','T'), &scraplen, &scrap);
|
||||
if ( scraplen != 0 && strcmp(scrap,"SDL-\r-scrap") ) {
|
||||
clipboard_get_scrap( T('T','E','X','T'), &scraplen, &scrap );
|
||||
|
||||
if ( scraplen != 0 && strcmp( scrap, "SDL-\r-scrap" ) ) {
|
||||
tStr.resize( scraplen-1, L' ' );
|
||||
|
||||
char *cp;
|
||||
@@ -1021,37 +1010,25 @@ std::wstring cEngine::GetClipboardTextWStr() {
|
||||
return tStr;
|
||||
}
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN
|
||||
void cEngine::SetCurrentContext( HGLRC Context ) {
|
||||
void cEngine::SetCurrentContext( eeWindowContex Context ) {
|
||||
if ( mInit ) {
|
||||
wglMakeCurrent( GetDC( mVideoInfo.info.window ), Context );
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN
|
||||
wglMakeCurrent( GetDC( mVideoInfo.info.window ), Context );
|
||||
#elif EE_PLATFORM == EE_PLATFORM_LINUX
|
||||
mVideoInfo.info.info.x11.lock_func();
|
||||
glXMakeCurrent( mVideoInfo.info.info.x11.display, mVideoInfo.info.info.x11.window, Context );
|
||||
mVideoInfo.info.info.x11.unlock_func();
|
||||
#elif EE_PLATFORM == EE_PLATFORM_MACOSX
|
||||
//aglSetCurrentContext( Context );
|
||||
#else
|
||||
#warning No context supported on this platform
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
HGLRC cEngine::GetContext() const {
|
||||
eeWindowContex cEngine::GetContext() const {
|
||||
return mContext;
|
||||
}
|
||||
#elif EE_PLATFORM == EE_PLATFORM_LINUX
|
||||
void cEngine::SetCurrentContext( GLXContext Context ) {
|
||||
if ( mInit ) {
|
||||
mVideoInfo.info.info.x11.lock_func();
|
||||
glXMakeCurrent( mVideoInfo.info.info.x11.display, mVideoInfo.info.info.x11.window, Context );
|
||||
mVideoInfo.info.info.x11.unlock_func();
|
||||
}
|
||||
}
|
||||
|
||||
GLXContext cEngine::GetContext() const {
|
||||
return mContext;
|
||||
}
|
||||
#elif EE_PLATFORM == EE_PLATFORM_MACOSX
|
||||
/*void cEngine::SetCurrentContext( AGLContext Context ) {
|
||||
aglSetCurrentContext( Context );
|
||||
}
|
||||
|
||||
AGLContext cEngine::GetContext() const {
|
||||
return mContext;
|
||||
}*/
|
||||
#endif
|
||||
|
||||
void cEngine::GetMainContext() {
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN
|
||||
@@ -1063,6 +1040,16 @@ void cEngine::GetMainContext() {
|
||||
#endif
|
||||
}
|
||||
|
||||
eeWindowHandler cEngine::GetWindowHandler() {
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN
|
||||
return mVideoInfo.info.window;
|
||||
#elif EE_PLATFORM == EE_PLATFORM_LINUX
|
||||
return mVideoInfo.info.info.x11.display;
|
||||
#elif EE_PLATFORM == EE_PLATFORM_MACOSX
|
||||
//return mVideoInfo.info.cocoa.window;
|
||||
#endif
|
||||
}
|
||||
|
||||
void cEngine::SetDefaultContext() {
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_LINUX
|
||||
SetCurrentContext( mContext );
|
||||
|
||||
@@ -6,20 +6,6 @@
|
||||
|
||||
namespace EE { namespace Window {
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_LINUX
|
||||
typedef Atom eeScrapType;
|
||||
#elif EE_PLATFORM == EE_PLATFORM_WIN
|
||||
typedef UINT eeScrapType;
|
||||
#else
|
||||
typedef Uint32 eeScrapType;
|
||||
#endif
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN
|
||||
inline BOOL WIN_ShowWindow( HWND hWnd, int nCmdShow ) {
|
||||
return ShowWindow( hWnd, nCmdShow );
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @brief The basic Graphics class. Here Init the context and render to screen. (Singleton Class). */
|
||||
class EE_API cEngine : public tSingleton<cEngine> {
|
||||
friend class tSingleton<cEngine>;
|
||||
@@ -234,15 +220,12 @@ class EE_API cEngine : public tSingleton<cEngine> {
|
||||
/** Set the size of the window for a windowed window */
|
||||
void SetWindowSize( const Uint32& Width, const Uint32& Height );
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN
|
||||
void SetCurrentContext( HGLRC Context );
|
||||
HGLRC GetContext() const;
|
||||
#elif EE_PLATFORM == EE_PLATFORM_LINUX
|
||||
void SetCurrentContext( GLXContext Context );
|
||||
GLXContext GetContext() const;
|
||||
#elif EE_PLATFORM == EE_PLATFORM_MACOSX
|
||||
//void SetCurrentContext( AGLContext Context );
|
||||
//AGLContext GetContext() const;
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_LINUX
|
||||
void SetCurrentContext( eeWindowContex Context );
|
||||
|
||||
eeWindowContex GetContext() const;
|
||||
|
||||
eeWindowHandler GetWindowHandler();
|
||||
#endif
|
||||
|
||||
void SetDefaultContext();
|
||||
@@ -256,8 +239,6 @@ class EE_API cEngine : public tSingleton<cEngine> {
|
||||
eeColor mBackColor;
|
||||
SDL_Cursor * mCursor;
|
||||
bool mShowCursor;
|
||||
eeVector2i mOldWinPos;
|
||||
|
||||
struct _Frames {
|
||||
struct _FPS {
|
||||
Uint32 LastCheck;
|
||||
@@ -270,24 +251,19 @@ class EE_API cEngine : public tSingleton<cEngine> {
|
||||
eeFloat ElapsedTime;
|
||||
} mFrames;
|
||||
|
||||
Uint32 mInitialWidth;
|
||||
Uint32 mInitialHeight;
|
||||
|
||||
cView mDefaultView;
|
||||
const cView * mCurrentView;
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN
|
||||
HGLRC mContext;
|
||||
#elif EE_PLATFORM == EE_PLATFORM_LINUX
|
||||
GLXContext mContext;
|
||||
#elif EE_PLATFORM == EE_PLATFORM_MACOSX
|
||||
//AGLContext mContext;
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_LINUX
|
||||
eeWindowContex mContext;
|
||||
#endif
|
||||
|
||||
std::string mIcon;
|
||||
|
||||
void CalculateFps();
|
||||
|
||||
void LimitFps();
|
||||
|
||||
void GetElapsedTime();
|
||||
|
||||
SDL_Cursor * CreateCursor( const Uint32& TexId, const eeVector2i& HotSpot );
|
||||
|
||||
Reference in New Issue
Block a user