5e64ac1f248c4e3c2ae63cff424b7b31690d9925
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / ViewInternal.cs
1 /*
2  * Copyright(c) 2022 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 global::System.Diagnostics;
21 using Tizen.NUI;
22
23 namespace Tizen.NUI.BaseComponents
24 {
25     /// <summary>
26     /// View is the base class for all views.
27     /// </summary>
28     /// <since_tizen> 3 </since_tizen>
29     public partial class View
30     {
31         internal string styleName;
32
33         internal virtual LayoutItem CreateDefaultLayout()
34         {
35             return new AbsoluteLayout();
36         }
37
38         internal class ThemeData
39         {
40             [Flags]
41             private enum States : byte
42             {
43                 None = 0,
44                 ControlStatePropagation = 1 << 0,
45                 ThemeChangeSensitive = 1 << 1,
46                 ThemeApplied = 1 << 2, // It is true when the view has valid style name or the platform theme has a component style for this view type.
47                                        // That indicates the view can have different styles by theme.
48                                        // Hence if the current state has ThemeApplied and ThemeChangeSensitive, the view will change its style by theme changing.
49                 ListeningThemeChangeEvent = 1 << 3,
50             };
51
52             private States states = ThemeManager.ApplicationThemeChangeSensitive ? States.ThemeChangeSensitive : States.None;
53             public ViewStyle viewStyle;
54             public ControlState controlStates = ControlState.Normal;
55             public ViewSelectorData selectorData;
56
57             public bool ControlStatePropagation
58             {
59                 get => ((states & States.ControlStatePropagation) != 0);
60                 set => SetOption(States.ControlStatePropagation, value);
61             }
62
63             public bool ThemeChangeSensitive
64             {
65                 get => ((states & States.ThemeChangeSensitive) != 0);
66                 set => SetOption(States.ThemeChangeSensitive, value);
67             }
68
69             public bool ThemeApplied
70             {
71                 get => ((states & States.ThemeApplied) != 0);
72                 set => SetOption(States.ThemeApplied, value);
73             }
74
75             public bool ListeningThemeChangeEvent
76             {
77                 get => ((states & States.ListeningThemeChangeEvent) != 0);
78                 set => SetOption(States.ListeningThemeChangeEvent, value);
79             }
80
81             private void SetOption(States option, bool value)
82             {
83                 if (value) states |= option;
84                 else states &= ~option;
85             }
86         }
87
88         /// <summary>
89         /// The color mode of View.
90         /// This specifies whether the View uses its own color, or inherits its parent color.
91         /// The default is ColorMode.UseOwnMultiplyParentColor.
92         /// </summary>
93         internal ColorMode ColorMode
94         {
95             set
96             {
97                 SetColorMode(value);
98             }
99             get
100             {
101                 return GetColorMode();
102             }
103         }
104
105         internal LayoutLength SuggestedMinimumWidth
106         {
107             get
108             {
109                 float result = Interop.Actor.GetSuggestedMinimumWidth(SwigCPtr);
110                 if (NDalicPINVOKE.SWIGPendingException.Pending)
111                     throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112                 return new LayoutLength(result);
113             }
114         }
115
116         internal LayoutLength SuggestedMinimumHeight
117         {
118             get
119             {
120                 float result = Interop.Actor.GetSuggestedMinimumHeight(SwigCPtr);
121                 if (NDalicPINVOKE.SWIGPendingException.Pending)
122                     throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123                 return new LayoutLength(result);
124             }
125         }
126
127         internal float WorldPositionX
128         {
129             get
130             {
131
132                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.WorldPositionX);
133             }
134         }
135
136         internal float WorldPositionY
137         {
138             get
139             {
140
141                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.WorldPositionY);
142             }
143         }
144
145         internal float WorldPositionZ
146         {
147             get
148             {
149
150                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.WorldPositionZ);
151             }
152         }
153
154         internal bool FocusState
155         {
156             get
157             {
158                 return IsKeyboardFocusable();
159             }
160             set
161             {
162                 SetKeyboardFocusable(value);
163             }
164         }
165
166         internal void SetLayout(LayoutItem layout)
167         {
168             LayoutCount++;
169
170             this.layout = layout;
171             this.layout?.AttachToOwner(this);
172             this.layout?.RequestLayout();
173         }
174
175         internal void AttachTransitionsToChildren(LayoutTransition transition)
176         {
177             // Iterate children, adding the transition unless a transition
178             // for the same condition and property has already been
179             // explicitly added.
180             foreach (View view in Children)
181             {
182                 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
183             }
184         }
185
186         internal float ParentOriginX
187         {
188             get
189             {
190
191                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.ParentOriginX);
192             }
193             set
194             {
195
196                 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.WorldPositionX, value);
197                 NotifyPropertyChanged();
198             }
199         }
200
201         internal float ParentOriginY
202         {
203             get
204             {
205
206                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.ParentOriginY);
207             }
208             set
209             {
210
211                 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.ParentOriginY, value);
212                 NotifyPropertyChanged();
213             }
214         }
215
216         internal float ParentOriginZ
217         {
218             get
219             {
220
221                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.ParentOriginZ);
222             }
223             set
224             {
225
226                 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.ParentOriginZ, value);
227                 NotifyPropertyChanged();
228             }
229         }
230
231         internal float PivotPointX
232         {
233             get
234             {
235
236                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.AnchorPointX);
237             }
238             set
239             {
240
241                 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.AnchorPointX, value);
242             }
243         }
244
245         internal float PivotPointY
246         {
247             get
248             {
249
250                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.AnchorPointY);
251             }
252             set
253             {
254
255                 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.AnchorPointY, value);
256             }
257         }
258
259         internal float PivotPointZ
260         {
261             get
262             {
263
264                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.AnchorPointZ);
265             }
266             set
267             {
268
269                 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.AnchorPointZ, value);
270             }
271         }
272
273         internal Matrix WorldMatrix
274         {
275             get
276             {
277                 Matrix returnValue = new Matrix();
278                 PropertyValue wordMatrix = GetProperty(View.Property.WorldMatrix);
279                 wordMatrix?.Get(returnValue);
280                 wordMatrix?.Dispose();
281                 return returnValue;
282             }
283         }
284
285         /// <summary>
286         /// The number of layouts including view's layout and children's layouts.
287         /// This can be used to set/unset Process callback to calculate Layout.
288         /// </summary>
289         internal int LayoutCount
290         {
291             get
292             {
293                 return layoutCount;
294             }
295
296             set
297             {
298                 if (layoutCount == value) return;
299
300                 if (value < 0) throw new global::System.ArgumentOutOfRangeException(nameof(LayoutCount), "LayoutCount(" + LayoutCount + ") should not be less than zero");
301
302                 int diff = value - layoutCount;
303                 layoutCount = value;
304
305                 if (InternalParent != null)
306                 {
307                     var parentView = InternalParent as View;
308                     if (parentView != null)
309                     {
310                         parentView.LayoutCount += diff;
311                     }
312                     else
313                     {
314                         var parentLayer = InternalParent as Layer;
315                         if (parentLayer != null)
316                         {
317                             parentLayer.LayoutCount += diff;
318                         }
319                     }
320                 }
321             }
322         }
323
324         /// <summary>
325         /// Indicates that this View should listen Touch event to handle its ControlState.
326         /// </summary>
327         private bool enableControlState = false;
328
329         private int LeftFocusableViewId
330         {
331             get
332             {
333
334                 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.LeftFocusableViewId);
335             }
336             set
337             {
338
339                 Object.InternalSetPropertyInt(SwigCPtr, View.Property.LeftFocusableViewId, value);
340             }
341         }
342
343         private int RightFocusableViewId
344         {
345             get
346             {
347
348                 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.RightFocusableViewId);
349             }
350             set
351             {
352
353                 Object.InternalSetPropertyInt(SwigCPtr, View.Property.RightFocusableViewId, value);
354             }
355         }
356
357         private int UpFocusableViewId
358         {
359             get
360             {
361
362                 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.UpFocusableViewId);
363             }
364             set
365             {
366
367                 Object.InternalSetPropertyInt(SwigCPtr, View.Property.UpFocusableViewId, value);
368             }
369         }
370
371         private int DownFocusableViewId
372         {
373             get
374             {
375
376                 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.DownFocusableViewId);
377             }
378             set
379             {
380
381                 Object.InternalSetPropertyInt(SwigCPtr, View.Property.DownFocusableViewId, value);
382             }
383         }
384
385         private int ClockwiseFocusableViewId
386         {
387             get
388             {
389
390                 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.ClockwiseFocusableViewId);
391             }
392             set
393             {
394
395                 Object.InternalSetPropertyInt(SwigCPtr, View.Property.ClockwiseFocusableViewId, value);
396             }
397         }
398
399         private int CounterClockwiseFocusableViewId
400         {
401             get
402             {
403
404                 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.CounterClockwiseFocusableViewId);
405             }
406             set
407             {
408
409                 Object.InternalSetPropertyInt(SwigCPtr, View.Property.CounterClockwiseFocusableViewId, value);
410             }
411         }
412
413         internal string GetName()
414         {
415             string ret = Interop.Actor.GetName(SwigCPtr);
416             if (NDalicPINVOKE.SWIGPendingException.Pending)
417                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418             return ret;
419         }
420
421         internal void SetName(string name)
422         {
423             Interop.Actor.SetName(SwigCPtr, name);
424             if (NDalicPINVOKE.SWIGPendingException.Pending)
425                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
426         }
427
428         internal uint GetId()
429         {
430             uint ret = Interop.Actor.GetId(SwigCPtr);
431             if (NDalicPINVOKE.SWIGPendingException.Pending)
432                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
433             return ret;
434         }
435
436         internal bool IsRoot()
437         {
438             bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
439             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
440             return ret;
441         }
442
443         internal bool OnWindow()
444         {
445             bool ret = Interop.Actor.OnStage(SwigCPtr);
446             if (NDalicPINVOKE.SWIGPendingException.Pending)
447                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
448             return ret;
449         }
450
451         internal View FindChildById(uint id)
452         {
453             //to fix memory leak issue, match the handle count with native side.
454             IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
455             View ret = this.GetInstanceSafely<View>(cPtr);
456             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
457             return ret;
458         }
459
460         internal override View FindCurrentChildById(uint id)
461         {
462             return FindChildById(id);
463         }
464
465         internal void SetParentOrigin(Position origin)
466         {
467             Interop.ActorInternal.SetParentOrigin(SwigCPtr, Position.getCPtr(origin));
468             if (NDalicPINVOKE.SWIGPendingException.Pending)
469                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
470         }
471
472         internal Position GetCurrentParentOrigin()
473         {
474
475             if(internalCurrentParentOrigin == null)
476             {
477                 internalCurrentParentOrigin = new Position(0, 0, 0);
478             }
479
480             Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.ParentOrigin, internalCurrentParentOrigin.SwigCPtr);
481
482             if (NDalicPINVOKE.SWIGPendingException.Pending)
483             {
484                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
485             }
486             return internalCurrentParentOrigin;
487         }
488
489         internal void SetAnchorPoint(Position anchorPoint)
490         {
491             Interop.Actor.SetAnchorPoint(SwigCPtr, Position.getCPtr(anchorPoint));
492             if (NDalicPINVOKE.SWIGPendingException.Pending)
493                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
494         }
495
496         internal Position GetCurrentAnchorPoint()
497         {
498
499             if(internalCurrentAnchorPoint == null)
500             {
501                 internalCurrentAnchorPoint = new Position(0, 0, 0);
502             }
503
504             Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.AnchorPoint, internalCurrentAnchorPoint.SwigCPtr);
505
506             if (NDalicPINVOKE.SWIGPendingException.Pending)
507             {
508                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
509             }
510             return internalCurrentAnchorPoint;
511         }
512
513         internal void SetSize(float width, float height)
514         {
515             Interop.ActorInternal.SetSize(SwigCPtr, width, height);
516             if (NDalicPINVOKE.SWIGPendingException.Pending)
517                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
518         }
519
520         internal void SetSize(float width, float height, float depth)
521         {
522             Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
523             if (NDalicPINVOKE.SWIGPendingException.Pending)
524                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
525         }
526
527         internal void SetSize(Vector2 size)
528         {
529             Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
530             if (NDalicPINVOKE.SWIGPendingException.Pending)
531                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
532         }
533
534         internal void SetSize(Vector3 size)
535         {
536             Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
537             if (NDalicPINVOKE.SWIGPendingException.Pending)
538                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
539         }
540
541         internal Vector3 GetTargetSize()
542         {
543
544             if(internalTargetSize == null)
545             {
546                 internalTargetSize = new Vector3(0, 0, 0);
547             }
548             
549             Interop.ActorInternal.RetrieveTargetSize(SwigCPtr, internalTargetSize.SwigCPtr);
550             
551             if (NDalicPINVOKE.SWIGPendingException.Pending)
552             {
553                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
554             }
555             return internalTargetSize;
556         }
557
558         internal Size2D GetCurrentSize()
559         {
560
561             if(internalCurrentSize == null)
562             {
563                 internalCurrentSize = new Size2D(0, 0);
564             }
565             
566             Interop.ActorInternal.RetrieveCurrentPropertyVector2ActualVector3(SwigCPtr, Property.SIZE, internalCurrentSize.SwigCPtr);
567
568             if (NDalicPINVOKE.SWIGPendingException.Pending)
569             {
570                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
571             }
572             return internalCurrentSize;
573         }
574
575         internal Size2D GetCurrentSizeFloat()
576         {
577             Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
578             if (NDalicPINVOKE.SWIGPendingException.Pending)
579                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
580             return ret;
581         }
582
583         /// <summary>
584         /// GetNaturalSize() function behaviour can be changed for each subclass of View.
585         /// So we make GetNaturalSize() function virtual, and make subclass can define it's owned logic
586         /// </summary>
587         internal virtual Vector3 GetNaturalSize()
588         {
589             Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
590             if (NDalicPINVOKE.SWIGPendingException.Pending)
591                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
592             return ret;
593         }
594
595         internal void SetX(float x)
596         {
597             Interop.ActorInternal.SetX(SwigCPtr, x);
598             if (NDalicPINVOKE.SWIGPendingException.Pending)
599                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
600         }
601
602         internal void SetY(float y)
603         {
604             Interop.ActorInternal.SetY(SwigCPtr, y);
605             if (NDalicPINVOKE.SWIGPendingException.Pending)
606                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
607         }
608
609         internal void SetZ(float z)
610         {
611             Interop.ActorInternal.SetZ(SwigCPtr, z);
612             if (NDalicPINVOKE.SWIGPendingException.Pending)
613                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
614         }
615
616         internal void TranslateBy(Vector3 distance)
617         {
618             Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
619             if (NDalicPINVOKE.SWIGPendingException.Pending)
620                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621         }
622
623         internal Position GetCurrentPosition()
624         {
625
626             if(internalCurrentPosition == null)
627             {
628                 internalCurrentPosition = new Position(0, 0, 0);
629             }
630             
631             Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, Property.POSITION, internalCurrentPosition.SwigCPtr);
632
633             if (NDalicPINVOKE.SWIGPendingException.Pending)
634             {
635                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
636             }
637             return internalCurrentPosition;
638         }
639         internal Vector3 GetCurrentWorldPosition()
640         {
641
642             if(internalCurrentWorldPosition == null)
643             {
644                 internalCurrentWorldPosition = new Vector3(0, 0, 0);
645             }
646             
647             Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.WorldPosition, internalCurrentWorldPosition.SwigCPtr);
648
649             if (NDalicPINVOKE.SWIGPendingException.Pending)
650             {
651                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
652             }
653             return internalCurrentWorldPosition;
654         }
655
656         internal Vector2 GetCurrentScreenPosition()
657         {
658
659             if(internalCurrentScreenPosition == null)
660             {
661                 internalCurrentScreenPosition = new Vector2(0, 0);
662             }
663
664             Object.InternalRetrievingPropertyVector2(SwigCPtr, View.Property.ScreenPosition, internalCurrentScreenPosition.SwigCPtr);
665
666             if (NDalicPINVOKE.SWIGPendingException.Pending)
667             {
668                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
669             }
670             return internalCurrentScreenPosition;
671         }
672
673         internal Vector4 GetCurrentScreenPositionSize()
674         {
675             Vector4 ret = new Vector4(Interop.Actor.CalculateScreenExtents(SwigCPtr), true);
676             if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
677             return ret;
678         }
679
680         internal void SetInheritPosition(bool inherit)
681         {
682             Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
683             if (NDalicPINVOKE.SWIGPendingException.Pending)
684                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
685         }
686
687         internal bool IsPositionInherited()
688         {
689             bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
690             if (NDalicPINVOKE.SWIGPendingException.Pending)
691                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
692             return ret;
693         }
694
695         internal void SetOrientation(Degree angle, Vector3 axis)
696         {
697             Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
698             if (NDalicPINVOKE.SWIGPendingException.Pending)
699                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
700         }
701
702         internal void SetOrientation(Radian angle, Vector3 axis)
703         {
704             Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
705             if (NDalicPINVOKE.SWIGPendingException.Pending)
706                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
707         }
708
709         internal void SetOrientation(Rotation orientation)
710         {
711             Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
712             if (NDalicPINVOKE.SWIGPendingException.Pending)
713                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
714         }
715
716         internal Rotation GetCurrentOrientation()
717         {
718             Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
719             if (NDalicPINVOKE.SWIGPendingException.Pending)
720                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
721             return ret;
722         }
723
724         internal void SetInheritOrientation(bool inherit)
725         {
726             Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
727             if (NDalicPINVOKE.SWIGPendingException.Pending)
728                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
729         }
730
731         internal bool IsOrientationInherited()
732         {
733             bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
734             if (NDalicPINVOKE.SWIGPendingException.Pending)
735                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
736             return ret;
737         }
738
739         internal Rotation GetCurrentWorldOrientation()
740         {
741             Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
742             if (NDalicPINVOKE.SWIGPendingException.Pending)
743                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
744             return ret;
745         }
746
747         internal void SetScale(float scale)
748         {
749             Interop.ActorInternal.SetScale(SwigCPtr, scale);
750             if (NDalicPINVOKE.SWIGPendingException.Pending)
751                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
752         }
753
754         internal void SetScale(float scaleX, float scaleY, float scaleZ)
755         {
756             Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
757             if (NDalicPINVOKE.SWIGPendingException.Pending)
758                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
759         }
760
761         internal void SetScale(Vector3 scale)
762         {
763             Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
764             if (NDalicPINVOKE.SWIGPendingException.Pending)
765                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
766         }
767
768         internal Vector3 GetCurrentScale()
769         {
770
771             if(internalCurrentScale == null)
772             {
773                 internalCurrentScale = new Vector3(0, 0, 0);
774             }
775             
776             Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.SCALE, internalCurrentScale.SwigCPtr);
777
778             if (NDalicPINVOKE.SWIGPendingException.Pending)
779             {
780                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
781             }
782             return internalCurrentScale;
783         }
784
785         internal Vector3 GetCurrentWorldScale()
786         {
787
788             if(internalCurrentWorldScale == null)
789             {
790                 internalCurrentWorldScale = new Vector3(0, 0, 0);
791             }
792             
793             Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.WorldScale, internalCurrentWorldScale.SwigCPtr);
794
795             if (NDalicPINVOKE.SWIGPendingException.Pending)
796             {
797                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
798             }
799             return internalCurrentWorldScale;
800         }
801
802         internal void SetInheritScale(bool inherit)
803         {
804             Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
805             if (NDalicPINVOKE.SWIGPendingException.Pending)
806                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
807         }
808
809         internal bool IsScaleInherited()
810         {
811             bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
812             if (NDalicPINVOKE.SWIGPendingException.Pending)
813                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
814             return ret;
815         }
816
817         internal Matrix GetCurrentWorldMatrix()
818         {
819             Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
820             if (NDalicPINVOKE.SWIGPendingException.Pending)
821                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
822             return ret;
823         }
824
825         internal void SetVisible(bool visible)
826         {
827             Interop.Actor.SetVisible(SwigCPtr, visible);
828             if (NDalicPINVOKE.SWIGPendingException.Pending)
829                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
830         }
831
832         /// <summary>
833         /// Retrieve the View's current Visibility.
834         /// </summary>
835         /// <remarks>
836         /// The <see cref="Visibility"/> property is set in the main thread, so it is not updated in real time when the value is changed in the render thread.
837         /// However, this method can get the current actual value updated in real time.
838         /// </remarks>
839         internal bool IsVisible()
840         {
841             bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
842             if (NDalicPINVOKE.SWIGPendingException.Pending)
843                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
844             return ret;
845         }
846
847         internal void SetOpacity(float opacity)
848         {
849             Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
850             if (NDalicPINVOKE.SWIGPendingException.Pending)
851                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
852         }
853
854         internal float GetCurrentOpacity()
855         {
856             float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
857             if (NDalicPINVOKE.SWIGPendingException.Pending)
858                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
859             return ret;
860         }
861
862         internal Vector4 GetCurrentColor()
863         {
864
865             if(internalCurrentColor == null)
866             {
867                 internalCurrentColor = new Vector4(0, 0, 0, 0);
868             }
869             
870             Interop.ActorInternal.RetrieveCurrentPropertyVector4(SwigCPtr, Interop.ActorProperty.ColorGet(), internalCurrentColor.SwigCPtr);
871
872             if (NDalicPINVOKE.SWIGPendingException.Pending)
873             {
874                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
875             }
876             return internalCurrentColor;
877         }
878         internal ColorMode GetColorMode()
879         {
880             ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
881             if (NDalicPINVOKE.SWIGPendingException.Pending)
882                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
883             return ret;
884         }
885
886         internal Vector4 GetCurrentWorldColor()
887         {
888
889             if(internalCurrentWorldColor == null)
890             {
891                 internalCurrentWorldColor = new Vector4(0, 0, 0, 0);
892             }
893             
894             Interop.ActorInternal.RetrieveCurrentPropertyVector4(SwigCPtr, Property.WorldColor, internalCurrentWorldColor.SwigCPtr);
895
896             if (NDalicPINVOKE.SWIGPendingException.Pending)
897             {
898                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
899             }
900             return internalCurrentWorldColor;
901         }
902
903         internal void SetDrawMode(DrawModeType drawMode)
904         {
905             Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
906             if (NDalicPINVOKE.SWIGPendingException.Pending)
907                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
908         }
909
910         internal DrawModeType GetDrawMode()
911         {
912             DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
913             if (NDalicPINVOKE.SWIGPendingException.Pending)
914                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
915             return ret;
916         }
917
918         internal void SetKeyboardFocusable(bool focusable)
919         {
920             Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
921             if (NDalicPINVOKE.SWIGPendingException.Pending)
922                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
923         }
924
925         internal bool IsKeyboardFocusable()
926         {
927             bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
928             if (NDalicPINVOKE.SWIGPendingException.Pending)
929                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
930             return ret;
931         }
932
933         internal void SetKeyboardFocusableChildren(bool focusable)
934         {
935             Interop.ActorInternal.SetKeyboardFocusableChildren(SwigCPtr, focusable);
936             if (NDalicPINVOKE.SWIGPendingException.Pending)
937                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
938         }
939
940         internal bool AreChildrenKeyBoardFocusable()
941         {
942             bool ret = Interop.ActorInternal.AreChildrenKeyBoardFocusable(SwigCPtr);
943             if (NDalicPINVOKE.SWIGPendingException.Pending)
944                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
945             return ret;
946         }
947
948         internal void SetFocusableInTouch(bool enabled)
949         {
950             Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled);
951             if (NDalicPINVOKE.SWIGPendingException.Pending)
952                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
953         }
954
955         internal bool IsFocusableInTouch()
956         {
957             bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr);
958             if (NDalicPINVOKE.SWIGPendingException.Pending)
959                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
960             return ret;
961         }
962
963         internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
964         {
965             Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
966             if (NDalicPINVOKE.SWIGPendingException.Pending)
967                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
968         }
969
970         internal ResizePolicyType GetResizePolicy(DimensionType dimension)
971         {
972             ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
973             if (NDalicPINVOKE.SWIGPendingException.Pending)
974                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
975             return ret;
976         }
977
978         internal Vector3 GetSizeModeFactor()
979         {
980
981                 if (internalSizeModeFactor == null)
982                 {
983                     internalSizeModeFactor = new Vector3(OnSizeModeFactorChanged, 0, 0, 0);
984                 }
985                 Object.InternalRetrievingPropertyVector3(SwigCPtr, View.Property.SizeModeFactor, internalSizeModeFactor.SwigCPtr);
986                 return internalSizeModeFactor;
987         }
988
989         internal void SetMinimumSize(Vector2 size)
990         {
991             Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
992             if (NDalicPINVOKE.SWIGPendingException.Pending)
993                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
994         }
995
996         internal Vector2 GetMinimumSize()
997         {
998
999             if (internalMinimumSize == null)
1000             {
1001                 internalMinimumSize = new Size2D(OnMinimumSizeChanged, 0, 0);
1002             }
1003             Object.InternalRetrievingPropertyVector2(SwigCPtr, View.Property.MinimumSize, internalMinimumSize.SwigCPtr);
1004             return internalMinimumSize;
1005         }
1006
1007         internal void SetMaximumSize(Vector2 size)
1008         {
1009             Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
1010             if (NDalicPINVOKE.SWIGPendingException.Pending)
1011                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1012         }
1013
1014         internal Vector2 GetMaximumSize()
1015         {
1016
1017             if (internalMaximumSize == null)
1018             {
1019                 internalMaximumSize = new Size2D(OnMaximumSizeChanged, 0, 0);
1020             }
1021             Object.InternalRetrievingPropertyVector2(SwigCPtr, View.Property.MaximumSize, internalMaximumSize.SwigCPtr);
1022             return internalMaximumSize;
1023         }
1024
1025         internal int GetHierarchyDepth()
1026         {
1027             int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
1028             if (NDalicPINVOKE.SWIGPendingException.Pending)
1029                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1030             return ret;
1031         }
1032
1033         internal uint GetRendererCount()
1034         {
1035             uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
1036             if (NDalicPINVOKE.SWIGPendingException.Pending)
1037                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1038             return ret;
1039         }
1040
1041         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
1042         {
1043             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1044         }
1045
1046         internal bool IsTopLevelView()
1047         {
1048             if (GetParent() is Layer)
1049             {
1050                 return true;
1051             }
1052             return false;
1053         }
1054
1055         /// <summary>
1056         /// Check whether Current view don't has BackgroundVisual or not.
1057         /// Some API (like Animation, Borderline) required non-empty backgrounds.
1058         /// </summary>
1059         internal bool IsBackgroundEmpty()
1060         {
1061
1062             int visualType = (int)Visual.Type.Invalid;
1063             Interop.View.InternalRetrievingVisualPropertyInt(this.SwigCPtr, Property.BACKGROUND, Visual.Property.Type, out visualType);
1064             return visualType == (int)Visual.Type.Invalid;
1065         }
1066
1067         internal void SetKeyInputFocus()
1068         {
1069             Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
1070             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1071         }
1072
1073         internal void ClearKeyInputFocus()
1074         {
1075             Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
1076             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1077         }
1078
1079         internal PinchGestureDetector GetPinchGestureDetector()
1080         {
1081             PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
1082             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1083             return ret;
1084         }
1085
1086         internal PanGestureDetector GetPanGestureDetector()
1087         {
1088             PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
1089             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1090             return ret;
1091         }
1092
1093         internal TapGestureDetector GetTapGestureDetector()
1094         {
1095             TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
1096             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1097             return ret;
1098         }
1099
1100         internal LongPressGestureDetector GetLongPressGestureDetector()
1101         {
1102             LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
1103             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1104             return ret;
1105         }
1106
1107         internal IntPtr GetPtrfromView()
1108         {
1109             return (IntPtr)SwigCPtr;
1110         }
1111
1112         internal void RemoveChild(View child)
1113         {
1114             // If the view had focus, it clears focus.
1115             if (child == FocusManager.Instance.GetCurrentFocusView())
1116             {
1117                 FocusManager.Instance.ClearFocus();
1118             }
1119             // Do actual child removal
1120             Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1121             if (NDalicPINVOKE.SWIGPendingException.Pending)
1122                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1123
1124             Children.Remove(child);
1125             child.InternalParent = null;
1126             LayoutCount -= child.LayoutCount;
1127
1128             OnChildRemoved(child);
1129             if (ChildRemoved != null)
1130             {
1131                 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1132                 {
1133                     Removed = child
1134                 };
1135                 ChildRemoved(this, e);
1136             }
1137         }
1138
1139         /// <summary>
1140         /// Removes the layout from this View.
1141         /// </summary>
1142         internal void ResetLayout()
1143         {
1144             LayoutCount--;
1145
1146             layout = null;
1147         }
1148
1149         internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1150         {
1151             return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1152         }
1153
1154         /// TODO open as a protected level
1155         internal virtual void ApplyCornerRadius()
1156         {
1157             if (backgroundExtraData == null) return;
1158
1159
1160             // Update corner radius properties to background and shadow by ActionUpdateProperty
1161             if (backgroundExtraData.CornerRadius != null)
1162             {
1163                 Interop.View.InternalUpdateVisualPropertyVector4(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.CornerRadius, Vector4.getCPtr(backgroundExtraData.CornerRadius));
1164                 Interop.View.InternalUpdateVisualPropertyVector4(this.SwigCPtr, View.Property.SHADOW, Visual.Property.CornerRadius, Vector4.getCPtr(backgroundExtraData.CornerRadius));
1165             }
1166             Interop.View.InternalUpdateVisualPropertyInt(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.CornerRadiusPolicy, (int)backgroundExtraData.CornerRadiusPolicy);
1167             Interop.View.InternalUpdateVisualPropertyInt(this.SwigCPtr, View.Property.SHADOW, Visual.Property.CornerRadiusPolicy, (int)backgroundExtraData.CornerRadiusPolicy);
1168         }
1169
1170         /// TODO open as a protected level
1171         internal virtual void ApplyBorderline()
1172         {
1173             if (backgroundExtraData == null) return;
1174
1175
1176             // ActionUpdateProperty works well only if BACKGROUND visual setup before.
1177             // If view don't have BACKGROUND visual, we set transparent background color in default.
1178             if (IsBackgroundEmpty())
1179             {
1180                 // BACKGROUND visual doesn't exist.
1181                 SetBackgroundColor(Color.Transparent);
1182                 // SetBackgroundColor function apply borderline internally.
1183                 // So we can just return now.
1184                 return;
1185             }
1186
1187             // Update borderline properties to background by ActionUpdateProperty
1188             Interop.View.InternalUpdateVisualPropertyFloat(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.BorderlineWidth, backgroundExtraData.BorderlineWidth);
1189             Interop.View.InternalUpdateVisualPropertyVector4(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.BorderlineColor, Vector4.getCPtr(backgroundExtraData.BorderlineColor ?? Color.Black));
1190             Interop.View.InternalUpdateVisualPropertyFloat(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.BorderlineOffset, backgroundExtraData.BorderlineOffset);
1191         }
1192
1193         /// <summary>
1194         /// Get selector value from the triggerable selector or related property.
1195         /// </summary>
1196         internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1197         {
1198             var selector = triggerableSelector?.Get();
1199             if (selector != null)
1200             {
1201                 return selector;
1202             }
1203
1204             var value = (T)GetValue(relatedProperty);
1205             return value == null ? null : new Selector<T>(value);
1206         }
1207
1208         internal void SetThemeApplied()
1209         {
1210             if (themeData == null) themeData = new ThemeData();
1211             themeData.ThemeApplied = true;
1212
1213             if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
1214             {
1215                 themeData.ListeningThemeChangeEvent = true;
1216                 ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
1217             }
1218         }
1219
1220         /// <summary>
1221         /// you can override it to clean-up your own resources.
1222         /// </summary>
1223         /// <param name="type">DisposeTypes</param>
1224         /// <since_tizen> 3 </since_tizen>
1225         protected override void Dispose(DisposeTypes type)
1226         {
1227             if (disposed)
1228             {
1229                 return;
1230             }
1231
1232             disposeDebugging(type);
1233
1234             //_mergedStyle = null;
1235
1236             internalMaximumSize?.Dispose();
1237             internalMaximumSize = null;
1238             internalMinimumSize?.Dispose();
1239             internalMinimumSize = null;
1240             internalMargin?.Dispose();
1241             internalMargin = null;
1242             internalPadding?.Dispose();
1243             internalPadding = null;
1244             internalSizeModeFactor?.Dispose();
1245             internalSizeModeFactor = null;
1246             internalCellIndex?.Dispose();
1247             internalCellIndex = null;
1248             internalBackgroundColor?.Dispose();
1249             internalBackgroundColor = null;
1250             internalColor?.Dispose();
1251             internalColor = null;
1252             internalPivotPoint?.Dispose();
1253             internalPivotPoint = null;
1254             internalPosition?.Dispose();
1255             internalPosition = null;
1256             internalPosition2D?.Dispose();
1257             internalPosition2D = null;
1258             internalScale?.Dispose();
1259             internalScale = null;
1260             internalSize?.Dispose();
1261             internalSize = null;
1262             internalSize2D?.Dispose();
1263             internalSize2D = null;
1264
1265             panGestureDetector?.Dispose();
1266             panGestureDetector = null;
1267             longGestureDetector?.Dispose();
1268             longGestureDetector = null;
1269             pinchGestureDetector?.Dispose();
1270             pinchGestureDetector = null;
1271             tapGestureDetector?.Dispose();
1272             tapGestureDetector = null;
1273             rotationGestureDetector?.Dispose();
1274             rotationGestureDetector = null;
1275
1276
1277             internalCurrentParentOrigin?.Dispose();
1278             internalCurrentParentOrigin = null;
1279             internalCurrentAnchorPoint?.Dispose();
1280             internalCurrentAnchorPoint = null;
1281             internalTargetSize?.Dispose();
1282             internalTargetSize = null;
1283             internalCurrentSize?.Dispose();
1284             internalCurrentSize = null;
1285             internalNaturalSize?.Dispose();
1286             internalNaturalSize = null;
1287             internalCurrentPosition?.Dispose();
1288             internalCurrentPosition = null;
1289             internalCurrentWorldPosition?.Dispose();
1290             internalCurrentWorldPosition = null;
1291             internalCurrentScale?.Dispose();
1292             internalCurrentScale = null;
1293             internalCurrentWorldScale?.Dispose();
1294             internalCurrentWorldScale = null;
1295             internalCurrentColor?.Dispose();
1296             internalCurrentColor = null;
1297             internalCurrentWorldColor?.Dispose();
1298             internalCurrentWorldColor = null;
1299             internalSizeModeFactor?.Dispose();
1300             internalSizeModeFactor = null;
1301             internalCurrentScreenPosition?.Dispose();
1302             internalCurrentScreenPosition = null;
1303
1304             if (type == DisposeTypes.Explicit)
1305             {
1306                 //Called by User
1307                 //Release your own managed resources here.
1308                 //You should release all of your own disposable objects here.
1309                 if (themeData != null)
1310                 {
1311                     themeData.selectorData?.Reset(this);
1312                     if (themeData.ListeningThemeChangeEvent)
1313                     {
1314                         ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1315                     }
1316                 }
1317                 if (widthConstraint != null)
1318                 {
1319                     widthConstraint.Remove();
1320                     widthConstraint.Dispose();
1321                 }
1322                 if (heightConstraint != null)
1323                 {
1324                     heightConstraint.Remove();
1325                     heightConstraint.Dispose();
1326                 }
1327             }
1328
1329             //Release your own unmanaged resources here.
1330             //You should not access any managed member here except static instance.
1331             //because the execution order of Finalizes is non-deterministic.
1332
1333             DisConnectFromSignals();
1334
1335             foreach (View view in Children)
1336             {
1337                 view.InternalParent = null;
1338             }
1339
1340             LayoutCount = 0;
1341
1342             NUILog.Debug($"[Dispose] View.Dispose({type}) END");
1343             NUILog.Debug($"=============================");
1344
1345             base.Dispose(type);
1346         }
1347
1348         /// This will not be public opened.
1349         [EditorBrowsable(EditorBrowsableState.Never)]
1350         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1351         {
1352             Interop.View.DeleteView(swigCPtr);
1353         }
1354
1355         /// <summary>
1356         /// The touch event handler for ControlState.
1357         /// Please change ControlState value by touch state if needed.
1358         /// </summary>
1359         /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1360         [EditorBrowsable(EditorBrowsableState.Never)]
1361         protected virtual bool HandleControlStateOnTouch(Touch touch)
1362         {
1363             if (touch == null)
1364             {
1365                 throw new global::System.ArgumentNullException(nameof(touch));
1366             }
1367
1368             switch (touch.GetState(0))
1369             {
1370                 case PointStateType.Down:
1371                     ControlState += ControlState.Pressed;
1372                     break;
1373                 case PointStateType.Interrupted:
1374                 case PointStateType.Up:
1375                     if (ControlState.Contains(ControlState.Pressed))
1376                     {
1377                         ControlState -= ControlState.Pressed;
1378                     }
1379                     break;
1380                 default:
1381                     break;
1382             }
1383             return false;
1384         }
1385
1386         /// <summary>
1387         /// Internal callback of enabled property changes.
1388         /// Inherited view can override this method to implements enabled property changes.
1389         /// </summary>
1390         [EditorBrowsable(EditorBrowsableState.Never)]
1391         protected virtual void OnEnabled(bool enabled)
1392         {
1393             if (enabled)
1394             {
1395                 if (State == View.States.Disabled)
1396                 {
1397                     State = View.States.Normal;
1398                 }
1399                 if (enableControlState)
1400                 {
1401                     ControlState -= ControlState.Disabled;
1402                 }
1403             }
1404             else
1405             {
1406                 State = View.States.Disabled;
1407                 if (enableControlState)
1408                 {
1409                     ControlState += ControlState.Disabled;
1410                 }
1411             }
1412         }
1413
1414
1415         private void DisConnectFromSignals()
1416         {
1417             if (HasBody() == false)
1418             {
1419                 NUILog.Debug($"[Dispose] DisConnectFromSignals() No native body! No need to Disconnect Signals!");
1420                 return;
1421             }
1422             NUILog.Debug($"[Dispose] DisConnectFromSignals START");
1423             NUILog.Debug($"[Dispose] View.DisConnectFromSignals() type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1424             NUILog.Debug($"[Dispose] ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1425
1426             if (onRelayoutEventCallback != null)
1427             {
1428                 NUILog.Debug($"[Dispose] onRelayoutEventCallback");
1429
1430                 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(GetBaseHandleCPtrHandleRef), false);
1431                 signal?.Disconnect(onRelayoutEventCallback);
1432                 onRelayoutEventCallback = null;
1433             }
1434
1435             if (offWindowEventCallback != null)
1436             {
1437                 NUILog.Debug($"[Dispose] offWindowEventCallback");
1438
1439                 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(GetBaseHandleCPtrHandleRef), false);
1440                 signal?.Disconnect(offWindowEventCallback);
1441                 offWindowEventCallback = null;
1442             }
1443
1444             if (onWindowEventCallback != null)
1445             {
1446                 NUILog.Debug($"[Dispose] onWindowEventCallback");
1447
1448                 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1449                 signal?.Disconnect(onWindowEventCallback);
1450                 onWindowEventCallback = null;
1451             }
1452
1453             if (wheelEventCallback != null)
1454             {
1455                 NUILog.Debug($"[Dispose] wheelEventCallback");
1456
1457                 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(GetBaseHandleCPtrHandleRef), false);
1458                 signal?.Disconnect(wheelEventCallback);
1459                 wheelEventCallback = null;
1460             }
1461
1462             if (hoverEventCallback != null)
1463             {
1464                 NUILog.Debug($"[Dispose] hoverEventCallback");
1465
1466                 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(GetBaseHandleCPtrHandleRef), false);
1467                 signal?.Disconnect(hoverEventCallback);
1468                 hoverEventCallback = null;
1469             }
1470
1471             if (hitTestResultDataCallback != null)
1472             {
1473                 NUILog.Debug($"[Dispose] hitTestResultDataCallback");
1474
1475                 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorHitTestResultSignal(GetBaseHandleCPtrHandleRef), false);
1476                 signal?.Disconnect(hitTestResultDataCallback);
1477                 hitTestResultDataCallback = null;
1478             }
1479
1480
1481             if (interceptTouchDataCallback != null)
1482             {
1483                 NUILog.Debug($"[Dispose] interceptTouchDataCallback");
1484
1485                 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(GetBaseHandleCPtrHandleRef), false);
1486                 signal?.Disconnect(interceptTouchDataCallback);
1487                 interceptTouchDataCallback = null;
1488             }
1489
1490             if (touchDataCallback != null)
1491             {
1492                 NUILog.Debug($"[Dispose] touchDataCallback");
1493
1494                 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(GetBaseHandleCPtrHandleRef), false);
1495                 signal?.Disconnect(touchDataCallback);
1496                 touchDataCallback = null;
1497             }
1498
1499             if (ResourcesLoadedCallback != null)
1500             {
1501                 NUILog.Debug($"[Dispose] ResourcesLoadedCallback");
1502
1503                 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1504                 signal?.Disconnect(ResourcesLoadedCallback);
1505                 ResourcesLoadedCallback = null;
1506             }
1507
1508             if (keyCallback != null)
1509             {
1510                 NUILog.Debug($"[Dispose] keyCallback");
1511
1512                 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(GetBaseHandleCPtrHandleRef), false);
1513                 signal?.Disconnect(keyCallback);
1514                 keyCallback = null;
1515             }
1516
1517             if (keyInputFocusLostCallback != null)
1518             {
1519                 NUILog.Debug($"[Dispose] keyInputFocusLostCallback");
1520
1521                 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(GetBaseHandleCPtrHandleRef), false);
1522                 signal?.Disconnect(keyInputFocusLostCallback);
1523                 keyInputFocusLostCallback = null;
1524                 keyInputFocusLostEventHandler = null;
1525             }
1526
1527             if (keyInputFocusGainedCallback != null)
1528             {
1529                 NUILog.Debug($"[Dispose] keyInputFocusGainedCallback");
1530
1531                 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(GetBaseHandleCPtrHandleRef), false);
1532                 signal?.Disconnect(keyInputFocusGainedCallback);
1533                 keyInputFocusGainedCallback = null;
1534                 keyInputFocusGainedEventHandler = null;
1535             }
1536
1537             if (backgroundResourceLoadedCallback != null)
1538             {
1539                 NUILog.Debug($"[Dispose] backgroundResourceLoadedCallback");
1540
1541                 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1542                 signal?.Disconnect(backgroundResourceLoadedCallback);
1543                 backgroundResourceLoadedCallback = null;
1544             }
1545
1546             if (onWindowSendEventCallback != null)
1547             {
1548                 NUILog.Debug($"[Dispose] onWindowSendEventCallback");
1549
1550                 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1551                 signal?.Disconnect(onWindowSendEventCallback);
1552                 onWindowSendEventCallback = null;
1553             }
1554             NUILog.Debug($"[Dispose] DisConnectFromSignals END");
1555         }
1556
1557         /// <summary>
1558         /// Apply initial style to the view.
1559         /// </summary>
1560         [EditorBrowsable(EditorBrowsableState.Never)]
1561         protected virtual void InitializeStyle(ViewStyle style = null)
1562         {
1563 #if PROFILE_TV
1564             Tizen.Log.Info("NUI", $"InitializeStyle() just return here in PROFILE_TV");
1565             return;
1566 #endif
1567             var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
1568             if (style == null)
1569             {
1570                 ApplyStyle(initialStyle);
1571             }
1572             else
1573             {
1574                 var refinedStyle = style;
1575                 if (style.IncludeDefaultStyle)
1576                 {
1577                     refinedStyle = initialStyle?.Merge(style);
1578                 }
1579                 ApplyStyle(refinedStyle);
1580             }
1581
1582             // Listen theme change event if needs.
1583             if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
1584             {
1585                 SetThemeApplied();
1586             }
1587         }
1588
1589         private View ConvertIdToView(uint id)
1590         {
1591             View view = GetParent()?.FindCurrentChildById(id);
1592
1593             //If we can't find the parent's children, find in the top layer.
1594             if (!view)
1595             {
1596                 Container parent = GetParent();
1597                 while ((parent is View) && (parent != null))
1598                 {
1599                     parent = parent.GetParent();
1600                     if (parent is Layer)
1601                     {
1602                         view = parent.FindCurrentChildById(id);
1603                         break;
1604                     }
1605                 }
1606             }
1607
1608             return view;
1609         }
1610
1611         private void OnScaleChanged(float x, float y, float z)
1612         {
1613             Scale = new Vector3(x, y, z);
1614         }
1615
1616         private void OnBackgroundColorChanged(float r, float g, float b, float a)
1617         {
1618             BackgroundColor = new Color(r, g, b, a);
1619         }
1620
1621         private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1622         {
1623             Padding = new Extents(start, end, top, bottom);
1624         }
1625
1626         private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1627         {
1628             Margin = new Extents(start, end, top, bottom);
1629         }
1630
1631         private void OnAnchorPointChanged(float x, float y, float z)
1632         {
1633             AnchorPoint = new Position(x, y, z);
1634         }
1635
1636         private void OnCellIndexChanged(float x, float y)
1637         {
1638             CellIndex = new Vector2(x, y);
1639         }
1640
1641         private void OnFlexMarginChanged(float x, float y, float z, float w)
1642         {
1643             FlexMargin = new Vector4(x, y, z, w);
1644         }
1645
1646         private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1647         {
1648             PaddingEX = new Extents(start, end, top, bottom);
1649         }
1650
1651         private void OnSizeModeFactorChanged(float x, float y, float z)
1652         {
1653             SizeModeFactor = new Vector3(x, y, z);
1654         }
1655
1656         private bool EmptyOnTouch(object target, TouchEventArgs args)
1657         {
1658             return false;
1659         }
1660
1661         [EditorBrowsable(EditorBrowsableState.Never)]
1662         protected virtual bool CheckResourceReady()
1663         {
1664             return true;
1665         }
1666
1667         private ViewSelectorData EnsureSelectorData()
1668         {
1669             if (themeData == null) themeData = new ThemeData();
1670
1671             return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());
1672         }
1673
1674         [Conditional("NUI_DISPOSE_DEBUG_ON")]
1675         private void disposeDebugging(DisposeTypes type)
1676         {
1677             DebugFileLogging.Instance.WriteLog($"View.Dispose({type}) START");
1678             DebugFileLogging.Instance.WriteLog($"type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1679             if (HasBody())
1680             {
1681                 DebugFileLogging.Instance.WriteLog($"ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1682             }
1683             else
1684             {
1685                 DebugFileLogging.Instance.WriteLog($"has no native body!");
1686             }
1687         }
1688
1689     }
1690 }