[NUI] TCSACR-226 code change (#1032)
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / EvasMap.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18
19 namespace ElmSharp
20 {
21     /// <summary>
22     /// The EvasMap is an opaque handle to map points.
23     /// </summary>
24     /// <since_tizen> preview </since_tizen>
25     public class EvasMap
26     {
27         IntPtr _evasMap;
28         bool _ownership;
29
30         /// <summary>
31         /// Creates and initializes a new instance of the EvasMap class.
32         /// </summary>
33         /// <param name="count">The number of points in the map</param>
34         /// <since_tizen> preview </since_tizen>
35         public EvasMap(int count)
36         {
37             _evasMap = Interop.Evas.evas_map_new(count);
38             _ownership = true;
39         }
40
41         internal EvasMap(IntPtr handle)
42         {
43             _evasMap = handle;
44             _ownership = false;
45         }
46
47         /// <summary>
48         /// Destructor for the EvasMap class.
49         /// </summary>
50         ~EvasMap()
51         {
52             if (_ownership)
53             {
54                 Interop.Evas.evas_map_free(_evasMap);
55             }
56         }
57
58         internal IntPtr Handle
59         {
60             get
61             {
62                 return _evasMap;
63             }
64         }
65
66         /// <summary>
67         /// Gets or sets the flag of the object to move synchronization for map rendering.
68         /// </summary>
69         /// <since_tizen> preview </since_tizen>
70         public bool IsMoveSync
71         {
72             get
73             {
74                 return Interop.Evas.evas_map_util_object_move_sync_get(_evasMap);
75             }
76             set
77             {
78                 Interop.Evas.evas_map_util_object_move_sync_set(_evasMap, value);
79             }
80         }
81
82         /// <summary>
83         /// Populates the source and destination map points to exactly match the object.
84         /// </summary>
85         /// <param name="obj">The object to use unmapped geometry to populate the map coordinates.</param>
86         /// <since_tizen> preview </since_tizen>
87         public void PopulatePoints(EvasObject obj)
88         {
89             Interop.Evas.evas_map_util_points_populate_from_object_full(_evasMap, obj, 0);
90         }
91
92         /// <summary>
93         /// Populates the source and destination map points to exactly match the object.
94         /// </summary>
95         /// <param name="obj">The object to use unmapped geometry to populate the map coordinates.</param>
96         /// <param name="z">
97         /// The point Z-coordinate hint (pre-perspective transform). This value is used for all the four points.
98         /// </param>
99         /// <since_tizen> preview </since_tizen>
100         public void PopulatePoints(EvasObject obj, int z)
101         {
102             Interop.Evas.evas_map_util_points_populate_from_object_full(_evasMap, obj, z);
103         }
104
105         /// <summary>
106         /// Populates the source and destination map points to match the given geometry.
107         /// </summary>
108         /// <param name="geometry">The geometry value contains X-coordinate, Y-coordinate, the width and height to use, to calculate the second and third points.</param>
109         /// <param name="z">The Z-coordinate hint (pre-perspective transform) This value is used for all the four points.</param>
110         /// <since_tizen> preview </since_tizen>
111         public void PopulatePoints(Rect geometry, int z)
112         {
113             Interop.Evas.evas_map_util_points_populate_from_geometry(_evasMap, geometry.X, geometry.Y, geometry.Width, geometry.Height, z);
114         }
115
116         /// <summary>
117         /// Rotates the map.
118         /// </summary>
119         /// <param name="degrees">The abount of degrees from 0.0 to 360.0 to rotate.</param>
120         /// <param name="cx">The rotation's center horizontal position.</param>
121         /// <param name="cy">The rotation's center vertical position.</param>
122         /// <since_tizen> preview </since_tizen>
123         public void Rotate(double degrees, int cx, int cy)
124         {
125             Interop.Evas.evas_map_util_rotate(_evasMap, degrees, cx, cy);
126         }
127
128         /// <summary>
129         /// Rotates the map around 3 axes in 3D.
130         /// </summary>
131         /// <param name="dx">The amount of degrees from 0.0 to 360.0 to rotate around the X-axis.</param>
132         /// <param name="dy">The amount of degrees from 0.0 to 360.0 to rotate around the Y-axis.</param>
133         /// <param name="dz">The amount of degrees from 0.0 to 360.0 to rotate around the Z-axis.</param>
134         /// <param name="cx">The rotation's center horizontal position.</param>
135         /// <param name="cy">The rotation's center vertical position.</param>
136         /// <param name="cz">The rotation's center depth position.</param>
137         /// <since_tizen> preview </since_tizen>
138         public void Rotate3D(double dx, double dy, double dz, int cx, int cy, int cz)
139         {
140             Interop.Evas.evas_map_util_3d_rotate(_evasMap, dx, dy, dz, cx, cy, cz);
141         }
142
143         /// <summary>
144         /// Changes the map point's coordinate.
145         /// </summary>
146         /// <param name="idx">The index of point to change, this must be smaller than the map size.</param>
147         /// <param name="point">The 3D point coordinate.</param>
148         /// <since_tizen> preview </since_tizen>
149         public void SetPointCoordinate(int idx, Point3D point)
150         {
151             Interop.Evas.evas_map_point_coord_set(_evasMap, idx, point.X, point.Y, point.Z);
152         }
153
154         /// <summary>
155         /// Gets the map point's coordinate.
156         /// </summary>
157         /// <param name="idx">The index of point to change, this must be smaller than the map size.</param>
158         /// <returns>The coordinates of a given point in the map.</returns>
159         /// <since_tizen> preview </since_tizen>
160         public Point3D GetPointCoordinate(int idx)
161         {
162             Point3D point;
163             Interop.Evas.evas_map_point_coord_get(_evasMap, idx, out point.X, out point.Y, out point.Z);
164             return point;
165         }
166
167         /// <summary>
168         /// Changes the map to apply the given zooming.
169         /// </summary>
170         /// <param name="x">The horizontal zoom to use.</param>
171         /// <param name="y">The vertical zoom to use.</param>
172         /// <param name="cx">The zooming center horizontal position.</param>
173         /// <param name="cy">The zooming center vertical position.</param>
174         /// <since_tizen> preview </since_tizen>
175         public void Zoom(double x, double y, int cx, int cy)
176         {
177             Interop.Evas.evas_map_util_zoom(_evasMap, x, y, cx, cy);
178         }
179     }
180 }