[NUI][AT-SPI] Singleton AccessibilityDelegate (#3899)
[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         internal Vector3 GetNaturalSize()
586         {
587             Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
588             if (NDalicPINVOKE.SWIGPendingException.Pending)
589                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
590             return ret;
591         }
592
593         internal void SetPosition(float x, float y)
594         {
595             Interop.ActorInternal.SetPosition(SwigCPtr, x, y);
596             if (NDalicPINVOKE.SWIGPendingException.Pending)
597                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
598         }
599
600         internal void SetPosition(float x, float y, float z)
601         {
602             Interop.ActorInternal.SetPosition(SwigCPtr, x, y, z);
603             if (NDalicPINVOKE.SWIGPendingException.Pending)
604                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
605         }
606
607         internal void SetPosition(Vector3 position)
608         {
609             Interop.ActorInternal.SetPosition(SwigCPtr, Vector3.getCPtr(position));
610             if (NDalicPINVOKE.SWIGPendingException.Pending)
611                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
612         }
613
614         internal void SetX(float x)
615         {
616             Interop.ActorInternal.SetX(SwigCPtr, x);
617             if (NDalicPINVOKE.SWIGPendingException.Pending)
618                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
619         }
620
621         internal void SetY(float y)
622         {
623             Interop.ActorInternal.SetY(SwigCPtr, y);
624             if (NDalicPINVOKE.SWIGPendingException.Pending)
625                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
626         }
627
628         internal void SetZ(float z)
629         {
630             Interop.ActorInternal.SetZ(SwigCPtr, z);
631             if (NDalicPINVOKE.SWIGPendingException.Pending)
632                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
633         }
634
635         internal void TranslateBy(Vector3 distance)
636         {
637             Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
638             if (NDalicPINVOKE.SWIGPendingException.Pending)
639                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
640         }
641
642         internal Position GetCurrentPosition()
643         {
644             Position ret = new Position(Interop.Actor.GetCurrentPosition(SwigCPtr), true);
645             if (NDalicPINVOKE.SWIGPendingException.Pending)
646                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
647             return ret;
648         }
649
650         internal Vector3 GetCurrentWorldPosition()
651         {
652             Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldPosition(SwigCPtr), true);
653             if (NDalicPINVOKE.SWIGPendingException.Pending)
654                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
655             return ret;
656         }
657
658         internal void SetInheritPosition(bool inherit)
659         {
660             Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
661             if (NDalicPINVOKE.SWIGPendingException.Pending)
662                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663         }
664
665         internal bool IsPositionInherited()
666         {
667             bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
668             if (NDalicPINVOKE.SWIGPendingException.Pending)
669                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
670             return ret;
671         }
672
673         internal void SetOrientation(Degree angle, Vector3 axis)
674         {
675             Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
676             if (NDalicPINVOKE.SWIGPendingException.Pending)
677                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
678         }
679
680         internal void SetOrientation(Radian angle, Vector3 axis)
681         {
682             Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
683             if (NDalicPINVOKE.SWIGPendingException.Pending)
684                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
685         }
686
687         internal void SetOrientation(Rotation orientation)
688         {
689             Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
690             if (NDalicPINVOKE.SWIGPendingException.Pending)
691                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
692         }
693
694         internal Rotation GetCurrentOrientation()
695         {
696             Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
697             if (NDalicPINVOKE.SWIGPendingException.Pending)
698                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
699             return ret;
700         }
701
702         internal void SetInheritOrientation(bool inherit)
703         {
704             Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
705             if (NDalicPINVOKE.SWIGPendingException.Pending)
706                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
707         }
708
709         internal bool IsOrientationInherited()
710         {
711             bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
712             if (NDalicPINVOKE.SWIGPendingException.Pending)
713                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
714             return ret;
715         }
716
717         internal Rotation GetCurrentWorldOrientation()
718         {
719             Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
720             if (NDalicPINVOKE.SWIGPendingException.Pending)
721                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
722             return ret;
723         }
724
725         internal void SetScale(float scale)
726         {
727             Interop.ActorInternal.SetScale(SwigCPtr, scale);
728             if (NDalicPINVOKE.SWIGPendingException.Pending)
729                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
730         }
731
732         internal void SetScale(float scaleX, float scaleY, float scaleZ)
733         {
734             Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
735             if (NDalicPINVOKE.SWIGPendingException.Pending)
736                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
737         }
738
739         internal void SetScale(Vector3 scale)
740         {
741             Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
742             if (NDalicPINVOKE.SWIGPendingException.Pending)
743                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
744         }
745
746         internal Vector3 GetCurrentScale()
747         {
748             Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentScale(SwigCPtr), true);
749             if (NDalicPINVOKE.SWIGPendingException.Pending)
750                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
751             return ret;
752         }
753
754         internal Vector3 GetCurrentWorldScale()
755         {
756             Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldScale(SwigCPtr), true);
757             if (NDalicPINVOKE.SWIGPendingException.Pending)
758                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
759             return ret;
760         }
761
762         internal void SetInheritScale(bool inherit)
763         {
764             Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
765             if (NDalicPINVOKE.SWIGPendingException.Pending)
766                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
767         }
768
769         internal bool IsScaleInherited()
770         {
771             bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
772             if (NDalicPINVOKE.SWIGPendingException.Pending)
773                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
774             return ret;
775         }
776
777         internal Matrix GetCurrentWorldMatrix()
778         {
779             Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
780             if (NDalicPINVOKE.SWIGPendingException.Pending)
781                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
782             return ret;
783         }
784
785         internal void SetVisible(bool visible)
786         {
787             Interop.Actor.SetVisible(SwigCPtr, visible);
788             if (NDalicPINVOKE.SWIGPendingException.Pending)
789                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
790         }
791
792         internal bool IsVisible()
793         {
794             bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
795             if (NDalicPINVOKE.SWIGPendingException.Pending)
796                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
797             return ret;
798         }
799
800         internal void SetOpacity(float opacity)
801         {
802             Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
803             if (NDalicPINVOKE.SWIGPendingException.Pending)
804                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
805         }
806
807         internal float GetCurrentOpacity()
808         {
809             float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
810             if (NDalicPINVOKE.SWIGPendingException.Pending)
811                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
812             return ret;
813         }
814
815         internal Vector4 GetCurrentColor()
816         {
817             Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentColor(SwigCPtr), true);
818             if (NDalicPINVOKE.SWIGPendingException.Pending)
819                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
820             return ret;
821         }
822         internal ColorMode GetColorMode()
823         {
824             ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
825             if (NDalicPINVOKE.SWIGPendingException.Pending)
826                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
827             return ret;
828         }
829
830         internal Vector4 GetCurrentWorldColor()
831         {
832             Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentWorldColor(SwigCPtr), true);
833             if (NDalicPINVOKE.SWIGPendingException.Pending)
834                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
835             return ret;
836         }
837
838         internal void SetDrawMode(DrawModeType drawMode)
839         {
840             Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
841             if (NDalicPINVOKE.SWIGPendingException.Pending)
842                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
843         }
844
845         internal DrawModeType GetDrawMode()
846         {
847             DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
848             if (NDalicPINVOKE.SWIGPendingException.Pending)
849                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
850             return ret;
851         }
852
853         internal void SetKeyboardFocusable(bool focusable)
854         {
855             Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
856             if (NDalicPINVOKE.SWIGPendingException.Pending)
857                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
858         }
859
860         internal bool IsKeyboardFocusable()
861         {
862             bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
863             if (NDalicPINVOKE.SWIGPendingException.Pending)
864                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
865             return ret;
866         }
867
868         internal void SetKeyboardFocusableChildren(bool focusable)
869         {
870             Interop.ActorInternal.SetKeyboardFocusableChildren(SwigCPtr, focusable);
871             if (NDalicPINVOKE.SWIGPendingException.Pending)
872                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
873         }
874
875         internal bool AreChildrenKeyBoardFocusable()
876         {
877             bool ret = Interop.ActorInternal.AreChildrenKeyBoardFocusable(SwigCPtr);
878             if (NDalicPINVOKE.SWIGPendingException.Pending)
879                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
880             return ret;
881         }
882
883         internal void SetFocusableInTouch(bool enabled)
884         {
885             Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled);
886             if (NDalicPINVOKE.SWIGPendingException.Pending)
887                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
888         }
889
890         internal bool IsFocusableInTouch()
891         {
892             bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr);
893             if (NDalicPINVOKE.SWIGPendingException.Pending)
894                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
895             return ret;
896         }
897
898         internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
899         {
900             Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
901             if (NDalicPINVOKE.SWIGPendingException.Pending)
902                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
903         }
904
905         internal ResizePolicyType GetResizePolicy(DimensionType dimension)
906         {
907             ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
908             if (NDalicPINVOKE.SWIGPendingException.Pending)
909                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
910             return ret;
911         }
912
913         internal Vector3 GetSizeModeFactor()
914         {
915             Vector3 ret = new Vector3(Interop.Actor.GetSizeModeFactor(SwigCPtr), true);
916             if (NDalicPINVOKE.SWIGPendingException.Pending)
917                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
918             return ret;
919         }
920
921         internal void SetMinimumSize(Vector2 size)
922         {
923             Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
924             if (NDalicPINVOKE.SWIGPendingException.Pending)
925                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
926         }
927
928         internal Vector2 GetMinimumSize()
929         {
930             Vector2 ret = new Vector2(Interop.ActorInternal.GetMinimumSize(SwigCPtr), true);
931             if (NDalicPINVOKE.SWIGPendingException.Pending)
932                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
933             return ret;
934         }
935
936         internal void SetMaximumSize(Vector2 size)
937         {
938             Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
939             if (NDalicPINVOKE.SWIGPendingException.Pending)
940                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
941         }
942
943         internal Vector2 GetMaximumSize()
944         {
945             Vector2 ret = new Vector2(Interop.ActorInternal.GetMaximumSize(SwigCPtr), true);
946             if (NDalicPINVOKE.SWIGPendingException.Pending)
947                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
948             return ret;
949         }
950
951         internal int GetHierarchyDepth()
952         {
953             int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
954             if (NDalicPINVOKE.SWIGPendingException.Pending)
955                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
956             return ret;
957         }
958
959         internal uint GetRendererCount()
960         {
961             uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
962             if (NDalicPINVOKE.SWIGPendingException.Pending)
963                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
964             return ret;
965         }
966
967         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
968         {
969             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
970         }
971
972         internal bool IsTopLevelView()
973         {
974             if (GetParent() is Layer)
975             {
976                 return true;
977             }
978             return false;
979         }
980
981         internal void SetKeyInputFocus()
982         {
983             Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
984             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
985         }
986
987         internal void ClearKeyInputFocus()
988         {
989             Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
990             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
991         }
992
993         internal PinchGestureDetector GetPinchGestureDetector()
994         {
995             PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
996             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
997             return ret;
998         }
999
1000         internal PanGestureDetector GetPanGestureDetector()
1001         {
1002             PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
1003             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1004             return ret;
1005         }
1006
1007         internal TapGestureDetector GetTapGestureDetector()
1008         {
1009             TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
1010             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1011             return ret;
1012         }
1013
1014         internal LongPressGestureDetector GetLongPressGestureDetector()
1015         {
1016             LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
1017             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1018             return ret;
1019         }
1020
1021         internal IntPtr GetPtrfromView()
1022         {
1023             return (IntPtr)SwigCPtr;
1024         }
1025
1026         internal void RemoveChild(View child)
1027         {
1028             // Do actual child removal
1029             Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1030             if (NDalicPINVOKE.SWIGPendingException.Pending)
1031                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1032
1033             Children.Remove(child);
1034             child.InternalParent = null;
1035             LayoutCount -= child.LayoutCount;
1036
1037             RemoveChildBindableObject(child);
1038
1039             if (ChildRemoved != null)
1040             {
1041                 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1042                 {
1043                     Removed = child
1044                 };
1045                 ChildRemoved(this, e);
1046             }
1047         }
1048
1049         /// <summary>
1050         /// Removes the layout from this View.
1051         /// </summary>
1052         internal void ResetLayout()
1053         {
1054             LayoutCount--;
1055
1056             layout = null;
1057         }
1058
1059         internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1060         {
1061             return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1062         }
1063
1064         /// TODO open as a protected level
1065         internal virtual void ApplyCornerRadius()
1066         {
1067             if (backgroundExtraData == null) return;
1068
1069             var cornerRadiusValue = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
1070             var cornerRadiusPolicyValue = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1071
1072             // Make current propertyMap
1073             PropertyMap currentPropertyMap = new PropertyMap();
1074             currentPropertyMap[Visual.Property.CornerRadius] = cornerRadiusValue;
1075             currentPropertyMap[Visual.Property.CornerRadiusPolicy] = cornerRadiusPolicyValue;
1076             var temp = new PropertyValue(currentPropertyMap);
1077
1078             // Update corner radius properties to background and shadow by ActionUpdateProperty
1079             DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1080             DoAction(View.Property.SHADOW, ActionUpdateProperty, temp);
1081
1082             temp.Dispose();
1083             currentPropertyMap.Dispose();
1084             cornerRadiusValue.Dispose();
1085             cornerRadiusPolicyValue.Dispose();
1086         }
1087
1088         /// TODO open as a protected level
1089         internal virtual void ApplyBorderline()
1090         {
1091             if (backgroundExtraData == null) return;
1092
1093             var borderlineWidthValue = new PropertyValue(backgroundExtraData.BorderlineWidth);
1094             var borderlineColorValue = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
1095             var borderlineOffsetValue = new PropertyValue(backgroundExtraData.BorderlineOffset);
1096
1097             // Make current propertyMap
1098             PropertyMap currentPropertyMap = new PropertyMap();
1099             currentPropertyMap[Visual.Property.BorderlineWidth] = borderlineWidthValue;
1100             currentPropertyMap[Visual.Property.BorderlineColor] = borderlineColorValue;
1101             currentPropertyMap[Visual.Property.BorderlineOffset] = borderlineOffsetValue;
1102             var temp = new PropertyValue(currentPropertyMap);
1103
1104             // Update borderline properties to background  by ActionUpdateProperty
1105             DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1106
1107             temp.Dispose();
1108             currentPropertyMap.Dispose();
1109             borderlineWidthValue.Dispose();
1110             borderlineColorValue.Dispose();
1111             borderlineOffsetValue.Dispose();
1112         }
1113
1114         /// <summary>
1115         /// Get selector value from the triggerable selector or related property.
1116         /// </summary>
1117         internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1118         {
1119             var selector = triggerableSelector?.Get();
1120             if (selector != null)
1121             {
1122                 return selector;
1123             }
1124
1125             var value = (T)GetValue(relatedProperty);
1126             return value == null ? null : new Selector<T>(value);
1127         }
1128
1129         internal void SetThemeApplied()
1130         {
1131             if (themeData == null) themeData = new ThemeData();
1132             themeData.ThemeApplied = true;
1133
1134             if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
1135             {
1136                 themeData.ListeningThemeChangeEvent = true;
1137                 ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
1138             }
1139         }
1140
1141         /// <summary>
1142         /// you can override it to clean-up your own resources.
1143         /// </summary>
1144         /// <param name="type">DisposeTypes</param>
1145         /// <since_tizen> 3 </since_tizen>
1146         protected override void Dispose(DisposeTypes type)
1147         {
1148             if (disposed)
1149             {
1150                 return;
1151             }
1152
1153             DebugFileLogging.Instance.WriteLog($"View.Dispose({type}) START");
1154             DebugFileLogging.Instance.WriteLog($"type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1155             if(HasBody())
1156             {
1157                 DebugFileLogging.Instance.WriteLog($"ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1158             }
1159             else
1160             {
1161                 DebugFileLogging.Instance.WriteLog($"has no native body!");
1162             }
1163
1164             //_mergedStyle = null;
1165
1166             internalMaximumSize?.Dispose();
1167             internalMaximumSize = null;
1168             internalMinimumSize?.Dispose();
1169             internalMinimumSize = null;
1170             internalMargin?.Dispose();
1171             internalMargin = null;
1172             internalPadding?.Dispose();
1173             internalPadding = null;
1174             internalSizeModeFactor?.Dispose();
1175             internalSizeModeFactor = null;
1176             internalCellIndex?.Dispose();
1177             internalCellIndex = null;
1178             internalBackgroundColor?.Dispose();
1179             internalBackgroundColor = null;
1180             internalColor?.Dispose();
1181             internalColor = null;
1182             internalPivotPoint?.Dispose();
1183             internalPivotPoint = null;
1184             internalPosition?.Dispose();
1185             internalPosition = null;
1186             internalPosition2D?.Dispose();
1187             internalPosition2D = null;
1188             internalScale?.Dispose();
1189             internalScale = null;
1190             internalSize?.Dispose();
1191             internalSize = null;
1192             internalSize2D?.Dispose();
1193             internalSize2D = null;
1194
1195             if (type == DisposeTypes.Explicit)
1196             {
1197                 //Called by User
1198                 //Release your own managed resources here.
1199                 //You should release all of your own disposable objects here.
1200                 if (themeData != null)
1201                 {
1202                     themeData.selectorData?.Reset(this);
1203                     if (themeData.ListeningThemeChangeEvent)
1204                     {
1205                         ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1206                     }
1207                 }
1208                 if (widthConstraint != null)
1209                 {
1210                     widthConstraint.Remove();
1211                     widthConstraint.Dispose();
1212                 }
1213                 if (heightConstraint != null)
1214                 {
1215                     heightConstraint.Remove();
1216                     heightConstraint.Dispose();
1217                 }
1218             }
1219
1220             //Release your own unmanaged resources here.
1221             //You should not access any managed member here except static instance.
1222             //because the execution order of Finalizes is non-deterministic.
1223
1224             DisConnectFromSignals();
1225
1226             foreach (View view in Children)
1227             {
1228                 view.InternalParent = null;
1229             }
1230
1231             LayoutCount = 0;
1232
1233             NUILog.Debug($"[Dispose] View.Dispose({type}) END");
1234             NUILog.Debug($"=============================");
1235
1236             base.Dispose(type);
1237         }
1238
1239         /// This will not be public opened.
1240         [EditorBrowsable(EditorBrowsableState.Never)]
1241         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1242         {
1243             Interop.View.DeleteView(swigCPtr);
1244         }
1245
1246         /// <summary>
1247         /// The touch event handler for ControlState.
1248         /// Please change ControlState value by touch state if needed.
1249         /// </summary>
1250         /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1251         [EditorBrowsable(EditorBrowsableState.Never)]
1252         protected virtual bool HandleControlStateOnTouch(Touch touch)
1253         {
1254             if (touch == null)
1255             {
1256                 throw new global::System.ArgumentNullException(nameof(touch));
1257             }
1258
1259             switch (touch.GetState(0))
1260             {
1261                 case PointStateType.Down:
1262                     ControlState += ControlState.Pressed;
1263                     break;
1264                 case PointStateType.Interrupted:
1265                 case PointStateType.Up:
1266                     if (ControlState.Contains(ControlState.Pressed))
1267                     {
1268                         ControlState -= ControlState.Pressed;
1269                     }
1270                     break;
1271                 default:
1272                     break;
1273             }
1274             return false;
1275         }
1276
1277         private void DisConnectFromSignals()
1278         {
1279             if (HasBody() == false)
1280             {
1281                 NUILog.Debug($"[Dispose] DisConnectFromSignals() No native body! No need to Disconnect Signals!");
1282                 return;
1283             }
1284             NUILog.Debug($"[Dispose] DisConnectFromSignals START");
1285             NUILog.Debug($"[Dispose] View.DisConnectFromSignals() type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1286             NUILog.Debug($"[Dispose] ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1287
1288             if (onRelayoutEventCallback != null)
1289             {
1290                 NUILog.Debug($"[Dispose] onRelayoutEventCallback");
1291
1292                 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(GetBaseHandleCPtrHandleRef), false);
1293                 signal?.Disconnect(onRelayoutEventCallback);
1294                 onRelayoutEventCallback = null;
1295             }
1296
1297             if (offWindowEventCallback != null)
1298             {
1299                 NUILog.Debug($"[Dispose] offWindowEventCallback");
1300
1301                 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(GetBaseHandleCPtrHandleRef), false);
1302                 signal?.Disconnect(offWindowEventCallback);
1303                 offWindowEventCallback = null;
1304             }
1305
1306             if (onWindowEventCallback != null)
1307             {
1308                 NUILog.Debug($"[Dispose] onWindowEventCallback");
1309
1310                 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1311                 signal?.Disconnect(onWindowEventCallback);
1312                 onWindowEventCallback = null;
1313             }
1314
1315             if (wheelEventCallback != null)
1316             {
1317                 NUILog.Debug($"[Dispose] wheelEventCallback");
1318
1319                 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(GetBaseHandleCPtrHandleRef), false);
1320                 signal?.Disconnect(wheelEventCallback);
1321                 wheelEventCallback = null;
1322             }
1323
1324             if (WindowWheelEventHandler != null)
1325             {
1326                 NUILog.Debug($"[Dispose] WindowWheelEventHandler");
1327
1328                 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
1329                 WindowWheelEventHandler = null;
1330             }
1331
1332             if (hoverEventCallback != null)
1333             {
1334                 NUILog.Debug($"[Dispose] hoverEventCallback");
1335
1336                 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(GetBaseHandleCPtrHandleRef), false);
1337                 signal?.Disconnect(hoverEventCallback);
1338                 hoverEventCallback = null;
1339             }
1340
1341             if (interceptTouchDataCallback != null)
1342             {
1343                 NUILog.Debug($"[Dispose] interceptTouchDataCallback");
1344
1345                 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(GetBaseHandleCPtrHandleRef), false);
1346                 signal?.Disconnect(interceptTouchDataCallback);
1347                 interceptTouchDataCallback = null;
1348             }
1349
1350             if (touchDataCallback != null)
1351             {
1352                 NUILog.Debug($"[Dispose] touchDataCallback");
1353
1354                 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(GetBaseHandleCPtrHandleRef), false);
1355                 signal?.Disconnect(touchDataCallback);
1356                 touchDataCallback = null;
1357             }
1358
1359             if (ResourcesLoadedCallback != null)
1360             {
1361                 NUILog.Debug($"[Dispose] ResourcesLoadedCallback");
1362
1363                 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1364                 signal?.Disconnect(ResourcesLoadedCallback);
1365                 ResourcesLoadedCallback = null;
1366             }
1367
1368             if (keyCallback != null)
1369             {
1370                 NUILog.Debug($"[Dispose] keyCallback");
1371
1372                 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(GetBaseHandleCPtrHandleRef), false);
1373                 signal?.Disconnect(keyCallback);
1374                 keyCallback = null;
1375             }
1376
1377             if (keyInputFocusLostCallback != null)
1378             {
1379                 NUILog.Debug($"[Dispose] keyInputFocusLostCallback");
1380
1381                 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(GetBaseHandleCPtrHandleRef), false);
1382                 signal?.Disconnect(keyInputFocusLostCallback);
1383                 keyInputFocusLostCallback = null;
1384                 keyInputFocusLostEventHandler = null;
1385             }
1386
1387             if (keyInputFocusGainedCallback != null)
1388             {
1389                 NUILog.Debug($"[Dispose] keyInputFocusGainedCallback");
1390
1391                 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(GetBaseHandleCPtrHandleRef), false);
1392                 signal?.Disconnect(keyInputFocusGainedCallback);
1393                 keyInputFocusGainedCallback = null;
1394                 keyInputFocusGainedEventHandler = null;
1395             }
1396
1397             if (backgroundResourceLoadedCallback != null)
1398             {
1399                 NUILog.Debug($"[Dispose] backgroundResourceLoadedCallback");
1400
1401                 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1402                 signal?.Disconnect(backgroundResourceLoadedCallback);
1403                 backgroundResourceLoadedCallback = null;
1404             }
1405
1406             if (onWindowSendEventCallback != null)
1407             {
1408                 NUILog.Debug($"[Dispose] onWindowSendEventCallback");
1409
1410                 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1411                 signal?.Disconnect(onWindowSendEventCallback);
1412                 onWindowSendEventCallback = null;
1413             }
1414             NUILog.Debug($"[Dispose] DisConnectFromSignals END");
1415         }
1416
1417         /// <summary>
1418         /// Apply initial style to the view.
1419         /// </summary>
1420         [EditorBrowsable(EditorBrowsableState.Never)]
1421         protected virtual void InitializeStyle(ViewStyle style = null)
1422         {
1423             var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
1424             if (style == null)
1425             {
1426                 ApplyStyle(initialStyle);
1427             }
1428             else
1429             {
1430                 var refinedStyle = style;
1431                 if (style.IncludeDefaultStyle)
1432                 {
1433                     refinedStyle = initialStyle?.Merge(style);
1434                 }
1435                 ApplyStyle(refinedStyle);
1436             }
1437
1438             // Listen theme change event if needs.
1439             if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
1440             {
1441                 SetThemeApplied();
1442             }
1443         }
1444
1445         private View ConvertIdToView(uint id)
1446         {
1447             View view = GetParent()?.FindCurrentChildById(id);
1448
1449             //If we can't find the parent's children, find in the top layer.
1450             if (!view)
1451             {
1452                 Container parent = GetParent();
1453                 while ((parent is View) && (parent != null))
1454                 {
1455                     parent = parent.GetParent();
1456                     if (parent is Layer)
1457                     {
1458                         view = parent.FindCurrentChildById(id);
1459                         break;
1460                     }
1461                 }
1462             }
1463
1464             return view;
1465         }
1466
1467         private void OnScaleChanged(float x, float y, float z)
1468         {
1469             Scale = new Vector3(x, y, z);
1470         }
1471
1472         private void OnBackgroundColorChanged(float r, float g, float b, float a)
1473         {
1474             BackgroundColor = new Color(r, g, b, a);
1475         }
1476
1477         private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1478         {
1479             Padding = new Extents(start, end, top, bottom);
1480         }
1481
1482         private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1483         {
1484             Margin = new Extents(start, end, top, bottom);
1485         }
1486
1487         private void OnAnchorPointChanged(float x, float y, float z)
1488         {
1489             AnchorPoint = new Position(x, y, z);
1490         }
1491
1492         private void OnCellIndexChanged(float x, float y)
1493         {
1494             CellIndex = new Vector2(x, y);
1495         }
1496
1497         private void OnFlexMarginChanged(float x, float y, float z, float w)
1498         {
1499             FlexMargin = new Vector4(x, y, z, w);
1500         }
1501
1502         private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1503         {
1504             PaddingEX = new Extents(start, end, top, bottom);
1505         }
1506
1507         private void OnSizeModeFactorChanged(float x, float y, float z)
1508         {
1509             SizeModeFactor = new Vector3(x, y, z);
1510         }
1511
1512         private bool EmptyOnTouch(object target, TouchEventArgs args)
1513         {
1514             return false;
1515         }
1516
1517         private ViewSelectorData EnsureSelectorData()
1518         {
1519             if (themeData == null) themeData = new ThemeData();
1520
1521             return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());
1522         }
1523     }
1524 }