diff --git a/saco/d3d9/common/DXUTgui.cpp b/saco/d3d9/common/DXUTgui.cpp new file mode 100644 index 0000000..aa6566d --- /dev/null +++ b/saco/d3d9/common/DXUTgui.cpp @@ -0,0 +1,35 @@ +//-------------------------------------------------------------------------------------- +// File: DXUTgui.cpp +// +// Desc: +// +// Copyright (c) Microsoft Corporation. All rights reserved. +//-------------------------------------------------------------------------------------- +#include "dxstdafx.h" +#include "DXUTgui.h" +#undef min // use __min instead +#undef max // use __max instead + +//-------------------------------------------------------------------------------------- +void DXUTBlendColor::Init( D3DCOLOR defaultColor, D3DCOLOR disabledColor, D3DCOLOR hiddenColor ) +{ + for( int i=0; i < MAX_CONTROL_STATES; i++ ) + { + States[ i ] = defaultColor; + } + + States[ DXUT_STATE_DISABLED ] = disabledColor; + States[ DXUT_STATE_HIDDEN ] = hiddenColor; + Current = hiddenColor; +} + + +//-------------------------------------------------------------------------------------- +void DXUTBlendColor::Blend( UINT iState, float fElapsedTime, float fRate ) +{ + D3DXCOLOR destColor = States[ iState ]; + D3DXColorLerp( &Current, &Current, &destColor, 1.0f - powf( fRate, 30 * fElapsedTime ) ); +} + + + diff --git a/saco/d3d9/common/DXUTgui.h b/saco/d3d9/common/DXUTgui.h new file mode 100644 index 0000000..203afb8 --- /dev/null +++ b/saco/d3d9/common/DXUTgui.h @@ -0,0 +1,38 @@ +//-------------------------------------------------------------------------------------- +// File: DXUTgui.h +// +// Desc: +// +// Copyright (c) Microsoft Corporation. All rights reserved. +//-------------------------------------------------------------------------------------- +#pragma once +#ifndef DXUT_GUI_H +#define DXUT_GUI_H + + +//-------------------------------------------------------------------------------------- +// Enums for pre-defined control types +//-------------------------------------------------------------------------------------- +enum DXUT_CONTROL_STATE +{ + DXUT_STATE_NORMAL = 0, + DXUT_STATE_DISABLED, + DXUT_STATE_HIDDEN, + DXUT_STATE_FOCUS, + DXUT_STATE_MOUSEOVER, + DXUT_STATE_PRESSED, +}; + +#define MAX_CONTROL_STATES 6 + +struct DXUTBlendColor +{ + void Init( D3DCOLOR defaultColor, D3DCOLOR disabledColor = D3DCOLOR_ARGB(200, 128, 128, 128), D3DCOLOR hiddenColor = 0 ); + void Blend( UINT iState, float fElapsedTime, float fRate = 0.7f ); + + D3DCOLOR States[ MAX_CONTROL_STATES ]; // Modulate colors for all possible control states + D3DXCOLOR Current; +}; + + +#endif // DXUT_GUI_H \ No newline at end of file diff --git a/saco/d3d9/common/dxstdafx.h b/saco/d3d9/common/dxstdafx.h index 46d56c8..37a7af4 100644 --- a/saco/d3d9/common/dxstdafx.h +++ b/saco/d3d9/common/dxstdafx.h @@ -31,5 +31,6 @@ #include #include "DXUTmisc.h" +#include "DXUTgui.h" #endif // !defined(DXSDK_STDAFX_H)