Release 4.0.0-preview1-00051
[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     public class EvasMap
25     {
26         IntPtr _evasMap;
27         bool _ownership;
28
29         /// <summary>
30         /// Creates and initializes a new instance of the EvasMap class.
31         /// </summary>
32         /// <param name="count">The number of points in the map</param>
33         public EvasMap(int count)
34         {
35             _evasMap = Interop.Evas.evas_map_new(count);
36             _ownership = true;
37         }
38
39         internal EvasMap(IntPtr handle)
40         {
41             _evasMap = handle;
42             _ownership = false;
43         }
44
45         ~EvasMap()
46         {
47             if (_ownership)
48             {
49                 Interop.Evas.evas_map_free(_evasMap);
50             }
51         }
52
53         internal IntPtr Handle
54         {
55             get
56             {
57                 return _evasMap;
58             }
59         }
60
61         /// <summary>
62         /// Gets or sets the flag of the object move synchronization for map rendering.
63         /// </summary>
64         public bool IsMoveSync
65         {
66             get
67             {
68                 return Interop.Evas.evas_map_util_object_move_sync_get(_evasMap);
69             }
70             set
71             {
72                 Interop.Evas.evas_map_util_object_move_sync_set(_evasMap, value);
73             }
74         }
75
76         /// <summary>
77         /// Populates source and destination map points to exactly match the object.
78         /// </summary>
79         /// <param name="obj">The object to use unmapped geometry to populate map coordinates</param>
80         /// <param name="z">
81         /// The point Z coordinate hint (pre-perspective transform)This value is used for all four points.
82         /// </param>
83         public void PopulatePoints(EvasObject obj, int z)
84         {
85             Interop.Evas.evas_map_util_points_populate_from_object_full(_evasMap, obj, z);
86         }
87
88         /// <summary>
89         /// Populates the source and destination map points to match the given geometry.
90         /// </summary>
91         /// <param name="geometry">The geometry value contains X coordinate,Y coordinate,the width and height to use to calculate second and third points</param>
92         /// <param name="z">The Z coordinate hint (pre-perspective transform) This value is used for all four points.</param>
93         public void PopulatePoints(Rect geometry, int z)
94         {
95             Interop.Evas.evas_map_util_points_populate_from_geometry(_evasMap, geometry.X, geometry.Y, geometry.Width, geometry.Height, z);
96         }
97
98         /// <summary>
99         /// Rotates the map around 3 axes in 3D.
100         /// </summary>
101         /// <param name="dx">The amount of degrees from 0.0 to 360.0 to rotate around X axis</param>
102         /// <param name="dy">The amount of degrees from 0.0 to 360.0 to rotate around Y axis</param>
103         /// <param name="dz">The amount of degrees from 0.0 to 360.0 to rotate around Z axis</param>
104         /// <param name="cx">The rotation's center horizontal position</param>
105         /// <param name="cy">The rotation's center vertical position</param>
106         /// <param name="cz">The rotation's center vertical position</param>
107         public void Rotate3D(double dx, double dy, double dz, int cx, int cy, int cz)
108         {
109             Interop.Evas.evas_map_util_3d_rotate(_evasMap, dx, dy, dz, cx, cy, cz);
110         }
111
112         /// <summary>
113         /// Changes the map point's coordinate.
114         /// </summary>
115         /// <param name="idx">The index of point to change ,this must be smaller than map size.</param>
116         /// <param name="point">3D Point coordinate</param>
117         public void SetPointCoordinate(int idx, Point3D point)
118         {
119             Interop.Evas.evas_map_point_coord_set(_evasMap, idx, point.X, point.Y, point.Z);
120         }
121
122         /// <summary>
123         /// Gets the map point's coordinate.
124         /// </summary>
125         /// <param name="idx">The index of point to change ,this must be smaller than map size.</param>
126         /// <returns>The coordinates of the given point in the map.</returns>
127         public Point3D GetPointCoordinate(int idx)
128         {
129             Point3D point;
130             Interop.Evas.evas_map_point_coord_get(_evasMap, idx, out point.X, out point.Y, out point.Z);
131             return point;
132         }
133
134         /// <summary>
135         /// Changes the map to apply the given zooming.
136         /// </summary>
137         /// <param name="x">The horizontal zoom to use</param>
138         /// <param name="y">The vertical zoom to use</param>
139         /// <param name="cx">The zooming center horizontal position</param>
140         /// <param name="cy">The zooming center vertical position</param>
141         public void Zoom(double x, double y, int cx, int cy)
142         {
143             Interop.Evas.evas_map_util_zoom(_evasMap, x, y, cx, cy);
144         }
145     }
146 }