File: myx_gc_animation.cpp

package info (click to toggle)
mysql-query-browser 1.2.5beta-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 63,792 kB
  • ctags: 46,485
  • sloc: pascal: 249,299; ansic: 80,111; cpp: 72,467; sh: 25,271; objc: 20,015; yacc: 10,755; java: 9,917; xml: 4,580; php: 2,806; python: 1,566; sql: 1,563; makefile: 1,452; perl: 3
file content (776 lines) | stat: -rw-r--r-- 27,731 bytes parent folder | download | duplicates (4)
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
/* Copyright (C) 2004 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

/**
 * @file myx_gc_animation.cpp 
 * @brief Implementation of the animation manager.
 * 
 */

#include "myx_gc_animation.h"

#define DEFAULT_INTERPOLATION GC_INTERPOLATION_LINEAR

//----------------------------------------------------------------------------------------------------------------------

/**
 * Computes a linear interpolation between 0 and the given end value, determined by parameter t.
 */
float interpolate(float endValue, float t, TInterpolation interpolation)
{
  float result = 0;
  switch (interpolation)
  {
    case GC_INTERPOLATION_LINEAR:
      {
        //         /
        //        /
        //       /
        //      /
        //     /
        //    /
        result = endValue * t;
        break;
      };
    case GC_INTERPOLATION_ACCELLERATED:
      {
        //           ----
        //          /
        //         |
        //         |
        //        /
        //    ---/
        result = endValue * (atan(5.0f * t - 2.5f) / (float) M_PI + 0.5f);
        break;
      };
  };
  return result;
}

//----------------- CAnimation -----------------------------------------------------------------------------------------

CAnimation::CAnimation(CAnimationManager* manager, int duration, bool suspended)
{
  FManager = manager;
  FDuration = (float) duration;
  FSuspended = suspended;
  FUsedTime = 0;
  if (!FSuspended)
    animationStarted();
}

//----------------------------------------------------------------------------------------------------------------------

