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