2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 using System.ComponentModel;
20 using System.Collections.Generic;
22 using System.Runtime.InteropServices;
23 using Tizen.NUI.Binding;
26 namespace Tizen.NUI.BaseComponents
29 /// View is the base class for all views.
31 /// <since_tizen> 3 </since_tizen>
32 public partial class View
34 private ViewSelectorData selectorData;
35 internal string styleName;
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.
42 internal ColorMode ColorMode
50 return GetColorMode();
54 internal float WorldPositionX
58 float returnValue = 0.0f;
59 PropertyValue wordPositionX = GetProperty(View.Property.WorldPositionX);
60 wordPositionX?.Get(out returnValue);
61 wordPositionX?.Dispose();
66 internal float WorldPositionY
70 float returnValue = 0.0f;
71 PropertyValue wordPositionY = GetProperty(View.Property.WorldPositionY);
72 wordPositionY?.Get(out returnValue);
73 wordPositionY?.Dispose();
78 internal float WorldPositionZ
82 float returnValue = 0.0f;
83 PropertyValue wordPositionZ = GetProperty(View.Property.WorldPositionZ);
84 wordPositionZ?.Get(out returnValue);
85 wordPositionZ?.Dispose();
90 internal bool FocusState
94 return IsKeyboardFocusable();
98 SetKeyboardFocusable(value);
102 internal void SetLayout(LayoutItem layout)
104 this.layout = layout;
105 this.layout?.AttachToOwner(this);
106 this.layout?.RequestLayout();
109 internal void AttachTransitionsToChildren(LayoutTransition transition)
111 // Iterate children, adding the transition unless a transition
112 // for the same condition and property has already been
114 foreach (View view in Children)
116 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
120 internal float ParentOriginX
124 float returnValue = 0.0f;
125 PropertyValue parentOriginX = GetProperty(View.Property.ParentOriginX);
126 parentOriginX?.Get(out returnValue);
127 parentOriginX?.Dispose();
132 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
133 SetProperty(View.Property.ParentOriginX, setValue);
135 NotifyPropertyChanged();
139 internal float ParentOriginY
143 float returnValue = 0.0f;
144 PropertyValue parentOriginY = GetProperty(View.Property.ParentOriginY);
145 parentOriginY?.Get(out returnValue);
146 parentOriginY?.Dispose();
151 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
152 SetProperty(View.Property.ParentOriginY, setValue);
154 NotifyPropertyChanged();
158 internal float ParentOriginZ
162 float returnValue = 0.0f;
163 PropertyValue parentOriginZ = GetProperty(View.Property.ParentOriginZ);
164 parentOriginZ?.Get(out returnValue);
165 parentOriginZ?.Dispose();
170 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
171 SetProperty(View.Property.ParentOriginZ, setValue);
173 NotifyPropertyChanged();
177 internal float PivotPointX
181 float returnValue = 0.0f;
182 PropertyValue anchorPointX = GetProperty(View.Property.AnchorPointX);
183 anchorPointX?.Get(out returnValue);
184 anchorPointX?.Dispose();
189 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
190 SetProperty(View.Property.AnchorPointX, setValue);
195 internal float PivotPointY
199 float returnValue = 0.0f;
200 PropertyValue anchorPointY = GetProperty(View.Property.AnchorPointY);
201 anchorPointY?.Get(out returnValue);
202 anchorPointY?.Dispose();
207 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
208 SetProperty(View.Property.AnchorPointY, setValue);
213 internal float PivotPointZ
217 float returnValue = 0.0f;
218 PropertyValue anchorPointZ = GetProperty(View.Property.AnchorPointZ);
219 anchorPointZ?.Get(out returnValue);
220 anchorPointZ?.Dispose();
225 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
226 SetProperty(View.Property.AnchorPointZ, setValue);
231 internal Matrix WorldMatrix
235 Matrix returnValue = new Matrix();
236 PropertyValue wordMatrix = GetProperty(View.Property.WorldMatrix);
237 wordMatrix?.Get(returnValue);
238 wordMatrix?.Dispose();
244 /// Indicates that this View should listen Touch event to handle its ControlState.
246 private bool enableControlState = false;
248 private int LeftFocusableViewId
253 PropertyValue leftFocusableViewId = GetProperty(View.Property.LeftFocusableViewId);
254 leftFocusableViewId?.Get(out returnValue);
255 leftFocusableViewId?.Dispose();
260 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
261 SetProperty(View.Property.LeftFocusableViewId, setValue);
266 private int RightFocusableViewId
271 PropertyValue rightFocusableViewId = GetProperty(View.Property.RightFocusableViewId);
272 rightFocusableViewId?.Get(out returnValue);
273 rightFocusableViewId?.Dispose();
278 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
279 SetProperty(View.Property.RightFocusableViewId, setValue);
284 private int UpFocusableViewId
289 PropertyValue upFocusableViewId = GetProperty(View.Property.UpFocusableViewId);
290 upFocusableViewId?.Get(out returnValue);
291 upFocusableViewId?.Dispose();
296 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
297 SetProperty(View.Property.UpFocusableViewId, setValue);
302 private int DownFocusableViewId
307 PropertyValue downFocusableViewId = GetProperty(View.Property.DownFocusableViewId);
308 downFocusableViewId?.Get(out returnValue);
309 downFocusableViewId?.Dispose();
314 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
315 SetProperty(View.Property.DownFocusableViewId, setValue);
320 private ViewSelectorData SelectorData
324 if (selectorData == null)
326 selectorData = new ViewSelectorData();
332 internal void Raise()
334 var parentChildren = GetParent()?.Children;
336 if (parentChildren != null)
338 int currentIndex = parentChildren.IndexOf(this);
340 // If the view is not already the last item in the list.
341 if (currentIndex >= 0 && currentIndex < parentChildren.Count - 1)
343 View temp = parentChildren[currentIndex + 1];
344 parentChildren[currentIndex + 1] = this;
345 parentChildren[currentIndex] = temp;
347 Interop.NDalic.Raise(SwigCPtr);
348 if (NDalicPINVOKE.SWIGPendingException.Pending)
349 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
354 internal void Lower()
356 var parentChildren = GetParent()?.Children;
358 if (parentChildren != null)
360 int currentIndex = parentChildren.IndexOf(this);
362 // If the view is not already the first item in the list.
363 if (currentIndex > 0 && currentIndex < parentChildren.Count)
365 View temp = parentChildren[currentIndex - 1];
366 parentChildren[currentIndex - 1] = this;
367 parentChildren[currentIndex] = temp;
369 Interop.NDalic.Lower(SwigCPtr);
370 if (NDalicPINVOKE.SWIGPendingException.Pending)
371 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
377 /// Raises the view to above the target view.
379 /// <remarks>The sibling order of views within the parent will be updated automatically.
380 /// Views on the level above the target view will still be shown above this view.
381 /// Raising this view above views with the same sibling order as each other will raise this view above them.
382 /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
384 /// <param name="target">Will be raised above this view.</param>
385 internal void RaiseAbove(View target)
387 var parentChildren = GetParent()?.Children;
389 if (parentChildren != null)
391 int currentIndex = parentChildren.IndexOf(this);
392 int targetIndex = parentChildren.IndexOf(target);
394 if (currentIndex < 0 || targetIndex < 0 ||
395 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
397 NUILog.Error("index should be bigger than 0 and less than children of layer count");
400 // If the currentIndex is less than the target index and the target has the same parent.
401 if (currentIndex < targetIndex)
403 parentChildren.Remove(this);
404 parentChildren.Insert(targetIndex, this);
406 Interop.NDalic.RaiseAbove(SwigCPtr, View.getCPtr(target));
407 if (NDalicPINVOKE.SWIGPendingException.Pending)
408 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
415 /// Lowers the view to below the target view.
417 /// <remarks>The sibling order of views within the parent will be updated automatically.
418 /// Lowering this view below views with the same sibling order as each other will lower this view above them.
419 /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
421 /// <param name="target">Will be lowered below this view.</param>
422 internal void LowerBelow(View target)
424 var parentChildren = GetParent()?.Children;
426 if (parentChildren != null)
428 int currentIndex = parentChildren.IndexOf(this);
429 int targetIndex = parentChildren.IndexOf(target);
430 if (currentIndex < 0 || targetIndex < 0 ||
431 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
433 NUILog.Error("index should be bigger than 0 and less than children of layer count");
437 // If the currentIndex is not already the 0th index and the target has the same parent.
438 if ((currentIndex != 0) && (targetIndex != -1) &&
439 (currentIndex > targetIndex))
441 parentChildren.Remove(this);
442 parentChildren.Insert(targetIndex, this);
444 Interop.NDalic.LowerBelow(SwigCPtr, View.getCPtr(target));
445 if (NDalicPINVOKE.SWIGPendingException.Pending)
446 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
452 internal string GetName()
454 string ret = Interop.Actor.GetName(SwigCPtr);
455 if (NDalicPINVOKE.SWIGPendingException.Pending)
456 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
460 internal void SetName(string name)
462 Interop.Actor.SetName(SwigCPtr, name);
463 if (NDalicPINVOKE.SWIGPendingException.Pending)
464 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
467 internal uint GetId()
469 uint ret = Interop.Actor.GetId(SwigCPtr);
470 if (NDalicPINVOKE.SWIGPendingException.Pending)
471 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
475 internal bool IsRoot()
477 bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
478 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
482 internal bool OnWindow()
484 bool ret = Interop.Actor.OnStage(SwigCPtr);
485 if (NDalicPINVOKE.SWIGPendingException.Pending)
486 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
490 internal View FindChildById(uint id)
492 //to fix memory leak issue, match the handle count with native side.
493 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
494 View ret = this.GetInstanceSafely<View>(cPtr);
495 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
499 internal override View FindCurrentChildById(uint id)
501 return FindChildById(id);
504 internal void SetParentOrigin(Vector3 origin)
506 Interop.ActorInternal.SetParentOrigin(SwigCPtr, Vector3.getCPtr(origin));
507 if (NDalicPINVOKE.SWIGPendingException.Pending)
508 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
511 internal Vector3 GetCurrentParentOrigin()
513 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentParentOrigin(SwigCPtr), true);
514 if (NDalicPINVOKE.SWIGPendingException.Pending)
515 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
519 internal void SetAnchorPoint(Vector3 anchorPoint)
521 Interop.Actor.SetAnchorPoint(SwigCPtr, Vector3.getCPtr(anchorPoint));
522 if (NDalicPINVOKE.SWIGPendingException.Pending)
523 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
526 internal Vector3 GetCurrentAnchorPoint()
528 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentAnchorPoint(SwigCPtr), true);
529 if (NDalicPINVOKE.SWIGPendingException.Pending)
530 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
534 internal void SetSize(float width, float height)
536 Interop.ActorInternal.SetSize(SwigCPtr, width, height);
537 if (NDalicPINVOKE.SWIGPendingException.Pending)
538 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
541 internal void SetSize(float width, float height, float depth)
543 Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
544 if (NDalicPINVOKE.SWIGPendingException.Pending)
545 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
548 internal void SetSize(Vector2 size)
550 Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
551 if (NDalicPINVOKE.SWIGPendingException.Pending)
552 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
555 internal void SetSize(Vector3 size)
557 Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
558 if (NDalicPINVOKE.SWIGPendingException.Pending)
559 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
562 internal Vector3 GetTargetSize()
564 Vector3 ret = new Vector3(Interop.ActorInternal.GetTargetSize(SwigCPtr), true);
565 if (NDalicPINVOKE.SWIGPendingException.Pending)
566 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
570 internal Size2D GetCurrentSize()
572 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
573 if (NDalicPINVOKE.SWIGPendingException.Pending)
574 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
575 Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
580 internal Size2D GetCurrentSizeFloat()
582 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
583 if (NDalicPINVOKE.SWIGPendingException.Pending)
584 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
588 internal Vector3 GetNaturalSize()
590 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
591 if (NDalicPINVOKE.SWIGPendingException.Pending)
592 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
596 internal void SetPosition(float x, float y)
598 Interop.ActorInternal.SetPosition(SwigCPtr, x, y);
599 if (NDalicPINVOKE.SWIGPendingException.Pending)
600 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
603 internal void SetPosition(float x, float y, float z)
605 Interop.ActorInternal.SetPosition(SwigCPtr, x, y, z);
606 if (NDalicPINVOKE.SWIGPendingException.Pending)
607 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
610 internal void SetPosition(Vector3 position)
612 Interop.ActorInternal.SetPosition(SwigCPtr, Vector3.getCPtr(position));
613 if (NDalicPINVOKE.SWIGPendingException.Pending)
614 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
617 internal void SetX(float x)
619 Interop.ActorInternal.SetX(SwigCPtr, x);
620 if (NDalicPINVOKE.SWIGPendingException.Pending)
621 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
624 internal void SetY(float y)
626 Interop.ActorInternal.SetY(SwigCPtr, y);
627 if (NDalicPINVOKE.SWIGPendingException.Pending)
628 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
631 internal void SetZ(float z)
633 Interop.ActorInternal.SetZ(SwigCPtr, z);
634 if (NDalicPINVOKE.SWIGPendingException.Pending)
635 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
638 internal void TranslateBy(Vector3 distance)
640 Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
641 if (NDalicPINVOKE.SWIGPendingException.Pending)
642 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
645 internal Position GetCurrentPosition()
647 Position ret = new Position(Interop.Actor.GetCurrentPosition(SwigCPtr), true);
648 if (NDalicPINVOKE.SWIGPendingException.Pending)
649 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
653 internal Vector3 GetCurrentWorldPosition()
655 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldPosition(SwigCPtr), true);
656 if (NDalicPINVOKE.SWIGPendingException.Pending)
657 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
661 internal void SetInheritPosition(bool inherit)
663 Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
664 if (NDalicPINVOKE.SWIGPendingException.Pending)
665 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
668 internal bool IsPositionInherited()
670 bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
671 if (NDalicPINVOKE.SWIGPendingException.Pending)
672 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
676 internal void SetOrientation(Degree angle, Vector3 axis)
678 Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
679 if (NDalicPINVOKE.SWIGPendingException.Pending)
680 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
683 internal void SetOrientation(Radian angle, Vector3 axis)
685 Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
686 if (NDalicPINVOKE.SWIGPendingException.Pending)
687 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
690 internal void SetOrientation(Rotation orientation)
692 Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
693 if (NDalicPINVOKE.SWIGPendingException.Pending)
694 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
697 internal Rotation GetCurrentOrientation()
699 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
700 if (NDalicPINVOKE.SWIGPendingException.Pending)
701 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
705 internal void SetInheritOrientation(bool inherit)
707 Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
708 if (NDalicPINVOKE.SWIGPendingException.Pending)
709 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
712 internal bool IsOrientationInherited()
714 bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
715 if (NDalicPINVOKE.SWIGPendingException.Pending)
716 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
720 internal Rotation GetCurrentWorldOrientation()
722 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
723 if (NDalicPINVOKE.SWIGPendingException.Pending)
724 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
728 internal void SetScale(float scale)
730 Interop.ActorInternal.SetScale(SwigCPtr, scale);
731 if (NDalicPINVOKE.SWIGPendingException.Pending)
732 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
735 internal void SetScale(float scaleX, float scaleY, float scaleZ)
737 Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
738 if (NDalicPINVOKE.SWIGPendingException.Pending)
739 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
742 internal void SetScale(Vector3 scale)
744 Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
745 if (NDalicPINVOKE.SWIGPendingException.Pending)
746 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
749 internal Vector3 GetCurrentScale()
751 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentScale(SwigCPtr), true);
752 if (NDalicPINVOKE.SWIGPendingException.Pending)
753 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
757 internal Vector3 GetCurrentWorldScale()
759 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldScale(SwigCPtr), true);
760 if (NDalicPINVOKE.SWIGPendingException.Pending)
761 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
765 internal void SetInheritScale(bool inherit)
767 Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
768 if (NDalicPINVOKE.SWIGPendingException.Pending)
769 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
772 internal bool IsScaleInherited()
774 bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
775 if (NDalicPINVOKE.SWIGPendingException.Pending)
776 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
780 internal Matrix GetCurrentWorldMatrix()
782 Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
783 if (NDalicPINVOKE.SWIGPendingException.Pending)
784 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
788 internal void SetVisible(bool visible)
790 Interop.Actor.SetVisible(SwigCPtr, visible);
791 if (NDalicPINVOKE.SWIGPendingException.Pending)
792 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
795 internal bool IsVisible()
797 bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
798 if (NDalicPINVOKE.SWIGPendingException.Pending)
799 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
803 internal void SetOpacity(float opacity)
805 Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
806 if (NDalicPINVOKE.SWIGPendingException.Pending)
807 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
810 internal float GetCurrentOpacity()
812 float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
813 if (NDalicPINVOKE.SWIGPendingException.Pending)
814 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
818 internal void SetColor(Vector4 color)
820 Interop.ActorInternal.SetColor(SwigCPtr, Vector4.getCPtr(color));
821 if (NDalicPINVOKE.SWIGPendingException.Pending)
822 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
825 internal Vector4 GetCurrentColor()
827 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentColor(SwigCPtr), true);
828 if (NDalicPINVOKE.SWIGPendingException.Pending)
829 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
832 internal ColorMode GetColorMode()
834 ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
835 if (NDalicPINVOKE.SWIGPendingException.Pending)
836 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
840 internal Vector4 GetCurrentWorldColor()
842 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentWorldColor(SwigCPtr), true);
843 if (NDalicPINVOKE.SWIGPendingException.Pending)
844 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
848 internal void SetDrawMode(DrawModeType drawMode)
850 Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
851 if (NDalicPINVOKE.SWIGPendingException.Pending)
852 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
855 internal DrawModeType GetDrawMode()
857 DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
858 if (NDalicPINVOKE.SWIGPendingException.Pending)
859 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
863 internal void SetKeyboardFocusable(bool focusable)
865 Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
866 if (NDalicPINVOKE.SWIGPendingException.Pending)
867 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
870 internal bool IsKeyboardFocusable()
872 bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
873 if (NDalicPINVOKE.SWIGPendingException.Pending)
874 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
878 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
880 Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
881 if (NDalicPINVOKE.SWIGPendingException.Pending)
882 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
885 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
887 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
888 if (NDalicPINVOKE.SWIGPendingException.Pending)
889 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
893 internal Vector3 GetSizeModeFactor()
895 Vector3 ret = new Vector3(Interop.Actor.GetSizeModeFactor(SwigCPtr), true);
896 if (NDalicPINVOKE.SWIGPendingException.Pending)
897 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
901 internal void SetMinimumSize(Vector2 size)
903 Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
904 if (NDalicPINVOKE.SWIGPendingException.Pending)
905 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
908 internal Vector2 GetMinimumSize()
910 Vector2 ret = new Vector2(Interop.ActorInternal.GetMinimumSize(SwigCPtr), true);
911 if (NDalicPINVOKE.SWIGPendingException.Pending)
912 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
916 internal void SetMaximumSize(Vector2 size)
918 Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
919 if (NDalicPINVOKE.SWIGPendingException.Pending)
920 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
923 internal Vector2 GetMaximumSize()
925 Vector2 ret = new Vector2(Interop.ActorInternal.GetMaximumSize(SwigCPtr), true);
926 if (NDalicPINVOKE.SWIGPendingException.Pending)
927 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
931 internal int GetHierarchyDepth()
933 int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
934 if (NDalicPINVOKE.SWIGPendingException.Pending)
935 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
939 internal uint GetRendererCount()
941 uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
942 if (NDalicPINVOKE.SWIGPendingException.Pending)
943 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
947 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
949 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
952 internal bool IsTopLevelView()
954 if (GetParent() is Layer)
961 internal void SetKeyInputFocus()
963 Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
964 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
967 internal void ClearKeyInputFocus()
969 Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
970 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
973 internal PinchGestureDetector GetPinchGestureDetector()
975 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
976 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
980 internal PanGestureDetector GetPanGestureDetector()
982 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
983 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
987 internal TapGestureDetector GetTapGestureDetector()
989 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
990 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
994 internal LongPressGestureDetector GetLongPressGestureDetector()
996 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
997 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1001 internal IntPtr GetPtrfromView()
1003 return (IntPtr)SwigCPtr;
1006 internal void RemoveChild(View child)
1008 // Do actual child removal
1009 Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1010 if (NDalicPINVOKE.SWIGPendingException.Pending)
1011 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1013 Children.Remove(child);
1014 child.InternalParent = null;
1016 if (ChildRemoved != null)
1018 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1022 ChildRemoved(this, e);
1027 /// Removes the layout from this View.
1029 internal void ResetLayout()
1034 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1036 return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1039 /// TODO open as a protected level
1040 internal virtual void ApplyCornerRadius()
1042 if (backgroundExtraData == null) return;
1044 // Apply to the background visual
1045 PropertyMap backgroundMap = new PropertyMap();
1046 PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
1047 if (background.Get(backgroundMap) && !backgroundMap.Empty())
1049 backgroundMap[Visual.Property.CornerRadius] = new PropertyValue(backgroundExtraData.CornerRadius);
1050 backgroundMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1051 var temp = new PropertyValue(backgroundMap);
1052 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
1055 backgroundMap.Dispose();
1056 background.Dispose();
1058 // Apply to the shadow visual
1059 PropertyMap shadowMap = new PropertyMap();
1060 PropertyValue shadow = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.SHADOW);
1061 if (shadow.Get(shadowMap) && !shadowMap.Empty())
1063 shadowMap[Visual.Property.CornerRadius] = new PropertyValue(backgroundExtraData.CornerRadius);
1064 shadowMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1065 var temp = new PropertyValue(shadowMap);
1066 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.SHADOW, temp);
1069 shadowMap.Dispose();
1073 internal void UpdateStyle()
1076 if (styleName == null) newStyle = ThemeManager.GetStyle(GetType());
1077 else newStyle = ThemeManager.GetStyle(styleName);
1079 if (newStyle != null && (viewStyle == null || viewStyle.GetType() == newStyle.GetType())) ApplyStyle(newStyle);
1083 /// you can override it to clean-up your own resources.
1085 /// <param name="type">DisposeTypes</param>
1086 /// <since_tizen> 3 </since_tizen>
1087 protected override void Dispose(DisposeTypes type)
1094 //_mergedStyle = null;
1096 if (type == DisposeTypes.Explicit)
1099 //Release your own managed resources here.
1100 //You should release all of your own disposable objects here.
1101 selectorData?.Reset(this);
1102 if (themeChangeSensitive)
1104 ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1108 //Release your own unmanaged resources here.
1109 //You should not access any managed member here except static instance.
1110 //because the execution order of Finalizes is non-deterministic.
1113 DisConnectFromSignals();
1116 foreach (View view in Children)
1118 view.InternalParent = null;
1124 /// This will not be public opened.
1125 [EditorBrowsable(EditorBrowsableState.Never)]
1126 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1128 Interop.View.DeleteView(swigCPtr);
1132 /// The touch event handler for ControlState.
1133 /// Please change ControlState value by touch state if needed.
1135 /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1136 [EditorBrowsable(EditorBrowsableState.Never)]
1137 protected virtual bool HandleControlStateOnTouch(Touch touch)
1141 throw new global::System.ArgumentNullException(nameof(touch));
1144 switch (touch.GetState(0))
1146 case PointStateType.Down:
1147 ControlState += ControlState.Pressed;
1149 case PointStateType.Interrupted:
1150 case PointStateType.Up:
1151 if (ControlState.Contains(ControlState.Pressed))
1153 ControlState -= ControlState.Pressed;
1162 private void DisConnectFromSignals()
1164 // Save current CPtr.
1165 global::System.Runtime.InteropServices.HandleRef currentCPtr = SwigCPtr;
1167 // Use BaseHandle CPtr as current might have been deleted already in derived classes.
1168 SwigCPtr = GetBaseHandleCPtrHandleRef;
1170 if (_onRelayoutEventCallback != null)
1172 ViewSignal signal = this.OnRelayoutSignal();
1173 signal?.Disconnect(_onRelayoutEventCallback);
1175 _onRelayoutEventCallback = null;
1178 if (_offWindowEventCallback != null)
1180 ViewSignal signal = this.OffWindowSignal();
1181 signal?.Disconnect(_offWindowEventCallback);
1183 _offWindowEventCallback = null;
1186 if (_onWindowEventCallback != null)
1188 ViewSignal signal = this.OnWindowSignal();
1189 signal?.Disconnect(_onWindowEventCallback);
1191 _onWindowEventCallback = null;
1194 if (_wheelEventCallback != null)
1196 WheelSignal signal = this.WheelEventSignal();
1197 signal?.Disconnect(_wheelEventCallback);
1201 if (WindowWheelEventHandler != null)
1203 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
1206 if (_hoverEventCallback != null)
1208 HoverSignal signal = this.HoveredSignal();
1209 signal?.Disconnect(_hoverEventCallback);
1213 if (_interceptTouchDataCallback != null)
1215 TouchDataSignal signal = this.InterceptTouchSignal();
1216 signal?.Disconnect(_interceptTouchDataCallback);
1220 if (_touchDataCallback != null)
1222 TouchDataSignal signal = this.TouchSignal();
1223 signal?.Disconnect(_touchDataCallback);
1227 if (_ResourcesLoadedCallback != null)
1229 ViewSignal signal = this.ResourcesLoadedSignal();
1230 signal?.Disconnect(_ResourcesLoadedCallback);
1232 _ResourcesLoadedCallback = null;
1235 if (_keyCallback != null)
1237 ControlKeySignal signal = this.KeyEventSignal();
1238 signal?.Disconnect(_keyCallback);
1242 if (_keyInputFocusLostCallback != null)
1244 KeyInputFocusSignal signal = this.KeyInputFocusLostSignal();
1245 signal?.Disconnect(_keyInputFocusLostCallback);
1249 if (_keyInputFocusGainedCallback != null)
1251 KeyInputFocusSignal signal = this.KeyInputFocusGainedSignal();
1252 signal?.Disconnect(_keyInputFocusGainedCallback);
1256 if (_backgroundResourceLoadedCallback != null)
1258 ViewSignal signal = this.ResourcesLoadedSignal();
1259 signal?.Disconnect(_backgroundResourceLoadedCallback);
1261 _backgroundResourceLoadedCallback = null;
1264 if (_onWindowSendEventCallback != null)
1266 ViewSignal signal = this.OnWindowSignal();
1267 signal?.Disconnect(_onWindowSendEventCallback);
1271 // BaseHandle CPtr is used in Registry and there is danger of deletion if we keep using it here.
1272 // Restore current CPtr.
1273 SwigCPtr = currentCPtr;
1276 private View ConvertIdToView(uint id)
1278 View view = GetParent()?.FindCurrentChildById(id);
1280 //If we can't find the parent's children, find in the top layer.
1283 Container parent = GetParent();
1284 while ((parent is View) && (parent != null))
1286 parent = parent.GetParent();
1287 if (parent is Layer)
1289 view = parent.FindCurrentChildById(id);
1298 private void OnScaleChanged(float x, float y, float z)
1300 Scale = new Vector3(x, y, z);
1303 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1305 BackgroundColor = new Color(r, g, b, a);
1308 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1310 Padding = new Extents(start, end, top, bottom);
1313 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1315 Margin = new Extents(start, end, top, bottom);
1318 private void OnColorChanged(float r, float g, float b, float a)
1320 Color = new Color(r, g, b, a);
1323 private void OnAnchorPointChanged(float x, float y, float z)
1325 AnchorPoint = new Position(x, y, z);
1328 private void OnCellIndexChanged(float x, float y)
1330 CellIndex = new Vector2(x, y);
1333 private void OnFlexMarginChanged(float x, float y, float z, float w)
1335 FlexMargin = new Vector4(x, y, z, w);
1338 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1340 PaddingEX = new Extents(start, end, top, bottom);
1343 private void OnSizeModeFactorChanged(float x, float y, float z)
1345 SizeModeFactor = new Vector3(x, y, z);
1348 private bool EmptyOnTouch(object target, TouchEventArgs args)
1353 private void InitializeStyle(ViewStyle style)
1355 if (style != null) ApplyStyle(style.Clone()); // Use given style
1356 else if (ThemeManager.ThemeApplied) UpdateStyle(); // Use style in the current theme