CAnimation::~CAnimation(void)
{
  FManager->removeAllDependencies(this);
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Base implementation for one animation step.
 *
 * @param step The number of milliseconds that passed by since the last animation step (not counted in suspend state).
 * @result True if the animation actually took place otherwise false.
 */
bool CAnimation::animate(int step)
{
  bool result = !FSuspended && !finished();
  if (result)
  {
    FUsedTime += step;

    // If we finished the animation with this step then trigger dependant animations.
    if (finished())
      FManager->triggerDependentAnimations(this);
  };

  return result;
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Adds a dependency between this animation and the animation given as parameter.
 *
 * @param animation That animation depends on this animation, that is, it is move from suspended to unsuspended state
 *                  when this animation has finished. The given animation must be in suspend state.
 */
void CAnimation::addDependency(CAnimation* animation)
{
  if (animation->suspendedGet())
    FManager->addDependency(this, animation);
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Tells the caller if the animation has used its full time slice already.
 *
 * @result True if the available time was used otherwise false.
 */
bool CAnimation::finished(void)
{
  return (FDuration == 0) || (FUsedTime >= FDuration);
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Sets a new suspended state holding or continuing so effectively the animation.
 *
 * @param suspended It true then the animation is stopped and waits. If false then a waiting animation continues.
 */
void CAnimation::suspendedSet(bool suspended)
{
  if (FSuspended != suspended)
  {
    FSuspended = suspended;
    if (FSuspended)
      animationStopped();
    else
      animationStarted();
  };
}

//----------------- CFigureInstancePathAnimation -----------------------------------------------------------------------

CFigureInstancePathAnimation::CFigureInstancePathAnimation(CAnimationManager* manager, int duration, bool suspended, 
                                                           CGraphicElement* element): CAnimation(manager, duration, suspended)
{
  FInstance = (CFigureInstance*) element;
  if (!suspended)
    FInstance->animationStarted();
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Adds a new point to the path.
 *
 * @param offset The values for x, y and z to be used for the move.
 * @param slice The duration this one move may use in relation to the full animation duration (0..1).
 *              Values <= 0 will prevent the new point from being added. A value > 1 is clamped to 1.
 */
void CFigureInstancePathAnimation::addPoint(const TVertex offset, float slice)
{
  if (slice > 1)
    slice = 1;
  if (slice > 0)
  {
    TAnimationPoint point;
    point.offset = offset;
    point.usedSlice = 0;
    point.usableSlice = slice * FDuration;
    FPoints.push_back(point);
  };
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Computes the necessary values to advance in the path animation and applies them to the target element.
 *
 * @param step The number of milliseconds that passed by since the last animation step (not counted in suspend state).
 * @result True if the animation actually took place otherwise false.
 */
bool CFigureInstancePathAnimation::animate(int step)
{
  bool result = CAnimation::animate(step) && (FPoints.size() > 0);
  if (result)
  {
    // The point at index 0 is always the active one.
    TAnimationPoint& point = FPoints[0];
    point.usedSlice += step;

    TVertex newOffset;
    float factor = point.usedSlice / point.usableSlice;
    if (factor > 1)
      factor = 1;
    newOffset.x = interpolate(point.offset.x, factor, DEFAULT_INTERPOLATION);
    newOffset.y = interpolate(point.offset.y, factor, DEFAULT_INTERPOLATION);
    newOffset.z = interpolate(point.offset.z, factor, DEFAULT_INTERPOLATION);

    FInstance->FTranslation[0] += newOffset.x - FLastOffset.x;
    FInstance->FTranslation[1] += newOffset.y - FLastOffset.y;
    FInstance->FTranslation[2] += newOffset.z - FLastOffset.z;
    FLastOffset = newOffset;
    
    // Remove the current point if we have used up its time slice.
    if (point.usedSlice >= point.usableSlice)
      FPoints.erase(FPoints.begin());
  };
  return result;
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Triggers the animation notification for the animated element.
 */
void CFigureInstancePathAnimation::animationStarted(void) 
{
  FInstance->animationStarted();
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Triggers the animation notification for the animated element.
 */
void CFigureInstancePathAnimation::animationStopped(void) 
{
  FInstance->animationStopped();
}

//----------------- CViewZoomAnimation ---------------------------------------------------------------------------------

CViewZoomAnimation::CViewZoomAnimation(CAnimationManager* manager, float newZoom, int duration, bool suspended, CGCView* element): 
  CAnimation(manager, duration, suspended)
{
  FView = element;
  FTargetZoom = newZoom;
  FZoomDelta = newZoom - FView->FZoom;
  FLastStep = 0;
  if (!suspended)
    FView->animationStarted();
}

//----------------------------------------------------------------------------------------------------------------------

CViewZoomAnimation::CViewZoomAnimation(CAnimationManager* manager, float from, float to, int duration, bool suspended, 
                                       CGCView* element): CAnimation(manager, duration, suspended)
{
  FView = element;
  FTargetZoom = to;
  FZoomDelta = to - from;
  FLastStep = 0;
  if (!suspended)
    FView->animationStarted();
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Computes the next zoom value and applies it.
 *
 * @param step The number of milliseconds that passed by since the last animation step (not counted in suspend state).
 * @result True if the animation actually took place otherwise false.
 */
bool CViewZoomAnimation::animate(int step)
{
  bool result = CAnimation::animate(step);
  if (result)
  {
    float newOffset = interpolate(FZoomDelta, FUsedTime / FDuration, DEFAULT_INTERPOLATION);
    FView->FZoom += newOffset - FLastStep;
    FLastStep = newOffset;

    // Set the end value explicitely because of computation inaccuracies
    // it can happen we did not hit the end point exactly.
    if (finished())
      FView->FZoom = FTargetZoom;
  };
  return result;
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Triggers the animation notification for the animated element.
 */
void CViewZoomAnimation::animationStarted(void) 
{
  FView->animationStarted();
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Triggers the animation notification for the animated element.
 */
void CViewZoomAnimation::animationStopped(void) 
{
  FView->animationStopped(true, false);
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Tells the caller if the animation has used its full time slice already or no change was actually necessary.
 *
 * @result True if no further steps are needed otherwise false.
 */
bool CViewZoomAnimation::finished(void)
{
  return CAnimation::finished() || (FZoomDelta == 0);
}

//----------------- CViewOffsetAnimation -------------------------------------------------------------------------------

CViewOffsetAnimation::CViewOffsetAnimation(CAnimationManager* manager, float x, float y, int duration, bool suspended, 
                                           CGCView* element): CAnimation(manager, duration, suspended)
{
  FView = element;
  FTargetOffsetX = x;
  FTargetOffsetY = y;
  FOffsetXDelta = x - FView->FOffsetX;
  FOffsetYDelta = y - FView->FOffsetY;
  FLastStepX = 0;
  FLastStepY = 0;
  if (!suspended)
    FView->animationStarted();
}

//----------------------------------------------------------------------------------------------------------------------

CViewOffsetAnimation::CViewOffsetAnimation(CAnimationManager* manager, float fromX, float fromY, float toX, float toY, 
                                           int duration, bool suspended, CGCView* element): CAnimation(manager, duration, suspended)
{
  FView = element;
  FTargetOffsetX = toX;
  FTargetOffsetY = toY;
  FOffsetXDelta = toX - fromX;
  FOffsetYDelta = toY - fromY;
  FLastStepX = 0;
  FLastStepY = 0;
  if (!suspended)
    FView->animationStarted();
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Computes the next zoom value and applies it.
 *
 * @param step The number of milliseconds that passed by since the last animation step (not counted in suspend state).
 * @result True if the animation actually took place otherwise false.
 */
bool CViewOffsetAnimation::animate(int step)
{
  bool result = CAnimation::animate(step);
  if (result)
  {
    float newOffsetX = interpolate(FOffsetXDelta, FUsedTime / FDuration, DEFAULT_INTERPOLATION);
    float newOffsetY = interpolate(FOffsetYDelta, FUsedTime / FDuration, DEFAULT_INTERPOLATION);
    FView->FOffsetX += newOffsetX - FLastStepX;
    FView->FOffsetY += newOffsetY - FLastStepY;
    FLastStepX = newOffsetX;
    FLastStepY = newOffsetY;

    // Set the end value explicitely because of computation inaccuracies
    // it can happen we did not hit the end point exactly.
    if (finished())
    {
      FView->FOffsetX = FTargetOffsetX;
      FView->FOffsetY = FTargetOffsetY;
    };
  };
  return result;
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Triggers the animation notification for the animated element.
 */
void CViewOffsetAnimation::animationStarted(void) 
{
  FView->animationStarted();
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Triggers the animation notification for the animated element.
 */
void CViewOffsetAnimation::animationStopped(void) 
{
  FView->animationStopped(false, true);
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Tells the caller if the animation has used its full time slice already or no change was actually necessary.
 *
 * @result True if no further steps are needed otherwise false.
 */
bool CViewOffsetAnimation::finished(void)
{
  return CAnimation::finished() || (FOffsetXDelta == 0 && FOffsetYDelta == 0);
}

//----------------- CAnimationManager ----------------------------------------------------------------------------------

CAnimationManager::CAnimationManager(CGenericCanvas* canvas): CGCBase(canvas)
{
  _className = "CAnimationManager";
  FTimerBase = 10; // 10 milliseconds per tick in pulse() per default.
}

//----------------------------------------------------------------------------------------------------------------------

CAnimationManager::~CAnimationManager(void)
{
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Adds the given animation pair to the internal dependency list.
 *
 * @param animation The animation that enables @dependentAnimation once it is finished.
 * @param dependantAnimation The animation that is started after @animation finished. This animation must be created with
 *                           suspended state on.
 */
void CAnimationManager::addDependency(CAnimation* animation, CAnimation* dependentAnimation)
{
  FDependencies.insert(CAnimationDependanciesPair(animation, dependentAnimation));
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Removes all dependencies for the given animation.
 *
 * @param animation All animations that depend on this animation are removed from the internal dependancies list.
 */
void CAnimationManager::removeAllDependencies(CAnimation* animation)
{
  // First remove all entries that have the given animation as trigger.
  CAnimationDependancies::iterator iterator = FDependencies.find(animation);
  while (iterator != FDependencies.end())
  {
    // Stop loop if there are no more entries for the given animation.
    if (iterator->first != animation)
      break;
#ifdef __GNUC__
    FDependencies.erase(iterator++);
#else
    iterator = FDependencies.erase(iterator);
#endif
  };

  // Then remove all entries that trigger the given animation.
  iterator = FDependencies.begin();
  while (iterator != FDependencies.end())
  {
#ifdef __GNUC__
    if (iterator->second == animation)
      FDependencies.erase(iterator++);
    else
      ++iterator;
#else
    if (iterator->second == animation)
      iterator= FDependencies.erase(iterator);
    else
      ++iterator;
#endif
  };
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Removes the given dependency.
 *
 * @param animation The animation on which @dependentAnimation depends.
 * @param dependentAnimation The animation that depends on @animation and which should be removed from the internal
 *                           dependancy list.
 */
void CAnimationManager::removeDependency(CAnimation* animation, CAnimation* dependentAnimation)
{
  CAnimationDependancies::iterator iterator = FDependencies.find(animation);
  while (iterator != FDependencies.end())
  {
    // Stop loop if there are no more entries for the given animation.
    if (iterator->first != animation)
      break;

    if (iterator->second == dependentAnimation)
    {
      // We found the dependent animation. Remove it and leave the loop.
      FDependencies.erase(iterator);
      break;
    };
  };
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Called when an animation was finished to awake any dependent animations from their suspended state.
 *
 * @param animation The animation that just ended.
 */
void CAnimationManager::triggerDependentAnimations(CAnimation* animation)
{
  CAnimationDependancies::iterator iterator = FDependencies.find(animation);
  while (iterator != FDependencies.end())
  {
    // Stop loop if there are no more entries for the given animation.
    if (iterator->first != animation)
      break;

    iterator->second->suspendedSet(false);
#ifdef __GNUC__
    FDependencies.erase(iterator++);
#else
    iterator = FDependencies.erase(iterator);
#endif
  };
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Creates and returns a new path animation. It accepts one offset which gets the full duration assigned.
 * This way the most commonly used path animation (a single move to a new location) is created with this one call.
 * However there can be more offsets added for which a time slice (percentage of the entire duration) must be given.
 * In that case sum of all time slices must not go beyond 1 (= 100%).
 *
 * @param offset The amount to move the target object.
 * @param duration The time the entire animation must last. It will neither be use less nor more than that (in milliseconds).
 * @param suspended Set to true if you want to add more target points (offsets) otherwise to false.
 * @element The element to be animated.
 * @result A new instance of a path animation for the given element or NULL, if the animation could not be created.
 */
CAnimation* CAnimationManager::createPathAnimation(const TVertex& offset, int duration, bool suspended,
                                                   CGraphicElement* element)
{
  CAnimation* result = NULL;

  if (element->classIs("CFigureInstance"))
  {
    CFigureInstancePathAnimation* animation = new CFigureInstancePathAnimation(this, duration, suspended, element);
    animation->addPoint(offset, 1);
    result = animation;
  };

  if (result != NULL)
    FAnimations.push_back(result);

  return result;
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Creates a new view animation for offset changes and returns it.
 *
 * @param x The new horizontal offset for the view.
 * @param y The new vertical offset for the view.
 * @param duration The time the entire animation must last. It will neither be use less nor more than that (in milliseconds).
 * @param suspended Set to true if you want to add more target points (offsets) otherwise to false.
 * @element The element to be animated.
 * @result A new instance of an animation for the given element or NULL, if the animation could not be created.
 */
CAnimation* CAnimationManager::createViewOffsetAnimation(float x, float y, int duration, bool suspended, CGCView* element)
{
  CViewOffsetAnimation* animation = new CViewOffsetAnimation(this, x, y, duration, suspended, element);
  if (animation->finished())
  {
    delete animation;
    animation = NULL;
  }
  else
    FAnimations.push_back(animation);

  return animation;
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Creates a new view animation for offset changes and returns it.
 *
 * @param fromX The horizontal offset for the view to start from.
 * @param fromY The vertical offset for the view to start from.
 * @param toX The horizontal offset for the view at the end.
 * @param toY The vertical offset for the view at the end.
 * @param duration The time the entire animation must last. It will neither be use less nor more than that (in milliseconds).
 * @param suspended Set to true if you want to add more target points (offsets) otherwise to false.
 * @element The element to be animated.
 * @result A new instance of an animation for the given element or NULL, if the animation could not be created.
 */
CAnimation* CAnimationManager::createViewOffsetAnimation2(float fromX, float fromY, float toX, float toY, int duration, 
                                                          bool suspended, CGCView* element)
{
  CViewOffsetAnimation* animation = new CViewOffsetAnimation(this, fromX, fromY, toX, toY, duration, suspended, element);
  if (animation->finished())
  {
    delete animation;
    animation = NULL;
  }
  else
    FAnimations.push_back(animation);

  return animation;
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Creates a new view animation for zoom changes and returns it.
 *
 * @param newZoom The new zoom for the view.
 * @param duration The time the entire animation must last. It will neither be use less nor more than that (in milliseconds).
 * @param suspended Set to true if you want to add more target points (offsets) otherwise to false.
 * @element The element to be animated.
 * @result A new instance of an animation for the given element or NULL, if the animation could not be created.
 */
CAnimation* CAnimationManager::createViewZoomAnimation(float newZoom, int duration, bool suspended, CGCView* element)
{
  CViewZoomAnimation* animation = new CViewZoomAnimation(this, newZoom, duration, suspended, element);
  if (animation->finished())
  {
    delete animation;
    animation = NULL;
  }
  else
    FAnimations.push_back(animation);

  return animation;
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Creates a new view animation for zoom changes and returns it.
 *
 * @param from The zoom for the view to start from.
 * @param to The zoom for the view at the end.
 * @param duration The time the entire animation must last. It will neither be use less nor more than that (in milliseconds).
 * @param suspended Set to true if you want to add more target points (offsets) otherwise to false.
 * @element The element to be animated.
 * @result A new instance of an animation for the given element or NULL, if the animation could not be created.
 */
CAnimation* CAnimationManager::createViewZoomAnimation2(float from, float to, int duration, bool suspended, CGCView* element)
{
  CViewZoomAnimation* animation = new CViewZoomAnimation(this, from, to, duration, suspended, element);
  if (animation->finished())
  {
    delete animation;
    animation = NULL;
  }
  else
    FAnimations.push_back(animation);

  return animation;
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Retrieves the value of the property given by path. The path syntax is must be something like (here expressed as regex)
 * (container)*(property), where container is a slash and the name of a container class (e.g. layers, figures) and
 * property is the name of a simple property of that container.
 *
 * @param name The name of the property to return.
 * @param index The index of the sub property to return if it is located in a list.
 * @return A description of the property value and, if the property is simple, the actual value.
 */
TGCVariant CAnimationManager::propertyGet(const char* name, unsigned int index)
{
  TGCVariant result;

  switch (getContainerID(name))
  {
    case GC_CONTAINER_UNKNOWN:
      {
        switch (getPropertyID(name))
        {
          case GC_PROPERTY_NAME:
            {
              result = "";
              break;
            };
        };

        break;
      };
  };

  return result;
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Sets the value of the given property, which must be a simple property.
 *
 * @param name The name of the property.
 * @param index The index of the sub property to return if it is located in a list.
 * @param value The new value of the property. Automatic conversion is performed where possible.
 */
void CAnimationManager::propertySet(const char* name, unsigned int index, TGCVariant value)
{
  // There are currently no properties that could be changed. The name is a unique identifier and must not be changed.
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * External clock entry. Since there is no platform independant way of a reliable timer in milliseconds range
 * we let the application pulse the manager. The calling frequency of this method must correspond to the
 * timer base, which is by default 10ms per tick and can be set via method timerBase.
 */
void CAnimationManager::pulse(void)
{
  if (FAnimations.size() > 0)
  {
    bool needRefresh = false;

    CAnimations::iterator iterator = FAnimations.begin();
    while (iterator != FAnimations.end())
    {
      CAnimation* animation = *iterator;

      if (animation->animate(FTimerBase))
        needRefresh = true;
      if (animation->finished())
      {
        if (!animation->suspendedGet())
          animation->animationStopped();
        delete animation;
        iterator = FAnimations.erase(iterator);
      }
      else
        ++iterator;
    };

    // Finally repaint scene.
    if (needRefresh)
      canvas()->refresh();
  };
}

//----------------------------------------------------------------------------------------------------------------------

/**
 * Sets the internal time base used to compute the amount of time which passed between two calls to pulse().
 *
 * @param base The new time base in milliseconds.
 */
void CAnimationManager::timerBase(int base)
{
  FTimerBase = base;
}

//----------------------------------------------------------------------------------------------------------------------