00001
00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024
00025
00026 #include "std_afx.h"
00027 #include "blend_wnd.h"
00028 #include <nel/misc/common.h>
00029 #include <nel/3d/animation_playlist.h>
00030
00031 using namespace NL3D;
00032 using namespace NLMISC;
00033
00034 #define COLOR_BLEND_ENABLE (RGB(192, 43, 223))
00035 #define COLOR_BLEND_DISABLE (RGB(140, 113, 142))
00036 #define SEGMENT_COUNT 10
00037
00038
00039
00040 CBlendWnd::CBlendWnd()
00041 {
00042 }
00043
00044
00045
00046 void CBlendWnd::MakePoint (const RECT& src, POINT& dst, float x, float y)
00047 {
00048 float widthClient=(float)src.right-(float)src.left;
00049 float heightClient=(float)src.bottom-(float)src.top;
00050 dst.x=src.left+(int)(widthClient*x);
00051 dst.y=src.top+(int)(heightClient*y);
00052 }
00053
00054
00055
00056 void CBlendWnd::MakeRect (const RECT& src, RECT& dst, float x, float y, float width, float height)
00057 {
00058 float widthClient=(float)src.right-(float)src.left;
00059 float heightClient=(float)src.bottom-(float)src.top;
00060 dst.left=src.left+(int)(widthClient*x);
00061 dst.top=src.top+(int)(heightClient*y);
00062 dst.right=src.left+(int)(widthClient*(x+width));
00063 dst.bottom=src.top+(int)(heightClient*(y+height));
00064 }
00065
00066
00067
00068 void CBlendWnd::OnPaint (const RECT& client, CDC* pDc, float StartBlend, float EndBlend, float StartBlendTime, float EndBlendTime,
00069 float Smoothness, float StartTime, float EndTime, bool enabled)
00070 {
00071
00072 COLORREF color=(enabled?COLOR_BLEND_ENABLE:COLOR_BLEND_DISABLE);
00073
00074
00075
00076
00077 float offsetLeft=(StartBlendTime-StartTime)/(EndTime-StartTime);
00078 clamp (offsetLeft, 0, 1);
00079
00080
00081 pDc->FillSolidRect(&client, GetSysColor (COLOR_SCROLLBAR));
00082
00083
00084 RECT left;
00085 MakeRect (client, left, 0.f, 1.f-StartBlend, offsetLeft, StartBlend);
00086 pDc->FillSolidRect(&left, color);
00087
00088
00089
00090
00091 float offsetRight=(EndBlendTime-StartTime)/(EndTime-StartTime);
00092 clamp (offsetRight, 0, 1);
00093
00094
00095 RECT right;
00096 MakeRect (client, right, offsetRight, 1.f-EndBlend, 1.f-offsetRight, EndBlend);
00097 pDc->FillSolidRect(&right, color);
00098
00099
00100
00101
00102 CPen myPen (PS_NULL, 0, color);
00103 CBrush myBrush (color);
00104 CPen* oldPen=NULL;
00105 CBrush* oldBrush=NULL;
00106
00107
00108 oldPen=pDc->SelectObject (&myPen);
00109 oldBrush=pDc->SelectObject (&myBrush);
00110
00111 for (uint i=0; i<SEGMENT_COUNT; i++)
00112 {
00113
00114 float firstOffset=offsetLeft+(float)i*(offsetRight-offsetLeft)/(float)SEGMENT_COUNT;
00115 float nextOffset=offsetLeft+(float)(i+1)*(offsetRight-offsetLeft)/(float)SEGMENT_COUNT;
00116
00117
00118 float firstTime=StartBlendTime+(float)i*(EndBlendTime-StartBlendTime)/(float)SEGMENT_COUNT;
00119 float nextTime=StartBlendTime+(float)(i+1)*(EndBlendTime-StartBlendTime)/(float)SEGMENT_COUNT;
00120
00121
00122 float firstValue=CAnimationPlaylist::getWeightValue (StartBlendTime, EndBlendTime, firstTime, StartBlend, EndBlend, Smoothness);
00123 float nextValue=CAnimationPlaylist::getWeightValue (StartBlendTime, EndBlendTime, nextTime, StartBlend, EndBlend, Smoothness);
00124
00125
00126 POINT polygon[4];
00127 MakePoint (client, polygon[0], firstOffset, 1.f);
00128 MakePoint (client, polygon[1], firstOffset, 1.f-firstValue);
00129 MakePoint (client, polygon[2], nextOffset, 1.f-nextValue);
00130 MakePoint (client, polygon[3], nextOffset, 1.f);
00131
00132
00133 pDc->Polygon (polygon, 4);
00134 }
00135
00136
00137 CPen myBlackPen (PS_SOLID, 1, RGB(0,0,0));
00138 pDc->SelectObject (&myBlackPen);
00139
00140 POINT p0;
00141 POINT p1;
00142
00143 MakePoint (client, p0, offsetLeft, 0.f);
00144 MakePoint (client, p1, offsetLeft, 1.f);
00145 pDc->MoveTo (p0);
00146 pDc->LineTo (p1);
00147
00148 MakePoint (client, p0, offsetRight, 0.f);
00149 MakePoint (client, p1, offsetRight, 1.f);
00150 pDc->MoveTo (p0);
00151 pDc->LineTo (p1);
00152
00153
00154 pDc->MoveTo (client.left, client.top);
00155 pDc->LineTo (client.right, client.top);
00156 pDc->LineTo (client.right, client.bottom);
00157 pDc->LineTo (client.left, client.bottom);
00158 pDc->LineTo (client.left, client.top);
00159
00160
00161 pDc->SelectObject (oldPen);
00162 pDc->SelectObject (oldBrush);
00163 }
00164
00165