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