2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
23 /// EcoreAnimator is a helper class. It provides the functions to manage animations.
25 /// <since_tizen> preview </since_tizen>
26 [Obsolete("This has been deprecated in API12")]
27 public static class EcoreAnimator
29 static readonly Dictionary<int, Func<bool>> _taskMap = new Dictionary<int, Func<bool>>();
30 static readonly Object _taskLock = new Object();
31 static int _newTaskId = 0;
33 static Interop.Ecore.EcoreTaskCallback _nativeHandler;
35 static EcoreAnimator()
37 _nativeHandler = NativeHandler;
41 /// Gets the current system time as a floating point value in seconds.
43 /// <returns>Current system time</returns>
44 /// <since_tizen> preview </since_tizen>
45 [Obsolete("This has been deprecated in API12")]
46 public static double GetCurrentTime()
48 return Interop.Ecore.ecore_time_get();
52 /// Adds an animator to call <paramref name="handler"/> at every animation tick during the main loop execution.
54 /// <param name="handler">The function to call when it ticks off.</param>
55 /// <returns>A handle to the new animator.</returns>
56 /// <since_tizen> preview </since_tizen>
57 [Obsolete("This has been deprecated in API12")]
58 public static IntPtr AddAnimator(Func<bool> handler)
60 int id = RegistHandler(handler);
61 return Interop.Ecore.ecore_animator_add(_nativeHandler, (IntPtr)id);
65 /// Removes the specified animator from the animator list.
67 /// <param name="anim">The specified animator handle.</param>
68 /// <since_tizen> preview </since_tizen>
69 [Obsolete("This has been deprecated in API12")]
70 public static void RemoveAnimator(IntPtr anim)
72 int taskId = (int)Interop.Ecore.ecore_animator_del(anim);
73 _taskMap.Remove(taskId);
76 static int RegistHandler(Func<bool> task)
81 taskId = _newTaskId++;
83 _taskMap[taskId] = task;
87 static bool NativeHandler(IntPtr userData)
89 int task_id = (int)userData;
90 Func<bool> userAction = null;
91 _taskMap.TryGetValue(task_id, out userAction);
92 return (userAction != null) ? userAction() : false;