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