Release 10.0.0.17552
[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 using Tizen.NUI;
22
23 namespace Tizen.NUI.BaseComponents
24 {
25     /// <summary>
26     /// View is the base class for all views.
27     /// </summary>
28     /// <since_tizen> 3 </since_tizen>
29     public partial class View
30     {
31         internal string styleName;
32
33         internal virtual LayoutItem CreateDefaultLayout()
34         {
35             return new AbsoluteLayout();
36         }
37
38         internal class ThemeData
39         {
40             [Flags]
41             private enum States : byte
42             {
43                 None = 0,
44                 ControlStatePropagation = 1 << 0,
45                 ThemeChangeSensitive = 1 << 1,
46                 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.
47                                        // That indicates the view can have different styles by theme.
48                                        // Hence if the current state has ThemeApplied and ThemeChangeSensitive, the view will change its style by theme changing.
49                 ListeningThemeChangeEvent = 1 << 3,
50             };
51
52             private States states = ThemeManager.ApplicationThemeChangeSensitive ? States.ThemeChangeSensitive : States.None;
53             public ViewStyle viewStyle;
54             public ControlState controlStates = ControlState.Normal;
55             public ViewSelectorData selectorData;
56
57             public bool ControlStatePropagation
58             {
59                 get => ((states & States.ControlStatePropagation) != 0);
60                 set => SetOption(States.ControlStatePropagation, value);
61             }
62
63             public bool ThemeChangeSensitive
64             {
65                 get => ((states & States.ThemeChangeSensitive) != 0);
66                 set => SetOption(States.ThemeChangeSensitive, value);
67             }
68
69             public bool ThemeApplied
70             {
71                 get => ((states & States.ThemeApplied) != 0);
72                 set => SetOption(States.ThemeApplied, value);
73             }
74
75             public bool ListeningThemeChangeEvent
76             {
77                 get => ((states & States.ListeningThemeChangeEvent) != 0);
78                 set => SetOption(States.ListeningThemeChangeEvent, value);
79             }
80
81             private void SetOption(States option, bool value)
82             {
83                 if (value) states |= option;
84                 else states &= ~option;
85             }
86         }
87
88         /// <summary>
89         /// The color mode of View.
90         /// This specifies whether the View uses its own color, or inherits its parent color.
91         /// The default is ColorMode.UseOwnMultiplyParentColor.
92         /// </summary>
93         internal ColorMode ColorMode
94         {
95             set
96             {
97                 SetColorMode(value);
98             }
99             get
100             {
101                 return GetColorMode();
102             }
103         }
104
105         internal LayoutLength SuggestedMinimumWidth
106         {
107             get
108             {
109                 float result = Interop.Actor.GetSuggestedMinimumWidth(SwigCPtr);
110                 if (NDalicPINVOKE.SWIGPendingException.Pending)
111                     throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112                 return new LayoutLength(result);
113             }
114         }
115
116         internal LayoutLength SuggestedMinimumHeight
117         {
118             get
119             {
120                 float result = Interop.Actor.GetSuggestedMinimumHeight(SwigCPtr);
121                 if (NDalicPINVOKE.SWIGPendingException.Pending)
122                     throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123                 return new LayoutLength(result);
124             }
125         }
126
127         internal float WorldPositionX
128         {
129             get
130             {
131 #if NUI_PROPERTY_CHANGE_3
132                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.WorldPositionX);
133 #else
134                 float returnValue = 0.0f;
135                 PropertyValue wordPositionX = GetProperty(View.Property.WorldPositionX);
136                 wordPositionX?.Get(out returnValue);
137                 wordPositionX?.Dispose();
138                 return returnValue;
139 #endif                
140             }
141         }
142
143         internal float WorldPositionY
144         {
145             get
146             {
147 #if NUI_PROPERTY_CHANGE_3
148                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.WorldPositionY);
149 #else
150                 float returnValue = 0.0f;
151                 PropertyValue wordPositionY = GetProperty(View.Property.WorldPositionY);
152                 wordPositionY?.Get(out returnValue);
153                 wordPositionY?.Dispose();
154                 return returnValue;
155 #endif
156             }
157         }
158
159         internal float WorldPositionZ
160         {
161             get
162             {
163 #if NUI_PROPERTY_CHANGE_3
164                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.WorldPositionZ);
165 #else
166                 float returnValue = 0.0f;
167                 PropertyValue wordPositionZ = GetProperty(View.Property.WorldPositionZ);
168                 wordPositionZ?.Get(out returnValue);
169                 wordPositionZ?.Dispose();
170                 return returnValue;
171 #endif
172             }
173         }
174
175         internal bool FocusState
176         {
177             get
178             {
179                 return IsKeyboardFocusable();
180             }
181             set
182             {
183                 SetKeyboardFocusable(value);
184             }
185         }
186
187         internal void SetLayout(LayoutItem layout)
188         {
189             LayoutCount++;
190
191             this.layout = layout;
192             this.layout?.AttachToOwner(this);
193             this.layout?.RequestLayout();
194         }
195
196         internal void AttachTransitionsToChildren(LayoutTransition transition)
197         {
198             // Iterate children, adding the transition unless a transition
199             // for the same condition and property has already been
200             // explicitly added.
201             foreach (View view in Children)
202             {
203                 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
204             }
205         }
206
207         internal float ParentOriginX
208         {
209             get
210             {
211 #if NUI_PROPERTY_CHANGE_3
212                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.ParentOriginX);
213 #else
214                 float returnValue = 0.0f;
215                 PropertyValue parentOriginX = GetProperty(View.Property.ParentOriginX);
216                 parentOriginX?.Get(out returnValue);
217                 parentOriginX?.Dispose();
218                 return returnValue;
219 #endif
220             }
221             set
222             {
223 #if NUI_PROPERTY_CHANGE_3
224                 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.WorldPositionX, value);
225 #else
226                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
227                 SetProperty(View.Property.ParentOriginX, setValue);
228                 setValue.Dispose();
229 #endif
230                 NotifyPropertyChanged();
231             }
232         }
233
234         internal float ParentOriginY
235         {
236             get
237             {
238 #if NUI_PROPERTY_CHANGE_3
239                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.ParentOriginY);
240 #else
241                 float returnValue = 0.0f;
242                 PropertyValue parentOriginY = GetProperty(View.Property.ParentOriginY);
243                 parentOriginY?.Get(out returnValue);
244                 parentOriginY?.Dispose();
245                 return returnValue;
246 #endif
247             }
248             set
249             {
250 #if NUI_PROPERTY_CHANGE_3
251                 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.ParentOriginY, value);
252 #else
253
254                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
255                 SetProperty(View.Property.ParentOriginY, setValue);
256                 setValue.Dispose();
257 #endif
258                 NotifyPropertyChanged();
259             }
260         }
261
262         internal float ParentOriginZ
263         {
264             get
265             {
266 #if NUI_PROPERTY_CHANGE_3
267                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.ParentOriginZ);
268 #else
269                 float returnValue = 0.0f;
270                 PropertyValue parentOriginZ = GetProperty(View.Property.ParentOriginZ);
271                 parentOriginZ?.Get(out returnValue);
272                 parentOriginZ?.Dispose();
273                 return returnValue;
274 #endif            
275             }
276             set
277             {
278 #if NUI_PROPERTY_CHANGE_3
279                 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.ParentOriginZ, value);
280 #else
281                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
282                 SetProperty(View.Property.ParentOriginZ, setValue);
283                 setValue.Dispose();
284 #endif
285                 NotifyPropertyChanged();
286             }
287         }
288
289         internal float PivotPointX
290         {
291             get
292             {
293 #if NUI_PROPERTY_CHANGE_3
294                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.AnchorPointX);
295 #else
296                 float returnValue = 0.0f;
297                 PropertyValue anchorPointX = GetProperty(View.Property.AnchorPointX);
298                 anchorPointX?.Get(out returnValue);
299                 anchorPointX?.Dispose();
300                 return returnValue;
301 #endif
302             }
303             set
304             {
305 #if NUI_PROPERTY_CHANGE_3
306                 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.AnchorPointX, value);
307 #else
308                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
309                 SetProperty(View.Property.AnchorPointX, setValue);
310                 setValue.Dispose();
311 #endif
312             }
313         }
314
315         internal float PivotPointY
316         {
317             get
318             {
319 #if NUI_PROPERTY_CHANGE_3
320                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.AnchorPointY);
321 #else
322
323                 float returnValue = 0.0f;
324                 PropertyValue anchorPointY = GetProperty(View.Property.AnchorPointY);
325                 anchorPointY?.Get(out returnValue);
326                 anchorPointY?.Dispose();
327                 return returnValue;
328 #endif
329             }
330             set
331             {
332 #if NUI_PROPERTY_CHANGE_3
333                 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.AnchorPointY, value);
334 #else
335                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
336                 SetProperty(View.Property.AnchorPointY, setValue);
337                 setValue.Dispose();
338 #endif
339             }
340         }
341
342         internal float PivotPointZ
343         {
344             get
345             {
346 #if NUI_PROPERTY_CHANGE_3
347                 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.AnchorPointZ);
348 #else
349                 float returnValue = 0.0f;
350                 PropertyValue anchorPointZ = GetProperty(View.Property.AnchorPointZ);
351                 anchorPointZ?.Get(out returnValue);
352                 anchorPointZ?.Dispose();
353                 return returnValue;
354 #endif            
355             }
356             set
357             {
358 #if NUI_PROPERTY_CHANGE_3
359                 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.AnchorPointZ, value);
360 #else
361                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
362                 SetProperty(View.Property.AnchorPointZ, setValue);
363                 setValue.Dispose();
364 #endif
365             }
366         }
367
368         internal Matrix WorldMatrix
369         {
370             get
371             {
372                 Matrix returnValue = new Matrix();
373                 PropertyValue wordMatrix = GetProperty(View.Property.WorldMatrix);
374                 wordMatrix?.Get(returnValue);
375                 wordMatrix?.Dispose();
376                 return returnValue;
377             }
378         }
379
380         /// <summary>
381         /// The number of layouts including view's layout and children's layouts.
382         /// This can be used to set/unset Process callback to calculate Layout.
383         /// </summary>
384         internal int LayoutCount
385         {
386             get
387             {
388                 return layoutCount;
389             }
390
391             set
392             {
393                 if (layoutCount == value) return;
394
395                 if (value < 0) throw new global::System.ArgumentOutOfRangeException(nameof(LayoutCount), "LayoutCount(" + LayoutCount + ") should not be less than zero");
396
397                 int diff = value - layoutCount;
398                 layoutCount = value;
399
400                 if (InternalParent != null)
401                 {
402                     var parentView = InternalParent as View;
403                     if (parentView != null)
404                     {
405                         parentView.LayoutCount += diff;
406                     }
407                     else
408                     {
409                         var parentLayer = InternalParent as Layer;
410                         if (parentLayer != null)
411                         {
412                             parentLayer.LayoutCount += diff;
413                         }
414                     }
415                 }
416             }
417         }
418
419         /// <summary>
420         /// Indicates that this View should listen Touch event to handle its ControlState.
421         /// </summary>
422         private bool enableControlState = false;
423
424         private int LeftFocusableViewId
425         {
426             get
427             {
428 #if NUI_PROPERTY_CHANGE_3
429                 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.LeftFocusableViewId);
430 #else
431                 int returnValue = 0;
432                 PropertyValue leftFocusableViewId = GetProperty(View.Property.LeftFocusableViewId);
433                 leftFocusableViewId?.Get(out returnValue);
434                 leftFocusableViewId?.Dispose();
435                 return returnValue;
436 #endif
437             }
438             set
439             {
440 #if NUI_PROPERTY_CHANGE_3
441                 Object.InternalSetPropertyInt(SwigCPtr, View.Property.LeftFocusableViewId, value);
442 #else
443                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
444                 SetProperty(View.Property.LeftFocusableViewId, setValue);
445                 setValue.Dispose();
446 #endif
447             }
448         }
449
450         private int RightFocusableViewId
451         {
452             get
453             {
454 #if NUI_PROPERTY_CHANGE_3
455                 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.RightFocusableViewId);
456 #else
457                 int returnValue = 0;
458                 PropertyValue rightFocusableViewId = GetProperty(View.Property.RightFocusableViewId);
459                 rightFocusableViewId?.Get(out returnValue);
460                 rightFocusableViewId?.Dispose();
461                 return returnValue;
462 #endif
463             }
464             set
465             {
466 #if NUI_PROPERTY_CHANGE_3
467                 Object.InternalSetPropertyInt(SwigCPtr, View.Property.RightFocusableViewId, value);
468 #else
469                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
470                 SetProperty(View.Property.RightFocusableViewId, setValue);
471                 setValue.Dispose();
472 #endif
473             }
474         }
475
476         private int UpFocusableViewId
477         {
478             get
479             {
480 #if NUI_PROPERTY_CHANGE_3
481                 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.UpFocusableViewId);
482 #else
483                 int returnValue = 0;
484                 PropertyValue upFocusableViewId = GetProperty(View.Property.UpFocusableViewId);
485                 upFocusableViewId?.Get(out returnValue);
486                 upFocusableViewId?.Dispose();
487                 return returnValue;
488 #endif
489             }
490             set
491             {
492 #if NUI_PROPERTY_CHANGE_3
493                 Object.InternalSetPropertyInt(SwigCPtr, View.Property.UpFocusableViewId, value);
494 #else
495                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
496                 SetProperty(View.Property.UpFocusableViewId, setValue);
497                 setValue.Dispose();
498 #endif
499             }
500         }
501
502         private int DownFocusableViewId
503         {
504             get
505             {
506 #if NUI_PROPERTY_CHANGE_3
507                 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.DownFocusableViewId);
508 #else
509                 int returnValue = 0;
510                 PropertyValue downFocusableViewId = GetProperty(View.Property.DownFocusableViewId);
511                 downFocusableViewId?.Get(out returnValue);
512                 downFocusableViewId?.Dispose();
513                 return returnValue;
514 #endif
515             }
516             set
517             {
518 #if NUI_PROPERTY_CHANGE_3
519                 Object.InternalSetPropertyInt(SwigCPtr, View.Property.DownFocusableViewId, value);
520 #else
521                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
522                 SetProperty(View.Property.DownFocusableViewId, setValue);
523                 setValue.Dispose();
524 #endif
525             }
526         }
527
528         private int ClockwiseFocusableViewId
529         {
530             get
531             {
532 #if NUI_PROPERTY_CHANGE_3
533                 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.ClockwiseFocusableViewId);
534 #else
535                 int returnValue = -1;
536                 PropertyValue clockwiseFocusableViewId = GetProperty(View.Property.ClockwiseFocusableViewId);
537                 clockwiseFocusableViewId?.Get(out returnValue);
538                 clockwiseFocusableViewId?.Dispose();
539                 return returnValue;
540 #endif
541             }
542             set
543             {
544 #if NUI_PROPERTY_CHANGE_3
545                 Object.InternalSetPropertyInt(SwigCPtr, View.Property.ClockwiseFocusableViewId, value);
546 #else
547                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
548                 SetProperty(View.Property.ClockwiseFocusableViewId, setValue);
549                 setValue.Dispose();
550 #endif
551             }
552         }
553
554         private int CounterClockwiseFocusableViewId
555         {
556             get
557             {
558 #if NUI_PROPERTY_CHANGE_3
559                 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.CounterClockwiseFocusableViewId);
560 #else
561                 int returnValue = -1;
562                 PropertyValue counterClockwiseFocusableViewId = GetProperty(View.Property.CounterClockwiseFocusableViewId);
563                 counterClockwiseFocusableViewId?.Get(out returnValue);
564                 counterClockwiseFocusableViewId?.Dispose();
565                 return returnValue;
566 #endif
567             }
568             set
569             {
570 #if NUI_PROPERTY_CHANGE_3
571                 Object.InternalSetPropertyInt(SwigCPtr, View.Property.CounterClockwiseFocusableViewId, value);
572 #else
573                 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
574                 SetProperty(View.Property.CounterClockwiseFocusableViewId, setValue);
575                 setValue.Dispose();
576 #endif
577             }
578         }
579
580         internal string GetName()
581         {
582             string ret = Interop.Actor.GetName(SwigCPtr);
583             if (NDalicPINVOKE.SWIGPendingException.Pending)
584                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
585             return ret;
586         }
587
588         internal void SetName(string name)
589         {
590             Interop.Actor.SetName(SwigCPtr, name);
591             if (NDalicPINVOKE.SWIGPendingException.Pending)
592                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
593         }
594
595         internal uint GetId()
596         {
597             uint ret = Interop.Actor.GetId(SwigCPtr);
598             if (NDalicPINVOKE.SWIGPendingException.Pending)
599                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
600             return ret;
601         }
602
603         internal bool IsRoot()
604         {
605             bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
606             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
607             return ret;
608         }
609
610         internal bool OnWindow()
611         {
612             bool ret = Interop.Actor.OnStage(SwigCPtr);
613             if (NDalicPINVOKE.SWIGPendingException.Pending)
614                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
615             return ret;
616         }
617
618         internal View FindChildById(uint id)
619         {
620             //to fix memory leak issue, match the handle count with native side.
621             IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
622             View ret = this.GetInstanceSafely<View>(cPtr);
623             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
624             return ret;
625         }
626
627         internal override View FindCurrentChildById(uint id)
628         {
629             return FindChildById(id);
630         }
631
632         internal void SetParentOrigin(Position origin)
633         {
634             Interop.ActorInternal.SetParentOrigin(SwigCPtr, Position.getCPtr(origin));
635             if (NDalicPINVOKE.SWIGPendingException.Pending)
636                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
637         }
638
639         internal Position GetCurrentParentOrigin()
640         {
641 #if NUI_PROPERTY_CHANGE_3
642             if(internalCurrentParentOrigin == null)
643             {
644                 internalCurrentParentOrigin = new Position(0, 0, 0);
645             }
646
647             Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.ParentOrigin, internalCurrentParentOrigin.SwigCPtr);
648
649             if (NDalicPINVOKE.SWIGPendingException.Pending)
650             {
651                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
652             }
653             return internalCurrentParentOrigin;
654 #else
655             Position ret = new Position(Interop.ActorInternal.GetCurrentParentOrigin(SwigCPtr), true);
656
657             if (NDalicPINVOKE.SWIGPendingException.Pending)
658                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
659             return ret;
660 #endif            
661         }
662
663         internal void SetAnchorPoint(Position anchorPoint)
664         {
665             Interop.Actor.SetAnchorPoint(SwigCPtr, Position.getCPtr(anchorPoint));
666             if (NDalicPINVOKE.SWIGPendingException.Pending)
667                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
668         }
669
670         internal Position GetCurrentAnchorPoint()
671         {
672 #if NUI_PROPERTY_CHANGE_3
673             if(internalCurrentAnchorPoint == null)
674             {
675                 internalCurrentAnchorPoint = new Position(0, 0, 0);
676             }
677
678             Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.AnchorPoint, internalCurrentAnchorPoint.SwigCPtr);
679
680             if (NDalicPINVOKE.SWIGPendingException.Pending)
681             {
682                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
683             }
684             return internalCurrentAnchorPoint;
685 #else
686             Position ret = new Position(Interop.ActorInternal.GetCurrentAnchorPoint(SwigCPtr), true);
687             if (NDalicPINVOKE.SWIGPendingException.Pending)
688                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
689             return ret;
690 #endif            
691         }
692
693         internal void SetSize(float width, float height)
694         {
695             Interop.ActorInternal.SetSize(SwigCPtr, width, height);
696             if (NDalicPINVOKE.SWIGPendingException.Pending)
697                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
698         }
699
700         internal void SetSize(float width, float height, float depth)
701         {
702             Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
703             if (NDalicPINVOKE.SWIGPendingException.Pending)
704                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
705         }
706
707         internal void SetSize(Vector2 size)
708         {
709             Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
710             if (NDalicPINVOKE.SWIGPendingException.Pending)
711                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
712         }
713
714         internal void SetSize(Vector3 size)
715         {
716             Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
717             if (NDalicPINVOKE.SWIGPendingException.Pending)
718                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
719         }
720
721         internal Vector3 GetTargetSize()
722         {
723 #if NUI_PROPERTY_CHANGE_3
724             if(internalTargetSize == null)
725             {
726                 internalTargetSize = new Vector3(0, 0, 0);
727             }
728             
729             Interop.ActorInternal.RetrieveTargetSize(SwigCPtr, internalTargetSize.SwigCPtr);
730             
731             if (NDalicPINVOKE.SWIGPendingException.Pending)
732             {
733                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
734             }
735             return internalTargetSize;
736 #else
737             Vector3 ret = new Vector3(Interop.ActorInternal.GetTargetSize(SwigCPtr), true);
738             if (NDalicPINVOKE.SWIGPendingException.Pending)
739                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
740             return ret;
741 #endif
742         }
743
744         internal Size2D GetCurrentSize()
745         {
746 #if NUI_PROPERTY_CHANGE_3
747             if(internalCurrentSize == null)
748             {
749                 internalCurrentSize = new Size2D(0, 0);
750             }
751             
752             Interop.ActorInternal.RetrieveCurrentPropertyVector2ActualVector3(SwigCPtr, Property.SIZE, internalCurrentSize.SwigCPtr);
753
754             if (NDalicPINVOKE.SWIGPendingException.Pending)
755             {
756                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
757             }
758             return internalCurrentSize;
759 #else
760             Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
761             if (NDalicPINVOKE.SWIGPendingException.Pending)
762                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
763             Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
764             ret.Dispose();
765             return size;
766 #endif
767         }
768
769         internal Size2D GetCurrentSizeFloat()
770         {
771             Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
772             if (NDalicPINVOKE.SWIGPendingException.Pending)
773                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
774             return ret;
775         }
776
777         /// <summary>
778         /// GetNaturalSize() function behaviour can be changed for each subclass of View.
779         /// So we make GetNaturalSize() function virtual, and make subclass can define it's owned logic
780         /// </summary>
781         internal virtual Vector3 GetNaturalSize()
782         {
783             Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
784             if (NDalicPINVOKE.SWIGPendingException.Pending)
785                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
786             return ret;
787         }
788
789         internal void SetX(float x)
790         {
791             Interop.ActorInternal.SetX(SwigCPtr, x);
792             if (NDalicPINVOKE.SWIGPendingException.Pending)
793                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
794         }
795
796         internal void SetY(float y)
797         {
798             Interop.ActorInternal.SetY(SwigCPtr, y);
799             if (NDalicPINVOKE.SWIGPendingException.Pending)
800                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
801         }
802
803         internal void SetZ(float z)
804         {
805             Interop.ActorInternal.SetZ(SwigCPtr, z);
806             if (NDalicPINVOKE.SWIGPendingException.Pending)
807                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
808         }
809
810         internal void TranslateBy(Vector3 distance)
811         {
812             Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
813             if (NDalicPINVOKE.SWIGPendingException.Pending)
814                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
815         }
816
817         internal Position GetCurrentPosition()
818         {
819 #if NUI_PROPERTY_CHANGE_3
820             if(internalCurrentPosition == null)
821             {
822                 internalCurrentPosition = new Position(0, 0, 0);
823             }
824             
825             Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, Property.POSITION, internalCurrentPosition.SwigCPtr);
826
827             if (NDalicPINVOKE.SWIGPendingException.Pending)
828             {
829                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
830             }
831             return internalCurrentPosition;
832 #else
833
834             Position ret = new Position(Interop.Actor.GetCurrentPosition(SwigCPtr), true);
835             if (NDalicPINVOKE.SWIGPendingException.Pending)
836                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
837             return ret;
838 #endif
839         }
840         internal Vector3 GetCurrentWorldPosition()
841         {
842 #if NUI_PROPERTY_CHANGE_3
843             if(internalCurrentWorldPosition == null)
844             {
845                 internalCurrentWorldPosition = new Vector3(0, 0, 0);
846             }
847             
848             Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.WorldPosition, internalCurrentWorldPosition.SwigCPtr);
849
850             if (NDalicPINVOKE.SWIGPendingException.Pending)
851             {
852                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
853             }
854             return internalCurrentWorldPosition;
855 #else
856             Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldPosition(SwigCPtr), true);
857             if (NDalicPINVOKE.SWIGPendingException.Pending)
858                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
859             return ret;
860 #endif
861         }
862
863         internal Vector2 GetCurrentScreenPosition()
864         {
865 #if NUI_VISUAL_PROPERTY_CHANGE_1
866             if(internalCurrentScreenPosition == null)
867             {
868                 internalCurrentScreenPosition = new Vector2(0, 0);
869             }
870
871             Object.InternalRetrievingPropertyVector2(SwigCPtr, View.Property.ScreenPosition, internalCurrentScreenPosition.SwigCPtr);
872
873             if (NDalicPINVOKE.SWIGPendingException.Pending)
874             {
875                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
876             }
877             return internalCurrentScreenPosition;
878 #else
879             Vector2 temp = new Vector2(0.0f, 0.0f);
880             var pValue = GetProperty(View.Property.ScreenPosition);
881             pValue.Get(temp);
882             pValue.Dispose();
883             return temp;
884 #endif
885         }
886
887         internal void SetInheritPosition(bool inherit)
888         {
889             Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
890             if (NDalicPINVOKE.SWIGPendingException.Pending)
891                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
892         }
893
894         internal bool IsPositionInherited()
895         {
896             bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
897             if (NDalicPINVOKE.SWIGPendingException.Pending)
898                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
899             return ret;
900         }
901
902         internal void SetOrientation(Degree angle, Vector3 axis)
903         {
904             Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
905             if (NDalicPINVOKE.SWIGPendingException.Pending)
906                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
907         }
908
909         internal void SetOrientation(Radian angle, Vector3 axis)
910         {
911             Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
912             if (NDalicPINVOKE.SWIGPendingException.Pending)
913                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
914         }
915
916         internal void SetOrientation(Rotation orientation)
917         {
918             Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
919             if (NDalicPINVOKE.SWIGPendingException.Pending)
920                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
921         }
922
923         internal Rotation GetCurrentOrientation()
924         {
925             Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
926             if (NDalicPINVOKE.SWIGPendingException.Pending)
927                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
928             return ret;
929         }
930
931         internal void SetInheritOrientation(bool inherit)
932         {
933             Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
934             if (NDalicPINVOKE.SWIGPendingException.Pending)
935                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
936         }
937
938         internal bool IsOrientationInherited()
939         {
940             bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
941             if (NDalicPINVOKE.SWIGPendingException.Pending)
942                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
943             return ret;
944         }
945
946         internal Rotation GetCurrentWorldOrientation()
947         {
948             Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
949             if (NDalicPINVOKE.SWIGPendingException.Pending)
950                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
951             return ret;
952         }
953
954         internal void SetScale(float scale)
955         {
956             Interop.ActorInternal.SetScale(SwigCPtr, scale);
957             if (NDalicPINVOKE.SWIGPendingException.Pending)
958                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
959         }
960
961         internal void SetScale(float scaleX, float scaleY, float scaleZ)
962         {
963             Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
964             if (NDalicPINVOKE.SWIGPendingException.Pending)
965                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
966         }
967
968         internal void SetScale(Vector3 scale)
969         {
970             Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
971             if (NDalicPINVOKE.SWIGPendingException.Pending)
972                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
973         }
974
975         internal Vector3 GetCurrentScale()
976         {
977 #if NUI_PROPERTY_CHANGE_3
978             if(internalCurrentScale == null)
979             {
980                 internalCurrentScale = new Vector3(0, 0, 0);
981             }
982             
983             Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.SCALE, internalCurrentScale.SwigCPtr);
984
985             if (NDalicPINVOKE.SWIGPendingException.Pending)
986             {
987                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
988             }
989             return internalCurrentScale;
990 #else
991
992             Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentScale(SwigCPtr), true);
993             if (NDalicPINVOKE.SWIGPendingException.Pending)
994                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
995             return ret;
996 #endif        
997         }
998
999         internal Vector3 GetCurrentWorldScale()
1000         {
1001 #if NUI_PROPERTY_CHANGE_3
1002             if(internalCurrentWorldScale == null)
1003             {
1004                 internalCurrentWorldScale = new Vector3(0, 0, 0);
1005             }
1006             
1007             Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.WorldScale, internalCurrentWorldScale.SwigCPtr);
1008
1009             if (NDalicPINVOKE.SWIGPendingException.Pending)
1010             {
1011                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1012             }
1013             return internalCurrentWorldScale;
1014 #else
1015
1016             Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldScale(SwigCPtr), true);
1017             if (NDalicPINVOKE.SWIGPendingException.Pending)
1018                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1019             return ret;
1020 #endif
1021         }
1022
1023         internal void SetInheritScale(bool inherit)
1024         {
1025             Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
1026             if (NDalicPINVOKE.SWIGPendingException.Pending)
1027                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1028         }
1029
1030         internal bool IsScaleInherited()
1031         {
1032             bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
1033             if (NDalicPINVOKE.SWIGPendingException.Pending)
1034                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1035             return ret;
1036         }
1037
1038         internal Matrix GetCurrentWorldMatrix()
1039         {
1040             Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
1041             if (NDalicPINVOKE.SWIGPendingException.Pending)
1042                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1043             return ret;
1044         }
1045
1046         internal void SetVisible(bool visible)
1047         {
1048             Interop.Actor.SetVisible(SwigCPtr, visible);
1049             if (NDalicPINVOKE.SWIGPendingException.Pending)
1050                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1051         }
1052
1053         /// <summary>
1054         /// Retrieve the View's current Visibility.
1055         /// </summary>
1056         /// <remarks>
1057         /// The <see cref="Visibility"/> property is set in the main thread, so it is not updated in real time when the value is changed in the render thread.
1058         /// However, this method can get the current actual value updated in real time.
1059         /// </remarks>
1060         internal bool IsVisible()
1061         {
1062             bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
1063             if (NDalicPINVOKE.SWIGPendingException.Pending)
1064                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1065             return ret;
1066         }
1067
1068         internal void SetOpacity(float opacity)
1069         {
1070             Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
1071             if (NDalicPINVOKE.SWIGPendingException.Pending)
1072                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1073         }
1074
1075         internal float GetCurrentOpacity()
1076         {
1077             float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
1078             if (NDalicPINVOKE.SWIGPendingException.Pending)
1079                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1080             return ret;
1081         }
1082
1083         internal Vector4 GetCurrentColor()
1084         {
1085 #if NUI_PROPERTY_CHANGE_3
1086             if(internalCurrentColor == null)
1087             {
1088                 internalCurrentColor = new Vector4(0, 0, 0, 0);
1089             }
1090             
1091             Interop.ActorInternal.RetrieveCurrentPropertyVector4(SwigCPtr, Interop.ActorProperty.ColorGet(), internalCurrentColor.SwigCPtr);
1092
1093             if (NDalicPINVOKE.SWIGPendingException.Pending)
1094             {
1095                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1096             }
1097             return internalCurrentColor;
1098 #else
1099
1100             Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentColor(SwigCPtr), true);
1101             if (NDalicPINVOKE.SWIGPendingException.Pending)
1102                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1103             return ret;
1104 #endif
1105         }
1106         internal ColorMode GetColorMode()
1107         {
1108             ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
1109             if (NDalicPINVOKE.SWIGPendingException.Pending)
1110                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1111             return ret;
1112         }
1113
1114         internal Vector4 GetCurrentWorldColor()
1115         {
1116 #if NUI_PROPERTY_CHANGE_3
1117             if(internalCurrentWorldColor == null)
1118             {
1119                 internalCurrentWorldColor = new Vector4(0, 0, 0, 0);
1120             }
1121             
1122             Interop.ActorInternal.RetrieveCurrentPropertyVector4(SwigCPtr, Property.WorldColor, internalCurrentWorldColor.SwigCPtr);
1123
1124             if (NDalicPINVOKE.SWIGPendingException.Pending)
1125             {
1126                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1127             }
1128             return internalCurrentWorldColor;
1129 #else
1130
1131             Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentWorldColor(SwigCPtr), true);
1132             if (NDalicPINVOKE.SWIGPendingException.Pending)
1133                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1134             return ret;
1135 #endif            
1136         }
1137
1138         internal void SetDrawMode(DrawModeType drawMode)
1139         {
1140             Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
1141             if (NDalicPINVOKE.SWIGPendingException.Pending)
1142                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1143         }
1144
1145         internal DrawModeType GetDrawMode()
1146         {
1147             DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
1148             if (NDalicPINVOKE.SWIGPendingException.Pending)
1149                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1150             return ret;
1151         }
1152
1153         internal void SetKeyboardFocusable(bool focusable)
1154         {
1155             Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
1156             if (NDalicPINVOKE.SWIGPendingException.Pending)
1157                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1158         }
1159
1160         internal bool IsKeyboardFocusable()
1161         {
1162             bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
1163             if (NDalicPINVOKE.SWIGPendingException.Pending)
1164                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1165             return ret;
1166         }
1167
1168         internal void SetKeyboardFocusableChildren(bool focusable)
1169         {
1170             Interop.ActorInternal.SetKeyboardFocusableChildren(SwigCPtr, focusable);
1171             if (NDalicPINVOKE.SWIGPendingException.Pending)
1172                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1173         }
1174
1175         internal bool AreChildrenKeyBoardFocusable()
1176         {
1177             bool ret = Interop.ActorInternal.AreChildrenKeyBoardFocusable(SwigCPtr);
1178             if (NDalicPINVOKE.SWIGPendingException.Pending)
1179                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1180             return ret;
1181         }
1182
1183         internal void SetFocusableInTouch(bool enabled)
1184         {
1185             Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled);
1186             if (NDalicPINVOKE.SWIGPendingException.Pending)
1187                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1188         }
1189
1190         internal bool IsFocusableInTouch()
1191         {
1192             bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr);
1193             if (NDalicPINVOKE.SWIGPendingException.Pending)
1194                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1195             return ret;
1196         }
1197
1198         internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
1199         {
1200             Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
1201             if (NDalicPINVOKE.SWIGPendingException.Pending)
1202                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1203         }
1204
1205         internal ResizePolicyType GetResizePolicy(DimensionType dimension)
1206         {
1207             ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
1208             if (NDalicPINVOKE.SWIGPendingException.Pending)
1209                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1210             return ret;
1211         }
1212
1213         internal Vector3 GetSizeModeFactor()
1214         {
1215 #if NUI_PROPERTY_CHANGE_1
1216                 if (internalSizeModeFactor == null)
1217                 {
1218                     internalSizeModeFactor = new Vector3(OnSizeModeFactorChanged, 0, 0, 0);
1219                 }
1220                 Object.InternalRetrievingPropertyVector3(SwigCPtr, View.Property.SizeModeFactor, internalSizeModeFactor.SwigCPtr);
1221                 return internalSizeModeFactor;
1222 #else
1223
1224             Vector3 ret = new Vector3(Interop.Actor.GetSizeModeFactor(SwigCPtr), true);
1225             if (NDalicPINVOKE.SWIGPendingException.Pending)
1226                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1227             return ret;
1228 #endif
1229         }
1230
1231         internal void SetMinimumSize(Vector2 size)
1232         {
1233             Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
1234             if (NDalicPINVOKE.SWIGPendingException.Pending)
1235                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1236         }
1237
1238         internal Vector2 GetMinimumSize()
1239         {
1240 #if NUI_PROPERTY_CHANGE_1
1241             if (internalMinimumSize == null)
1242             {
1243                 internalMinimumSize = new Size2D(OnMinimumSizeChanged, 0, 0);
1244             }
1245             Object.InternalRetrievingPropertyVector2(SwigCPtr, View.Property.MinimumSize, internalMinimumSize.SwigCPtr);
1246             return internalMinimumSize;
1247 #else
1248             Vector2 ret = new Vector2(Interop.ActorInternal.GetMinimumSize(SwigCPtr), true);
1249             if (NDalicPINVOKE.SWIGPendingException.Pending)
1250                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1251             return ret;
1252 #endif
1253         }
1254
1255         internal void SetMaximumSize(Vector2 size)
1256         {
1257             Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
1258             if (NDalicPINVOKE.SWIGPendingException.Pending)
1259                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1260         }
1261
1262         internal Vector2 GetMaximumSize()
1263         {
1264 #if NUI_PROPERTY_CHANGE_1
1265             if (internalMaximumSize == null)
1266             {
1267                 internalMaximumSize = new Size2D(OnMaximumSizeChanged, 0, 0);
1268             }
1269             Object.InternalRetrievingPropertyVector2(SwigCPtr, View.Property.MaximumSize, internalMaximumSize.SwigCPtr);
1270             return internalMaximumSize;
1271 #else
1272
1273             Vector2 ret = new Vector2(Interop.ActorInternal.GetMaximumSize(SwigCPtr), true);
1274             if (NDalicPINVOKE.SWIGPendingException.Pending)
1275                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1276             return ret;
1277 #endif
1278         }
1279
1280         internal int GetHierarchyDepth()
1281         {
1282             int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
1283             if (NDalicPINVOKE.SWIGPendingException.Pending)
1284                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1285             return ret;
1286         }
1287
1288         internal uint GetRendererCount()
1289         {
1290             uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
1291             if (NDalicPINVOKE.SWIGPendingException.Pending)
1292                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1293             return ret;
1294         }
1295
1296         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
1297         {
1298             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1299         }
1300
1301         internal bool IsTopLevelView()
1302         {
1303             if (GetParent() is Layer)
1304             {
1305                 return true;
1306             }
1307             return false;
1308         }
1309
1310         /// <summary>
1311         /// Check whether Current view don't has BackgroundVisual or not.
1312         /// Some API (like Animation, Borderline) required non-empty backgrounds.
1313         /// </summary>
1314         internal bool IsBackgroundEmpty()
1315         {
1316 #if NUI_VISUAL_PROPERTY_CHANGE_1
1317             int visualType = (int)Visual.Type.Invalid;
1318             Interop.View.InternalRetrievingVisualPropertyInt(this.SwigCPtr, Property.BACKGROUND, Visual.Property.Type, out visualType);
1319             return visualType == (int)Visual.Type.Invalid;
1320 #else
1321             PropertyMap background = Background;
1322             return (background == null || background.Empty());
1323 #endif
1324         }
1325
1326         internal void SetKeyInputFocus()
1327         {
1328             Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
1329             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1330         }
1331
1332         internal void ClearKeyInputFocus()
1333         {
1334             Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
1335             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1336         }
1337
1338         internal PinchGestureDetector GetPinchGestureDetector()
1339         {
1340             PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
1341             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1342             return ret;
1343         }
1344
1345         internal PanGestureDetector GetPanGestureDetector()
1346         {
1347             PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
1348             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1349             return ret;
1350         }
1351
1352         internal TapGestureDetector GetTapGestureDetector()
1353         {
1354             TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
1355             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1356             return ret;
1357         }
1358
1359         internal LongPressGestureDetector GetLongPressGestureDetector()
1360         {
1361             LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
1362             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1363             return ret;
1364         }
1365
1366         internal IntPtr GetPtrfromView()
1367         {
1368             return (IntPtr)SwigCPtr;
1369         }
1370
1371         internal void RemoveChild(View child)
1372         {
1373             // If the view had focus, it clears focus.
1374             if (child == FocusManager.Instance.GetCurrentFocusView())
1375             {
1376                 FocusManager.Instance.ClearFocus();
1377             }
1378             // Do actual child removal
1379             Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1380             if (NDalicPINVOKE.SWIGPendingException.Pending)
1381                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1382
1383             Children.Remove(child);
1384             child.InternalParent = null;
1385             LayoutCount -= child.LayoutCount;
1386
1387             OnChildRemoved(child);
1388             if (ChildRemoved != null)
1389             {
1390                 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1391                 {
1392                     Removed = child
1393                 };
1394                 ChildRemoved(this, e);
1395             }
1396         }
1397
1398         /// <summary>
1399         /// Removes the layout from this View.
1400         /// </summary>
1401         internal void ResetLayout()
1402         {
1403             LayoutCount--;
1404
1405             layout = null;
1406         }
1407
1408         internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1409         {
1410             return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1411         }
1412
1413         /// TODO open as a protected level
1414         internal virtual void ApplyCornerRadius()
1415         {
1416             if (backgroundExtraData == null) return;
1417
1418 #if NUI_VISUAL_PROPERTY_CHANGE_1
1419             // Update corner radius properties to background and shadow by ActionUpdateProperty
1420             if (backgroundExtraData.CornerRadius != null)
1421             {
1422                 Interop.View.InternalUpdateVisualPropertyVector4(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.CornerRadius, Vector4.getCPtr(backgroundExtraData.CornerRadius));
1423                 Interop.View.InternalUpdateVisualPropertyVector4(this.SwigCPtr, View.Property.SHADOW, Visual.Property.CornerRadius, Vector4.getCPtr(backgroundExtraData.CornerRadius));
1424             }
1425             Interop.View.InternalUpdateVisualPropertyInt(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.CornerRadiusPolicy, (int)backgroundExtraData.CornerRadiusPolicy);
1426             Interop.View.InternalUpdateVisualPropertyInt(this.SwigCPtr, View.Property.SHADOW, Visual.Property.CornerRadiusPolicy, (int)backgroundExtraData.CornerRadiusPolicy);
1427 #else
1428             var cornerRadiusValue = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
1429             var cornerRadiusPolicyValue = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1430
1431             // Make current propertyMap
1432             PropertyMap currentPropertyMap = new PropertyMap();
1433             currentPropertyMap[Visual.Property.CornerRadius] = cornerRadiusValue;
1434             currentPropertyMap[Visual.Property.CornerRadiusPolicy] = cornerRadiusPolicyValue;
1435             var temp = new PropertyValue(currentPropertyMap);
1436
1437             // Update corner radius properties to background and shadow by ActionUpdateProperty
1438             DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1439             DoAction(View.Property.SHADOW, ActionUpdateProperty, temp);
1440
1441             temp.Dispose();
1442             currentPropertyMap.Dispose();
1443             cornerRadiusValue.Dispose();
1444             cornerRadiusPolicyValue.Dispose();
1445 #endif
1446         }
1447
1448         /// TODO open as a protected level
1449         internal virtual void ApplyBorderline()
1450         {
1451             if (backgroundExtraData == null) return;
1452
1453 #if NUI_VISUAL_PROPERTY_CHANGE_1
1454             // ActionUpdateProperty works well only if BACKGROUND visual setup before.
1455             // If view don't have BACKGROUND visual, we set transparent background color in default.
1456             if (IsBackgroundEmpty())
1457             {
1458                 // BACKGROUND visual doesn't exist.
1459                 SetBackgroundColor(Color.Transparent);
1460                 // SetBackgroundColor function apply borderline internally.
1461                 // So we can just return now.
1462                 return;
1463             }
1464
1465             // Update borderline properties to background by ActionUpdateProperty
1466             Interop.View.InternalUpdateVisualPropertyFloat(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.BorderlineWidth, backgroundExtraData.BorderlineWidth);
1467             Interop.View.InternalUpdateVisualPropertyVector4(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.BorderlineColor, Vector4.getCPtr(backgroundExtraData.BorderlineColor ?? Color.Black));
1468             Interop.View.InternalUpdateVisualPropertyFloat(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.BorderlineOffset, backgroundExtraData.BorderlineOffset);
1469 #else
1470             // ActionUpdateProperty works well only if BACKGROUND visual setup before.
1471             // If view don't have BACKGROUND visual, we set transparent background color in default.
1472             using (PropertyMap backgroundPropertyMap = new PropertyMap())
1473             {
1474                 using (PropertyValue propertyValue = Object.GetProperty(SwigCPtr, Property.BACKGROUND))
1475                 {
1476                     propertyValue?.Get(backgroundPropertyMap);
1477                     if (backgroundPropertyMap.Empty())
1478                     {
1479                         // BACKGROUND visual doesn't exist.
1480                         SetBackgroundColor(Color.Transparent);
1481                         // SetBackgroundColor function apply borderline internally.
1482                         // So we can just return now.
1483                         return;
1484                     }
1485                 }
1486             }
1487
1488             var borderlineWidthValue = new PropertyValue(backgroundExtraData.BorderlineWidth);
1489             var borderlineColorValue = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
1490             var borderlineOffsetValue = new PropertyValue(backgroundExtraData.BorderlineOffset);
1491
1492             // Make current propertyMap
1493             PropertyMap currentPropertyMap = new PropertyMap();
1494             currentPropertyMap[Visual.Property.BorderlineWidth] = borderlineWidthValue;
1495             currentPropertyMap[Visual.Property.BorderlineColor] = borderlineColorValue;
1496             currentPropertyMap[Visual.Property.BorderlineOffset] = borderlineOffsetValue;
1497             var temp = new PropertyValue(currentPropertyMap);
1498
1499             // Update borderline properties to background  by ActionUpdateProperty
1500             DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1501
1502             temp.Dispose();
1503             currentPropertyMap.Dispose();
1504             borderlineWidthValue.Dispose();
1505             borderlineColorValue.Dispose();
1506             borderlineOffsetValue.Dispose();
1507 #endif
1508         }
1509
1510         /// <summary>
1511         /// Get selector value from the triggerable selector or related property.
1512         /// </summary>
1513         internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1514         {
1515             var selector = triggerableSelector?.Get();
1516             if (selector != null)
1517             {
1518                 return selector;
1519             }
1520
1521             var value = (T)GetValue(relatedProperty);
1522             return value == null ? null : new Selector<T>(value);
1523         }
1524
1525         internal void SetThemeApplied()
1526         {
1527             if (themeData == null) themeData = new ThemeData();
1528             themeData.ThemeApplied = true;
1529
1530             if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
1531             {
1532                 themeData.ListeningThemeChangeEvent = true;
1533                 ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
1534             }
1535         }
1536
1537         /// <summary>
1538         /// you can override it to clean-up your own resources.
1539         /// </summary>
1540         /// <param name="type">DisposeTypes</param>
1541         /// <since_tizen> 3 </since_tizen>
1542         protected override void Dispose(DisposeTypes type)
1543         {
1544             if (disposed)
1545             {
1546                 return;
1547             }
1548
1549             disposeDebugging(type);
1550
1551             //_mergedStyle = null;
1552
1553             internalMaximumSize?.Dispose();
1554             internalMaximumSize = null;
1555             internalMinimumSize?.Dispose();
1556             internalMinimumSize = null;
1557             internalMargin?.Dispose();
1558             internalMargin = null;
1559             internalPadding?.Dispose();
1560             internalPadding = null;
1561             internalSizeModeFactor?.Dispose();
1562             internalSizeModeFactor = null;
1563             internalCellIndex?.Dispose();
1564             internalCellIndex = null;
1565             internalBackgroundColor?.Dispose();
1566             internalBackgroundColor = null;
1567             internalColor?.Dispose();
1568             internalColor = null;
1569             internalPivotPoint?.Dispose();
1570             internalPivotPoint = null;
1571             internalPosition?.Dispose();
1572             internalPosition = null;
1573             internalPosition2D?.Dispose();
1574             internalPosition2D = null;
1575             internalScale?.Dispose();
1576             internalScale = null;
1577             internalSize?.Dispose();
1578             internalSize = null;
1579             internalSize2D?.Dispose();
1580             internalSize2D = null;
1581
1582             panGestureDetector?.Dispose();
1583             panGestureDetector = null;
1584             longGestureDetector?.Dispose();
1585             longGestureDetector = null;
1586             pinchGestureDetector?.Dispose();
1587             pinchGestureDetector = null;
1588             tapGestureDetector?.Dispose();
1589             tapGestureDetector = null;
1590             rotationGestureDetector?.Dispose();
1591             rotationGestureDetector = null;
1592
1593 #if NUI_PROPERTY_CHANGE_3
1594             internalCurrentParentOrigin?.Dispose();
1595             internalCurrentParentOrigin = null;
1596             internalCurrentAnchorPoint?.Dispose();
1597             internalCurrentAnchorPoint = null;
1598             internalTargetSize?.Dispose();
1599             internalTargetSize = null;
1600             internalCurrentSize?.Dispose();
1601             internalCurrentSize = null;
1602             internalNaturalSize?.Dispose();
1603             internalNaturalSize = null;
1604             internalCurrentPosition?.Dispose();
1605             internalCurrentPosition = null;
1606             internalCurrentWorldPosition?.Dispose();
1607             internalCurrentWorldPosition = null;
1608             internalCurrentScale?.Dispose();
1609             internalCurrentScale = null;
1610             internalCurrentWorldScale?.Dispose();
1611             internalCurrentWorldScale = null;
1612             internalCurrentColor?.Dispose();
1613             internalCurrentColor = null;
1614             internalCurrentWorldColor?.Dispose();
1615             internalCurrentWorldColor = null;
1616             internalSizeModeFactor?.Dispose();
1617             internalSizeModeFactor = null;
1618 #endif
1619 #if NUI_VISUAL_PROPERTY_CHANGE_1
1620             internalCurrentScreenPosition?.Dispose();
1621             internalCurrentScreenPosition = null;
1622 #endif
1623
1624             if (type == DisposeTypes.Explicit)
1625             {
1626                 //Called by User
1627                 //Release your own managed resources here.
1628                 //You should release all of your own disposable objects here.
1629                 if (themeData != null)
1630                 {
1631                     themeData.selectorData?.Reset(this);
1632                     if (themeData.ListeningThemeChangeEvent)
1633                     {
1634                         ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1635                     }
1636                 }
1637                 if (widthConstraint != null)
1638                 {
1639                     widthConstraint.Remove();
1640                     widthConstraint.Dispose();
1641                 }
1642                 if (heightConstraint != null)
1643                 {
1644                     heightConstraint.Remove();
1645                     heightConstraint.Dispose();
1646                 }
1647             }
1648
1649             //Release your own unmanaged resources here.
1650             //You should not access any managed member here except static instance.
1651             //because the execution order of Finalizes is non-deterministic.
1652
1653             DisConnectFromSignals();
1654
1655             foreach (View view in Children)
1656             {
1657                 view.InternalParent = null;
1658             }
1659
1660             LayoutCount = 0;
1661
1662             NUILog.Debug($"[Dispose] View.Dispose({type}) END");
1663             NUILog.Debug($"=============================");
1664
1665             base.Dispose(type);
1666         }
1667
1668         /// This will not be public opened.
1669         [EditorBrowsable(EditorBrowsableState.Never)]
1670         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1671         {
1672             Interop.View.DeleteView(swigCPtr);
1673         }
1674
1675         /// <summary>
1676         /// The touch event handler for ControlState.
1677         /// Please change ControlState value by touch state if needed.
1678         /// </summary>
1679         /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1680         [EditorBrowsable(EditorBrowsableState.Never)]
1681         protected virtual bool HandleControlStateOnTouch(Touch touch)
1682         {
1683             if (touch == null)
1684             {
1685                 throw new global::System.ArgumentNullException(nameof(touch));
1686             }
1687
1688             switch (touch.GetState(0))
1689             {
1690                 case PointStateType.Down:
1691                     ControlState += ControlState.Pressed;
1692                     break;
1693                 case PointStateType.Interrupted:
1694                 case PointStateType.Up:
1695                     if (ControlState.Contains(ControlState.Pressed))
1696                     {
1697                         ControlState -= ControlState.Pressed;
1698                     }
1699                     break;
1700                 default:
1701                     break;
1702             }
1703             return false;
1704         }
1705
1706         /// <summary>
1707         /// Internal callback of enabled property changes.
1708         /// Inherited view can override this method to implements enabled property changes.
1709         /// </summary>
1710         [EditorBrowsable(EditorBrowsableState.Never)]
1711         protected virtual void OnEnabled(bool enabled)
1712         {
1713             if (enabled)
1714             {
1715                 if (State == View.States.Disabled)
1716                 {
1717                     State = View.States.Normal;
1718                 }
1719                 if (enableControlState)
1720                 {
1721                     ControlState -= ControlState.Disabled;
1722                 }
1723             }
1724             else
1725             {
1726                 State = View.States.Disabled;
1727                 if (enableControlState)
1728                 {
1729                     ControlState += ControlState.Disabled;
1730                 }
1731             }
1732         }
1733
1734
1735         private void DisConnectFromSignals()
1736         {
1737             if (HasBody() == false)
1738             {
1739                 NUILog.Debug($"[Dispose] DisConnectFromSignals() No native body! No need to Disconnect Signals!");
1740                 return;
1741             }
1742             NUILog.Debug($"[Dispose] DisConnectFromSignals START");
1743             NUILog.Debug($"[Dispose] View.DisConnectFromSignals() type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1744             NUILog.Debug($"[Dispose] ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1745
1746             if (onRelayoutEventCallback != null)
1747             {
1748                 NUILog.Debug($"[Dispose] onRelayoutEventCallback");
1749
1750                 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(GetBaseHandleCPtrHandleRef), false);
1751                 signal?.Disconnect(onRelayoutEventCallback);
1752                 onRelayoutEventCallback = null;
1753             }
1754
1755             if (offWindowEventCallback != null)
1756             {
1757                 NUILog.Debug($"[Dispose] offWindowEventCallback");
1758
1759                 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(GetBaseHandleCPtrHandleRef), false);
1760                 signal?.Disconnect(offWindowEventCallback);
1761                 offWindowEventCallback = null;
1762             }
1763
1764             if (onWindowEventCallback != null)
1765             {
1766                 NUILog.Debug($"[Dispose] onWindowEventCallback");
1767
1768                 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1769                 signal?.Disconnect(onWindowEventCallback);
1770                 onWindowEventCallback = null;
1771             }
1772
1773             if (wheelEventCallback != null)
1774             {
1775                 NUILog.Debug($"[Dispose] wheelEventCallback");
1776
1777                 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(GetBaseHandleCPtrHandleRef), false);
1778                 signal?.Disconnect(wheelEventCallback);
1779                 wheelEventCallback = null;
1780             }
1781
1782             if (hoverEventCallback != null)
1783             {
1784                 NUILog.Debug($"[Dispose] hoverEventCallback");
1785
1786                 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(GetBaseHandleCPtrHandleRef), false);
1787                 signal?.Disconnect(hoverEventCallback);
1788                 hoverEventCallback = null;
1789             }
1790
1791             if (hitTestResultDataCallback != null)
1792             {
1793                 NUILog.Debug($"[Dispose] hitTestResultDataCallback");
1794
1795                 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorHitTestResultSignal(GetBaseHandleCPtrHandleRef), false);
1796                 signal?.Disconnect(hitTestResultDataCallback);
1797                 hitTestResultDataCallback = null;
1798             }
1799
1800
1801             if (interceptTouchDataCallback != null)
1802             {
1803                 NUILog.Debug($"[Dispose] interceptTouchDataCallback");
1804
1805                 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(GetBaseHandleCPtrHandleRef), false);
1806                 signal?.Disconnect(interceptTouchDataCallback);
1807                 interceptTouchDataCallback = null;
1808             }
1809
1810             if (touchDataCallback != null)
1811             {
1812                 NUILog.Debug($"[Dispose] touchDataCallback");
1813
1814                 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(GetBaseHandleCPtrHandleRef), false);
1815                 signal?.Disconnect(touchDataCallback);
1816                 touchDataCallback = null;
1817             }
1818
1819             if (ResourcesLoadedCallback != null)
1820             {
1821                 NUILog.Debug($"[Dispose] ResourcesLoadedCallback");
1822
1823                 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1824                 signal?.Disconnect(ResourcesLoadedCallback);
1825                 ResourcesLoadedCallback = null;
1826             }
1827
1828             if (keyCallback != null)
1829             {
1830                 NUILog.Debug($"[Dispose] keyCallback");
1831
1832                 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(GetBaseHandleCPtrHandleRef), false);
1833                 signal?.Disconnect(keyCallback);
1834                 keyCallback = null;
1835             }
1836
1837             if (keyInputFocusLostCallback != null)
1838             {
1839                 NUILog.Debug($"[Dispose] keyInputFocusLostCallback");
1840
1841                 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(GetBaseHandleCPtrHandleRef), false);
1842                 signal?.Disconnect(keyInputFocusLostCallback);
1843                 keyInputFocusLostCallback = null;
1844                 keyInputFocusLostEventHandler = null;
1845             }
1846
1847             if (keyInputFocusGainedCallback != null)
1848             {
1849                 NUILog.Debug($"[Dispose] keyInputFocusGainedCallback");
1850
1851                 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(GetBaseHandleCPtrHandleRef), false);
1852                 signal?.Disconnect(keyInputFocusGainedCallback);
1853                 keyInputFocusGainedCallback = null;
1854                 keyInputFocusGainedEventHandler = null;
1855             }
1856
1857             if (backgroundResourceLoadedCallback != null)
1858             {
1859                 NUILog.Debug($"[Dispose] backgroundResourceLoadedCallback");
1860
1861                 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1862                 signal?.Disconnect(backgroundResourceLoadedCallback);
1863                 backgroundResourceLoadedCallback = null;
1864             }
1865
1866             if (onWindowSendEventCallback != null)
1867             {
1868                 NUILog.Debug($"[Dispose] onWindowSendEventCallback");
1869
1870                 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1871                 signal?.Disconnect(onWindowSendEventCallback);
1872                 onWindowSendEventCallback = null;
1873             }
1874             NUILog.Debug($"[Dispose] DisConnectFromSignals END");
1875         }
1876
1877         /// <summary>
1878         /// Apply initial style to the view.
1879         /// </summary>
1880         [EditorBrowsable(EditorBrowsableState.Never)]
1881         protected virtual void InitializeStyle(ViewStyle style = null)
1882         {
1883             var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
1884             if (style == null)
1885             {
1886                 ApplyStyle(initialStyle);
1887             }
1888             else
1889             {
1890                 var refinedStyle = style;
1891                 if (style.IncludeDefaultStyle)
1892                 {
1893                     refinedStyle = initialStyle?.Merge(style);
1894                 }
1895                 ApplyStyle(refinedStyle);
1896             }
1897
1898             // Listen theme change event if needs.
1899             if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
1900             {
1901                 SetThemeApplied();
1902             }
1903         }
1904
1905         private View ConvertIdToView(uint id)
1906         {
1907             View view = GetParent()?.FindCurrentChildById(id);
1908
1909             //If we can't find the parent's children, find in the top layer.
1910             if (!view)
1911             {
1912                 Container parent = GetParent();
1913                 while ((parent is View) && (parent != null))
1914                 {
1915                     parent = parent.GetParent();
1916                     if (parent is Layer)
1917                     {
1918                         view = parent.FindCurrentChildById(id);
1919                         break;
1920                     }
1921                 }
1922             }
1923
1924             return view;
1925         }
1926
1927         private void OnScaleChanged(float x, float y, float z)
1928         {
1929             Scale = new Vector3(x, y, z);
1930         }
1931
1932         private void OnBackgroundColorChanged(float r, float g, float b, float a)
1933         {
1934             BackgroundColor = new Color(r, g, b, a);
1935         }
1936
1937         private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1938         {
1939             Padding = new Extents(start, end, top, bottom);
1940         }
1941
1942         private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1943         {
1944             Margin = new Extents(start, end, top, bottom);
1945         }
1946
1947         private void OnAnchorPointChanged(float x, float y, float z)
1948         {
1949             AnchorPoint = new Position(x, y, z);
1950         }
1951
1952         private void OnCellIndexChanged(float x, float y)
1953         {
1954             CellIndex = new Vector2(x, y);
1955         }
1956
1957         private void OnFlexMarginChanged(float x, float y, float z, float w)
1958         {
1959             FlexMargin = new Vector4(x, y, z, w);
1960         }
1961
1962         private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1963         {
1964             PaddingEX = new Extents(start, end, top, bottom);
1965         }
1966
1967         private void OnSizeModeFactorChanged(float x, float y, float z)
1968         {
1969             SizeModeFactor = new Vector3(x, y, z);
1970         }
1971
1972         private bool EmptyOnTouch(object target, TouchEventArgs args)
1973         {
1974             return false;
1975         }
1976
1977         [EditorBrowsable(EditorBrowsableState.Never)]
1978         protected virtual bool CheckResourceReady()
1979         {
1980             return true;
1981         }
1982
1983         private ViewSelectorData EnsureSelectorData()
1984         {
1985             if (themeData == null) themeData = new ThemeData();
1986
1987             return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());
1988         }
1989
1990         [Conditional("NUI_DISPOSE_DEBUG_ON")]
1991         private void disposeDebugging(DisposeTypes type)
1992         {
1993             DebugFileLogging.Instance.WriteLog($"View.Dispose({type}) START");
1994             DebugFileLogging.Instance.WriteLog($"type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1995             if (HasBody())
1996             {
1997                 DebugFileLogging.Instance.WriteLog($"ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1998             }
1999             else
2000             {
2001                 DebugFileLogging.Instance.WriteLog($"has no native body!");
2002             }
2003         }
2004
2005     }
2006 }