1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef TIMELINEITEM_H
#define TIMELINEITEM_H
#ifdef _WIN32
#pragma once
#endif
#include <mxtk/mx.h>
#include "utlvector.h"
#include "ExpressionSample.h"
class CExpression;
class ExpressionTool;
class CFlexAnimationTrack;
class CChoreoWidgetDrawHelper;
class CChoreoView;
template< class T > class CCurveEditorHelper;
#define FP_TL_SELECTION_TOLERANCE 30.0f
#define FP_TL_SELECTION_RECTANGLE_TOLERANCE 5.0f
#define FP_TL_ADDSAMPLE_TOLERANCE 5.0f
class TimelineItem
{
public:
// Construction
TimelineItem( mxWindow *workspace );
~TimelineItem( void );
virtual int handleEvent( mxEvent *event );
virtual void Draw( CChoreoWidgetDrawHelper& drawHelper );
void DrawEventEnd( CChoreoWidgetDrawHelper& drawHelper );
void DrawSelf( void );
void SetExpressionInfo( CFlexAnimationTrack *track, int flexnum );
void Clear( bool preserveundo );
void SetCollapsed( bool state );
bool IsCollapsed( void ) const;
void SetActive( bool state );
bool IsActive( void );
int GetHeight( void );
void ResetHeight();
// If samples > 0
bool IsValid( void );
void SetEditType( int type );
int GetEditType( void );
void SetBounds( const RECT& rect );
void GetBounds( RECT& rect );
void SetVisible( bool vis );
bool GetVisible( void ) const;
int CountSelected( void );
CFlexAnimationTrack *GetSafeTrack( void );
int GetNumSelected( void );
void Copy( void );
void Paste( void );
void SelectAll( void );
void DeselectAll( void );
void Delete( void );
void GetLastMouse( int& mx, int& my )
{
mx = m_nLastX;
my = m_nLastY;
}
void SnapAll();
void SnapSelected();
void DeletePoints( float start, float end );
float GetTimeForMouse( int mx, bool clip = false );
int GetMouseForTime( float t, bool *clipped = NULL );
void SetMousePositionForEvent( mxEvent *event );
int NumSamples();
CExpressionSample *GetSample( int idx );
void PreDataChanged( char const *undodescription );
void PostDataChanged( char const *redodescription );
CExpressionSample *GetSampleUnderMouse( int mx, int my, float tolerance = FP_TL_SELECTION_TOLERANCE );
void GetWorkList( bool reflect, CUtlVector< TimelineItem * >& list );
private:
enum
{
DRAGTYPE_NONE = 0,
DRAGTYPE_MOVEPOINTS_VALUE,
DRAGTYPE_MOVEPOINTS_TIME,
DRAGTYPE_SELECTION,
DRAGTYPE_GROW,
};
bool CanHaveGrowHandle();
void DrawGrowHandle( CChoreoWidgetDrawHelper& helper, RECT& handleRect );
void GetGrowHandleRect( RECT& rc );
bool IsMouseOverGrowHandle( int x, int y);
void MouseDrag( int x, int y, int modifiers, bool snap = false );
void DrawGrowRect();
void DrawFocusRect( void );
void SelectPoints( void );
void OnDoubleClicked( void );
void DrawAutoHighlight( mxEvent *event );
int m_nDragging;
int m_nLastX;
int m_nLastY;
int m_nStartX;
int m_nStartY;
void AddSample( CExpressionSample const& sample );
void DrawRelativeTags( CChoreoWidgetDrawHelper& drawHelper );
int m_nNumSelected;
int m_nFlexNum;
bool m_bCollapsed;
char m_szTrackName[ 128 ];
int m_nEditType;
int m_nUndoSetup;
RECT m_rcBounds;
bool m_bVisible;
mxWindow *m_pWorkspace;
double m_flLastClickTime;
int m_nCurrentHeight;
CCurveEditorHelper< TimelineItem > *m_pHelper;
};
#endif // TIMELINEITEM_H
|