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