2370b86530af4ed0413355f56ecb89c6d10cf34c
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / ViewInternal.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
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
18 using System;
19 using System.ComponentModel;
20 using System.IO;
21 using System.Runtime.InteropServices;
22 using Tizen.NUI.Binding;
23 using Tizen.NUI.Xaml;
24
25 namespace Tizen.NUI.BaseComponents
26 {
27     /// <summary>
28     /// View is the base class for all views.
29     /// </summary>
30     /// <since_tizen> 3 </since_tizen>
31     public partial class View
32     {
33         private MergedStyle mergedStyle = null;
34         internal MergedStyle _mergedStyle
35         {
36             get
37             {
38                 if (null == mergedStyle)
39                 {
40                     mergedStyle = new MergedStyle(GetType(), this);
41                 }
42
43                 return mergedStyle;
44             }
45         }
46
47         /// <summary>
48         /// The color mode of View.
49         /// This specifies whether the View uses its own color, or inherits its parent color.
50         /// The default is ColorMode.UseOwnMultiplyParentColor.
51         /// </summary>
52         internal ColorMode ColorMode
53         {
54             set
55             {
56                 SetColorMode(value);
57             }
58             get
59             {
60                 return GetColorMode();
61             }
62         }
63
64         internal float WorldPositionX
65         {
66             get
67             {
68                 float temp = 0.0f;
69                 GetProperty(View.Property.WORLD_POSITION_X).Get(out temp);
70                 return temp;
71             }
72         }
73
74         internal float WorldPositionY
75         {
76             get
77             {
78                 float temp = 0.0f;
79                 GetProperty(View.Property.WORLD_POSITION_Y).Get(out temp);
80                 return temp;
81             }
82         }
83
84         internal float WorldPositionZ
85         {
86             get
87             {
88                 float temp = 0.0f;
89                 GetProperty(View.Property.WORLD_POSITION_Z).Get(out temp);
90                 return temp;
91             }
92         }
93
94         internal bool FocusState
95         {
96             get
97             {
98                 return IsKeyboardFocusable();
99             }
100             set
101             {
102                 SetKeyboardFocusable(value);
103             }
104         }
105
106         internal void SetLayout(LayoutItem layout)
107         {
108             _layout = layout;
109             _layout?.AttachToOwner(this);
110             _layout?.RequestLayout();
111         }
112
113         /// <summary>
114         /// Stores the calculated width value and its ModeType. Width component.
115         /// </summary>
116         internal MeasureSpecification MeasureSpecificationWidth
117         {
118             set
119             {
120                 _measureSpecificationWidth = value;
121                 _layout?.RequestLayout();
122             }
123             get
124             {
125                 return _measureSpecificationWidth;
126             }
127         }
128
129         /// <summary>
130         /// Stores the calculated width value and its ModeType. Height component.
131         /// </summary>
132         internal MeasureSpecification MeasureSpecificationHeight
133         {
134             set
135             {
136                 _measureSpecificationHeight = value;
137                 _layout?.RequestLayout();
138             }
139             get
140             {
141                 return _measureSpecificationHeight;
142             }
143         }
144
145         internal void AttachTransitionsToChildren(LayoutTransition transition)
146         {
147             // Iterate children, adding the transition unless a transition
148             // for the same condition and property has already been
149             // explicitly added.
150             foreach (View view in Children)
151             {
152                 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
153             }
154         }
155
156         internal float ParentOriginX
157         {
158             get
159             {
160                 float temp = 0.0f;
161                 GetProperty(View.Property.PARENT_ORIGIN_X).Get(out temp);
162                 return temp;
163             }
164             set
165             {
166                 SetProperty(View.Property.PARENT_ORIGIN_X, new Tizen.NUI.PropertyValue(value));
167                 NotifyPropertyChanged();
168             }
169         }
170
171         internal float ParentOriginY
172         {
173             get
174             {
175                 float temp = 0.0f;
176                 GetProperty(View.Property.PARENT_ORIGIN_Y).Get(out temp);
177                 return temp;
178             }
179             set
180             {
181                 SetProperty(View.Property.PARENT_ORIGIN_Y, new Tizen.NUI.PropertyValue(value));
182                 NotifyPropertyChanged();
183             }
184         }
185
186         internal float ParentOriginZ
187         {
188             get
189             {
190                 float temp = 0.0f;
191                 GetProperty(View.Property.PARENT_ORIGIN_Z).Get(out temp);
192                 return temp;
193             }
194             set
195             {
196                 SetProperty(View.Property.PARENT_ORIGIN_Z, new Tizen.NUI.PropertyValue(value));
197                 NotifyPropertyChanged();
198             }
199         }
200
201         internal float PivotPointX
202         {
203             get
204             {
205                 float temp = 0.0f;
206                 GetProperty(View.Property.ANCHOR_POINT_X).Get(out temp);
207                 return temp;
208             }
209             set
210             {
211                 SetProperty(View.Property.ANCHOR_POINT_X, new Tizen.NUI.PropertyValue(value));
212             }
213         }
214
215         internal float PivotPointY
216         {
217             get
218             {
219                 float temp = 0.0f;
220                 GetProperty(View.Property.ANCHOR_POINT_Y).Get(out temp);
221                 return temp;
222             }
223             set
224             {
225                 SetProperty(View.Property.ANCHOR_POINT_Y, new Tizen.NUI.PropertyValue(value));
226             }
227         }
228
229         internal float PivotPointZ
230         {
231             get
232             {
233                 float temp = 0.0f;
234                 GetProperty(View.Property.ANCHOR_POINT_Z).Get(out temp);
235                 return temp;
236             }
237             set
238             {
239                 SetProperty(View.Property.ANCHOR_POINT_Z, new Tizen.NUI.PropertyValue(value));
240             }
241         }
242
243         internal Matrix WorldMatrix
244         {
245             get
246             {
247                 Matrix temp = new Matrix();
248                 GetProperty(View.Property.WORLD_MATRIX).Get(temp);
249                 return temp;
250             }
251         }
252
253         private int LeftFocusableViewId
254         {
255             get
256             {
257                 int temp = 0;
258                 GetProperty(View.Property.LEFT_FOCUSABLE_VIEW_ID).Get(out temp);
259                 return temp;
260             }
261             set
262             {
263                 SetProperty(View.Property.LEFT_FOCUSABLE_VIEW_ID, new Tizen.NUI.PropertyValue(value));
264             }
265         }
266
267         private int RightFocusableViewId
268         {
269             get
270             {
271                 int temp = 0;
272                 GetProperty(View.Property.RIGHT_FOCUSABLE_VIEW_ID).Get(out temp);
273                 return temp;
274             }
275             set
276             {
277                 SetProperty(View.Property.RIGHT_FOCUSABLE_VIEW_ID, new Tizen.NUI.PropertyValue(value));
278             }
279         }
280
281         private int UpFocusableViewId
282         {
283             get
284             {
285                 int temp = 0;
286                 GetProperty(View.Property.UP_FOCUSABLE_VIEW_ID).Get(out temp);
287                 return temp;
288             }
289             set
290             {
291                 SetProperty(View.Property.UP_FOCUSABLE_VIEW_ID, new Tizen.NUI.PropertyValue(value));
292             }
293         }
294
295         private int DownFocusableViewId
296         {
297             get
298             {
299                 int temp = 0;
300                 GetProperty(View.Property.DOWN_FOCUSABLE_VIEW_ID).Get(out temp);
301                 return temp;
302             }
303             set
304             {
305                 SetProperty(View.Property.DOWN_FOCUSABLE_VIEW_ID, new Tizen.NUI.PropertyValue(value));
306             }
307         }
308
309         internal void Raise()
310         {
311             var parentChildren = GetParent()?.Children;
312
313             if (parentChildren != null)
314             {
315                 int currentIndex = parentChildren.IndexOf(this);
316
317                 // If the view is not already the last item in the list.
318                 if (currentIndex >= 0 && currentIndex < parentChildren.Count - 1)
319                 {
320                     View temp = parentChildren[currentIndex + 1];
321                     parentChildren[currentIndex + 1] = this;
322                     parentChildren[currentIndex] = temp;
323
324                     Interop.NDalic.Raise(swigCPtr);
325                     if (NDalicPINVOKE.SWIGPendingException.Pending)
326                         throw NDalicPINVOKE.SWIGPendingException.Retrieve();
327                 }
328             }
329         }
330
331         internal void Lower()
332         {
333             var parentChildren = GetParent()?.Children;
334
335             if (parentChildren != null)
336             {
337                 int currentIndex = parentChildren.IndexOf(this);
338
339                 // If the view is not already the first item in the list.
340                 if (currentIndex > 0 && currentIndex < parentChildren.Count)
341                 {
342                     View temp = parentChildren[currentIndex - 1];
343                     parentChildren[currentIndex - 1] = this;
344                     parentChildren[currentIndex] = temp;
345
346                     Interop.NDalic.Lower(swigCPtr);
347                     if (NDalicPINVOKE.SWIGPendingException.Pending)
348                         throw NDalicPINVOKE.SWIGPendingException.Retrieve();
349                 }
350             }
351         }
352
353         /// <summary>
354         /// Raises the view to above the target view.
355         /// </summary>
356         /// <remarks>The sibling order of views within the parent will be updated automatically.
357         /// Views on the level above the target view will still be shown above this view.
358         /// Raising this view above views with the same sibling order as each other will raise this view above them.
359         /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
360         /// </remarks>
361         /// <param name="target">Will be raised above this view.</param>
362         internal void RaiseAbove(View target)
363         {
364             var parentChildren = GetParent()?.Children;
365
366             if (parentChildren != null)
367             {
368                 int currentIndex = parentChildren.IndexOf(this);
369                 int targetIndex = parentChildren.IndexOf(target);
370
371                 if (currentIndex < 0 || targetIndex < 0 ||
372                     currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
373                 {
374                     NUILog.Error("index should be bigger than 0 and less than children of layer count");
375                     return;
376                 }
377                 // If the currentIndex is less than the target index and the target has the same parent.
378                 if (currentIndex < targetIndex)
379                 {
380                     parentChildren.Remove(this);
381                     parentChildren.Insert(targetIndex, this);
382
383                     Interop.NDalic.RaiseAbove(swigCPtr, View.getCPtr(target));
384                     if (NDalicPINVOKE.SWIGPendingException.Pending)
385                         throw NDalicPINVOKE.SWIGPendingException.Retrieve();
386                 }
387             }
388
389         }
390
391         /// <summary>
392         /// Lowers the view to below the target view.
393         /// </summary>
394         /// <remarks>The sibling order of views within the parent will be updated automatically.
395         /// Lowering this view below views with the same sibling order as each other will lower this view above them.
396         /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
397         /// </remarks>
398         /// <param name="target">Will be lowered below this view.</param>
399         internal void LowerBelow(View target)
400         {
401             var parentChildren = GetParent()?.Children;
402
403             if (parentChildren != null)
404             {
405                 int currentIndex = parentChildren.IndexOf(this);
406                 int targetIndex = parentChildren.IndexOf(target);
407                 if (currentIndex < 0 || targetIndex < 0 ||
408                    currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
409                 {
410                     NUILog.Error("index should be bigger than 0 and less than children of layer count");
411                     return;
412                 }
413
414                 // If the currentIndex is not already the 0th index and the target has the same parent.
415                 if ((currentIndex != 0) && (targetIndex != -1) &&
416                     (currentIndex > targetIndex))
417                 {
418                     parentChildren.Remove(this);
419                     parentChildren.Insert(targetIndex, this);
420
421                     Interop.NDalic.LowerBelow(swigCPtr, View.getCPtr(target));
422                     if (NDalicPINVOKE.SWIGPendingException.Pending)
423                         throw NDalicPINVOKE.SWIGPendingException.Retrieve();
424                 }
425             }
426
427         }
428
429         internal string GetName()
430         {
431             string ret = Interop.Actor.Actor_GetName(swigCPtr);
432             if (NDalicPINVOKE.SWIGPendingException.Pending)
433                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
434             return ret;
435         }
436
437         internal void SetName(string name)
438         {
439             Interop.Actor.Actor_SetName(swigCPtr, name);
440             if (NDalicPINVOKE.SWIGPendingException.Pending)
441                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
442         }
443
444         internal uint GetId()
445         {
446             uint ret = Interop.Actor.Actor_GetId(swigCPtr);
447             if (NDalicPINVOKE.SWIGPendingException.Pending)
448                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
449             return ret;
450         }
451
452         internal bool IsRoot()
453         {
454             bool ret = Interop.ActorInternal.Actor_IsRoot(swigCPtr);
455             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
456             return ret;
457         }
458
459         internal bool OnWindow()
460         {
461             bool ret = Interop.Actor.Actor_OnStage(swigCPtr);
462             if (NDalicPINVOKE.SWIGPendingException.Pending)
463                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
464             return ret;
465         }
466
467         internal View FindChildById(uint id)
468         {
469             //to fix memory leak issue, match the handle count with native side.
470             IntPtr cPtr = Interop.Actor.Actor_FindChildById(swigCPtr, id);
471             View ret = this.GetInstanceSafely<View>(cPtr);
472             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
473             return ret;
474         }
475
476         internal override View FindCurrentChildById(uint id)
477         {
478             return FindChildById(id);
479         }
480
481         internal void SetParentOrigin(Vector3 origin)
482         {
483             Interop.ActorInternal.Actor_SetParentOrigin(swigCPtr, Vector3.getCPtr(origin));
484             if (NDalicPINVOKE.SWIGPendingException.Pending)
485                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
486         }
487
488         internal Vector3 GetCurrentParentOrigin()
489         {
490             Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentParentOrigin(swigCPtr), true);
491             if (NDalicPINVOKE.SWIGPendingException.Pending)
492                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
493             return ret;
494         }
495
496         internal void SetAnchorPoint(Vector3 anchorPoint)
497         {
498             Interop.Actor.Actor_SetAnchorPoint(swigCPtr, Vector3.getCPtr(anchorPoint));
499             if (NDalicPINVOKE.SWIGPendingException.Pending)
500                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
501         }
502
503         internal Vector3 GetCurrentAnchorPoint()
504         {
505             Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentAnchorPoint(swigCPtr), true);
506             if (NDalicPINVOKE.SWIGPendingException.Pending)
507                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
508             return ret;
509         }
510
511         internal void SetSize(float width, float height)
512         {
513             Interop.ActorInternal.Actor_SetSize__SWIG_0(swigCPtr, width, height);
514             if (NDalicPINVOKE.SWIGPendingException.Pending)
515                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
516         }
517
518         internal void SetSize(float width, float height, float depth)
519         {
520             Interop.ActorInternal.Actor_SetSize__SWIG_1(swigCPtr, width, height, depth);
521             if (NDalicPINVOKE.SWIGPendingException.Pending)
522                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
523         }
524
525         internal void SetSize(Vector2 size)
526         {
527             Interop.ActorInternal.Actor_SetSize__SWIG_2(swigCPtr, Vector2.getCPtr(size));
528             if (NDalicPINVOKE.SWIGPendingException.Pending)
529                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
530         }
531
532         internal void SetSize(Vector3 size)
533         {
534             Interop.ActorInternal.Actor_SetSize__SWIG_3(swigCPtr, Vector3.getCPtr(size));
535             if (NDalicPINVOKE.SWIGPendingException.Pending)
536                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
537         }
538
539         internal Vector3 GetTargetSize()
540         {
541             Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetTargetSize(swigCPtr), true);
542             if (NDalicPINVOKE.SWIGPendingException.Pending)
543                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
544             return ret;
545         }
546
547         internal Size2D GetCurrentSize()
548         {
549             Size ret = new Size(Interop.Actor.Actor_GetCurrentSize(swigCPtr), true);
550             if (NDalicPINVOKE.SWIGPendingException.Pending)
551                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
552             Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
553             return size;
554         }
555
556         internal Vector3 GetNaturalSize()
557         {
558             Vector3 ret = new Vector3(Interop.Actor.Actor_GetNaturalSize(swigCPtr), true);
559             if (NDalicPINVOKE.SWIGPendingException.Pending)
560                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
561             return ret;
562         }
563
564         internal void SetPosition(float x, float y)
565         {
566             Interop.ActorInternal.Actor_SetPosition__SWIG_0(swigCPtr, x, y);
567             if (NDalicPINVOKE.SWIGPendingException.Pending)
568                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
569         }
570
571         internal void SetPosition(float x, float y, float z)
572         {
573             Interop.ActorInternal.Actor_SetPosition__SWIG_1(swigCPtr, x, y, z);
574             if (NDalicPINVOKE.SWIGPendingException.Pending)
575                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
576         }
577
578         internal void SetPosition(Vector3 position)
579         {
580             Interop.ActorInternal.Actor_SetPosition__SWIG_2(swigCPtr, Vector3.getCPtr(position));
581             if (NDalicPINVOKE.SWIGPendingException.Pending)
582                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
583         }
584
585         internal void SetX(float x)
586         {
587             Interop.ActorInternal.Actor_SetX(swigCPtr, x);
588             if (NDalicPINVOKE.SWIGPendingException.Pending)
589                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
590         }
591
592         internal void SetY(float y)
593         {
594             Interop.ActorInternal.Actor_SetY(swigCPtr, y);
595             if (NDalicPINVOKE.SWIGPendingException.Pending)
596                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
597         }
598
599         internal void SetZ(float z)
600         {
601             Interop.ActorInternal.Actor_SetZ(swigCPtr, z);
602             if (NDalicPINVOKE.SWIGPendingException.Pending)
603                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
604         }
605
606         internal void TranslateBy(Vector3 distance)
607         {
608             Interop.ActorInternal.Actor_TranslateBy(swigCPtr, Vector3.getCPtr(distance));
609             if (NDalicPINVOKE.SWIGPendingException.Pending)
610                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
611         }
612
613         internal Position GetCurrentPosition()
614         {
615             Position ret = new Position(Interop.Actor.Actor_GetCurrentPosition(swigCPtr), true);
616             if (NDalicPINVOKE.SWIGPendingException.Pending)
617                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
618             return ret;
619         }
620
621         internal Vector3 GetCurrentWorldPosition()
622         {
623             Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentWorldPosition(swigCPtr), true);
624             if (NDalicPINVOKE.SWIGPendingException.Pending)
625                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
626             return ret;
627         }
628
629         internal void SetInheritPosition(bool inherit)
630         {
631             Interop.ActorInternal.Actor_SetInheritPosition(swigCPtr, inherit);
632             if (NDalicPINVOKE.SWIGPendingException.Pending)
633                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
634         }
635
636         internal bool IsPositionInherited()
637         {
638             bool ret = Interop.ActorInternal.Actor_IsPositionInherited(swigCPtr);
639             if (NDalicPINVOKE.SWIGPendingException.Pending)
640                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
641             return ret;
642         }
643
644         internal void SetOrientation(Degree angle, Vector3 axis)
645         {
646             Interop.ActorInternal.Actor_SetOrientation__SWIG_0(swigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
647             if (NDalicPINVOKE.SWIGPendingException.Pending)
648                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649         }
650
651         internal void SetOrientation(Radian angle, Vector3 axis)
652         {
653             Interop.ActorInternal.Actor_SetOrientation__SWIG_1(swigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
654             if (NDalicPINVOKE.SWIGPendingException.Pending)
655                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656         }
657
658         internal void SetOrientation(Rotation orientation)
659         {
660             Interop.ActorInternal.Actor_SetOrientation__SWIG_2(swigCPtr, Rotation.getCPtr(orientation));
661             if (NDalicPINVOKE.SWIGPendingException.Pending)
662                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663         }
664
665         internal Rotation GetCurrentOrientation()
666         {
667             Rotation ret = new Rotation(Interop.ActorInternal.Actor_GetCurrentOrientation(swigCPtr), true);
668             if (NDalicPINVOKE.SWIGPendingException.Pending)
669                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
670             return ret;
671         }
672
673         internal void SetInheritOrientation(bool inherit)
674         {
675             Interop.ActorInternal.Actor_SetInheritOrientation(swigCPtr, inherit);
676             if (NDalicPINVOKE.SWIGPendingException.Pending)
677                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
678         }
679
680         internal bool IsOrientationInherited()
681         {
682             bool ret = Interop.ActorInternal.Actor_IsOrientationInherited(swigCPtr);
683             if (NDalicPINVOKE.SWIGPendingException.Pending)
684                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
685             return ret;
686         }
687
688         internal Rotation GetCurrentWorldOrientation()
689         {
690             Rotation ret = new Rotation(Interop.ActorInternal.Actor_GetCurrentWorldOrientation(swigCPtr), true);
691             if (NDalicPINVOKE.SWIGPendingException.Pending)
692                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
693             return ret;
694         }
695
696         internal void SetScale(float scale)
697         {
698             Interop.ActorInternal.Actor_SetScale__SWIG_0(swigCPtr, scale);
699             if (NDalicPINVOKE.SWIGPendingException.Pending)
700                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
701         }
702
703         internal void SetScale(float scaleX, float scaleY, float scaleZ)
704         {
705             Interop.ActorInternal.Actor_SetScale__SWIG_1(swigCPtr, scaleX, scaleY, scaleZ);
706             if (NDalicPINVOKE.SWIGPendingException.Pending)
707                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
708         }
709
710         internal void SetScale(Vector3 scale)
711         {
712             Interop.ActorInternal.Actor_SetScale__SWIG_2(swigCPtr, Vector3.getCPtr(scale));
713             if (NDalicPINVOKE.SWIGPendingException.Pending)
714                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
715         }
716
717         internal Vector3 GetCurrentScale()
718         {
719             Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentScale(swigCPtr), true);
720             if (NDalicPINVOKE.SWIGPendingException.Pending)
721                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
722             return ret;
723         }
724
725         internal Vector3 GetCurrentWorldScale()
726         {
727             Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentWorldScale(swigCPtr), true);
728             if (NDalicPINVOKE.SWIGPendingException.Pending)
729                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
730             return ret;
731         }
732
733         internal void SetInheritScale(bool inherit)
734         {
735             Interop.ActorInternal.Actor_SetInheritScale(swigCPtr, inherit);
736             if (NDalicPINVOKE.SWIGPendingException.Pending)
737                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
738         }
739
740         internal bool IsScaleInherited()
741         {
742             bool ret = Interop.ActorInternal.Actor_IsScaleInherited(swigCPtr);
743             if (NDalicPINVOKE.SWIGPendingException.Pending)
744                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
745             return ret;
746         }
747
748         internal Matrix GetCurrentWorldMatrix()
749         {
750             Matrix ret = new Matrix(Interop.ActorInternal.Actor_GetCurrentWorldMatrix(swigCPtr), true);
751             if (NDalicPINVOKE.SWIGPendingException.Pending)
752                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
753             return ret;
754         }
755
756         internal void SetVisible(bool visible)
757         {
758             Interop.Actor.Actor_SetVisible(swigCPtr, visible);
759             if (NDalicPINVOKE.SWIGPendingException.Pending)
760                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
761         }
762
763         internal bool IsVisible()
764         {
765             bool ret = Interop.ActorInternal.Actor_IsVisible(swigCPtr);
766             if (NDalicPINVOKE.SWIGPendingException.Pending)
767                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
768             return ret;
769         }
770
771         internal void SetOpacity(float opacity)
772         {
773             Interop.ActorInternal.Actor_SetOpacity(swigCPtr, opacity);
774             if (NDalicPINVOKE.SWIGPendingException.Pending)
775                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
776         }
777
778         internal float GetCurrentOpacity()
779         {
780             float ret = Interop.ActorInternal.Actor_GetCurrentOpacity(swigCPtr);
781             if (NDalicPINVOKE.SWIGPendingException.Pending)
782                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
783             return ret;
784         }
785
786         internal void SetColor(Vector4 color)
787         {
788             Interop.ActorInternal.Actor_SetColor(swigCPtr, Vector4.getCPtr(color));
789             if (NDalicPINVOKE.SWIGPendingException.Pending)
790                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
791         }
792
793         internal Vector4 GetCurrentColor()
794         {
795             Vector4 ret = new Vector4(Interop.ActorInternal.Actor_GetCurrentColor(swigCPtr), true);
796             if (NDalicPINVOKE.SWIGPendingException.Pending)
797                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
798             return ret;
799         }
800         internal ColorMode GetColorMode()
801         {
802             ColorMode ret = (ColorMode)Interop.ActorInternal.Actor_GetColorMode(swigCPtr);
803             if (NDalicPINVOKE.SWIGPendingException.Pending)
804                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
805             return ret;
806         }
807
808         internal Vector4 GetCurrentWorldColor()
809         {
810             Vector4 ret = new Vector4(Interop.ActorInternal.Actor_GetCurrentWorldColor(swigCPtr), true);
811             if (NDalicPINVOKE.SWIGPendingException.Pending)
812                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
813             return ret;
814         }
815
816         internal void SetDrawMode(DrawModeType drawMode)
817         {
818             Interop.ActorInternal.Actor_SetDrawMode(swigCPtr, (int)drawMode);
819             if (NDalicPINVOKE.SWIGPendingException.Pending)
820                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
821         }
822
823         internal DrawModeType GetDrawMode()
824         {
825             DrawModeType ret = (DrawModeType)Interop.ActorInternal.Actor_GetDrawMode(swigCPtr);
826             if (NDalicPINVOKE.SWIGPendingException.Pending)
827                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
828             return ret;
829         }
830
831         internal void SetKeyboardFocusable(bool focusable)
832         {
833             Interop.ActorInternal.Actor_SetKeyboardFocusable(swigCPtr, focusable);
834             if (NDalicPINVOKE.SWIGPendingException.Pending)
835                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
836         }
837
838         internal bool IsKeyboardFocusable()
839         {
840             bool ret = Interop.ActorInternal.Actor_IsKeyboardFocusable(swigCPtr);
841             if (NDalicPINVOKE.SWIGPendingException.Pending)
842                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
843             return ret;
844         }
845
846         internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
847         {
848             Interop.Actor.Actor_SetResizePolicy(swigCPtr, (int)policy, (int)dimension);
849             if (NDalicPINVOKE.SWIGPendingException.Pending)
850                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
851         }
852
853         internal ResizePolicyType GetResizePolicy(DimensionType dimension)
854         {
855             ResizePolicyType ret = (ResizePolicyType)Interop.Actor.Actor_GetResizePolicy(swigCPtr, (int)dimension);
856             if (NDalicPINVOKE.SWIGPendingException.Pending)
857                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
858             return ret;
859         }
860
861         internal Vector3 GetSizeModeFactor()
862         {
863             Vector3 ret = new Vector3(Interop.Actor.Actor_GetSizeModeFactor(swigCPtr), true);
864             if (NDalicPINVOKE.SWIGPendingException.Pending)
865                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
866             return ret;
867         }
868
869         internal void SetMinimumSize(Vector2 size)
870         {
871             Interop.ActorInternal.Actor_SetMinimumSize(swigCPtr, Vector2.getCPtr(size));
872             if (NDalicPINVOKE.SWIGPendingException.Pending)
873                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
874         }
875
876         internal Vector2 GetMinimumSize()
877         {
878             Vector2 ret = new Vector2(Interop.ActorInternal.Actor_GetMinimumSize(swigCPtr), true);
879             if (NDalicPINVOKE.SWIGPendingException.Pending)
880                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
881             return ret;
882         }
883
884         internal void SetMaximumSize(Vector2 size)
885         {
886             Interop.ActorInternal.Actor_SetMaximumSize(swigCPtr, Vector2.getCPtr(size));
887             if (NDalicPINVOKE.SWIGPendingException.Pending)
888                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
889         }
890
891         internal Vector2 GetMaximumSize()
892         {
893             Vector2 ret = new Vector2(Interop.ActorInternal.Actor_GetMaximumSize(swigCPtr), true);
894             if (NDalicPINVOKE.SWIGPendingException.Pending)
895                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
896             return ret;
897         }
898
899         internal int GetHierarchyDepth()
900         {
901             int ret = Interop.Actor.Actor_GetHierarchyDepth(swigCPtr);
902             if (NDalicPINVOKE.SWIGPendingException.Pending)
903                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
904             return ret;
905         }
906
907         internal uint GetRendererCount()
908         {
909             uint ret = Interop.Actor.Actor_GetRendererCount(swigCPtr);
910             if (NDalicPINVOKE.SWIGPendingException.Pending)
911                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
912             return ret;
913         }
914
915         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
916         {
917             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
918         }
919
920         internal bool IsTopLevelView()
921         {
922             if (GetParent() is Layer)
923             {
924                 return true;
925             }
926             return false;
927         }
928
929         internal void SetKeyInputFocus()
930         {
931             Interop.ViewInternal.View_SetKeyInputFocus(swigCPtr);
932             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
933         }
934
935         internal void ClearKeyInputFocus()
936         {
937             Interop.ViewInternal.View_ClearKeyInputFocus(swigCPtr);
938             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
939         }
940
941         internal PinchGestureDetector GetPinchGestureDetector()
942         {
943             PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.View_GetPinchGestureDetector(swigCPtr), true);
944             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
945             return ret;
946         }
947
948         internal PanGestureDetector GetPanGestureDetector()
949         {
950             PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.View_GetPanGestureDetector(swigCPtr), true);
951             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
952             return ret;
953         }
954
955         internal TapGestureDetector GetTapGestureDetector()
956         {
957             TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.View_GetTapGestureDetector(swigCPtr), true);
958             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
959             return ret;
960         }
961
962         internal LongPressGestureDetector GetLongPressGestureDetector()
963         {
964             LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.View_GetLongPressGestureDetector(swigCPtr), true);
965             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
966             return ret;
967         }
968
969         internal IntPtr GetPtrfromView()
970         {
971             return (IntPtr)swigCPtr;
972         }
973
974         internal void RemoveChild(View child)
975         {
976             // Do actual child removal
977             Interop.Actor.Actor_Remove(swigCPtr, View.getCPtr(child));
978             if (NDalicPINVOKE.SWIGPendingException.Pending)
979                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
980
981             Children.Remove(child);
982             child.InternalParent = null;
983
984             if (ChildRemoved != null)
985             {
986                 ChildRemovedEventArgs e = new ChildRemovedEventArgs
987                 {
988                     Removed = child
989                 };
990                 ChildRemoved(this, e);
991             }
992         }
993
994         /// <summary>
995         /// Removes the layout from this View.
996         /// </summary>
997         internal void ResetLayout()
998         {
999             _layout = null;
1000         }
1001
1002         internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1003         {
1004             return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND);
1005         }
1006
1007         /// <summary>
1008         /// you can override it to clean-up your own resources.
1009         /// </summary>
1010         /// <param name="type">DisposeTypes</param>
1011         /// <since_tizen> 3 </since_tizen>
1012         protected override void Dispose(DisposeTypes type)
1013         {
1014             if (disposed)
1015             {
1016                 return;
1017             }
1018
1019             //_mergedStyle = null;
1020
1021             //Release your own unmanaged resources here.
1022             //You should not access any managed member here except static instance.
1023             //because the execution order of Finalizes is non-deterministic.
1024             if (this != null)
1025             {
1026                 DisConnectFromSignals();
1027             }
1028
1029             foreach (View view in Children)
1030             {
1031                 view.InternalParent = null;
1032             }
1033
1034             base.Dispose(type);
1035         }
1036
1037         /// This will not be public opened.
1038         [EditorBrowsable(EditorBrowsableState.Never)]
1039         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1040         {
1041             Interop.View.delete_View(swigCPtr);
1042         }
1043
1044         private void DisConnectFromSignals()
1045         {
1046             // Save current CPtr.
1047             global::System.Runtime.InteropServices.HandleRef currentCPtr = swigCPtr;
1048
1049             // Use BaseHandle CPtr as current might have been deleted already in derived classes.
1050             swigCPtr = GetBaseHandleCPtrHandleRef;
1051
1052             if (_onRelayoutEventCallback != null)
1053             {
1054                 this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
1055             }
1056
1057             if (_offWindowEventCallback != null)
1058             {
1059                 this.OffWindowSignal().Disconnect(_offWindowEventCallback);
1060             }
1061
1062             if (_onWindowEventCallback != null)
1063             {
1064                 this.OnWindowSignal().Disconnect(_onWindowEventCallback);
1065             }
1066
1067             if (_wheelEventCallback != null)
1068             {
1069                 this.WheelEventSignal().Disconnect(_wheelEventCallback);
1070             }
1071
1072             if (_hoverEventCallback != null)
1073             {
1074                 this.HoveredSignal().Disconnect(_hoverEventCallback);
1075             }
1076
1077             if (_touchDataCallback != null)
1078             {
1079                 this.TouchSignal().Disconnect(_touchDataCallback);
1080             }
1081
1082             if (_ResourcesLoadedCallback != null)
1083             {
1084                 this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
1085             }
1086
1087             if (_offWindowEventCallback != null)
1088             {
1089                 this.OffWindowSignal().Disconnect(_offWindowEventCallback);
1090             }
1091
1092             if (_onWindowEventCallback != null)
1093             {
1094                 this.OnWindowSignal().Disconnect(_onWindowEventCallback);
1095             }
1096
1097             if (_wheelEventCallback != null)
1098             {
1099                 this.WheelEventSignal().Disconnect(_wheelEventCallback);
1100             }
1101
1102             if (_hoverEventCallback != null)
1103             {
1104                 this.HoveredSignal().Disconnect(_hoverEventCallback);
1105             }
1106
1107             if (_touchDataCallback != null)
1108             {
1109                 this.TouchSignal().Disconnect(_touchDataCallback);
1110             }
1111
1112             if (_onRelayoutEventCallback != null)
1113             {
1114                 this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
1115             }
1116
1117             if (_keyCallback != null)
1118             {
1119                 this.KeyEventSignal().Disconnect(_keyCallback);
1120             }
1121
1122             if (_keyInputFocusLostCallback != null)
1123             {
1124                 this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
1125             }
1126
1127             if (_keyInputFocusGainedCallback != null)
1128             {
1129                 this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
1130             }
1131
1132             if (_backgroundResourceLoadedCallback != null)
1133             {
1134                 this.ResourcesLoadedSignal().Disconnect(_backgroundResourceLoadedCallback);
1135             }
1136
1137             if (_onWindowSendEventCallback != null)
1138             {
1139                 this.OnWindowSignal().Disconnect(_onWindowSendEventCallback);
1140             }
1141
1142             // BaseHandle CPtr is used in Registry and there is danger of deletion if we keep using it here.
1143             // Restore current CPtr.
1144             swigCPtr = currentCPtr;
1145         }
1146
1147         private View ConvertIdToView(uint id)
1148         {
1149             View view = GetParent()?.FindCurrentChildById(id);
1150
1151             //If we can't find the parent's children, find in the top layer.
1152             if (!view)
1153             {
1154                 Container parent = GetParent();
1155                 while ((parent is View) && (parent != null))
1156                 {
1157                     parent = parent.GetParent();
1158                     if (parent is Layer)
1159                     {
1160                         view = parent.FindCurrentChildById(id);
1161                         break;
1162                     }
1163                 }
1164             }
1165
1166             return view;
1167         }
1168
1169         private void LoadTransitions()
1170         {
1171             foreach (string str in transitionNames)
1172             {
1173                 string resourceName = str + ".xaml";
1174                 Transition trans = null;
1175
1176                 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
1177
1178                 string likelyResourcePath = resource + "animation/" + resourceName;
1179
1180                 if (File.Exists(likelyResourcePath))
1181                 {
1182                     trans = Xaml.Extensions.LoadObject<Transition>(likelyResourcePath);
1183                 }
1184                 if (trans)
1185                 {
1186                     transDictionary.Add(trans.Name, trans);
1187                 }
1188             }
1189         }
1190
1191
1192         private void OnScaleChanged(float x, float y, float z)
1193         {
1194             Scale = new Vector3(x, y, z);
1195         }
1196
1197         private void OnBackgroundColorChanged(float r, float g, float b, float a)
1198         {
1199             BackgroundColor = new Color(r, g, b, a);
1200         }
1201
1202         private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1203         {
1204             Padding = new Extents(start, end, top, bottom);
1205         }
1206
1207         private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1208         {
1209             Margin = new Extents(start, end, top, bottom);
1210         }
1211
1212         private void OnColorChanged(float r, float g, float b, float a)
1213         {
1214             Color = new Color(r, g, b, a);
1215         }
1216
1217         private void OnAnchorPointChanged(float x, float y, float z)
1218         {
1219             AnchorPoint = new Position(x, y, z);
1220         }
1221
1222         private void OnCellIndexChanged(float x, float y)
1223         {
1224             CellIndex = new Vector2(x, y);
1225         }
1226
1227         private void OnFlexMarginChanged(float x, float y, float z, float w)
1228         {
1229             FlexMargin = new Vector4(x, y, z, w);
1230         }
1231
1232         private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1233         {
1234             PaddingEX = new Extents(start, end, top, bottom);
1235         }
1236
1237         private void OnSizeModeFactorChanged(float x, float y, float z)
1238         {
1239             SizeModeFactor = new Vector3(x, y, z);
1240         }
1241
1242
1243     }
1244 }