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