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