2 * Copyright(c) 2021 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.Collections.Generic;
20 using System.ComponentModel;
21 using System.Runtime.CompilerServices;
23 namespace Tizen.NUI.BaseComponents
26 /// View is the base class for all views.
28 /// <since_tizen> 3 </since_tizen>
29 public partial class View
31 private static bool blockSetDirty = false;
32 private ViewSelectorData selectorData;
33 private HashSet<string> dirtyPropertySet;
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 LayoutLength SuggestedMinimumWidth
58 float result = Interop.Actor.GetSuggestedMinimumWidth(SwigCPtr);
59 if (NDalicPINVOKE.SWIGPendingException.Pending)
60 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
61 return new LayoutLength(result);
65 internal LayoutLength SuggestedMinimumHeight
69 float result = Interop.Actor.GetSuggestedMinimumHeight(SwigCPtr);
70 if (NDalicPINVOKE.SWIGPendingException.Pending)
71 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72 return new LayoutLength(result);
76 internal float WorldPositionX
80 float returnValue = 0.0f;
81 PropertyValue wordPositionX = GetProperty(View.Property.WorldPositionX);
82 wordPositionX?.Get(out returnValue);
83 wordPositionX?.Dispose();
88 internal float WorldPositionY
92 float returnValue = 0.0f;
93 PropertyValue wordPositionY = GetProperty(View.Property.WorldPositionY);
94 wordPositionY?.Get(out returnValue);
95 wordPositionY?.Dispose();
100 internal float WorldPositionZ
104 float returnValue = 0.0f;
105 PropertyValue wordPositionZ = GetProperty(View.Property.WorldPositionZ);
106 wordPositionZ?.Get(out returnValue);
107 wordPositionZ?.Dispose();
112 internal bool FocusState
116 return IsKeyboardFocusable();
120 SetKeyboardFocusable(value);
124 internal void SetLayout(LayoutItem layout)
126 Window.Instance.LayoutController.CreateProcessCallback();
127 this.layout = layout;
128 this.layout?.AttachToOwner(this);
129 this.layout?.RequestLayout();
132 internal void AttachTransitionsToChildren(LayoutTransition transition)
134 // Iterate children, adding the transition unless a transition
135 // for the same condition and property has already been
137 foreach (View view in Children)
139 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
143 internal float ParentOriginX
147 float returnValue = 0.0f;
148 PropertyValue parentOriginX = GetProperty(View.Property.ParentOriginX);
149 parentOriginX?.Get(out returnValue);
150 parentOriginX?.Dispose();
155 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
156 SetProperty(View.Property.ParentOriginX, setValue);
158 NotifyPropertyChanged();
162 internal float ParentOriginY
166 float returnValue = 0.0f;
167 PropertyValue parentOriginY = GetProperty(View.Property.ParentOriginY);
168 parentOriginY?.Get(out returnValue);
169 parentOriginY?.Dispose();
174 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
175 SetProperty(View.Property.ParentOriginY, setValue);
177 NotifyPropertyChanged();
181 internal float ParentOriginZ
185 float returnValue = 0.0f;
186 PropertyValue parentOriginZ = GetProperty(View.Property.ParentOriginZ);
187 parentOriginZ?.Get(out returnValue);
188 parentOriginZ?.Dispose();
193 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
194 SetProperty(View.Property.ParentOriginZ, setValue);
196 NotifyPropertyChanged();
200 internal float PivotPointX
204 float returnValue = 0.0f;
205 PropertyValue anchorPointX = GetProperty(View.Property.AnchorPointX);
206 anchorPointX?.Get(out returnValue);
207 anchorPointX?.Dispose();
212 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
213 SetProperty(View.Property.AnchorPointX, setValue);
218 internal float PivotPointY
222 float returnValue = 0.0f;
223 PropertyValue anchorPointY = GetProperty(View.Property.AnchorPointY);
224 anchorPointY?.Get(out returnValue);
225 anchorPointY?.Dispose();
230 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
231 SetProperty(View.Property.AnchorPointY, setValue);
236 internal float PivotPointZ
240 float returnValue = 0.0f;
241 PropertyValue anchorPointZ = GetProperty(View.Property.AnchorPointZ);
242 anchorPointZ?.Get(out returnValue);
243 anchorPointZ?.Dispose();
248 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
249 SetProperty(View.Property.AnchorPointZ, setValue);
254 internal Matrix WorldMatrix
258 Matrix returnValue = new Matrix();
259 PropertyValue wordMatrix = GetProperty(View.Property.WorldMatrix);
260 wordMatrix?.Get(returnValue);
261 wordMatrix?.Dispose();
267 /// Indicates that this View should listen Touch event to handle its ControlState.
269 private bool enableControlState = false;
271 private int LeftFocusableViewId
276 PropertyValue leftFocusableViewId = GetProperty(View.Property.LeftFocusableViewId);
277 leftFocusableViewId?.Get(out returnValue);
278 leftFocusableViewId?.Dispose();
283 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
284 SetProperty(View.Property.LeftFocusableViewId, setValue);
289 private int RightFocusableViewId
294 PropertyValue rightFocusableViewId = GetProperty(View.Property.RightFocusableViewId);
295 rightFocusableViewId?.Get(out returnValue);
296 rightFocusableViewId?.Dispose();
301 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
302 SetProperty(View.Property.RightFocusableViewId, setValue);
307 private int UpFocusableViewId
312 PropertyValue upFocusableViewId = GetProperty(View.Property.UpFocusableViewId);
313 upFocusableViewId?.Get(out returnValue);
314 upFocusableViewId?.Dispose();
319 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
320 SetProperty(View.Property.UpFocusableViewId, setValue);
325 private int DownFocusableViewId
330 PropertyValue downFocusableViewId = GetProperty(View.Property.DownFocusableViewId);
331 downFocusableViewId?.Get(out returnValue);
332 downFocusableViewId?.Dispose();
337 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
338 SetProperty(View.Property.DownFocusableViewId, setValue);
343 internal void Raise()
345 var parentChildren = GetParent()?.Children;
347 if (parentChildren != null)
349 int currentIndex = parentChildren.IndexOf(this);
351 // If the view is not already the last item in the list.
352 if (currentIndex >= 0 && currentIndex < parentChildren.Count - 1)
354 View temp = parentChildren[currentIndex + 1];
355 parentChildren[currentIndex + 1] = this;
356 parentChildren[currentIndex] = temp;
358 Interop.NDalic.Raise(SwigCPtr);
359 if (NDalicPINVOKE.SWIGPendingException.Pending)
360 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
365 internal void Lower()
367 var parentChildren = GetParent()?.Children;
369 if (parentChildren != null)
371 int currentIndex = parentChildren.IndexOf(this);
373 // If the view is not already the first item in the list.
374 if (currentIndex > 0 && currentIndex < parentChildren.Count)
376 View temp = parentChildren[currentIndex - 1];
377 parentChildren[currentIndex - 1] = this;
378 parentChildren[currentIndex] = temp;
380 Interop.NDalic.Lower(SwigCPtr);
381 if (NDalicPINVOKE.SWIGPendingException.Pending)
382 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
388 /// Raises the view to above the target view.
390 /// <remarks>The sibling order of views within the parent will be updated automatically.
391 /// Views on the level above the target view will still be shown above this view.
392 /// Raising this view above views with the same sibling order as each other will raise this view above them.
393 /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
395 /// <param name="target">Will be raised above this view.</param>
396 internal void RaiseAbove(View target)
398 var parentChildren = GetParent()?.Children;
400 if (parentChildren != null)
402 int currentIndex = parentChildren.IndexOf(this);
403 int targetIndex = parentChildren.IndexOf(target);
405 if (currentIndex < 0 || targetIndex < 0 ||
406 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
408 NUILog.Error("index should be bigger than 0 and less than children of layer count");
411 // If the currentIndex is less than the target index and the target has the same parent.
412 if (currentIndex < targetIndex)
414 parentChildren.Remove(this);
415 parentChildren.Insert(targetIndex, this);
417 Interop.NDalic.RaiseAbove(SwigCPtr, View.getCPtr(target));
418 if (NDalicPINVOKE.SWIGPendingException.Pending)
419 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
426 /// Lowers the view to below the target view.
428 /// <remarks>The sibling order of views within the parent will be updated automatically.
429 /// Lowering this view below views with the same sibling order as each other will lower this view above them.
430 /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
432 /// <param name="target">Will be lowered below this view.</param>
433 internal void LowerBelow(View target)
435 var parentChildren = GetParent()?.Children;
437 if (parentChildren != null)
439 int currentIndex = parentChildren.IndexOf(this);
440 int targetIndex = parentChildren.IndexOf(target);
441 if (currentIndex < 0 || targetIndex < 0 ||
442 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
444 NUILog.Error("index should be bigger than 0 and less than children of layer count");
448 // If the currentIndex is not already the 0th index and the target has the same parent.
449 if ((currentIndex != 0) && (targetIndex != -1) &&
450 (currentIndex > targetIndex))
452 parentChildren.Remove(this);
453 parentChildren.Insert(targetIndex, this);
455 Interop.NDalic.LowerBelow(SwigCPtr, View.getCPtr(target));
456 if (NDalicPINVOKE.SWIGPendingException.Pending)
457 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
463 internal string GetName()
465 string ret = Interop.Actor.GetName(SwigCPtr);
466 if (NDalicPINVOKE.SWIGPendingException.Pending)
467 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
471 internal void SetName(string name)
473 Interop.Actor.SetName(SwigCPtr, name);
474 if (NDalicPINVOKE.SWIGPendingException.Pending)
475 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
478 internal uint GetId()
480 uint ret = Interop.Actor.GetId(SwigCPtr);
481 if (NDalicPINVOKE.SWIGPendingException.Pending)
482 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
486 internal bool IsRoot()
488 bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
489 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
493 internal bool OnWindow()
495 bool ret = Interop.Actor.OnStage(SwigCPtr);
496 if (NDalicPINVOKE.SWIGPendingException.Pending)
497 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
501 internal View FindChildById(uint id)
503 //to fix memory leak issue, match the handle count with native side.
504 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
505 View ret = this.GetInstanceSafely<View>(cPtr);
506 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
510 internal override View FindCurrentChildById(uint id)
512 return FindChildById(id);
515 internal void SetParentOrigin(Vector3 origin)
517 Interop.ActorInternal.SetParentOrigin(SwigCPtr, Vector3.getCPtr(origin));
518 if (NDalicPINVOKE.SWIGPendingException.Pending)
519 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
522 internal Vector3 GetCurrentParentOrigin()
524 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentParentOrigin(SwigCPtr), true);
525 if (NDalicPINVOKE.SWIGPendingException.Pending)
526 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
530 internal void SetAnchorPoint(Vector3 anchorPoint)
532 Interop.Actor.SetAnchorPoint(SwigCPtr, Vector3.getCPtr(anchorPoint));
533 if (NDalicPINVOKE.SWIGPendingException.Pending)
534 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
537 internal Vector3 GetCurrentAnchorPoint()
539 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentAnchorPoint(SwigCPtr), true);
540 if (NDalicPINVOKE.SWIGPendingException.Pending)
541 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
545 internal void SetSize(float width, float height)
547 Interop.ActorInternal.SetSize(SwigCPtr, width, height);
548 if (NDalicPINVOKE.SWIGPendingException.Pending)
549 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
552 internal void SetSize(float width, float height, float depth)
554 Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
555 if (NDalicPINVOKE.SWIGPendingException.Pending)
556 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
559 internal void SetSize(Vector2 size)
561 Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
562 if (NDalicPINVOKE.SWIGPendingException.Pending)
563 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
566 internal void SetSize(Vector3 size)
568 Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
569 if (NDalicPINVOKE.SWIGPendingException.Pending)
570 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
573 internal Vector3 GetTargetSize()
575 Vector3 ret = new Vector3(Interop.ActorInternal.GetTargetSize(SwigCPtr), true);
576 if (NDalicPINVOKE.SWIGPendingException.Pending)
577 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
581 internal Size2D GetCurrentSize()
583 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
584 if (NDalicPINVOKE.SWIGPendingException.Pending)
585 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
586 Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
591 internal Size2D GetCurrentSizeFloat()
593 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
594 if (NDalicPINVOKE.SWIGPendingException.Pending)
595 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
599 internal Vector3 GetNaturalSize()
601 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
602 if (NDalicPINVOKE.SWIGPendingException.Pending)
603 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
607 internal void SetPosition(float x, float y)
609 Interop.ActorInternal.SetPosition(SwigCPtr, x, y);
610 if (NDalicPINVOKE.SWIGPendingException.Pending)
611 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
614 internal void SetPosition(float x, float y, float z)
616 Interop.ActorInternal.SetPosition(SwigCPtr, x, y, z);
617 if (NDalicPINVOKE.SWIGPendingException.Pending)
618 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621 internal void SetPosition(Vector3 position)
623 Interop.ActorInternal.SetPosition(SwigCPtr, Vector3.getCPtr(position));
624 if (NDalicPINVOKE.SWIGPendingException.Pending)
625 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628 internal void SetX(float x)
630 Interop.ActorInternal.SetX(SwigCPtr, x);
631 if (NDalicPINVOKE.SWIGPendingException.Pending)
632 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
635 internal void SetY(float y)
637 Interop.ActorInternal.SetY(SwigCPtr, y);
638 if (NDalicPINVOKE.SWIGPendingException.Pending)
639 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
642 internal void SetZ(float z)
644 Interop.ActorInternal.SetZ(SwigCPtr, z);
645 if (NDalicPINVOKE.SWIGPendingException.Pending)
646 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649 internal void TranslateBy(Vector3 distance)
651 Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
652 if (NDalicPINVOKE.SWIGPendingException.Pending)
653 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656 internal Position GetCurrentPosition()
658 Position ret = new Position(Interop.Actor.GetCurrentPosition(SwigCPtr), true);
659 if (NDalicPINVOKE.SWIGPendingException.Pending)
660 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
664 internal Vector3 GetCurrentWorldPosition()
666 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldPosition(SwigCPtr), true);
667 if (NDalicPINVOKE.SWIGPendingException.Pending)
668 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
672 internal void SetInheritPosition(bool inherit)
674 Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
675 if (NDalicPINVOKE.SWIGPendingException.Pending)
676 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
679 internal bool IsPositionInherited()
681 bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
682 if (NDalicPINVOKE.SWIGPendingException.Pending)
683 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
687 internal void SetOrientation(Degree angle, Vector3 axis)
689 Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
690 if (NDalicPINVOKE.SWIGPendingException.Pending)
691 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
694 internal void SetOrientation(Radian angle, Vector3 axis)
696 Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
697 if (NDalicPINVOKE.SWIGPendingException.Pending)
698 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
701 internal void SetOrientation(Rotation orientation)
703 Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
704 if (NDalicPINVOKE.SWIGPendingException.Pending)
705 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
708 internal Rotation GetCurrentOrientation()
710 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
711 if (NDalicPINVOKE.SWIGPendingException.Pending)
712 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
716 internal void SetInheritOrientation(bool inherit)
718 Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
719 if (NDalicPINVOKE.SWIGPendingException.Pending)
720 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
723 internal bool IsOrientationInherited()
725 bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
726 if (NDalicPINVOKE.SWIGPendingException.Pending)
727 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
731 internal Rotation GetCurrentWorldOrientation()
733 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
734 if (NDalicPINVOKE.SWIGPendingException.Pending)
735 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
739 internal void SetScale(float scale)
741 Interop.ActorInternal.SetScale(SwigCPtr, scale);
742 if (NDalicPINVOKE.SWIGPendingException.Pending)
743 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
746 internal void SetScale(float scaleX, float scaleY, float scaleZ)
748 Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
749 if (NDalicPINVOKE.SWIGPendingException.Pending)
750 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
753 internal void SetScale(Vector3 scale)
755 Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
756 if (NDalicPINVOKE.SWIGPendingException.Pending)
757 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
760 internal Vector3 GetCurrentScale()
762 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentScale(SwigCPtr), true);
763 if (NDalicPINVOKE.SWIGPendingException.Pending)
764 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
768 internal Vector3 GetCurrentWorldScale()
770 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldScale(SwigCPtr), true);
771 if (NDalicPINVOKE.SWIGPendingException.Pending)
772 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
776 internal void SetInheritScale(bool inherit)
778 Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
779 if (NDalicPINVOKE.SWIGPendingException.Pending)
780 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
783 internal bool IsScaleInherited()
785 bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
786 if (NDalicPINVOKE.SWIGPendingException.Pending)
787 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
791 internal Matrix GetCurrentWorldMatrix()
793 Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
794 if (NDalicPINVOKE.SWIGPendingException.Pending)
795 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
799 internal void SetVisible(bool visible)
801 Interop.Actor.SetVisible(SwigCPtr, visible);
802 if (NDalicPINVOKE.SWIGPendingException.Pending)
803 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
806 internal bool IsVisible()
808 bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
809 if (NDalicPINVOKE.SWIGPendingException.Pending)
810 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
814 internal void SetOpacity(float opacity)
816 Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
817 if (NDalicPINVOKE.SWIGPendingException.Pending)
818 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
821 internal float GetCurrentOpacity()
823 float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
824 if (NDalicPINVOKE.SWIGPendingException.Pending)
825 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
829 internal Vector4 GetCurrentColor()
831 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentColor(SwigCPtr), true);
832 if (NDalicPINVOKE.SWIGPendingException.Pending)
833 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
836 internal ColorMode GetColorMode()
838 ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
839 if (NDalicPINVOKE.SWIGPendingException.Pending)
840 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
844 internal Vector4 GetCurrentWorldColor()
846 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentWorldColor(SwigCPtr), true);
847 if (NDalicPINVOKE.SWIGPendingException.Pending)
848 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
852 internal void SetDrawMode(DrawModeType drawMode)
854 Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
855 if (NDalicPINVOKE.SWIGPendingException.Pending)
856 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
859 internal DrawModeType GetDrawMode()
861 DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
862 if (NDalicPINVOKE.SWIGPendingException.Pending)
863 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
867 internal void SetKeyboardFocusable(bool focusable)
869 Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
870 if (NDalicPINVOKE.SWIGPendingException.Pending)
871 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
874 internal bool IsKeyboardFocusable()
876 bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
877 if (NDalicPINVOKE.SWIGPendingException.Pending)
878 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
882 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
884 Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
885 if (NDalicPINVOKE.SWIGPendingException.Pending)
886 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
889 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
891 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
892 if (NDalicPINVOKE.SWIGPendingException.Pending)
893 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
897 internal Vector3 GetSizeModeFactor()
899 Vector3 ret = new Vector3(Interop.Actor.GetSizeModeFactor(SwigCPtr), true);
900 if (NDalicPINVOKE.SWIGPendingException.Pending)
901 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
905 internal void SetMinimumSize(Vector2 size)
907 Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
908 if (NDalicPINVOKE.SWIGPendingException.Pending)
909 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
912 internal Vector2 GetMinimumSize()
914 Vector2 ret = new Vector2(Interop.ActorInternal.GetMinimumSize(SwigCPtr), true);
915 if (NDalicPINVOKE.SWIGPendingException.Pending)
916 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
920 internal void SetMaximumSize(Vector2 size)
922 Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
923 if (NDalicPINVOKE.SWIGPendingException.Pending)
924 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
927 internal Vector2 GetMaximumSize()
929 Vector2 ret = new Vector2(Interop.ActorInternal.GetMaximumSize(SwigCPtr), true);
930 if (NDalicPINVOKE.SWIGPendingException.Pending)
931 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
935 internal int GetHierarchyDepth()
937 int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
938 if (NDalicPINVOKE.SWIGPendingException.Pending)
939 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
943 internal uint GetRendererCount()
945 uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
946 if (NDalicPINVOKE.SWIGPendingException.Pending)
947 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
951 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
953 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
956 internal bool IsTopLevelView()
958 if (GetParent() is Layer)
965 internal void SetKeyInputFocus()
967 Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
968 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
971 internal void ClearKeyInputFocus()
973 Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
974 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
977 internal PinchGestureDetector GetPinchGestureDetector()
979 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
980 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
984 internal PanGestureDetector GetPanGestureDetector()
986 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
987 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
991 internal TapGestureDetector GetTapGestureDetector()
993 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
994 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
998 internal LongPressGestureDetector GetLongPressGestureDetector()
1000 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
1001 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1005 internal IntPtr GetPtrfromView()
1007 return (IntPtr)SwigCPtr;
1010 internal void RemoveChild(View child)
1012 // Do actual child removal
1013 Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1014 if (NDalicPINVOKE.SWIGPendingException.Pending)
1015 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1017 Children.Remove(child);
1018 child.InternalParent = null;
1020 if (ChildRemoved != null)
1022 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1026 ChildRemoved(this, e);
1031 /// Removes the layout from this View.
1033 internal void ResetLayout()
1038 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1040 return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1043 /// TODO open as a protected level
1044 internal virtual void ApplyCornerRadius()
1046 if (backgroundExtraData == null) return;
1048 // TODO Fix to support Vector4 for corner radius after dali support it.
1049 // Current code only gets first argument of Vector4.
1050 float cornerRadius = backgroundExtraData.CornerRadius?.X ?? 0.0f;
1052 // Apply to the background visual
1053 PropertyMap backgroundMap = new PropertyMap();
1054 PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
1055 if (background.Get(backgroundMap) && !backgroundMap.Empty())
1057 backgroundMap[Visual.Property.CornerRadius] = new PropertyValue(cornerRadius);
1058 backgroundMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1059 var temp = new PropertyValue(backgroundMap);
1060 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
1063 backgroundMap.Dispose();
1064 background.Dispose();
1066 // Apply to the shadow visual
1067 PropertyMap shadowMap = new PropertyMap();
1068 PropertyValue shadow = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.SHADOW);
1069 if (shadow.Get(shadowMap) && !shadowMap.Empty())
1071 shadowMap[Visual.Property.CornerRadius] = new PropertyValue(cornerRadius);
1072 shadowMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1073 var temp = new PropertyValue(shadowMap);
1074 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.SHADOW, temp);
1077 shadowMap.Dispose();
1082 /// Get selector value from the triggerable selector or related property.
1084 internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1086 var selector = triggerableSelector?.Get();
1087 if (selector != null)
1092 var value = (T)GetValue(relatedProperty);
1093 return value == null ? null : new Selector<T>(value);
1097 /// you can override it to clean-up your own resources.
1099 /// <param name="type">DisposeTypes</param>
1100 /// <since_tizen> 3 </since_tizen>
1101 protected override void Dispose(DisposeTypes type)
1108 //_mergedStyle = null;
1110 if (type == DisposeTypes.Explicit)
1113 //Release your own managed resources here.
1114 //You should release all of your own disposable objects here.
1115 selectorData?.Reset(this);
1116 if (themeChangeSensitive)
1118 ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1122 //Release your own unmanaged resources here.
1123 //You should not access any managed member here except static instance.
1124 //because the execution order of Finalizes is non-deterministic.
1127 DisConnectFromSignals();
1130 foreach (View view in Children)
1132 view.InternalParent = null;
1138 /// This will not be public opened.
1139 [EditorBrowsable(EditorBrowsableState.Never)]
1140 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1142 Interop.View.DeleteView(swigCPtr);
1146 /// The touch event handler for ControlState.
1147 /// Please change ControlState value by touch state if needed.
1149 /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1150 [EditorBrowsable(EditorBrowsableState.Never)]
1151 protected virtual bool HandleControlStateOnTouch(Touch touch)
1155 throw new global::System.ArgumentNullException(nameof(touch));
1158 switch (touch.GetState(0))
1160 case PointStateType.Down:
1161 ControlState += ControlState.Pressed;
1163 case PointStateType.Interrupted:
1164 case PointStateType.Up:
1165 if (ControlState.Contains(ControlState.Pressed))
1167 ControlState -= ControlState.Pressed;
1177 /// Call this method from a child class to notify that a change happened on a property.
1179 /// <param name="propertyName">The name of the property that changed.</param>
1180 [EditorBrowsable(EditorBrowsableState.Never)]
1181 protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
1183 base.OnPropertyChanged(propertyName);
1187 dirtyPropertySet?.Add(propertyName);
1191 private void DisConnectFromSignals()
1193 // Save current CPtr.
1194 global::System.Runtime.InteropServices.HandleRef currentCPtr = SwigCPtr;
1196 // Use BaseHandle CPtr as current might have been deleted already in derived classes.
1197 SwigCPtr = GetBaseHandleCPtrHandleRef;
1199 if (onRelayoutEventCallback != null)
1201 ViewSignal signal = this.OnRelayoutSignal();
1202 signal?.Disconnect(onRelayoutEventCallback);
1204 onRelayoutEventCallback = null;
1207 if (offWindowEventCallback != null)
1209 ViewSignal signal = this.OffWindowSignal();
1210 signal?.Disconnect(offWindowEventCallback);
1212 offWindowEventCallback = null;
1215 if (onWindowEventCallback != null)
1217 ViewSignal signal = this.OnWindowSignal();
1218 signal?.Disconnect(onWindowEventCallback);
1220 onWindowEventCallback = null;
1223 if (wheelEventCallback != null)
1225 WheelSignal signal = this.WheelEventSignal();
1226 signal?.Disconnect(wheelEventCallback);
1230 if (WindowWheelEventHandler != null)
1232 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
1235 if (hoverEventCallback != null)
1237 HoverSignal signal = this.HoveredSignal();
1238 signal?.Disconnect(hoverEventCallback);
1242 if (interceptTouchDataCallback != null)
1244 TouchDataSignal signal = this.InterceptTouchSignal();
1245 signal?.Disconnect(interceptTouchDataCallback);
1249 if (touchDataCallback != null)
1251 TouchDataSignal signal = this.TouchSignal();
1252 signal?.Disconnect(touchDataCallback);
1256 if (ResourcesLoadedCallback != null)
1258 ViewSignal signal = this.ResourcesLoadedSignal();
1259 signal?.Disconnect(ResourcesLoadedCallback);
1261 ResourcesLoadedCallback = null;
1264 if (keyCallback != null)
1266 ControlKeySignal signal = this.KeyEventSignal();
1267 signal?.Disconnect(keyCallback);
1271 if (keyInputFocusLostCallback != null)
1273 KeyInputFocusSignal signal = this.KeyInputFocusLostSignal();
1274 signal?.Disconnect(keyInputFocusLostCallback);
1278 if (keyInputFocusGainedCallback != null)
1280 KeyInputFocusSignal signal = this.KeyInputFocusGainedSignal();
1281 signal?.Disconnect(keyInputFocusGainedCallback);
1285 if (backgroundResourceLoadedCallback != null)
1287 ViewSignal signal = this.ResourcesLoadedSignal();
1288 signal?.Disconnect(backgroundResourceLoadedCallback);
1290 backgroundResourceLoadedCallback = null;
1293 if (onWindowSendEventCallback != null)
1295 ViewSignal signal = this.OnWindowSignal();
1296 signal?.Disconnect(onWindowSendEventCallback);
1298 onWindowSendEventCallback = null;
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;
1307 /// Apply initial style to the view.
1309 [EditorBrowsable(EditorBrowsableState.Never)]
1310 protected void InitializeStyle(ViewStyle style = null)
1312 if (style != null) ApplyStyle(style); // Use given style
1313 else UpdateStyle(); // Use style in the current theme
1316 private View ConvertIdToView(uint id)
1318 View view = GetParent()?.FindCurrentChildById(id);
1320 //If we can't find the parent's children, find in the top layer.
1323 Container parent = GetParent();
1324 while ((parent is View) && (parent != null))
1326 parent = parent.GetParent();
1327 if (parent is Layer)
1329 view = parent.FindCurrentChildById(id);
1338 private void OnScaleChanged(float x, float y, float z)
1340 Scale = new Vector3(x, y, z);
1343 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1345 BackgroundColor = new Color(r, g, b, a);
1348 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1350 Padding = new Extents(start, end, top, bottom);
1353 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1355 Margin = new Extents(start, end, top, bottom);
1358 private void OnColorChanged(float r, float g, float b, float a)
1360 Color = new Color(r, g, b, a);
1363 private void OnAnchorPointChanged(float x, float y, float z)
1365 AnchorPoint = new Position(x, y, z);
1368 private void OnCellIndexChanged(float x, float y)
1370 CellIndex = new Vector2(x, y);
1373 private void OnFlexMarginChanged(float x, float y, float z, float w)
1375 FlexMargin = new Vector4(x, y, z, w);
1378 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1380 PaddingEX = new Extents(start, end, top, bottom);
1383 private void OnSizeModeFactorChanged(float x, float y, float z)
1385 SizeModeFactor = new Vector3(x, y, z);
1388 private bool EmptyOnTouch(object target, TouchEventArgs args)
1393 private void UpdateStyle()
1396 if (string.IsNullOrEmpty(styleName)) newStyle = ThemeManager.GetStyleWithoutClone(GetType());
1397 else newStyle = ThemeManager.GetStyleWithoutClone(styleName);
1399 if (newStyle != null)
1401 blockSetDirty = true;
1402 ApplyStyle(newStyle);
1403 blockSetDirty = false;
1407 private ViewSelectorData EnsureSelectorData() => selectorData ?? (selectorData = new ViewSelectorData());