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