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