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