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