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