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