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
73 GetProperty(View.Property.WORLD_POSITION_X).Get(out temp);
78 internal float WorldPositionY
83 GetProperty(View.Property.WORLD_POSITION_Y).Get(out temp);
88 internal float WorldPositionZ
93 GetProperty(View.Property.WORLD_POSITION_Z).Get(out temp);
98 internal bool FocusState
102 return IsKeyboardFocusable();
106 SetKeyboardFocusable(value);
110 internal void SetLayout(LayoutItem layout)
113 _layout?.AttachToOwner(this);
114 _layout?.RequestLayout();
118 /// Stores the calculated width value and its ModeType. Width component.
120 internal MeasureSpecification MeasureSpecificationWidth
124 _measureSpecificationWidth = value;
125 _layout?.RequestLayout();
129 return _measureSpecificationWidth;
134 /// Stores the calculated width value and its ModeType. Height component.
136 internal MeasureSpecification MeasureSpecificationHeight
140 _measureSpecificationHeight = value;
141 _layout?.RequestLayout();
145 return _measureSpecificationHeight;
149 internal void AttachTransitionsToChildren(LayoutTransition transition)
151 // Iterate children, adding the transition unless a transition
152 // for the same condition and property has already been
154 foreach (View view in Children)
156 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
160 internal float ParentOriginX
165 GetProperty(View.Property.PARENT_ORIGIN_X).Get(out temp);
170 SetProperty(View.Property.PARENT_ORIGIN_X, new Tizen.NUI.PropertyValue(value));
171 NotifyPropertyChanged();
175 internal float ParentOriginY
180 GetProperty(View.Property.PARENT_ORIGIN_Y).Get(out temp);
185 SetProperty(View.Property.PARENT_ORIGIN_Y, new Tizen.NUI.PropertyValue(value));
186 NotifyPropertyChanged();
190 internal float ParentOriginZ
195 GetProperty(View.Property.PARENT_ORIGIN_Z).Get(out temp);
200 SetProperty(View.Property.PARENT_ORIGIN_Z, new Tizen.NUI.PropertyValue(value));
201 NotifyPropertyChanged();
205 internal float PivotPointX
210 GetProperty(View.Property.ANCHOR_POINT_X).Get(out temp);
215 SetProperty(View.Property.ANCHOR_POINT_X, new Tizen.NUI.PropertyValue(value));
219 internal float PivotPointY
224 GetProperty(View.Property.ANCHOR_POINT_Y).Get(out temp);
229 SetProperty(View.Property.ANCHOR_POINT_Y, new Tizen.NUI.PropertyValue(value));
233 internal float PivotPointZ
238 GetProperty(View.Property.ANCHOR_POINT_Z).Get(out temp);
243 SetProperty(View.Property.ANCHOR_POINT_Z, new Tizen.NUI.PropertyValue(value));
247 internal Matrix WorldMatrix
251 Matrix temp = new Matrix();
252 GetProperty(View.Property.WORLD_MATRIX).Get(temp);
258 /// Indicates that this View should listen Touch event to handle its ControlState.
260 private bool enableControlState = false;
262 private int LeftFocusableViewId
267 GetProperty(View.Property.LEFT_FOCUSABLE_VIEW_ID).Get(out temp);
272 SetProperty(View.Property.LEFT_FOCUSABLE_VIEW_ID, new Tizen.NUI.PropertyValue(value));
276 private int RightFocusableViewId
281 GetProperty(View.Property.RIGHT_FOCUSABLE_VIEW_ID).Get(out temp);
286 SetProperty(View.Property.RIGHT_FOCUSABLE_VIEW_ID, new Tizen.NUI.PropertyValue(value));
290 private int UpFocusableViewId
295 GetProperty(View.Property.UP_FOCUSABLE_VIEW_ID).Get(out temp);
300 SetProperty(View.Property.UP_FOCUSABLE_VIEW_ID, new Tizen.NUI.PropertyValue(value));
304 private int DownFocusableViewId
309 GetProperty(View.Property.DOWN_FOCUSABLE_VIEW_ID).Get(out temp);
314 SetProperty(View.Property.DOWN_FOCUSABLE_VIEW_ID, new Tizen.NUI.PropertyValue(value));
318 private ViewSelectorData SelectorData
322 if (selectorData == null)
324 selectorData = new ViewSelectorData();
330 internal void Raise()
332 var parentChildren = GetParent()?.Children;
334 if (parentChildren != null)
336 int currentIndex = parentChildren.IndexOf(this);
338 // If the view is not already the last item in the list.
339 if (currentIndex >= 0 && currentIndex < parentChildren.Count - 1)
341 View temp = parentChildren[currentIndex + 1];
342 parentChildren[currentIndex + 1] = this;
343 parentChildren[currentIndex] = temp;
345 Interop.NDalic.Raise(swigCPtr);
346 if (NDalicPINVOKE.SWIGPendingException.Pending)
347 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
352 internal void Lower()
354 var parentChildren = GetParent()?.Children;
356 if (parentChildren != null)
358 int currentIndex = parentChildren.IndexOf(this);
360 // If the view is not already the first item in the list.
361 if (currentIndex > 0 && currentIndex < parentChildren.Count)
363 View temp = parentChildren[currentIndex - 1];
364 parentChildren[currentIndex - 1] = this;
365 parentChildren[currentIndex] = temp;
367 Interop.NDalic.Lower(swigCPtr);
368 if (NDalicPINVOKE.SWIGPendingException.Pending)
369 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
375 /// Raises the view to above the target view.
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.
382 /// <param name="target">Will be raised above this view.</param>
383 internal void RaiseAbove(View target)
385 var parentChildren = GetParent()?.Children;
387 if (parentChildren != null)
389 int currentIndex = parentChildren.IndexOf(this);
390 int targetIndex = parentChildren.IndexOf(target);
392 if (currentIndex < 0 || targetIndex < 0 ||
393 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
395 NUILog.Error("index should be bigger than 0 and less than children of layer count");
398 // If the currentIndex is less than the target index and the target has the same parent.
399 if (currentIndex < targetIndex)
401 parentChildren.Remove(this);
402 parentChildren.Insert(targetIndex, this);
404 Interop.NDalic.RaiseAbove(swigCPtr, View.getCPtr(target));
405 if (NDalicPINVOKE.SWIGPendingException.Pending)
406 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
413 /// Lowers the view to below the target view.
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.
419 /// <param name="target">Will be lowered below this view.</param>
420 internal void LowerBelow(View target)
422 var parentChildren = GetParent()?.Children;
424 if (parentChildren != null)
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)
431 NUILog.Error("index should be bigger than 0 and less than children of layer count");
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))
439 parentChildren.Remove(this);
440 parentChildren.Insert(targetIndex, this);
442 Interop.NDalic.LowerBelow(swigCPtr, View.getCPtr(target));
443 if (NDalicPINVOKE.SWIGPendingException.Pending)
444 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
450 internal string GetName()
452 string ret = Interop.Actor.Actor_GetName(swigCPtr);
453 if (NDalicPINVOKE.SWIGPendingException.Pending)
454 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
458 internal void SetName(string name)
460 Interop.Actor.Actor_SetName(swigCPtr, name);
461 if (NDalicPINVOKE.SWIGPendingException.Pending)
462 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
465 internal uint GetId()
467 uint ret = Interop.Actor.Actor_GetId(swigCPtr);
468 if (NDalicPINVOKE.SWIGPendingException.Pending)
469 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
473 internal bool IsRoot()
475 bool ret = Interop.ActorInternal.Actor_IsRoot(swigCPtr);
476 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
480 internal bool OnWindow()
482 bool ret = Interop.Actor.Actor_OnStage(swigCPtr);
483 if (NDalicPINVOKE.SWIGPendingException.Pending)
484 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
488 internal View FindChildById(uint id)
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();
497 internal override View FindCurrentChildById(uint id)
499 return FindChildById(id);
502 internal void SetParentOrigin(Vector3 origin)
504 Interop.ActorInternal.Actor_SetParentOrigin(swigCPtr, Vector3.getCPtr(origin));
505 if (NDalicPINVOKE.SWIGPendingException.Pending)
506 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
509 internal Vector3 GetCurrentParentOrigin()
511 Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentParentOrigin(swigCPtr), true);
512 if (NDalicPINVOKE.SWIGPendingException.Pending)
513 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
517 internal void SetAnchorPoint(Vector3 anchorPoint)
519 Interop.Actor.Actor_SetAnchorPoint(swigCPtr, Vector3.getCPtr(anchorPoint));
520 if (NDalicPINVOKE.SWIGPendingException.Pending)
521 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
524 internal Vector3 GetCurrentAnchorPoint()
526 Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentAnchorPoint(swigCPtr), true);
527 if (NDalicPINVOKE.SWIGPendingException.Pending)
528 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
532 internal void SetSize(float width, float height)
534 Interop.ActorInternal.Actor_SetSize__SWIG_0(swigCPtr, width, height);
535 if (NDalicPINVOKE.SWIGPendingException.Pending)
536 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
539 internal void SetSize(float width, float height, float depth)
541 Interop.ActorInternal.Actor_SetSize__SWIG_1(swigCPtr, width, height, depth);
542 if (NDalicPINVOKE.SWIGPendingException.Pending)
543 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
546 internal void SetSize(Vector2 size)
548 Interop.ActorInternal.Actor_SetSize__SWIG_2(swigCPtr, Vector2.getCPtr(size));
549 if (NDalicPINVOKE.SWIGPendingException.Pending)
550 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
553 internal void SetSize(Vector3 size)
555 Interop.ActorInternal.Actor_SetSize__SWIG_3(swigCPtr, Vector3.getCPtr(size));
556 if (NDalicPINVOKE.SWIGPendingException.Pending)
557 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
560 internal Vector3 GetTargetSize()
562 Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetTargetSize(swigCPtr), true);
563 if (NDalicPINVOKE.SWIGPendingException.Pending)
564 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
568 internal Size2D GetCurrentSize()
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);
577 internal Size2D GetCurrentSizeFloat()
579 Size ret = new Size(Interop.Actor.Actor_GetCurrentSize(swigCPtr), true);
580 if (NDalicPINVOKE.SWIGPendingException.Pending)
581 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
585 internal Vector3 GetNaturalSize()
587 Vector3 ret = new Vector3(Interop.Actor.Actor_GetNaturalSize(swigCPtr), true);
588 if (NDalicPINVOKE.SWIGPendingException.Pending)
589 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
593 internal void SetPosition(float x, float y)
595 Interop.ActorInternal.Actor_SetPosition__SWIG_0(swigCPtr, x, y);
596 if (NDalicPINVOKE.SWIGPendingException.Pending)
597 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
600 internal void SetPosition(float x, float y, float z)
602 Interop.ActorInternal.Actor_SetPosition__SWIG_1(swigCPtr, x, y, z);
603 if (NDalicPINVOKE.SWIGPendingException.Pending)
604 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
607 internal void SetPosition(Vector3 position)
609 Interop.ActorInternal.Actor_SetPosition__SWIG_2(swigCPtr, Vector3.getCPtr(position));
610 if (NDalicPINVOKE.SWIGPendingException.Pending)
611 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
614 internal void SetX(float x)
616 Interop.ActorInternal.Actor_SetX(swigCPtr, x);
617 if (NDalicPINVOKE.SWIGPendingException.Pending)
618 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621 internal void SetY(float y)
623 Interop.ActorInternal.Actor_SetY(swigCPtr, y);
624 if (NDalicPINVOKE.SWIGPendingException.Pending)
625 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628 internal void SetZ(float z)
630 Interop.ActorInternal.Actor_SetZ(swigCPtr, z);
631 if (NDalicPINVOKE.SWIGPendingException.Pending)
632 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
635 internal void TranslateBy(Vector3 distance)
637 Interop.ActorInternal.Actor_TranslateBy(swigCPtr, Vector3.getCPtr(distance));
638 if (NDalicPINVOKE.SWIGPendingException.Pending)
639 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
642 internal Position GetCurrentPosition()
644 Position ret = new Position(Interop.Actor.Actor_GetCurrentPosition(swigCPtr), true);
645 if (NDalicPINVOKE.SWIGPendingException.Pending)
646 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
650 internal Vector3 GetCurrentWorldPosition()
652 Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentWorldPosition(swigCPtr), true);
653 if (NDalicPINVOKE.SWIGPendingException.Pending)
654 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
658 internal void SetInheritPosition(bool inherit)
660 Interop.ActorInternal.Actor_SetInheritPosition(swigCPtr, inherit);
661 if (NDalicPINVOKE.SWIGPendingException.Pending)
662 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
665 internal bool IsPositionInherited()
667 bool ret = Interop.ActorInternal.Actor_IsPositionInherited(swigCPtr);
668 if (NDalicPINVOKE.SWIGPendingException.Pending)
669 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
673 internal void SetOrientation(Degree angle, Vector3 axis)
675 Interop.ActorInternal.Actor_SetOrientation__SWIG_0(swigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
676 if (NDalicPINVOKE.SWIGPendingException.Pending)
677 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
680 internal void SetOrientation(Radian angle, Vector3 axis)
682 Interop.ActorInternal.Actor_SetOrientation__SWIG_1(swigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
683 if (NDalicPINVOKE.SWIGPendingException.Pending)
684 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
687 internal void SetOrientation(Rotation orientation)
689 Interop.ActorInternal.Actor_SetOrientation__SWIG_2(swigCPtr, Rotation.getCPtr(orientation));
690 if (NDalicPINVOKE.SWIGPendingException.Pending)
691 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
694 internal Rotation GetCurrentOrientation()
696 Rotation ret = new Rotation(Interop.ActorInternal.Actor_GetCurrentOrientation(swigCPtr), true);
697 if (NDalicPINVOKE.SWIGPendingException.Pending)
698 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
702 internal void SetInheritOrientation(bool inherit)
704 Interop.ActorInternal.Actor_SetInheritOrientation(swigCPtr, inherit);
705 if (NDalicPINVOKE.SWIGPendingException.Pending)
706 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
709 internal bool IsOrientationInherited()
711 bool ret = Interop.ActorInternal.Actor_IsOrientationInherited(swigCPtr);
712 if (NDalicPINVOKE.SWIGPendingException.Pending)
713 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
717 internal Rotation GetCurrentWorldOrientation()
719 Rotation ret = new Rotation(Interop.ActorInternal.Actor_GetCurrentWorldOrientation(swigCPtr), true);
720 if (NDalicPINVOKE.SWIGPendingException.Pending)
721 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
725 internal void SetScale(float scale)
727 Interop.ActorInternal.Actor_SetScale__SWIG_0(swigCPtr, scale);
728 if (NDalicPINVOKE.SWIGPendingException.Pending)
729 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
732 internal void SetScale(float scaleX, float scaleY, float scaleZ)
734 Interop.ActorInternal.Actor_SetScale__SWIG_1(swigCPtr, scaleX, scaleY, scaleZ);
735 if (NDalicPINVOKE.SWIGPendingException.Pending)
736 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
739 internal void SetScale(Vector3 scale)
741 Interop.ActorInternal.Actor_SetScale__SWIG_2(swigCPtr, Vector3.getCPtr(scale));
742 if (NDalicPINVOKE.SWIGPendingException.Pending)
743 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
746 internal Vector3 GetCurrentScale()
748 Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentScale(swigCPtr), true);
749 if (NDalicPINVOKE.SWIGPendingException.Pending)
750 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
754 internal Vector3 GetCurrentWorldScale()
756 Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentWorldScale(swigCPtr), true);
757 if (NDalicPINVOKE.SWIGPendingException.Pending)
758 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
762 internal void SetInheritScale(bool inherit)
764 Interop.ActorInternal.Actor_SetInheritScale(swigCPtr, inherit);
765 if (NDalicPINVOKE.SWIGPendingException.Pending)
766 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
769 internal bool IsScaleInherited()
771 bool ret = Interop.ActorInternal.Actor_IsScaleInherited(swigCPtr);
772 if (NDalicPINVOKE.SWIGPendingException.Pending)
773 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
777 internal Matrix GetCurrentWorldMatrix()
779 Matrix ret = new Matrix(Interop.ActorInternal.Actor_GetCurrentWorldMatrix(swigCPtr), true);
780 if (NDalicPINVOKE.SWIGPendingException.Pending)
781 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
785 internal void SetVisible(bool visible)
787 Interop.Actor.Actor_SetVisible(swigCPtr, visible);
788 if (NDalicPINVOKE.SWIGPendingException.Pending)
789 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
792 internal bool IsVisible()
794 bool ret = Interop.ActorInternal.Actor_IsVisible(swigCPtr);
795 if (NDalicPINVOKE.SWIGPendingException.Pending)
796 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
800 internal void SetOpacity(float opacity)
802 Interop.ActorInternal.Actor_SetOpacity(swigCPtr, opacity);
803 if (NDalicPINVOKE.SWIGPendingException.Pending)
804 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
807 internal float GetCurrentOpacity()
809 float ret = Interop.ActorInternal.Actor_GetCurrentOpacity(swigCPtr);
810 if (NDalicPINVOKE.SWIGPendingException.Pending)
811 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
815 internal void SetColor(Vector4 color)
817 Interop.ActorInternal.Actor_SetColor(swigCPtr, Vector4.getCPtr(color));
818 if (NDalicPINVOKE.SWIGPendingException.Pending)
819 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
822 internal Vector4 GetCurrentColor()
824 Vector4 ret = new Vector4(Interop.ActorInternal.Actor_GetCurrentColor(swigCPtr), true);
825 if (NDalicPINVOKE.SWIGPendingException.Pending)
826 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
829 internal ColorMode GetColorMode()
831 ColorMode ret = (ColorMode)Interop.ActorInternal.Actor_GetColorMode(swigCPtr);
832 if (NDalicPINVOKE.SWIGPendingException.Pending)
833 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
837 internal Vector4 GetCurrentWorldColor()
839 Vector4 ret = new Vector4(Interop.ActorInternal.Actor_GetCurrentWorldColor(swigCPtr), true);
840 if (NDalicPINVOKE.SWIGPendingException.Pending)
841 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
845 internal void SetDrawMode(DrawModeType drawMode)
847 Interop.ActorInternal.Actor_SetDrawMode(swigCPtr, (int)drawMode);
848 if (NDalicPINVOKE.SWIGPendingException.Pending)
849 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
852 internal DrawModeType GetDrawMode()
854 DrawModeType ret = (DrawModeType)Interop.ActorInternal.Actor_GetDrawMode(swigCPtr);
855 if (NDalicPINVOKE.SWIGPendingException.Pending)
856 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
860 internal void SetKeyboardFocusable(bool focusable)
862 Interop.ActorInternal.Actor_SetKeyboardFocusable(swigCPtr, focusable);
863 if (NDalicPINVOKE.SWIGPendingException.Pending)
864 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
867 internal bool IsKeyboardFocusable()
869 bool ret = Interop.ActorInternal.Actor_IsKeyboardFocusable(swigCPtr);
870 if (NDalicPINVOKE.SWIGPendingException.Pending)
871 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
875 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
877 Interop.Actor.Actor_SetResizePolicy(swigCPtr, (int)policy, (int)dimension);
878 if (NDalicPINVOKE.SWIGPendingException.Pending)
879 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
882 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
884 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.Actor_GetResizePolicy(swigCPtr, (int)dimension);
885 if (NDalicPINVOKE.SWIGPendingException.Pending)
886 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
890 internal Vector3 GetSizeModeFactor()
892 Vector3 ret = new Vector3(Interop.Actor.Actor_GetSizeModeFactor(swigCPtr), true);
893 if (NDalicPINVOKE.SWIGPendingException.Pending)
894 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
898 internal void SetMinimumSize(Vector2 size)
900 Interop.ActorInternal.Actor_SetMinimumSize(swigCPtr, Vector2.getCPtr(size));
901 if (NDalicPINVOKE.SWIGPendingException.Pending)
902 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
905 internal Vector2 GetMinimumSize()
907 Vector2 ret = new Vector2(Interop.ActorInternal.Actor_GetMinimumSize(swigCPtr), true);
908 if (NDalicPINVOKE.SWIGPendingException.Pending)
909 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
913 internal void SetMaximumSize(Vector2 size)
915 Interop.ActorInternal.Actor_SetMaximumSize(swigCPtr, Vector2.getCPtr(size));
916 if (NDalicPINVOKE.SWIGPendingException.Pending)
917 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
920 internal Vector2 GetMaximumSize()
922 Vector2 ret = new Vector2(Interop.ActorInternal.Actor_GetMaximumSize(swigCPtr), true);
923 if (NDalicPINVOKE.SWIGPendingException.Pending)
924 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
928 internal int GetHierarchyDepth()
930 int ret = Interop.Actor.Actor_GetHierarchyDepth(swigCPtr);
931 if (NDalicPINVOKE.SWIGPendingException.Pending)
932 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
936 internal uint GetRendererCount()
938 uint ret = Interop.Actor.Actor_GetRendererCount(swigCPtr);
939 if (NDalicPINVOKE.SWIGPendingException.Pending)
940 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
944 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
946 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
949 internal bool IsTopLevelView()
951 if (GetParent() is Layer)
958 internal void SetKeyInputFocus()
960 Interop.ViewInternal.View_SetKeyInputFocus(swigCPtr);
961 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
964 internal void ClearKeyInputFocus()
966 Interop.ViewInternal.View_ClearKeyInputFocus(swigCPtr);
967 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
970 internal PinchGestureDetector GetPinchGestureDetector()
972 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.View_GetPinchGestureDetector(swigCPtr), true);
973 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
977 internal PanGestureDetector GetPanGestureDetector()
979 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.View_GetPanGestureDetector(swigCPtr), true);
980 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
984 internal TapGestureDetector GetTapGestureDetector()
986 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.View_GetTapGestureDetector(swigCPtr), true);
987 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
991 internal LongPressGestureDetector GetLongPressGestureDetector()
993 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.View_GetLongPressGestureDetector(swigCPtr), true);
994 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
998 internal IntPtr GetPtrfromView()
1000 return (IntPtr)swigCPtr;
1003 internal void RemoveChild(View child)
1005 // Do actual child removal
1006 Interop.Actor.Actor_Remove(swigCPtr, View.getCPtr(child));
1007 if (NDalicPINVOKE.SWIGPendingException.Pending)
1008 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1010 Children.Remove(child);
1011 child.InternalParent = null;
1013 if (ChildRemoved != null)
1015 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1019 ChildRemoved(this, e);
1024 /// Removes the layout from this View.
1026 internal void ResetLayout()
1031 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1033 return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND);
1036 internal virtual void UpdateCornerRadius(float value)
1040 (backgroundExtraData ?? (backgroundExtraData = new BackgroundExtraData())).CornerRadius = value;
1043 Tizen.NUI.PropertyMap backgroundMap = new Tizen.NUI.PropertyMap();
1044 Tizen.NUI.Object.GetProperty(swigCPtr, View.Property.BACKGROUND).Get(backgroundMap);
1046 if (!backgroundMap.Empty())
1048 backgroundMap[Visual.Property.CornerRadius] = new PropertyValue(value);
1049 Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.BACKGROUND, new Tizen.NUI.PropertyValue(backgroundMap));
1052 UpdateShadowCornerRadius(value);
1055 internal void UpdateStyle()
1058 if (styleName == null) newStyle = ThemeManager.GetStyle(GetType());
1059 else newStyle = ThemeManager.GetStyle(styleName);
1061 if (newStyle != null && (viewStyle == null || viewStyle.GetType() == newStyle.GetType())) ApplyStyle(newStyle);
1065 /// you can override it to clean-up your own resources.
1067 /// <param name="type">DisposeTypes</param>
1068 /// <since_tizen> 3 </since_tizen>
1069 protected override void Dispose(DisposeTypes type)
1076 //_mergedStyle = null;
1078 if (type == DisposeTypes.Explicit)
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)
1086 ThemeManager.ThemeChanged -= OnThemeChanged;
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.
1095 DisConnectFromSignals();
1098 foreach (View view in Children)
1100 view.InternalParent = null;
1106 /// This will not be public opened.
1107 [EditorBrowsable(EditorBrowsableState.Never)]
1108 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1110 Interop.View.delete_View(swigCPtr);
1114 /// The touch event handler for ControlState.
1115 /// Please change ControlState value by touch state if needed.
1117 [EditorBrowsable(EditorBrowsableState.Never)]
1118 protected virtual bool HandleControlStateOnTouch(Touch touch)
1120 switch(touch.GetState(0))
1122 case PointStateType.Down:
1123 ControlState += ControlState.Pressed;
1125 case PointStateType.Interrupted:
1126 case PointStateType.Up:
1127 if (ControlState.Contains(ControlState.Pressed))
1129 ControlState -= ControlState.Pressed;
1139 private void DisConnectFromSignals()
1141 // Save current CPtr.
1142 global::System.Runtime.InteropServices.HandleRef currentCPtr = swigCPtr;
1144 // Use BaseHandle CPtr as current might have been deleted already in derived classes.
1145 swigCPtr = GetBaseHandleCPtrHandleRef;
1147 if (_onRelayoutEventCallback != null)
1149 this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
1150 _onRelayoutEventCallback = null;
1153 if (_offWindowEventCallback != null)
1155 this.OffWindowSignal().Disconnect(_offWindowEventCallback);
1156 _offWindowEventCallback = null;
1159 if (_onWindowEventCallback != null)
1161 this.OnWindowSignal().Disconnect(_onWindowEventCallback);
1162 _onWindowEventCallback = null;
1165 if (_wheelEventCallback != null)
1167 this.WheelEventSignal().Disconnect(_wheelEventCallback);
1170 if (WindowWheelEventHandler != null)
1172 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
1175 if (_hoverEventCallback != null)
1177 this.HoveredSignal().Disconnect(_hoverEventCallback);
1180 if (_interceptTouchDataCallback != null)
1182 this.InterceptTouchSignal().Disconnect(_interceptTouchDataCallback);
1185 if (_touchDataCallback != null)
1187 this.TouchSignal().Disconnect(_touchDataCallback);
1190 if (_ResourcesLoadedCallback != null)
1192 this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
1193 _ResourcesLoadedCallback = null;
1196 if (_keyCallback != null)
1198 this.KeyEventSignal().Disconnect(_keyCallback);
1201 if (_keyInputFocusLostCallback != null)
1203 this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
1206 if (_keyInputFocusGainedCallback != null)
1208 this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
1211 if (_backgroundResourceLoadedCallback != null)
1213 this.ResourcesLoadedSignal().Disconnect(_backgroundResourceLoadedCallback);
1214 _backgroundResourceLoadedCallback = null;
1217 if (_onWindowSendEventCallback != null)
1219 this.OnWindowSignal().Disconnect(_onWindowSendEventCallback);
1222 // BaseHandle CPtr is used in Registry and there is danger of deletion if we keep using it here.
1223 // Restore current CPtr.
1224 swigCPtr = currentCPtr;
1227 private View ConvertIdToView(uint id)
1229 View view = GetParent()?.FindCurrentChildById(id);
1231 //If we can't find the parent's children, find in the top layer.
1234 Container parent = GetParent();
1235 while ((parent is View) && (parent != null))
1237 parent = parent.GetParent();
1238 if (parent is Layer)
1240 view = parent.FindCurrentChildById(id);
1249 private void LoadTransitions()
1251 foreach (string str in transitionNames)
1253 string resourceName = str + ".xaml";
1254 Transition trans = null;
1256 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
1258 string likelyResourcePath = resource + "animation/" + resourceName;
1260 if (File.Exists(likelyResourcePath))
1262 trans = Xaml.Extensions.LoadObject<Transition>(likelyResourcePath);
1266 transDictionary.Add(trans.Name, trans);
1271 private void OnScaleChanged(float x, float y, float z)
1273 Scale = new Vector3(x, y, z);
1276 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1278 BackgroundColor = new Color(r, g, b, a);
1281 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1283 Padding = new Extents(start, end, top, bottom);
1286 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1288 Margin = new Extents(start, end, top, bottom);
1291 private void OnColorChanged(float r, float g, float b, float a)
1293 Color = new Color(r, g, b, a);
1296 private void OnAnchorPointChanged(float x, float y, float z)
1298 AnchorPoint = new Position(x, y, z);
1301 private void OnCellIndexChanged(float x, float y)
1303 CellIndex = new Vector2(x, y);
1306 private void OnFlexMarginChanged(float x, float y, float z, float w)
1308 FlexMargin = new Vector4(x, y, z, w);
1311 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1313 PaddingEX = new Extents(start, end, top, bottom);
1316 private void OnSizeModeFactorChanged(float x, float y, float z)
1318 SizeModeFactor = new Vector3(x, y, z);
1321 private void UpdateShadowCornerRadius(float value)
1323 // TODO Update corner radius property only whe DALi supports visual property update.
1324 PropertyMap map = new PropertyMap();
1326 if (Tizen.NUI.Object.GetProperty(swigCPtr, View.Property.SHADOW).Get(map) && !map.Empty())
1328 map[Visual.Property.CornerRadius] = new PropertyValue(value);
1330 Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.SHADOW, new PropertyValue(map));
1334 private bool EmptyOnTouch(object target, TouchEventArgs args)