-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTimeLineEditor.cpp
More file actions
3821 lines (2593 loc) · 109 KB
/
TimeLineEditor.cpp
File metadata and controls
3821 lines (2593 loc) · 109 KB
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/************************************************************************************************************
Copyright (C) 2008 by Paradox Interactive
Component: Time Line Editor Interface
Date : July, 2008
Author(s): George Papaioannou a.k.a sdancer75
Notes : Uses Keith Rule's MemDC for flickering avoid
: Very heavy (or all) modified code from the ZTimeLineEditor
:
:Small scaling functions, does not fully implemented. In the drawTimeSplice is needed to adjust
the start point in pixels as well as the length since the float divisions leave remaining that
affects the visualizations especially in case where InDurationFx + OutDurationFx = Length of the slice
****************************************************************************************************************/
#include "stdafx.h"
#include "ZTimeAlloc.h"
#include "TimeLineEditor.h"
#include "ZTimeAllocDoc.h"
#include "ChangeDurationDlg.h"
#include <math.h>
#include "MemDC.h"
/*//////////////////////////////////////////////////////////////*\
** MACROS
**\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CTimeLineEditor, CScrollView)
/*//////////////////////////////////////////////////////////////*\
** Automatic Object m_eventState Management (C/CC/D)'tors
**\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
CTimeLineEditor::CTimeLineEditor()
{
m_nActiveSpan = -1;
m_nActiveSlice = -1; //no slice is selected
m_nTimeLineStateTime = 0;
m_nTimeMax = 0; // Time Line seconds
m_eventState = NOEVENT;
m_nIdealMajorTickPix = TICKERFREQMAJOR; //seconds
m_nTimer = m_nBallonTimer = 0;
m_bSnap = FALSE;
m_bShowSBXInfoBallon = FALSE;
m_MouseState = NOEVENT;
m_MouseButtonState = NOBUTTONEVENT;
m_MouseX = m_MouseY = 0;
m_bScrollRight = m_bScrollLeft = FALSE;
m_GlobalCurrentTime = 0;
m_fDownScaleFactor = 0; //not initialised in this case. If its true it will be down in the onDraw
}
CTimeLineEditor::~CTimeLineEditor()
{
}
/*//////////////////////////////////////////////////////////////*\
** Message Map
**\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
BEGIN_MESSAGE_MAP(CTimeLineEditor, CScrollView)
//{{AFX_MSG_MAP(CTimeLineEditor)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_ERASEBKGND()
ON_WM_RBUTTONUP()
ON_WM_RBUTTONDOWN()
ON_WM_LBUTTONDBLCLK()
ON_WM_CREATE()
ON_WM_SETCURSOR()
ON_WM_TIMER()
//}}AFX_MSG_MAP
ON_WM_SIZE()
ON_COMMAND(ID_SLICEBODY_DURATION, &CTimeLineEditor::OnSlicebodyDuration)
ON_WM_CONTEXTMENU()
ON_COMMAND(ID_SLICEBODY_DELETE, &CTimeLineEditor::OnSlicebodyDelete)
END_MESSAGE_MAP()
/*//////////////////////////////////////////////////////////////*\
** Message Handlers: Basic
**\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
void CTimeLineEditor::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
SetTimeMax(3600);//give the time in seconds
SetTimeLineScale();
//Currently in this version dont support smaller visual ranges
//SetTimeLineScale(HALFTIMELINE); //initialize to default - FULLTIMELINE, else call it directly from the application
//SetTimeLineScale(SCALETOWINDOW); //initialize to default - FULLTIMELINE, else call it directly from the application
//CreateNewSlice(ID=Span=Slice, StartTime, Length(Duration),InFxDuration,OutFxDuration)
CreateNewSlice(0,35,180,60,10);//give the time in seconds
//AddNewFxToSlice(Span, Slice, StartTime, Length(Duration),FxID)
AddNewFxToSlice(m_nActiveSpan, m_nActiveSlice, 70,5,1);
AddNewFxToSlice(m_nActiveSpan, m_nActiveSlice, 150,20,1);
}
// since I use Keith's Rule CMemoryDC, this would create flickering
// and I already draw on the entire full screen
BOOL CTimeLineEditor::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
int CTimeLineEditor::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CScrollView::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
/************************************************************************************************
OnLButtonDown
Takes care the Left mouse button events
**************************************************************************************************/
// relates to selection and checkboxes
void CTimeLineEditor::OnLButtonDown(UINT nFlags, CPoint point)
{
int nStart, nLength, nFxInDuration, nFxOutDuration;
double dActionID;
CPoint M;
CRect FxSliceRect;
int start,length;
double actionID;
POINT CursorPoint;
m_eventState = NOEVENT; // reset the state
m_MouseButtonState = LBUTTONDOWN;
GetCursorPos (&CursorPoint);
ScreenToClient(&CursorPoint);
M.x = CursorPoint.x + GetScrollPosition().x; // augment the point
M.y = CursorPoint.y + GetScrollPosition().y; // augment the point
m_MouseX = point.x = CursorPoint.x;
m_MouseY = point.y = CursorPoint.y;
//CString str;
//str.Format("OnLButtonDown X=%d Y=%d\n",M.x,M.y);
//TRACE(str);
m_eventState = TestPos(M, m_nActiveSpan, m_nActiveSlice); //Did I click on something imporant
if(m_eventState != NOEVENT)
{
switch(m_eventState)
{
case TIMELINEHANDLER:
SetCapture();
Refresh();
break;
case TIMELINEHEADER:
SetCapture();
m_GlobalCurrentTime = M.x;
Refresh();
break;
case OVERSLICE:
case OVERSLICEFXINBODY:
case OVERSLICEFXOUTBODY:
SetCapture();
m_eventState = OVERSLICE;
//now find the distance between the mouseXY hit and the start of the slice.
//we do this because we dont want the mouseXY to comply with the slice Start
//So the slice start is the its the current mouse XY - this difference
m_TimeLineSpan.GetSlice(m_nActiveSpan,m_nActiveSlice,nStart,nLength,nFxInDuration,nFxOutDuration,dActionID);
m_SliceMouseX_Minus_SliceStartDistance = (int) (M.x* m_fDownScaleFactor) - nStart;
Refresh();
break;
case OVERSLICELEFTHANDLE:
Refresh();
break;
case OVERSLICERIGHTHANDLE:
Refresh();
break;
case OVERSLICEINFXLEFTHANDLE:
Refresh();
break;
case OVERSLICEOUTFXRIGHTHANDLE:
Refresh();
break;
case BODYSLICEFX:
m_TimeLineSpan.GetFxToSlice(m_nActiveSpan,m_nActiveSlice,m_nSBFxActive,start,length,actionID);
m_SliceMouseX_Minus_SliceStartDistance = (int) (M.x* m_fDownScaleFactor) - start;
Refresh();
break;
case BODYSLICEFXLEFTHANDLE:
m_TimeLineSpan.GetSlice(m_nActiveSpan,m_nActiveSlice,nStart,nLength,nFxInDuration,nFxOutDuration,dActionID);
m_TimeLineSpan.GetFxToSlice(m_nActiveSpan,m_nActiveSlice,m_nSBFxActive,start,length,actionID);
//================ set the mouse cursor just in the left side handler.============
//remember we have 4-pixel width thumb nail. So glue the mouse cursor
//just in the left edge of the SBFx.
CursorPoint.x = nStart+start;
CursorPoint.y = point.y;
m_MouseX = point.x = CursorPoint.x;
m_MouseY = point.y = CursorPoint.y;
m_SliceMouseX_Minus_SliceStartDistance = (int) (CursorPoint.x * m_fDownScaleFactor) - start;
ClientToScreen(&CursorPoint);
SetCursorPos(CursorPoint.x-GetScrollPosition().x,CursorPoint.y-GetScrollPosition().y);
//=================================================================================
Refresh();
break;
case BODYSLICEFXRIGHTHANDLE:
m_TimeLineSpan.GetSlice(m_nActiveSpan,m_nActiveSlice,nStart,nLength,nFxInDuration,nFxOutDuration,dActionID);
m_TimeLineSpan.GetFxToSlice(m_nActiveSpan,m_nActiveSlice,m_nSBFxActive,start,length,actionID);
//================ set the mouse cursor just in the right side handler.============
//remember we have 4-pixel width thumb nail. So glue the mouse cursor
//just in the right edge of the SBFx.
CursorPoint.x = nStart+start+length;
CursorPoint.y = point.y;
m_MouseX = point.x = CursorPoint.x;
m_MouseY = point.y = CursorPoint.y;
m_SliceMouseX_Minus_SliceStartDistance = (int) (CursorPoint.x * m_fDownScaleFactor) - (start+length);
ClientToScreen(&CursorPoint);
SetCursorPos(CursorPoint.x-GetScrollPosition().x,CursorPoint.y-GetScrollPosition().y);
//=================================================================================
Refresh();
break;
default:
break;
}
}
PostMessage(WM_SETCURSOR);
CScrollView::OnLButtonDown(nFlags, point);
}
/***************************************************************************************************
OnLButtonUp
Takes care the Left button up events
******************************************************************************************************/
void CTimeLineEditor::OnLButtonUp(UINT nFlags, CPoint point)
{
CRect ClientArea;
GetClientRect(ClientArea);
m_MouseButtonState = LBUTTONUP;
CPoint M = point + GetScrollPosition(); // augment the point to rendering space;
m_MouseX = point.x;
m_MouseY = point.y;
//do this because if mouse is outside the client area (timer scroll enabled) and you release the LButton then the handler is not shown
//because it is a few seconds in front of the viewable area. Adjust the time a few backward
//The same is true when we have negative values or scroll to the left.
if ( (point.x > ClientArea.right) && (m_bScrollRight) && (m_eventState==TIMELINEHANDLER))
m_GlobalCurrentTime = GetScrollPosition().x + ClientArea.right-(TIMELINEHANDLERWIDTH / 2);
if ( (point.x < ClientArea.left) && (m_bScrollLeft) && (m_eventState==TIMELINEHANDLER))
m_GlobalCurrentTime = GetScrollPosition().x + (TIMELINEHANDLERWIDTH / 2);
if (GetCapture () == this)
ReleaseCapture ();
KillCurrentTimer();
m_bScrollRight = m_bScrollLeft = FALSE;
//set the state.Must be before the DetectCursorFromObjBelow
m_eventState = NOEVENT;
DetectCursorFromObjBellow(M);
Refresh();
CScrollView::OnLButtonUp(nFlags, point);
}
/*****************************************************************************************************
OnLButtonDblClk
Takes care the double clicks if any needed.
********************************************************************************************************/
void CTimeLineEditor::OnLButtonDblClk(UINT nFlags, CPoint point)
{
m_MouseButtonState = DCLICK;
CScrollView::OnLButtonDblClk(nFlags, point);
}
/*********************************************************************************************************
OnMouseMove
Take cares the mouse movements as well as selections ie change Objectslice positions, durations etc
**********************************************************************************************************/
void CTimeLineEditor::OnMouseMove(UINT nFlags, CPoint point)
{
CRect rect,FxSliceRect;
int nStart, nLength, nFxInDuration, nFxOutDuration,nSliceMoveNewStart;
double dActionID;
int nNewFxSize,nNewLength;
int newx;
int StartOfFirstSBFx,LengthOfLastSBFx;
int nSBFxMoveNewStart,nSBFxNewLength;
int start,length,Neighbouring_start,Neighbouring_length;
double actionID,Neighbouring_actionID;
int nTemp_start, nTemp_length;
double dTemp_actionID;
int newSBFxActive;
POINT CursorPoint;
CPoint M;
//this is used when the user releases the L-R-M MouseButton outside from the client area.
if ( ( !(nFlags & MK_LBUTTON) ) && (m_MouseButtonState == LBUTTONDOWN) )
{
m_MouseButtonState = NOBUTTONEVENT;
m_eventState = NOEVENT;
Refresh();
}
if ( ( !(nFlags & MK_RBUTTON) ) && (m_MouseButtonState == RBUTTONDOWN) )
{
m_MouseButtonState = NOBUTTONEVENT;
m_eventState = NOEVENT;
Refresh();
}
if ( ( !(nFlags & MK_MBUTTON) ) && (m_MouseButtonState == MBUTTONDOWN) )
{
m_MouseButtonState = NOBUTTONEVENT;
m_eventState = NOEVENT;
Refresh();
}
GetCursorPos (&CursorPoint);
ScreenToClient(&CursorPoint);
M.x = CursorPoint.x + GetScrollPosition().x; // augment the point
M.y = CursorPoint.y + GetScrollPosition().y; // augment the point
m_MouseX = point.x = CursorPoint.x;
m_MouseY = point.y = CursorPoint.y;
//CString str;
//str.Format("onMouseMove X=%d Y=%d\n",M.x,M.y);
//TRACE(str);
// the left mouse button states
if (m_eventState==BODYSLICEFX)
{
newSBFxActive = m_nSBFxActive;
GetClientRect(&rect);
m_TimeLineSpan.GetSlice(m_nActiveSpan,m_nActiveSlice,nStart,nLength,nFxInDuration,nFxOutDuration,dActionID);
//the m_nSBFxActive which shows the selected SBFx was set in the LMouseButtonDown event
m_TimeLineSpan.GetFxToSlice(m_nActiveSpan,m_nActiveSlice,m_nSBFxActive,start,length,actionID);
if ( (m_MouseX >=0) && (m_MouseX <= rect.Width()- (m_sScaleTimeLine == SCALETOWINDOW ? ENDPOINT : 0) ) )
{
//compute the new Start. Use the uncompressed timeline because the drawTimeSlice will convert the scaled values
//automatically. So in this point nSliceMoveNewStart is pointing to the FULLSCALE timeline.
//nSliceMoveNewStart = nStart + round( (M.x-cpOldMouseXY.x)* m_fDownScaleFactor);
nSBFxMoveNewStart = (int) (M.x * m_fDownScaleFactor) - m_SliceMouseX_Minus_SliceStartDistance;
if (m_bSnap)
{
Snap(nSBFxMoveNewStart);
}
//check if we are out of our space
if ( (nSBFxMoveNewStart + length) > (nLength -nFxOutDuration) )
nSBFxMoveNewStart = nLength -nFxOutDuration - length;
if (nSBFxMoveNewStart < (nFxInDuration ))
nSBFxMoveNewStart = nFxInDuration;
//now check of collisions with other SBFxs
//first the Left part. If its zero the its the first so don't make any computations
if (m_nSBFxActive > 0)
{
m_TimeLineSpan.GetFxToSlice(m_nActiveSpan,m_nActiveSlice,m_nSBFxActive-1,nTemp_start,nTemp_length,dTemp_actionID);
if (nSBFxMoveNewStart <= (nTemp_start+nTemp_length ) )
{
if ( (nSBFxMoveNewStart+length) <= nTemp_start)
newSBFxActive=m_nSBFxActive-1;
else
nSBFxMoveNewStart = nTemp_start+nTemp_length;
}
}
//this is the right part
if ( (m_TimeLineSpan.GetSliceFxCount(m_nActiveSpan,m_nActiveSlice)-1) > 0 )
{
if ( m_nSBFxActive < (m_TimeLineSpan.GetSliceFxCount(m_nActiveSpan,m_nActiveSlice)-1) )
{
m_TimeLineSpan.GetFxToSlice(m_nActiveSpan,m_nActiveSlice,m_nSBFxActive+1,nTemp_start,nTemp_length,dTemp_actionID);
//if mouse check is inside the next SBFx then stop it else if the user continue to drag the SBFx and the start pos
//of the selected block exceed the length of the previous block then jump it
if ( (nSBFxMoveNewStart+length) >= nTemp_start)
{
if (nSBFxMoveNewStart < (nTemp_start+nTemp_length))
nSBFxMoveNewStart = nTemp_start - length;
else
//we have to update the m_nSBFxActive since with the editFxToSlice we sort every block and after the jump
//the current selected Slice Body Fx will become the previous one.
newSBFxActive=m_nSBFxActive+1;
}
}
}
}
m_TimeLineSpan.EditFxToSlice(m_nActiveSpan,m_nActiveSlice,m_nSBFxActive,nSBFxMoveNewStart,length,actionID);
m_nSBFxActive = newSBFxActive;
Refresh();
UpdateWindow();
}
if(m_eventState==BODYSLICEFXLEFTHANDLE)
{
m_TimeLineSpan.GetSlice(m_nActiveSpan,m_nActiveSlice,nStart,nLength,nFxInDuration,nFxOutDuration,dActionID);
//the m_nSBFxActive which shows the selected SBFx was set in the LMouseButtonDown event
m_TimeLineSpan.GetFxToSlice(m_nActiveSpan,m_nActiveSlice,m_nSBFxActive,start,length,actionID);
nNewFxSize = (int) (M.x * m_fDownScaleFactor) - ( nStart+start);
nSBFxNewLength = length - nNewFxSize;
//compute the new Start. Use the uncompressed timeline because the drawTimeSlice will convert the scaled values
//automatically. So in this point nSliceMoveNewStart is pointing to the FULLSCALE timeline.
nSBFxMoveNewStart = (int) (M.x * m_fDownScaleFactor) - m_SliceMouseX_Minus_SliceStartDistance;
if (m_bSnap)
{
Snap(nSBFxMoveNewStart);
}
//check if we are out of our space
if ( (nSBFxNewLength) < 1 )
{
nSBFxMoveNewStart = start+length-1;
nSBFxNewLength = 1;
}
if (nSBFxMoveNewStart < (nFxInDuration ))
{
nSBFxMoveNewStart = nFxInDuration;
nSBFxNewLength = (start+length) - nSBFxMoveNewStart;
}
//check collision with the previous SBFx
if ( m_nSBFxActive > 0 )
{
m_TimeLineSpan.GetFxToSlice(m_nActiveSpan,m_nActiveSlice,m_nSBFxActive-1,Neighbouring_start,Neighbouring_length,Neighbouring_actionID);
if (nSBFxMoveNewStart < (Neighbouring_start+Neighbouring_length))
{
nSBFxMoveNewStart = Neighbouring_start+Neighbouring_length;
nSBFxNewLength = (start+length) - nSBFxMoveNewStart;
}
}
m_TimeLineSpan.EditFxToSlice(m_nActiveSpan,m_nActiveSlice,m_nSBFxActive,nSBFxMoveNewStart,nSBFxNewLength,actionID);
Refresh();
UpdateWindow();
}
if(m_eventState==BODYSLICEFXRIGHTHANDLE)
{
m_TimeLineSpan.GetSlice(m_nActiveSpan,m_nActiveSlice,nStart,nLength,nFxInDuration,nFxOutDuration,dActionID);
//the m_nSBFxActive which shows the selected SBFx was set in the LMouseButtonDown event
m_TimeLineSpan.GetFxToSlice(m_nActiveSpan,m_nActiveSlice,m_nSBFxActive,start,length,actionID);
nNewFxSize = (int) (M.x * m_fDownScaleFactor) - ( nStart+start+length);
nSBFxNewLength = length + nNewFxSize;
//compute the new Start. Use the uncompressed timeline because the drawTimeSlice will convert the scaled values
//automatically. So in this point nSliceMoveNewStart is pointing to the FULLSCALE timeline.
nSBFxMoveNewStart = (int) (M.x * m_fDownScaleFactor) - m_SliceMouseX_Minus_SliceStartDistance;
if (m_bSnap)
{
Snap(nSBFxMoveNewStart);
}
//check if we are out of our space
if ( (nSBFxNewLength) < 1 )
{
nSBFxNewLength = 1;
}
if ((nStart+start+nSBFxNewLength) > (nStart + nLength - nFxOutDuration ))
{
nSBFxNewLength = nSBFxNewLength - ( (nStart+start+nSBFxNewLength) - (nStart + nLength -nFxOutDuration ));
}
//check collision with the next SBFx
if ( m_nSBFxActive < (m_TimeLineSpan.GetSliceFxCount(m_nActiveSpan,m_nActiveSlice)-1) )
{
m_TimeLineSpan.GetFxToSlice(m_nActiveSpan,m_nActiveSlice,m_nSBFxActive+1,Neighbouring_start,Neighbouring_length,Neighbouring_actionID);
if ((start + nSBFxNewLength) > Neighbouring_start)
nSBFxNewLength = Neighbouring_start - start;
}
m_TimeLineSpan.EditFxToSlice(m_nActiveSpan,m_nActiveSlice,m_nSBFxActive,start,nSBFxNewLength,actionID);
Refresh();
UpdateWindow();
}
// the left mouse button states
if ( (m_eventState==OVERSLICE) || (m_eventState==OVERSLICEFXINBODY) || (m_eventState==OVERSLICEFXOUTBODY) )
{
GetClientRect(&rect);
//Scroll window in any case except when scale = SCALETOWINDOW
//automatically scroll when the handler reach the edges;
if ( ( point.x >= rect.Width() ) && (m_sScaleTimeLine != SCALETOWINDOW) )
{
m_bScrollRight = TRUE;
m_bScrollLeft = FALSE;
if (m_nTimer == 0)
m_nTimer = SetTimer (IDT_TIMER1, 10, NULL);
}
//Scroll window in any case except when scale = SCALETOWINDOW
else if ( (point.x < 0) && (m_sScaleTimeLine != SCALETOWINDOW) )
{
m_bScrollLeft = TRUE;
m_bScrollRight = FALSE;
if (m_nTimer == 0)
m_nTimer = SetTimer (IDT_TIMER1, 10, NULL);
}
else
// if no scroll do the normal job
{
m_TimeLineSpan.GetSlice(m_nActiveSpan,m_nActiveSlice,nStart,nLength,nFxInDuration,nFxOutDuration,dActionID);
if ( (m_MouseX >=0) && (m_MouseX <= rect.Width()- (m_sScaleTimeLine == SCALETOWINDOW ? ENDPOINT : 0) ) )
{
//compute the new Start. Use the uncompressed timeline because the drawTimeSlice will convert the scaled values
//automatically. So in this point nSliceMoveNewStart is pointing to the FULLSCALE timeline.
//nSliceMoveNewStart = nStart + round( (M.x-cpOldMouseXY.x)* m_fDownScaleFactor);
nSliceMoveNewStart = (int) (M.x * m_fDownScaleFactor) - m_SliceMouseX_Minus_SliceStartDistance;
if (m_bSnap)
{
Snap(nSliceMoveNewStart);
}
//check if we are out of our space
if ( (nSliceMoveNewStart + nLength) > m_nTimeMax)
nSliceMoveNewStart = m_nTimeMax - nLength;
if (nSliceMoveNewStart < 0)
nSliceMoveNewStart = 0;
}
//do these checks since we use the SetCapture / ReleaseCapture Mouse and we dont want artefacts
//but only in case that we have scaled to SCALETOWINDOW since in different case we want to scroll and
//we treat such messages totally different.
else if ( (m_MouseX < 0 ) && (m_sScaleTimeLine == SCALETOWINDOW) )
nSliceMoveNewStart = 0;
else if ( (m_MouseX > (rect.Width()-ENDPOINT) ) && (m_sScaleTimeLine == SCALETOWINDOW) )
nSliceMoveNewStart = m_nTimeMax - nLength;
m_TimeLineSpan.Edit(m_nActiveSpan,m_nActiveSlice, nSliceMoveNewStart ,nLength,nFxInDuration,nFxOutDuration,dActionID);
m_bScrollRight = FALSE;
m_bScrollLeft = FALSE;
Refresh();
UpdateWindow();
}
}
if(m_eventState==OVERSLICELEFTHANDLE)
{
m_TimeLineSpan.GetSlice(m_nActiveSpan,m_nActiveSlice,nStart,nLength,nFxInDuration,nFxOutDuration,dActionID);
nNewFxSize = ((int) (M.x * m_fDownScaleFactor) - ( nStart+nFxInDuration));
if ( (nFxInDuration+nNewFxSize) <= 0 )
nNewFxSize = - nFxInDuration;
//check if we hit a SBFx from the Left edge
else if ( (StartOfFirstSBFx=HitLeftFxSplice(nStart+nFxInDuration+nNewFxSize)) != -1)
nNewFxSize = StartOfFirstSBFx - (nStart+nFxInDuration);
else if ( (nFxInDuration+nNewFxSize) >= (nLength - nFxOutDuration) - SLICEBODYMINWIDTH )
nNewFxSize = (nLength - nFxOutDuration) - nFxInDuration - SLICEBODYMINWIDTH;
else if (m_bSnap) //do the snapping when no out of borders occures
{
newx = nStart + nNewFxSize + nFxInDuration;
Snap(newx);
nNewFxSize = newx - nStart;
if ( (nFxInDuration+nNewFxSize) <= 0 )
nNewFxSize = nFxInDuration;
nFxInDuration = 0;
}
m_TimeLineSpan.Edit (m_nActiveSpan,m_nActiveSlice,nStart,nLength,nFxInDuration+nNewFxSize,nFxOutDuration,dActionID);
Refresh();
UpdateWindow();
}
if(m_eventState==OVERSLICERIGHTHANDLE)
{
m_TimeLineSpan.GetSlice(m_nActiveSpan,m_nActiveSlice,nStart,nLength,nFxInDuration,nFxOutDuration,dActionID);
nNewFxSize =(nStart + ( nLength-nFxOutDuration) - (int) (M.x * m_fDownScaleFactor));
nNewLength = nLength - nFxInDuration - (nFxOutDuration + nNewFxSize );
//check to see if we hit a SBFx from the right edge
if ( (LengthOfLastSBFx=HitRightFxSplice(nStart + ( nLength-nFxOutDuration) - nNewFxSize)) != -1)
nNewFxSize = (nStart + ( nLength-nFxOutDuration)) - LengthOfLastSBFx;
else if ( nNewLength < SLICEBODYMINWIDTH)
nNewFxSize = nLength - nFxInDuration - nFxOutDuration;
else if ( (nFxOutDuration+nNewFxSize) < 0 )
nNewFxSize = -nFxOutDuration;
else if (m_bSnap) //do the snapping when no out of borders occures
{
newx = nLength - (nFxOutDuration+nNewFxSize) + nStart;
Snap(newx);
nNewFxSize = (nStart+nLength) - newx;
nNewLength = nLength - nFxInDuration - nNewFxSize;
if ( nNewLength < SLICEBODYMINWIDTH)
nNewFxSize = nFxOutDuration;
nFxOutDuration = 0;
}
m_TimeLineSpan.Edit (m_nActiveSpan,m_nActiveSlice,nStart,nLength,nFxInDuration,nFxOutDuration+nNewFxSize,dActionID);
Refresh();
UpdateWindow();
}
if(m_eventState==OVERSLICEINFXLEFTHANDLE)
{
m_TimeLineSpan.GetSlice(m_nActiveSpan,m_nActiveSlice,nStart,nLength,nFxInDuration,nFxOutDuration,dActionID);
nNewFxSize = (int) (M.x * m_fDownScaleFactor) - nStart;
if( (LengthOfLastSBFx=HitRightFxSplice(nStart + ( nLength-nFxOutDuration) - nNewFxSize)) != -1)
nNewFxSize = (nStart + ( nLength-nFxOutDuration)) - LengthOfLastSBFx;
else if ( (nStart+nNewFxSize) <= 0 )
nNewFxSize = - nStart;
else if ( (nFxInDuration+nNewFxSize) >= (nLength - nFxOutDuration) - SLICEBODYMINWIDTH )
nNewFxSize = (nLength - nFxOutDuration) - nFxInDuration - SLICEBODYMINWIDTH;
else if (m_bSnap) //do the snapping when no out of borders occures
{
newx = nStart + nNewFxSize;
Snap(newx);
nLength = nLength+(nStart-newx);
nStart = newx;
nNewFxSize = 0;
}
m_TimeLineSpan.Edit (m_nActiveSpan,m_nActiveSlice,nStart+nNewFxSize,nLength-nNewFxSize,nFxInDuration,nFxOutDuration,dActionID);
Refresh();
UpdateWindow();
}
if(m_eventState==OVERSLICEOUTFXRIGHTHANDLE)
{
m_TimeLineSpan.GetSlice(m_nActiveSpan,m_nActiveSlice,nStart,nLength,nFxInDuration,nFxOutDuration,dActionID);
nNewFxSize = (int) (M.x * m_fDownScaleFactor) - (nStart + nLength);
nNewLength = nLength - nFxInDuration - (nFxOutDuration - nNewFxSize );
//check if we hit a SBFx from the Left edge
if( (LengthOfLastSBFx=HitRightFxSplice(nStart + ( nLength-nFxOutDuration) + nNewFxSize)) != -1)
nNewFxSize = LengthOfLastSBFx - (nStart + ( nLength-nFxOutDuration));
else if ( nNewLength < SLICEBODYMINWIDTH)
nNewFxSize = -(nLength - nFxInDuration - nFxOutDuration);
else if ( nStart + nLength + nNewFxSize > m_nTimeMax)
nNewFxSize = 0;
else if (m_bSnap) //do the snapping when no out of borders occures
{
newx = nStart+nLength+nNewFxSize;
Snap(newx);
nNewFxSize = newx - nStart;
nNewLength = nNewFxSize - nFxInDuration - nFxOutDuration;
if ( nNewLength < SLICEBODYMINWIDTH)
nNewFxSize = nLength;
nLength = 0;
}
m_TimeLineSpan.Edit (m_nActiveSpan,m_nActiveSlice,nStart,nLength+nNewFxSize,nFxInDuration,nFxOutDuration,dActionID);
Refresh();
UpdateWindow();
}
if (m_eventState == TIMELINEHANDLER)
{
m_GlobalCurrentTime = GetTimeHandlerX(M.x);
if (m_bSnap)
{
Snap(m_GlobalCurrentTime);
}
Refresh();
UpdateWindow();
//Scroll window in any case except when scale = SCALETOWINDOW
if (m_sScaleTimeLine != SCALETOWINDOW)
{
GetClientRect(&rect);
//automatically scroll when the handler reach the edges;
if ( ( point.x >= rect.Width() ) && (M.x < m_nScaledTimeMax) )
{
m_bScrollRight = TRUE;
m_bScrollLeft = FALSE;
if (m_nTimer == 0)
m_nTimer = SetTimer (IDT_TIMER1, 10, NULL);
}
else if ( (point.x < 0) && (M.x > 0) )
{
m_bScrollLeft = TRUE;
m_bScrollRight = FALSE;
if (m_nTimer == 0)
m_nTimer = SetTimer (IDT_TIMER1, 10, NULL);
}
else
{
m_bScrollRight = FALSE;
m_bScrollLeft = FALSE;
}
}
}
//if no Event during the xButtonDown then there is no event and the mouse buttons are free.
//So check if there is a "hot" object bellow mouse cursor and change the cursor accordingly
//if so change the m_MouseState state accordingly so the OnSetCursor will update the cursor
DetectCursorFromObjBellow(M);
if ( (m_MouseButtonState == LBUTTONUP) || (m_MouseButtonState == RBUTTONUP) || (m_MouseButtonState == MBUTTONUP))
m_MouseButtonState = NOBUTTONEVENT;
CScrollView::OnMouseMove(nFlags, point);
}
/*****************************************************************************************************************
DetectCursorFromObjBellow
Detect if there is a hot object below the current x,y position of the mouse cursor
and if its true change the shape accordingly
******************************************************************************************************************/
void CTimeLineEditor::DetectCursorFromObjBellow(CPoint M)
{
m_bShowSBXInfoBallon = FALSE;
if(m_eventState==NOEVENT)
{
// since TestPos is a m_eventState Driven function, it must be in the if statement
EVENTS res = TestPos(M, m_nActiveSpan, m_nActiveSlice); //Did I click on something important
if(res != NOEVENT)
{
switch(res)
{
case OVERTIMELINEHANDLER:
m_MouseState = OVERTIMELINEHANDLER;
PostMessage(WM_SETCURSOR);
break;