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