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 MergedStyle mergedStyle = null;
35 private ViewSelectorData selectorData;
36 internal string styleName;
38 internal MergedStyle _mergedStyle
42 if (null == mergedStyle)
44 mergedStyle = new MergedStyle(GetType(), this);
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.
56 internal ColorMode ColorMode
64 return GetColorMode();
68 internal float WorldPositionX
72 float returnValue = 0.0f;
73 PropertyValue wordPositionX = GetProperty(View.Property.WORLD_POSITION_X);
74 wordPositionX?.Get(out returnValue);
75 wordPositionX?.Dispose();
80 internal float WorldPositionY
84 float returnValue = 0.0f;
85 PropertyValue wordPositionY = GetProperty(View.Property.WORLD_POSITION_Y);
86 wordPositionY?.Get(out returnValue);
87 wordPositionY?.Dispose();
92 internal float WorldPositionZ
96 float returnValue = 0.0f;
97 PropertyValue wordPositionZ = GetProperty(View.Property.WORLD_POSITION_Z);
98 wordPositionZ?.Get(out returnValue);
99 wordPositionZ?.Dispose();
104 internal bool FocusState
108 return IsKeyboardFocusable();
112 SetKeyboardFocusable(value);
116 internal void SetLayout(LayoutItem layout)
119 _layout?.AttachToOwner(this);
120 _layout?.RequestLayout();
124 /// Stores the calculated width value and its ModeType. Width component.
126 internal MeasureSpecification MeasureSpecificationWidth
130 _measureSpecificationWidth = value;
131 _layout?.RequestLayout();
135 return _measureSpecificationWidth;
140 /// Stores the calculated width value and its ModeType. Height component.
142 internal MeasureSpecification MeasureSpecificationHeight
146 _measureSpecificationHeight = value;
147 _layout?.RequestLayout();
151 return _measureSpecificationHeight;
155 internal void AttachTransitionsToChildren(LayoutTransition transition)
157 // Iterate children, adding the transition unless a transition
158 // for the same condition and property has already been
160 foreach (View view in Children)
162 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
166 internal float ParentOriginX
170 float returnValue = 0.0f;
171 PropertyValue parentOriginX = GetProperty(View.Property.PARENT_ORIGIN_X);
172 parentOriginX?.Get(out returnValue);
173 parentOriginX?.Dispose();
178 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
179 SetProperty(View.Property.PARENT_ORIGIN_X, setValue);
181 NotifyPropertyChanged();
185 internal float ParentOriginY
189 float returnValue = 0.0f;
190 PropertyValue parentOriginY = GetProperty(View.Property.PARENT_ORIGIN_Y);
191 parentOriginY?.Get(out returnValue);
192 parentOriginY?.Dispose();
197 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
198 SetProperty(View.Property.PARENT_ORIGIN_Y, setValue);
200 NotifyPropertyChanged();
204 internal float ParentOriginZ
208 float returnValue = 0.0f;
209 PropertyValue parentOriginZ = GetProperty(View.Property.PARENT_ORIGIN_Z);
210 parentOriginZ?.Get(out returnValue);
211 parentOriginZ?.Dispose();
216 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
217 SetProperty(View.Property.PARENT_ORIGIN_Z, setValue);
219 NotifyPropertyChanged();
223 internal float PivotPointX
227 float returnValue = 0.0f;
228 PropertyValue anchorPointX = GetProperty(View.Property.ANCHOR_POINT_X);
229 anchorPointX?.Get(out returnValue);
230 anchorPointX?.Dispose();
235 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
236 SetProperty(View.Property.ANCHOR_POINT_X, setValue);
241 internal float PivotPointY
245 float returnValue = 0.0f;
246 PropertyValue anchorPointY = GetProperty(View.Property.ANCHOR_POINT_Y);
247 anchorPointY?.Get(out returnValue);
248 anchorPointY?.Dispose();
253 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
254 SetProperty(View.Property.ANCHOR_POINT_Y, setValue);
259 internal float PivotPointZ
263 float returnValue = 0.0f;
264 PropertyValue anchorPointZ = GetProperty(View.Property.ANCHOR_POINT_Z);
265 anchorPointZ?.Get(out returnValue);
266 anchorPointZ?.Dispose();
271 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
272 SetProperty(View.Property.ANCHOR_POINT_Z, setValue);
277 internal Matrix WorldMatrix
281 Matrix returnValue = new Matrix();
282 PropertyValue wordMatrix = GetProperty(View.Property.WORLD_MATRIX);
283 wordMatrix?.Get(returnValue);
284 wordMatrix?.Dispose();
290 /// Indicates that this View should listen Touch event to handle its ControlState.
292 private bool enableControlState = false;
294 private int LeftFocusableViewId
299 PropertyValue leftFocusableViewId = GetProperty(View.Property.LEFT_FOCUSABLE_VIEW_ID);
300 leftFocusableViewId?.Get(out returnValue);
301 leftFocusableViewId?.Dispose();
306 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
307 SetProperty(View.Property.LEFT_FOCUSABLE_VIEW_ID, setValue);
312 private int RightFocusableViewId
317 PropertyValue rightFocusableViewId = GetProperty(View.Property.RIGHT_FOCUSABLE_VIEW_ID);
318 rightFocusableViewId?.Get(out returnValue);
319 rightFocusableViewId?.Dispose();
324 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
325 SetProperty(View.Property.RIGHT_FOCUSABLE_VIEW_ID, setValue);
330 private int UpFocusableViewId
335 PropertyValue upFocusableViewId = GetProperty(View.Property.UP_FOCUSABLE_VIEW_ID);
336 upFocusableViewId?.Get(out returnValue);
337 upFocusableViewId?.Dispose();
342 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
343 SetProperty(View.Property.UP_FOCUSABLE_VIEW_ID, setValue);
348 private int DownFocusableViewId
353 PropertyValue downFocusableViewId = GetProperty(View.Property.DOWN_FOCUSABLE_VIEW_ID);
354 downFocusableViewId?.Get(out returnValue);
355 downFocusableViewId?.Dispose();
360 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
361 SetProperty(View.Property.DOWN_FOCUSABLE_VIEW_ID, setValue);
366 private ViewSelectorData SelectorData
370 if (selectorData == null)
372 selectorData = new ViewSelectorData();
378 internal void Raise()
380 var parentChildren = GetParent()?.Children;
382 if (parentChildren != null)
384 int currentIndex = parentChildren.IndexOf(this);
386 // If the view is not already the last item in the list.
387 if (currentIndex >= 0 && currentIndex < parentChildren.Count - 1)
389 View temp = parentChildren[currentIndex + 1];
390 parentChildren[currentIndex + 1] = this;
391 parentChildren[currentIndex] = temp;
393 Interop.NDalic.Raise(swigCPtr);
394 if (NDalicPINVOKE.SWIGPendingException.Pending)
395 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
400 internal void Lower()
402 var parentChildren = GetParent()?.Children;
404 if (parentChildren != null)
406 int currentIndex = parentChildren.IndexOf(this);
408 // If the view is not already the first item in the list.
409 if (currentIndex > 0 && currentIndex < parentChildren.Count)
411 View temp = parentChildren[currentIndex - 1];
412 parentChildren[currentIndex - 1] = this;
413 parentChildren[currentIndex] = temp;
415 Interop.NDalic.Lower(swigCPtr);
416 if (NDalicPINVOKE.SWIGPendingException.Pending)
417 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
423 /// Raises the view to above the target view.
425 /// <remarks>The sibling order of views within the parent will be updated automatically.
426 /// Views on the level above the target view will still be shown above this view.
427 /// Raising this view above views with the same sibling order as each other will raise this view above them.
428 /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
430 /// <param name="target">Will be raised above this view.</param>
431 internal void RaiseAbove(View target)
433 var parentChildren = GetParent()?.Children;
435 if (parentChildren != null)
437 int currentIndex = parentChildren.IndexOf(this);
438 int targetIndex = parentChildren.IndexOf(target);
440 if (currentIndex < 0 || targetIndex < 0 ||
441 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
443 NUILog.Error("index should be bigger than 0 and less than children of layer count");
446 // If the currentIndex is less than the target index and the target has the same parent.
447 if (currentIndex < targetIndex)
449 parentChildren.Remove(this);
450 parentChildren.Insert(targetIndex, this);
452 Interop.NDalic.RaiseAbove(swigCPtr, View.getCPtr(target));
453 if (NDalicPINVOKE.SWIGPendingException.Pending)
454 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
461 /// Lowers the view to below the target view.
463 /// <remarks>The sibling order of views within the parent will be updated automatically.
464 /// Lowering this view below views with the same sibling order as each other will lower this view above them.
465 /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
467 /// <param name="target">Will be lowered below this view.</param>
468 internal void LowerBelow(View target)
470 var parentChildren = GetParent()?.Children;
472 if (parentChildren != null)
474 int currentIndex = parentChildren.IndexOf(this);
475 int targetIndex = parentChildren.IndexOf(target);
476 if (currentIndex < 0 || targetIndex < 0 ||
477 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
479 NUILog.Error("index should be bigger than 0 and less than children of layer count");
483 // If the currentIndex is not already the 0th index and the target has the same parent.
484 if ((currentIndex != 0) && (targetIndex != -1) &&
485 (currentIndex > targetIndex))
487 parentChildren.Remove(this);
488 parentChildren.Insert(targetIndex, this);
490 Interop.NDalic.LowerBelow(swigCPtr, View.getCPtr(target));
491 if (NDalicPINVOKE.SWIGPendingException.Pending)
492 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
498 internal string GetName()
500 string ret = Interop.Actor.ActorGetName(swigCPtr);
501 if (NDalicPINVOKE.SWIGPendingException.Pending)
502 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506 internal void SetName(string name)
508 Interop.Actor.ActorSetName(swigCPtr, name);
509 if (NDalicPINVOKE.SWIGPendingException.Pending)
510 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
513 internal uint GetId()
515 uint ret = Interop.Actor.ActorGetId(swigCPtr);
516 if (NDalicPINVOKE.SWIGPendingException.Pending)
517 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
521 internal bool IsRoot()
523 bool ret = Interop.ActorInternal.ActorIsRoot(swigCPtr);
524 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
528 internal bool OnWindow()
530 bool ret = Interop.Actor.ActorOnStage(swigCPtr);
531 if (NDalicPINVOKE.SWIGPendingException.Pending)
532 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
536 internal View FindChildById(uint id)
538 //to fix memory leak issue, match the handle count with native side.
539 IntPtr cPtr = Interop.Actor.ActorFindChildById(swigCPtr, id);
540 View ret = this.GetInstanceSafely<View>(cPtr);
541 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
545 internal override View FindCurrentChildById(uint id)
547 return FindChildById(id);
550 internal void SetParentOrigin(Vector3 origin)
552 Interop.ActorInternal.ActorSetParentOrigin(swigCPtr, Vector3.getCPtr(origin));
553 if (NDalicPINVOKE.SWIGPendingException.Pending)
554 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
557 internal Vector3 GetCurrentParentOrigin()
559 Vector3 ret = new Vector3(Interop.ActorInternal.ActorGetCurrentParentOrigin(swigCPtr), true);
560 if (NDalicPINVOKE.SWIGPendingException.Pending)
561 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
565 internal void SetAnchorPoint(Vector3 anchorPoint)
567 Interop.Actor.ActorSetAnchorPoint(swigCPtr, Vector3.getCPtr(anchorPoint));
568 if (NDalicPINVOKE.SWIGPendingException.Pending)
569 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
572 internal Vector3 GetCurrentAnchorPoint()
574 Vector3 ret = new Vector3(Interop.ActorInternal.ActorGetCurrentAnchorPoint(swigCPtr), true);
575 if (NDalicPINVOKE.SWIGPendingException.Pending)
576 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
580 internal void SetSize(float width, float height)
582 Interop.ActorInternal.ActorSetSize(swigCPtr, width, height);
583 if (NDalicPINVOKE.SWIGPendingException.Pending)
584 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
587 internal void SetSize(float width, float height, float depth)
589 Interop.ActorInternal.ActorSetSize(swigCPtr, width, height, depth);
590 if (NDalicPINVOKE.SWIGPendingException.Pending)
591 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
594 internal void SetSize(Vector2 size)
596 Interop.ActorInternal.ActorSetSizeVector2(swigCPtr, Vector2.getCPtr(size));
597 if (NDalicPINVOKE.SWIGPendingException.Pending)
598 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
601 internal void SetSize(Vector3 size)
603 Interop.ActorInternal.ActorSetSizeVector3(swigCPtr, Vector3.getCPtr(size));
604 if (NDalicPINVOKE.SWIGPendingException.Pending)
605 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
608 internal Vector3 GetTargetSize()
610 Vector3 ret = new Vector3(Interop.ActorInternal.ActorGetTargetSize(swigCPtr), true);
611 if (NDalicPINVOKE.SWIGPendingException.Pending)
612 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
616 internal Size2D GetCurrentSize()
618 Size ret = new Size(Interop.Actor.ActorGetCurrentSize(swigCPtr), true);
619 if (NDalicPINVOKE.SWIGPendingException.Pending)
620 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621 Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
626 internal Size2D GetCurrentSizeFloat()
628 Size ret = new Size(Interop.Actor.ActorGetCurrentSize(swigCPtr), true);
629 if (NDalicPINVOKE.SWIGPendingException.Pending)
630 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
634 internal Vector3 GetNaturalSize()
636 Vector3 ret = new Vector3(Interop.Actor.ActorGetNaturalSize(swigCPtr), true);
637 if (NDalicPINVOKE.SWIGPendingException.Pending)
638 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
642 internal void SetPosition(float x, float y)
644 Interop.ActorInternal.ActorSetPosition(swigCPtr, x, y);
645 if (NDalicPINVOKE.SWIGPendingException.Pending)
646 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649 internal void SetPosition(float x, float y, float z)
651 Interop.ActorInternal.ActorSetPosition(swigCPtr, x, y, z);
652 if (NDalicPINVOKE.SWIGPendingException.Pending)
653 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656 internal void SetPosition(Vector3 position)
658 Interop.ActorInternal.ActorSetPosition(swigCPtr, Vector3.getCPtr(position));
659 if (NDalicPINVOKE.SWIGPendingException.Pending)
660 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663 internal void SetX(float x)
665 Interop.ActorInternal.ActorSetX(swigCPtr, x);
666 if (NDalicPINVOKE.SWIGPendingException.Pending)
667 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
670 internal void SetY(float y)
672 Interop.ActorInternal.ActorSetY(swigCPtr, y);
673 if (NDalicPINVOKE.SWIGPendingException.Pending)
674 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
677 internal void SetZ(float z)
679 Interop.ActorInternal.ActorSetZ(swigCPtr, z);
680 if (NDalicPINVOKE.SWIGPendingException.Pending)
681 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
684 internal void TranslateBy(Vector3 distance)
686 Interop.ActorInternal.ActorTranslateBy(swigCPtr, Vector3.getCPtr(distance));
687 if (NDalicPINVOKE.SWIGPendingException.Pending)
688 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
691 internal Position GetCurrentPosition()
693 Position ret = new Position(Interop.Actor.ActorGetCurrentPosition(swigCPtr), true);
694 if (NDalicPINVOKE.SWIGPendingException.Pending)
695 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
699 internal Vector3 GetCurrentWorldPosition()
701 Vector3 ret = new Vector3(Interop.ActorInternal.ActorGetCurrentWorldPosition(swigCPtr), true);
702 if (NDalicPINVOKE.SWIGPendingException.Pending)
703 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
707 internal void SetInheritPosition(bool inherit)
709 Interop.ActorInternal.ActorSetInheritPosition(swigCPtr, inherit);
710 if (NDalicPINVOKE.SWIGPendingException.Pending)
711 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
714 internal bool IsPositionInherited()
716 bool ret = Interop.ActorInternal.ActorIsPositionInherited(swigCPtr);
717 if (NDalicPINVOKE.SWIGPendingException.Pending)
718 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
722 internal void SetOrientation(Degree angle, Vector3 axis)
724 Interop.ActorInternal.ActorSetOrientationDegree(swigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
725 if (NDalicPINVOKE.SWIGPendingException.Pending)
726 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
729 internal void SetOrientation(Radian angle, Vector3 axis)
731 Interop.ActorInternal.ActorSetOrientationRadian(swigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
732 if (NDalicPINVOKE.SWIGPendingException.Pending)
733 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
736 internal void SetOrientation(Rotation orientation)
738 Interop.ActorInternal.ActorSetOrientationQuaternion(swigCPtr, Rotation.getCPtr(orientation));
739 if (NDalicPINVOKE.SWIGPendingException.Pending)
740 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
743 internal Rotation GetCurrentOrientation()
745 Rotation ret = new Rotation(Interop.ActorInternal.ActorGetCurrentOrientation(swigCPtr), true);
746 if (NDalicPINVOKE.SWIGPendingException.Pending)
747 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
751 internal void SetInheritOrientation(bool inherit)
753 Interop.ActorInternal.ActorSetInheritOrientation(swigCPtr, inherit);
754 if (NDalicPINVOKE.SWIGPendingException.Pending)
755 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
758 internal bool IsOrientationInherited()
760 bool ret = Interop.ActorInternal.ActorIsOrientationInherited(swigCPtr);
761 if (NDalicPINVOKE.SWIGPendingException.Pending)
762 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
766 internal Rotation GetCurrentWorldOrientation()
768 Rotation ret = new Rotation(Interop.ActorInternal.ActorGetCurrentWorldOrientation(swigCPtr), true);
769 if (NDalicPINVOKE.SWIGPendingException.Pending)
770 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
774 internal void SetScale(float scale)
776 Interop.ActorInternal.ActorSetScale(swigCPtr, scale);
777 if (NDalicPINVOKE.SWIGPendingException.Pending)
778 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
781 internal void SetScale(float scaleX, float scaleY, float scaleZ)
783 Interop.ActorInternal.ActorSetScale(swigCPtr, scaleX, scaleY, scaleZ);
784 if (NDalicPINVOKE.SWIGPendingException.Pending)
785 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
788 internal void SetScale(Vector3 scale)
790 Interop.ActorInternal.ActorSetScale(swigCPtr, Vector3.getCPtr(scale));
791 if (NDalicPINVOKE.SWIGPendingException.Pending)
792 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
795 internal Vector3 GetCurrentScale()
797 Vector3 ret = new Vector3(Interop.ActorInternal.ActorGetCurrentScale(swigCPtr), true);
798 if (NDalicPINVOKE.SWIGPendingException.Pending)
799 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
803 internal Vector3 GetCurrentWorldScale()
805 Vector3 ret = new Vector3(Interop.ActorInternal.ActorGetCurrentWorldScale(swigCPtr), true);
806 if (NDalicPINVOKE.SWIGPendingException.Pending)
807 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
811 internal void SetInheritScale(bool inherit)
813 Interop.ActorInternal.ActorSetInheritScale(swigCPtr, inherit);
814 if (NDalicPINVOKE.SWIGPendingException.Pending)
815 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
818 internal bool IsScaleInherited()
820 bool ret = Interop.ActorInternal.ActorIsScaleInherited(swigCPtr);
821 if (NDalicPINVOKE.SWIGPendingException.Pending)
822 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
826 internal Matrix GetCurrentWorldMatrix()
828 Matrix ret = new Matrix(Interop.ActorInternal.ActorGetCurrentWorldMatrix(swigCPtr), true);
829 if (NDalicPINVOKE.SWIGPendingException.Pending)
830 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
834 internal void SetVisible(bool visible)
836 Interop.Actor.ActorSetVisible(swigCPtr, visible);
837 if (NDalicPINVOKE.SWIGPendingException.Pending)
838 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
841 internal bool IsVisible()
843 bool ret = Interop.ActorInternal.ActorIsVisible(swigCPtr);
844 if (NDalicPINVOKE.SWIGPendingException.Pending)
845 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
849 internal void SetOpacity(float opacity)
851 Interop.ActorInternal.ActorSetOpacity(swigCPtr, opacity);
852 if (NDalicPINVOKE.SWIGPendingException.Pending)
853 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
856 internal float GetCurrentOpacity()
858 float ret = Interop.ActorInternal.ActorGetCurrentOpacity(swigCPtr);
859 if (NDalicPINVOKE.SWIGPendingException.Pending)
860 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
864 internal void SetColor(Vector4 color)
866 Interop.ActorInternal.ActorSetColor(swigCPtr, Vector4.getCPtr(color));
867 if (NDalicPINVOKE.SWIGPendingException.Pending)
868 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
871 internal Vector4 GetCurrentColor()
873 Vector4 ret = new Vector4(Interop.ActorInternal.ActorGetCurrentColor(swigCPtr), true);
874 if (NDalicPINVOKE.SWIGPendingException.Pending)
875 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
878 internal ColorMode GetColorMode()
880 ColorMode ret = (ColorMode)Interop.ActorInternal.ActorGetColorMode(swigCPtr);
881 if (NDalicPINVOKE.SWIGPendingException.Pending)
882 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
886 internal Vector4 GetCurrentWorldColor()
888 Vector4 ret = new Vector4(Interop.ActorInternal.ActorGetCurrentWorldColor(swigCPtr), true);
889 if (NDalicPINVOKE.SWIGPendingException.Pending)
890 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
894 internal void SetDrawMode(DrawModeType drawMode)
896 Interop.ActorInternal.ActorSetDrawMode(swigCPtr, (int)drawMode);
897 if (NDalicPINVOKE.SWIGPendingException.Pending)
898 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
901 internal DrawModeType GetDrawMode()
903 DrawModeType ret = (DrawModeType)Interop.ActorInternal.ActorGetDrawMode(swigCPtr);
904 if (NDalicPINVOKE.SWIGPendingException.Pending)
905 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
909 internal void SetKeyboardFocusable(bool focusable)
911 Interop.ActorInternal.ActorSetKeyboardFocusable(swigCPtr, focusable);
912 if (NDalicPINVOKE.SWIGPendingException.Pending)
913 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
916 internal bool IsKeyboardFocusable()
918 bool ret = Interop.ActorInternal.ActorIsKeyboardFocusable(swigCPtr);
919 if (NDalicPINVOKE.SWIGPendingException.Pending)
920 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
924 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
926 Interop.Actor.ActorSetResizePolicy(swigCPtr, (int)policy, (int)dimension);
927 if (NDalicPINVOKE.SWIGPendingException.Pending)
928 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
931 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
933 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.ActorGetResizePolicy(swigCPtr, (int)dimension);
934 if (NDalicPINVOKE.SWIGPendingException.Pending)
935 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
939 internal Vector3 GetSizeModeFactor()
941 Vector3 ret = new Vector3(Interop.Actor.ActorGetSizeModeFactor(swigCPtr), true);
942 if (NDalicPINVOKE.SWIGPendingException.Pending)
943 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
947 internal void SetMinimumSize(Vector2 size)
949 Interop.ActorInternal.ActorSetMinimumSize(swigCPtr, Vector2.getCPtr(size));
950 if (NDalicPINVOKE.SWIGPendingException.Pending)
951 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
954 internal Vector2 GetMinimumSize()
956 Vector2 ret = new Vector2(Interop.ActorInternal.ActorGetMinimumSize(swigCPtr), true);
957 if (NDalicPINVOKE.SWIGPendingException.Pending)
958 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
962 internal void SetMaximumSize(Vector2 size)
964 Interop.ActorInternal.ActorSetMaximumSize(swigCPtr, Vector2.getCPtr(size));
965 if (NDalicPINVOKE.SWIGPendingException.Pending)
966 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
969 internal Vector2 GetMaximumSize()
971 Vector2 ret = new Vector2(Interop.ActorInternal.ActorGetMaximumSize(swigCPtr), true);
972 if (NDalicPINVOKE.SWIGPendingException.Pending)
973 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
977 internal int GetHierarchyDepth()
979 int ret = Interop.Actor.ActorGetHierarchyDepth(swigCPtr);
980 if (NDalicPINVOKE.SWIGPendingException.Pending)
981 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
985 internal uint GetRendererCount()
987 uint ret = Interop.Actor.ActorGetRendererCount(swigCPtr);
988 if (NDalicPINVOKE.SWIGPendingException.Pending)
989 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
993 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
995 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
998 internal bool IsTopLevelView()
1000 if (GetParent() is Layer)
1007 internal void SetKeyInputFocus()
1009 Interop.ViewInternal.View_SetKeyInputFocus(swigCPtr);
1010 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1013 internal void ClearKeyInputFocus()
1015 Interop.ViewInternal.View_ClearKeyInputFocus(swigCPtr);
1016 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1019 internal PinchGestureDetector GetPinchGestureDetector()
1021 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.View_GetPinchGestureDetector(swigCPtr), true);
1022 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1026 internal PanGestureDetector GetPanGestureDetector()
1028 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.View_GetPanGestureDetector(swigCPtr), true);
1029 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1033 internal TapGestureDetector GetTapGestureDetector()
1035 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.View_GetTapGestureDetector(swigCPtr), true);
1036 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1040 internal LongPressGestureDetector GetLongPressGestureDetector()
1042 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.View_GetLongPressGestureDetector(swigCPtr), true);
1043 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1047 internal IntPtr GetPtrfromView()
1049 return (IntPtr)swigCPtr;
1052 internal void RemoveChild(View child)
1054 // Do actual child removal
1055 Interop.Actor.ActorRemove(swigCPtr, View.getCPtr(child));
1056 if (NDalicPINVOKE.SWIGPendingException.Pending)
1057 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1059 Children.Remove(child);
1060 child.InternalParent = null;
1062 if (ChildRemoved != null)
1064 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1068 ChildRemoved(this, e);
1073 /// Removes the layout from this View.
1075 internal void ResetLayout()
1080 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1082 return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND);
1085 internal virtual void UpdateCornerRadius(float value)
1089 (backgroundExtraData ?? (backgroundExtraData = new BackgroundExtraData())).CornerRadius = value;
1092 Tizen.NUI.PropertyMap backgroundMap = new Tizen.NUI.PropertyMap();
1093 PropertyValue background = Tizen.NUI.Object.GetProperty(swigCPtr, View.Property.BACKGROUND);
1094 background?.Get(backgroundMap);
1096 if (!backgroundMap.Empty())
1098 backgroundMap[Visual.Property.CornerRadius] = new PropertyValue(value);
1099 PropertyValue setValue = new Tizen.NUI.PropertyValue(backgroundMap);
1100 Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.BACKGROUND, setValue);
1101 setValue?.Dispose();
1103 UpdateShadowCornerRadius(value);
1104 backgroundMap?.Dispose();
1105 background?.Dispose();
1108 internal void UpdateStyle()
1111 if (styleName == null) newStyle = ThemeManager.GetStyle(GetType());
1112 else newStyle = ThemeManager.GetStyle(styleName);
1114 if (newStyle != null && (viewStyle == null || viewStyle.GetType() == newStyle.GetType())) ApplyStyle(newStyle);
1118 /// you can override it to clean-up your own resources.
1120 /// <param name="type">DisposeTypes</param>
1121 /// <since_tizen> 3 </since_tizen>
1122 protected override void Dispose(DisposeTypes type)
1129 //_mergedStyle = null;
1131 if (type == DisposeTypes.Explicit)
1134 //Release your own managed resources here.
1135 //You should release all of your own disposable objects here.
1136 selectorData?.Reset(this);
1137 if (themeChangeSensitive)
1139 ThemeManager.ThemeChanged -= OnThemeChanged;
1143 //Release your own unmanaged resources here.
1144 //You should not access any managed member here except static instance.
1145 //because the execution order of Finalizes is non-deterministic.
1148 DisConnectFromSignals();
1151 foreach (View view in Children)
1153 view.InternalParent = null;
1159 /// This will not be public opened.
1160 [EditorBrowsable(EditorBrowsableState.Never)]
1161 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1163 Interop.View.delete_View(swigCPtr);
1167 /// The touch event handler for ControlState.
1168 /// Please change ControlState value by touch state if needed.
1170 [EditorBrowsable(EditorBrowsableState.Never)]
1171 protected virtual bool HandleControlStateOnTouch(Touch touch)
1173 switch (touch.GetState(0))
1175 case PointStateType.Down:
1176 ControlState += ControlState.Pressed;
1178 case PointStateType.Interrupted:
1179 case PointStateType.Up:
1180 if (ControlState.Contains(ControlState.Pressed))
1182 ControlState -= ControlState.Pressed;
1192 private void DisConnectFromSignals()
1194 // Save current CPtr.
1195 global::System.Runtime.InteropServices.HandleRef currentCPtr = swigCPtr;
1197 // Use BaseHandle CPtr as current might have been deleted already in derived classes.
1198 swigCPtr = GetBaseHandleCPtrHandleRef;
1200 if (_onRelayoutEventCallback != null)
1202 ViewSignal signal = this.OnRelayoutSignal();
1203 signal?.Disconnect(_onRelayoutEventCallback);
1205 _onRelayoutEventCallback = null;
1208 if (_offWindowEventCallback != null)
1210 ViewSignal signal = this.OffWindowSignal();
1211 signal?.Disconnect(_offWindowEventCallback);
1213 _offWindowEventCallback = null;
1216 if (_onWindowEventCallback != null)
1218 ViewSignal signal = this.OnWindowSignal();
1219 signal?.Disconnect(_onWindowEventCallback);
1221 _onWindowEventCallback = null;
1224 if (_wheelEventCallback != null)
1226 WheelSignal signal = this.WheelEventSignal();
1227 signal?.Disconnect(_wheelEventCallback);
1231 if (WindowWheelEventHandler != null)
1233 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
1236 if (_hoverEventCallback != null)
1238 HoverSignal signal = this.HoveredSignal();
1239 signal?.Disconnect(_hoverEventCallback);
1243 if (_interceptTouchDataCallback != null)
1245 TouchDataSignal signal = this.InterceptTouchSignal();
1246 signal?.Disconnect(_interceptTouchDataCallback);
1250 if (_touchDataCallback != null)
1252 TouchDataSignal signal = this.TouchSignal();
1253 signal?.Disconnect(_touchDataCallback);
1257 if (_ResourcesLoadedCallback != null)
1259 ViewSignal signal = this.ResourcesLoadedSignal();
1260 signal?.Disconnect(_ResourcesLoadedCallback);
1262 _ResourcesLoadedCallback = null;
1265 if (_keyCallback != null)
1267 ControlKeySignal signal = this.KeyEventSignal();
1268 signal?.Disconnect(_keyCallback);
1272 if (_keyInputFocusLostCallback != null)
1274 KeyInputFocusSignal signal = this.KeyInputFocusLostSignal();
1275 signal?.Disconnect(_keyInputFocusLostCallback);
1279 if (_keyInputFocusGainedCallback != null)
1281 KeyInputFocusSignal signal = this.KeyInputFocusGainedSignal();
1282 signal?.Disconnect(_keyInputFocusGainedCallback);
1286 if (_backgroundResourceLoadedCallback != null)
1288 ViewSignal signal = this.ResourcesLoadedSignal();
1289 signal?.Disconnect(_backgroundResourceLoadedCallback);
1291 _backgroundResourceLoadedCallback = null;
1294 if (_onWindowSendEventCallback != null)
1296 ViewSignal signal = this.OnWindowSignal();
1297 signal?.Disconnect(_onWindowSendEventCallback);
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;
1306 private View ConvertIdToView(uint id)
1308 View view = GetParent()?.FindCurrentChildById(id);
1310 //If we can't find the parent's children, find in the top layer.
1313 Container parent = GetParent();
1314 while ((parent is View) && (parent != null))
1316 parent = parent.GetParent();
1317 if (parent is Layer)
1319 view = parent.FindCurrentChildById(id);
1328 private void LoadTransitions()
1330 foreach (string str in transitionNames)
1332 string resourceName = str + ".xaml";
1333 Transition trans = null;
1335 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
1337 string likelyResourcePath = resource + "animation/" + resourceName;
1339 if (File.Exists(likelyResourcePath))
1341 trans = Xaml.Extensions.LoadObject<Transition>(likelyResourcePath);
1345 transDictionary.Add(trans.Name, trans);
1350 private void OnScaleChanged(float x, float y, float z)
1352 Scale = new Vector3(x, y, z);
1355 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1357 BackgroundColor = new Color(r, g, b, a);
1360 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1362 Padding = new Extents(start, end, top, bottom);
1365 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1367 Margin = new Extents(start, end, top, bottom);
1370 private void OnColorChanged(float r, float g, float b, float a)
1372 Color = new Color(r, g, b, a);
1375 private void OnAnchorPointChanged(float x, float y, float z)
1377 AnchorPoint = new Position(x, y, z);
1380 private void OnCellIndexChanged(float x, float y)
1382 CellIndex = new Vector2(x, y);
1385 private void OnFlexMarginChanged(float x, float y, float z, float w)
1387 FlexMargin = new Vector4(x, y, z, w);
1390 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1392 PaddingEX = new Extents(start, end, top, bottom);
1395 private void OnSizeModeFactorChanged(float x, float y, float z)
1397 SizeModeFactor = new Vector3(x, y, z);
1400 private void UpdateShadowCornerRadius(float value)
1402 // TODO Update corner radius property only whe DALi supports visual property update.
1403 PropertyMap map = new PropertyMap();
1405 PropertyValue shadowVal = Tizen.NUI.Object.GetProperty(swigCPtr, View.Property.SHADOW);
1406 if (shadowVal.Get(map) && !map.Empty())
1408 map[Visual.Property.CornerRadius] = new PropertyValue(value);
1410 PropertyValue setValue = new PropertyValue(map);
1411 Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.SHADOW, setValue);
1412 setValue?.Dispose();
1415 shadowVal?.Dispose();
1418 private bool EmptyOnTouch(object target, TouchEventArgs args)